本文整理汇总了PHP中JFolder::folders方法的典型用法代码示例。如果您正苦于以下问题:PHP JFolder::folders方法的具体用法?PHP JFolder::folders怎么用?PHP JFolder::folders使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JFolder
的用法示例。
在下文中一共展示了JFolder::folders方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: fetchElement
function fetchElement($name, $value, &$node, $control_name)
{
// init vars
$class = $node->attributes('class') ? 'class="' . $node->attributes('class') . '"' : 'class="inputbox"';
$constraint = $node->attributes('constraint');
// get renderer
$this->renderer = new ItemRenderer();
$this->renderer->addPath($this->_parent->layout_path);
// if selectable types isn't specified, get all types
if (empty($this->_parent->selectable_types)) {
$this->_parent->selectable_types = array('');
foreach (JFolder::folders($this->_parent->layout_path . '/' . $this->renderer->getFolder() . '/item') as $folder) {
$this->_parent->selectable_types[] = $folder;
}
}
// get layouts
$layouts = array();
foreach ($this->_parent->selectable_types as $type) {
$layouts = array_merge($layouts, $this->_getLayouts($type, $constraint));
}
// create layout options
$options = array(JHTML::_('select.option', '', JText::_('Item Name')));
foreach ($layouts as $layout => $layout_name) {
$text = $layout_name;
$val = $layout;
$options[] = JHTML::_('select.option', $val, JText::_($text));
}
return JHTML::_('select.genericlist', $options, $control_name . '[' . $name . ']', $class, 'value', 'text', $value, $control_name . $name);
}
示例2: doExecute
/**
* Entry point for CLI script
*
* @return void
*
* @since 3.0
*/
public function doExecute()
{
ini_set("max_execution_time", 300);
jimport('joomla.filesystem.archive');
jimport('joomla.filesystem.folder');
jimport('joomla.filesystem.file');
$config = JFactory::getConfig();
$username = $config->get('user');
$password = $config->get('password');
$database = $config->get('db');
echo 'Exporting database...
';
exec("mysqldump --user={$username} --password={$password} --quick --add-drop-table --add-locks --extended-insert --lock-tables --all {$database} > " . JPATH_SITE . "/database-backup.sql");
$zipFilesArray = array();
$dirs = JFolder::folders(JPATH_SITE, '.', true, true);
array_push($dirs, JPATH_SITE);
echo 'Collecting files...
';
foreach ($dirs as $dir) {
$files = JFolder::files($dir, '.', false, true);
foreach ($files as $file) {
$data = JFile::read($file);
$zipFilesArray[] = array('name' => str_replace(JPATH_SITE . '/', '', $file), 'data' => $data);
}
}
$zip = JArchive::getAdapter('zip');
echo 'Creating zip...
';
$archive = JPATH_SITE . '/backups/' . date('Ymd') . '-backup.zip';
$zip->create($archive, $zipFilesArray);
echo 'Backup created ' . $archive . '
';
}
示例3: purge
public function purge()
{
$db = JFactory::getDbo();
$user = JFactory::getUser();
if (!$user->authorise('core.admin', 'com_djmediatools')) {
echo JText::_('JLIB_APPLICATION_ERROR_ACCESS_FORBIDDEN');
exit(0);
}
$files = JFolder::files(JPATH_ROOT . DS . 'media' . DS . 'djmediatools' . DS . 'cache', '.', true, true, array('index.html', '.svn', 'CVS', '.DS_Store', '__MACOSX'));
$errors = array();
if (count($files) > 0) {
foreach ($files as $file) {
if (!JFile::delete($file)) {
$errors[] = $db->quote(JPath::clean(str_replace(JPATH_ROOT, '', $file)));
}
}
}
$folders = JFolder::folders(JPATH_ROOT . DS . 'media' . DS . 'djmediatools' . DS . 'cache', '.', true, true, array('.', '..'));
if (count($folders) > 0) {
$folders = array_reverse($folders);
foreach ($folders as $key => $folder) {
JFolder::delete($folder);
}
}
if (count($errors) > 0) {
$db->setQuery("DELETE FROM #__djmt_resmushit WHERE path NOT IN (" . implode(',', $errors) . ")");
$db->query();
echo JText::sprintf('COM_DJMEDIATOOLS_N_IMAGES_HAVE_NOT_BEEN_DELETED', count($errors));
} else {
$db->setQuery("DELETE FROM #__djmt_resmushit");
$db->query();
echo JText::sprintf('COM_DJMEDIATOOLS_N_IMAGES_HAVE_BEEN_DELETED', count($files));
}
}
示例4: fetchElement
function fetchElement($name, $value, &$node, $control_name)
{
jimport('joomla.filesystem.folder');
$mainframe =& JFactory::getApplication();
$fieldName = version_compare(JVERSION, '1.6.0', 'ge') ? $name : $control_name . '[' . $name . ']';
if (version_compare(JVERSION, '1.6.0', 'ge')) {
$pluginTemplatesPath = JPATH_SITE . DS . 'plugins' . DS . 'content' . DS . 'jw_ts' . DS . 'jw_ts' . DS . 'tmpl';
} else {
$pluginTemplatesPath = JPATH_SITE . DS . 'plugins' . DS . 'content' . DS . 'jw_ts' . DS . 'tmpl';
}
$pluginTemplatesFolders = JFolder::folders($pluginTemplatesPath);
$db =& JFactory::getDBO();
if (version_compare(JVERSION, '1.6.0', 'ge')) {
$query = "SELECT template FROM #__template_styles WHERE client_id = 0 AND home = 1";
} else {
$query = "SELECT template FROM #__templates_menu WHERE client_id = 0 AND menuid = 0";
}
$db->setQuery($query);
$template = $db->loadResult();
$templatePath = JPATH_SITE . DS . 'templates' . DS . $template . DS . 'html' . DS . 'jw_ts';
if (JFolder::exists($templatePath)) {
$templateFolders = JFolder::folders($templatePath);
$folders = @array_merge($templateFolders, $pluginTemplatesFolders);
$folders = @array_unique($folders);
} else {
$folders = $pluginTemplatesFolders;
}
sort($folders);
$options = array();
foreach ($folders as $folder) {
$options[] = JHTML::_('select.option', $folder, $folder);
}
return JHTML::_('select.genericlist', $options, $fieldName, 'class="inputbox"', 'value', 'text', $value);
}
示例5: fetchElement
function fetchElement($name, $value, &$node, $control_name)
{
jimport('joomla.filesystem.folder');
// path to images directory
$path = JPATH_ROOT . DS . $node->attributes('directory');
$filter = $node->attributes('filter');
$exclude = $node->attributes('exclude');
$folders = JFolder::folders($path, $filter);
$options = array();
foreach ($folders as $folder) {
if ($exclude) {
if (preg_match(chr(1) . $exclude . chr(1), $folder)) {
continue;
}
}
$options[] = JHTML::_('select.option', $folder, $folder);
}
if (!$node->attributes('hide_none')) {
array_unshift($options, JHTML::_('select.option', '-1', '- ' . JText::_('Do not use') . ' -'));
}
if (!$node->attributes('hide_default')) {
array_unshift($options, JHTML::_('select.option', '', '- ' . JText::_('Use default') . ' -'));
}
return JHTML::_('select.genericlist', $options, '' . $control_name . '[' . $name . ']', 'class="inputbox"', 'value', 'text', $value, $control_name . $name);
}
示例6: uninstall
public function uninstall($parent)
{
// Remove all Nucleus files manually as file installer only uninstalls files.
$manifest = $parent->getManifest();
// Loop through all elements and get list of files and folders
foreach ($manifest->fileset->files as $eFiles) {
$target = (string) $eFiles->attributes()->target;
$targetFolder = empty($target) ? JPATH_ROOT : JPATH_ROOT . '/' . $target;
// Check if all children exists
if (count($eFiles->children()) > 0) {
// Loop through all filenames elements
foreach ($eFiles->children() as $eFileName) {
if ($eFileName->getName() == 'folder') {
$folder = $targetFolder . '/' . $eFileName;
$files = JFolder::files($folder, '.', false, true);
foreach ($files as $name) {
JFile::delete($name);
}
$subFolders = JFolder::folders($folder, '.', false, true);
foreach ($subFolders as $name) {
JFolder::delete($name);
}
}
}
}
}
return true;
}
示例7: getOptions
/**
* Method to get the field options.
*
* @return array The field option objects.
*
* @since 11.1
*/
protected function getOptions()
{
// Initialize variables.
$options = array();
// Initialize some field attributes.
$filter = (string) $this->element['filter'];
$exclude = (string) $this->element['exclude'];
$hideNone = (string) $this->element['hide_none'];
$hideDefault = (string) $this->element['hide_default'];
// Get the path in which to search for file options.
$path = JPATH_ROOT . '/components/com_joomleague/extensions';
if (!is_dir($path)) {
$path = JPATH_ROOT . '/' . $path;
}
// Get a list of folders in the search path with the given filter.
$folders = JFolder::folders($path, $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 ($exclude) {
if (preg_match(chr(1) . $exclude . chr(1), $folder)) {
continue;
}
}
$options[] = JHtml::_('select.option', $folder, $folder);
}
}
// Merge any additional options in the XML definition.
$options = array_merge(parent::getOptions(), $options);
return $options;
}
示例8: getInput
public function getInput()
{
$application = JFactory::getApplication();
if ($application->isSite()) {
$template = $application->getTemplate();
} else {
$db = JFactory::getDbo();
$query = $db->getQuery(true);
$query->select($db->quoteName('template'))->from($db->quoteName('#__template_styles'))->where($db->quoteName('client_id') . ' = 0')->where($db->quoteName('home') . ' = 1');
$db->setQuery($query);
$template = $db->loadResult();
}
$this->extension = $this->element['extension'];
if ($this->extension == 'com_k2') {
$corePath = JPATH_SITE . '/components/com_k2/templates';
$overridesPath = JPATH_SITE . '/templates/' . $template . '/html/com_k2';
} else {
$corePath = JPATH_SITE . '/modules/' . $this->extension . '/tmpl';
$overridesPath = JPATH_SITE . '/templates/' . $template . '/html/' . $this->extension;
}
$coreTemplates = JFolder::folders($corePath);
if (JFolder::exists($overridesPath)) {
$overrides = JFolder::folders($overridesPath);
$templates = @array_merge($overrides, $coreTemplates);
$templates = @array_unique($templates);
} else {
$templates = $coreTemplates;
}
$options = array();
foreach ($templates as $folder) {
$options[] = JHtml::_('select.option', $folder, $folder);
}
return JHtml::_('select.genericlist', $options, $this->name, '', 'value', 'text', $this->value, $this->id);
}
示例9: parseXmlFiles
public static function parseXmlFiles($templateBaseDir = null)
{
// Read the template folder to find templates
if (!$templateBaseDir) {
$templateBaseDir = KPATH_SITE . '/template';
}
jimport('joomla.filesystem.folder');
$data = self::parseXmlFile('', $templateBaseDir);
if ($data) {
// Guess template folder.
$data->directory = preg_replace('/[^a-z0-9_]/', '', preg_replace('/\\s+/', '_', strtolower($data->name)));
if (!$data->directory) {
return array();
}
// Template found from the root (folder cannot contain more than one template)
return array('' => $data);
}
$templateDirs = JFolder::folders($templateBaseDir);
$rows = array();
// Check that the directory contains an xml file
foreach ($templateDirs as $templateDir) {
$data = self::parseXmlFile($templateDir, $templateBaseDir);
if ($data) {
$rows[$templateDir] = $data;
}
}
ksort($rows);
return $rows;
}
示例10: listslanguagesType
function listslanguagesType()
{
jimport('joomla.filesystem.folder');
$path = JLanguage::getLanguagePath(JPATH_ROOT);
$dirs = JFolder::folders($path);
$this->languages = array();
foreach ($dirs as $dir) {
if (strlen($dir) != 5 || $dir == "xx-XX") {
continue;
}
$xmlFiles = JFolder::files($path . DS . $dir, '^([-_A-Za-z]*)\\.xml$');
$xmlFile = reset($xmlFiles);
if (empty($xmlFile)) {
continue;
}
$data = JApplicationHelper::parseXMLLangMetaFile($path . DS . $dir . DS . $xmlFile);
$oneLanguage = new stdClass();
$oneLanguage->language = strtolower($dir);
$oneLanguage->name = empty($data['name']) ? $dir : $data['name'];
$this->languages[] = $oneLanguage;
}
if (count($this->languages) < 2) {
return;
}
$this->multipleLang = true;
$this->choice = array();
$this->choice[] = JHTML::_('select.option', 'all', JText::_('ACY_ALL'));
$this->choice[] = JHTML::_('select.option', 'special', JText::_('ACY_CUSTOM'));
$js = "function updateLanguages(){\n\t\t\tchoice = eval('document.adminForm.choice_languages');\n\t\t\tchoiceValue = 'special';\n\t\t\tfor (var i=0; i < choice.length; i++){\n\t\t\t\t if (choice[i].checked){\n\t\t\t\t\t choiceValue = choice[i].value;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\thiddenVar = document.getElementById('hidden_languages');\n\t\t\tif(choiceValue != 'special'){\n\t\t\t\thiddenVar.value = choiceValue;\n\t\t\t\tdocument.getElementById('div_languages').style.display = 'none';\n\t\t\t}else{\n\t\t\t\tdocument.getElementById('div_languages').style.display = 'block';\n\t\t\t\tspecialVar = eval('document.adminForm.special_languages');\n\t\t\t\tfinalValue = '';\n\t\t\t\tfor (var i=0; i < specialVar.length; i++){\n\t\t\t\t\tif (specialVar[i].checked){\n\t\t\t\t\t\t\t finalValue += specialVar[i].value+',';\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\thiddenVar.value = finalValue;\n\t\t\t}\n\n\t\t}";
$doc = JFactory::getDocument();
$doc->addScriptDeclaration($js);
}
示例11: _getOptions
/**
* Method to get a list of options for a list input.
*
* @return array An array of JHtml options.
*/
protected function _getOptions()
{
jimport('joomla.filesystem.folder');
// path to folders directory
$path = JPATH_ROOT . '/' . $this->_element->attributes()->directory;
$filter = (string) $this->_element->attributes()->filter;
$exclude = (string) $this->_element->attributes()->exclude;
$folders = JFolder::folders($path, $filter);
// Prepare return value
$options = array();
// Add basic options
if (!(string) $this->_element->attributes()->hide_none) {
$options[] = JHtml::_('select.option', '-1', JText::_('JOption_Do_Not_Use'));
}
if (!(string) $this->_element->attributes()->hide_default) {
$options[] = JHtml::_('select.option', '', JText::_('JOption_Use_Default'));
}
// Iterate over folders
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, $folder);
}
}
// Merge any additional options in the XML definition.
$options = array_merge(parent::_getOptions(), $options);
return $options;
}
示例12: fetchElement
function fetchElement($name, $value, &$node, $control_name)
{
jimport('joomla.filesystem.folder');
$mainframe = JFactory::getApplication();
$fieldName = WEJM16 ? $name : $control_name . '[' . $name . ']';
$modulePath = JPATH_SITE . DS . 'modules' . DS . 'mod_we_ufeed_display' . DS . 'tmpl';
$tmplFolders = JFolder::folders($modulePath);
$db = JFactory::getDBO();
$query = "SELECT template FROM #__templates_menu WHERE client_id = 0 AND menuid = 0";
if (WEJM16) {
$query = "SELECT template FROM #__template_styles WHERE client_id = 0 AND home = 1";
}
$db->setQuery($query);
$defaultemplate = $db->loadResult();
$templatePath = JPATH_SITE . DS . 'templates' . DS . $defaultemplate . DS . 'html' . DS . 'mod_we_ufeed_display';
if (JFolder::exists($templatePath)) {
$templateFolders = JFolder::folders($templatePath);
$folders = @array_merge($templateFolders, $tmplFolders);
$folders = @array_unique($folders);
} else {
$folders = $tmplFolders;
}
$exclude = 'default';
$options = array();
foreach ($folders as $folder) {
if (preg_match(chr(1) . $exclude . chr(1), $folder)) {
continue;
}
$options[] = JHTML::_('select.option', $folder, $folder);
}
array_unshift($options, JHTML::_('select.option', '', '-- ' . JText::_('Use Default') . ' --'));
return JHTML::_('select.genericlist', $options, $fieldName, 'class="inputbox"', 'value', 'text', $value, $control_name . $name);
}
示例13: getInput
protected function getInput()
{
$catalog_path = JPATH_SITE . DS . 'modules' . DS . 'mod_image_show_gk4' . DS . 'styles';
$folders = JFolder::folders($catalog_path);
$options = array();
$final_output = '';
if (count($folders) > 0) {
foreach ($folders as $folder) {
$output = '';
// read XML file
$xml =& JFactory::getXMLParser('Simple');
$result = $xml->loadFile($catalog_path . DS . $folder . DS . 'info.xml');
//
foreach ($xml->document->config[0]->field as $field) {
$type = $field->attributes('type');
$output .= '<li>' . $this->generateField($type, $field, $folder) . '</li>';
}
//
$final_output .= '<div id="module_style_' . $folder . '" class="module_style"><ul class="adminformlist">' . $output . '</ul></div>';
}
} else {
$final_output = 'Module have no styles. Please install some style package.';
}
$final_output .= '<textarea name="' . $this->name . '" id="' . $this->id . '" rows="20" cols="50">' . $this->value . '</textarea>';
return $final_output;
}
示例14: getRedcoreComponents
/**
* Get the element name of the components using redcore.
*
* @return array An array of component names (com_redshopb...)
*/
public static function getRedcoreComponents()
{
if (empty(self::$redcoreExtensions)) {
$componentPath = JPATH_ADMINISTRATOR . '/components';
$folders = JFolder::folders($componentPath);
foreach ($folders as $folder) {
$componentFolderPath = $componentPath . '/' . $folder;
$folderFiles = JFolder::files($componentFolderPath, '.xml');
foreach ($folderFiles as $folderFile) {
$componentXmlPath = $componentFolderPath . '/' . $folderFile;
try {
$content = @file_get_contents($componentXmlPath);
if (!is_string($content)) {
continue;
}
$element = new SimpleXMLElement($content);
if (!isset($element->name) || 'com_redcore' === trim(strtolower($element->name))) {
continue;
}
self::$redcoreExtensionManifests[$folder] = $element;
if ($element->xpath('//redcore')) {
self::$redcoreExtensions[] = 'com_' . strstr($folderFile, '.xml', true);
}
} catch (Exception $e) {
JFactory::getApplication()->enqueueMessage($e->getMessage() . ': ' . $folder . '/' . $folderFile, 'error');
}
}
}
}
return self::$redcoreExtensions;
}
示例15: fetchElement
function fetchElement($name, $value, &$node, $control_name)
{
jimport('joomla.filesystem.folder');
$componentPath = JPATH_SITE . DS . 'components' . DS . 'com_k2' . DS . 'templates';
$componentFolders = JFolder::folders($componentPath);
$db =& JFactory::getDBO();
$query = "SELECT template FROM #__templates_menu WHERE client_id = 0 AND menuid = 0";
$db->setQuery($query);
$defaultemplate = $db->loadResult();
if (JFolder::exists(JPATH_SITE . DS . 'templates' . DS . $defaultemplate . DS . 'html' . DS . 'com_k2' . DS . 'templates')) {
$templatePath = JPATH_SITE . DS . 'templates' . DS . $defaultemplate . DS . 'html' . DS . 'com_k2' . DS . 'templates';
} else {
$templatePath = JPATH_SITE . DS . 'templates' . DS . $defaultemplate . DS . 'html' . DS . 'com_k2';
}
if (JFolder::exists($templatePath)) {
$templateFolders = JFolder::folders($templatePath);
$folders = @array_merge($templateFolders, $componentFolders);
$folders = @array_unique($folders);
} else {
$folders = $componentFolders;
}
$exclude = 'default';
$options = array();
foreach ($folders as $folder) {
if (preg_match(chr(1) . $exclude . chr(1), $folder)) {
continue;
}
$options[] = JHTML::_('select.option', $folder, $folder);
}
array_unshift($options, JHTML::_('select.option', '', '-- ' . JText::_('Use default') . ' --'));
return JHTML::_('select.genericlist', $options, '' . $control_name . '[' . $name . ']', 'class="inputbox"', 'value', 'text', $value, $control_name . $name);
}