Example #1
0
 /**
  * returns an array containing attachment information
  *
  * @param string $file
  * @return array $arrReturn 'path','webpath','extension', false if attachment doesn't exist in filesystem
  */
 function _getAttachment($file)
 {
     $file = contrexx_addslashes($file);
     $cx = \Cx\Core\Core\Controller\Cx::instanciate();
     $path = $cx->getWebsiteMediaForumUploadPath() . '/';
     if (!file_exists($path . $file) || empty($file)) {
         return false;
     }
     $pathinfo = pathinfo($file);
     $icon = \Cx\Core_Modules\Media\Controller\MediaLibrary::_getIconWebPath() . \Cx\Core_Modules\Media\Controller\MediaLibrary::_getIcon($path . $file) . '.png';
     return array('name' => $file, 'path' => $path . $file, 'webpath' => $cx->getWebsiteMediaForumUploadWebPath() . '/' . $file, 'extension' => $pathinfo['extension'], 'icon' => $icon, 'size' => filesize($path . $file));
 }
 /**
  * Get the web path to the icon used for displaying the file type of a file
  *
  * @param   string  $file   File of which the related file type icon path shall be returned.
  *                          File must be an absolute file system path or an URL.
  * @param   string  $fileType  (optional) The file type of $file (as file extension). When supplied, the method will skip the file type detection and will run quite faster.
  * @return  string  Web path to the icon.
  */
 public static function getFileTypeIconWebPath($file, $fileType = null)
 {
     $iconPath = \Cx\Core_Modules\Media\Controller\MediaLibrary::_getIconPath() . \Cx\Core_Modules\Media\Controller\MediaLibrary::_getIcon($file, $fileType) . '.png';
     return \Cx\Core\Core\Controller\Cx::instanciate()->getClassLoader()->getWebFilePath($iconPath);
 }
Example #3
0
 /**
  * Getting the files and folders in a ul li format for the js tree
  * 
  * @param array  $folder     array of files and folders
  * @param string $path       current path of the $folder array
  * @param string $block      type of the folder array (theme or applicationTheme)
  * @param string $themesPage selected file in the ul li
  * 
  * @return string formatted ul and li for the js tree
  */
 function getUlLi($folder, $path, $block, $themesPage)
 {
     $result = '<ul>';
     $virtualFolder = array('View', 'Template', 'Frontend');
     foreach ($folder as $folderName => $fileName) {
         $permissionClass = 'protected';
         $resetClass = '';
         $relativePath = $path . '/' . (is_array($fileName) ? $folderName : $fileName);
         $isComponentFile = false;
         if (self::isFileTypeComponent($relativePath)) {
             $componentFilePath = self::getComponentFilePath($relativePath, $block == 'applicationTheme');
             if (!$componentFilePath) {
                 // may be a folder
                 $componentFilePath = self::replaceComponentFolderByItsType($relativePath);
             }
             $isComponentFile = true;
         }
         $filePath = $this->websiteThemesFilePath . ($isComponentFile ? $componentFilePath : $relativePath);
         if (file_exists($filePath)) {
             $permissionClass = '';
             if ($this->websiteThemesFilePath != $this->codeBaseThemesFilePath && file_exists($this->codeBaseThemesFilePath . ($isComponentFile ? $componentFilePath : $relativePath))) {
                 $permissionClass = 'protected';
                 $resetClass = 'reset';
             }
         } else {
             $filePath = $this->codeBaseThemesFilePath . ($isComponentFile ? $componentFilePath : $relativePath);
         }
         if (is_array($fileName)) {
             if ($block == 'applicationTheme' || $block == 'theme' && !in_array($folderName, $virtualFolder)) {
                 $icon = "<img height='16' width='16' alt='icon' src='" . \Cx\Core_Modules\Media\Controller\MediaLibrary::_getIconWebPath() . "Folder.png' class='icon'>";
                 $activeFolder = preg_match('#^' . $relativePath . '# i', $themesPage) ? "id='activeFolder'" : '';
                 $result .= '<li><a  href="javascript:void(0);"' . $activeFolder . ' data-rel="' . $relativePath . '" class="folder naming ' . $permissionClass . ' ' . $resetClass . '">' . $icon . $folderName . '</a>';
             }
             $result .= $this->getUlLi($fileName, $path . (!in_array($folderName, $virtualFolder) ? '/' . $folderName : ''), $block, $themesPage);
             $result .= '</li>';
         } else {
             if (in_array($fileName, $this->filenames)) {
                 $iconSrc = '../core/ViewManager/View/Media/Config.png';
             } else {
                 $iconSrc = \Cx\Core_Modules\Media\Controller\MediaLibrary::_getIconWebPath() . \Cx\Core_Modules\Media\Controller\MediaLibrary::_getIcon($filePath) . '.png';
             }
             $icon = "<img height='16' width='16' alt='icon' src='" . $iconSrc . "' class='icon'>";
             $activeFile = $themesPage == $relativePath ? "id = 'activeFile'" : '';
             $result .= "<li><a  href= 'javascript:void(0);' class='loadThemesPage naming {$permissionClass} {$resetClass}' {$activeFile} data-rel='" . $relativePath . "'>" . $icon . $fileName . "</a></li>";
         }
     }
     $result .= '</ul>';
     return $result;
 }
 /**
  * Returns the appropriate icon of the given file.
  *
  * @param   string  $file
  * @return  string  $img
  */
 private function getFileIcon($file)
 {
     $icon = \Cx\Core_Modules\Media\Controller\MediaLibrary::_getIcon(\Env::get('cx')->getWebsiteDocumentRootPath() . $file);
     $img = '<img src="' . \Cx\Core_Modules\Media\Controller\MediaLibrary::_getIconWebPath() . $icon . '.png" alt="Attach" border="0" style="position: relative; top: 3px;" />&nbsp;';
     return $img;
 }
 /**
  * returns an array containing attachment information
  *
  * @param string $file
  * @return array $arrReturn 'path','webpath','extension', false if attachment doesn't exist in filesystem
  */
 function _getAttachment($file)
 {
     $file = addslashes($file);
     if (!file_exists(ASCMS_FORUM_UPLOAD_PATH . '/' . $file) || empty($file)) {
         return false;
     }
     $pathinfo = pathinfo($file);
     $icon = \Cx\Core_Modules\Media\Controller\MediaLibrary::_getIcon($file);
     return array('name' => $file, 'path' => ASCMS_FORUM_UPLOAD_PATH . '/' . $file, 'webpath' => ASCMS_FORUM_UPLOAD_WEB_PATH . '/' . $file, 'extension' => $pathinfo['extension'], 'icon' => $icon, 'size' => filesize(ASCMS_FORUM_UPLOAD_PATH . '/' . $file));
 }