public function renderMediaBrowser($path, $folderLink, $fileLink) { $folders = Digitalus_Filesystem_Dir::getDirectories($path); $files = Digitalus_Filesystem_File::getFilesByType($path, false, false, true); $links = null; if (is_array($folders) && count($folders) > 0) { foreach ($folders as $folder) { $folderPath = $path . '/' . $folder; $link = Digitalus_Toolbox_String::addUnderscores($folderPath); //remove reference to media $link = str_replace('media_', '', $link); $submenu = $this->view->RenderMediaBrowser($folderPath, $folderLink, $fileLink); $links[] = '<li class="menuItem">' . $this->view->link($folder, '/' . $folderLink . '/' . $link, 'folder.png') . $submenu . '</li>'; } } if (is_array($files) && count($files) > 0) { foreach ($files as $file) { if (substr($file, 0, 1) != '.') { $filePath = $path . '/' . $file; $links[] = '<li class="menuItem">' . $this->view->link($file, $fileLink . '/' . $filePath, $this->view->getIconByFiletype($file, false)) . '</li>'; } } } if (is_array($links)) { $filetree = '<ul id="fileTree" class="treeview">' . implode(null, $links) . '</ul>'; return $filetree; } return null; }
public function RenderFileBrowser($parentId, $depth = 1, $level = 0, $basePath = null, $id = 'fileTree') { // @todo: deal with selected menu items if ($level <= $depth - 1) { $links = array(); $menu = new Model_Menu(); $children = $menu->getMenuItems($parentId); foreach ($children as $child) { if (!empty($child->label)) { $label = $child->label; } else { $label = $child->title; } $children = $menu->getMenuItems($child->id); if ($children->count() > 0) { $class = 'dir'; $newLevel = $level + 1; $submenu = $this->view->RenderFileBrowser($child->id, $depth, $newLevel, $link); } else { $class = 'page'; $submenu = false; } $linkId = Digitalus_Toolbox_String::addUnderscores($menu->path, true); $links[] = "<li class='menuItem'><a href='/admin/page/open/id/{$child->id}' class='{$class}' id='page-{$child->id}'>{$label}</a>" . $submenu . '</li>'; } } if (is_array($links)) { if ($level == 0) { $strId = "id='{$id}'"; } return "<ul {$strId}>" . implode(null, $links) . '</ul>'; } }
public function removeCacheFormPath($path, $option = Zend_Cache::CLEANING_MODE_MATCHING_TAG) { $path = Digitalus_Toolbox_String::stripLeading('/', $path); $path = Digitalus_Toolbox_Regex::stripTrailingSlash($path); $path = Digitalus_Toolbox_String::addUnderscores($path); self::$_cache->clean($option, array($path)); }
public function renderMenuBrowser($parentId, $basePath = null, $id = 'menuTree') { $menu = new Model_Menu(); $children = $menu->getMenuItems($parentId, true); foreach ($children as $child) { $label = $child->title; if (!empty($child->label)) { $label = $child->label . ' / ' . $label; } $class = 'menu'; $submenu = $this->view->renderMenuBrowser($child->id, $link); $linkId = Digitalus_Toolbox_String::addUnderscores($menu->path, true); $links[] = '<li class="menuItem"><a href="/admin/navigation/open/id/' . $child->id . '" class="' . $class . '" id="page-' . $child->id . '">' . $label . '</a>' . $submenu . '</li>'; } if (is_array($links)) { if ($level == 0) { $strId = 'id="' . $id . '"'; } return '<ul ' . $strId . '>' . implode(null, $links) . '</ul>'; } }
public function RenderMenuBrowser($parentId, $basePath = null, $id = 'menuTree') { $menu = new Model_Menu(); $children = $menu->getMenuItems($parentId, true); foreach ($children as $child) { $label = $child->title; if (!empty($child->label)) { $label = $child->label . ' / ' . $label; } $class = 'menu'; $submenu = $this->view->RenderMenuBrowser($child->id, $link); $linkId = Digitalus_Toolbox_String::addUnderscores($menu->path, true); $links[] = "<li class='menuItem'><a href='/admin/navigation/open/id/{$child->id}' class='{$class}' id='page-{$child->id}'>{$label}</a>" . $submenu . '</li>'; } if (is_array($links)) { if ($level == 0) { $strId = "id='{$id}'"; } return "<ul {$strId}>" . implode(null, $links) . '</ul>'; } }
/** * Rename Folder Action * * @return void */ public function renameFolderAction() { $filepath = Digitalus_Filter_Post::get('filepath'); $folderName = Digitalus_Filter_Post::get('folder_name'); Digitalus_Media::renameFolder($filepath, $folderName); $folder = Digitalus_Toolbox_String::addUnderscores(Digitalus_Toolbox_String::getParentFromPath($filepath) . '/' . $folderName); $this->_request->setParam('folder', $folder); $this->_forward('open-folder'); }
/** * 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'))); }