本文整理汇总了PHP中JFolder::files方法的典型用法代码示例。如果您正苦于以下问题:PHP JFolder::files方法的具体用法?PHP JFolder::files怎么用?PHP JFolder::files使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JFolder
的用法示例。
在下文中一共展示了JFolder::files方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getOptions
protected function getOptions()
{
$options = array();
$path = $this->get('folder');
if (!is_dir($path))
{
$path = JPATH_ROOT . '/' . $path;
}
// Prepend some default options based on field attributes.
if (!$this->get('hidenone', 0))
{
$options[] = JHtml::_('select.option', '-1', JText::alt('JOPTION_DO_NOT_USE', preg_replace('/[^a-zA-Z0-9_\-]/', '_', $this->fieldname)));
}
if (!$this->get('hidedefault', 0))
{
$options[] = JHtml::_('select.option', '', JText::alt('JOPTION_USE_DEFAULT', preg_replace('/[^a-zA-Z0-9_\-]/', '_', $this->fieldname)));
}
// Get a list of files in the search path with the given filter.
$files = JFolder::files($path, $this->get('filter'));
// Build the options list from the list of files.
if (is_array($files))
{
foreach ($files as $file)
{
// Check to see if the file is in the exclude mask.
if ($this->get('exclude'))
{
if (preg_match(chr(1) . $this->get('exclude') . chr(1), $file))
{
continue;
}
}
// If the extension is to be stripped, do it.
if ($this->get('stripext', 1))
{
$file = JFile::stripExt($file);
}
$label = $file;
if ($this->get('language_prefix'))
{
$label = JText::_($this->get('language_prefix') . strtoupper($label));
}
$options[] = JHtml::_('select.option', $file, $label);
}
}
// Merge any additional options in the XML definition.
$options = array_merge(parent::getOptions(), $options);
return $options;
}
示例2: fetchElement
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);
}
示例3: display
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);
}
示例4: getItems
public function getItems()
{
$searchpath = JPATH_ROOT . DIRECTORY_SEPARATOR . "components/com_content";
$items[] = JFolder::files($searchpath);
$items[] = JFolder::listFolderTree($searchpath, '');
return $items;
}
示例5: getOptions
/**
* 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;
}
示例6: fetchElement
/**
* 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));
}
示例7: getExtensionVersion
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 '';
}
}
示例8: unzip
/**
* unzip the file
* @return bool
*/
public function unzip()
{
JRequest::checkToken() or die('Invalid Token');
$appl = JFactory::getApplication();
// if folder doesn't exist - create it!
if (!JFolder::exists($this->pathUnzipped)) {
JFolder::create($this->pathUnzipped);
} else {
// let us remove all previous unzipped files
$folders = JFolder::folders($this->pathUnzipped);
foreach ($folders as $folder) {
JFolder::delete($this->pathUnzipped . '/' . $folder);
}
}
$file = JFolder::files($this->pathArchive);
$result = JArchive::extract($this->pathArchive . '/' . $file[0], $this->pathUnzipped . '/' . $file[0]);
if ($result) {
// scan unzipped folders if we find zip file -> unzip them as well
$this->unzipAll($this->pathUnzipped . '/' . $file[0]);
$message = 'COM_JEDCHECKER_UNZIP_SUCCESS';
} else {
$message = 'COM_JEDCHECKER_UNZIP_FAILED';
}
$appl->redirect('index.php?option=com_jedchecker&view=uploads', JText::_($message));
return $result;
}
示例9: fetchElement
function fetchElement($name, $value, &$node, $control_name)
{
jimport('joomla.filesystem.folder');
jimport('joomla.filesystem.file');
// path to images directory
$path = JPATH_ROOT . DS . $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::_('Do not use') . ' -');
}
if (!$node->attributes('hide_default')) {
$options[] = JHTML::_('select.option', '', '- ' . JText::_('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 . ']', 'class="inputbox"', 'value', 'text', $value, $control_name . $name);
}
示例10: getInput
public function getInput()
{
$this->_templates = JPATH_ROOT . DS . 'modules' . DS . 'mod_rokfeaturetable' . DS . 'templates';
$this->_jtemplate = $this->_getCurrentTemplatePath();
$output = "";
jimport('joomla.filesystem.file');
if (JFolder::exists($this->_templates)) {
$files = JFolder::files($this->_templates, "\\.txt", true, true);
if (JFolder::exists($this->_jtemplate)) {
$jfiles = JFolder::files($this->_jtemplate, "\\.txt", true, true);
if (count($jfiles)) {
$this->merge($files, $jfiles);
}
}
if (count($files)) {
$output = "<select id='templates'>\n";
$output .= "<option value='_select_' class='disabled' selected='selected'>Select a Template</option>";
foreach ($files as $file) {
$title = JFile::stripExt(JFile::getName($file));
$title = str_replace("-", " ", str_replace("_", " ", $title));
$title = ucwords($title);
$output .= "<option value='" . JFile::read($file) . "'>" . $title . "</option>";
}
$output .= "</select>\n";
$output .= "<span id='import-button' class='action-import'><span>import</span></span>\n";
}
} else {
$output = "Templates folder was not found.";
}
return $output;
}
示例11: getArrayImageLinks
public function getArrayImageLinks()
{
$pathRoot = JPath::clean(JPATH_ROOT . DIRECTORY_SEPARATOR . 'images/');
sort($this->path);
for ($p = 0; $p < $this->numberFolder; $p++) {
$ListImage[$p] = JFolder::files($pathRoot . $this->path[$p], $filter = '.');
sort($ListImage[$p]);
}
$tmpListImage = array();
for ($p = 0; $p < $this->numberFolder; $p++) {
$imgInFolder = 0;
$tmpListImage[$p] = array();
for ($n = 0; $n < sizeof($ListImage[$p]); $n++) {
$tmp = $ListImage[$p][$n];
$pattern = '/[^A-Za-z0-9._\\-+\\s]/';
$tmpname = explode('.', $tmp);
$ext = end($tmpname);
if (strtolower($ext) == 'png' || strtolower($ext) == 'jpeg' || strtolower($ext) == 'jpg' || strtolower($ext) == 'gif' || strtolower($ext) == 'bmp') {
if (preg_match($pattern, $tmp)) {
} else {
$tmpListImage[$p][$imgInFolder++] = $ListImage[$p][$n];
}
}
}
}
return $tmpListImage;
}
示例12: load
/**
* Get the list with files from logs folder
*
* <code>
* $logFiles = new CrowdfundingLogFiles();
* $logFiles->load();
*
* foreach ($logFiles as $file) {
* ....
* }
* </code>
*/
public function load()
{
// Read files in folder /logs
$config = \JFactory::getConfig();
/** @var $config Registry */
$logFolder = $config->get('log_path');
$files = \JFolder::files($logFolder);
if (!is_array($files)) {
$files = array();
}
foreach ($files as $key => $file) {
if (strcmp('index.html', $file) !== 0) {
$this->items[] = \JPath::clean($logFolder . DIRECTORY_SEPARATOR . $files[$key]);
}
}
if (count($this->files) > 0) {
foreach ($this->files as $fileName) {
// Check for a file in site folder.
$errorLogFile = \JPath::clean(JPATH_ROOT . DIRECTORY_SEPARATOR . $fileName);
if (\JFile::exists($errorLogFile)) {
$this->items[] = $errorLogFile;
}
// Check for a file in admin folder.
$errorLogFile = \JPath::clean(JPATH_BASE . DIRECTORY_SEPARATOR . $fileName);
if (\JFile::exists($errorLogFile)) {
$this->items[] = $errorLogFile;
}
}
}
sort($this->items);
}
示例13: _findActorIdentifiers
/**
* Return an array of actor identifiers
*
* @return array
*/
protected static function _findActorIdentifiers(KServiceInterface $container)
{
$components = $container->get('repos://admin/components.component')->getQuery()->enabled(true)->fetchSet();
$components = array_unique($container->get('repos://admin/components.component')->fetchSet()->component);
$identifiers = array();
foreach ($components as $component) {
$path = JPATH_SITE . '/components/' . $component . '/domains/entities';
if (!file_exists($path)) {
continue;
}
//get all the files
$files = (array) JFolder::files($path);
//convert com_<Component> to ['com','<Name>']
$parts = explode('_', $component);
$identifier = new KServiceIdentifier('com:' . substr($component, strpos($component, '_') + 1));
$identifier->path = array('domain', 'entity');
foreach ($files as $file) {
$identifier->name = substr($file, 0, strpos($file, '.'));
try {
if (is($identifier->classname, 'ComActorsDomainEntityActor')) {
$identifiers[] = clone $identifier;
}
} catch (Exception $e) {
}
}
}
return $identifiers;
}
示例14: __construct
/**
* Constructor.
*
* @param string $element Element name
* @param string $scope Scope name
* @param string $basePath The base path
*/
public function __construct($element, $scope, $basePath = '')
{
$this->_element = $element;
$this->_scope = $scope;
$this->basePath = $basePath;
parent::__construct($this->group, $this->name, $element, $scope);
//-- Read the files in /options folder
$options = JFolder::files($this->basePath . DS . 'tmpl' . DS . 'options');
foreach ($options as $fName) {
$fContents = JFile::read($this->basePath . DS . 'tmpl' . DS . 'options' . DS . $fName);
$key = JFile::stripExt($fName);
$this->fieldsOptions[$key] = $fContents;
}
//foreach
$this->keys['##ECR_OPTIONS##'] = '__ECR_KEY__';
/*
//# $this->keys['##ECR_VIEW1_TMPL1_TDS##'] = '##ECR_KEY##';
// $this->patterns['##ECR_VIEW1_TMPL1_THS##'] = ' <th>'.NL
// ." <?php echo JHTML::_('grid.sort', '##ECR_KEY##',
// * '##ECR_KEY##', \$this->lists['order_Dir'], \$this->lists['order']);?>".NL
// .' </th>'.NL;
// $this->patterns['##ECR_VIEW1_TMPL1_TDS##'] = ' <td>'.NL
// .' <php echo $row->##ECR_KEY##; ?>'.NL
// .' </td>'.NL;
* */
}
示例15: getSwtFiles
function getSwtFiles()
{
jimport('joomla.filesystem.folder');
$filesDir = 'components' . DS . "com_clm" . DS . 'swt';
$this->swtFiles = JFolder::files($filesDir, '.SWT$|.swt$', false, true);
return $this->swtFiles;
}