Loading filetree.module +25 −13 Changes for filetree.module: 25 added lines, 13 removed lines. Original line number Diff line number Diff line Loading @@ -55,6 +55,17 @@ function filetree_tokens($type, $tokens, array $data = array(), array $options = case 'modified': $replacements[$original] = format_date(filemtime($data['filepath']), 'filetree'); break; case 'link': if (isset($data['filename'])) { $name = isset($data['descriptions'][$data['filename']]) ? $data['descriptions'][$data['filename']] : token_replace($data['params']['filename'], array('filepath' => $data['filepath'])); $url = $data['params']['absolute'] ? file_create_url($data['filepath']) : substr(file_create_url($data['filepath']), strlen($GLOBALS['base_url'] . '/')); $replacements[$original] = l($name, urldecode($url)); } break; } } } Loading Loading @@ -108,6 +119,8 @@ function _filetree_tips($filter, $format, $long = FALSE) { '!url' => url('admin/config/regional/date-time'), )), ))); $output .= '<p>' . t('You may format the way each file is listed via the "fileformat" option. The tokens above are available, in addition to a "%link" option, which renders the "filename" token. For example:') . '</p>'; $output .= '<blockquote>[filetree dir="some-directory" fileformat="%link - %size"]</blockquote>'; $output .= '<p>' . t('You can also read a <a href="http://drupal.org/project/filetree">detailed explanation of these options</a>.'). '</p>'; } return $output; Loading @@ -133,6 +146,7 @@ function _filetree_process($text, $filter, $format, $langcode, $cache, $cache_id 'dirtitle' => '%filename', 'filename' => '%filename', 'filetitle' => '%filename', 'fileformat' => '%link', 'animation' => TRUE, ); Loading Loading @@ -177,7 +191,7 @@ function _filetree_process($text, $filter, $format, $langcode, $cache, $cache_id $params[$key]['exclude'] = implode("\n", $params[$key]['exclude']); // Convert params containing token values. foreach (array('dirname', 'dirtitle', 'filename', 'filetitle') as $token_param) { foreach (array('dirname', 'dirtitle', 'filename', 'filetitle', 'fileformat') as $token_param) { $params[$key][$token_param] = preg_replace('/%(\w+)/', '[filetree:$1]', $params[$key][$token_param]); } Loading Loading @@ -213,30 +227,28 @@ function _filetree_list_files($dir, $params) { // - additional paths from the "exclude" param if ($filename[0] != '.' && !drupal_match_path($filename, $params['exclude'])) { $filepath = "$dir/$filename"; $token_args = array( 'filename' => $filename, 'filepath' => $filepath, 'descriptions' => $descriptions, 'params' => $params, ); // It's a folder. if (is_dir($filepath)) { $folders[$filename] = array( 'data' => isset($descriptions[$filename]) ? $descriptions[$filename] : token_replace($params['dirname'], array('filepath' => $filepath)), 'data' => isset($descriptions[$filename]) ? $descriptions[$filename] : token_replace($params['dirname'], $token_args), 'children' => _filetree_list_files($filepath, $params), 'title' => token_replace($params['dirtitle'], array('filepath' => $filepath)), 'title' => token_replace($params['dirtitle'], $token_args), 'class' => array('folder'), ); } // It's a file. else { $name = isset($descriptions[$filename]) ? $descriptions[$filename] : token_replace($params['filename'], array('filepath' => $filepath)); $url = $params['absolute'] ? file_create_url($filepath) : substr(file_create_url($filepath), strlen($GLOBALS['base_url'] . '/')); $files[$filename] = array( 'data' => l($name, urldecode($url)), 'title' => token_replace($params['filetitle'], array('filepath' => $filepath)), 'data' => token_replace($params['fileformat'], $token_args), 'title' => token_replace($params['filetitle'], $token_args), 'class' => array(_filetree_icon(pathinfo($filename, PATHINFO_EXTENSION))), ); } Loading Loading
filetree.module +25 −13 Changes for filetree.module: 25 added lines, 13 removed lines. Original line number Diff line number Diff line Loading @@ -55,6 +55,17 @@ function filetree_tokens($type, $tokens, array $data = array(), array $options = case 'modified': $replacements[$original] = format_date(filemtime($data['filepath']), 'filetree'); break; case 'link': if (isset($data['filename'])) { $name = isset($data['descriptions'][$data['filename']]) ? $data['descriptions'][$data['filename']] : token_replace($data['params']['filename'], array('filepath' => $data['filepath'])); $url = $data['params']['absolute'] ? file_create_url($data['filepath']) : substr(file_create_url($data['filepath']), strlen($GLOBALS['base_url'] . '/')); $replacements[$original] = l($name, urldecode($url)); } break; } } } Loading Loading @@ -108,6 +119,8 @@ function _filetree_tips($filter, $format, $long = FALSE) { '!url' => url('admin/config/regional/date-time'), )), ))); $output .= '<p>' . t('You may format the way each file is listed via the "fileformat" option. The tokens above are available, in addition to a "%link" option, which renders the "filename" token. For example:') . '</p>'; $output .= '<blockquote>[filetree dir="some-directory" fileformat="%link - %size"]</blockquote>'; $output .= '<p>' . t('You can also read a <a href="http://drupal.org/project/filetree">detailed explanation of these options</a>.'). '</p>'; } return $output; Loading @@ -133,6 +146,7 @@ function _filetree_process($text, $filter, $format, $langcode, $cache, $cache_id 'dirtitle' => '%filename', 'filename' => '%filename', 'filetitle' => '%filename', 'fileformat' => '%link', 'animation' => TRUE, ); Loading Loading @@ -177,7 +191,7 @@ function _filetree_process($text, $filter, $format, $langcode, $cache, $cache_id $params[$key]['exclude'] = implode("\n", $params[$key]['exclude']); // Convert params containing token values. foreach (array('dirname', 'dirtitle', 'filename', 'filetitle') as $token_param) { foreach (array('dirname', 'dirtitle', 'filename', 'filetitle', 'fileformat') as $token_param) { $params[$key][$token_param] = preg_replace('/%(\w+)/', '[filetree:$1]', $params[$key][$token_param]); } Loading Loading @@ -213,30 +227,28 @@ function _filetree_list_files($dir, $params) { // - additional paths from the "exclude" param if ($filename[0] != '.' && !drupal_match_path($filename, $params['exclude'])) { $filepath = "$dir/$filename"; $token_args = array( 'filename' => $filename, 'filepath' => $filepath, 'descriptions' => $descriptions, 'params' => $params, ); // It's a folder. if (is_dir($filepath)) { $folders[$filename] = array( 'data' => isset($descriptions[$filename]) ? $descriptions[$filename] : token_replace($params['dirname'], array('filepath' => $filepath)), 'data' => isset($descriptions[$filename]) ? $descriptions[$filename] : token_replace($params['dirname'], $token_args), 'children' => _filetree_list_files($filepath, $params), 'title' => token_replace($params['dirtitle'], array('filepath' => $filepath)), 'title' => token_replace($params['dirtitle'], $token_args), 'class' => array('folder'), ); } // It's a file. else { $name = isset($descriptions[$filename]) ? $descriptions[$filename] : token_replace($params['filename'], array('filepath' => $filepath)); $url = $params['absolute'] ? file_create_url($filepath) : substr(file_create_url($filepath), strlen($GLOBALS['base_url'] . '/')); $files[$filename] = array( 'data' => l($name, urldecode($url)), 'title' => token_replace($params['filetitle'], array('filepath' => $filepath)), 'data' => token_replace($params['fileformat'], $token_args), 'title' => token_replace($params['filetitle'], $token_args), 'class' => array(_filetree_icon(pathinfo($filename, PATHINFO_EXTENSION))), ); } Loading