public function publish(CollectionKey $ak, Page $page, AttributeValue $value)
 {
     $inspector = \Core::make('import/value_inspector');
     $result = $inspector->inspect($value->getValue());
     $content = $result->getReplacedContent();
     $page->setAttribute($ak->getAttributeKeyHandle(), $content);
 }
Example #2
0
 public function getCacheHeaders(Page $c)
 {
     $lifetime = $c->getCollectionFullPageCachingLifetimeValue();
     $expires = gmdate('D, d M Y H:i:s', time() + $lifetime) . ' GMT';
     $headers = array('Pragma' => 'public', 'Cache-Control' => 'max-age=' . $lifetime . ',s-maxage=' . $lifetime, 'Expires' => $expires);
     return $headers;
 }
Example #3
0
 public function getPublishButtonTitle(Page $c)
 {
     if ($c->isPageDraft()) {
         $publishTitle = t('Publish Page');
     } else {
         $publishTitle = t('Publish Changes');
     }
     $pk = Key::getByHandle('approve_page_versions');
     $pk->setPermissionObject($c);
     $pa = $pk->getPermissionAccessObject();
     $workflows = array();
     $canApproveWorkflow = true;
     if (is_object($pa)) {
         $workflows = $pa->getWorkflows();
     }
     foreach ($workflows as $wf) {
         if (!$wf->canApproveWorkflow()) {
             $canApproveWorkflow = false;
         }
     }
     if (count($workflows) > 0 && !$canApproveWorkflow) {
         $publishTitle = t('Submit to Workflow');
     }
     return $publishTitle;
 }
Example #4
0
 /**
  * Determines whether this nav item is the current page the user is on.
  *
  * @param \Concrete\Core\Page\Page $c The page object for the current page
  *
  * @return bool
  */
 public function isActive(&$c)
 {
     if ($c) {
         $cID = $c->getCollectionPointerID() > 0 ? $c->getCollectionPointerOriginalID() : $c->getCollectionID();
         return $cID == $this->cID;
     }
 }
 public function canPublishPageTypeBeneathTarget(Type $pagetype, \Concrete\Core\Page\Page $page)
 {
     if ($page->getAttribute('blog_section') > 0) {
         return true;
     } else {
         return false;
     }
 }
 public function publish(CollectionKey $ak, Page $page, AttributeValue $value)
 {
     $links = $value->getValue();
     $r = array();
     foreach ($links as $link) {
         $r[$link['service']] = $link['detail'];
     }
     $page->setAttribute($ak->getAttributeKeyHandle(), $r);
 }
 public function publish(CollectionKey $ak, Page $page, AttributeValue $value)
 {
     $inspector = \Core::make('import/value_inspector');
     $result = $inspector->inspect($value->getValue());
     $items = $result->getMatchedItems();
     if (isset($items[0]) && $items[0] instanceof FileItem) {
         $file = $items[0]->getContentObject();
         $page->setAttribute($ak->getAttributeKeyHandle(), $file);
     }
 }
Example #8
0
 public function getMenuItemClass(Page $page)
 {
     $classes = [];
     if (is_object($this->currentPage) && $page->getCollectionID() == $this->currentPage->getCollectionID()) {
         $classes[] = 'nav-selected';
     }
     if (in_array($page->getCollectionID(), $this->trail)) {
         $classes[] = 'nav-path-selected';
     }
     return implode($classes, ' ');
 }
 /**
  * @param CollectionKey $ak
  * @param Page $page
  * @param AddressAttributeValue $address
  */
 public function publish(CollectionKey $ak, Page $page, AttributeValue $address)
 {
     $value = new Value();
     $value->address1 = $address->getAddress1();
     $value->address2 = $address->getAddress2();
     $value->address3 = $address->getAddress3();
     $value->city = $address->getCity();
     $value->country = $address->getCountry();
     $value->state_province = $address->getStateProvince();
     $value->postal_code = $address->getPostalCode();
     $page->setAttribute($ak->getAttributeKeyHandle(), $value);
 }
 public function set(ConcretePage $c, $content)
 {
     if (!is_dir(Config::get('concrete.cache.page.directory'))) {
         @mkdir(Config::get('concrete.cache.page.directory'));
         @touch(Config::get('concrete.cache.page.directory') . '/index.html');
     }
     $lifetime = $c->getCollectionFullPageCachingLifetimeValue();
     $file = $this->getCacheFile($c);
     if ($file) {
         $response = new PageCacheRecord($c, $content, $lifetime);
         if ($content) {
             file_put_contents($file, serialize($response));
         }
     }
 }
 public function publishToPage(Page $c, $data, $controls)
 {
     array_push(self::$ptComposerRequestControlsProcessed, $this);
     // now we check to see if we have any more core controls to process in this request
     $coreControls = array();
     foreach ($controls as $cnt) {
         if ($cnt->getPageTypeComposerControlTypeHandle() == $this->ptComposerControlTypeHandle) {
             $coreControls[] = $controls;
         }
     }
     if (count(self::$ptComposerRequestControlsProcessed) == count($coreControls)) {
         // this was the last one. so we're going to loop through our saved request
         // and do the page update once, rather than four times.
         $c->update(self::$ptComposerSaveRequest);
     }
 }
 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 #13
0
 public static function setupSiteInterfaceLocalization(Page $c = null)
 {
     $loc = \Localization::getInstance();
     if (!(\User::isLoggedIn() && Config::get('concrete.multilingual.keep_users_locale'))) {
         if (!$c) {
             $c = Page::getCurrentPage();
         }
         // don't translate dashboard pages
         $dh = \Core::make('helper/concrete/dashboard');
         if ($dh->inDashboard($c)) {
             return;
         }
         $locale = null;
         $ms = Section::getBySectionOfSite($c);
         if ($ms) {
             $locale = $ms->getLocale();
         }
         if (!$locale) {
             if (Config::get('concrete.multilingual.use_previous_locale') && Session::has('previous_locale')) {
                 $locale = Session::get('previous_locale');
             }
             if (!$locale) {
                 $ms = static::getPreferredSection();
                 if ($ms) {
                     $locale = $ms->getLocale();
                 }
             }
         }
         if ($locale) {
             $loc->setLocale($locale);
         }
     }
     Session::set('previous_locale', $loc->getLocale());
 }
Example #14
0
 public static function setupSiteInterfaceLocalization(Page $c = null)
 {
     if (!$c) {
         $c = Page::getCurrentPage();
     }
     $app = Facade::getFacadeApplication();
     // don't translate dashboard pages
     $dh = $app->make('helper/concrete/dashboard');
     if ($dh->inDashboard($c)) {
         return;
     }
     $ms = Section::getBySectionOfSite($c);
     if (!is_object($ms)) {
         $ms = static::getPreferredSection();
     }
     if (!$ms) {
         return;
     }
     $locale = $ms->getLocale();
     if ($locale) {
         $app->make('session')->set('multilingual_default_locale', $locale);
         $loc = Localization::getInstance();
         $loc->setContextLocale('site', $locale);
     }
 }
 public function registerEvents()
 {
     $app = $this->app;
     $events = $this->app->make('director');
     // Add the sitemap icons listener
     $events->addListener('on_before_render', function ($event) use($app) {
         $c = Page::getCurrentPage();
         $view = $event->getArgument('view');
         $assets = $app->make('asset_pipeline/helper/assets');
         $theme = null;
         if (is_object($c)) {
             $theme = $c->getCollectionThemeObject();
         } else {
             $theme = Theme::getSiteTheme();
         }
         // TODO: If there are page-specific styles set, should we use
         //       this one instead:
         //$style = $c->getCustomStyleObject();
         $style = $theme->getThemeCustomStyleObject();
         if (is_object($style)) {
             $valueList = $style->getValueList();
             if ($valueList instanceof \Concrete\Core\StyleCustomizer\Style\ValueList) {
                 $variables = array();
                 foreach ($valueList->getValues() as $value) {
                     $variables = array_merge($value->toLessVariablesArray(), $variables);
                 }
                 $assets->setStylesheetVariables('theme', $variables);
             }
         }
         $view->addScopeItems(array('assets' => $assets));
     });
 }
Example #16
0
 public static function setupSiteInterfaceLocalization(Page $c = null)
 {
     if (\User::isLoggedIn() && Config::get('concrete.multilingual.keep_users_locale')) {
         return;
     }
     if (!$c) {
         $c = Page::getCurrentPage();
     }
     // don't translate dashboard pages
     $dh = \Core::make('helper/concrete/dashboard');
     if ($dh->inDashboard($c)) {
         return;
     }
     $ms = Section::getBySectionOfSite($c);
     if (!is_object($ms)) {
         $ms = static::getPreferredSection();
     }
     if (!$ms) {
         return;
     }
     $locale = $ms->getLocale();
     if (strlen($locale)) {
         \Localization::changeLocale($locale);
     }
 }
Example #17
0
 public function up(Schema $schema)
 {
     /** Add query log db table */
     try {
         $table = $schema->getTable('SystemDatabaseQueryLog');
     } catch (Exception $e) {
         $table = null;
     }
     if (!$table instanceof Table) {
         $ql = $schema->createTable('SystemDatabaseQueryLog');
         $ql->addColumn('query', 'text');
         $ql->addColumn('params', 'text', array('notnull' => false));
         $ql->addColumn('executionMS', 'string');
     }
     /** Add query log single pages */
     $sp = Page::getByPath('/dashboard/system/optimization/query_log');
     if (!is_object($sp) || $sp->isError()) {
         $sp = SinglePage::add('/dashboard/system/optimization/query_log');
         $sp->update(array('cName' => 'Database Query Log'));
         $sp->setAttribute('meta_keywords', 'queries, database, mysql');
     }
     /** Refresh image block */
     $bt = BlockType::getByHandle('image');
     if (is_object($bt)) {
         $bt->refresh();
     }
 }
 public function import(\SimpleXMLElement $sx)
 {
     $siteTree = null;
     if (isset($this->home)) {
         $siteTree = $this->home->getSiteTreeObject();
     }
     if (isset($sx->singlepages)) {
         foreach ($sx->singlepages->page as $px) {
             if ($px['custom-path']) {
                 $page = Page::getByPath((string) $px['custom-path'], 'RECENT', $siteTree);
             } else {
                 $page = Page::getByPath((string) $px['path'], 'RECENT', $siteTree);
             }
             if (isset($px->area)) {
                 $this->importPageAreas($page, $px);
             }
             if (isset($px->attributes)) {
                 foreach ($px->attributes->children() as $attr) {
                     $ak = CollectionKey::getByHandle($attr['handle']);
                     if (is_object($ak)) {
                         $page->setAttribute((string) $attr['handle'], $ak->getController()->importValue($attr));
                     }
                 }
             }
         }
     }
 }
 public function publish(Batch $batch, BlockType $bt, Page $page, Area $area, BlockValue $value)
 {
     $data = array();
     $data['slID'] = array();
     $records = $value->getRecords();
     foreach ($records as $record) {
         $value = $record->getData();
         $value = $value['service'];
         // because it comes out as an array
         $socialLink = Link::getByServiceHandle($value);
         if (is_object($socialLink)) {
             $data['slID'][] = $socialLink->getID();
         }
     }
     $b = $page->addBlock($bt, $area->getName(), $data);
     return $b;
 }
 public function up(Schema $schema)
 {
     $sp = Page::getByPath('/dashboard/system/multilingual/copy');
     if (!is_object($sp) || $sp->isError()) {
         $sp = \Concrete\Core\Page\Single::add('/dashboard/system/multilingual/copy');
         $sp->update(array('cName' => 'Copy Languages'));
     }
 }
Example #21
0
 public function getPermissionObject()
 {
     if (is_object($this->page)) {
         return $this->page;
     }
     $page = \Concrete\Core\Page\Page::getByPath($this->page);
     if (is_object($page) && !$page->isError()) {
         return $page;
     }
 }
 public function publishToPage(Page $c, $data, $controls)
 {
     if (!is_array($data)) {
         $data = [];
     }
     $data += ['name' => null];
     $slug = array_filter($controls, function ($item) {
         if ($item instanceof UrlSlugCorePageProperty) {
             return true;
         }
         return false;
     });
     $this->addPageTypeComposerControlRequestValue('cName', $data['name']);
     if (!count($slug) && $c->isPageDraft()) {
         $txt = new Text();
         $this->addPageTypeComposerControlRequestValue('cHandle', $txt->urlify($data['name'], \Config::get('concrete.seo.segment_max_length')));
     }
     parent::publishToPage($c, $data, $controls);
 }
Example #23
0
 public function getChildPages($parent)
 {
     $pages = array();
     if ($parent->getCollectionPath() == '/account') {
         // Add My Account to the List
         $pages[] = Page::getByPath('/account/welcome');
     }
     $pages = array_merge($pages, parent::getChildPages($parent));
     return $pages;
 }
 public function getPageThemeGridFrameworkSelectedDeviceHideClassesForDisplay(StyleSet $set, Page $page)
 {
     $classes = array();
     if (!$page->isEditMode()) {
         if ($set->getHideOnExtraSmallDevice()) {
             $classes[] = $this->getPageThemeGridFrameworkHideOnExtraSmallDeviceClass();
         }
         if ($set->getHideOnSmallDevice()) {
             $classes[] = $this->getPageThemeGridFrameworkHideOnSmallDeviceClass();
         }
         if ($set->getHideOnMediumDevice()) {
             $classes[] = $this->getPageThemeGridFrameworkHideOnMediumDeviceClass();
         }
         if ($set->getHideOnLargeDevice()) {
             $classes[] = $this->getPageThemeGridFrameworkHideOnLargeDeviceClass();
         }
     }
     return $classes;
 }
Example #25
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;
     }
 }
Example #26
0
 public function on_start()
 {
     Events::addListener('on_before_render', function () {
         $c = Page::getCurrentPage();
         if (is_object($c) && $c->isEditMode()) {
             $view = View::getInstance();
             $html = new Html();
             $view->addHeaderItem($html->css('area_hints.css', 'area_hints'));
         }
     });
 }
Example #27
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 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 #29
0
 public function addHomePage(Locale $locale, Template $template, $name, $url_slug = null)
 {
     $tree = $locale->getSiteTree();
     $home = Page::addHomePage($tree);
     $tree->setLocale($locale);
     $tree->setSiteHomePageID($home->getCollectionID());
     $this->entityManager->persist($tree);
     $this->entityManager->flush();
     $home->update(['cName' => $name, 'pTemplateID' => $template->getPageTemplateID(), 'cHandle' => $url_slug ? $url_slug : $locale->getLocale()]);
     $home->rescanCollectionPath();
     return $home;
 }
 public function publish(Batch $batch, BlockType $bt, Page $page, Area $area, BlockValue $value)
 {
     $routine = new PublishPageContentRoutine();
     $routine->setBatch($batch);
     /* @var $value AreaLayoutBlockValue */
     $layout = $value->getAreaLayout();
     $publisher = $layout->getPublisher();
     $layoutObject = $publisher->publish($layout);
     $columns = $layout->getColumns();
     $i = 0;
     $layoutBlock = $page->addBlock($bt, $area->getName(), array('arLayoutID' => $layoutObject->getAreaLayoutID()));
     foreach ($layoutObject->getAreaLayoutColumns() as $columnObject) {
         $column = $columns[$i];
         foreach ($column->getBlocks() as $block) {
             $subValue = $block->getBlockValue();
             $publisher = $subValue->getPublisher();
             $subarea = new Area();
             $subAreaName = $area->getName() . SubArea::AREA_SUB_DELIMITER . $columnObject->getAreaLayoutColumnDisplayID();
             $subarea->setName($subAreaName);
             /*
              * @var $publisher BlockPublisherInterface
              */
             $subBlockType = $routine->getTargetItem('block_type', $block->getType());
             if (is_object($subBlockType)) {
                 $b = $publisher->publish($batch, $subBlockType, $page, $subarea, $subValue);
                 $styleSet = $block->getStyleSet();
                 if (is_object($styleSet)) {
                     $styleSetPublisher = $styleSet->getPublisher();
                     $publishedStyleSet = $styleSetPublisher->publish();
                     $b->setCustomStyleSet($publishedStyleSet);
                 }
                 if ($block->getCustomTemplate()) {
                     $b->setCustomTemplate($block->getCustomTemplate());
                 }
             }
         }
         ++$i;
     }
     return $layoutBlock;
 }