Exemplo n.º 1
0
 /**
  * Open Folder Action
  *
  * @return void
  */
 public function openFolderAction()
 {
     $folder = $this->_request->getParam('folder');
     $folder = str_replace('media_', '', $folder);
     $this->view->path = $folder;
     $folder = Digitalus_Toolbox_String::stripHyphens($folder);
     $folder = Digitalus_Toolbox_String::stripLeading('_', $folder);
     $folderArray = explode('_', $folder);
     if (is_array($folderArray)) {
         foreach ($folderArray as $pathPart) {
             if (!empty($pathPart)) {
                 $fullPathParts[] = $pathPart;
                 $fullPath = implode('_', $fullPathParts);
                 $folderPathParts[$fullPath] = $pathPart;
             }
         }
     }
     if (isset($folderPathParts) && !empty($folderPathParts)) {
         $this->view->folderPathParts = $folderPathParts;
     }
     $pathToFolder = Digitalus_Toolbox_String::stripUnderscores($folder);
     $this->view->filesystemPath = $pathToFolder;
     $this->view->mediaPath = $folder;
     $this->view->folders = Digitalus_Filesystem_Dir::getDirectories($this->_pathToMedia . '/' . $pathToFolder);
     $this->view->files = Digitalus_Filesystem_File::getFilesByType($this->_pathToMedia . '/' . $pathToFolder, false, false, true);
     $this->view->breadcrumbs[$this->view->getTranslation('Open Folder') . ': ' . Digitalus_Toolbox_String::stripUnderscores($folder)] = $this->getFrontController()->getBaseUrl() . '/admin/media/open-folder/folder/' . $folder;
     $this->view->toolbarLinks = array();
     $tmpPath = Digitalus_Toolbox_String::addUnderscores($folder);
     $this->view->toolbarLinks['Add to my bookmarks'] = $this->getFrontController()->getBaseUrl() . '/admin/index/bookmark' . '/url/admin_media_open-folder_folder_' . $tmpPath . '/label/' . $this->view->getTranslation('Media') . ':' . $pathToFolder;
     $this->view->toolbarLinks['Delete'] = $this->getFrontController()->getBaseUrl() . '/admin/media/delete-folder/folder/' . $folder;
 }
Exemplo n.º 2
0
 /**
  * Initialize the form
  *
  * @return void
  */
 public function init()
 {
     parent::init();
     $view = $this->getView();
     $pathToMedia = $this->_getData('pathToMedia');
     $mediaFolder = $this->_getData('mediaFolder');
     $path = $this->_getData('path');
     $filepath = $this->_getData('filepath');
     $mediapath = $this->_getData('mediapath');
     $files = $this->_getData('files');
     $folders = $this->_getData('folders');
     $folderPathParts = $this->_getData('folderPathParts');
     $label = $this->_getData('label');
     /* *********************************************************************
      * CURRENT DIRECTORY
      * ****************************************************************** */
     $pathParts[] = $pathToMedia;
     if (is_array($folderPathParts)) {
         foreach ($folderPathParts as $path2 => $label2) {
             $pathParts[] = '<a href="' . $view->getBaseUrl() . '/admin/media/open-folder/folder/' . $path2 . '">' . Digitalus_Toolbox_String::stripUnderscores($label2) . '</a>';
         }
     }
     $xhtml = '<p>' . $view->getTranslation('Media Root') . implode('/', $pathParts) . '</p>';
     $currentDirectory = $this->createElement('AnyMarkup', 'current_directory', array('value' => $xhtml, 'decorators' => $this->getStandardDecorator('none')));
     /* *********************************************************************
      * BROWSE
      * ****************************************************************** */
     $siteRoot = $view->getBaseUrl() . '/';
     $basePath = $siteRoot . $mediaFolder;
     if (!empty($filepath)) {
         $basePath .= '/' . $filepath;
     }
     $xhtml = '';
     // DIRECTORIES
     if (is_array($folders) && count($folders) > 0) {
         $xhtml = '<h3>' . $view->getTranslation('Subfolders') . '</h3>';
         foreach ($folders as $folder) {
             $folder = Digitalus_Toolbox_String::addUnderscores($folder);
             $cleanPath = Digitalus_Toolbox_String::stripHyphens($folder);
             $cleanPath = Digitalus_Toolbox_String::stripUnderscores($folder);
             $deleteLink = '/admin/media/delete-folder/folder/' . $mediapath . '_' . $folder;
             $path2 = '/admin/media/open-folder/folder/' . $mediapath . '_' . $folder;
             $xhtml .= '<div class="folderWrapper">' . '    ' . $view->link('Delete', $deleteLink, 'delete.png', 'rightLink delete') . '    <h4>' . $view->link($cleanPath, $path2, 'folder.png') . '</h4>' . '    <p>' . $view->getTranslation('Full path') . ': <code>' . $basePath . '/' . $cleanPath . '</code></p>' . '</div>';
         }
     }
     // FILES
     if (is_array($files) && count($files) > 0) {
         $xhtml .= '<h3>' . $view->getTranslation('Files') . '</h3>';
         foreach ($files as $file) {
             if (substr($file, 0, 1) != '.') {
                 $filepath2 = Digitalus_Toolbox_String::stripUnderscores($basePath) . '/' . $file;
                 $fileLink = $mediapath . '_' . $file;
                 $deleteLink = '/admin/media/delete-file/file/' . $fileLink . '/';
                 $path2 = $mediaFolder . '/' . $filepath . $filepath2;
                 $xhtml .= '<div class="fileWrapper">' . '    ' . $view->link('Delete', $deleteLink, 'delete.png', 'rightLink delete') . '    <h4>' . $view->link($file, $path2, $view->getIconByFiletype($filepath2, false)) . '</h4>' . '    <p>' . $view->getTranslation('Full path') . ': <code>' . $basePath . $filepath2 . '</code></p>' . '</div>';
             }
         }
     }
     $subDirectories = $this->createElement('AnyMarkup', 'sub_directories', array('value' => $xhtml, 'decorators' => $this->getStandardDecorator('none')));
     /* *********************************************************************
      * UPLOAD
      * ****************************************************************** */
     $filePath = $this->createElement('hidden', 'filepath', array('value' => $filepath, 'decorators' => $this->getStandardDecorator('none')));
     $mediapath = $this->createElement('hidden', 'mediapath', array('value' => $mediapath, 'decorators' => $this->getStandardDecorator('none')));
     $uploads = $this->createElement('file', 'uploads[]', array('label' => $view->getTranslation('Select the files to upload'), 'belongsTo' => 'uploads', 'attribs' => array('id' => 'multi_upload'), 'filters' => array('StringTrim', 'StripTags'), 'validators' => array(array('File_NotExists', true, array()))));
     $uploadSubmit = $this->createElement('submit', 'uploadSubmit', array('label' => $view->getTranslation('Upload Files'), 'attribs' => array('class' => 'submit')));
     /* *********************************************************************
      * CREATE SUBFOLDER
      * ****************************************************************** */
     $path = $this->createElement('hidden', 'path', array('value' => $path, 'decorators' => $this->getStandardDecorator('none')));
     $folderName = $this->createElement('text', 'folder_name', array('required' => true, 'label' => $view->getTranslation('Folder Name'), 'filters' => array('StringTrim', 'StripTags'), 'validators' => array(array('NotEmpty', true), array('Regex', true, array('pattern' => Digitalus_Media::MEDIALABEL_REGEX, 'messages' => array('regexNotMatch' => Digitalus_Media::MEDIALABEL_REGEX_NOTMATCH))))));
     $createFolderSubmit = $this->createElement('submit', 'createFolderSubmit', array('label' => $view->getTranslation('Create Folder'), 'attribs' => array('class' => 'submit')));
     /* *********************************************************************
      * RENAME FOLDER
      * ****************************************************************** */
     $newName = $this->createElement('text', 'new_folder_name', array('required' => true, 'label' => $view->getTranslation('New Name'), 'value' => $label, 'filters' => array('StringTrim', 'StripTags'), 'validators' => array(array('NotEmpty', true), array('Regex', true, array('pattern' => Digitalus_Media::MEDIALABEL_REGEX, 'messages' => array('regexNotMatch' => Digitalus_Media::MEDIALABEL_REGEX_NOTMATCH))))));
     $renameFolderSubmit = $this->createElement('submit', 'renameFolderSubmit', array('label' => $view->getTranslation('Rename Folder'), 'attribs' => array('class' => 'submit')));
     /* *********************************************************************
      * PUT IT ALL TOGETHER
      * ****************************************************************** */
     $this->addElement($currentDirectory);
     $this->addElement($subDirectories);
     $this->addElement($filePath);
     $this->addElement($mediapath);
     $this->addElement($uploads);
     $this->addElement($path);
     $this->addElement($folderName);
     $this->addElement($newName);
     $this->addElement($uploadSubmit);
     $this->addElement($createFolderSubmit);
     $this->addElement($renameFolderSubmit);
     $this->addDisplayGroup(array('form_instance', 'filepath', 'mediapath', 'current_directory'), 'mediaCurrentGroup', array('legend' => $view->getTranslation('Current Folder')));
     $this->addDisplayGroup(array('sub_directories'), 'mediaSubDirectoriesGroup', array('legend' => $view->getTranslation('Current folder contents')));
     $this->addDisplayGroup(array('uploads', 'uploadSubmit'), 'mediaUploadGroup', array('legend' => $view->getTranslation('Upload Files')));
     $this->addDisplayGroup(array('path', 'folder_name', 'createFolderSubmit'), 'mediaCreateFolderGroup', array('legend' => $view->getTranslation('Create Subfolder')));
     $this->addDisplayGroup(array('new_folder_name', 'renameFolderSubmit'), 'mediaRenameFolderGroup', array('legend' => $view->getTranslation('Rename Folder')));
 }
Exemplo n.º 3
0
 /**
  * cleans the uri
  *
  * @param string $uri
  * @return string
  */
 private function _cleanUri($uri)
 {
     $uri = Digitalus_Toolbox_Regex::stripFileExtension($uri);
     $uri = Digitalus_Toolbox_Regex::stripTrailingSlash($uri);
     $uri = urldecode($uri);
     $array = explode('/', $uri);
     $splitPaths = Digitalus_Toolbox_Array::splitOnValue($array, 'p');
     if (is_array($splitPaths)) {
         $uri = implode('/', $splitPaths[0]);
         if (is_array($splitPaths[1])) {
             $this->_params = Digitalus_Toolbox_Array::makeHashFromArray($splitPaths[1]);
         }
     }
     return Digitalus_Toolbox_String::stripHyphens($uri);
 }