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 link($label, $link, $icon = null, $class = 'link', $target = null, $suppressLabel = false, $translate = true) { $this->link = Digitalus_Toolbox_String::stripLeading('/', $link); $this->baseUrl = Digitalus_Toolbox_String::stripLeading('/', $this->view->getBaseUrl()); // clean the link if ($this->isRemoteLink($link) || $this->isAnchorLink($link)) { $cleanLink = $link; } else { $cleanLink = '/' . $this->addBaseUrl($this->link); } if ($target != null) { $target = 'target="' . $target . '"'; } $linkParts[] = '<a href="' . $cleanLink . '" class="' . $class . '" ' . $target . '>'; if (null !== $icon) { $linkParts[] = $this->getIcon($icon, $label); } if (!empty($label) && true != $suppressLabel) { if (true === (bool) $translate) { $linkParts[] = $this->view->getTranslation((string) $label); } else { $linkParts[] = (string) $label; } } $linkParts[] = '</a>'; return implode(null, $linkParts); }
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 __construct() { $mdlPage = new Model_Page(); $mdlContentNode = new Model_PageNode(); $select = $mdlPage->select(); $select->where("namespace = 'content'"); $pages = $mdlPage->fetchAll($select); if ($pages->count() > 0) { foreach ($pages as $page) { $contentNodes = $mdlContentNode->fetchContentObject($page->id); if (isset($contentNodes->content)) { //if the page does not have content it doesnt belong in the index (eg blocks) $title = $mdlPage->getPageTitle($page->id); $link = Digitalus_Toolbox_Page::getUrl($page); $link = strtolower($link); $contentNodes = $mdlContentNode->fetchContentObject($page->id); if (isset($contentNodes->teaser)) { $teaser = $contentNodes->teaser; } else { $teaser = Digitalus_Toolbox_String::truncateText($contentNodes->content); } $content = $contentNodes->content; $this->_addPage($link, $title, $teaser, $content); } } } }
public function renderBookmarks($bookmarks = null) { $xhtml = ''; if (!is_array($bookmarks)) { $mdlBookmark = new Model_Bookmark(); $bookmarks = $mdlBookmark->getUsersBookmarks(); } if (!empty($bookmarks)) { $xhtml = '<ul class="bookmarks">'; foreach ($bookmarks as $bookmark) { $xhtml .= ' <li>' . PHP_EOL; $xhtml .= ' ' . $this->view->link(null, '/admin/index/delete-bookmark/id/' . $bookmark->id, 'link_delete.png', 'clear') . PHP_EOL; $url = $bookmark->url; if (strpos($url, 'mod_') === 0) { $url = str_replace('mod_', '', $url); $url = Digitalus_Toolbox_String::stripUnderscores($url); $url = 'mod_' . $url; } else { $url = Digitalus_Toolbox_String::stripUnderscores($url); } $xhtml .= ' ' . $this->view->link($bookmark->label, '/' . $url); $xhtml .= ' </li>'; } $xhtml .= '</ul>'; } else { $xhtml = $this->view->getTranslation('You do not have any bookmarks.'); } return $xhtml; }
/** * you pass this function the key for the $_FILES[key] array * and the new filepath to move the file to * then add the new filename * if $createPath is true then this will attempt to create the directories required for the path * * @param string $key * @param string $path * @param string $filename * @param bool $createPath */ public function upload($key, $path, $filename = false, $createPath = true, $permissions = '777') { if (self::isUploaded($key)) { //default to the name on the client machine if (!$filename) { $filename = $_FILES[$key]['name']; } $path = Digitalus_Toolbox_String::stripLeading('/', $path); if ($createPath) { //attempt to create the new path Digitalus_Filesystem_Dir::makeRecursive(self::PATH_TO_FILES, $path); } //clean the filename $filename = Digitalus_Filesystem_File::cleanFilename($filename); $filename = Digitalus_Toolbox_String::getSelfFromPath($filename); $fullPath = self::PATH_TO_FILES . "/" . $path . "/" . $filename; if (move_uploaded_file($_FILES[$key]['tmp_name'], $fullPath)) { // Set permissions for this file @chmod($fullPath, $permissions); //return the filepath if things worked out //this is relative to the site root as this is the format that will be required for links and what not $fullPath = Digitalus_Toolbox_String::stripLeading('./', $fullPath); return $fullPath; } } }
public static function getCurrentPageName($onlyLast = true) { $uri = new Digitalus_Uri(); $uriString = $uri->toString(); if (true === $onlyLast) { return Digitalus_Toolbox_String::getSelfFromPath($uriString); } return Digitalus_Toolbox_String::stripLeading('/', $uriString); }
/** * Sets one attribute * * @param string $key * @param string $value * @return void */ protected function _setAttrib($key, $value) { if (key_exists($key, $this->_attribs)) { if (in_array($key, $this->_booleanValues)) { // needed to convert "true" or "false" strings into boolean values $this->_attribs[$key] = Digitalus_Toolbox_String::booleanise($key); } else { $this->_attribs[$key] = (string) $value; } } }
/** * render a module page like news_showNewPosts */ public function listWhatsNew() { $newStories = $this->view->pageObj->getNewStories(); if ($newStories) { foreach ($newStories as $story) { $link = Digitalus_Toolbox_String::addHyphens($this->view->realPath($story->id)); $data[] = '<a href="' . $link . '">' . $this->view->pageObj->getLabel($story) . '</a>'; } if (is_array($data)) { return $this->view->htmlList($data); } } }
/** * Render partial action * * @throws Zend_Exception * @return void */ public function renderPartialAction() { $partial = $this->_request->getParam('partial'); if ($partial != null) { $this->view->partialKey = Digitalus_Toolbox_String::stripUnderscores($partial); $data = new stdClass(); $data->get = $this->_request->getParams(); $data->post = $_POST; $this->view->data = $data; } else { throw new Zend_Exception('Invalid placeholder passed'); } }
/** * render a module page like news_showNewPosts */ public function ListMostPopular() { $popular = $this->view->pageObj->getPopularStories(); if ($popular) { foreach ($popular as $story) { $link = Digitalus_Toolbox_String::addHyphens($this->view->RealPath($story->id)); $data[] = "<a href='{$link}'>" . $this->view->pageObj->getLabel($story) . "</a>"; } if (is_array($data)) { return $this->view->htmlList($data); } } }
/** * removes any params from the uri */ public function CleanUri($uri = null, $absolute = false, $stripUnderscores = false) { if ($uri == null) { $uri = $this->view->pageObj->getCleanUri(); } if ($absolute && !empty($uri)) { $uri = '/' . $uri; } if ($stripUnderscores) { $uri = Digitalus_Toolbox_String::stripUnderscores($uri, true); } return Digitalus_Toolbox_String::addHyphens($uri); }
public function hasAccess($tab) { if ($this->currentUser) { if ($this->currentUser->role == Model_User::SUPERUSER_ROLE) { return true; } else { $tab = Digitalus_Toolbox_String::stripLeading("/", $tab); $tab = str_replace("/", "_", $tab); if ($this->userModel->queryPermissions($tab)) { return true; } } } }
public function RenderBreadcrumbs($separator = ' > ', $siteRoot = 'Home') { $parents = $this->view->pageObj->getParents(); if (is_array($parents) && count($parents) > 0) { $path = null; foreach ($parents as $parent) { $label = $this->view->pageObj->getLabel($parent); $link = '/' . Digitalus_Toolbox_String::addHyphens($label); $path .= $link; $arrLinks[] = "<a href='{$path}' class='breadcrumb'>{$parent->title}</a>"; } } $arrLinks[] = "<a href='' class='breadcrumb last'>{$this->view->page->title}</a>"; return implode($separator, $arrLinks); }
public function RenderListIcons($dir, $name) { $cache = Digitalus_Cache_Manager::getInstance(); $key = "{$dir}/{$name}"; if (($data = $cache->loadCache($key)) != false) { return $data; } $arr_files = Digitalus_Filesystem_File::getFilesByType($dir, array('png', 'jpg', 'gif')); $dir = Digitalus_Toolbox_String::stripLeading(BASE_PATH, $dir); $data = " <input type='radio' value='' name='{$name}'/> Empty "; foreach ($arr_files as $icon_file) { $data .= " <span><input type='radio' value='{$icon_file}' name='admin_menu_img'/> "; $data .= "<img src='{$dir}/{$icon_file}' alt='{$icon_file}'/></span> "; } $cache->saveCache($data, $key); return $data; }
/** * explode url * return : * Array ( [url_key] => admin_menu_index [module] => admin [controller] => menu [action] => index [params] => Array ( [key_1] => value_1 [key_2] => value_2 [key_3] => value_3 ) ) * */ public function ExplodeUrl($url) { $result = array(); $url = Digitalus_Toolbox_String::stripLeading($this->view->getBaseUrl() . '/', $url); $array_url = explode('/', $url); $result['url_key'] = ''; $result['base_url'] = $this->view->getBaseUrl(); $result['module'] = array_shift($array_url); $result['controller'] = array_shift($array_url); $result['action'] = array_shift($array_url); $result['url_key'] = $result['module'] . '_' . $result['controller'] . '_' . $result['action']; $params = array(); while ($key = array_shift($array_url)) { $params[$key] = array_shift($array_url); } $result['params'] = $params; return $result; }
public function load($template) { if (is_object($template)) { return $template; } else { if (file_exists($template)) { $form = new Digitalus_Content_Form(); $view = $form->getView(); $templateName = basename($template); $layoutPath = Digitalus_Toolbox_String::getParentFromPath($template); $view->addScriptPath($layoutPath); $fileContents = $view->render($templateName); $cleanFile = preg_replace('/(<\\?{1}[pP\\s]{1}.+\\?>)/', '', $fileContents); return simplexml_load_string($cleanFile); } else { return simplexml_load_string($template); } } }
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>'; } }
/** * */ public function link($label, $link, $icon = null, $class = 'link', $target = null) { $this->link = Digitalus_Toolbox_String::stripLeading('/', $link); $this->baseUrl = Digitalus_Toolbox_String::stripLeading('/', $this->view->getBaseUrl()); // clean the link if ($this->isRemoteLink($link) || $this->isAnchorLink($link)) { $cleanLink = $link; } else { $cleanLink = '/' . $this->addBaseUrl($this->link); } if ($target != null) { $target = "target='{$target}'"; } $linkParts[] = "<a href='{$cleanLink}' class='{$class}' {$target}>"; if (null !== $icon) { $linkParts[] = $this->getIcon($icon, $label); } if (!empty($label)) { $linkParts[] = $this->view->getTranslation((string) $label); } $linkParts[] = '</a>'; return implode(null, $linkParts); }
public static function getMediaPath($path, $relative = true) { $path = Digitalus_Toolbox_String::stripUnderscores($path); //make it impossible to get out of the media library $path = str_replace('./', '', $path); $path = str_replace('../', '', $path); //remove root path from path if it exists in path already. $path = str_replace(self::rootDirectory(false), '', $path); //remove the reference to media if it exists $pathParts = explode('/', $path); if (is_array($pathParts)) { if ($pathParts[0] == 'media') { unset($pathParts[0]); } //remove any leading slash that may exist. $partial = implode('/', $pathParts); if (substr($partial, 0, 1) == '/') { $partial = substr($partial, 1); } //add the media root $path = self::rootDirectory($relative) . '/' . $partial; return $path; } return false; }
/** * 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'); }
/** * uploads the selected file (the key is the name of the files control) * if successfull then it resizes the images, creating a thumbnail and a full size image * if then removes the source file * * @param string $key */ public function uploadImage($key, $filename = false, $subdir = null, $resize = true, $makeThumb = true, $thumbWidth = null, $fullWidth = null) { //try to upload the file if ($subdir !== null) { $path = Digitalus_Toolbox_String::stripLeading('/', $subdir); } else { $path = self::IMAGE_PATH; } $upload = parent::upload($key, $path, $filename); if ($upload) { if ($resize == true) { //make the full sized image if ($fullWidth == null) { $fullWidth = self::FULL_WIDTH; } $this->fullPath = $this->resize($upload, $fullWidth, 'full_'); } else { $this->fullPath = $upload; } if ($makeThumb) { //make the thumbnail if ($thumbWidth == null) { $thumbWidth = self::THUMB_WIDTH; } $this->thumbPath = $this->resize($upload, $thumbWidth, 'thumb_'); } if ($resize == true) { //remove the source file unlink($upload); } } }
/** * replaces underscores with slashes * if relative is true then return the path as relative * * @param string $string * @param bool $relative * @return string */ public static function stripUnderscores($string, $relative = false) { $string = str_replace('_', '/', trim($string)); if ($relative) { $string = Digitalus_Toolbox_String::stripLeading('/', $string); } $string = str_replace(self::UNDERSCORE, '_', $string); return $string; }
/** * Get Page data as array * * @return array Returns an array of the page data, otherwise an empty array */ protected function _getPageAsArray($item = null) { if (empty($item)) { $item = $this->getItem(); } $baseUrl = $this->view->baseUrl(); $mdlMenu = new Model_Menu(); $page = array('active' => $this->isActive(false), 'class' => 'menuItem', 'id' => $item->id, 'label' => Digitalus_Toolbox_Page::getLabel($item), 'name' => $item->name, 'resource' => strtolower(Digitalus_Toolbox_String::replaceEmptySpace($item->name)), 'title' => Digitalus_Toolbox_Page::getLabel($item), 'uri' => $baseUrl . '/' . Digitalus_Toolbox_String::replaceEmptySpace(Digitalus_Toolbox_Page::getUrl($item)), 'visible' => $this->isVisible($item)); $subPages = array(); if ($mdlMenu->hasChildren($this->id)) { $children = $mdlMenu->getChildren($this->id); foreach ($children as $child) { $subPages[] = new Digitalus_Menu_Item(null, $child); } $page['pages'] = $subPages; } return $page; }
public static function hasAccess($path) { $userModel = new self(); $user = $userModel->getCurrentUser(); if ($user->role == Model_User::SUPERUSER_ROLE) { return true; } else { $path = Digitalus_Toolbox_String::stripLeading("/", $path); $path = str_replace("/", "_", $path); if ($userModel->queryPermissions($path)) { return true; } else { return false; } } }
/** * validate the current user's request * * @param Zend_Controller_Request_Abstract $request */ public function preDispatch(Zend_Controller_Request_Abstract $request) { $this->_identity = Digitalus_Auth::getIdentity(); $this->_acl = new Digitalus_Acl(); $role = Model_Group::GUEST_ROLE; if (!empty($this->_identity)) { $role = $this->_identity->role; } $module = $request->module; $controller = $request->controller; $action = $request->action; if ($module != 'public' && $controller != 'public') { //go from more specific to less specific $moduleLevel = $module; $controllerLevel = $moduleLevel . '_' . $controller; $actionLevel = $controllerLevel . '_' . $action; if ($this->_acl->has($actionLevel)) { $resource = $actionLevel; } else { if ($this->_acl->has($controllerLevel)) { $resource = $controllerLevel; } else { $resource = $moduleLevel; } } if ($this->_acl->has($resource) && !$this->_acl->isAllowed($role, $resource)) { if (!$this->_identity || Model_Group::GUEST_ROLE == $role) { $request->setModuleName($this->_noAuth['admin']['module']); $request->setControllerName($this->_noAuth['admin']['controller']); $request->setActionName($this->_noAuth['admin']['action']); $request->setParam('authPage', 'login'); } else { $request->setModuleName($this->_noAcl['admin']['module']); $request->setControllerName($this->_noAcl['admin']['controller']); $request->setActionName($this->_noAcl['admin']['action']); $request->setParam('authPage', 'noauth'); } } } else { $resource = Digitalus_Toolbox_Page::getCurrentPageName(); // write pageName to registry when coming from a page if ('index' == $controller && 'index' == $action) { Zend_Registry::set('Digitalus_Page_Name', $resource); } $resource = strtolower(Digitalus_Toolbox_String::replaceUnderscore($resource)); // only check Acl if page is NOT homepage if (!empty($resource) && '' != $resource && Digitalus_Toolbox_Page::getHomePageName() != $resource) { if ($this->_acl->has($resource) && !$this->_acl->isAllowed($role, $resource)) { if (!$this->_identity || Model_Group::GUEST_ROLE != $role) { $request->setModuleName($this->_noAcl['public']['module']); $request->setControllerName($this->_noAcl['public']['controller']); $request->setActionName($this->_noAcl['public']['action']); $request->setParam('authPage', 'login'); } else { $request->setModuleName($this->_noAcl['public']['module']); $request->setControllerName($this->_noAcl['public']['controller']); $request->setActionName($this->_noAcl['public']['action']); $request->setParam('authPage', 'noauth'); } } } } }
/** * Reset password action * * @return void */ public function resetPasswordAction() { if (strtolower($_SERVER['REQUEST_METHOD']) == 'post') { $userName = Digitalus_Filter_Post::get('name'); $user = new Model_User(); $match = $user->getUserByUsername($userName); if ($match) { //create the password $password = Digitalus_Toolbox_String::random(10); //10 character random string //load the email data $data['username'] = $match->name; $data['first_name'] = $match->first_name; $data['last_name'] = $match->last_name; $data['email'] = $match->email; $data['password'] = $password; //get standard site settings $s = new Model_SiteSettings(); $settings = $s->toObject(); $emailFormat = "Hello %s (<em>%s %s</em>),<br /><br />Your password has been reset to:<br /><br /><strong>%s</strong><br /><br />You can login again with Your new Password.<br /><br />Best wishes,<br />%s"; $emailText = sprintf($emailFormat, $data['username'], $data['first_name'], $data['last_name'], $data['password'], $settings->default_email_sender); //attempt to send the email $mail = new Digitalus_Mail(); if ($mail->send($match->email, array($settings->default_email, $settings->default_email_sender), 'Password Reminder', $emailText)) { //update the user's password $match->password = md5($password); $match->save(); //save the new password $m = new Digitalus_View_Message(); $m->add($this->view->getTranslation('Your password has been reset for security and sent to your email address')); } else { $e = new Digitalus_View_Error(); $e->add($this->view->getTranslation('Sorry, there was an error sending you your updated password. Please contact us for more help.')); } } else { $e = new Digitalus_View_Error(); $e->add($this->view->getTranslation('Sorry, we could not locate your account. Please contact us to resolve this issue.')); } $url = 'admin/auth/login'; $this->_redirect($url); } }
/** * 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'))); }