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(); } } }
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 static function getByPath($path, $version = 'RECENT', TreeInterface $siteTree = null) { $c = parent::getByPath(STACKS_PAGE_PATH . '/' . trim($path, '/'), $version, $siteTree); if (static::isValidStack($c)) { return $c; } return false; }
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')); } }
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 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 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 getChildPages($parent) { $pages = parent::getChildPages($parent); if ($parent->getCollectionPath() == '/dashboard/welcome') { // Add My Account to the List $pages[] = Page::getByPath('/account'); $site = \Core::make("site")->getSite(); $config = $site->getConfigRepository(); if (is_object($site) && $config->get('user.profiles_enabled')) { $pages[] = Page::getByPath('/members/profile'); } } return $pages; }
/** * Given either a path or a Page object, this is a shortcut to * 1. Grab the controller of THAT page. * 2. Grab the view of THAT controller * 3. Render that view. * 4. Exit – so we immediately stop all other output in the controller that * called render(). * * @param @string|\Concrete\Core\Page\Page $var */ public function replace($var) { if ($var instanceof Page) { $page = $var; $path = $var->getCollectionPath(); } else { $path = (string) $var; $page = Page::getByPath($path); } $request = Request::getInstance(); $controller = $page->getPageController(); $request->setCurrentPage($page); if (is_callable([$controller, 'setCustomRequestPath'])) { $controller->setCustomRequestPath($path); } $this->replacement = $controller; }
public function up(Schema $schema) { /* delete customize page themes dashboard single page */ $customize = Page::getByPath('/dashboard/pages/themes/customize'); if (is_object($customize) && !$customize->isError()) { $customize->delete(); } /* Add inspect single page back if it's missing */ $sp = Page::getByPath('/dashboard/pages/themes/inspect'); if (!is_object($sp) || $sp->isError()) { $sp = SinglePage::add('/dashboard/pages/themes/inspect'); $sp->setAttribute('meta_keywords', 'inspect, templates'); $sp->setAttribute('exclude_nav', 1); } $sp = Page::getByPath('/members/directory'); if (!is_object($sp) || $sp->isError()) { $sp = SinglePage::add('/members/directory'); $sp->setAttribute('exclude_nav', 1); } $bt = BlockType::getByHandle('feature'); if (is_object($bt)) { $bt->refresh(); } $bt = BlockType::getByHandle('image_slider'); if (is_object($bt)) { $bt->refresh(); } $db = Database::get(); $sm = $db->getSchemaManager(); $schemaTables = $sm->listTableNames(); if (in_array('signuprequests', $schemaTables)) { $db->query('alter table signuprequests rename SignupRequestsTmp'); $db->query('alter table SignupRequestsTmp rename SignupRequests'); } if (in_array('userbannedips', $schemaTables)) { $db->query('alter table userbannedips rename UserBannedIPsTmp'); $db->query('alter table UserBannedIPsTmp rename UserBannedIPs'); } // Clean up File stupidity $r = $db->Execute('select Files.fID from Files left join FileVersions on (Files.fID = FileVersions.fID) where FileVersions.fID is null'); while ($row = $r->FetchRow()) { $db->Execute('delete from Files where fID = ?', array($row['fID'])); } }
public function on_start() { $stacksPage = Page::getByPath('/dashboard/blocks/stacks'); $stacksPerms = new Permissions($stacksPage); // Make sure we can view the stacks page if ($stacksPerms->canViewPage()) { $currentPage = $this->c; $currentPagePerms = new Permissions($currentPage); $viewTask = $this->request->get('vtask'); // If the current user can't view this pages versions, or if vtask is not one of the available tasks if (!$currentPagePerms->canViewPageVersions() || !in_array($viewTask, ['view_versions', 'compare'])) { $url = $stacksPage->getPageController()->action('view_details', $currentPage->getCollectionID()); // Redirect to the stacks page return $this->factory->redirect($url); } else { // Otherwise set the current theme and render normally $this->theme = 'dashboard'; } } // If we can't view the stacks page, send a 404 return $this->factory->notFound(''); }
public function up(Schema $schema) { // image resizing options $sp = Page::getByPath('/dashboard/system/files/image_uploading'); if (!is_object($sp) || $sp->isError()) { $sp = \Concrete\Core\Page\Single::add('/dashboard/system/files/image_uploading'); $sp->update(array('cName' => 'Image Uploading')); } // background size/position \Concrete\Core\Database\Schema\Schema::refreshCoreXMLSchema(array('StyleCustomizerInlineStyleSets')); $bt = \BlockType::getByHandle('image_slider'); if (is_object($bt)) { $bt->refresh(); } $bt = \BlockType::getByHandle('youtube'); if (is_object($bt)) { $bt->refresh(); } $bt = \BlockType::getByHandle('autonav'); if (is_object($bt)) { $bt->refresh(); } }
public static function add($cPath, $pkg = null) { // if we get to this point, we create a special collection // without a specific type. This collection has a special cFilename that // points to the passed node $db = Loader::db(); $txt = Loader::helper('text'); Loader::helper('concrete/ui')->clearInterfaceItemsCache(); // trim off a leading / if there is one $cPath = trim($cPath, '/'); // now we grab the parent collection, if there is a static one. $pages = explode('/', $cPath); // instantiate the home collection so we have someplace to add these to $parent = CorePage::getByID(1); // now we iterate through the pages to ensure that they exist in the system before adding the new guy $pathPrefix = ''; for ($i = 0; $i < count($pages); $i++) { $currentPath = $pathPrefix . $pages[$i]; $pathToFile = static::getPathToNode($currentPath, $pkg); // check to see if a page at this point in the tree exists $c = CorePage::getByPath("/" . $currentPath); if ($c->isError() && $c->getError() == COLLECTION_NOT_FOUND) { // create the page at that point in the tree $data = array(); $data['handle'] = $pages[$i]; $data['name'] = $txt->unhandle($data['handle']); $data['filename'] = $pathToFile; $data['uID'] = USER_SUPER_ID; if ($pkg != null) { $data['pkgID'] = $pkg->getPackageID(); } $newC = $parent->addStatic($data); $parent = $newC; } else { $parent = $c; } $pathPrefix = $currentPath . '/'; } $env = Environment::get(); $env->clearOverrideCache(); return $parent; }
/** * @inheritdoc */ public function forbidden($requestUrl, $code = Response::HTTP_FORBIDDEN, $headers = array()) { // set page for redirection after successful login $this->session->set('rUri', $requestUrl); // load page forbidden $item = '/page_forbidden'; $c = Page::getByPath($item); if (is_object($c) && !$c->isError()) { return $this->collection($c, $code, $headers); } $cnt = $this->app->make(PageForbidden::class); $this->controller($cnt, $code, $headers); }
public function up(Schema $schema) { /* refresh CollectionVersionBlocks, CollectionVersionBlocksCacheSettings tables */ $cvb = $schema->getTable('CollectionVersionBlocks'); $cvb->addColumn('cbOverrideBlockTypeCacheSettings', 'boolean', array('default' => 0)); $cvbcs = $schema->createTable('CollectionVersionBlocksCacheSettings'); $cvbcs->addColumn('cID', 'integer', array('notnull' => true, 'unsigned' => true, 'default' => 0)); $cvbcs->addColumn('cvID', 'integer', array('notnull' => true, 'unsigned' => true, 'default' => 1)); $cvbcs->addColumn('bID', 'integer', array('notnull' => true, 'unsigned' => true, 'default' => 0)); $cvbcs->addColumn('arHandle', 'string', array('notnull' => false)); $cvbcs->addColumn('btCacheBlockOutput', 'boolean', array('default' => 0)); $cvbcs->addColumn('btCacheBlockOutputOnPost', 'boolean', array('default' => 0)); $cvbcs->addColumn('btCacheBlockOutputForRegisteredUsers', 'boolean', array('default' => 0)); $cvbcs->addColumn('btCacheBlockOutputLifetime', 'integer', array('notnull' => true, 'unsigned' => true, 'default' => 0)); $cvbcs->setPrimaryKey(array('cID', 'cvID', 'bId', 'arHandle')); /* add permissions lines for edit_block_name and edit_block_cache_settings */ $ebk = Key::getByHandle('edit_block_name'); if (!is_object($ebk)) { Key::add('block', 'edit_block_name', 'Edit Name', "Controls whether users can change the block's name (rarely used.).", false, false); } $ebk = Key::getByHandle('edit_block_cache_settings'); if (!is_object($ebk)) { Key::add('block', 'edit_block_cache_settings', 'Edit Cache Settings', "Controls whether users can change the block cache settings for this block instance.", false, false); } /* Add marketplace single pages */ $sp = Page::getByPath('/dashboard/extend/connect'); if (!is_object($sp) || $sp->isError()) { $sp = SinglePage::add('/dashboard/extend/connect'); $sp->update(array('cName' => 'Connect to the Community')); $sp->setAttribute('meta_keywords', 'concrete5.org, my account, marketplace'); } $sp = Page::getByPath('/dashboard/extend/themes'); if (!is_object($sp) || $sp->isError()) { $sp = SinglePage::add('/dashboard/extend/themes'); $sp->update(array('cName' => 'Get More Themes')); $sp->setAttribute('meta_keywords', 'buy theme, new theme, marketplace, template'); } $sp = Page::getByPath('/dashboard/extend/addons'); if (!is_object($sp) || $sp->isError()) { $sp = SinglePage::add('/dashboard/extend/addons'); $sp->update(array('cName' => 'Get More Add-Ons')); $sp->setAttribute('meta_keywords', 'buy addon, buy add on, buy add-on, purchase addon, purchase add on, purchase add-on, find addon, new addon, marketplace'); } /* Add auth types ("handle|name") "twitter|Twitter" and "community|concrete5.org" */ try { $community = AuthenticationType::getByHandle('community'); } catch (Exception $e) { $community = AuthenticationType::add('community', 'concrete5.org'); if (is_object($community)) { $community->disable(); } } try { $twitter = AuthenticationType::getByHandle('twitter'); } catch (Exception $e) { $twitter = AuthenticationType::add('twitter', 'Twitter'); if (is_object($twitter)) { $twitter->disable(); } } /* delete customize page themes dashboard single page */ $customize = Page::getByPath('/dashboard/pages/themes/customize'); if (is_object($customize) && !$customize->isError()) { $customize->delete(); } /* exclude nav from flat view in dashboard */ $flat = Page::getByPath('/dashboard/sitemap/explore'); if (is_object($customize) && !$customize->isError()) { $flat->setAttribute("exclude_nav", false); } }
public function upgrade() { parent::upgrade(); // Install Single Pages $sP = Page::getByPath('/dashboard/fundamental'); if (!is_object($sP) || $sP->isError()) { $sP = SinglePage::add('/dashboard/fundamental', $this); $sP->update(array('cName' => t("Fundamental Theme Settings"))); // Set up Default Config Settings // Navigation Config::save('c5hub.fundamental.navigation.position', 'right'); Config::save('c5hub.fundamental.navigation.branding', true); Config::save('c5hub.fundamental.navigation.branding_position', 'branding-left'); Config::save('c5hub.fundamental.navigation.contain_to_grid', true); Config::save('c5hub.fundamental.navigation.sticky', false); Config::save('c5hub.fundamental.navigation.custom_back_text', true); Config::save('c5hub.fundamental.navigation.back_text', 'Back'); Config::save('c5hub.fundamental.navigation.is_hover', true); Config::save('c5hub.fundamental.navigation.mobile_show_parent_link', true); Config::save('c5hub.fundamental.navigation.scroll_top', false); Config::save('c5hub.fundamental.navigation.divider', false); // Page Meta Config::save('c5hub.fundamental.page_meta_alignment', 'text-left'); Config::save('c5hub.fundamental.page_meta_title', true); Config::save('c5hub.fundamental.page_meta_description', true); // Background Images Config::save('c5hub.fundamental.body_background_image_repeat', 'repeat'); Config::save('c5hub.fundamental.body_background_image_size', 'auto'); Config::save('c5hub.fundamental.body_background_image_attachment', 'scroll'); Config::save('c5hub.fundamental.top_background_image_repeat', 'repeat'); Config::save('c5hub.fundamental.top_background_image_size', 'auto'); Config::save('c5hub.fundamental.top_background_image_attachment', 'scroll'); Config::save('c5hub.fundamental.branding_background_image_repeat', 'repeat'); Config::save('c5hub.fundamental.branding_background_image_size', 'auto'); Config::save('c5hub.fundamental.branding_background_image_attachment', 'scroll'); Config::save('c5hub.fundamental.navigation_background_image_repeat', 'repeat'); Config::save('c5hub.fundamental.navigation_background_image_size', 'auto'); Config::save('c5hub.fundamental.navigation_background_image_attachment', 'scroll'); Config::save('c5hub.fundamental.header_background_image_repeat', 'repeat'); Config::save('c5hub.fundamental.header_background_image_size', 'auto'); Config::save('c5hub.fundamental.header_background_image_attachment', 'scroll'); Config::save('c5hub.fundamental.banner_background_image_repeat', 'repeat'); Config::save('c5hub.fundamental.banner_background_image_size', 'auto'); Config::save('c5hub.fundamental.banner_background_image_attachment', 'scroll'); Config::save('c5hub.fundamental.page_info_background_image_repeat', 'repeat'); Config::save('c5hub.fundamental.page_info_background_image_size', 'auto'); Config::save('c5hub.fundamental.page_info_background_image_attachment', 'scroll'); Config::save('c5hub.fundamental.main_background_image_repeat', 'repeat'); Config::save('c5hub.fundamental.main_background_image_size', 'auto'); Config::save('c5hub.fundamental.main_background_image_attachment', 'scroll'); Config::save('c5hub.fundamental.footer_top_background_image_repeat', 'repeat'); Config::save('c5hub.fundamental.footer_top_background_image_size', 'auto'); Config::save('c5hub.fundamental.footer_top_background_image_attachment', 'scroll'); Config::save('c5hub.fundamental.footer_bottom_background_image_repeat', 'repeat'); Config::save('c5hub.fundamental.footer_bottom_background_image_size', 'auto'); Config::save('c5hub.fundamental.footer_bottom_background_image_attachment', 'scroll'); // Attribution Config::save('c5hub.fundamental.footer_attribution', '/ <a href="http://c5hub.com" target="_blank" title="concrete5 themes & add-ons">Responsive concrete5 Theme by <b>c5Hub</b></a>'); // White Label Config::save('concrete.marketplace.enabled', true); Config::save('concrete.marketplace.intelligent_search', true); Config::save('concrete.external.news_overlay', true); Config::save('concrete.external.news', true); } $sP = Page::getByPath('/dashboard/fundamental/navigation'); if (!is_object($sP) || $sP->isError()) { $sP = SinglePage::add('/dashboard/fundamental/navigation', $this); $sP->update(array('cName' => t("Navigation"))); } $sP = Page::getByPath('/dashboard/fundamental/off_canvas_navigation'); if (!is_object($sP) || $sP->isError()) { $sP = SinglePage::add('/dashboard/fundamental/off_canvas_navigation', $this); $sP->update(array('cName' => t("Off Canvas Navigation"))); // Off Canvas Navigation Config::save('c5hub.fundamental.off_canvas.position', 'right'); Config::save('c5hub.fundamental.off_canvas.open_method', 'move'); Config::save('c5hub.fundamental.off_canvas.close_on_click', false); } $sP = Page::getByPath('/dashboard/fundamental/page_meta'); if (!is_object($sP) || $sP->isError()) { $sP = SinglePage::add('/dashboard/fundamental/page_meta', $this); $sP->update(array('cName' => t("Page Meta"))); } $sP = Page::getByPath('/dashboard/fundamental/background_images'); if (!is_object($sP) || $sP->isError()) { $sP = SinglePage::add('/dashboard/fundamental/background_images', $this); $sP->update(array('cName' => t("Background Images"))); } $sP = Page::getByPath('/dashboard/fundamental/attribution'); if (!is_object($sP) || $sP->isError()) { $sP = SinglePage::add('/dashboard/fundamental/attribution', $this); $sP->update(array('cName' => t("Attribution"))); } $sP = Page::getByPath('/dashboard/fundamental/white_label'); if (!is_object($sP) || $sP->isError()) { $sP = SinglePage::add('/dashboard/fundamental/white_label', $this); $sP->update(array('cName' => t("White Label"))); } $sP = Page::getByPath('/dashboard/fundamental/general'); if (!is_object($sP) || $sP->isError()) { $sP = SinglePage::add('/dashboard/fundamental/general', $this); $sP->update(array('cName' => t("General"))); // General Config::save('c5hub.fundamental.general.boxed', false); Config::save('c5hub.fundamental.general.sticky_footer', false); } $sP = Page::getByPath('/dashboard/fundamental/masonry_grid'); if (!is_object($sP) || $sP->isError()) { $sP = SinglePage::add('/dashboard/fundamental/masonry_grid', $this); $sP->update(array('cName' => t("Masonry Grid"))); // Masonry Grid Config::save('c5hub.fundamental.masonry_grid_columns_desktop', 4); Config::save('c5hub.fundamental.masonry_grid_columns_tablet', 4); Config::save('c5hub.fundamental.masonry_grid_columns_mobile', 12); } // Install Page Types if (!PageTemplate::getByHandle('blog_entry')) { PageTemplate::add('blog_entry', 'Blog Entry', 'left_sidebar.png', $pkg); } if (!PageTemplate::getByHandle('custom')) { PageTemplate::add('custom', 'Custom', 'full.png', $pkg); } if (!PageTemplate::getByHandle('blank')) { PageTemplate::add('blank', t('Blank'), 'full.png', $pkg); } // Install Blocks if (!BlockType::getByHandle('fundamental_simple_document')) { BlockType::installBlockTypeFromPackage('fundamental_simple_document', $this); } if (!BlockType::getByHandle('fundamental_section')) { BlockType::installBlockTypeFromPackage('fundamental_section', $this); } if (!BlockType::getByHandle('fundamental_slick_slider')) { BlockType::installBlockTypeFromPackage('fundamental_slick_slider', $this); } // Install Thumbnail Types $small = \Concrete\Core\File\Image\Thumbnail\Type\Type::getByHandle('small'); if (!is_object($small)) { $type = new \Concrete\Core\File\Image\Thumbnail\Type\Type(); $type->setName('Small'); $type->setHandle('small'); $type->setWidth(740); $type->save(); } $medium = \Concrete\Core\File\Image\Thumbnail\Type\Type::getByHandle('medium'); if (!is_object($medium)) { $type = new \Concrete\Core\File\Image\Thumbnail\Type\Type(); $type->setName('Medium'); $type->setHandle('medium'); $type->setWidth(940); $type->save(); } $large = \Concrete\Core\File\Image\Thumbnail\Type\Type::getByHandle('large'); if (!is_object($large)) { $type = new \Concrete\Core\File\Image\Thumbnail\Type\Type(); $type->setName('Large'); $type->setHandle('large'); $type->setWidth(1140); $type->save(); } $xlarge = \Concrete\Core\File\Image\Thumbnail\Type\Type::getByHandle('xlarge'); if (!is_object($xlarge)) { $type = new \Concrete\Core\File\Image\Thumbnail\Type\Type(); $type->setName('XLarge'); $type->setHandle('xlarge'); $type->setWidth(9999); $type->save(); } // Attributes $navIconKey = CollectionAttributeKey::getByHandle('nav_icon'); if (!$navIconKey || !intval($navIconKey->getAttributeKeyID())) { $navIconType = AttributeType::getByHandle('select'); $navIconKey = CollectionAttributeKey::add($navIconType, array('akHandle' => 'nav_icon', 'akName' => t('Nav Icon'), 'akIsSearchable' => false), $pkg); ## Add Options $options = $this->getIconClasses(); foreach ($options as $opt) { $navIconKeyOption = SelectAttributeTypeOption::add($navIconKey, $opt, 0); } } $thumbnailKey = CollectionAttributeKey::getByHandle('thumbnail'); if (!$thumbnailKey || !intval($thumbnailKey->getAttributeKeyID())) { $thumbnailType = AttributeType::getByHandle('image_file'); $thumbnailKey = CollectionAttributeKey::add($thumbnailType, array('akHandle' => 'thumbnail', 'akName' => t('Thumbnail'), 'akIsSearchable' => false), $pkg); } $disableTitleKey = CollectionAttributeKey::getByHandle('disable_page_info_title'); if (!$disableTitleKey || !intval($disableTitleKey->getAttributeKeyID())) { $disableTitleType = AttributeType::getByHandle('boolean'); $disableTitleKey = CollectionAttributeKey::add($disableTitleType, array('akHandle' => 'disable_page_info_title', 'akName' => t('Disable Page Info Title'), 'akIsSearchable' => false), $pkg); } $disableDescriptionKey = CollectionAttributeKey::getByHandle('disable_page_info_description'); if (!$disableDescriptionKey || !intval($disableDescriptionKey->getAttributeKeyID())) { $disableDescriptionType = AttributeType::getByHandle('boolean'); $disableDescriptionKey = CollectionAttributeKey::add($disableDescriptionType, array('akHandle' => 'disable_page_info_description', 'akName' => t('Disable Page Info Description'), 'akIsSearchable' => false), $pkg); } $areaCountKey = CollectionAttributeKey::getByHandle('area_count'); if (!$areaCountKey || !intval($areaCountKey->getAttributeKeyID())) { $areaCountType = AttributeType::getByHandle('number'); $areaCountKey = CollectionAttributeKey::add($areaCountType, array('akHandle' => 'area_count', 'akName' => t('Area Count'), 'akIsSearchable' => false), $pkg); } }
public function import(\SimpleXMLElement $sx) { if (isset($sx->pages)) { $nodes = array(); $i = 0; foreach ($sx->pages->page as $p) { $p->originalPos = $i; $nodes[] = $p; ++$i; } usort($nodes, array('static', 'setupPageNodeOrder')); $siteTree = null; if (isset($this->home)) { $home = $this->home; $siteTree = $this->home->getSiteTreeObject(); } else { $home = Page::getByID(HOME_CID, 'RECENT'); } foreach ($nodes as $px) { $pkg = static::getPackageObject($px['package']); $data = array(); $user = (string) $px['user']; if ($user != '') { $ui = UserInfo::getByUserName($user); if (is_object($ui)) { $data['uID'] = $ui->getUserID(); } else { $data['uID'] = USER_SUPER_ID; } } $cDatePublic = (string) $px['public-date']; if ($cDatePublic) { $data['cDatePublic'] = $cDatePublic; } $data['pkgID'] = 0; if (is_object($pkg)) { $data['pkgID'] = $pkg->getPackageID(); } $args = array(); $ct = Type::getByHandle($px['pagetype']); $template = Template::getByHandle($px['template']); if ($px['path'] != '') { // not home page $page = Page::getByPath($px['path'], 'RECENT', $siteTree); if (!is_object($page) || $page->isError()) { $lastSlash = strrpos((string) $px['path'], '/'); $parentPath = substr((string) $px['path'], 0, $lastSlash); $data['cHandle'] = substr((string) $px['path'], $lastSlash + 1); if (!$parentPath) { $parent = $home; } else { $parent = Page::getByPath($parentPath, 'RECENT', $siteTree); } $page = $parent->add($ct, $data); } } else { $page = $home; } $args['cName'] = $px['name']; $args['cDescription'] = $px['description']; if (is_object($ct)) { $args['ptID'] = $ct->getPageTypeID(); } $args['pTemplateID'] = $template->getPageTemplateID(); $page->update($args); } } }
public function testBasicFeedSave() { $pt = \Concrete\Core\Page\Type\Type::getByHandle('another'); $pp = \Concrete\Core\Page\Page::getByPath('/another-fun-page'); $pf = new \Concrete\Core\Page\Feed(); $pf->setHandle('blog'); $pf->setPageTypeID($pt->getPageTypeID()); $pf->setParentID($pp->getCollectionID()); $pf->setTitle('RSS Feed'); $pf->setDescription('My Description'); $pf->save(); $this->assertEquals('blog', $pf->getHandle()); $this->assertEquals(1, $pf->getID()); $pf->ignorePermissions(); $pl = $pf->getPageListObject(); $this->assertInstanceOf('\\Concrete\\Core\\Page\\PageList', $pl); $this->assertEquals(1, $pl->getTotalResults()); $results = $pl->getResults(); $this->assertEquals('Foobler', $results[0]->getCollectionName()); }
public static function createPageInTree($cPath, TreeInterface $tree, $moveToRoot = false, $pkg = null) { $txt = Loader::helper('text'); // trim off a leading / if there is one $cPath = trim($cPath, '/'); // now we grab the parent collection, if there is a static one. $pages = explode('/', $cPath); $parent = $tree->getSiteTreeObject()->getSiteHomePageObject(); // now we iterate through the pages to ensure that they exist in the system before adding the new guy $pathPrefix = ''; $checkGlobally = false; for ($i = 0; $i < count($pages); ++$i) { $currentPath = $pathPrefix . $pages[$i]; if ($i == 0) { // First, we check the first path to see if it falls outside of the root already. If it does, // we're not going to check within the site for them $rootPage = CorePage::getByPath("/" . $currentPath); if (!$rootPage->isError() && $rootPage->getSiteTreeID() == 0) { // That means we've already added this as a system page, like Dashboard, etc... Which means // that we add the subsequent pages globally $checkGlobally = true; } } $pathToFile = static::getPathToNode($currentPath, $pkg); // check to see if a page at this point in the tree exists if (!$checkGlobally) { $c = CorePage::getByPath("/" . $currentPath, 'RECENT', $tree); } else { $c = CorePage::getByPath("/" . $currentPath); } if ($c->isError() && $c->getError() == COLLECTION_NOT_FOUND) { // create the page at that point in the tree $data = array(); $data['handle'] = $pages[$i]; $data['name'] = $txt->unhandle($data['handle']); $data['filename'] = $pathToFile; $data['uID'] = USER_SUPER_ID; if ($pkg != null) { $data['pkgID'] = $pkg->getPackageID(); } if ($moveToRoot) { $newC = Page::addStatic($data, $tree); $newC->moveToRoot(); // change cparent ID back to 0 } else { $newC = Page::addStatic($data, $parent); } $parent = $newC; } else { $parent = $c; } $pathPrefix = $currentPath . '/'; } return $parent; }
public function createDraft(\Concrete\Core\Entity\Page\Template $pt, $u = false) { if (!is_object($u)) { $u = new User(); } $db = Loader::db(); $ptID = $this->getPageTypeID(); $parent = Page::getByPath(Config::get('concrete.paths.drafts')); $data = array('cvIsApproved' => 0, 'cIsActive' => false, 'cAcquireComposerOutputControls' => true); $p = $parent->add($this, $data, $pt); // now we setup in the initial configurated page target $target = $this->getPageTypePublishTargetObject(); $cParentID = $target->getDefaultParentPageID(); if ($cParentID > 0) { $p->setPageDraftTargetParentPageID($cParentID); } $controls = PageTypeComposerControl::getList($this); foreach ($controls as $cn) { $cn->onPageDraftCreate($p); } return $p; }
protected function installDesktops() { $this->output(t('Installing Desktops...')); $template = Template::getByHandle('desktop'); if (!is_object($template)) { Template::add('desktop', t('Desktop'), FILENAME_PAGE_TEMPLATE_DEFAULT_ICON, null, true); } $type = \Concrete\Core\Page\Type\Type::getByHandle('core_desktop'); if (!is_object($type)) { \Concrete\Core\Page\Type\Type::add(array('handle' => 'core_desktop', 'name' => 'Desktop', 'internal' => true)); } $category = Category::getByHandle('collection')->getController(); $attribute = CollectionKey::getByHandle('is_desktop'); if (!is_object($attribute)) { $key = new PageKey(); $key->setAttributeKeyHandle('is_desktop'); $key->setAttributeKeyName('Is Desktop'); $key->setIsAttributeKeyInternal(true); $category->add('boolean', $key); } $attribute = CollectionKey::getByHandle('desktop_priority'); if (!is_object($attribute)) { $key = new PageKey(); $key->setAttributeKeyHandle('desktop_priority'); $key->setAttributeKeyName('Desktop Priority'); $key->setIsAttributeKeyInternal(true); $category->add('number', $key); } $desktop = Page::getByPath('/dashboard/welcome'); if (is_object($desktop) && !$desktop->isError()) { $desktop->moveToTrash(); } $desktop = Page::getByPath('/desktop'); if (is_object($desktop) && !$desktop->isError()) { $desktop->moveToTrash(); } $page = \Page::getByPath("/account/messages"); if (is_object($page) && !$page->isError()) { $page->moveToTrash(); } // Private Messages tweak SinglePage::add('/account/messages'); $ci = new ContentImporter(); $ci->importContentFile(DIR_BASE_CORE . '/config/install/upgrade/desktops.xml'); $desktop = Page::getByPath('/dashboard/welcome'); $desktop->movePageDisplayOrderToTop(); \Config::save('concrete.misc.login_redirect', 'DESKTOP'); }
/** * Looks at the current page. If the site tree ID is 0, sets system page to true. * If the site tree is not user, looks at where the page falls in the hierarchy. If it's inside a page * at the top level that has 0 as its parent, then it is considered a system page. */ public function rescanSystemPageStatus() { $systemPage = false; $db = Database::connection(); $cID = $this->getCollectionID(); if (!$this->isHomePage()) { if ($this->getSiteTreeID() == 0) { $systemPage = true; } else { $cID = $this->getCollectionPointerOriginalID() > 0 ? $this->getCollectionPointerOriginalID() : $this->getCollectionID(); $db = Database::connection(); $path = $db->fetchColumn('select cPath from PagePaths where cID = ? and ppIsCanonical = 1', array($cID)); if ($path) { // Grab the top level parent $fragments = explode('/', $path); $topPath = '/' . $fragments[1]; $c = \Page::getByPath($topPath); if (is_object($c) && !$c->isError()) { if ($c->getCollectionParentID() == 0) { $systemPage = true; } } } } } if ($systemPage) { $db->executeQuery('update Pages set cIsSystemPage = 1 where cID = ?', array($cID)); $this->cIsSystemPage = true; } else { $db->executeQuery('update Pages set cIsSystemPage = 0 where cID = ?', array($cID)); $this->cIsSystemPage = false; } }
public function moveToTrash() { // run any internal event we have for page trashing $pe = new Event($this); Events::dispatch('on_page_move_to_trash', $pe); $trash = Page::getByPath(Config::get('concrete.paths.trash')); Log::addEntry(t('Page "%s" at path "%s" Moved to trash', $this->getCollectionName(), $this->getCollectionPath()), t('Page Action')); $this->move($trash); $this->deactivate(); // if this page has a custom canonical path we need to clear it $path = $this->getCollectionPathObject(); if (!$path->isPagePathAutoGenerated()) { $path = $this->getAutoGeneratedPagePathObject(); $this->setCanonicalPagePath($path->getPagePath(), true); $this->rescanCollectionPath(); } $cID = $this->getCollectionPointerOriginalID() > 0 ? $this->getCollectionPointerOriginalID() : $this->cID; $pages = array(); $pages = $this->populateRecursivePages($pages, array('cID' => $cID), $this->getCollectionParentID(), 0, false); $db = Database::get(); foreach ($pages as $page) { $db->Execute('update Pages set cIsActive = 0 where cID = ?', array($page['cID'])); } }
public function moveToTrash() { // run any internal event we have for page trashing $pe = new Event($this); Events::dispatch('on_page_move_to_trash', $pe); if ($ret < 0) { return false; } $trash = Page::getByPath(Config::get('concrete.paths.trash')); Log::addEntry(t('Page "%s" at path "%s" Moved to trash', $this->getCollectionName(), $this->getCollectionPath()), t('Page Action')); $this->move($trash); $this->deactivate(); $pages = array(); $pages = $this->populateRecursivePages($pages, array('cID' => $this->getCollectionID()), $this->getCollectionParentID(), 0, false); $db = Loader::db(); foreach ($pages as $page) { $db->Execute('update Pages set cIsActive = 0 where cID = ?', array($page['cID'])); } }