Example #1
0
 /**
  *
  */
 public function prepare()
 {
     $this->fetched = $this->fetch();
     $this->fetched->rewind();
     $this->filtered = $this->filter($this->fetched);
     $this->filtered->rewind();
     $this->sorted = $this->sort($this->filtered);
     $this->sorted->rewind();
 }
Example #2
0
 /**
  * Returns if a given directory has tests (recursively)
  *
  * @param string $dir full path to the directory to look for phpunit tests
  * @param string $testtype phpunit|behat
  * @return bool if a given directory has tests (true) or no (false)
  */
 private static function directory_has_tests($dir, $testtype)
 {
     if (!is_dir($dir)) {
         return false;
     }
     $dirite = new RecursiveDirectoryIterator($dir);
     $iteite = new RecursiveIteratorIterator($dirite);
     $regexp = self::get_regexp($testtype);
     $regite = new RegexIterator($iteite, $regexp);
     $regite->rewind();
     if ($regite->valid()) {
         return true;
     }
     return false;
 }
Example #3
0
 private function findFile(string $fileName, string $extension)
 {
     $iterator = new \RegexIterator(new \DirectoryIterator($this->downloadPath), sprintf('/%s\\.%s$/ui', preg_quote(pathinfo($fileName, PATHINFO_FILENAME), '/'), '(' . $extension . ')'), \RegexIterator::GET_MATCH);
     $iterator->rewind();
     return $iterator->current()[0];
 }
Example #4
0
 /**
  * Returns if a given directory has tests (recursively)
  *
  * @param $dir string full path to the directory to look for phpunit tests
  * @return bool if a given directory has tests (true) or no (false)
  */
 private static function directory_has_tests($dir)
 {
     if (!is_dir($dir)) {
         return false;
     }
     $dirite = new RecursiveDirectoryIterator($dir);
     $iteite = new RecursiveIteratorIterator($dirite);
     $sep = preg_quote(DIRECTORY_SEPARATOR, '|');
     $regite = new RegexIterator($iteite, '|' . $sep . 'tests' . $sep . '.*_test\\.php$|');
     $regite->rewind();
     if ($regite->valid()) {
         return true;
     }
     return false;
 }
        echo '>' . $this->_valeur . '</div>' . PHP_EOL;
    }
}
?>

<style>
    .vert{ color: green; margin-left: 25px; }
    .bleu{color: blue; }
</style>
<h2>Mon Filtre avec while</h2>

<?php 
$DirectoryIterator = new MonDI('./');
//print_r($DirectoryIterator);
$Iterator_iterator = new MonFilter($DirectoryIterator);
$Iterator_iterator->rewind();
while ($Iterator_iterator->valid()) {
    $Iterator_iterator->afficher_valeur();
    $Iterator_iterator->next();
}
echo '<h2>RegexIterator avec while</h2>';
$RegexIterator = new RegexIterator($DirectoryIterator, '#rep#');
$RegexIterator->rewind();
while ($RegexIterator->valid()) {
    echo $RegexIterator->current()->getFilename() . '<br />';
    $RegexIterator->next();
}
echo '<h2>RegexIterator avec foreach</h2>';
foreach ($RegexIterator as $Resultat) {
    echo $Resultat . '<br />';
}
Example #6
0
echo JText::_('FLEXI_EDIT_LAYOUT_FILES');
?>
</h3>
			
			<div id="layout-filelist-container" class="span4" style="margin:0.5%;">
				<span class="fcsep_level0" style="margin:0 0 12px 0; background-color:#333; ">
					<span class="badge"><?php 
echo JText::_('FLEXI_LAYOUT_FILES');
?>
</span>
				</span>
				<?php 
$tmpldir = JPATH_ROOT . DS . 'components' . DS . 'com_flexicontent' . DS . 'templates' . DS . $this->layout->name;
$it = new RegexIterator(new RecursiveIteratorIterator(new RecursiveDirectoryIterator($tmpldir)), '#' . $this->layout->view . '(_.*\\.|\\.)(php|xml|css|js)#i');
//$it = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($tmpldir));
$it->rewind();
$ext_badge = array('php' => 'success', 'xml' => 'info', 'css' => 'warning', 'js' => 'important', 'ini' => 'info');
$file_tip = array('item.css' => 'Contains CSS specific to this item layout', 'category.css' => 'Contains CSS specific to this category layout', 'item.xml' => 'Layout\'s structure: including display parameters, field positions, file list, etc', 'category.xml' => 'Layout\'s structure: including display parameters, field positions, file list, etc', 'item.php' => 'PHP/HTML to display item\'s fields', 'category_items.php' => 'Item list filtering form, and Item loop (displaying every item)', 'category.php' => 'Top-level container of the layout', 'category_category.php' => 'Displays category information: title, description, image, etc', 'category_category_html5.php' => 'Displays category information: title, description, image, etc', 'category_alpha.php' => 'Displays the alphanumerical index of the item list', 'category_peercategories.php' => 'Displays the peer categories list', 'category_subcategories.php' => 'Display the sub-categories list');
$file_tip['item_html5.php'] = $file_tip['item.php'] . ' (HTML5 version)';
$file_tip['category_items_html5.php'] = $file_tip['category_items.php'] . ' (HTML5 version)';
$file_tip['category_html5.php'] = $file_tip['category.php'] . ' (HTML5 version)';
$file_tip['category_category_html5.php'] = $file_tip['category_category.php'] . ' (HTML5 version)';
$file_tip['category_alpha_html5.php'] = $file_tip['category_alpha.php'] . ' (HTML5 version)';
$file_tip['category_peercategories_html5.php'] = $file_tip['category_peercategories.php'] . ' (HTML5 version)';
$file_tip['category_subcategories_html5.php'] = $file_tip['category_subcategories.php'] . ' (HTML5 version)';
$file_tip_extra = array('item.xml' => 'This file contains layout\' s structure: including <br/> - <b>display parameters, field positions, file list, etc</b>, <br/> - you can add extra parameters/positions, <br/>-- if you add a new position, you will need to also add the dispay -LOOP- of the new position inside files: <br/><b>item.php</b> <br/><b>item_html5.php</b> <br/><br/>(click to edit file and then use the code button)', 'category.xml' => 'This file contains layout\' s structure: including <br/> - <b>display parameters, field positions, file list, etc</b>, <br/> - you can add extra parameters/positions, <br/>-- if you add a new position, you will need to also add the dispay -LOOP- of the new position inside files: <br/><b>category_items.php</b> <br/><b>category_items_html5.php</b> <br/><br/>(click to edit file and then use the code button)', 'item.php' => 'This file display the item, thus has display LOOPs of for every position to show fields of every position, if you add new position in the XML file, then make sure that you ADD the display loop here <br/><br/>(click to edit file and then use the code button)', 'category_items.php' => 'This file includes: <br/><br/>- Item list filtering form, <br/>- Item loop (that displays every item\'s fields), <br/><br/>if you add new field position in the XML file, then make sure that you ADD here, the display loop that displays the fields of the position <br/><br/>(click to edit file and then use the code button)');
$file_tip_extra['item_html5.php'] = $file_tip_extra['item.php'];
$file_tip_extra['category_items_html5.php'] = $file_tip_extra['category_items.php'];
$file_code_btns = array('item.xml' => array('fieldPosXML' => 1, 'paramTextXML' => 1, 'paramRadioXML' => 1, 'paramSelectXML' => 1), 'category.xml' => array('fieldPosXML' => 1, 'paramTextXML' => 1, 'paramRadioXML' => 1, 'paramSelectXML' => 1), 'item.php' => array('itemPosHTML' => 1, 'itemFieldDisplay' => 1), 'category_items.php' => array('catPosHTML' => 1, 'catFieldDisplay' => 1));
$file_code_btns['item_html5.php'] = $file_code_btns['item.php'];
$file_code_btns['category_items_html5.php'] = $file_code_btns['category_items.php'];
 private function folderContains($folderPath, $filePattern)
 {
     if (!is_dir($folderPath)) {
         return false;
     }
     $directoryIterator = new \RecursiveDirectoryIterator($folderPath);
     $flatIterator = new \RecursiveIteratorIterator($directoryIterator);
     $fileIterator = new \RegexIterator($flatIterator, $filePattern, \RegexIterator::GET_MATCH);
     $fileIterator->rewind();
     return $fileIterator->valid();
 }
 /**
  * Method to get files having the given extensions from a given folder
  *
  * @access private
  * @return integer
  * @since 1.0
  */
 function getFilesFromPath($itemid, $fieldid, $append_item = 1, $append_field = 0, $folder_param_name = 'dir', $exts = 'bmp,csv,doc,docx,gif,ico,jpg,jpeg,odg,odp,ods,odt,pdf,png,ppt,pptx,swf,txt,xcf,xls,xlsx,zip,ics')
 {
     $app = JFactory::getApplication();
     $option = JRequest::getVar('option');
     $imageexts = array('jpg', 'gif', 'png', 'bmp', 'jpeg');
     // Common image extensions
     $gallery_folder = $this->getFieldFolderPath($itemid, $fieldid, $append_item, $append_field, $folder_param_name);
     //echo $gallery_folder ."<br />";
     // Create folder for current language
     if (!is_dir($gallery_folder)) {
         mkdir($gallery_folder, $mode = 0755, $recursive = true);
     }
     // Get file list according to filtering
     $exts = preg_replace("/[\\s]*,[\\s]*/", '|', $exts);
     $it = new RegexIterator(new RecursiveIteratorIterator(new RecursiveDirectoryIterator($gallery_folder)), '#(.*\\.)(' . $exts . ')#i');
     $it->rewind();
     // Get file information
     $rows = array();
     $i = 1;
     while ($it->valid()) {
         if ($it->isDot()) {
             $it->next();
             continue;
         }
         $filesubpath = $it->getSubPathName();
         // filename including the folder subpath
         $filepath = $it->key();
         $pinfo = pathinfo($filepath);
         $row = new stdClass();
         $row->ext = $pinfo['extension'];
         $row->filename = $filesubpath;
         //$pinfo['filename'].".".$pinfo['extension'];
         $row->size = sprintf("%.0f KB", filesize($filepath) / 1024);
         $row->altname = $pinfo['filename'];
         $row->uploader = '-';
         $row->uploaded = date("F d Y H:i:s.", filectime($filepath));
         $row->id = $i;
         if (in_array(strtolower($row->ext), $imageexts)) {
             $row->icon = JURI::root() . "components/com_flexicontent/assets/images/mime-icon-16/image.png";
         } elseif (file_exists(JPATH_SITE . "/components/com_flexicontent/assets/images/mime-icon-16/" . $row->ext . ".png")) {
             $row->icon = JURI::root() . "components/com_flexicontent/assets/images/mime-icon-16/" . $row->ext . ".png";
         } else {
             $row->icon = JURI::root() . "components/com_flexicontent/assets/images/mime-icon-16/unknown.png";
         }
         $rows[] = $row;
         $i++;
         $it->next();
     }
     return $rows;
 }
Example #9
0
 /**
  * Find templates/resources for the given path.
  *
  * <p><strong>Example:</strong></p>
  *
  * <p>Find all styles in a particular folder (<em>style</em>).</p>
  * <code><pre>
  *   $styles = $this->find('style', '/css/');
  *   foreach ($styles as $name => $url) {
  *    echo '<link rel="stylesheet" type="text/css" href="'.$url.'"/>';
  *   }
  * </pre></code>
  *
  * <p>Alternatively, using the build in $resource manager, it would look like this:</p>
  * <code><pre>
  *   $styles = $this->find('style', '/css/');
  *   foreach ($styles as $name => $url) {
  *    $resourceManager->cssFile($name);
  *   }
  * </pre></code>
  *
  * @param string path The base path, relative to the template/resource path.
  * @param string regexp Optional filter expression; default is <code>null</code> for none.
  * @param string type The resource type; default is <code>View::RESOURCE</code>.
  * @return array A map of matching filenames.
  */
 public function find($path, $regexp = null, $type = View::RESOURCE)
 {
     list($path, $type) = $this->resolveType($path, $type);
     $locations = $this->getLocationsFor($type);
     // iterate in ascending priority, so the more important come first
     $files = array();
     foreach ($locations as $location) {
         $base = $location . '/' . $path;
         if (file_exists($base) && is_dir($base)) {
             $it = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($base));
             if (null != $regexp) {
                 $it = new \RegexIterator($it, $regexp, \RegexIterator::MATCH);
             }
             for ($it->rewind(); $it->valid(); $it->next()) {
                 $name = str_replace(array($base, '\\'), array('', '/'), $it->current()->getPathname());
                 $files[] = $name;
             }
         }
     }
     return $files;
 }