/**
  * Returns an array collection of all parallax pages.
  *
  * @param  integer       $parallaxId
  * @param  array|string  $skipPages
  *
  * @return array
  */
 public function getPageCollection($parallaxId, $skipPages = [])
 {
     if (!is_array($skipPages)) {
         $skipPages = [$skipPages];
     }
     $parallax = Parallaxes::find($parallaxId);
     if (!$parallax || !$parallax->pages) {
         return [];
     }
     $pages = json_decode($parallax->pages, true);
     if (!$pages) {
         $pages = [];
     }
     $collection = [];
     foreach ($pages as $parent) {
         if (!$this->_isPageValid($parallaxId, $parent['pagename'], $skipPages)) {
             continue;
         }
         $tempParent = ['title' => $parent['title'], 'pagename' => $parent['pagename'], 'html' => $this->_getHtmlFromFilename($parent['pagename']), 'url' => $this->_getUrlFromFilename($parent['pagename']), 'children' => []];
         if (is_array($parent['children'])) {
             foreach ($parent['children'] as $child) {
                 if (!$this->_isPageValid($parallaxId, $child['pagename'], $skipPages)) {
                     continue;
                 }
                 $tempChild = ['title' => $child['title'], 'pagename' => $child['pagename'], 'html' => $this->_getHtmlFromFilename($child['pagename']), 'url' => $this->_getUrlFromFilename($child['pagename'])];
                 $tempParent['children'][] = $tempChild;
             }
         }
         $collection[] = $tempParent;
     }
     return $collection;
 }
 /**
  * Deletes single of multiple items from the list.
  */
 public function index_onDelete()
 {
     if (($ids = post('checked')) && is_array($ids) && count($ids)) {
         foreach ($ids as $id) {
             $parallax = Parallax::find($id);
             if ($parallax) {
                 $parallax->delete();
             }
         }
         Flash::success(Lang::get('freestream.parallax::lang.controllers.parallax.deleted_success'));
     }
     return $this->listRefresh();
 }
Example #3
0
 /**
  * Retrieves all pages from the current parallax.
  *
  * @return array
  */
 protected function _getPageCollection()
 {
     if (!$this->_pageCollection) {
         $model = new Parallaxes();
         $this->_pageCollection = $model->getPageCollection($this->property('parallax', $this->page->id));
     }
     return $this->_pageCollection;
 }