本文整理汇总了PHP中JFolder::listFolderTree方法的典型用法代码示例。如果您正苦于以下问题:PHP JFolder::listFolderTree方法的具体用法?PHP JFolder::listFolderTree怎么用?PHP JFolder::listFolderTree使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JFolder
的用法示例。
在下文中一共展示了JFolder::listFolderTree方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _generateTree
function _generateTree()
{
$path = JPATH_SITE . '/templates/' . $this->item->name;
$folders = JFolder::listFolderTree($path, '.', 5);
$i = 0;
$path = array();
$prev = 0;
$tree = '';
foreach ($folders as $k => $f) {
$p = $f['parent'];
if ($p > $prev) {
$tree .= '<ul><li id="phtml_' . $f['id'] . '">' . '<a href="#">' . $f['name'] . '</a>';
$path[$i++] = $prev;
} else {
if ($p < $prev) {
for ($j = $i - 1; $j >= 0; $j--) {
$tree .= '</li></ul>';
$last = $path[$j];
unset($path[$j]);
$i--;
if ($p == $last) {
break;
}
}
}
$tree .= '</li><li id="phtml_' . $f['id'] . '">' . '<a href="#">' . $f['name'] . '</a>';
}
$prev = $p;
//$folders[$k]['files'] = JFolder::files( $f['fullname'], '.', false, true );
}
$tree = '<ul><li id="phtml_0" class="jstree-open jstree-last">' . '<a href="#" class="jstree-clicked">' . './' . '</a><ul>' . substr($tree, 5) . '</li></ul></li></ul>';
return $tree;
}
示例2: getOptions
protected function getOptions()
{
$options = array();
$filter = (string) $this->element['filter'];
$exclude = (string) $this->element['exclude'];
$options[] = JHtml::_('select.option', '-1', JText::_('SELECT_FOLDER'));
$params = JComponentHelper::getParams('com_igallery');
$path = (string) $params->get('import_server_base', 'images/');
if (!is_dir($path)) {
$path = JPATH_ROOT . '/' . $path;
}
$folders = JFolder::listFolderTree($path, $filter, 9);
if (is_array($folders)) {
foreach ($folders as $folder) {
if ($exclude) {
if (preg_match(chr(1) . $exclude . chr(1), $folder)) {
continue;
}
}
$options[] = JHtml::_('select.option', $folder['relname'], $folder['relname']);
}
}
$options = array_merge(parent::getOptions(), $options);
return $options;
}
示例3: getItems
public function getItems()
{
$searchpath = JPATH_ROOT . DIRECTORY_SEPARATOR . "components/com_content";
$items[] = JFolder::files($searchpath);
$items[] = JFolder::listFolderTree($searchpath, '');
return $items;
}
示例4: getOptions
/**
* Method to get the field options.
*
* @return array The field option objects.
*
* @since 1.0
*/
protected function getOptions()
{
$options = array();
$path = $this->directory;
if (!is_dir($path)) {
$path = JPATH_ROOT . '/' . $path;
}
// Prepend some default options based on field attributes.
if (!$this->hideNone) {
$options[] = JHtml::_('select.option', '-1', JText::alt('JOPTION_DO_NOT_USE', preg_replace('/[^a-zA-Z0-9_\\-]/', '_', $this->fieldname)));
}
if (!$this->hideDefault) {
$options[] = JHtml::_('select.option', '', JText::alt('JOPTION_USE_DEFAULT', preg_replace('/[^a-zA-Z0-9_\\-]/', '_', $this->fieldname)));
}
// Get a list of folders in the search path with the given filter.
$folders = JFolder::listFolderTree($path, $this->filter);
// Build the options list from the list of folders.
if (is_array($folders)) {
foreach ($folders as $folder) {
// Check to see if the file is in the exclude mask.
if ($this->exclude) {
if (preg_match(chr(1) . $this->exclude . chr(1), $folder['relname'])) {
continue;
}
}
// Add the folder
$options[] = JHtml::_('select.option', $folder['relname'], $folder['relname']);
}
}
return $options;
}
示例5: getInput
protected function getInput()
{
$options = array();
// path to images directory
$path = JPATH_ROOT . '/' . $this->element['directory'];
$filter = $this->element['filter'];
$folders = JFolder::listFolderTree($path, $filter);
foreach ($folders as $folder) {
$options[] = JHtml::_('select.option', str_replace("\\", "/", $folder['relname']), str_replace("\\", "/", substr($folder['relname'], 1)));
}
return JHtml::_('select.genericlist', $options, $this->name, '', 'value', 'text', $this->value);
}
示例6: getOptions
protected function getOptions()
{
//Pega os diretórios modelos
$modelos_dir = JFolder::listFolderTree(JPATH_SITE . '/modules/mod_chamadas/modelos/', '', 1);
//Busca diretórios na pasta "mod_chamadas/modelos" e cria opções de seleção para configuração do módulo
foreach ($modelos_dir as $modelo) {
$options[] = JHtml::_('select.option', $modelo['name'], ucwords(str_replace('_', ' ', $modelo['name'])));
}
//Lista que será incorporada nos fields do módulo
$options = array_merge(parent::getOptions(), $options);
return $options;
}
示例7: getInput
protected function getInput()
{
// output for options
$output_options = '';
$output_configs = '';
// prefix for the language files
$pre = 'MOD_NEWS_PRO_GK5_';
// get folders with data sources
$folders = JFolder::listFolderTree(JPATH_SITE . '/modules/mod_news_pro_gk5/data_sources/', '', 1);
//
$json_data = null;
// iterate through data source folders
foreach ($folders as $folder) {
// check if the data source contains the configuration.json file
if (JFile::exists($folder['fullname'] . '/configuration.json')) {
// read JSON from this data source
$file_content = JFile::read($folder['fullname'] . '/configuration.json');
// parse JSON
$json_data = json_decode($file_content);
// if the JSON file is correct
if (json_last_error() === JSON_ERROR_NONE) {
// generate the header option
$output_options .= '<optgroup label="' . JText::_($pre . $json_data->data_source) . '">';
// generate the options
foreach ($json_data->sources as $source) {
// option
$output_options .= '<option data-source="' . $json_data->source . '" value="' . $source->value . '"' . ($this->value == $source->value ? ' selected="selected"' : '') . '>' . JText::_($pre . $source->name) . '</option>';
}
// close header option
$output_options .= '</optgroup>';
// parse file content and put translations
$json_matches = array();
preg_match_all('@\\"MOD_NEWS_PRO_GK5_.*?\\"@mis', $file_content, $json_matches);
//
if (isset($json_matches[0]) && count($json_matches[0]) > 0 && strlen($json_matches[0][0]) > 0) {
foreach ($json_matches[0] as $translations) {
$phrase = str_replace('"', '', $translations);
$file_content = str_replace($phrase, '\'.JText::_("' . $phrase . '").\'', $file_content);
}
}
//
$file_content = "'" . $file_content . "'";
$out_fn = create_function('', 'return ' . $file_content . ';');
// output the config
$output_configs .= '<div class="gk-json-config" id="gk-json-config-' . $json_data->source . '">' . $out_fn() . '</div>';
}
}
}
// output the select
echo '<select id="' . $this->id . '" name="' . $this->name . '">' . $output_options . '</select>';
echo $output_configs;
}
示例8: getOptions
protected function getOptions()
{
$options = array();
$template_names = array();
$t_names = JFolder::listFolderTree(JPATH_ROOT . DS . "media" . DS . "com_jvrelatives" . DS . "styles", ".", 1);
foreach ($t_names as $t) {
$row = new StdClass();
$row->text = $t['name'];
$row->value = $t['name'];
$options[] = $row;
}
$options = array_merge(parent::getOptions(), $options);
return $options;
}
示例9: getInput
protected function getInput()
{
global $expose;
$html = '';
$fonts = '';
$options = array();
$url = JURI::getInstance();
$id = $url->getVar('id');
// Initialize some field attributes.
$class = $this->element['class'];
$selectClass = 'class="gfonts"';
$pretext = $this->element['pretext'] != NULL ? '<span class="pre-text hasTip" title="::' . JText::_($this->element['pre-desc'] ? $this->element['pre-desc'] : $this->description) . '">' . JText::_($this->element['pretext']) . '</span>' : '';
$posttext = $this->element['posttext'] != NULL ? '<span class="post-text">' . JText::_($this->element['posttext']) . '</span>' : '';
$wrapstart = '<div class="field-wrap fonts-list clearfix ' . $class . '">';
$wrapend = '</div>';
//create a google font list file on admin folder to avoid api call and slow down the admin panel
$fileName = 'gfonts.txt';
$template = $this->form->getValue('template');
$path = JPATH_ROOT . '/templates/' . $template . '/asset/' . $fileName;
if (!JFile::exists($path) or JFile::read($path) == NULL) {
$this->createFontList($path);
}
$fontsPath = JPATH_ROOT . '/templates/' . $template . '/fonts/';
//var_dump( $path);die();
if (JFolder::exists($fontsPath)) {
$fontFolders = JFolder::listFolderTree($fontsPath, $filter = '', $maxLevel = 1, $level = 0, $parent = 0);
}
$data = JFile::read($path);
$data = explode(';', $data);
//add none
$options[] = JHtml::_('select.option', '0', JText::alt('JOPTION_DO_NOT_USE', 'language'));
$options[] = JHtml::_('select.option', '-1', JText::alt('---------- General fonts ----------', 'language'));
$options[] = JHtml::_('select.option', '\'Arial\', Helvetica, sans-serif', JText::alt('"Arial", Helvetica, sans-serif', 'language'));
$options[] = JHtml::_('select.option', '\'Times New Roman\', Times, serif', JText::alt('"Times New Roman", Times, serif', 'language'));
$options[] = JHtml::_('select.option', '\'Courier New\', Courier, monospace', JText::alt('"Courier New", Courier, monospace', 'language'));
$options[] = JHtml::_('select.option', '\'Georgia\',Times New Roman, Times, serif', JText::alt('"Georgia",Times New Roman, Times, serif', 'language'));
$options[] = JHtml::_('select.option', '\'Verdana\', Arial, Helvetica, sans-serif', JText::alt('"Verdana", Arial, Helvetica, sans-serif', 'language'));
$options[] = JHtml::_('select.option', '-1', JText::alt('---------- Google fonts ----------', preg_replace('/[^a-zA-Z0-9_\\-]/', '_', $this->fieldname)));
foreach ($data as $val) {
//var_dump($val);
list($fontVal, $fontName) = explode('=', "{$val}=");
$fontVal = str_replace(' ', '+', $fontVal);
$options[] = JHtml::_('select.option', $fontVal, $fontName);
}
//pop the last empty array
array_pop($options);
$html .= '<a class="link-gfont" href="http://www.google.com/webfonts" target="_blank">' . JText::_('GOOGLE_FONT_LINK_LABLE') . '</a>';
$html .= JHtml::_('select.genericlist', $options, $this->name, $selectClass, 'value', 'text', $this->value, $this->id);
return $wrapstart . $pretext . $html . $posttext . $wrapend;
}
示例10: getInput
protected function getInput()
{
$attr = '';
$attr .= $this->element['class'] ? ' class="' . (string) $this->element['class'] . '"' : '';
$attr .= (string) $this->element['disabled'] == 'true' ? ' disabled="disabled"' : '';
$attr .= $this->element['size'] ? ' size="' . (int) $this->element['size'] . '"' : '';
$themes = JFolder::listFolderTree(JPATH_SITE . DS . 'components' . DS . 'com_djreviews' . DS . 'themes', '', 1);
$default = $this->element['default'];
$options = array();
if ($default == '') {
$options[] = JHTML::_('select.option', '', JText::_('JGLOBAL_USE_GLOBAL'));
}
foreach ($themes as $theme) {
$options[] = JHTML::_('select.option', $theme['name'], $theme['name']);
}
$out = JHTML::_('select.genericlist', $options, $this->name, null, 'value', 'text', $this->value);
return $out;
}
示例11: listFolderTree
/**
* Lists folder in format suitable for tree display.
*
* @access public
* @param string The path of the folder to read.
* @param string A filter for folder names.
* @param integer The maximum number of levels to recursively read,
* defaults to three.
* @param integer The current level, optional.
* @param integer Unique identifier of the parent folder, if any.
* @return array Folders in the given folder.
* @since 1.5
*/
function listFolderTree($path, $filter, $maxLevel = 3, $level = 0, $parent = 0)
{
$dirs = array();
if ($level == 0) {
$GLOBALS['_JFolder_folder_tree_index'] = 0;
}
if ($level < $maxLevel) {
$folders = JFolder::folders($path, $filter);
// first path, index foldernames
foreach ($folders as $name) {
$id = ++$GLOBALS['_JFolder_folder_tree_index'];
$fullName = JPath::clean($path . DS . $name);
$dirs[] = array('id' => $id, 'parent' => $parent, 'name' => $name, 'fullname' => $fullName, 'relname' => str_replace(JPATH_ROOT, '', $fullName));
$dirs2 = JFolder::listFolderTree($fullName, $filter, $maxLevel, $level + 1, $id);
$dirs = array_merge($dirs, $dirs2);
}
}
return $dirs;
}
示例12: getInput
protected function getInput()
{
global $expose;
$html = '';
$fonts = '';
$options = array();
//get template id
$url = JURI::getInstance();
$id = $url->getVar('id');
// Initialize some field attributes.
$class = $this->element['class'];
$selectClass = 'class="gfonts"';
$pretext = $this->element['pretext'] != NULL ? '<span class="pre-text hasTip" title="::' . JText::_($this->element['pre-desc'] ? $this->element['pre-desc'] : $this->description) . '">' . JText::_($this->element['pretext']) . '</span>' : '';
$posttext = $this->element['posttext'] != NULL ? '<span class="post-text">' . JText::_($this->element['posttext']) . '</span>' : '';
$wrapstart = '<div class="field-wrap fonts-list clearfix ' . $class . '">';
$wrapend = '</div>';
//create a google font list file on admin folder to avoid api call and slow down the admin panel
$fileName = 'gfonts.txt';
$path = JPATH_ROOT . '/templates/' . getTemplate($id) . '/' . $fileName;
//$path = realpath(dirname(dirname(__FILE__))) .'/'.$fileName;
if (!JFile::exists($path) or JFile::read($path) == NULL) {
$this->createFontList($path);
}
$fontsPath = JPATH_ROOT . '/templates/' . getTemplate($id) . '/fonts/';
if (JFolder::exists($fontsPath)) {
$fontFolders = JFolder::listFolderTree($fontsPath, $filter = '', $maxLevel = 1, $level = 0, $parent = 0);
}
$data = JFile::read($path);
$data = explode(',', $data);
//add none
$options[] = JHtml::_('select.option', '0', JText::alt('JOPTION_DO_NOT_USE', 'language'));
$options[] = JHtml::_('select.option', '-1', JText::alt('---------- General fonts ----------', 'language'));
$options[] = JHtml::_('select.option', 'Arial, Helvetica, sans-serif', JText::alt('Arial, Helvetica, sans-serif', 'language'));
$options[] = JHtml::_('select.option', '\'Times New Roman\', Times, serif', JText::alt('"Times New Roman", Times, serif', 'language'));
$options[] = JHtml::_('select.option', '"Courier New", Courier, monospace', JText::alt('"Courier New", Courier, monospace', 'language'));
$options[] = JHtml::_('select.option', 'Georgia,"Times New Roman", Times, serif', JText::alt('Georgia,"Times New Roman", Times, serif', 'language'));
$options[] = JHtml::_('select.option', 'Verdana, Arial, Helvetica, sans-serif', JText::alt('Verdana, Arial, Helvetica, sans-serif', 'language'));
// Add custom fonts in font folder as options
/*if ( JFolder::exists($fontsPath) )
{
foreach($fontFolders as $fontFolder){
$customFontName = ucwords( str_replace( "-", " ", $fontFolder['name'] ) );
$options[] = JHtml::_('select.option', $fontFolder['name'] . '-webfont', JText::alt($customFontName,'language'));
// Add @font-face for font preview in admin
$templatePath = JURI::root(true) . '/templates/' . getTemplate($id);
$fontFilename = $fontFolder['name'] . '-webfont';
$fontFamily = $fontFolder['name'];
$fontFamily = ucwords( str_replace( "-", " ", $fontFamily ) );
$fonts .= "
@font-face {
font-family: {$fontFamily};
src: url('{$templatePath}/fonts/{$fontFolder['name']}/{$fontFilename}.eot');
src: local({$fontFamily}),
url('{$templatePath}/fonts/{$fontFolder['name']}/{$fontFilename}.woff') format('woff'),
url('{$templatePath}/fonts/{$fontFolder['name']}/{$fontFilename}.ttf') format('truetype'),
url('{$templatePath}/fonts/{$fontFolder['name']}/{$fontFilename}.svg#font')
}
";
}
}*/
//$expose->document->addStyleDeclaration($fonts);
// Load set parameter values to make fonts show on load
//$expose->document->addStyleSheet('http://fonts.googleapis.com/css?family=Abril+Fatface');
$options[] = JHtml::_('select.option', '-1', JText::alt('---------- Google fonts ----------', preg_replace('/[^a-zA-Z0-9_\\-]/', '_', $this->fieldname)));
foreach ($data as $val) {
list($fontVal, $fontName) = explode('=', "{$val}=");
$fontVal = str_replace(' ', '+', $fontVal);
$options[] = JHtml::_('select.option', $fontVal, $fontName);
}
//pop the last empty array
array_pop($options);
$html .= '<a href="http://www.google.com/webfonts" target="_blank">' . JText::_('GOOGLE_FONT_LINK_LABLE') . '</a>';
$html .= "<br/>";
$html .= JHtml::_('select.genericlist', $options, $this->name, $selectClass, 'value', 'text', $this->value, $this->id);
return $wrapstart . $pretext . $html . $posttext . $wrapend;
}
示例13: _generateArborescence
private function _generateArborescence($folders)
{
$folderList = array();
foreach ($folders as $folder) {
$folderPath = JPath::clean(ACYMAILING_ROOT . trim(str_replace('/', DS, trim($folder)), DS));
if (!file_exists($folderPath)) {
acymailing_createDir($folderPath);
}
$subFolders = JFolder::listFolderTree($folderPath, '', 15);
$folderList[] = trim($folder, '/ ');
foreach ($subFolders as $oneFolder) {
$subFolder = str_replace(ACYMAILING_ROOT, '', $oneFolder['relname']);
$subFolder = str_replace(DS, '/', $subFolder);
$folderList[] = ltrim($subFolder, '/');
}
}
return array_unique($folderList);
}
示例14: media_bank
public function media_bank()
{
$uri = JURI::getInstance();
$url = $uri->root();
$folder_path = JRequest::getVar('path', '');
$dirpath = JRequest::getVar('dirpath', '');
if (!$folder_path) {
$path = REDSHOP_FRONT_IMAGES_RELPATH;
$dir_path = "components/com_redshop/assets/images";
} else {
$path = $folder_path;
$dir_path = $dirpath;
}
$files = JFolder::listFolderTree($path, '.', 1);
$tbl = '';
$tbl .= "<table cellspacing='7' cellpadding='2' width='100%' border='0'>";
$tbl .= "<tr>";
if ($folder_path) {
$t = preg_split('/', $folder_path);
$na = count($t) - 1;
$n = count($t) - 2;
if ($t[$n] != 'assets') {
if ($t[$n] == 'images') {
$path_bk = REDSHOP_FRONT_IMAGES_RELPATH;
$dir_path = 'components/com_redshop/assets/images/' . $t[$na];
} else {
$path_bk = REDSHOP_FRONT_IMAGES_RELPATH . '/' . $t[$n];
$dir_path = 'components/com_redshop/assets/images/' . $t[$n] . '/' . $t[$na];
}
$folder_img_bk = "components/com_redshop/assets/images/folderup_32.png";
$info = @getimagesize($folder_img_bk);
$width = @$info[0];
$height = @$info[1];
if ($info[0] > 50 || $info[1] > 50) {
$dimensions = $this->_imageResize($info[0], $info[1], 50);
$width_60 = $dimensions[0];
$height_60 = $dimensions[1];
} else {
$width_60 = $width;
$height_60 = $height;
}
$link_bk = "index.php?tmpl=component&option=com_redshop&view=product_detail&task=media_bank&path=" . $path_bk . "&dirpath=" . $dir_path;
$tbl .= "<td width='25%'><table width='120' height='70' style='background-color:#C0C0C0;' cellspacing='1'\n\t\t\t\tcellpadding='1'><tr><td align='center' style='background-color:#FFFFFF;'>\n\t\t\t\t<a href='" . $link_bk . "'><img src='" . $folder_img_bk . "' width='" . $width_60 . "' height='" . $height_60 . "'></a></td></tr>\n\t\t\t\t<tr height='15'><td style='background-color:#F7F7F7;' align='center'><label>Up</label></td></tr></table></td></tr><tr>";
} else {
$dir_path = "components/com_redshop/assets/images";
}
}
if ($handle = opendir($path)) {
$folder_img = "components/com_redshop/assets/images/folder.png";
$info = @getimagesize($folder_img);
$width = @$info[0];
$height = @$info[1];
if ($info[0] > 50 || $info[1] > 50) {
$dimensions = $this->_imageResize($info[0], $info[1], 50);
$width_60 = $dimensions[0];
$height_60 = $dimensions[1];
} else {
$width_60 = $width;
$height_60 = $height;
}
$j = 1;
for ($f = 0; $f < count($files); $f++) {
$link = "index.php?tmpl=component&option=com_redshop&view=product_detail&task=media_bank&folder=1&path=" . $files[$f]['fullname'] . "&dirpath=" . $files[$f]['relname'];
$tbl .= "<td width='25%'><table width='120' height='70' style='background-color:#C0C0C0;' cellspacing='1' cellpdding='1'>\n\t\t\t\t<tr><td align='center' style='background-color:#FFFFFF;'><a href='" . $link . "'>\n\t\t\t\t<img src='" . $folder_img . "' width='" . $width_60 . "' height='" . $height_60 . "'></a></tr><tr height='15'>\n\t\t\t\t<td style='background-color:#F7F7F7;' align='center'><label>" . $files[$f]['name'] . "</label></td></tr></table></td>";
if ($j % 4 == 0) {
$tbl .= "</tr><tr>";
}
$j++;
}
$i = $j;
while (false !== ($filename = readdir($handle))) {
if (preg_match("/.jpg/", $filename) || preg_match("/.gif/", $filename) || preg_match("/.png/", $filename)) {
$live_path = $url . $dir_path . '/' . $filename;
$info = @getimagesize($live_path);
$width = @$info[0];
$height = @$info[1];
if ($info[0] > 50 || $info[1] > 50) {
$dimensions = $this->_imageResize($info[0], $info[1], 50);
$width_60 = $dimensions[0];
$height_60 = $dimensions[1];
} else {
$width_60 = $width;
$height_60 = $height;
}
$tbl .= "<td width='25%'><table width='120' height='70' style='background-color:#C0C0C0;' cellspacing='1' cellpdding='1'>\n\t\t\t\t\t<tr><td align='center' style='background-color:#FFFFFF;'>\n\t\t\t\t\t<a href=\"javascript:window.parent.jimage_insert('" . $dir_path . '/' . $filename . "');window.parent.SqueezeBox.close();\">\n\t\t\t\t\t<img width='" . $width_60 . "' height='" . $height_60 . "' alt='" . $filename . "' src='" . $live_path . "'></a>\n\t\t\t\t\t</td></tr><tr height='15'><td style='background-color:#F7F7F7;' align='center'><label>" . substr($filename, 0, 10) . "</label>\n\t\t\t\t\t</td></tr></table></td>";
if ($i % 4 == 0) {
$tbl .= "</tr><tr>";
}
$i++;
}
}
$tbl .= '</tr></table>';
echo $tbl;
closedir($handle);
}
}
示例15: loadAllFolder
function loadAllFolder($path)
{
$folders = JFolder::listFolderTree($path, '');
return $folders;
}