Exemple #1
0
 public function copyToTargetCategory(StackCategory $category)
 {
     $list = new StackList();
     $list->filterByStackCategory($this);
     $stacks = $list->get();
     foreach ($stacks as $stack) {
         $stack->duplicate($category->getPage());
     }
 }
 public function getItems()
 {
     $pages = $this->section->populateRecursivePages(array(), array('cID' => $this->section->getCollectionID()), $this->section->getCollectionParentID(), 0, false);
     // Add in all the stack pages found for the current locale.
     $list = new StackList();
     $list->filterByLanguageSection($this->getSection());
     $results = $list->get();
     foreach ($results as $result) {
         $pages[] = array('cID' => $result->getCollectionID());
     }
     return $pages;
 }
 /**
  * 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();
     }
 }
 public function up(Schema $schema)
 {
     \Concrete\Core\Database\Schema\Schema::refreshCoreXMLSchema(array('Stacks'));
     if (\Core::make('multilingual/detector')->isEnabled()) {
         StackList::rescanMultilingualStacks();
     }
 }
Exemple #5
0
 /**
  * @param string $stackName
  * @param int    $type
  *
  * @return Page
  */
 public static function addStack($stackName, $type = 0)
 {
     $data = array();
     $parent = Page::getByPath(STACKS_PAGE_PATH);
     $data = array();
     $data['name'] = $stackName;
     if (!$stackName) {
         $data['name'] = t('No Name');
     }
     $pagetype = PageType::getByHandle(STACKS_PAGE_TYPE);
     $page = $parent->add($pagetype, $data);
     // we have to do this because we need the area to exist before we try and add something to it.
     Area::getOrCreate($page, STACKS_AREA_NAME);
     // finally we add the row to the stacks table
     $db = Database::connection();
     $stackCID = $page->getCollectionID();
     $v = array($stackName, $stackCID, $type);
     $db->Execute('insert into Stacks (stName, cID, stType) values (?, ?, ?)', $v);
     $stack = static::getByID($stackCID);
     // If the multilingual add-on is enabled, we need to take this stack and copy it into all non-default stack categories.
     if (Core::make('multilingual/detector')->isEnabled()) {
         $list = Section::getList();
         foreach ($list as $section) {
             if (!$section->isDefaultMultilingualSection()) {
                 $category = StackCategory::getCategoryFromMultilingualSection($section);
                 if (!is_object($category)) {
                     $category = StackCategory::createFromMultilingualSection($section);
                 }
                 $stack->duplicate($category->getPage());
             }
         }
         StackList::rescanMultilingualStacks();
     }
     return $stack;
 }
 public function run()
 {
     $this->x = new SimpleXMLElement("<concrete5-cif></concrete5-cif>");
     $this->x->addAttribute('version', '1.0');
     // First, attribute categories
     AttributeKeyCategory::exportList($this->x);
     // Features
     Feature::exportList($this->x);
     FeatureCategory::exportList($this->x);
     ConversationEditor::exportList($this->x);
     ConversationRatingType::exportList($this->x);
     // composer
     PageTypePublishTargetType::exportList($this->x);
     PageTypeComposerControlType::exportList($this->x);
     PageType::exportList($this->x);
     // attribute types
     AttributeType::exportList($this->x);
     // then block types
     BlockTypeList::exportList($this->x);
     // now block type sets (including user)
     BlockTypeSet::exportList($this->x);
     // gathering
     GatheringDataSource::exportList($this->x);
     GatheringItemTemplate::exportList($this->x);
     // now attribute keys (including user)
     AttributeKey::exportList($this->x);
     // now attribute keys (including user)
     AttributeSet::exportList($this->x);
     PageTemplate::exportList($this->x);
     // now theme
     PageTheme::exportList($this->x);
     // now packages
     PackageList::export($this->x);
     // permission access entity types
     PermissionAccessEntityType::exportList($this->x);
     // now task permissions
     PermissionKey::exportList($this->x);
     // workflow types
     WorkflowType::exportList($this->x);
     // now jobs
     Job::exportList($this->x);
     // now single pages
     $singlepages = $this->x->addChild("singlepages");
     $db = Loader::db();
     $r = $db->Execute('select cID from Pages where cFilename is not null and cFilename <> "" and cID not in (select cID from Stacks) order by cID asc');
     while ($row = $r->FetchRow()) {
         $pc = Page::getByID($row['cID'], 'RECENT');
         $pc->export($singlepages);
     }
     // now stacks/global areas
     StackList::export($this->x);
     // now content pages
     $pages = $this->x->addChild("pages");
     $db = Loader::db();
     $r = $db->Execute('select Pages.cID from Pages where cIsTemplate = 0 and cFilename is null or cFilename = "" order by cID asc');
     while ($row = $r->FetchRow()) {
         $pc = Page::getByID($row['cID'], 'RECENT');
         if ($pc->getPageTypeHandle() == STACKS_PAGE_TYPE) {
             continue;
         }
         $pc->export($pages);
     }
     SystemCaptchaLibrary::exportList($this->x);
     \Concrete\Core\Sharing\SocialNetwork\Link::exportList($this->x);
     \Concrete\Core\Page\Feed::exportList($this->x);
     \Concrete\Core\File\Image\Thumbnail\Type\Type::exportList($this->x);
     Config::exportList($this->x);
     Tree::exportList($this->x);
 }
 /**
  * Get a list of stacks available.
  *
  * @return \Concrete\Core\Page\Stack\StackList
  */
 public function getStacks()
 {
     $list = new StackList();
     $list->filterByUserAdded();
     return $list->get();
 }
Exemple #8
0
 public function view()
 {
     $stm = new StackList();
     $stm->filterByUserAdded();
     $this->setupMultilingualStackList($stm);
     $this->set('stacks', $stm->get());
     $parent = Page::getByPath(STACKS_PAGE_PATH);
     $cpc = new Permissions($parent);
     if ($cpc->canMoveOrCopyPage()) {
         $this->set('canMoveStacks', true);
         $sortUrl = View::url('/dashboard/blocks/stacks', 'update_order');
         $this->set('sortURL', $sortUrl);
     }
 }
Exemple #9
0
 /**
  * @param string $stackName
  * @param int    $type
  *
  * @return Page
  */
 public static function addStack($stackName, $type = 0, $multilingualStackToReturn = self::MULTILINGUAL_CONTENT_SOURCE_CURRENT)
 {
     $return = false;
     $db = \Database::connection();
     if (Core::make('multilingual/detector')->isEnabled()) {
         $returnFromSection = Stack::getMultilingualSectionFromType($multilingualStackToReturn);
         $list = Section::getList();
         foreach ($list as $section) {
             $cID = $db->GetOne('select cID from Stacks where stName = ? and stMultilingualSection = ?', array($stackName, $section->getCollectionID()));
             if (!$cID) {
                 $category = StackCategory::getCategoryFromMultilingualSection($section);
                 if (!is_object($category)) {
                     $category = StackCategory::createFromMultilingualSection($section);
                 }
                 $stack = Stack::addStackToCategory($category->getPage(), $stackName, $type);
                 if (is_object($returnFromSection) && $returnFromSection->getCollectionID() == $section->getCollectionID()) {
                     $return = $stack;
                 }
             }
         }
         StackList::rescanMultilingualStacks();
     } else {
         $parent = \Page::getByPath(STACKS_PAGE_PATH);
         $return = Stack::addStackToCategory($parent, $stackName, $type);
     }
     return $return;
 }
Exemple #10
0
 public function swapContent($options)
 {
     // Custom method to allow us to offer multiple starting points
     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 = PageType::getList();
         foreach ($pageTypes as $ct) {
             $ct->delete();
         }
         // Overidden functionality to let us install selected starting point.... now we add in any files that this package has
         if (is_dir($this->getPackagePath() . '/starting_points/' . $this->startingPoint . '/content_files')) {
             $fh = new FileImporter();
             $contents = Core::make('helper/file')->getDirectoryContents($this->getPackagePath() . '/starting_points/' . $this->startingPoint . '/content_files');
             foreach ($contents as $filename) {
                 $f = $fh->import($this->getPackagePath() . '/starting_points/' . $this->startingPoint . '/content_files/' . $filename, $filename);
             }
         }
         // Install selected starting point.
         $ci = new ContentImporter();
         $ci->importContentFile($this->getPackagePath() . '/starting_points/' . $this->startingPoint . '/content.xml');
         // Set the default preset
         $pt = PageTheme::getByHandle($this->pkgHandle);
         if (is_object($pt) && $pt->isThemeCustomizable()) {
             $presets = $pt->getThemeCustomizableStylePresets();
             foreach ($presets as $preset) {
                 if ($preset->getPresetHandle() == $this->startingPoint) {
                     $styles = $pt->getThemeCustomizableStyleList();
                     $lessFile = $this->getPackagePath() . '/themes/' . $this->pkgHandle . '/css/presets/' . $this->startingPoint . '.less';
                     $vl = \Concrete\Core\StyleCustomizer\Style\ValueList::loadFromLessFile($lessFile);
                     $vl->save();
                     $pt->setCustomStyleObject($vl, $preset, false);
                 }
             }
         }
         \Core::make('cache/request')->enable();
     }
 }
 /**
  * Sets up a multiple columns to search by. Each argument is taken "as-is" (including asc or desc) and concatenated with commas
  * Note that this is overrides any previous sortByMultiple() call, and all sortBy() calls. Alternatively, you can pass a single
  * array with multiple columns to sort by as its values.
  * e.g. $list->sortByMultiple('columna desc', 'columnb asc');
  * or $list->sortByMultiple(array('columna desc', 'columnb asc'));
  */
 public function sortByMultiple()
 {
     return parent::sortByMultiple();
 }