Beispiel #1
0
 function folderItems()
 {
     // Get filetypes
     $exts = 'bmp,csv,doc,gif,jpg,jpeg,odg,odp,ods,odt,pdf,png,ppt,txt,xcf,xls';
     $exts = LinkrHelper::getMediaParam('upload_extensions', $exts);
     // Build regular expression
     $exts = preg_replace('/[^A-Z0-9,]/i', '', $exts);
     $exts = '\\.(' . str_replace(',', '|', $exts) . ')';
     // Get folder from request
     $info = $this->fileInfo();
     $folder = $info['path'];
     // Get folders
     if ($info['parent']) {
         $folders = LinkrHelper::listDirectories($info['path']);
     } else {
         $paths = LinkrHelper::getParam('paths', 'images');
         $regex = LinkrHelper::buildRegex($paths);
         $folders = LinkrHelper::listDirectories($info['base'], $regex);
     }
     // Get files
     $files = LinkrHelper::listFiles($folder, $exts);
     // Create output
     $items = '<div id="filedirlist">' . '<div style="clear:both;"></div>';
     // Parent directory
     $icon = JURI::root() . 'administrator/components/com_media/images/folderup_32.png';
     $icon = JHTML::image($icon, 'Folder', array('width' => 32, 'height' => 32, 'class' => 'big'));
     if ($info['parent']) {
         $click = 'LinkrHelper.fileDir(\'' . $info['parent.64'] . '\')';
         $items .= '<div class="item up">' . '<div class="icon" onclick="' . $click . '">' . '<div align="center" class="border"><a>' . $icon . '</a></div></div>' . '<div class="name">' . JText::_('up') . '</div>' . '</div>';
     }
     // Folders
     $icon = JURI::root() . 'administrator/components/com_media/images/folder.png';
     $icon = JHTML::image($icon, 'Folder', array('width' => 32, 'height' => 32, 'class' => 'big'));
     foreach ($folders as $d) {
         $click = 'LinkrHelper.fileDir(\'' . $d['path.64'] . '\')';
         $items .= '<div class="item">' . '<div class="icon" onclick="' . $click . '">' . '<div align="center" class="border"><a>' . $icon . '</a></div></div>' . '<div class="name">' . $d['name'] . '</div>' . '</div>';
     }
     // Files
     foreach ($files as $f) {
         $icon = array('width' => $f->width, 'height' => $f->height);
         $icon = JHTML::image($f->icon, $f->name, $icon);
         $title = $f->type . ' - ' . $f->name . ' (' . $f->size . ')';
         $name = str_replace('.' . $f->ext, '', $f->name);
         $click = 'LinkrHelper.file(\'' . $f->src . '\')';
         $items .= '<div class="item">' . '<div class="icon"title="' . $title . '"onclick="' . $click . '">' . '<div align="center" class="border"><a>' . $icon . '</a></div></div>' . '<div class="name">' . $name . '</div>' . '</div>';
     }
     return $items . '</div>';
 }
Beispiel #2
0
 function _fileInfo()
 {
     if (isset($this->_fi)) {
         return $this->_fi;
     }
     // Paths list
     $i = array('path.list' => array());
     $paths = LinkrHelper::getParam('paths', 'images');
     $paths = $this->getState('path', $paths, 'STRING');
     $list = @explode(',', $paths);
     foreach ($list as $p) {
         $p = trim($p);
         if (!strlen($p)) {
             continue;
         }
         $p = str_replace('/', DS, $p);
         $p = substr($p, 0, 1) == DS ? $p : DS . $p;
         $p = substr($p, -1) == DS ? substr($p, 0, -1) : $p;
         if (is_dir(JPATH_ROOT . $p)) {
             $i['path.list'][] = JPATH_ROOT . $p;
         }
     }
     if (!count($i['path.list'])) {
         $i['path.list'][] = JPATH_ROOT . DS . 'images';
     }
     // Base folder
     if (count($i['path.list']) == 1) {
         $i['base'] = $i['path.list'][0];
         $i['base.regex'] = '.';
         $i['base.folder'] = str_replace(JPATH_ROOT . DS, '', $i['base']);
         $i['base.folder'] = str_replace(DS, '/', $i['base.folder']);
     } else {
         $i['base'] = strlen(JPATH_ROOT) ? JPATH_ROOT : DS;
         $i['base.regex'] = LinkrHelper::buildRegex($paths);
         $i['base.folder'] = '/';
     }
     // Current path
     $i['path'] = $this->getState('current', null);
     $i['path'] = $i['path'] ? base64_decode($i['path']) : $i['base'];
     if (strpos($i['path'], $i['base']) !== 0) {
         $i['path'] = $i['base'];
     }
     $i['path.64'] = base64_encode($i['path']);
     // Collect information
     $i['base.64'] = base64_encode($i['base']);
     if ($i['path'] != $i['base']) {
         $parent = substr($i['path'], 0, strrpos($i['path'], DS));
         $i['parent'] = $parent;
         $i['parent.64'] = base64_encode($parent);
     } else {
         $i['parent'] = false;
         $i['parent.64'] = false;
     }
     // Return information
     $this->_fi = $i;
     return $this->_fi;
 }