Esempio n. 1
0
 public function save($args)
 {
     // If we've gotten to the process() function for this class, we assume that we're in
     // the clear, as far as permissions are concerned (since we check permissions at several
     // points within the dispatcher)
     $db = Database::connection();
     $bID = $this->bID;
     $c = $this->getCollectionObject();
     if (is_object($c)) {
         $this->cID = $c->getCollectionID();
         $this->cPID = $c->getCollectionParentID();
     }
     $args += ['enableExternalFiltering' => 0, 'includeAllDescendents' => 0, 'includeDate' => 0, 'truncateSummaries' => 0, 'displayFeaturedOnly' => 0, 'topicFilter' => '', 'displayThumbnail' => 0, 'displayAliases' => 0, 'truncateChars' => 0, 'paginate' => 0, 'rss' => 0, 'pfID' => 0, 'filterDateOption' => '', 'cParentID' => null];
     $args['num'] = $args['num'] > 0 ? $args['num'] : 0;
     $args['cThis'] = $args['cParentID'] == $this->cID ? '1' : '0';
     $args['cThisParent'] = $args['cParentID'] == $this->cPID ? '1' : '0';
     $args['cParentID'] = $args['cParentID'] == 'OTHER' ? $args['cParentIDValue'] : $args['cParentID'];
     if (!$args['cParentID']) {
         $args['cParentID'] = 0;
     }
     $args['enableExternalFiltering'] = $args['enableExternalFiltering'] ? '1' : '0';
     $args['includeAllDescendents'] = $args['includeAllDescendents'] ? '1' : '0';
     $args['includeDate'] = $args['includeDate'] ? '1' : '0';
     $args['truncateSummaries'] = $args['truncateSummaries'] ? '1' : '0';
     $args['displayFeaturedOnly'] = $args['displayFeaturedOnly'] ? '1' : '0';
     $args['filterByRelated'] = $args['topicFilter'] == 'related' ? '1' : '0';
     $args['filterByCustomTopic'] = $args['topicFilter'] == 'custom' ? '1' : '0';
     $args['displayThumbnail'] = $args['displayThumbnail'] ? '1' : '0';
     $args['displayAliases'] = $args['displayAliases'] ? '1' : '0';
     $args['truncateChars'] = intval($args['truncateChars']);
     $args['paginate'] = intval($args['paginate']);
     $args['rss'] = intval($args['rss']);
     $args['ptID'] = intval($args['ptID']);
     if (!$args['filterByRelated']) {
         $args['relatedTopicAttributeKeyHandle'] = '';
     }
     if (!$args['filterByCustomTopic']) {
         $args['customTopicAttributeKeyHandle'] = '';
         $args['customTopicTreeNodeID'] = 0;
     }
     if ($args['rss']) {
         if (isset($this->pfID) && $this->pfID) {
             $pf = Feed::getByID($this->pfID);
         }
         if (!is_object($pf)) {
             $pf = new \Concrete\Core\Entity\Page\Feed();
             $pf->setTitle($args['rssTitle']);
             $pf->setDescription($args['rssDescription']);
             $pf->setHandle($args['rssHandle']);
         }
         $pf->setParentID($args['cParentID']);
         $pf->setPageTypeID($args['ptID']);
         $pf->setIncludeAllDescendents($args['includeAllDescendents']);
         $pf->setDisplayAliases($args['displayAliases']);
         $pf->setDisplayFeaturedOnly($args['displayFeaturedOnly']);
         $pf->setDisplayAliases($args['displayAliases']);
         $pf->displayShortDescriptionContent();
         $pf->save();
         $args['pfID'] = $pf->getID();
     } elseif (isset($this->pfID) && $this->pfID && !$args['rss']) {
         // let's make sure this isn't in use elsewhere.
         $cnt = $db->fetchColumn('select count(pfID) from btPageList where pfID = ?', [$this->pfID]);
         if ($cnt == 1) {
             // this is the last one, so we delete
             $pf = Feed::getByID($this->pfID);
             if (is_object($pf)) {
                 $pf->delete();
             }
         }
         $args['pfID'] = 0;
     }
     if ($args['filterDateOption'] != 'between') {
         $args['filterDateStart'] = null;
         $args['filterDateEnd'] = null;
     }
     if ($args['filterDateOption'] == 'past') {
         $args['filterDateDays'] = $args['filterDatePast'];
     } elseif ($args['filterDateOption'] == 'future') {
         $args['filterDateDays'] = $args['filterDateFuture'];
     } else {
         $args['filterDateDays'] = null;
     }
     $args['pfID'] = intval($args['pfID']);
     parent::save($args);
 }
Esempio n. 2
0
 protected function loadFeedFromRequest(\Concrete\Core\Entity\Page\Feed $pf = null)
 {
     if (!$pf) {
         $pf = new \Concrete\Core\Entity\Page\Feed();
     }
     $pf->setTitle($this->post('pfTitle'));
     $pf->setDescription($this->post('pfDescription'));
     $pf->setHandle($this->post('pfHandle'));
     $pf->setPageTypeID($this->post('ptID'));
     $pf->setCustomTopicAttributeKeyHandle($this->post('customTopicAttributeKeyHandle'));
     $customTopicTreeNodeID = $this->post('customTopicAttributeKeyHandle') ? $this->post('customTopicTreeNodeID') : 0;
     $pf->setCustomTopicTreeNodeID($customTopicTreeNodeID);
     $pf->setParentID(intval($this->post('cParentID')));
     $pf->setIncludeAllDescendents($this->post('pfIncludeAllDescendents'));
     $pf->setDisplayAliases($this->post('pfDisplayAliases'));
     $pf->setIconFileID($this->post('iconFID'));
     $pf->setDisplayFeaturedOnly($this->post('pfDisplayFeaturedOnly'));
     if ($this->post('pfContentToDisplay') == 'A') {
         $pf->displayAreaContent($this->post('pfAreaHandleToDisplay'));
     } else {
         $pf->displayShortDescriptionContent();
     }
     return $pf;
 }
 public function import(\SimpleXMLElement $sx)
 {
     if (isset($sx->pagefeeds)) {
         foreach ($sx->pagefeeds->feed as $f) {
             $feed = Feed::getByHandle((string) $f->handle);
             $inspector = \Core::make('import/value_inspector');
             if (!is_object($feed)) {
                 $feed = new \Concrete\Core\Entity\Page\Feed();
             }
             if ($f->parent) {
                 $result = $inspector->inspect((string) $f->parent);
                 $parent = $result->getReplacedValue();
                 $feed->setParentID($parent);
             }
             $feed->setTitle((string) $f->title);
             $feed->setDescription((string) $f->description);
             $feed->setHandle((string) $f->handle);
             if ($f->descendents) {
                 $feed->setIncludeAllDescendents(true);
             }
             if ($f->aliases) {
                 $feed->setDisplayAliases(true);
             }
             if ($f->featured) {
                 $feed->setDisplayFeaturedOnly(true);
             }
             if ($f->pagetype) {
                 $result = $inspector->inspect((string) $f->pagetype);
                 $pagetype = $result->getReplacedValue();
                 $feed->setPageTypeID($pagetype);
             }
             $contentType = $f->contenttype;
             $type = (string) $contentType['type'];
             if ($type == 'description') {
                 $feed->displayShortDescriptionContent();
             } elseif ($type == 'area') {
                 $feed->displayAreaContent((string) $contentType['handle']);
             }
             $feed->save();
         }
     }
 }