"Fossies" - the Fresh Open Source Software Archive

Member "papayacms-core-6.12.5/src/system/Papaya/Administration/Pages/Ancestors.php" (7 Jul 2020, 2892 Bytes) of package /linux/www/papayacms-core-6.12.5.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) PHP source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "Ancestors.php" see the Fossies "Dox" file reference documentation.

    1 <?php
    2 /**
    3  * papaya CMS
    4  *
    5  * @copyright 2000-2018 by papayaCMS project - All rights reserved.
    6  * @link http://www.papaya-cms.com/
    7  * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU General Public License, version 2
    8  *
    9  *  You can redistribute and/or modify this script under the terms of the GNU General Public
   10  *  License (GPL) version 2, provided that the copyright and license notes, including these
   11  *  lines, remain unmodified. papaya is distributed in the hope that it will be useful, but
   12  *  WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
   13  *  FOR A PARTICULAR PURPOSE.
   14  */
   15 namespace Papaya\Administration\Pages;
   16 
   17 use Papaya\Content;
   18 use Papaya\UI;
   19 
   20 /**
   21  * Display anchestors of the current page.
   22  *
   23  * @package Papaya-Library
   24  * @subpackage Administration
   25  */
   26 class Ancestors extends UI\Control {
   27   /**
   28    * Member variable for pages subobject
   29    *
   30    * @var Content\Pages
   31    */
   32   private $_pages;
   33 
   34   /**
   35    * Member variable for hierarchy menu subobject
   36    *
   37    * @var UI\Hierarchy\Menu
   38    */
   39   private $_menu;
   40 
   41   /**
   42    * Append ancestor menu xml to parent element, this will do nothing until ids are set.
   43    *
   44    * @param \Papaya\XML\Element $parent
   45    *
   46    * @return null|\Papaya\XML\Element
   47    */
   48   public function appendTo(\Papaya\XML\Element $parent) {
   49     return $this->menu()->appendTo($parent);
   50   }
   51 
   52   /**
   53    * Load data for the given page ids and create items in the menu for them.
   54    *
   55    * @param array $pageIds
   56    */
   57   public function setIds(array $pageIds) {
   58     $this->pages()->load(
   59       [
   60         'id' => $pageIds,
   61         'language_id' => $this->papaya()->administrationLanguage->getCurrent()->id
   62       ]
   63     );
   64     $this->menu()->items->clear();
   65     $this->menu()->items->limit = 10;
   66     foreach ($pageIds as $id) {
   67       if ($this->pages()->offsetExists($id)) {
   68         $data = $this->pages()->offsetGet($id);
   69         $this->menu()->items[] = $item = new UI\Hierarchy\Item($data['title']);
   70         $item->reference->setParameters(['page_id' => $id], 'tt');
   71       }
   72     }
   73   }
   74 
   75   /**
   76    * Content object, to load page informations
   77    *
   78    * @param Content\Pages $pages
   79    *
   80    * @return Content\Pages
   81    */
   82   public function pages(Content\Pages $pages = NULL) {
   83     if (NULL !== $pages) {
   84       $this->_pages = $pages;
   85     } elseif (NULL === $this->_pages) {
   86       $this->_pages = new Content\Pages();
   87       $this->_pages->papaya($this->papaya());
   88     }
   89     return $this->_pages;
   90   }
   91 
   92   /**
   93    * Menu object used to generate xml with page items
   94    *
   95    * @param UI\Hierarchy\Menu $menu
   96    *
   97    * @return UI\Hierarchy\Menu
   98    */
   99   public function menu(UI\Hierarchy\Menu $menu = NULL) {
  100     if (NULL !== $menu) {
  101       $this->_menu = $menu;
  102     } elseif (NULL === $this->_menu) {
  103       $this->_menu = new UI\Hierarchy\Menu();
  104       $this->_menu->papaya($this->papaya());
  105     }
  106     return $this->_menu;
  107   }
  108 }