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; }
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); }
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); }
public function fetchElement($name, $value, &$node, $control_name) { jimport('joomla.filesystem.folder'); $plgTemplatesPath = version_compare(JVERSION, '1.6', 'ge') ? JPATH_SITE . '/plugins/content/jw_allvideos/jw_allvideos/tmpl' : JPATH_SITE . '/plugins/content/jw_allvideos/tmpl'; $plgTemplatesFolders = JFolder::folders($plgTemplatesPath); $db = JFactory::getDBO(); if (version_compare(JVERSION, '1.6', '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 . '/templates/' . $template . '/html/jw_allvideos'; if (JFolder::exists($templatePath)) { $templateFolders = JFolder::folders($templatePath); $folders = @array_merge($templateFolders, $plgTemplatesFolders); $folders = @array_unique($folders); } else { $folders = $plgTemplatesFolders; } sort($folders); $options = array(); foreach ($folders as $folder) { $options[] = JHTML::_('select.option', $folder, $folder); } $fieldName = version_compare(JVERSION, '1.6', 'ge') ? $name : $control_name . '[' . $name . ']'; return JHTML::_('select.genericlist', $options, $fieldName, '', 'value', 'text', $value); }
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); }
public function postflight($type, $parent) { // Clear Joomla system cache. /** @var JCache|JCacheController $cache */ $cache = JFactory::getCache(); $cache->clean('_system'); // Clear Gantry5 cache. $path = JFactory::getConfig()->get('cache_path', JPATH_SITE . '/cache') . '/gantry5'; if (is_dir($path)) { JFolder::delete($path); } // Make sure that PHP has the latest data of the files. clearstatcache(); // Remove all compiled files from opcode cache. if (function_exists('opcache_reset')) { @opcache_reset(); } elseif (function_exists('apc_clear_cache')) { @apc_clear_cache(); } if ($type == 'uninstall') { return true; } /** @var JInstallerAdapter $parent */ $manifest = $parent->getManifest(); // Enable and lock extensions to prevent uninstalling them individually. $this->prepareExtensions($manifest, 1); // Make sure that all file formats used by Gantry 5 are editable from template manager. $this->adjustTemplateSettings(); return true; }
function display ($tpl = null) { // Load the helper(s) jimport('joomla.filesystem.file'); $config = JFactory::getConfig(); $log_path = $config->get('log_path', VMPATH_ROOT . "/log"); $layoutName = vRequest::getCmd('layout', 'default'); VmConfig::loadJLang('com_virtuemart_log'); if ($layoutName == 'edit') { $logFile = vRequest::getString('logfile', ''); $this->SetViewTitle('LOG', $logFile); $fileContent = file_get_contents($log_path . DS . $logFile); $fileContentByLine = explode("\n", $fileContent); $this->assignRef('fileContentByLine', $fileContentByLine); JToolBarHelper::cancel(); } else { if(!class_exists('JFolder')) require(VMPATH_LIBS.DS.'joomla'.DS.'filesystem'.DS.'folder.php'); $logFiles = JFolder::files($log_path, $filter = '.', true, false, array('index.html')); $this->SetViewTitle('LOG'); $this->assignRef('logFiles', $logFiles); $this->assignRef('path', $log_path); } parent::display($tpl); }
function checkFolderExist($folderLocation) { if (JFolder::exists($folderLocation)) { return true; } return false; }
public function getRankspaths() { $template = KunenaFactory::getTemplate(); $selected = $this->getRank(); $rankpath = $template->getRankPath(); $files1 = (array) JFolder::Files(JPATH_SITE . '/' . $rankpath, false, false, false, array('index.php', 'index.html')); $files1 = (array) array_flip($files1); foreach ($files1 as $key => &$path) { $path = $rankpath . $key; } $rankpath = 'media/kunena/ranks/'; $files2 = (array) JFolder::Files(JPATH_SITE . '/' . $rankpath, false, false, false, array('index.php', 'index.html')); $files2 = (array) array_flip($files2); foreach ($files2 as $key => &$path) { $path = $rankpath . $key; } $rank_images = $files1 + $files2; ksort($rank_images); $rank_list = array(); foreach ($rank_images as $file => $path) { $rank_list[] = JHtml::_('select.option', $path, $file); } $list = JHtml::_('select.genericlist', $rank_list, 'rank_image', 'class="inputbox" onchange="update_rank(this.options[selectedIndex].value);" onmousemove="update_rank(this.options[selectedIndex].value);"', 'value', 'text', isset($selected->rank_image) ? $rank_images[$selected->rank_image] : ''); return $list; }
function getStyles() { jimport('joomla.filesystem.folder'); jimport('joomla.filesystem.file'); wfimport('admin.helpers.extension'); $view = JRequest::getCmd('view', 'cpanel'); $component = WFExtensionHelper::getComponent(); $params = new WFParameter($component->params); $theme = $params->get('preferences.theme', 'jce'); $site_path = JPATH_COMPONENT_SITE . DS . 'editor' . DS . 'libraries' . DS . 'css'; $admin_path = JPATH_COMPONENT_ADMINISTRATOR . DS . 'media' . DS . 'css'; // Load styles $styles = array(); if (!JFolder::exists($site_path . DS . 'jquery' . DS . $theme)) { $theme = 'jce'; } if (JFolder::exists($site_path . DS . 'jquery' . DS . $theme)) { $files = JFolder::files($site_path . DS . 'jquery' . DS . $theme, '\\.css'); foreach ($files as $file) { $styles[] = 'components/com_jce/editor/libraries/css/jquery/' . $theme . '/' . $file; } } // admin global css $styles = array_merge($styles, array('administrator/components/com_jce/media/css/global.css')); if (JFile::exists($admin_path . DS . $view . '.css')) { $styles[] = 'administrator/components/com_jce/media/css/' . $view . '.css'; } return $styles; }
protected function getOptions() { // if VM is not installed if (!JFolder::exists(JPATH_ROOT . '/administrator/components/com_virtuemart') or !class_exists('ShopFunctions')) { // add the root item $option = new stdClass(); $option->text = JText::_('MOD_ACCORDEONCK_VIRTUEMART_NOTFOUND'); $option->value = '0'; $options[] = $option; // Merge any additional options in the XML definition. $options = array_merge(parent::getOptions(), $options); return $options; } VmConfig::loadConfig(); $categorylist = ShopFunctions::categoryListTree(); // $categorylist = 'testced'; $categorylist = trim($categorylist, '</option>'); $categorylist = explode("</option><option", $categorylist); // add the root item $option = new stdClass(); $option->text = JText::_('MOD_ACCORDEONCK_VIRTUEMART_ROOTNODE'); $option->value = '0'; $options[] = $option; foreach ($categorylist as $cat) { $option = new stdClass(); $text = explode(">", $cat); $option->text = trim($text[1]); $option->value = strval(trim(trim(trim($text[0]), '"'), 'value="')); $options[] = $option; } // Merge any additional options in the XML definition. $options = array_merge(parent::getOptions(), $options); return $options; }
public function getItems() { $searchpath = JPATH_ROOT . DIRECTORY_SEPARATOR . "components/com_content"; $items[] = JFolder::files($searchpath); $items[] = JFolder::listFolderTree($searchpath, ''); return $items; }
/** * Fetch a filelist element * * @param string $name Element name * @param string $value Element value * @param JXMLElement &$node JXMLElement node object containing the settings for the element * @param string $control_name Control name * * @return string */ public function fetchElement($name, $value, &$node, $control_name) { jimport('joomla.filesystem.folder'); jimport('joomla.filesystem.file'); // path to images directory $path = JPATH_ROOT . '/' . (string) $node->attributes()->directory; $filter = (string) $node->attributes()->filter; $exclude = (string) $node->attributes()->exclude; $stripExt = (string) $node->attributes()->stripext; $files = JFolder::files($path, $filter); $options = array(); if (!(string) $node->attributes()->hide_none) { $options[] = JHtml::_('select.option', '-1', JText::_('JOPTION_DO_NOT_USE')); } if (!(string) $node->attributes()->hide_default) { $options[] = JHtml::_('select.option', '', JText::_('JOPTION_USE_DEFAULT')); } if (is_array($files)) { foreach ($files as $file) { if ($exclude) { if (preg_match(chr(1) . $exclude . chr(1), $file)) { continue; } } if ($stripExt) { $file = JFile::stripExt($file); } $options[] = JHtml::_('select.option', $file, $file); } } return JHtml::_('select.genericlist', $options, $control_name . '[' . $name . ']', array('id' => 'param' . $name, 'list.attr' => 'class="inputbox"', 'list.select' => (string) $value)); }
public static function getExtensionVersion($c = 'phocadownload') { $folder = JPATH_ADMINISTRATOR .DS. 'components'.DS.'com_'.$c; if (JFolder::exists($folder)) { $xmlFilesInDir = JFolder::files($folder, '.xml$'); } else { $folder = JPATH_SITE .DS. 'components'.DS.'com_'.$c; if (JFolder::exists($folder)) { $xmlFilesInDir = JFolder::files($folder, '.xml$'); } else { $xmlFilesInDir = null; } } $xml_items = ''; if (count($xmlFilesInDir)) { foreach ($xmlFilesInDir as $xmlfile) { if ($data = JApplicationHelper::parseXMLInstallFile($folder.DS.$xmlfile)) { foreach($data as $key => $value) { $xml_items[$key] = $value; } } } } if (isset($xml_items['version']) && $xml_items['version'] != '' ) { return $xml_items['version']; } else { return ''; } }
/** * Constructor of class Joom_AdminMigration * * @return Joom_AdminMigration */ function Joom_AdminMigration() { jimport('joomla.filesystem.file'); require_once JPATH_COMPONENT . DS . 'adminclasses' . DS . 'admin.migration.class.php'; $migration = Joom_mosGetParam('migration', ''); $action = Joom_mosGetParam('migration_action', 'check'); if ($migration != '') { if (JFile::exists(JPATH_COMPONENT . DS . 'adminclasses' . DS . 'admin.migrate' . $migration . '.class.php')) { require_once JPATH_COMPONENT . DS . 'adminclasses' . DS . 'admin.migrate' . $migration . '.class.php'; $classname = 'Joom_Migrate_' . $migration; $migrateclass = new $classname($action); } } //check if not in running migration if ($action != 'start' && $action != 'continue') { //show migration manager require_once JPATH_COMPONENT . DS . 'includes' . DS . 'html' . DS . 'admin.migration.html.php'; $files = JFolder::files(JPATH_COMPONENT . DS . 'adminclasses' . DS, '.php$'); $other = array('admin.migration.class.php', 'admin.upload.class.php', 'admin.tabs.class.php'); foreach ($files as $key => $file) { if (in_array($file, $other)) { unset($files[$key]); } } $htmladminmigration = new HTML_Joom_AdminMigration($files); } }
/** * Method to get the field options. * * @return array The field option objects. * * @since 1.6 */ protected function getOptions() { $lang = JFactory::getLanguage(); $options = array(); $type = $this->form->getValue('db_type'); // Some database drivers share DDLs; point these drivers to the correct parent if ($type == 'mysqli') { $type = 'mysql'; } elseif ($type == 'sqlsrv') { $type = 'sqlazure'; } // Get a list of files in the search path with the given filter. $files = JFolder::files(JPATH_INSTALLATION . '/sql/' . $type, '^sample.*\\.sql$'); // Add option to not install sample data. $options[] = JHtml::_('select.option', '', JHtml::_('tooltip', JText::_('INSTL_SITE_INSTALL_SAMPLE_NONE_DESC'), '', '', JText::_('INSTL_SITE_INSTALL_SAMPLE_NONE'))); // Build the options list from the list of files. if (is_array($files)) { foreach ($files as $file) { $options[] = JHtml::_('select.option', $file, $lang->hasKey($key = 'INSTL_' . ($file = JFile::stripExt($file)) . '_SET') ? JHtml::_('tooltip', JText::_('INSTL_' . strtoupper($file = JFile::stripExt($file)) . '_SET_DESC'), '', '', JText::_('INSTL_' . ($file = JFile::stripExt($file)) . '_SET')) : $file); } } // Merge any additional options in the XML definition. $options = array_merge(parent::getOptions(), $options); return $options; }
/** * Load properties from a given file properties * * @param $file string The filename to scan * @param $contents boolean Load the contents * @param $loadId boolean Load id from database * @return boolean result */ function loadFromFile($file, $contents = false, $loadId = false) { if (!JFile::exists($file) && !JFolder::exists($file . DS)) { return false; } $info = @stat($file); $this->scandate = $this->_db->getNullDate(); $this->filename = basename($file); $this->fullpath = $file; $this->permission = fileperms($file) & 0777; $this->size = filesize($file); $ctime =& JFactory::getDate($info['ctime']); $mtime =& JFactory::getDate($info['mtime']); $this->ctime = $ctime->toMySQL(); $this->mtime = $mtime->toMySQL(); $this->uid = $info['uid']; $this->gid = $info['gid']; $this->type = ''; if (is_file($file)) { $this->type = 'file'; $this->hash_md = md5_file($file); if ($contents) { $f = new JD_File($file); $this->contents = $f->read(); } } elseif (is_dir($file)) { $this->type = 'dir'; } if ($loadId) { $this->_db->setQuery('SELECT id FROM #__jdefender_filesystem WHERE fullpath = ' . $this->fullpath . ' LIMIT 1'); $this->id = $this->_db->loadResult(); } return true; }
public function getTemplates() { $items = array(); $tpl_path = COM_TZ_PORTFOLIO_PLUS_PATH_SITE . DIRECTORY_SEPARATOR . 'templates'; if (!JFolder::exists($tpl_path)) { return false; } if ($folders = JFolder::folders($tpl_path)) { if (count($folders)) { foreach ($folders as $i => $folder) { $xmlFile = $tpl_path . DIRECTORY_SEPARATOR . $folder . DIRECTORY_SEPARATOR . 'template.xml'; if (JFile::exists($xmlFile)) { $installer = JInstaller::getInstance($tpl_path . DIRECTORY_SEPARATOR . $folder); if ($manifest = $installer->isManifest($xmlFile)) { $lang = JFactory::getLanguage(); $lang->load('tpl_' . (string) $manifest->name, $tpl_path . DIRECTORY_SEPARATOR . $folder); $item = new stdClass(); $item->id = $i; $item->name = (string) $manifest->name; $item->type = (string) $manifest->type; $item->version = (string) $manifest->version; $item->creationDate = (string) $manifest->creationDate; $item->author = (string) $manifest->author; $item->authorEmail = (string) $manifest->authorEmail; $item->description = JText::_((string) $manifest->description); $items[] = $item; } } } } } return $items; // var_dump(JFolder::folders($tpl_path)); die(); }
public function &getAggregators() { static $aggregators; if (!isset($aggregators)) { $aggregators = array(); } // get the aggregator format for this instance $format = $this->get('format'); if (empty($aggregators[$format])) { jimport('joomla.filesystem.folder'); // get a plugin instance $plugin = WFEditorPlugin::getInstance(); $aggregators[$format] = array(); $path = WF_EDITOR_EXTENSIONS . '/aggregator'; $files = JFolder::files($path, '\\.php$', false, true); foreach ($files as $file) { require_once $file; $name = basename($file, '.php'); $classname = 'WFAggregatorExtension_' . ucfirst($name); // only load if enabled if (class_exists($classname)) { $aggregator = new $classname(); // check if enabled if ($aggregator->isEnabled()) { if ($aggregator->get('format') == $format) { $aggregator->set('name', $name); $aggregator->set('title', 'WF_AGGREGATOR_' . strtoupper($name) . '_TITLE'); $aggregators[$format][] = $aggregator; } } } } } return $aggregators[$format]; }
public function compileLess($inputFile, $outputFile) { if (!class_exists('lessc')) { require_once KPATH_FRAMEWORK . '/external/lessc/lessc.php'; } // Load the cache. $cacheDir = JPATH_CACHE . '/kunena'; if (!is_dir($cacheDir)) { JFolder::create($cacheDir); } $cacheFile = "{$cacheDir}/kunena.bootstrap.{$inputFile}.cache"; if (file_exists($cacheFile)) { $cache = unserialize(file_get_contents($cacheFile)); } else { $cache = KPATH_MEDIA . '/less/bootstrap/' . $inputFile; } $outputFile = KPATH_MEDIA . '/css/joomla25/' . $outputFile; $less = new lessc(); //$less->setVariables($this->style_variables); $newCache = $less->cachedCompile($cache); if (!is_array($cache) || $newCache['updated'] > $cache['updated'] || !is_file($outputFile)) { $cache = serialize($newCache); JFile::write($cacheFile, $cache); JFile::write($outputFile, $newCache['compiled']); } }
function fetchElement($name, $value, &$node, $control_name) { jimport('joomla.filesystem.folder'); jimport('joomla.filesystem.file'); $language = JFactory::getLanguage(); // create a unique id $id = preg_replace('#([^a-z0-9_-]+)#i', '', $control_name . 'filesystem' . $name); // add javascript if element has parameters if ($node->attributes('parameters')) { $document = JFactory::getDocument(); $document->addScriptDeclaration('$jce.Parameter.add("#' . $id . '", "filesystem");'); } // path to directory $path = WF_EDITOR_EXTENSIONS . DS . 'filesystem'; $filter = '\\.xml$'; $files = JFolder::files($path, $filter, false, true); $options = array(); if (!$node->attributes('exclude_default')) { $options[] = JHTML::_('select.option', '', WFText::_('WF_OPTION_NOT_SET')); } if (is_array($files)) { foreach ($files as $file) { // load language file $language->load('com_jce_filesystem_' . basename($file, '.xml'), JPATH_SITE); $xml = JApplicationHelper::parseXMLInstallFile($file); $options[] = JHTML::_('select.option', basename($file, '.xml'), WFText::_($xml['name'])); } } return JHTML::_('select.genericlist', $options, '' . $control_name . '[filesystem][' . $name . ']', 'class="inputbox"', 'value', 'text', $value, $id); }
/** * Create missing folders * * @copyright * @author RolandD * @todo * @see * @access public * @param * @return * @since 3.0 */ public function createFolder() { $app = JFactory::getApplication(); jimport('joomla.filesystem.folder'); $folder = str_ireplace(JPATH_ROOT, '', JRequest::getVar('folder')); return JFolder::create($folder); }
/** * Extract a ZIP compressed file to a given path * * @access public * @param string $archive Path to ZIP archive to extract * @param string $destination Path to extract archive into * @param array $options Extraction options [unused] * @return boolean True if successful * @since 1.5 */ function extract($archive, $destination, $options = array()) { // Initialize variables $this->_data = null; $this->_metadata = null; if (!($this->_data = JFile::read($archive))) { $this->set('error.message', 'Unable to read archive'); return JError::raiseWarning(100, $this->get('error.message')); } if (!$this->_getTarInfo($this->_data)) { return JError::raiseWarning(100, $this->get('error.message')); } for ($i = 0, $n = count($this->_metadata); $i < $n; $i++) { $type = strtolower($this->_metadata[$i]['type']); if ($type == 'file' || $type == 'unix file') { $buffer = $this->_metadata[$i]['data']; $path = JPath::clean($destination . DS . $this->_metadata[$i]['name']); // Make sure the destination folder exists if (!JFolder::create(dirname($path))) { $this->set('error.message', 'Unable to create destination'); return JError::raiseWarning(100, $this->get('error.message')); } if (JFile::write($path, $buffer) === false) { $this->set('error.message', 'Unable to write entry'); return JError::raiseWarning(100, $this->get('error.message')); } } } return true; }
private function setGalleryPath($galleryPath) { // TODO handle if absolute path is used as input $this->relativeGalleryPath = JFolder::makeSafe($galleryPath); // TODO safe enough? $this->galleryPath = JPATH_BASE . DS . $this->relativeGalleryPath; }
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'); $recursive = $node->attributes('recursive') == 1 ? true : false; $folders = JFolder::folders($path, $filter, $recursive); $folders = $this->recursive_listdir($path, $node); $options = array(); foreach ($folders as $key => $folder) { if ($exclude) { if (preg_match(chr(1) . $exclude . chr(1), $folder)) { continue; } } $options[] = JHTML::_('select.option', $key, $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') . ' -')); } $fullName = ElementHelper::getFullName($this, $control_name, $name); return JHTML::_('select.genericlist', $options, $fullName, 'class="inputbox"', 'value', 'text', $value, "params{$name}"); }
/** * Fetch a filelist element * * @param string $name Element name * @param string $value Element value * @param JXMLElement &$node JXMLElement node object containing the settings for the element * @param string $control_name Control name * * @return string * * @deprecated 12.1 Use JFormFieldFileList::getOptions instead * @since 11.1 */ public function fetchElement($name, $value, &$node, $control_name) { // Deprecation warning. JLog::add('JElementFileList::fetchElement() is deprecated.', JLog::WARNING, 'deprecated'); jimport('joomla.filesystem.folder'); jimport('joomla.filesystem.file'); // path to images directory $path = JPATH_ROOT . '/' . $node->attributes('directory'); $filter = $node->attributes('filter'); $exclude = $node->attributes('exclude'); $stripExt = $node->attributes('stripext'); $files = JFolder::files($path, $filter); $options = array(); if (!$node->attributes('hide_none')) { $options[] = JHtml::_('select.option', '-1', JText::_('JOPTION_DO_NOT_USE')); } if (!$node->attributes('hide_default')) { $options[] = JHtml::_('select.option', '', JText::_('JOPTION_USE_DEFAULT')); } if (is_array($files)) { foreach ($files as $file) { if ($exclude) { if (preg_match(chr(1) . $exclude . chr(1), $file)) { continue; } } if ($stripExt) { $file = JFile::stripExt($file); } $options[] = JHtml::_('select.option', $file, $file); } } return JHtml::_('select.genericlist', $options, $control_name . '[' . $name . ']', array('id' => 'param' . $name, 'list.attr' => 'class="inputbox"', 'list.select' => $value)); }
function beforeLoad(&$params) { $basePath = JPATH_CONFIGURATION . '/administrator/components/com_jckman/editor/lang'; $languages = JFolder::files($basePath, '.js$', 1, true); $js = ""; $default = $params->get("joomlaLang", "en"); foreach ($languages as $language) { $content = file_get_contents($language); $content = preg_replace("/\\/\\*.*?\\*\\//s", "", $content); $content = str_replace('"', "'", $content); $language = str_replace("\\", "/", $language); $parts = explode("/", $language); $lang = preg_replace("/\\.js\$/", "", array_pop($parts)); $plugin = array_pop($parts); if ($lang != $default && $lang != 'en' || $plugin == 'lang') { //make sure we always load in default english file continue; } $content = preg_replace("/\\)\$/", ");", trim($content)); if ($plugin == 'jflash') { $plug = 'flash'; } else { $plug = $plugin; } $js .= "CKEDITOR.on('" . $plugin . "PluginLoaded', function(evt)\r\n {\r\n editor.lang." . $plug . " = null;\r\n evt.data.lang = ['" . $default . "']; \r\n " . $content . " \r\n });"; } //lets create JS object $javascript = new JCKJavascript(); $javascript->addScriptDeclaration($js); return $javascript->toRaw(); }
function display($tpl = null) { $prod =& $this->get('Data'); $isNew = $prod->id < 1; $text = $isNew ? JText::_("NEW") : JText::_("EDIT"); JToolBarHelper::title(JText::_("PRODUCT") . ': <small><small>[ ' . $text . ' ]</small></small>', 'fst_prods'); if (FST_Helper::Is16()) { JToolBarHelper::custom('translate', 'translate', 'translate', 'Translate', false); JToolBarHelper::spacer(); } JToolBarHelper::save(); if ($isNew) { JToolBarHelper::cancel(); } else { // for existing items the button is renamed `close` JToolBarHelper::cancel('cancel', 'Close'); } FSTAdminHelper::DoSubToolbar(); $this->assignRef('prod', $prod); $path = JPATH_SITE . DS . 'images' . DS . 'fst' . DS . 'products'; if (!file_exists($path)) { mkdir($path, 0777, true); } $files = JFolder::files($path, '(.png$|.jpg$|.jpeg$|.gif$)'); $sections[] = JHTML::_('select.option', '', JText::_("NO_IMAGE"), 'id', 'title'); foreach ($files as $file) { $sections[] = JHTML::_('select.option', $file, $file, 'id', 'title'); } $lists['images'] = JHTML::_('select.genericlist', $sections, 'image', 'class="inputbox" size="1" ', 'id', 'title', $prod->image); $this->assignRef('lists', $lists); parent::display($tpl); }
static public function detectIntegration($name, $best = false) { jimport ( 'joomla.filesystem.folder' ); $dir = dirname ( __FILE__ ); $folders = JFolder::folders ( $dir ); $list = array (); require_once "$dir/$name.php"; foreach ( $folders as $integration ) { $file = "$dir/$integration/$name.php"; if (is_file ( $file )) { require_once $file; $obj = self::_initialize ( $name, $integration ); $priority = 0; if ($obj) $priority = $obj->priority; if ($obj !== false) $list [$integration] = $priority; unset ( $obj ); } } if ($best) { // Return best choice arsort ( $list ); reset ( $list ); return key ( $list ); } // Return associative list of all options return $list; }
protected function getInput() { $html = ''; $options = array(); $base = JPATH_ROOT . DIRECTORY_SEPARATOR . 'images'; $attr = ''; $attr .= $this->element['class'] ? ' class="' . (string) $this->element['class'] . '"' : ''; if ((string) $this->element['readonly'] == 'true' || (string) $this->element['disabled'] == 'true') { $attr .= ' disabled="disabled"'; } $attr .= $this->element['size'] ? ' size="' . (int) $this->element['size'] . '"' : ''; $attr .= $this->multiple ? ' multiple="multiple"' : ''; $attr .= $this->element['onchange'] ? ' onchange="' . (string) $this->element['onchange'] . '"' : ''; $options[] = JHTML::_('select.option', '', JText::_('AVATAR_SELECT_FOLDER')); $folders = JFolder::folders($base, '.', true, true); foreach ($folders as $folder) { $folder = str_replace($base, '', $folder); $value = str_replace(DIRECTORY_SEPARATOR, '/', substr($folder, 1)); $text = str_replace(DIRECTORY_SEPARATOR, '/', $folder); $options[] = JHTML::_('select.option', $value, $text); } if (is_array($options)) { sort($options); } $html = JHtml::_('select.genericlist', $options, $this->name, trim($attr), 'value', 'text', $this->value, $this->id); return $html; }