Example #1
0
 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 replaceBoldWithStrong($content, $strongClass = null)
 {
     if ($strongClass) {
         $class = 'class="' . $strongClass . '"';
     }
     //get the content body
     $content = Digitalus_Toolbox_Regex::extractHtmlPart($content, 'body');
     //replace the tags
     $content = Digitalus_Toolbox_Regex::replaceTag('b', 'strong', $content, $class);
     return $content;
 }
Example #3
0
 /**
  * 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);
         }
     }
 }
Example #4
0
 /**
  * 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);
         }
     }
 }
Example #5
0
 /**
  * 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');
 }
Example #6
0
 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');
     }
 }
Example #7
0
 /**
  *
  */
 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);
 }
Example #8
0
 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);
 }
Example #9
0
 /**
  *
  */
 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;
 }
Example #10
0
 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');
     }
 }
Example #12
0
 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');
     }
 }
Example #13
0
 /**
  * returns the current file from the path
  * this is a custom version of basename
  *
  * @param string $path
  * @return string
  */
 public static function getSelfFromPath($path)
 {
     $path = Digitalus_Toolbox_Regex::stripTrailingSlash($path);
     $parts = explode('/', $path);
     return array_pop($parts);
 }
Example #14
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);
     return str_replace(' ', '_', trim($uri));
 }