示例#1
0
 /**
  * Create nav tree from content type
  *
  * @param  mixed $type
  * @param  int   $navId
  * @return void
  */
 protected function createNavFrom($type, $navId)
 {
     if ($type == 'categories') {
         $category = new \Phire\Categories\Model\Category();
         $contentAry = $category->getAll();
         $cat = true;
     } else {
         $sess = Session::getInstance();
         unset($sess->lastSortField);
         unset($sess->lastSortOrder);
         unset($sess->lastPage);
         $content = new \Phire\Content\Model\Content();
         $contentAry = $content->getAll($type, 'id');
         $cat = false;
     }
     foreach ($contentAry as $c) {
         $item = new Table\NavigationItems(['navigation_id' => $navId, 'item_id' => $c->id, 'type' => $cat ? 'category' : 'content', 'name' => $c->title, 'href' => $cat ? '/category' . $c->uri : $c->uri, 'order' => 0]);
         $item->save();
         if (isset($c->status) && $c->status == 1 || !isset($c->status)) {
             $this->createNavChildren($item->id, $navId, $c, 0, $cat);
         }
     }
 }
示例#2
0
 /**
  * batch action method
  *
  * @param  int $lid
  * @return void
  */
 public function batch($lid)
 {
     $library = new Model\MediaLibrary();
     $library->getById($lid);
     if (!isset($library->id)) {
         $this->redirect(BASE_PATH . APP_URI . '/media');
     }
     $browser = new Browser();
     $dragAndDrop = !($browser->isMsie() && $browser->getVersion() <= 9);
     if (null !== $this->request->getQuery('basic') && $this->request->getQuery('basic')) {
         $this->prepareView('media/batch.phtml');
         $this->view->title = 'Media : ' . $library->name . ' : Batch Upload';
         $this->view->lid = $lid;
         $this->view->max = $library->getMaxFilesize();
         $this->view->dragAndDrop = $dragAndDrop;
         $fields = $this->application->config()['forms']['Phire\\Media\\Form\\Batch'];
         $fields[0]['library_id']['value'] = $lid;
         $fields[2]['batch_archive']['label'] = 'Batch Archive File <span class="batch-formats">(' . implode(', ', array_keys(\Pop\Archive\Archive::getFormats())) . ')</span>';
         $fields[2]['batch_archive']['validators'] = new \Pop\Validator\RegEx('/^.*\\.(' . implode('|', array_keys(\Pop\Archive\Archive::getFormats())) . ')$/i', 'That file archive type is not allowed.');
         $this->view->form = new Form\Batch($fields);
         if ($this->request->isPost()) {
             $settings = $library->getSettings();
             $folder = $_SERVER['DOCUMENT_ROOT'] . BASE_PATH . CONTENT_PATH . DIRECTORY_SEPARATOR . $library->folder;
             if (!file_exists($folder)) {
                 $library->createFolder($library->folder);
             }
             $values = !empty($_FILES['file_1']) && !empty($_FILES['file_1']['name']) ? array_merge($this->request->getPost(), ['file_1' => $_FILES['file_1']['name']]) : $this->request->getPost();
             $this->view->form->addFilter('htmlentities', [ENT_QUOTES, 'UTF-8'])->setFieldValues($values, $settings);
             if ($this->view->form->isValid()) {
                 $this->view->form->clearFilters()->addFilter('html_entity_decode', [ENT_QUOTES, 'UTF-8'])->filter();
                 $media = new Model\Media();
                 $media->batch($_FILES, $this->view->form->getFields());
                 $this->view->id = $media->ids;
                 $this->sess->setRequestValue('saved', true);
                 $this->redirect(BASE_PATH . APP_URI . '/media/' . $lid . '?basic=1');
             }
         }
     } else {
         if (!$dragAndDrop) {
             $this->redirect(BASE_PATH . APP_URI . '/media/batch/' . $lid . '?basic=1');
         } else {
             $this->prepareView('media/batch-ajax.phtml');
             $this->view->title = 'Media : ' . $library->name . ' : Batch Upload';
             $this->view->lid = $lid;
             $this->view->max = $library->getMaxFilesize();
             $this->view->categoriesForBatch = null;
             if (class_exists('Phire\\Categories\\Model\\Category')) {
                 $config = $this->application->module('phire-categories');
                 $cat = new \Phire\Categories\Model\Category([], $config);
                 $cat->getAll();
                 if (count($cat->getFlatMap()) > 0) {
                     $categoryValues = $cat->getCategoryValues();
                     $categories = new \Pop\Form\Element\CheckboxSet('categories', $categoryValues);
                     $categories->setLabel('Categories');
                     $this->view->categoriesForBatch = $categories;
                 }
             }
         }
     }
     $this->send();
 }
示例#3
0
 /**
  * Create nav tree from content type
  *
  * @param  int $id
  * @return mixed
  */
 protected function createNavFrom($id)
 {
     $tree = [];
     if ($id == 'categories') {
         $category = new \Phire\Categories\Model\Category();
         $contentAry = $category->getAll();
         $cat = true;
     } else {
         $sess = Session::getInstance();
         unset($sess->lastSortField);
         unset($sess->lastSortOrder);
         unset($sess->lastPage);
         $content = new \Phire\Content\Model\Content();
         $contentAry = $content->getAll($id, 'id');
         $cat = false;
     }
     foreach ($contentAry as $c) {
         $branch = ['id' => $c->id, 'type' => $cat ? 'category' : 'content', 'name' => $c->title, 'href' => $c->uri, 'children' => isset($c->status) && $c->status == 1 || !isset($c->status) ? $this->getNavChildren($c, 0, $cat) : []];
         if (isset($c->roles)) {
             $roles = unserialize($c->roles);
             if (count($roles) > 0) {
                 $branch['acl'] = ['resource' => 'content-' . $c->id];
             }
         }
         if (isset($c->status) && $c->status == 1 || !isset($c->status)) {
             $tree[] = $branch;
         }
     }
     return serialize($tree);
 }