Example #1
0
 public function update_profiles()
 {
     /** @var Token $token */
     $token = \Core::make('token');
     if (!$token->validate("update_profile")) {
         $this->error->add('Invalid Token.');
         return;
     }
     if ($this->isPost()) {
         $config = $this->getSite()->getConfigRepository();
         $config->save('user.profiles_enabled', $this->post('public_profiles') ? true : false);
         $config->save('user.gravatar.enabled', $this->post('gravatar_fallback') ? true : false);
         $config->save('user.gravatar.max_level', Loader::helper('security')->sanitizeString($this->post('gravatar_max_level')));
         $config->save('user.gravatar.image_set', Loader::helper('security')->sanitizeString($this->post('gravatar_image_set')));
         // $message = ($this->post('public_profiles')?t('Public profiles have been enabled'):t('Public profiles have been disabled.'));
         if ($this->post('public_profiles')) {
             Single::add('/members');
             $c = Single::add('/members/profile');
             Single::add('/members/directory');
             $c->update(['cName' => 'View Profile']);
             $this->redirect('/dashboard/system/registration/profiles/profiles_enabled');
         } else {
             foreach ($this->app->make('site')->getList() as $site) {
                 foreach (['/members/directory', '/members/profile', '/members'] as $path) {
                     $c = \Page::getByPath($path, 'RECENT', $site);
                     $c->delete();
                 }
             }
             $this->redirect('/dashboard/system/registration/profiles/profiles_disabled');
         }
     }
 }
 public function import(\SimpleXMLElement $sx)
 {
     if (isset($sx->singlepages)) {
         foreach ($sx->singlepages->page as $p) {
             $pkg = static::getPackageObject($p['package']);
             if (isset($p['global']) && (string) $p['global'] === 'true') {
                 $spl = Single::addGlobal($p['path'], $pkg);
             } else {
                 $root = false;
                 if (isset($p['root']) && (string) $p['root'] === 'true') {
                     $root = true;
                 }
                 $siteTree = null;
                 if (isset($this->home)) {
                     $siteTree = $this->home->getSiteTreeObject();
                 } else {
                     $home = \Page::getByID(HOME_CID);
                     $siteTree = $home->getSiteTreeObject();
                 }
                 $spl = Single::createPageInTree($p['path'], $siteTree, $root, $pkg);
             }
             if (is_object($spl)) {
                 if ($p['name']) {
                     $spl->update(array('cName' => $p['name'], 'cDescription' => $p['description']));
                 }
                 if ($p['custom-path']) {
                     $spl->setCanonicalPagePath((string) $p['custom-path'], false);
                 }
             }
         }
     }
 }
Example #3
0
 public function install()
 {
     $pkg = parent::install();
     $theme = PageTheme::add('nukiuchi_theme', $pkg);
     $page = Single::add('/blog', $pkg);
     $page->setTheme($theme);
 }
 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 #5
0
 public function install()
 {
     $pkg = parent::install();
     //BlockType::installBlockTypeFromPackage('Mailer', $pkg);
     Job::installByPackage('process_xmailer', $pkg);
     SinglePage::add('/dashboard/xmailer', $pkg);
     SinglePage::add('/dashboard/xmailer/mailboxes', $pkg);
     SinglePage::add('/dashboard/xmailer/mailboxes/user', $pkg);
     SinglePage::add('/dashboard/xmailer/mailboxes/group', $pkg);
     SinglePage::add('/dashboard/xmailer/settings', $pkg);
 }
Example #6
0
 public function refresh($cID = 0, $token)
 {
     if (intval($cID) > 0) {
         if ($this->token->validate('refresh', $token)) {
             $p = SinglePage::getByID($cID);
             $cp = new Permissions($p);
             if ($cp->canAdmin()) {
                 SinglePage::refresh($p);
                 $this->redirect('/dashboard/pages/single', 'single_page_refreshed');
             } else {
                 $this->error->add(t('You do not have permissions to refresh this page.'));
             }
         } else {
             $this->error->add($this->token->getErrorMessage());
         }
     } else {
         $this->error->add(t('Page Unsuccessfully Refreshed.'));
     }
 }
 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 function execute(Batch $batch)
 {
     $this->batch = $batch;
     $pages = $this->getPagesOrderedForImport($batch);
     if (!$pages) {
         return;
     }
     // Now loop through all pages, and build them
     foreach ($pages as $page) {
         $pkg = null;
         if ($page->getPackage()) {
             $pkg = \Package::getByHandle($page->getPackage());
         }
         $c = Single::add($page->getOriginalPath(), $pkg);
         if (is_object($c)) {
             if ($page->getIsAtRoot()) {
                 $c->moveToRoot();
             }
             $data['name'] = $page->getName();
             $data['description'] = $page->getDescription();
             $c->update($data);
         }
     }
 }
Example #9
0
 public function getFilesInTheme()
 {
     $dh = Loader::helper('file');
     $templateList = PageTemplate::getList();
     $pts = [];
     foreach ($templateList as $pt) {
         $pts[] = $pt->getPageTemplateHandle();
     }
     $files = [];
     $filesTmp = $dh->getDirectoryContents($this->pThemeDirectory);
     foreach ($filesTmp as $f) {
         if (strrchr($f, '.') == static::THEME_EXTENSION) {
             $fHandle = substr($f, 0, strpos($f, '.'));
             if ($f == FILENAME_THEMES_VIEW) {
                 $type = PageThemeFile::TFTYPE_VIEW;
             } elseif ($f == FILENAME_THEMES_CLASS) {
                 $type = PageThemeFile::TFTYPE_PAGE_CLASS;
             } else {
                 if ($f == FILENAME_THEMES_DEFAULT) {
                     $type = PageThemeFile::TFTYPE_DEFAULT;
                 } else {
                     if (in_array($f, SinglePage::getThemeableCorePages())) {
                         $type = PageThemeFile::TFTYPE_SINGLE_PAGE;
                     } else {
                         if (in_array($fHandle, $pts)) {
                             $type = PageThemeFile::TFTYPE_PAGE_TEMPLATE_EXISTING;
                         } else {
                             $type = PageThemeFile::TFTYPE_PAGE_TEMPLATE_NEW;
                         }
                     }
                 }
             }
             $pf = new PageThemeFile();
             $pf->setFilename($f);
             $pf->setType($type);
             $files[] = $pf;
         }
     }
     return $files;
 }
 protected function updateWorkflows()
 {
     $this->output(t('Updating Workflows...'));
     $page = \Page::getByPath("/dashboard/workflow");
     if (is_object($page) && !$page->isError()) {
         $page->moveToTrash();
     }
     $page = \Page::getByPath("/dashboard/system/permissions/workflows");
     if (!is_object($page) || $page->isError()) {
         SinglePage::add('/dashboard/system/permissions/workflows');
     }
 }
 /**
  * Adds/installs or refresh a single page
  * @param string $pagePath The relative path to the single page
  * @param string $pageName The name of the single page
  * @param string $description The description for the single page
  * Thanks! http://www.code-examples.com/concrete-5-7-creating-a-single-page-for-the-frontend/
  */
 private function addSinglePage($pagePath, $pageName, $description)
 {
     $pkg = Package::getByHandle($this->getPackageHandle());
     $singlePage = Page::getByPath($pagePath);
     if ($singlePage->isError() && $singlePage->getError() == COLLECTION_NOT_FOUND) {
         /* @var $singlePage Single*/
         $singlePage = Single::add($pagePath, $pkg);
         $singlePage->update(array('cName' => $pageName, 'cDescription' => $description));
         return $singlePage;
     } else {
         //refresh single page by package file
         $cID = Page::getByPath($pagePath)->getCollectionID();
         Loader::db()->execute('update Pages set pkgID = ? where cID = ?', array($pkg->pkgID, $cID));
     }
     return null;
 }
Example #12
0
 public function getPackageItems(Package $package)
 {
     return Single::getListByPackage($package);
 }
Example #13
0
 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 install()
 {
     $pkg = parent::install();
     SinglePage::add('/dashboard/collection_version_list', $pkg);
     SinglePage::add('/dashboard/collection_version_list/search', $pkg);
 }
 /**
  * adds all single pages if they do not exist
  * @return void
  */
 public function add_single_pages()
 {
     foreach ($this->single_pages as $pageHandle) {
         if (Page::getByPath($pageHandle)->getCollectionID() <= 0) {
             $sp = SinglePage::add($pageHandle, $this->pkg);
         }
         if ($pageHandle == '/dashboard/razor/migrate/import' || $pageHandle == '/dashboard/razor/migrate/export') {
             $page = Page::getByPath($pageHandle);
             $page->setAttribute('exclude_nav', true);
         }
         if ($pageHandle == '/dashboard/razor') {
             $pageDashRazor = Page::getByPath($pageHandle);
             $pageDashRazor->updateCollectionName('Commerce');
             $pageDashRazor->updateDisplayOrder(0);
             $pageDashFiles = Page::getByPath('/dashboard/files');
             $pageDashFiles->updateDisplayOrder(1);
             $pageDash = Page::getByPath('/dashboard');
             $pageDash->rescanChildrenDisplayOrder();
         }
     }
 }