public function import(\SimpleXMLElement $sx)
 {
     $siteTree = null;
     if (isset($this->home)) {
         $siteTree = $this->home->getSiteTreeObject();
     }
     if (isset($sx->pages)) {
         foreach ($sx->pages->page as $px) {
             if ($px['path'] != '') {
                 $page = Page::getByPath($px['path'], 'RECENT', $siteTree);
             } else {
                 if (isset($this->home)) {
                     $page = $this->home;
                 } else {
                     $page = Page::getByID(HOME_CID, 'RECENT');
                 }
             }
             if (isset($px->area)) {
                 $this->importPageAreas($page, $px);
             }
             if (isset($px->attributes)) {
                 foreach ($px->attributes->children() as $attr) {
                     $handle = (string) $attr['handle'];
                     $ak = CollectionKey::getByHandle($handle);
                     if (is_object($ak)) {
                         $value = $ak->getController()->importValue($attr);
                         $page->setAttribute($handle, $value);
                     }
                 }
             }
             $page->reindex();
         }
     }
 }
Example #2
0
 public function getContentObject()
 {
     if ($this->getReference() == '/' || $this->getReference() == '') {
         return Page::getByID(HOME_CID, 'ACTIVE');
     }
     $c = Page::getByPath($this->getReference(), 'ACTIVE');
     if (is_object($c) && !$c->isError()) {
         return $c;
     }
 }
 public function export($cxml)
 {
     $target = parent::export($cxml);
     if ($this->getStartingPointPageID()) {
         $c = Page::getByID($this->getStartingPointPageID(), 'ACTIVE');
         if (is_object($c) && !$c->isError()) {
             $target->addAttribute('path', $c->getCollectionPath());
         }
     }
     $target->addAttribute('form-factor', $this->getSelectorFormFactor());
 }
Example #4
0
 public function getCommentsByParentIDs($IDs)
 {
     $db = Loader::db();
     $child_pages = array();
     $blogList = new PageList();
     $blogList->sortBy('cDateAdded', 'desc');
     //$blogList->filter(false,"(CHAR_LENGTH(cv.cvName) > 4 OR cv.cvName NOT REGEXP '^[0-9]')");
     $blogList->filter(false, "ak_is_canonical_page < 1");
     if (!$IDs) {
         $r = $db->EXECUTE("SELECT DISTINCT cnv.cID FROM ConversationMessages cnvm LEFT JOIN Conversations cnv ON cnvm.cnvID = cnv.cnvID ORDER BY cnvMessageDateCreated DESC");
         while ($row = $r->fetchrow()) {
             $IDs[] = $row['cID'];
         }
     }
     if (is_array($IDs)) {
         foreach ($IDs as $id) {
             if ($fs) {
                 $fs .= ' OR ';
             }
             $path = Page::getByID($id)->getCollectionPath() . '/';
             $fs .= "pp.cPath LIKE '{$path}%'";
         }
         $blogList->filter(false, "({$fs})");
     }
     //$blogList->filter(false,"(CHAR_LENGTH(cv.cvName) > 4 OR cv.cvName NOT REGEXP '^[0-9]')");
     $blogList->filter(false, "ak_is_canonical_page < 1");
     $blogResults = $blogList->get();
     foreach ($blogResults as $result) {
         $child_pages[] = $result->getCollectionID();
     }
     $filter = '';
     if ($this->request('comment_todo')) {
         $this->set('comment_todo', $this->request('comment_todo'));
         switch ($this->request('comment_todo')) {
             case 'approves':
                 $filter = "WHERE cnvm.cnvIsMessageApproved = 1";
                 break;
             case 'unapproves':
                 $filter = "WHERE cnvm.cnvIsMessageDeleted = 1";
                 break;
         }
     }
     $r = $db->EXECUTE("SELECT * FROM ConversationMessages cnvm LEFT JOIN Conversations cnv ON cnvm.cnvID = cnv.cnvID {$filter} ORDER BY cnvMessageDateCreated DESC");
     $comments = array();
     while ($row = $r->fetchrow()) {
         $ccObj = Page::getByID($row['cID']);
         $pID = $ccObj->getCollectionID();
         //var_dump($pID.' - '.print_r($child_pages));
         if (in_array($pID, $child_pages)) {
             $comments[] = $row;
         }
     }
     return $comments;
 }
 public function saveForm(Page $c)
 {
     $controls = Control::getList($this->type);
     $outputControls = array();
     foreach ($controls as $cn) {
         $data = $cn->getRequestValue();
         $cn->publishToPage($c, $data, $controls);
         $outputControls[] = $cn;
     }
     // set page name from controls
     // now we see if there's a page name field in there
     $containsPageNameControl = false;
     foreach ($outputControls as $cn) {
         if ($cn instanceof NameCorePageProperty) {
             $containsPageNameControl = true;
             break;
         }
     }
     if (!$containsPageNameControl) {
         foreach ($outputControls as $cn) {
             if ($cn->canPageTypeComposerControlSetPageName()) {
                 $pageName = $cn->getPageTypeComposerControlPageNameValue($c);
                 $c->updateCollectionName($pageName);
             }
         }
     }
     // remove all but the most recent X drafts.
     if ($c->isPageDraft()) {
         $vl = new VersionList($c);
         $vl->setItemsPerPage(-1);
         // this will ensure that we only ever keep X versions.
         $vArray = $vl->getPage();
         if (count($vArray) > $this->ptDraftVersionsToSave) {
             for ($i = $this->ptDraftVersionsToSave; $i < count($vArray); ++$i) {
                 $v = $vArray[$i];
                 @$v->delete();
             }
         }
     }
     $c = Page::getByID($c->getCollectionID(), 'RECENT');
     $controls = array();
     foreach ($outputControls as $oc) {
         $oc->setPageObject($c);
         $controls[] = $oc;
     }
     $ev = new Event($c);
     $ev->setPageType($this->type);
     $ev->setArgument('controls', $controls);
     \Events::dispatch('on_page_type_save_composer_form', $ev);
     return $controls;
 }
 public function execute(ActionInterface $action)
 {
     $target = $action->getTarget();
     $subject = $action->getSubject();
     \Cache::disableAll();
     $c = Page::getByID($subject['cID']);
     $db = \Database::connection();
     if (is_object($c) && !$c->isError()) {
         $blocks = $c->getBlocks();
         $nvc = $c->getVersionToModify();
         $isApproved = $c->getVersionObject()->isApproved();
         foreach ($blocks as $b) {
             $controller = $b->getController();
             $pageColumns = $controller->getBlockTypeExportPageColumns();
             if (count($pageColumns)) {
                 $columns = $db->MetaColumnNames($controller->getBlockTypeDatabaseTable());
                 $data = array();
                 $record = $controller->getBlockControllerData();
                 foreach ($columns as $key) {
                     $data[$key] = $record->{$key};
                 }
                 foreach ($pageColumns as $column) {
                     $cID = $data[$column];
                     if ($cID > 0) {
                         $link = Page::getByID($cID, 'ACTIVE');
                         $section = $target->getSection();
                         if (is_object($section)) {
                             $relatedID = $section->getTranslatedPageID($link);
                             if ($relatedID) {
                                 $data[$column] = $relatedID;
                             }
                         }
                     }
                 }
                 unset($data['bID']);
                 $ob = $b;
                 // replace the block with the version of the block in the later version (if applicable)
                 $b2 = \Block::getByID($b->getBlockID(), $nvc, $b->getAreaHandle());
                 if ($b2->isAlias()) {
                     $nb = $ob->duplicate($nvc);
                     $b2->deleteBlock();
                     $b2 = clone $nb;
                 }
                 $b2->update($data);
             }
         }
         if ($isApproved) {
             $nvc->getVersionObject()->approve();
         }
     }
 }
 /**
  * Removes any existing pages, files, stacks, block and page types and installs content from the package.
  *
  * @param $options
  */
 public function swapContent(Package $package, $options)
 {
     if ($this->validateClearSiteContents($options)) {
         \Core::make('cache/request')->disable();
         $pl = new PageList();
         $pages = $pl->getResults();
         foreach ($pages as $c) {
             $c->delete();
         }
         $fl = new FileList();
         $files = $fl->getResults();
         foreach ($files as $f) {
             $f->delete();
         }
         // clear stacks
         $sl = new StackList();
         foreach ($sl->get() as $c) {
             $c->delete();
         }
         $home = \Page::getByID(HOME_CID);
         $blocks = $home->getBlocks();
         foreach ($blocks as $b) {
             $b->deleteBlock();
         }
         $pageTypes = Type::getList();
         foreach ($pageTypes as $ct) {
             $ct->delete();
         }
         // Set the page type of the home page to 0, because
         // if it has a type the type will be gone since we just
         // deleted it
         $home = Page::getByID(HOME_CID);
         $home->setPageType(null);
         // now we add in any files that this package has
         if (is_dir($package->getPackagePath() . '/content_files')) {
             $ch = new ContentImporter();
             $computeThumbnails = true;
             if ($package->contentProvidesFileThumbnails()) {
                 $computeThumbnails = false;
             }
             $ch->importFiles($package->getPackagePath() . '/content_files', $computeThumbnails);
         }
         // now we parse the content.xml if it exists.
         $ci = new ContentImporter();
         $ci->importContentFile($package->getPackagePath() . '/content.xml');
         \Core::make('cache/request')->enable();
     }
 }
Example #8
0
 public function get($itemsToGet = 0, $offset = 0)
 {
     $_pages = DatabaseItemList::get($itemsToGet, $offset);
     $pages = array();
     foreach ($_pages as $row) {
         $c = ConcretePage::getByID($row['cID']);
         $cp = new Permissions($c);
         if ($cp->canViewPageVersions()) {
             $c->loadVersionObject('RECENT');
         } else {
             $c->loadVersionObject('ACTIVE');
         }
         $wp = PageWorkflowProgress::getByID($row['wpID']);
         $pages[] = new Page($c, $wp);
     }
     return $pages;
 }
 public function importPageAreas(Page $page, \SimpleXMLElement $px)
 {
     foreach ($px->area as $ax) {
         if (isset($ax->blocks)) {
             foreach ($ax->blocks->block as $bx) {
                 if ($bx['type'] != '') {
                     // we check this because you might just get a block node with only an mc-block-id, if it's an alias
                     $bt = BlockType::getByHandle((string) $bx['type']);
                     if (!is_object($bt)) {
                         throw new \Exception(t('Invalid block type handle: %s', strval($bx['type'])));
                     }
                     $btc = $bt->getController();
                     $btc->import($page, (string) $ax['name'], $bx);
                 } else {
                     if ($bx['mc-block-id'] != '') {
                         // we find that block in the master collection block pool and alias it out
                         $bID = array_search((string) $bx['mc-block-id'], ContentImporter::getMasterCollectionTemporaryBlockIDs());
                         if ($bID) {
                             $mc = Page::getByID($page->getMasterCollectionID(), 'RECENT');
                             $block = Block::getByID($bID, $mc, (string) $ax['name']);
                             $block->alias($page);
                             if ($block->getBlockTypeHandle() == BLOCK_HANDLE_LAYOUT_PROXY) {
                                 // we have to go get the blocks on that page in this layout.
                                 $btc = $block->getController();
                                 $arLayout = $btc->getAreaLayoutObject();
                                 $columns = $arLayout->getAreaLayoutColumns();
                                 foreach ($columns as $column) {
                                     $area = $column->getAreaObject();
                                     $blocks = $area->getAreaBlocksArray($mc);
                                     foreach ($blocks as $_b) {
                                         $_b->alias($page);
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
         if (isset($ax->style)) {
             $area = \Area::get($page, (string) $ax['name']);
             $set = StyleSet::import($ax->style);
             $page->setCustomStyleSet($area, $set);
         }
     }
 }
 public function execute(ActionInterface $action)
 {
     $target = $action->getTarget();
     $subject = $action->getSubject();
     \Cache::disableAll();
     $c = Page::getByID($subject['cID']);
     if (is_object($c) && !$c->isError()) {
         $blocks = $c->getBlocks();
         $nvc = $c->getVersionToModify();
         $isApproved = $c->getVersionObject()->isApproved();
         foreach ($blocks as $b) {
             if ($b->getBlockTypeHandle() == 'content') {
                 $content = $b->getController()->content;
                 $content = preg_replace_callback('/{CCM:CID_([0-9]+)}/i', function ($matches) use($subject, $target) {
                     $cID = $matches[1];
                     if ($cID > 0) {
                         $link = Page::getByID($cID, 'ACTIVE');
                         $section = $target->getSection();
                         if (is_object($section)) {
                             $relatedID = $section->getTranslatedPageID($link);
                             if ($relatedID) {
                                 return sprintf('{CCM:CID_%s}', $relatedID);
                             }
                         }
                     }
                 }, $content);
                 $ob = $b;
                 // replace the block with the version of the block in the later version (if applicable)
                 $b2 = \Block::getByID($b->getBlockID(), $nvc, $b->getAreaHandle());
                 if ($b2->isAlias()) {
                     $nb = $ob->duplicate($nvc);
                     $b2->deleteBlock();
                     $b2 = clone $nb;
                 }
                 $data = array('content' => $content);
                 $b2->update($data);
             }
         }
         if ($isApproved) {
             $nvc->getVersionObject()->approve();
         }
     }
 }
Example #11
0
 public function getJSONObject()
 {
     $o = parent::getBaseJSONObject();
     if ($this->cID > 0) {
         $o->cID = $this->cID;
     } else {
         if (count($this->cIDs) > 0) {
             foreach ($this->cIDs as $cID) {
                 $o->cID[] = $cID;
             }
         }
     }
     if (!is_array($o->cID)) {
         $o->pages[] = Page::getByID($o->cID)->getJSONObject();
     } else {
         foreach ($o->cID as $cID) {
             $o->pages[] = Page::getByID($cID)->getJSONObject();
         }
     }
     return $o;
 }
 protected function installLocales()
 {
     $this->output(t('Updating locales and multilingual sections...'));
     // Update home page so it has no handle. This way we won't make links like /home/services unless
     // people really want that.
     $home = Page::getByID(HOME_CID, 'RECENT');
     $home->update(['cHandle' => '']);
     // Loop through all multilingual sections
     $r = $this->connection->executeQuery('select * from MultilingualSections');
     $sections = array();
     while ($row = $r->fetch()) {
         $sections[] = $row;
     }
     $em = $this->connection->getEntityManager();
     $service = new \Concrete\Core\Localization\Locale\Service($em);
     $site = \Core::make('site')->getSite();
     $redirectToDefaultLocale = \Config::get('concrete.multilingual.redirect_home_to_default_locale');
     $defaultLocale = \Config::get('concrete.multilingual.default_locale');
     $sectionsIncludeHome = false;
     foreach ($sections as $section) {
         if ($section['cID'] == 1) {
             $sectionsIncludeHome = true;
         }
     }
     // Now we have a valid locale object.
     // Case 1: Home Page redirects to default locale, default locale inside the home page. 99% of sites.
     if (!$sectionsIncludeHome && $redirectToDefaultLocale) {
         // Move the home page outside site trees.
         $this->output(t('Moving home page to outside of site trees...'));
         $this->connection->executeQuery('update Pages set siteTreeID = 0 where cID = 1');
     }
     foreach ($sections as $section) {
         $sectionPage = \Page::getByID($section['cID']);
         $this->output(t('Migrating multilingual section: %s...', $sectionPage->getCollectionName()));
         // Create a locale for this section
         if ($site->getDefaultLocale()->getLocale() != $section['msLanguage'] . '_' . $section['msCountry']) {
             // We don't create the locale if it's the default, because we've already created it.
             $locale = $service->add($site, $section['msLanguage'], $section['msCountry']);
         } else {
             $locale = $em->getRepository('Concrete\\Core\\Entity\\Site\\Locale')->findOneBy(['msLanguage' => $section['msLanguage'], 'msCountry' => $section['msCountry']]);
         }
         // Now that we have the locale, let's take the multilingual section and make it the
         // home page for the newly created site tree
         if ($section['cID'] != 1) {
             $tree = $locale->getSiteTree();
             if (!$redirectToDefaultLocale && $locale->getLocale() == $site->getDefaultLocale()->getLocale()) {
                 // Case 2: This is our default locale (/en perhaps) but it is contained within a home
                 // page that we do not redirect from. So we want to actually make the HOME page
                 // the multilingual section – which is already is automatically.
                 // We actually do nothing in this case since this is all already set up automatically earlier.
             } else {
                 $this->output(t('Setting pages for section %s to site tree %s...', $sectionPage->getCollectionName(), $tree->getSiteTreeID()));
                 $tree->setSiteHomePageID($section['cID']);
                 $em->persist($tree);
                 $em->flush();
                 $this->connection->executeQuery('update Pages set cParentID = 0, siteTreeID = ? where cID = ?', [$tree->getSiteTreeID(), $section['cID']]);
                 // Now we set all pages in this site tree to the new site tree ID.
                 $children = $sectionPage->getCollectionChildrenArray();
                 foreach ($children as $cID) {
                     $this->connection->executeQuery('update Pages set siteTreeID = ? where cID = ?', [$tree->getSiteTreeID(), $cID]);
                 }
             }
         }
     }
     // Case 3 - Home page is the default locale.
     // We don't have to do anything to fulfill this since it's already been taken care of by the previous migrations.
 }
Example #13
0
 /**
  * For a particular page ID, grabs all the pages of this page, and decrements the cTotalChildren number for them.
  */
 public static function decrementParents($cID)
 {
     $db = Loader::db();
     $cParentID = $db->GetOne("select cParentID from Pages where cID = ?", array($cID));
     $cChildren = $db->GetOne("select cChildren from Pages where cID = ?", array($cParentID));
     --$cChildren;
     if ($cChildren < 0) {
         $cChildren = 0;
     }
     $q = "update Pages set cChildren = ? where cID = ?";
     $cpc = Page::getByID($cParentID);
     $cpc->refreshCache();
     $r = $db->query($q, array($cChildren, $cParentID));
 }
 private function collectionNotFound(Collection $collection, Request $request, array $headers)
 {
     // if we don't have a path and we're doing cID, then this automatically fires a 404.
     if (!$request->getPath() && $request->get('cID')) {
         return $this->notFound('', Response::HTTP_NOT_FOUND, $headers);
     }
     // let's test to see if this is, in fact, the home page,
     // and we're routing arguments onto it (which is screwing up the path.)
     $home = Page::getByID(HOME_CID);
     $request->setCurrentPage($home);
     $homeController = $home->getPageController();
     $homeController->setupRequestActionAndParameters($request);
     $response = $homeController->validateRequest();
     if ($response instanceof \Symfony\Component\HttpFoundation\Response) {
         return $response;
     } elseif ($response === true) {
         return $this->controller($homeController);
     } else {
         return $this->notFound('', Response::HTTP_NOT_FOUND, $headers);
     }
 }
Example #15
0
 /**
  * @param Section $section
  *
  * @return self
  */
 public function addLocalizedStack(Section $section)
 {
     $neutralStack = $this->getNeutralStack();
     if ($neutralStack === null) {
         $neutralStack = $this;
     }
     $name = $neutralStack->getCollectionName();
     $neutralStackPage = Page::getByID($neutralStack->getCollectionID());
     $localizedStackPage = $neutralStackPage->duplicate($neutralStackPage);
     $localizedStackPage->update(['cName' => $name]);
     $siteTreeID = $neutralStack->getSiteTreeID();
     // we have to do this because we need the area to exist before we try and add something to it.
     Area::getOrCreate($localizedStackPage, STACKS_AREA_NAME);
     $localizedStackCID = $localizedStackPage->getCollectionID();
     $db = Database::connection();
     $db->executeQuery('
         insert into Stacks (stName, cID, stType, stMultilingualSection, siteTreeID) values (?, ?, ?, ?, ?)', [$name, $localizedStackCID, $this->getStackType(), $section->getCollectionID(), $siteTreeID]);
     $localizedStack = static::getByID($localizedStackCID);
     return $localizedStack;
 }
Example #16
0
 public function unloadCollectionEdit($removeCache = true)
 {
     $app = Application::getFacadeApplication();
     $db = $app['database']->connection();
     if ($this->getUserID() > 0) {
         $col = $db->GetCol('select cID from Pages where cCheckedOutUID = ?', array($this->getUserID()));
         foreach ($col as $cID) {
             $p = Page::getByID($cID);
             if ($removeCache) {
                 $p->refreshCache();
             }
         }
         $q = "update Pages set cIsCheckedOut = 0, cCheckedOutUID = null, cCheckedOutDatetime = null, cCheckedOutDatetimeLastEdit = null where cCheckedOutUID = ?";
         $db->query($q, array($this->getUserID()));
     }
 }
Example #17
0
 /**
  * @param string $language
  * @return Section|false
  */
 public static function getByLocale($locale)
 {
     $locale = explode('_', $locale);
     $db = Database::get();
     $r = $db->GetRow('select cID, msLanguage, msCountry, msNumPlurals, msPluralRule, msPluralCases from MultilingualSections where msLanguage = ? and msCountry = ?', array($locale[0], $locale[1]));
     if ($r && is_array($r) && $r['msLanguage']) {
         $obj = parent::getByID($r['cID'], 'RECENT', '\\Concrete\\Core\\Multilingual\\Page\\Section\\Section');
         self::assignPropertiesFromArray($obj, $r);
         return $obj;
     }
     return false;
 }
Example #18
0
 /**
  * @return Controller
  */
 function assignPageTypes()
 {
     Loader::db()->Execute('UPDATE Pages set pkgID = ? WHERE cID = 1', array((int) $this->packageObject()->getPackageID()));
     // Things available through the API
     $homePageCollection = \Concrete\Core\Page\Page::getByID(1)->getVersionToModify();
     $homePageCollection->update(array('pTemplateID' => PageTemplate::getByHandle('home')->getPageTemplateID()));
     $homePageCollection->setPageType(PageType::getByHandle('page'));
     return $this;
 }
Example #19
0
 public function deletethis($cIDd, $name = null)
 {
     $c = Page::getByID($cIDd);
     $c->delete();
     $this->set('message', t('"%s" has been deleted', $name));
     $this->set('remove_name', '');
     $this->set('remove_cid', '');
     $this->view();
 }
Example #20
0
 public function addStatic($data)
 {
     $db = Database::get();
     $cParentID = $this->getCollectionID();
     if (isset($data['pkgID'])) {
         $pkgID = $data['pkgID'];
     } else {
         $pkgID = 0;
     }
     $cFilename = $data['filename'];
     $uID = USER_SUPER_ID;
     $data['uID'] = $uID;
     $cIsSystemPage = 0;
     $cobj = parent::addCollection($data);
     $cID = $cobj->getCollectionID();
     $this->rescanChildrenDisplayOrder();
     $cDisplayOrder = $this->getNextSubPageDisplayOrder();
     // These get set to parent by default here, but they can be overridden later
     $cInheritPermissionsFromCID = $this->getPermissionsCollectionID();
     $cInheritPermissionsFrom = 'PARENT';
     $v = array($cID, $cFilename, $cParentID, $cInheritPermissionsFrom, $this->overrideTemplatePermissions(), $cInheritPermissionsFromCID, $cDisplayOrder, $cIsSystemPage, $uID, $pkgID);
     $q = 'insert into Pages (cID, cFilename, cParentID, cInheritPermissionsFrom, cOverrideTemplatePermissions, cInheritPermissionsFromCID, cDisplayOrder, cIsSystemPage, uID, pkgID) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)';
     $r = $db->prepare($q);
     $res = $db->execute($r, $v);
     if ($res) {
         // Collection added with no problem -- update cChildren on parrent
         PageStatistics::incrementParents($cID);
     }
     $pc = Page::getByID($cID);
     $pc->rescanCollectionPath();
     return $pc;
 }
Example #21
0
?>
</td>
            <td><?php 
echo t('Handle');
?>
</td>
            <td><?php 
echo t('Location');
?>
</td>
        </tr>
        </thead>
        <?php 
/** @var \Concrete\Core\Entity\Statistics\UsageTracker\FileUsageRecord */
foreach ($records as $record) {
    $page = \Concrete\Core\Page\Page::getByID($record->getCollectionID());
    ?>
            <tr>
                <td><?php 
    echo $page->getCollectionID();
    ?>
</td>
                <td><?php 
    echo $page->getVersionID();
    ?>
</td>
                <td><?php 
    echo $page->getCollectionHandle();
    ?>
</td>
                <td><a target="_blank" href="<?php 
Example #22
0
 /**
  * @param Page $page
  *
  * @return Section
  */
 public static function getBySectionOfSite($page)
 {
     $identifier = sprintf('/multilingual/section/%s', $page->getCollectionID());
     $cache = \Core::make('cache/request');
     $item = $cache->getItem($identifier);
     if (!$item->isMiss()) {
         $returnID = $item->get();
     } else {
         $item->lock();
         if ($page->getPageTypeHandle() == STACKS_PAGE_TYPE) {
             $parent = Page::getByID($page->getCollectionParentID());
             if ($parent->getCollectionPath() == STACKS_PAGE_PATH) {
                 // this is the default multilingual section.
                 return static::getDefaultSection();
             } else {
                 // this is a stack category page type
                 $locale = $parent->getCollectionHandle();
                 return static::getByLocale($locale);
             }
         }
         // looks at the page, traverses its parents until it finds the proper language
         $nav = \Core::make('helper/navigation');
         $pages = $nav->getTrailToCollection($page);
         $pages = array_reverse($pages);
         $pages[] = $page;
         $ids = self::getIDList();
         $returnID = false;
         foreach ($pages as $pc) {
             if (in_array($pc->getCollectionID(), $ids)) {
                 $returnID = $pc->getCollectionID();
             }
         }
         $item->set($returnID);
     }
     if ($returnID) {
         return static::getByID($returnID);
     }
 }
Example #23
0
 public function getOutput($request = null)
 {
     $pl = $this->getPageListObject();
     if ($this->cParentID) {
         $parent = Page::getByID($this->cParentID);
         $link = $parent->getCollectionLink();
     }
     $pagination = $pl->getPagination();
     if ($pagination->getTotalResults() > 0) {
         $writer = new \Zend\Feed\Writer\Feed();
         $writer->setTitle($this->getTitle());
         $writer->setDescription($this->getDescription());
         $writer->setLink((string) $link);
         foreach ($pagination->getCurrentPageResults() as $p) {
             $entry = $writer->createEntry();
             $entry->setTitle($p->getCollectionName());
             $entry->setDateCreated(strtotime($p->getCollectionDatePublic()));
             $content = $this->getPageFeedContent($p);
             if (!$content) {
                 $content = t('No Content.');
             }
             $entry->setDescription($content);
             $entry->setLink((string) $p->getCollectionLink(true));
             $writer->addEntry($entry);
         }
         $ev = new FeedEvent($parent);
         $ev->setFeedObject($this);
         $ev->setWriterObject($writer);
         $ev->setRequest($request);
         $ev = \Events::dispatch('on_page_feed_output', $ev);
         $writer = $ev->getWriterObject();
         return $writer->export('rss');
     }
 }
Example #24
0
 public function getPermissionObject()
 {
     return \Concrete\Core\Page\Page::getByID(HOME_CID);
 }
Example #25
0
 /**
  * @return string
  */
 public function getLinkURL()
 {
     $linkUrl = '';
     if (!empty($this->externalLink)) {
         $sec = $this->app->make('helper/security');
         $linkUrl = $sec->sanitizeURL($this->externalLink);
     } elseif (!empty($this->internalLinkCID)) {
         $linkToC = Page::getByID($this->internalLinkCID);
         if (is_object($linkToC) && !$linkToC->isError()) {
             $linkUrl = $linkToC->getCollectionLink();
         }
     }
     return $linkUrl;
 }
Example #26
0
 public function getOutput()
 {
     $pl = $this->getPageListObject();
     $link = BASE_URL;
     if ($this->cParentID) {
         $parent = Page::getByID($this->cParentID);
         $link = $parent->getCollectionLink(true);
     }
     $pagination = $pl->getPagination();
     if ($pagination->getTotalResults() > 0) {
         $writer = new \Zend\Feed\Writer\Feed();
         $writer->setTitle($this->getTitle());
         $writer->setDescription($this->getDescription());
         $writer->setLink($link);
         foreach ($pagination->getCurrentPageResults() as $p) {
             $entry = $writer->createEntry();
             $entry->setTitle($p->getCollectionName());
             $entry->setDateCreated(strtotime($p->getCollectionDatePublic()));
             $content = $this->getPageFeedContent($p);
             if (!$content) {
                 $content = t('No Content.');
             }
             $entry->setDescription($content);
             $entry->setLink($p->getCollectionLink(true));
             $writer->addEntry($entry);
         }
         return $writer->export('rss');
     }
 }
Example #27
0
 /**
  * @param $queryRow
  *
  * @return \Concrete\Core\File\File
  */
 public function getResult($queryRow)
 {
     $c = ConcretePage::getByID($queryRow['cID'], 'ACTIVE');
     if (is_object($c) && $this->checkPermissions($c)) {
         if ($this->pageVersionToRetrieve == self::PAGE_VERSION_RECENT) {
             $cp = new \Permissions($c);
             if ($cp->canViewPageVersions() || $this->permissionsChecker === -1) {
                 $c->loadVersionObject('RECENT');
             }
         }
         if (isset($queryRow['cIndexScore'])) {
             $c->setPageIndexScore($queryRow['cIndexScore']);
         }
         return $c;
     }
 }
Example #28
0
 public function getDisplaySanitizedValue()
 {
     if (is_object($this->attributeValue)) {
         return \Concrete\Core\Page\Page::getByID($this->getValue())->getCollectionName();
     }
 }
Example #29
0
 /**
  * @param string $language
  *
  * @return Section|false
  */
 public static function getByLocale($locale, Site $site = null)
 {
     if (!$site) {
         $site = \Core::make('site')->getSite();
     }
     if ($locale) {
         if (!is_object($locale)) {
             $locale = explode('_', $locale);
             if (!isset($locale[1])) {
                 $locale[1] = '';
             }
             $em = Database::get()->getEntityManager();
             $locale = $em->getRepository('Concrete\\Core\\Entity\\Site\\Locale')->findOneBy(['site' => $site, 'msLanguage' => $locale[0], 'msCountry' => $locale[1]]);
         }
         if (is_object($locale)) {
             $obj = parent::getByID($locale->getSiteTree()->getSiteHomePageID(), 'RECENT');
             $obj->setLocale($locale);
             return $obj;
         }
     }
     return false;
 }
Example #30
0
 public static function getList()
 {
     $db = Loader::db();
     $r = $db->query("select Pages.cID from Pages inner join Collections on Pages.cID = Collections.cID where cFilename is not null order by cDateModified desc");
     $pages = array();
     while ($row = $r->fetchRow()) {
         $c = Page::getByID($row['cID']);
         $pages[] = $c;
     }
     return $pages;
 }