/** * */ public function checkSkinStyles($name, $values) { $config = Zend_Registry::get('config'); $basePath = $config->design->pathToSkins; $xhtml = array(); $this->view->name = $name; $this->view->selectedStyles = $values; //load the skin folders if (is_dir('./' . $basePath)) { $folders = Digitalus_Filesystem_Dir::getDirectories('./' . $basePath); if (count($folders) > 0) { foreach ($folders as $folder) { $this->view->skin = $folder; $styles = Digitalus_Filesystem_File::getFilesByType('./' . $basePath . '/' . $folder . '/styles', 'css'); if (is_array($styles)) { foreach ($styles as $style) { //add each style sheet to the hash // key = path / value = filename $hashStyles[$style] = $style; } $this->view->styles = $hashStyles; $xhtml[] = $this->view->render($this->partialFile); unset($hashStyles); } } } } else { throw new Zend_Acl_Exception('Unable to locate skin folder'); } return implode(null, $xhtml); }
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; }
/** * display all of the current commands * */ public function run($params = null) { $commands = Digitalus_Filesystem_File::getFilesByType(BASE_PATH . Digitalus_Command::PATH_TO_COMMANDS, 'php'); foreach ($commands as $command) { //clean up the list if ($command != 'Abstract.php' && $command != 'List.php' && $command != 'Exception.php') { $cleanCommand = Digitalus_Toolbox_Regex::stripFileExtension($command); $link = '<a class="loadCommand" href="#" title="' . $cleanCommand . '">' . $cleanCommand . '</a>'; $this->log($link); } } }
/** * display all of the current commands * */ public function run() { $commands = Digitalus_Filesystem_File::getFilesByType(Digitalus_Command::PATH_TO_COMMANDS, 'php'); foreach ($commands as $command) { //clean up the list if ($command != 'Abstract.php' && $command != 'List.php') { $cleanCommand = Digitalus_Toolbox_Regex::stripFileExtension($command); $link = "<a class='loadCommand' href='#' title='" . $cleanCommand . "'>" . $cleanCommand . "</a>"; $this->log($link); } } }
/** * Initialize the form * * @return void */ public function init() { parent::init(); $view = $this->getView(); // create new element $id = $this->createElement('hidden', 'id', array('decorators' => array('ViewHelper'))); $this->addElement($id); // create new element $name = $this->createElement('text', 'page_name', array('label' => $view->getTranslation('Page Name'), 'required' => true, 'filters' => array('StringTrim', 'StripTags'), 'validators' => array(array('NotEmpty', true), array('StringLength', true, array(4, Model_Page::PAGE_NAME_LENGTH)), array('Regex', true, array('pattern' => Model_Page::PAGE_NAME_REGEX, 'messages' => array('regexNotMatch' => Model_Page::PAGE_NAME_REGEX_NOTMATCH)))), 'attribs' => array('size' => 50), 'order' => 0)); $this->addElement($name); // add options for parent page $multiOptions = array(0 => $view->getTranslation('Site Root')); $mdlIndex = new Model_Page(); $index = $mdlIndex->getIndex(0, 'name'); if (is_array($index)) { foreach ($index as $id => $page) { $multiOptions[$id] = $page; } } // create new element $parentId = $this->createElement('select', 'parent_id', array('label' => $view->getTranslation('Parent page') . ':', 'required' => true, 'multiOptions' => $multiOptions, 'order' => 1)); $this->addElement($parentId); // add options for template $multiOptions = array(); $templateConfig = Zend_Registry::get('config')->template; $templates = Digitalus_Filesystem_Dir::getDirectories(BASE_PATH . '/' . $templateConfig->pathToTemplates . '/public'); foreach ($templates as $template) { $designs = Digitalus_Filesystem_File::getFilesByType(BASE_PATH . '/' . $templateConfig->pathToTemplates . '/public/' . $template . '/pages', 'xml'); if (is_array($designs)) { foreach ($designs as $design) { $design = Digitalus_Toolbox_Regex::stripFileExtension($design); $multiOptions[$template . '_' . $design] = $view->getTranslation($template) . ' / ' . $view->getTranslation($design); } } } // create new element $contentTemplate = $this->createElement('select', 'content_template', array('label' => $view->getTranslation('Template') . ':', 'required' => true, 'multiOptions' => $multiOptions, 'order' => 2)); $this->addElement($contentTemplate); // create new element $continue = $this->createElement('checkbox', 'continue_adding_pages', array('label' => $view->getTranslation('Continue adding pages') . '?', 'order' => 3)); $this->addElement($continue); // create new element $showOnMenu = $this->createElement('checkbox', 'show_on_menu', array('label' => $view->getTranslation('Show Page on menu') . '?', 'order' => 4)); $this->addElement($showOnMenu); // create new element $publish = $this->createElement('checkbox', 'publish_pages', array('label' => $view->getTranslation('Publish page instantly') . '?', 'order' => 5)); $this->addElement($publish); // create new element $submit = $this->createElement('submit', 'submitPageForm', array('label' => $view->getTranslation('Submit'), 'attribs' => array('class' => 'submit'), 'order' => 1000)); $this->addElement($submit); $this->addDisplayGroup(array('form_instance', 'id', 'page_name', 'parent_id', 'content_template', 'continue_adding_pages', 'show_on_menu', 'publish_pages', 'submitPageForm'), 'createPageGroup'); }
public function SelectModulePage($name, $module, $value, $attribs = null) { $pages = Digitalus_Filesystem_File::getFilesByType('./application/modules/' . $module . '/views/scripts/public', 'phtml'); if (is_array($pages)) { $data[] = $this->view->getTranslation('Select One'); foreach ($pages as $page) { $page = Digitalus_Toolbox_Regex::stripFileExtension($page); $data[$page] = $page; } return $this->view->formSelect($name, $value, $attribs, $data); } else { return $this->view->getTranslation('There are no pages in this module'); } }
/** * */ public function selectDesign($name, $value = null, $attr = null) { $templateConfig = Zend_Registry::get('config')->template; $templates = Digitalus_Filesystem_Dir::getDirectories(BASE_PATH . '/' . $templateConfig->pathToTemplates . '/public'); foreach ($templates as $template) { $designs = Digitalus_Filesystem_File::getFilesByType(BASE_PATH . '/' . $templateConfig->pathToTemplates . '/public/' . $template . '/pages', 'xml'); if (is_array($designs)) { foreach ($designs as $design) { $design = Digitalus_Toolbox_Regex::stripFileExtension($design); $options[$template . '_' . $design] = $template . ' / ' . $design; } } } return $this->view->formSelect($name, $value, $attr, $options); }
public function init() { $id = $this->createElement('hidden', 'id'); $id->setDecorators(array('ViewHelper')); $this->addElement($id); $name = $this->createElement('text', 'page_name'); $name->addFilter('StripTags'); $name->setRequired(true); $name->setLabel('Page Name: '); $name->setAttrib('size', 50); $name->setOrder(0); $this->addElement($name); $parentId = $this->createElement('select', 'parent_id'); $parentId->setLabel($this->getView()->getTranslation('Parent page') . ':'); $mdlIndex = new Model_Page(); $index = $mdlIndex->getIndex(0, 'name'); $parentId->addMultiOption(0, $this->getView()->getTranslation('Site Root')); if (is_array($index)) { foreach ($index as $id => $page) { $parentId->addMultiOption($id, $page); } } $parentId->setOrder(1); $this->addElement($parentId); $contentTemplate = $this->createElement('select', 'content_template'); $contentTemplate->setLabel($this->getView()->getTranslation('Template') . ':'); $templateConfig = Zend_Registry::get('config')->template; $templates = Digitalus_Filesystem_Dir::getDirectories(BASE_PATH . '/' . $templateConfig->pathToTemplates . '/public'); foreach ($templates as $template) { $designs = Digitalus_Filesystem_File::getFilesByType(BASE_PATH . '/' . $templateConfig->pathToTemplates . '/public/' . $template . '/pages', 'xml'); if (is_array($designs)) { foreach ($designs as $design) { $design = Digitalus_Toolbox_Regex::stripFileExtension($design); $contentTemplate->addMultiOption($template . '_' . $design, $template . ' / ' . $design); } } } $contentTemplate->setOrder(2); $this->addElement($contentTemplate); $continue = $this->createElement('checkbox', 'continue_adding_pages'); $continue->setLabel($this->getView()->getTranslation('Continue adding pages') . '?'); $continue->setOrder(3); $this->addElement($continue); $submit = $this->createElement('submit', $this->getView()->getTranslation('Submit')); $submit->setOrder(1000); $this->addElement($submit); }
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; }
/** * */ public function selectLayout($name, $value = null, $attr = null, $defaut = null) { $config = Zend_Registry::get('config'); $pathToPublicLayouts = $config->design->pathToPublicLayouts; $layouts = Digitalus_Filesystem_File::getFilesByType($pathToPublicLayouts, 'phtml'); if ($defaut == NULL) { $defaut = $this->view->getTranslation('Select One'); } $options[0] = $defaut; if (is_array($layouts)) { foreach ($layouts as $layout) { $options[$layout] = $layout; } return $this->view->formSelect($name, $value, $attr, $options); } else { return null; } }
/** * */ public function selectDesign($name, $value = null, $attribs = null, $options = null) { $templateConfig = Zend_Registry::get('config')->template; $templates = Digitalus_Filesystem_Dir::getDirectories(BASE_PATH . '/' . $templateConfig->pathToTemplates . '/public'); foreach ($templates as $template) { $designs = Digitalus_Filesystem_File::getFilesByType(BASE_PATH . '/' . $templateConfig->pathToTemplates . '/public/' . $template . '/pages', 'xml'); if (is_array($designs)) { foreach ($designs as $design) { $design = Digitalus_Toolbox_Regex::stripFileExtension($design); $options[$template . '_' . $design] = $template . ' / ' . $design; } } } $form = new Digitalus_Form(); $select = $form->createElement('select', $name, array('multiOptions' => $options, 'value' => $value)); if (is_array($attribs)) { $select->setAttribs($attribs); } return $select; }
protected function _getModuleForms() { $moduleForms = array(); $modules = Digitalus_Filesystem_Dir::getDirectories(APPLICATION_PATH . '/modules'); if (is_array($modules)) { foreach ($modules as $module) { $pages = Digitalus_Filesystem_File::getFilesByType(APPLICATION_PATH . '/modules/' . $module . '/views/scripts/public', 'phtml'); if (is_array($pages)) { foreach ($pages as $page) { if (strpos($page, '.form.')) { $page = Digitalus_Toolbox_Regex::stripFileExtension($page); $page = str_replace('.form', '', $page); $moduleForms[$module . '_' . $page] = $this->view->getTranslation($module) . ' -> ' . $page; } } } } return $moduleForms; } return false; }
public function selectModulePage($name, $module, $value, $attribs = null) { $pages = Digitalus_Filesystem_File::getFilesByType(APPLICATION_PATH . '/modules/' . $module . '/views/scripts/public', 'phtml'); if (is_array($pages)) { $options[] = $this->view->getTranslation('Select One'); foreach ($pages as $page) { $page = Digitalus_Toolbox_Regex::stripFileExtension($page); $options[$page] = $page; } $form = new Digitalus_Form(); $select = $form->createElement('select', $name, array('multiOptions' => $options)); if (is_array($value)) { $select->setValue($value); } if (is_array($attribs)) { $select->setAttribs($attribs); } return $select; } else { return $this->view->getTranslation('There are no pages in this module'); } }
public function SelectModule($name, $value, $attribs = null) { $modules = Digitalus_Filesystem_Dir::getDirectories('./application/modules'); if (is_array($modules)) { $data[] = $this->view->getTranslation('Select a module'); foreach ($modules as $module) { $pages = Digitalus_Filesystem_File::getFilesByType('./application/modules/' . $module . '/views/scripts/public', 'phtml'); if (is_array($pages)) { foreach ($pages as $page) { if (!strpos($page, '.form.')) { $page = Digitalus_Toolbox_Regex::stripFileExtension($page); $data[$module . '_' . $page] = $module . ' -> ' . $page; } } } } $attribs['multiple'] = false; return $this->view->formSelect($name, $value, $attribs, $data); } else { return $this->view->getTranslation('There are no modules currently installed'); } }
/** * 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; }
/** * Open Folder Action * * @return void */ public function openFolderAction() { $folder = $this->_request->getParam('folder'); $folder = str_replace('media_', '', $folder); $folder = Digitalus_Toolbox_String::stripLeading('_', $folder); $data = array(); $data['path'] = $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)) { $data['folderPathParts'] = $folderPathParts; $data['label'] = array_pop($folderPathParts); } $pathToFolder = Digitalus_Toolbox_String::stripUnderscores($folder); $data['filepath'] = $pathToFolder; $data['mediapath'] = $folder; $data['folders'] = Digitalus_Filesystem_Dir::getDirectories($this->_pathToMedia . '/' . $pathToFolder); $data['files'] = Digitalus_Filesystem_File::getFilesByType($this->_pathToMedia . '/' . $pathToFolder, false, false, true); $data['mediaFolder'] = $this->view->mediaFolder; $form = new Admin_Form_Media(null, $data); $form->setDecorators(array('FormElements', 'Form', array('FormErrors', array('placement' => 'prepend')))); if ($this->_request->isPost() && Digitalus_Filter_Post::has('form_instance')) { $path = Digitalus_Filter_Post::get('path'); $filePath = Digitalus_Filter_Post::get('filepath'); $mediaPath = Digitalus_Filter_Post::get('mediapath'); $folderName = Digitalus_Filter_Post::get('folder_name'); $newFolderName = Digitalus_Filter_Post::get('new_folder_name'); // indicator if it is a return of one of the other actions if (false == $this->_request->getParam('return')) { // createFolderAction if ($form->isValidPartial(array('path' => $path, 'folder_name' => $folderName)) && isset($_POST['createFolderSubmit']) && !empty($_POST['createFolderSubmit'])) { $this->_request->setParam('path', $path); $this->_request->setParam('folder_name', $folderName); $this->_forward('create-folder'); // renameFolderAction } else { if ($form->isValidPartial(array('filepath' => $filePath, 'new_folder_name' => $newFolderName)) && isset($_POST['renameFolderSubmit']) && !empty($_POST['renameFolderSubmit'])) { $this->_request->setParam('filepath', $filePath); $this->_request->setParam('new_folder_name', $newFolderName); $this->_forward('rename-folder'); // uploadAction } else { if ($form->isValidPartial(array('filepath' => $filePath, 'mediapath' => $mediaPath)) && isset($_POST['uploadSubmit']) && !empty($_POST['uploadSubmit'])) { $this->_request->setParam('filepath', $filePath); $this->_request->setParam('mediapath', $mediaPath); $this->_forward('upload'); } } } } } $this->view->form = $form; $tmpPath = Digitalus_Toolbox_String::addUnderscores($folder); $this->view->toolbarLinks['Add to my bookmarks'] = $this->baseUrl . '/admin/index/bookmark' . '/url/admin_media_open-folder_folder_' . $tmpPath . '/label/' . $this->view->getTranslation('Media') . ':' . $pathToFolder; $this->view->toolbarLinks['Delete'] = $this->baseUrl . '/admin/media/delete-folder/folder/' . $folder; $this->view->breadcrumbs[$this->view->getTranslation('Open Folder') . ': ' . Digitalus_Toolbox_String::stripUnderscores($folder)] = $this->baseUrl . '/admin/media/open-folder/folder/' . $folder; }