Exemple #1
0
 public function output($identifier)
 {
     if ($feed = PageFeed::getByHandle($identifier)) {
         if ($xml = $feed->getOutput($this->request)) {
             return Response::create($xml, 200, array('Content-Type' => 'text/xml'));
         }
     }
     return Response::create('', 404);
 }
Exemple #2
0
 public function get($identifier)
 {
     $feed = \Concrete\Core\Page\Feed::getByHandle($identifier);
     if (is_object($feed)) {
         //header('Content-Type: text/xml');
         $xml = $feed->getOutput($this->request);
         print $xml;
     }
     exit;
 }
 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();
         }
     }
 }
Exemple #4
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 = Loader::db();
     $bID = $this->bID;
     $c = $this->getCollectionObject();
     if (is_object($c)) {
         $this->cID = $c->getCollectionID();
     }
     $args = $args + array('enableExternalFiltering' => 0, 'includeAllDescendents' => 0, 'includeDate' => 0, 'truncateSummaries' => 0, 'displayFeaturedOnly' => 0, 'topicFilter' => '', 'displayThumbnail' => 0, 'displayAliases' => 0, 'truncateChars' => 0, 'paginate' => 0, 'rss' => 0, 'pfID' => 0);
     $args['num'] = $args['num'] > 0 ? $args['num'] : 0;
     $args['cThis'] = $args['cParentID'] == $this->cID ? '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\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->GetOne('select count(pfID) from btPageList where pfID = ?', array($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;
     }
     $args['pfID'] = intval($args['pfID']);
     parent::save($args);
 }
 public static function replacePageFeedWithPlaceholder($pfID)
 {
     if ($pfID > 0) {
         $pf = Feed::getByID($pfID);
         return '{ccm:export:pagefeed:' . $pf->getHandle() . '}';
     }
 }
 public function execute(Batch $batch)
 {
     $inspector = \Core::make('import/value_inspector');
     $feeds = $batch->getObjectCollection('page_feed');
     if (!$feeds) {
         return;
     }
     foreach ($feeds->getFeeds() as $feed) {
         if (!$feed->getPublisherValidator()->skipItem()) {
             $f = new Feed();
             $parentID = intval($inspector->inspect($feed->getParent())->getReplacedValue());
             $pageType = intval($inspector->inspect($feed->getPageType())->getReplacedValue());
             $f->setTitle($feed->getTitle());
             $f->setHandle($feed->getHandle());
             $f->setDescription($feed->getDescription());
             $f->setParentID($parentID);
             $f->setPageTypeID($pageType);
             $f->setIncludeAllDescendents($feed->getIncludeAllDescendants());
             $f->setDisplayFeaturedOnly($feed->getDisplayFeaturedOnly());
             $f->setDisplayAliases($feed->getDisplayAliases());
             if ($feed->getContentType() == 'description') {
                 $f->displayShortDescriptionContent();
             } else {
                 $f->displayAreaContent($feed->getContentTypeArea());
             }
             $f->save();
         }
     }
 }
Exemple #7
0
 public static function getValue($value)
 {
     if (preg_match('/\\{ccm:export:page:(.*?)\\}|' . '\\{ccm:export:file:(.*?)\\}|' . '\\{ccm:export:image:(.*?)\\}|' . '\\{ccm:export:pagetype:(.*?)\\}|' . '\\{ccm:export:pagefeed:(.*?)\\}/i', $value, $matches)) {
         if (isset($matches[1]) && $matches[1]) {
             $c = Page::getByPath($matches[1]);
             return $c->getCollectionID();
         }
         if (isset($matches[2]) && $matches[2]) {
             $db = Database::connection();
             $fID = $db->GetOne('select fID from FileVersions where fvFilename = ?', array($matches[2]));
             return $fID;
         }
         if (isset($matches[3]) && $matches[3]) {
             $db = Database::connection();
             $fID = $db->GetOne('select fID from FileVersions where fvFilename = ?', array($matches[3]));
             return $fID;
         }
         if (isset($matches[4]) && $matches[4]) {
             $ct = PageType::getByHandle($matches[4]);
             return $ct->getPageTypeID();
         }
         if (isset($matches[5]) && $matches[5]) {
             $pf = Feed::getByHandle($matches[5]);
             return $pf->getID();
         }
     } else {
         return $value;
     }
 }
 /**
  * {@inheritDoc}
  */
 public function getOutput($request = NULL)
 {
     $this->__initializer__ && $this->__initializer__->__invoke($this, 'getOutput', array($request));
     return parent::getOutput($request);
 }
Exemple #9
0
 public function edit($pfID = null)
 {
     if (Core::make("helper/validation/numbers")->integer($pfID)) {
         if ($pfID > 0) {
             $feed = Feed::getByID($pfID);
         }
     }
     if (!is_object($feed)) {
         $this->redirect('/dashboard/pages/feeds');
     }
     $this->feed = $feed;
     $this->set('feed', $feed);
     $this->add();
 }
 /**
  * {@inheritDoc}
  */
 public function getOutput()
 {
     $this->__initializer__ && $this->__initializer__->__invoke($this, 'getOutput', array());
     return parent::getOutput();
 }
Exemple #11
0
 public function getContentObject()
 {
     return Feed::getByHandle($this->getReference());
 }
 public function skipItem()
 {
     $feed = Feed::getByHandle($this->object->getHandle());
     return is_object($feed);
 }