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); }
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); } }
/** * @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); }
private function addPageAttributeKeys($pkg) { $att = CollectionAttributeKey::getByHandle("db_table_demo"); if (!$att) { CollectionAttributeKey::add('db_table_demo', array('akHandle' => 'db_table_demo', 'akName' => t('Database Table Tutorial Demo'), 'akIsSearchable' => true), $pkg); } }
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 addField($fieldHandle, $required = false, $args = array()) { $akid = AttributeCollectionKey::getByHandle($fieldHandle); $ctca = ComposerControlType::getByHandle('collection_attribute'); $control = $ctca->getPageTypeComposerControlByIdentifier($akid->getAttributeKeyID()); $control->addToPageTypeComposerFormLayoutSet($this->layoutSet)->updateFormLayoutSetControlRequired($required); }
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)); } } } } } }
/** * render Add Blog dialog */ public function render() { if ($_REQUEST['akID']) { $akID = $_REQUEST['akID']; if ($_REQUEST['akID']) { if ($_REQUEST['akID'] == 'same_tags') { $key = CollectionAttributeKey::getByHandle('tags'); $akID = $key->getAttributeKeyID(); } } $html = '<fieldset>'; $db = loader::db(); $r = $db->execute("SELECT * FROM atSelectOptions WHERE akID = ?", array($akID)); while ($row = $r->fetchrow()) { $id = $row['ID']; $options[$id] = $row['value']; } if (is_array($options)) { foreach ($options as $key => $option) { $html .= '<input type="checkbox" name="fields[]" value="' . $option . '">' . $option . '<br/>'; } } $html .= '</fieldset>'; //print json_encode($options); print $html; exit; } }
public static function saveData($p) { $blocks = $p->getBlocks('Main'); foreach ($blocks as $b) { if ($b->getBlockTypeHandle() == 'content' || $b->getBlockTypeHandle() == 'core_page_type_composer_control_output') { $b->deleteBlock(); } } Loader::model("attribute/categories/collection"); $cak = CollectionAttributeKey::getByHandle('tags'); $cak->saveAttributeForm($p); $cck = CollectionAttributeKey::getByHandle('meta_title'); $cck->saveAttributeForm($p); $cck = CollectionAttributeKey::getByHandle('meta_description'); $cck->saveAttributeForm($p); $cck = CollectionAttributeKey::getByHandle('meta_keywords'); $cck->saveAttributeForm($p); $cck = CollectionAttributeKey::getByHandle('blog_category'); $cck->saveAttributeForm($p); //$cnv = CollectionAttributeKey::getByHandle('exclude_nav'); //$cnv->saveAttributeForm($p); $ct = CollectionAttributeKey::getByHandle('thumbnail'); $ct->saveAttributeForm($p); $ca = CollectionAttributeKey::getByHandle('blog_author'); $ca->saveAttributeForm($p); $set = AttributeSet::getByHandle('problog_additional_attributes'); $setAttribs = $set->getAttributeKeys(); if ($setAttribs) { foreach ($setAttribs as $ak) { $aksv = CollectionAttributeKey::getByHandle($ak->akHandle); $aksv->saveAttributeForm($p); } } $bt = BlockType::getByHandle('content'); if (empty($_POST['blogBody'])) { $content = ' '; } else { $content = $_POST['blogBody']; } $data = array('content' => $content); $b = $p->addBlock($bt, 'Main', $data); $b->setCustomTemplate('blog_post'); $b->setAbsoluteBlockDisplayOrder('1'); $db = Loader::db(); $pTemplate = $db->getOne("SELECT ptComposerFormLayoutSetControlID FROM PageTypeComposerOutputControls WHERE pTemplateID = ? AND ptID = ?", array($p->getPageTemplateID(), $p->getPageTypeID())); if ($pTemplate) { $db->Replace('PageTypeComposerOutputBlocks', array('cID' => $p->getCollectionID(), 'arHandle' => 'Main', 'cbDisplayOrder' => 0, 'ptComposerFormLayoutSetControlID' => $pTemplate, 'bID' => $b->getBlockID()), 'cID', true); } Events::fire('on_problog_submit', $p); $ba = Loader::helper('blog_actions'); $ba->doSubscription($p); $p->reindex(); }
public function skipItem() { $key = false; switch ($this->object->getCategory()) { case 'collection': $key = CollectionKey::getByHandle($this->object->getHandle()); break; case 'file': $key = FileKey::getByHandle($this->object->getHandle()); break; case 'user': $key = UserKey::getByHandle($this->object->getHandle()); break; } return is_object($key); }
public function clear_attribute($ptID = false) { $this->setupPageType($ptID); $sr = new EditResponse(); if (Loader::helper('validation/token')->validate()) { $ak = CollectionKey::getByID(Loader::helper('security')->sanitizeInt($_REQUEST['akID'])); if (is_object($ak)) { $this->defaultPage->clearAttribute($ak); } } else { $this->error->add(Loader::helper('validation/token')->getErrorMessage()); } if ($this->error->has()) { $sr->setError($this->error); } else { $sr->setMessage(t('Attribute cleared successfully.')); } $sr->outputJSON(); }
public function edit() { $this->requireAsset('core/topics'); $tt = new TopicTree(); $defaultTree = $tt->getDefault(); $tree = $tt->getByID(Loader::helper('security')->sanitizeInt($this->topicTreeID)); if (!$tree) { $tree = $defaultTree; } $trees = $tt->getList(); $keys = CollectionKey::getList(); foreach ($keys as $ak) { if ($ak->getAttributeTypeHandle() == 'topics') { $attributeKeys[] = $ak; } } $this->set('attributeKeys', $attributeKeys); $this->set('tree', $tree); $this->set('trees', $trees); }
public function doSubscription() { $c = Page::getByID($_REQUEST['blog']); $ak = CollectionAttributeKey::getByHandle('subscription'); $subscribed = $c->getAttribute('subscription'); $ui = UserInfo::getByID($_REQUEST['user']); $user_removed = false; if ($subscribed) { $subscribers = array(); foreach ($subscribed as $uID) { if ($uID != $_REQUEST['user']) { $subscribers[] = $uID; } else { $user_removed = true; } } } if (!$user_removed) { $subscribers[] = $_REQUEST['user']; } $c->setAttribute($ak, $subscribers); $c->reindex(); exit; }
public function delete($akID = null) { $key = CollectionKey::getByID($akID); $this->executeDelete($key, \URL::to('/dashboard/pages/attributes', 'view')); }
protected function getTemplateHandle() { if (in_array($this->attributeHandle, array_keys($this->getAvailablePageValues()))) { switch ($this->attributeHandle) { case "rpv_pageDateCreated": case 'rpv_pageDateLastModified': case "rpv_pageDatePublic": $templateHandle = 'date_time'; break; } } else { $attributeKey = CollectionAttributeKey::getByHandle($this->attributeHandle); if (is_object($attributeKey)) { $attributeType = $attributeKey->getAttributeType(); $templateHandle = $attributeType->getAttributeTypeHandle(); } } return $templateHandle; }
public function getPages($query = null) { $b = Block::getByID($this->bID); $exclude_list = array('tags', 'categories', 'tag_cloud', 'archive'); $template = strtolower($b->getBlockFilename()); if (!in_array($template, $exclude_list)) { $pl = new ProblogList(); $db = Loader::db(); $bID = $this->bID; if ($this->bID) { $q = "select * from btProBlogList where bID = '{$bID}'"; $r = $db->query($q); if ($r) { $row = $r->fetchRow(); } } else { $row['num'] = $this->num; $row['cParentID'] = $this->cParentID; $row['cThis'] = $this->cThis; $row['orderBy'] = $this->orderBy; $row['ctID'] = $this->ctID; $row['rss'] = $this->rss; $row['category'] = $this->category; $row['title'] = $this->title; $row['paginate'] = $this->paginate; $row['displayAliases'] = $this->displayAliases; $row['subscribe'] = $this->subscribe; $row['rssTitle'] = $this->rssTitle; $row['rssDescription'] = $this->rssDescription; $row['truncateSummaries'] = $this->truncateSummaries; $row['truncateChars'] = $this->truncateChars; $row['use_content'] = $this->use_content; $row['author'] = $this->author; } $cArray = array(); switch ($row['orderBy']) { case 'display_asc': $pl->sortByDisplayOrder(); break; case 'display_desc': $pl->sortByDisplayOrderDescending(); break; case 'chrono_asc': $pl->sortByPublicDateTime(); break; case 'alpha_asc': $pl->sortByName(); break; case 'alpha_desc': $pl->sortByNameDescending(); break; default: $pl->sortByPublicDateDescending(); break; } $num = (int) $row['num']; if ($num > 0) { $pl->setItemsPerPage($num); } $c = Page::getCurrentPage(); if (is_object($c)) { $this->cID = $c->getCollectionID(); } $cParentID = $row['cThis'] ? $this->cID : $row['cParentID']; //$pl->filter(false,"(CHAR_LENGTH(cv.cvName) > 4 OR cv.cvName NOT REGEXP '^[0-9]')"); $pl->filter(false, "ak_is_canonical_page < 1"); $pl->filterByPublicDate(date('Y-m-d H:i:s'), '<='); //filter by publish date Loader::model('attribute/categories/collection'); if ($this->displayFeaturedOnly == 1) { $cak = CollectionAttributeKey::getByHandle('is_featured'); if (is_object($cak)) { $pl->filterByIsFeatured(1); } } if (!$row['displayAliases']) { $pl->filterByIsAlias(0); } $pl->filter('cvName', '', '!='); if ($row['ctID']) { $ctID = $row['ctID']; $pl->filter(false, "p.ptID = {$ctID}"); } $columns = $db->MetaColumns(CollectionAttributeKey::getIndexedSearchTable()); if (isset($columns['AK_EXCLUDE_PAGE_LIST'])) { $pl->filter(false, '(ak_exclude_page_list = 0 or ak_exclude_page_list is null)'); } if (intval($cParentID) != 0) { $path = Page::getByID($cParentID)->getCollectionPath(); $pl->filterByPath($path); } if ($row['author']) { $pl->filterByBlogAuthor($row['author']); } if ($this->category != t('All Categories')) { $selected_cat = explode(', ', $this->category); if ($this->filter_strict > 0) { $condition = ' AND '; } else { $condition = ' OR '; } foreach ($selected_cat as $cat) { $cat = str_replace("'", "\\'", $cat); if ($fi) { $category_filter .= $condition; } $category_filter .= "ak_blog_category LIKE '%\n{$cat}\n%'"; $fi++; } $pl->filter(false, "(" . $category_filter . ")"); } //$pl->debug(); //Pagination... $showPagination = false; if ($this->paginate > 0) { $pagination = $pl->getPagination(); $pages = $pagination->getCurrentPageResults(); if ($pagination->getTotalPages() > 1 && $this->paginate) { $showPagination = true; $pagination = $pagination->renderDefaultView(); $this->set('pagination', $pagination); } } else { $pages = $pl->getResults(); } if ($showPagination) { $this->requireAsset('css', 'core/frontend/pagination'); } $this->set('pl', $pl); } return $pages; }
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'); }
public static function importContent($node) { $db = Loader::db(); $ptHandle = (string) $node['handle']; $ptID = $db->GetOne('select ptID from PageTypes where ptHandle = ?', array($ptHandle)); if ($ptID) { $pt = static::getByID($ptID); $defaultTemplate = $pt->getPageTypeDefaultPageTemplateObject(); if (isset($node->composer->output->pagetemplate)) { $ci = new ContentImporter(); foreach ($node->composer->output->pagetemplate as $pagetemplate) { $handle = (string) $pagetemplate['handle']; $ptt = PageTemplate::getByHandle($handle); if (is_object($ptt)) { // let's get the defaults page for this $xc = $pt->getPageTypePageTemplateDefaultPageObject($ptt); // if the $handle matches the default page template for this page type, then we ALSO check in here // and see if there are any attributes if (is_object($defaultTemplate) && $defaultTemplate->getPageTemplateHandle() == $handle) { if (isset($pagetemplate->page->attributes)) { foreach ($pagetemplate->page->attributes->children() as $attr) { $ak = CollectionKey::getByHandle((string) $attr['handle']); if (is_object($ak)) { $xc->setAttribute((string) $attr['handle'], $ak->getController()->importValue($attr)); } } } } // now that we have the defaults page, let's import this content into it. if (isset($pagetemplate->page)) { $ci->importPageAreas($xc, $pagetemplate->page); } } } } } }
public function get_composer_field() { $db = Loader::db(); $fieldJSON = array(); // product_type field $ak = AttributeCollectionKey::getByHandle('product_type'); $query = $db->GetAll("select * from atSelectOptions where akID = ? ", array($ak->getAttributeKeyID())); $options = array(); foreach ($query as $selectOption) { $key = strtolower($selectOption['value']); $key = str_replace(' ', '_', $key); $selectOption['key'] = $key; $options[$selectOption['ID']] = $selectOption; } $fieldJSON['product_type']['ak'] = $ak; $fieldJSON['product_type']['values'] = $options; // is_virtual field $ak = AttributeCollectionKey::getByHandle('is_virtual'); $fieldJSON['is_virtual']['ak'] = $ak; // is_downloadable field $ak = AttributeCollectionKey::getByHandle('is_downloadable'); $fieldJSON['is_downloadable']['ak'] = $ak; print json_encode($fieldJSON); exit; }
public function publish(CollectionKey $ak, Page $page, AttributeValue $value) { $node = simplexml_load_string($value->getValue()); $page->setAttribute($ak->getAttributeKeyHandle(), $ak->getController()->importValue($node)); }
?> > <?php $page = Loader::helper('form/page_selector'); if ($isOtherPage) { print $page->selectPage('cParentIDValue', $cParentID); } else { print $page->selectPage('cParentIDValue'); } ?> </div> <?php $cadf = CollectionAttributeKey::getByHandle('is_featured'); ?> <br/> <h5><?php echo t('Filter only Featured Posts'); ?> </h5> <div class="input"> <input <?php if (!is_object($cadf)) { ?> disabled <?php } ?> type="checkbox" name="displayFeaturedOnly" value="1" <?php if ($displayFeaturedOnly == 1) {
public function install() { $pkg = parent::install(); // Dashboard Page $sp = SinglePage::add('/dashboard/forums', $pkg); if (is_object($sp)) { $sp->update(array('cName' => t('Forums'), 'cDescription' => t('Forums Dashboard'))); } // Add Sidebar block set BlockTypeSet::add('forums', 'Forums', $pkg); // Add forum moderator user group $forumGroup = Group::getByName('Forum Moderators'); if (!is_object($authorGroup)) { Group::add('Forum Moderators', t('Forum Moderators, delete, edit, approve')); } // install blocks BlockType::installBlockTypeFromPackage('webli_forum_post', $pkg); BlockType::installBlockTypeFromPackage('webli_forum_list', $pkg); BlockType::installBlockTypeFromPackage('webli_forum_search', $pkg); BlockType::installBlockTypeFromPackage('webli_forum_archive', $pkg); BlockType::installBlockTypeFromPackage('webli_forum_tags', $pkg); // Add Collection Attribute Set $akCat = AttributeKeyCategory::getByHandle('collection'); $akCat->setAllowAttributeSets(AttributeKeyCategory::ASET_ALLOW_SINGLE); $akCatSet = $akCat->addSet('forums', t('Forums'), $pkg); // Add Collection Attributes $attribute = CollectionAttributeKey::getByHandle('forum_post'); if (!is_object($attribute)) { $att = AttributeType::getByHandle('textarea'); // add to attribute set CollectionAttributeKey::add($att, array('akHandle' => 'forum_post', 'akName' => t('Forum Post'), 'akIsSearchableIndexed' => true, 'akTextareaDisplayMode' => 'rich_text'), $pkg)->setAttributeSet($akCatSet); } $attribute = CollectionAttributeKey::getByHandle('forum_category'); if (!is_object($attribute)) { $att = AttributeType::getByHandle('boolean'); // add to attribute set CollectionAttributeKey::add($att, array('akHandle' => 'forum_category', 'akName' => t('Forum Category')), $pkg)->setAttributeSet($akCatSet); } $attribute = CollectionAttributeKey::getByHandle('forum_email'); if (!is_object($attribute)) { $att = AttributeType::getByHandle('text'); // add to attribute set CollectionAttributeKey::add($att, array('akHandle' => 'forum_email', 'akName' => t('Forum Email Address'), 'akIsSearchableIndexed' => true), $pkg)->setAttributeSet($akCatSet); } $attribute = CollectionAttributeKey::getByHandle('forum_name'); if (!is_object($attribute)) { $att = AttributeType::getByHandle('text'); // add to attribute set CollectionAttributeKey::add($att, array('akHandle' => 'forum_name', 'akName' => t('Forum Name'), 'akIsSearchableIndexed' => true), $pkg)->setAttributeSet($akCatSet); } $attribute = CollectionAttributeKey::getByHandle('forum_pin'); if (!is_object($attribute)) { $att = AttributeType::getByHandle('boolean'); // add to attribute set CollectionAttributeKey::add($att, array('akHandle' => 'forum_pin', 'akName' => t('Pin Forum Post')), $pkg)->setAttributeSet($akCatSet); } $attribute = CollectionAttributeKey::getByHandle('forum_post_approved'); if (!is_object($attribute)) { $att = AttributeType::getByHandle('boolean'); // add to attribute set CollectionAttributeKey::add($att, array('akHandle' => 'forum_post_approved', 'akName' => t('Forum Post Approved')), $pkg)->setAttributeSet($akCatSet); } $attribute = CollectionAttributeKey::getByHandle('tags'); if (!is_object($attribute)) { $att = AttributeType::getByHandle('select'); // add to attribute set CollectionAttributeKey::add($att, array('akHandle' => 'tags', 'akName' => t('Tags'), 'akIsSearchableIndexed' => true), $pkg)->setAttributeSet($akCatSet); } $attribute = CollectionAttributeKey::getByHandle('forum_image'); if (!is_object($attribute)) { $att = AttributeType::getByHandle('image_file'); // add to attribute set CollectionAttributeKey::add($att, array('akHandle' => 'forum_image', 'akName' => t('Forum Image')), $pkg)->setAttributeSet($akCatSet); $addAttribute = CollectionAttributeKey::getByHandle('forum_image'); } // Add top level Forums Page $forumPage = \Page::getByPath('/forums'); if (!is_object($forumPage) || $forumPage->cID == null) { $parentPage = \Page::getByID(1); $pageType = \PageType::getByHandle('right_sidebar'); $template = \PageTemplate::getByHandle('right_sidebar'); $forumsPage = $parentPage->add($pageType, array('cName' => t('Forums'), 'cDescription' => t('Top Level Forums Page'), 'cHandle ' => 'forums'), $template); //Add forum_category page attribute $forumsPage->setAttribute('forum_category', 1); } // Add top Forum Search Results Page $forumSearchPage = \Page::getByPath('/forum-search'); if (!is_object($forumSearchPage) || $forumSearch->cID == null) { $parentPage = \Page::getByID(1); $pageType = \PageType::getByHandle('right_sidebar'); $template = \PageTemplate::getByHandle('right_sidebar'); $forumSearchPage = $parentPage->add($pageType, array('cName' => t('Forum Search'), 'cDescription' => t('Forum Search Page'), 'cHandle ' => 'forum-search'), $template); $forumSearchPage->setAttribute('exclude_nav', 1); } // Add Forum Post Page Template if (!is_object(PageTemplate::getByHandle('forum_post'))) { $pageTemplate = PageTemplate::add('forum_post', 'Forum Post', 'landing.png', $pkg); } // Add Forum Post Page Type if (!is_object(PageType::getByHandle('forum_post'))) { $data = array('handle' => 'forum_post', 'name' => 'Forum Post', 'ptLaunchInComposer' => true, 'ptIsFrequentlyAdded' => true, 'defaultTemplate' => PageTemplate::getByHandle('forum_post'), 'allowedTemplates' => 'C', 'templates' => array(PageTemplate::getByHandle('forum_post'))); $pt = PageType::add($data, $pkg); } /* Get blog_post page template */ $pageType = \PageType::getByHandle('forum_post'); $ctTemplate = $pageType->getPageTypeDefaultPageTemplateObject(); $forumPostTemplate = $pageType->getPageTypePageTemplateDefaultPageObject($ctTemplate); /* Add Composer Layouts */ $basics = $pageType->addPageTypeComposerFormLayoutSet('Basics', 'Basic Info'); $post = $pageType->addPageTypeComposerFormLayoutSet('Forum Post', 'Forum Post'); /* Add Built in Properties */ $cct = ComposerControlType::getByHandle('core_page_property'); /* Post Title */ $control = $cct->getPageTypeComposerControlByIdentifier('name'); $control->addToPageTypeComposerFormLayoutSet($basics); /* Post Slug */ $control = $cct->getPageTypeComposerControlByIdentifier('url_slug'); $control->addToPageTypeComposerFormLayoutSet($basics); /* Post Publish Location */ $control = $cct->getPageTypeComposerControlByIdentifier('publish_target'); $control->addToPageTypeComposerFormLayoutSet($basics); /* Post Date */ $control = $cct->getPageTypeComposerControlByIdentifier('date_time'); $control->addToPageTypeComposerFormLayoutSet($basics); /* Post Author */ $control = $cct->getPageTypeComposerControlByIdentifier('user'); $control->addToPageTypeComposerFormLayoutSet($basics); /* Add Attributes */ $cct = ComposerControlType::getByHandle('collection_attribute'); /* Forum Pin */ $attributeId = CollectionAttributeKey::getByHandle('forum_pin')->getAttributeKeyID(); $control = $cct->getPageTypeComposerControlByIdentifier($attributeId); $control->addToPageTypeComposerFormLayoutSet($post); /* Forum Post Approved */ $attributeId = CollectionAttributeKey::getByHandle('forum_post_approved')->getAttributeKeyID(); $control = $cct->getPageTypeComposerControlByIdentifier($attributeId); $control->addToPageTypeComposerFormLayoutSet($post); /* Forum Post */ $attributeId = CollectionAttributeKey::getByHandle('forum_post')->getAttributeKeyID(); $control = $cct->getPageTypeComposerControlByIdentifier($attributeId); $control->addToPageTypeComposerFormLayoutSet($post); /* Forum Image */ $attributeId = CollectionAttributeKey::getByHandle('forum_image')->getAttributeKeyID(); $control = $cct->getPageTypeComposerControlByIdentifier($attributeId); $control->addToPageTypeComposerFormLayoutSet($post); /* Forum Tags */ $attributeId = CollectionAttributeKey::getByHandle('tags')->getAttributeKeyID(); $control = $cct->getPageTypeComposerControlByIdentifier($attributeId); $control->addToPageTypeComposerFormLayoutSet($post); /* Add default Blocks to page template */ $ctTemplate = $pageType->getPageTypeDefaultPageTemplateObject(); $forumPostTemplate = $pageType->getPageTypePageTemplateDefaultPageObject($ctTemplate); //Add exclude_nav page attributeto Forum Post Template $forumPostTemplate->setAttribute('exclude_nav', 1); // Get Forum Category Page $forumCategoryPage = Page::getByPath('/forums'); //Add forum_category page attribute $forumCategoryPage->setAttribute('forum_category', 1); // Get Forum Search Page $forumSearchPage = Page::getByPath('/forum-search'); //Add exclude_nav page attribute $forumSearchPage->setAttribute('exclude_nav', 1); // Install Blocks //install Forum Post Block $forumPost = BlockType::getByHandle('webli_forum_post'); $forumPostData = array(); $forumCategoryPage->addBlock($forumPost, 'Main', $forumPostData); //install forum post block to forum_post template $forumPostTemplate->addBlock($forumPost, 'Forum Post', $forumPostData); //install Forum List Block on Forums top level page $forumList = BlockType::getByHandle('webli_forum_list'); $forumListData = array(); $forumListData['num'] = 25; $forumListData['paginate'] = 1; $forumListData['cParentID'] = $forumCategoryPage->getCollectionID(); $forumListData['orderBy'] = 'chrono_desc'; $forumListData['use_content'] = 1; $forumListData['truncateSummaries'] = 1; $forumListData['truncateChars'] = 200; $forumListData['display_author'] = 1; $forumListData['includeDate'] = 1; $forumListData['includeName'] = 1; $forumListData['includeDescription'] = 1; $forumListData['date_format'] = 'l F j, Y g:ia'; $forumListData['forum_pin'] = 1; $forumListData['forumReplies'] = 3; $forumListData['thumb_width'] = 250; $forumListData['thumb_height'] = 150; $forumListData['crop'] = 1; $forumListData['noResultsMessage'] = 'No Forum Posts available to view.'; $forumCategoryPage->addBlock($forumList, 'Main', $forumListData); // Install Forum Search Block on forum_post Page template $forumSearch = BlockType::getByHandle('webli_forum_search'); $forumSearchData = array(); $forumSearchData['title'] = 'Forum Search'; $forumSearchData['postTo_cID'] = $forumSearchPage->getCollectionID(); $forumSearchData['baseSearchPath'] = 'PARENT'; $forumPostTemplate->addBlock($forumSearch, 'Sidebar', $forumSearchData); //install Forum Search Block Forums forum_category Page $forumSearchData = array(); $forumSearchData['title'] = 'Forum Search'; $forumSearchData['postTo_cID'] = $forumSearchPage->getCollectionID(); $forumSearchData['baseSearchPath'] = $forumCategoryPage->getCollectionPath(); $forumCategoryPage->addBlock($forumSearch, 'Sidebar', $forumSearchData); //install Forum Search Block on Forum Search Page $forumSearchData = array(); $forumSearchData['title'] = 'Forum Search'; $forumSearchData['buttonText'] = 'Search'; $forumSearchData['baseSearchPath'] = $forumCategoryPage->getCollectionPath(); $forumSearchPage->addBlock($forumSearch, 'Main', $forumSearchData); //install Forum Archive Block on forum_post template $forumArchive = BlockType::getByHandle('webli_forum_archive'); $forumArchiveData = array(); $forumArchiveData['title'] = 'Forum Archive'; $forumArchiveData['cParentID'] = 'PARENT'; $forumPostTemplate->addBlock($forumArchive, 'Sidebar', $forumArchiveData); //install Forum Archive Block $forumArchiveData = array(); $forumArchiveData['title'] = 'Forum Archive'; $forumArchiveData['cParentID'] = $forumCategoryPage->getCollectionID(); $forumCategoryPage->addBlock($forumArchive, 'Sidebar', $forumArchiveData); $forumSearchPage->addBlock($forumArchive, 'Sidebar', $forumArchiveData); //install Forum Tags Block on forum_post template $forumTags = BlockType::getByHandle('webli_forum_tags'); $forumTagsData = array(); $forumTagsData['title'] = 'Forum Tags'; $forumTagsData['cParentID'] = 'PARENT'; $forumTagsData['postTo_cID'] = $forumSearchPage->getCollectionID(); $forumTagsData['baseSearchPath'] = $forumCategoryPage->getCollectionPath(); $forumTagsData['min_height'] = 15; $forumTagsData['max_height'] = 30; $forumPostTemplate->addBlock($forumTags, 'Sidebar', $forumTagsData); //install Forum Tags Block $forumTagsData = array(); $forumTagsData['title'] = 'Forum Tags'; $forumTagsData['cParentID'] = $forumCategoryPage->getCollectionID(); $forumTagsData['postTo_cID'] = $forumSearchPage->getCollectionID(); $forumTagsData['baseSearchPath'] = $forumCategoryPage->getCollectionPath(); $forumTagsData['min_height'] = 15; $forumTagsData['max_height'] = 30; $forumCategoryPage->addBlock($forumTags, 'Sidebar', $forumTagsData); $forumSearchPage->addBlock($forumTags, 'Sidebar', $forumTagsData); //install Conversations block to forum_post template $conversations = BlockType::getByHandle('core_conversation'); $conversationsData = array(); $conversationsData['attachmentsEnabled'] = 0; $conversationsData['addMessageLabel'] = t('Add a Comment'); $conversationsData['itemsPerPage'] = 25; $conversationsData['enablePosting'] = 1; $conversationsData['enableCommentRating'] = 1; $conversationsData['paginate'] = 1; $conversationsData['displayMode'] = 'threaded'; $conversationsData['displayPostingForm'] = 'bottom'; $forumPostTemplate->addBlock($conversations, 'Forum Replies', $conversationsData); $db = Loader::db(); // insert default page category values $db->Execute('insert into btWebliForums ( cID, display_title, display_author, display_date, date_format, display_tags, enable_comments, enable_breadcrumb, crop_image, display_image, image_height, image_width, display_avatars, forum_search_block, forum_archive_block, forum_tags_block, rich_text, page_template, page_type ) values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)', array(0, 1, 1, 1, 'l F j, Y g:ia', 1, 1, 1, 0, 1, 350, 250, 1, 1, 1, 1, 1, $pageTemplate->getPageTemplateID(), $pageType->getPageTypeID())); // Add Sample Forum Post $forumsPage = \Page::getByPath('/forums'); if (is_object($forumsPage) || $forumsPage->cID != null) { $pageType = \PageType::getByHandle('forum_post'); $template = \PageTemplate::getByHandle('forum_post'); $samplePost = $forumsPage->add($pageType, array('cName' => 'My First Forum Post', 'cDescription' => 'First Forum Post', 'cHandle ' => 'first-forum-post'), $template); $samplePost->setAttribute('forum_post', t(' <p>Hey, Congratulations, you have installed Forums for Concrete5. Forums will give visitors to your site frontend editing capabilities to add Forum Messages and reply to existing messages.</p> <p>Administrators have access to the Forums Dashboard Page to customize and manage your forums.</p> <p>So get your forum started and if you have any comments or questions visit <a href="http://forums.webli.us" target="_blank">forums.webli.us</a></p>')); $samplePost->setAttribute('forum_post_approved', 1); $samplePost->setAttribute('tags', array('Forums', t('Frist Message'))); } $cms = Core::make('app'); $cms->clearCaches(); }
function new_forum_post() { $vf = Loader::helper('validation/form'); $vf->setData($_POST['ccm_token']); $vf->addRequiredToken('new_forum_post'); if ($vf->test()) { $th = Core::make('helper/text'); $parentPage = Page::getByID($_POST['category']); $pageType = PageType::getByHandle('forum_post'); $template = PageTemplate::getByHandle('forum_post'); $u = new User(); // if user not loggged in make admin page owner if ($u->isLoggedIn()) { $owner = $u->getUserID(); } else { $owner = 1; } // Add new page to site $newPage = $parentPage->add($pageType, array('cName' => $_POST['title'], 'cDescription' => $th->makenice($_POST['description']), 'cHandle ' => $th->sanitizeFileSystem($_POST['title'], $leaveSlashes = false), 'uID' => $_POST['user'], 'cDatePublic' => $_POST['public_date']), $template); if ($_POST['forumPost']) { $newPage->setAttribute('forum_post', $_POST['forumPost']); } if ($_POST['forumImage']) { $newPage->setAttribute('forum_image', $_POST['forumImage']); } if ($_POST['pin']) { $newPage->setAttribute('forum_pin', $_POST['pin']); } $newPage->setAttribute('forum_post_approved', 1); // save tags $ak = CollectionAttributeKey::getByHandle('tags'); $ak->saveAttributeForm($newPage); $newPage->reindex(); } else { die("Access Denied."); } $this->redirect($newPage->getCollectionPath()); }
public function do_search() { $request = Request::getInstance(); $query = (string) $request->request('query'); $ipl = new PageList(); $aksearch = false; $akIDs = $request->request('akID'); if (is_array($akIDs)) { foreach ($akIDs as $akID => $req) { $fak = CollectionAttributeKey::getByID($akID); if (is_object($fak)) { $type = $fak->getAttributeType(); $cnt = $type->getController(); $cnt->setAttributeKey($fak); $cnt->searchForm($ipl); $aksearch = true; } } } if ($request->request('month') !== null && $request->request('year') !== null) { $year = @intval($request->request('year')); $month = abs(@intval($request->request('month'))); if (strlen(abs($year)) < 4) { $year = ($year < 0 ? '-' : '') . str_pad($year, 4, '0', STR_PAD_LEFT); } if ($month < 12) { $month = str_pad($month, 2, '0', STR_PAD_LEFT); } $daysInMonth = date('t', strtotime("{$year}-{$month}-01")); $dh = Core::make('helper/date'); /* @var $dh \Concrete\Core\Localization\Service\Date */ $start = $dh->toDB("{$year}-{$month}-01 00:00:00", 'user'); $end = $dh->toDB("{$year}-{$month}-{$daysInMonth} 23:59:59", 'user'); $ipl->filterByPublicDate($start, '>='); $ipl->filterByPublicDate($end, '<='); $aksearch = true; } if ($query === '' && $aksearch === false) { return false; } if ($query !== '') { $ipl->filterByKeywords($query); } $search_paths = $request->request('search_paths'); if (is_array($search_paths)) { foreach ($search_paths as $path) { if ($path === '') { continue; } $ipl->filterByPath($path); } } elseif ($this->baseSearchPath != '') { $ipl->filterByPath($this->baseSearchPath); } $cak = CollectionKey::getByHandle('exclude_search_index'); if (is_object($cak)) { $ipl->filterByExcludeSearchIndex(false); } $pagination = $ipl->getPagination(); $results = $pagination->getCurrentPageResults(); $this->set('query', $query); $this->set('results', $results); $this->set('do_search', true); $this->set('searchList', $ipl); $this->set('pagination', $pagination); }
public static function getCollectionSelectValues($attrHandle = '') { // Loader::model('attribute/type'); // Loader::model('attribute/categories/collection'); $ak = CollectionAttributeKey::getByHandle($attrHandle); $satc = new SelectAttributeTypeController(AttributeType::getByHandle('select')); $satc->setAttributeKey($ak); return $satc->getOptions(); }
public function loadData() { $this->requireAsset('core/express'); $r = $this->entityManager->getRepository('Concrete\\Core\\Entity\\Express\\Entity'); $entityObjects = $r->findAll(); $entities = array('' => t("** Choose Entity")); foreach ($entityObjects as $entity) { $entities[$entity->getID()] = $entity->getName(); } $this->set('entities', $entities); $keys = CollectionKey::getList(); foreach ($keys as $ak) { if ($ak->getAttributeTypeHandle() == 'express') { $attributeKeys[] = $ak; } } $this->set('expressAttributes', $attributeKeys); }
protected function loadKeys() { $attributeKeys = array(); $keys = CollectionKey::getList(array('atHandle' => 'topics')); foreach ($keys as $ak) { if ($ak->getAttributeTypeHandle() == 'topics') { $attributeKeys[] = $ak; } } $this->set('attributeKeys', $attributeKeys); }
private function parseSearchPath($filter = null, $val = null) { if ($filter && $val) { $category = $val; } else { $tag = $filter; } $c = Page::getCurrentPage(); if ($category) { $metaT = t('Blog Search Categories') . ' - ' . $category; $metaD = t('Blog categories search result for ') . $category; $this->set('category', $category); } else { $metaT = t('Blog Search Tags') . ' - ' . $tag; $metaD = t('Blog tags search result for ') . $tag; $this->set('tag', $tag); } $mtitle = CollectionAttributeKey::getByHandle('meta_title'); $c->setAttribute($mtitle, $metaT); $mdesc = CollectionAttributeKey::getByHandle('meta_description'); $c->setAttribute($mdesc, $metaD); $blogify = Loader::helper('blogify'); $refered = str_replace(BASE_URL, '', str_replace('/index.php', '', $_SERVER['HTTP_REFERER'])); $rp = Page::getByPath($refered); if ($rp) { $parent = $blogify->getCanonicalParent(null, $rp); $_REQUEST['search_paths'][] = Page::getByID($parent)->getCollectionPath(); } $blog_settings = $blogify->getBlogSettings(); $path = Loader::helper('navigation')->getLinkToCollection(Page::getByID($blog_settings['search_path'])); if ($category != '') { $category = str_replace('_', ' ', $category); $ak = CollectionAttributeKey::getByHandle('blog_category'); $akID = $ak->getAttributeKeyID(); $akc = $ak->getController(); $options = $akc->getOptions(); if (is_object($options)) { foreach ($options as $option) { if ($option == $category) { $url = $path . '?akID[' . $akID . '][atSelectOptionID][]=' . $option->ID; if ($blog_settings['search_path'] == $c->getCollectionID()) { $_REQUEST['akID'][$akID]['atSelectOptionID'][] = $option->ID; $_REQUEST['query'] = $category; } else { $this->redirect($url); } } } } } elseif (substr_count($_SERVER["REQUEST_URI"], 'atSelectOptionID') < 1) { $tag = str_replace('_', ' ', $tag); $ak = CollectionAttributeKey::getByHandle('tags'); $akID = $ak->getAttributeKeyID(); $akc = $ak->getController(); $options = $akc->getOptions(); if (is_object($options)) { foreach ($options as $option) { if ($option == $tag) { $url = $path . '?akID[' . $akID . '][atSelectOptionID][]=' . $option->ID; if ($blog_settings['search_path'] == $c->getCollectionID()) { $_REQUEST['akID'][$akID]['atSelectOptionID'][] = $option->ID; $_REQUEST['query'] = $tag; } else { $this->redirect($url); } } } } } }
public function add() { $pageTypes = array('' => t('** No Filtering')); $types = Type::getList(); foreach ($types as $type) { $pageTypes[$type->getPageTypeID()] = $type->getPageTypeDisplayName(); } $this->set('pageTypes', $pageTypes); $attributeKeys = array(); $keys = CollectionKey::getList(); foreach ($keys as $ak) { if ($ak->getAttributeTypeHandle() == 'topics') { $attributeKeys[] = $ak; } } $this->set('topicAttributes', $attributeKeys); $areas = Area::getHandleList(); $select = array(); foreach ($areas as $handle) { $select[$handle] = $handle; } $this->set('areas', $select); $this->requireAsset('core/topics'); }