/**
  *
  */
 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);
 }
Exemple #2
0
 /**
  * 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 function editAction()
 {
     $cId = $this->_request->getParam('cId');
     $cPath = $this->_request->getParam('cPath');
     if ($this->_request->isPost()) {
         if (Digitalus_Filesystem_File::isUploaded('field_image')) {
             // Xu ly upload file
             $upload = new Digitalus_Resource_Image();
             $ext = Digitalus_Filesystem_File::getFileExtension($_FILES['field_image']['name']);
             $file_name = 'cat_' . time() . ".{$ext}";
             $upload->uploadImage('field_image', $file_name, DIR_VM_CATALOG_IMAGE, false, false);
             $_POST['image'] = DIR_VM_CATALOG_IMAGE . "/{$file_name}";
         }
         if ($this->_objCats->updateFromPost()) {
             $this->_redirect($this->_currentControllerUrl);
             return;
         }
         $rowManu = $this->_objCats->createRow($this->_request->getParams());
     } else {
         $rowCat = $this->_objCats->find($cId)->current();
         if (!$rowCat) {
             $this->_redirect($this->_currentControllerUrl);
         }
     }
     $this->view->breadCrumbs = $this->view->partial('category-product/_bread_crumbs.phtml', array('view' => $this->view, 'arrPath' => $this->view->getBreadCrumbsData($cId)));
     $this->view->rowCat = $rowCat;
     $this->view->cId = $cId;
     $this->view->cPath = $cPath;
     $this->view->title_action = $this->view->getTranslation('Edit');
 }
 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 addAction()
 {
     $cId = $this->_request->getParam('cId', 0);
     $cPath = $this->_request->getParam('cPath', null);
     $type_id = $this->_request->getParam('type_id', null);
     // Neu khong ton tai category hay product thi chuyen den trang chu
     if ($cId != 0 && !$this->_objCats->find($cId)->current()) {
         $this->_redirect($this->_currentModuleUrl);
     }
     $val = array('tax_rates_id' => 0, 'quantity' => 0, 'price' => 0, 'discount' => 0, 'weight' => 0, 'in_stock' => 0, 'quantity_order_min' => 0, 'quantity_order_max' => 0, 'quantity_order_units' => 0, 'is_virtual' => 0, 'is_free' => 0, 'is_call' => 0, 'is_always_free_shipping' => 0, 'order' => 0, 'active' => 0);
     //you must validate that the session ids match
     if ($this->_request->isPost()) {
         if (Digitalus_Filesystem_File::isUploaded('field_image')) {
             // Xu ly upload file
             $upload = new Digitalus_Resource_Image();
             $ext = Digitalus_Filesystem_File::getFileExtension($_FILES['field_image']['name']);
             $file_name = 'cat_' . time() . ".{$ext}";
             $upload->uploadImage('field_image', $file_name, DIR_VM_CATALOG_IMAGE, false, false);
             $_POST['image'] = DIR_VM_CATALOG_IMAGE . "/{$file_name}";
         }
         if ($this->_objCats->insertFromPost()) {
             $this->_redirect($this->_currentControllerUrl);
             return;
         }
         $val = $this->_request->getParams();
     }
     $this->view->breadCrumbs = $this->view->partial('category-product/_bread_crumbs.phtml', array('view' => $this->view, 'arrPath' => $this->view->getBreadCrumbsData($cId)));
     $rowProduct = $this->_objProducts->createRow($val);
     $this->view->rowProduct = $rowProduct;
     $this->view->cId = $cId;
     $this->view->cPath = $cPath;
     $this->view->type_id = $type_id;
     $this->view->title_action = $this->view->getTranslation('Add');
 }
 public function editAction()
 {
     if ($this->_request->isPost()) {
         if (Digitalus_Filesystem_File::isUploaded('field_image')) {
             // Xu ly upload file
             $upload = new Digitalus_Resource_Image();
             $ext = Digitalus_Filesystem_File::getFileExtension($_FILES['field_image']['name']);
             $file_name = 'manu_' . time() . ".{$ext}";
             $upload->uploadImage('field_image', $file_name, DIR_VM_MANUFACTURER_IMAGE, false, false);
             $_POST['image'] = DIR_VM_MANUFACTURER_IMAGE . "/{$file_name}";
         }
         if ($this->_objManus->updateFromPost()) {
             $this->_redirect($this->_currentControllerUrl);
             return;
         }
         $rowManu = $this->_objManus->createRow($this->_request->getParams());
     } else {
         $id = $this->_request->getParam('id');
         $rowManu = $this->_objManus->find($id)->current();
         if (!$rowManu) {
             $this->_redirect($this->_currentControllerUrl);
         }
     }
     $this->view->rowManu = $rowManu;
     $this->view->title_action = $this->view->getTranslation('Edit');
 }
 public function editAction()
 {
     $this->loadLeftPage();
     if ($this->_request->isPost()) {
         if (Digitalus_Filesystem_File::isUploaded('field_default_image')) {
             // Xu ly upload file
             $upload = new Digitalus_Resource_Image();
             $ext = Digitalus_Filesystem_File::getFileExtension($_FILES['field_default_image']['name']);
             $file_name = 'type_' . time() . ".{$ext}";
             $upload->uploadImage('field_default_image', $file_name, DIR_VM_PRODUCT_TYPE_IMAGE, false, false);
             $_POST['default_image'] = DIR_VM_PRODUCT_TYPE_IMAGE . "/{$file_name}";
         }
         if ($this->_objProTypes->updateFromPost()) {
             // Xoa toan bo cache trong trong troller nay
             $this->_redirect($this->_currentControllerUrl);
             return;
         }
         $rowType = $this->_objProTypes->createRow($this->_request->getParams());
     } else {
         $id = $this->_request->getParam('id');
         $rowType = $this->_objProTypes->find($id)->current();
         if (!$rowType) {
             $this->_redirect($this->_currentControllerUrl);
         }
     }
     $this->view->rowType = $rowType;
     $this->view->title_action = "Edit";
 }
Exemple #8
0
 public static function load($filepath)
 {
     $fileExtension = Digitalus_Filesystem_File::getFileExtension($filepath);
     $fileExtension = strtolower($fileExtension);
     $allowedFiletypes = Digitalus_Media::getFiletypes();
     if (is_array($allowedFiletypes) && array_key_exists($fileExtension, $allowedFiletypes)) {
         return $allowedFiletypes[$fileExtension];
     }
     return null;
 }
Exemple #9
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);
         }
     }
 }
Exemple #10
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);
         }
     }
 }
Exemple #11
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');
 }
 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');
     }
 }
Exemple #13
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);
 }
Exemple #14
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);
 }
Exemple #15
0
 public static function upload($file, $path, $filename = null, $createPath = true, $base = '.')
 {
     $view = Zend_Controller_Action_HelperBroker::getStaticHelper('viewRenderer')->view;
     $e = new Digitalus_View_Error();
     if ($file['error'] == 4 || empty($file['name'])) {
         return;
     }
     if (self::isAllowed($file['type'])) {
         $path = self::getMediaPath($path);
         //default to the name on the client machine
         if (is_null($filename)) {
             $filename = $file['name'];
         }
         $filename = str_replace('_', '-', $filename);
         $filename = str_replace(' ', '-', $filename);
         $path = str_replace(self::rootDirectory(), '', $path);
         $path = Digitalus_Toolbox_String::stripUnderscores($path);
         $path = Digitalus_Toolbox_String::stripLeading('/', $path);
         /*
          * This fixes an issue when the system is installed on a path other than
          * root. Path should contain a path that is relative to the (cms) root
          * index.php (not root to the public_html of the web server (as it was trying
          * to do before).
          */
         $config = Zend_Registry::get('config');
         $path = $config->filepath->media . '/' . $path;
         if ($createPath) {
             //attempt to create the new path
             Digitalus_Filesystem_Dir::makeRecursive($base, $path);
         }
         //clean the filename
         $filename = Digitalus_Filesystem_File::cleanFilename($filename);
         $filename = basename($filename);
         $path .= '/' . $filename;
         if (move_uploaded_file($file['tmp_name'], $path)) {
             //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($base . '/', $path);
             return $fullPath;
         } else {
             $e->add($view->getTranslation('An error occurred uploading the file' . ': ' . $file['name']));
         }
     } else {
         $e->add($view->getTranslation('This filetype is not allowed' . ': ' . $file['type']));
     }
 }
Exemple #16
0
 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 = "&nbsp;<input type='radio' value='' name='{$name}'/>&nbsp;Empty&nbsp;";
     foreach ($arr_files as $icon_file) {
         $data .= "&nbsp;<span><input type='radio' value='{$icon_file}' name='admin_menu_img'/>&nbsp;";
         $data .= "<img src='{$dir}/{$icon_file}' alt='{$icon_file}'/></span>&nbsp;";
     }
     $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;
 }
Exemple #20
0
 public static function upload($file, $path, $filename, $createPath = true, $base = '.')
 {
     if (self::isAllowed($file['type'])) {
         $path = self::getMediaPath($path);
         //default to the name on the client machine
         if ($filename == null) {
             $filename = $file['name'];
         }
         $filename = str_replace('_', '-', $filename);
         $filename = str_replace(' ', '-', $filename);
         $path = str_replace(self::rootDirectory(), '', $path);
         $path = Digitalus_Toolbox_String::stripUnderscores($path);
         $path = Digitalus_Toolbox_String::stripLeading('/', $path);
         /*
          * Update by Brad Seefeld on May 12, 2009
          *
          * This fixes an issue when the system is installed on a path other than
          * root. Path should contain a path that is relative to the (cms) root
          * index.php (not root to the public_html of the web server (as it was trying
          * to do before).
          */
         $config = Zend_Registry::get('config');
         $path = $config->filepath->media . '/' . $path;
         if ($createPath) {
             //attempt to create the new path
             Digitalus_Filesystem_Dir::makeRecursive($base, $path);
         }
         //clean the filename
         $filename = Digitalus_Filesystem_File::cleanFilename($filename);
         $filename = basename($filename);
         $path .= '/' . $filename;
         if (move_uploaded_file($file['tmp_name'], $path)) {
             //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($base . '/', $path);
             return $fullPath;
         }
     }
 }
Exemple #21
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');
     }
 }
 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');
     }
 }
Exemple #23
0
 /**
  * Test action
  *
  * @return void
  */
 public function testAction()
 {
     $str = "test  --------  test";
     $str = preg_replace("/\\s*[-\\s]+\\s*/", "_", $str);
     echo "<pre>";
     print_r($str);
     echo "</pre>";
     exit;
     //    	html_entity_decode();
     //  		$convert = Digitalus_Convert::removeAccent("Bùi Văn Tiến Đức");
     //		$objhtmlEntities 	= new Zend_Filter_HtmlEntities();
     $v = new Digitalus_Convert();
     $str = '<img align="left" style="" width="" height="" class="border_img" src="/media/image/images_2.jpeg" alt="" />';
     //		&lt;p&gt;&lt;img height=\&quot;150\&quot; width=\&quot;100\&quot; src=\&quot;/media/image/images_2.jpeg\&quot; alt=\&quot;\&quot; /&gt;&lt;/p&gt;
     //		&lt;p&gt;&lt;img height=\&quot;150\&quot; width=\&quot;100\&quot; src=\&quot;/media/image/images_2.jpeg\&quot; alt=\&quot;\&quot; /&gt;&lt;/p&gt;
     //		&lt;img align=&quot;left&quot; style=&quot;&quot; width=&quot;&quot; height=&quot;&quot; class=&quot;border_img&quot; src=&quot;/media/image/images_2.jpeg&quot; alt=&quot;&quot; /&gt;
     $ss = "&lt;p&gt;&lt;img height=\\&quot;150\\&quot; width=\\&quot;100\\&quot; src=\\&quot;/media/image/images_2.jpeg\\&quot; alt=\\&quot;\\&quot; /&gt;&lt;/p&gt;";
     // Nguyen goc
     print_r($str);
     // Luu vao database
     $str_1 = $v->scriptToData($str, 'editor');
     print_r($str_1);
     // Outputs: A 'quote' is &lt;b&gt;bold&lt;/b&gt;
     //		$str = htmlentities($str);
     //		$str = $objhtmlEntities->filter($str);
     // Outputs: A &#039;quote&#039; is &lt;b&gt;bold&lt;/b&gt;
     //		echo htmlentities($str, ENT_QUOTES);
     // Script View
     print_r($v->dataToScriptView($str_1));
     echo "<br><br><br><br><br><br><br><br><br><br><br><br><br><br>";
     print_r($v->dataToScriptEdit($ss, 'editor'));
     exit;
     if ($this->_request->isPost()) {
         $upload = new Digitalus_Resource_Image();
         $ext = Digitalus_Filesystem_File::getFileExtension($_FILES['file_field']['name']);
         $upload->uploadImage('file_field', time() . ".{$ext}", 'tam_tru');
         echo "<pre>";
         print_r($upload->fullPath);
         echo "</pre>";
         echo "<pre>";
         print_r($_FILES);
         echo "</pre>";
         exit;
     }
 }
Exemple #24
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;
 }
 /**
  * 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;
 }