Exemplo n.º 1
0
 /**
  * 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;
 }
Exemplo n.º 2
0
$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'];
while ($it->valid()) {
    if (!$it->isDot()) {
        //echo '<span class="label">SubPathName</span> '. $it->getSubPathName();
        //echo ' -- <span class="label">SubPath</span> '. $it->getSubPath();
        //echo ' -- <span class="label">Key</span> '. $it->key();
        $subpath = $it->getSubPath();
        $subpath_highlighted = $subpath ? '<span class="label">' . $subpath . '/</span>' : '';
        $subpath_file = $it->getSubPathName();
        $filename = preg_replace('#^' . $subpath . '\\' . DS . '#', '', $subpath_file);
        $pi = pathinfo($it->key());
        $ext = $pi['extension'];
        $file_type = isset($ext_badge[$ext]) ? '<span class="badge badge-' . $ext_badge[$ext] . '">' . $ext . '</span> ' : '<span class="badge">---</span> ';
        $btns_handle_class = isset($ext_badge[$ext]) ? '<span class="badge badge-' . $ext_badge[$ext] . '">' . $ext . '</span> ' : '<span class="badge">---</span> ';
        $btn_allowed = isset($file_code_btns[$filename]) ? array_keys($file_code_btns[$filename]) : array();
        echo '
						' . $file_type . (!isset($file_tip_extra[$filename]) ? '<img src="components/com_flexicontent/assets/images/tick_f2.png" alt="Edit file">' : '<img src="components/com_flexicontent/assets/images/comment.png" data-placement="bottom" class="' . $tip_class . '" title="' . $file_tip_extra[$filename] . '" alt="Edit file"/>') . '
						<a href="javascript:;" class="' . $tip_class . '" data-placement="right" onclick="load_layout_file(\'' . addslashes($this->layout->name) . '\', \'' . addslashes($it->getSubPathName()) . '\', \'0\', \'' . implode($btn_allowed, ' ') . '\'); return false;"
						title="' . (isset($file_tip[$filename]) ? $file_tip[$filename] : $ext . ' file') . '">' . $subpath_highlighted . $filename . '</a>';
        echo "<br/>";
    }
    $it->next();
}
?>
			</div>
Exemplo n.º 3
0
 private static function _searchAllInternal($needle, array $array, array &$keys = null, $const = 0)
 {
     try {
         $iterator = new \RegexIterator(new \RecursiveIteratorIterator(new \RecursiveArrayIterator($array)), $needle, \RegexIterator::MATCH, $const);
         $result = [];
         /** @var \RecursiveIteratorIterator $iterator */
         foreach ($iterator as $value) {
             $result[] = ['key' => $iterator->key(), 'value' => $value];
             $_keys = [];
             foreach (range(0, $iterator->getDepth()) as $depth) {
                 $_keys[] = $iterator->getSubIterator($depth)->key();
             }
             $keys[][$iterator->key()] = $_keys;
         }
     } catch (\Exception $e) {
         throw new ArrayException($e->getMessage(), [], $e);
     }
     return $result;
 }