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();
         }
     }
 }
Exemplo n.º 2
0
 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);
 }
Exemplo n.º 3
0
 public function view()
 {
     $c = \Page::getCurrentPage();
     if ($this->entryMode == 'A') {
         $ak = CollectionKey::getByHandle($this->exEntryAttributeKeyHandle);
         if (is_object($ak)) {
             $settings = $ak->getAttributeKeySettings();
             $value = $c->getAttribute($ak);
             if (is_object($settings)) {
                 $this->set('entity', $settings->getEntity());
             }
             if (is_object($value)) {
                 $this->set('entry', $value->getSelectedEntries()[0]);
             }
         }
     } else {
         $entity = $this->entityManager->find('Concrete\\Core\\Entity\\Express\\Entity', $this->exEntityID);
         if (is_object($entity)) {
             $this->set('entity', $entity);
             if ($this->entryMode == 'S' && $this->exSpecificEntryID) {
                 $this->set('entry', Express::getEntry($this->exSpecificEntryID));
             }
         }
     }
     $form = $this->entityManager->find('Concrete\\Core\\Entity\\Express\\Form', $this->exFormID);
     $renderer = $this->app->make('Concrete\\Core\\Express\\Form\\StandardViewRenderer', ['form' => $form]);
     $this->set('renderer', $renderer);
 }
 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));
                     }
                 }
             }
         }
     }
 }
Exemplo n.º 5
0
 /**
  * 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;
     }
 }
 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);
     }
 }
Exemplo n.º 7
0
 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);
 }
Exemplo n.º 9
0
 public function on_start()
 {
     $this->list = new PageList();
     $this->list->disableAutomaticSorting();
     //$pl->setNameSpace('b' . $this->bID);
     $cArray = array();
     $c = Page::getCurrentPage();
     if (is_object($c)) {
         $this->cID = $c->getCollectionID();
     }
     if ($this->displayAliases) {
         $this->list->includeAliases();
     }
     $this->list->filter('cvName', '', '!=');
     if ($this->ptID) {
         $this->list->filterByPageTypeID($this->ptID);
     }
     if ($this->filterByRelated) {
         $ak = CollectionKey::getByHandle($this->relatedTopicAttributeKeyHandle);
         if (is_object($ak)) {
             $topics = $c->getAttribute($ak->getAttributeKeyHandle());
             if (count($topics) > 0 && is_array($topics)) {
                 $topic = $topics[array_rand($topics)];
                 $this->list->filter('p.cID', $c->getCollectionID(), '<>');
                 $this->list->filterByTopic($topic);
             }
         }
     }
     $db = Database::connection();
     $columns = $db->MetaColumnNames(CollectionAttributeKey::getDefaultIndexedSearchTable());
     if (in_array('ak_exclude_page_list', $columns)) {
         $this->list->filter(false, '(ak_exclude_page_list = 0 or ak_exclude_page_list is null)');
     }
     if (intval($this->cParentID) != 0) {
         $cParentID = $this->cThis ? $this->cID : $this->cParentID;
         $this->list->filterByPath(Page::getByID($cParentID)->getCollectionPath());
     }
     if ($this->parent) {
         $parentPage = Page::getByID($c->getCollectionParentID());
         $this->list->filterByParentID($parentPage->getCollectionID());
     }
     //$this->list->filterByAttribute('forum_category', 1, '!=');
     $this->list->filterByAttribute('forum_post_approved', 1, '=');
     $this->list->sortByPublicDateDescending();
     return $this->list;
 }
Exemplo n.º 10
0
 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;
 }
Exemplo n.º 11
0
 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;
 }
Exemplo n.º 12
0
 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');
 }
Exemplo n.º 14
0
 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);
                     }
                 }
             }
         }
     }
 }
Exemplo n.º 15
0
 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);
                     }
                 }
             }
         }
     }
 }
Exemplo n.º 16
0
<?php

defined('C5_EXECUTE') or die(_("Access Denied."));
use Concrete\Package\Problog\Attribute\Select\SelectBlog;
use Concrete\Core\Attribute\Type as AttributeType;
use Concrete\Core\Attribute\Key\CollectionKey as CollectionAttributeKey;
if ($title != '') {
    echo '<h3>' . t($title) . '</h3>';
}
?>
    <div class="ccm-page-list">

    <?php 
$tagCounts = array();
$ak = CollectionAttributeKey::getByHandle('blog_category');
$akc = new SelectBlog(AttributeType::getByHandle('select'));
$akc->setAttributeKey($ak);
$ttags = $akc->getOptionUsageArray($pp);
$tags = array();
foreach ($ttags as $t) {
    $tagCounts[] = $t->getSelectAttributeOptionUsageCount();
    $tags[] = $t;
}
shuffle($tags);
for ($i = 0; $i < $ttags->count(); $i++) {
    $akct = $tags[$i];
    //$qs = $akc->field('atSelectOptionID') . '[]=' . $akct->getSelectAttributeOptionID();
    echo '<a href="' . $search . 'categories/' . rawurlencode(str_replace(' ', '_', $akct->getSelectAttributeOptionValue())) . '/">' . $akct->getSelectAttributeOptionValue() . ' (' . $akct->getSelectAttributeOptionUsageCount() . ')</a><br/>';
}
?>
</div><br/>
 public function configurePackage($pkg)
 {
     $theme = Theme::getByHandle('worldskills');
     if (!is_object($theme)) {
         $theme = Theme::add('worldskills', $pkg);
     }
     // add skill ID attribute
     $attributeKey = CollectionAttributeKey::getByHandle('worldskills_skill_id');
     if (!is_object($attributeKey)) {
         $type = AttributeType::getByHandle('text');
         $args = array('akHandle' => 'worldskills_skill_id', 'akName' => t('Skill ID'), 'akIsSearchable' => 1, 'akIsSearchableIndexed' => 1);
         CollectionAttributeKey::add($type, $args, $pkg);
     }
     // add skill page type
     $pageType = \PageType::getByHandle('worldskills_skill');
     if (!is_object($pageType)) {
         $template = \PageTemplate::getByHandle('full');
         \PageType::add(array('handle' => 'worldskills_skill', 'name' => 'Skill', 'defaultTemplate' => $template, 'allowedTemplates' => 'C', 'templates' => array($template), 'ptLaunchInComposer' => 0, 'ptIsFrequentlyAdded' => 0), $pkg)->setConfiguredPageTypePublishTargetObject(new PageTypePublishTargetAllConfiguration(PageTypePublishTargetAllType::getByHandle('all')));
     }
     // add member ID attribute
     $attributeKey = CollectionAttributeKey::getByHandle('worldskills_member_id');
     if (!is_object($attributeKey)) {
         $type = AttributeType::getByHandle('text');
         $args = array('akHandle' => 'worldskills_member_id', 'akName' => t('Member ID'), 'akIsSearchable' => 1, 'akIsSearchableIndexed' => 1);
         CollectionAttributeKey::add($type, $args, $pkg);
     }
     // add member page type
     $pageType = \PageType::getByHandle('worldskills_member');
     if (!is_object($pageType)) {
         $template = \PageTemplate::getByHandle('full');
         \PageType::add(array('handle' => 'worldskills_member', 'name' => 'Member', 'defaultTemplate' => $template, 'allowedTemplates' => 'C', 'templates' => array($template), 'ptLaunchInComposer' => 0, 'ptIsFrequentlyAdded' => 0), $pkg)->setConfiguredPageTypePublishTargetObject(new PageTypePublishTargetAllConfiguration(PageTypePublishTargetAllType::getByHandle('all')));
     }
     // add skill block
     $blockType = \BlockType::getByHandle('worldskills_skill');
     if (!is_object($blockType)) {
         \BlockType::installBlockTypeFromPackage('worldskills_skill', $pkg);
     }
     // add skill list block
     $blockType = \BlockType::getByHandle('worldskills_skill_list');
     if (!is_object($blockType)) {
         \BlockType::installBlockTypeFromPackage('worldskills_skill_list', $pkg);
     }
     // add people block
     $blockType = \BlockType::getByHandle('worldskills_people');
     if (!is_object($blockType)) {
         \BlockType::installBlockTypeFromPackage('worldskills_people', $pkg);
     }
     // add member block
     $blockType = \BlockType::getByHandle('worldskills_member');
     if (!is_object($blockType)) {
         \BlockType::installBlockTypeFromPackage('worldskills_member', $pkg);
     }
     // add member list block
     $blockType = \BlockType::getByHandle('worldskills_member_list');
     if (!is_object($blockType)) {
         \BlockType::installBlockTypeFromPackage('worldskills_member_list', $pkg);
     }
     try {
         $authenticationType = AuthenticationType::getByHandle('worldskills');
     } catch (\Exception $e) {
         $authenticationType = AuthenticationType::add('worldskills', 'WorldSkills Auth', 0, $pkg);
         $authenticationType->disable();
     }
     $page = \SinglePage::add('/dashboard/system/basics/worldskills', $pkg);
     if (is_object($pag)) {
         $page->updateCollectionName('WorldSkills');
     }
     \Config::save('worldskills.api_url', \Config::get('worldskills.api_url', 'https://api.worldskills.org'));
     \Config::save('worldskills.authorize_url', \Config::get('worldskills.authorize_url', 'https://auth.worldskills.org'));
 }
Exemplo n.º 18
0
 public function on_start()
 {
     $this->list = new PageList();
     $this->list->disableAutomaticSorting();
     //$pl->setNameSpace('b' . $this->bID);
     $cArray = array();
     switch ($this->orderBy) {
         case 'display_asc':
             $this->list->sortByDisplayOrder();
             break;
         case 'display_desc':
             $this->list->sortByDisplayOrderDescending();
             break;
         case 'chrono_asc':
             $this->list->sortByPublicDate();
             break;
         case 'random':
             $this->list->sortBy('RAND()');
             break;
         case 'alpha_asc':
             $this->list->sortByName();
             break;
         case 'alpha_desc':
             $this->list->sortByNameDescending();
             break;
         default:
             $this->list->sortByPublicDateDescending();
             break;
     }
     $c = Page::getCurrentPage();
     if (is_object($c)) {
         $this->cID = $c->getCollectionID();
     }
     if ($this->displayFeaturedOnly == 1) {
         $cak = CollectionAttributeKey::getByHandle('is_featured');
         if (is_object($cak)) {
             $this->list->filterByIsFeatured(1);
         }
     }
     if ($this->displayAliases) {
         $this->list->includeAliases();
     }
     $this->list->filter('cvName', '', '!=');
     if ($this->ptID) {
         $this->list->filterByPageTypeID($this->ptID);
     }
     if ($this->filterByRelated) {
         $ak = CollectionKey::getByHandle($this->relatedTopicAttributeKeyHandle);
         if (is_object($ak)) {
             $topics = $c->getAttribute($ak->getAttributeKeyHandle());
             if (count($topics) > 0 && is_array($topics)) {
                 $topic = $topics[array_rand($topics)];
                 $this->list->filter('p.cID', $c->getCollectionID(), '<>');
                 $this->list->filterByTopic($topic);
             }
         }
     }
     if ($this->filterByCustomTopic) {
         $this->list->filterByTopic(intval($this->customTopicTreeNodeID));
     }
     $db = Loader::db();
     $columns = $db->MetaColumnNames(CollectionAttributeKey::getIndexedSearchTable());
     if (in_array('ak_exclude_page_list', $columns)) {
         $this->list->filter(false, '(ak_exclude_page_list = 0 or ak_exclude_page_list is null)');
     }
     if (intval($this->cParentID) != 0) {
         $cParentID = $this->cThis ? $this->cID : $this->cParentID;
         if ($this->includeAllDescendents) {
             $this->list->filterByPath(Page::getByID($cParentID)->getCollectionPath());
         } else {
             $this->list->filterByParentID($cParentID);
         }
     }
     return $this->list;
 }
Exemplo n.º 19
0
 public function getTargetItemContentObject(TargetItemInterface $targetItem)
 {
     return CollectionKey::getByHandle($targetItem->getItemID());
 }
Exemplo n.º 20
0
 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();
 }
Exemplo n.º 21
0
 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());
 }
Exemplo n.º 22
0
 public function renderCollectionField($handle, $cID)
 {
     $u = new User();
     $page = Page::getByID($cID);
     $fieldValue = false;
     $field = AttributeCollectionKey::getByHandle($handle);
     $fieldValue = $page->getAttributeValueObject($field);
     print $field->render('form', $fieldValue, true);
 }
Exemplo n.º 23
0
?>
>

				<?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) {
Exemplo n.º 24
0
 public function getAttributeValueObject($ak, $createIfNotExists = false)
 {
     if (!is_object($ak)) {
         $ak = CollectionKey::getByHandle($ak);
     }
     $value = false;
     if (is_object($ak)) {
         $value = $this->getObjectAttributeCategory()->getAttributeValue($ak, $this);
     }
     if ($value) {
         return $value;
     } elseif ($createIfNotExists) {
         $attributeValue = new PageValue();
         $attributeValue->setPageID($this->getCollectionID());
         $attributeValue->setVersionID($this->getVersionID());
         $attributeValue->setAttributeKey($ak);
         return $attributeValue;
     }
 }
Exemplo n.º 25
0
 public function on_start()
 {
     $this->list = new PageList();
     $this->list->disableAutomaticSorting();
     //$pl->setNameSpace('b' . $this->bID);
     $cArray = array();
     switch ($this->orderBy) {
         case 'display_asc':
             $this->list->sortByDisplayOrder();
             break;
         case 'display_desc':
             $this->list->sortByDisplayOrderDescending();
             break;
         case 'chrono_asc':
             $this->list->sortByPublicDate();
             break;
         case 'random':
             $this->list->sortBy('RAND()');
             break;
         case 'alpha_asc':
             $this->list->sortByName();
             break;
         case 'alpha_desc':
             $this->list->sortByNameDescending();
             break;
         default:
             $this->list->sortByPublicDateDescending();
             break;
     }
     $today = date('Y-m-d');
     $end = $start = null;
     switch ($this->filterDateOption) {
         case 'now':
             $start = "{$today} 00:00:00";
             $end = "{$today} 23:59:59";
             break;
         case 'past':
             $end = "{$today} 23:59:59";
             if ($this->filterDateDays > 0) {
                 $past = date('Y-m-d', strtotime("-{$this->filterDateDays} days"));
                 $start = "{$past} 00:00:00";
             }
             break;
         case 'future':
             $start = "{$today} 00:00:00";
             if ($this->filterDateDays > 0) {
                 $future = date('Y-m-d', strtotime("+{$this->filterDateDays} days"));
                 $end = "{$future} 23:59:59";
             }
             break;
         case 'between':
             $start = "{$this->filterDateStart} 00:00:00";
             $end = "{$this->filterDateEnd} 23:59:59";
             break;
         case 'all':
         default:
             break;
     }
     if ($start) {
         $this->list->filterByPublicDate($start, '>=');
     }
     if ($end) {
         $this->list->filterByPublicDate($end, '<=');
     }
     $c = Page::getCurrentPage();
     if (is_object($c)) {
         $this->cID = $c->getCollectionID();
     }
     if ($this->displayFeaturedOnly == 1) {
         $cak = CollectionAttributeKey::getByHandle('is_featured');
         if (is_object($cak)) {
             $this->list->filterByIsFeatured(1);
         }
     }
     if ($this->displayAliases) {
         $this->list->includeAliases();
     }
     $this->list->filter('cvName', '', '!=');
     if ($this->ptID) {
         $this->list->filterByPageTypeID($this->ptID);
     }
     if ($this->filterByRelated) {
         $ak = CollectionKey::getByHandle($this->relatedTopicAttributeKeyHandle);
         if (is_object($ak)) {
             $topics = $c->getAttribute($ak->getAttributeKeyHandle());
             if (count($topics) > 0 && is_array($topics)) {
                 $topic = $topics[array_rand($topics)];
                 $this->list->filter('p.cID', $c->getCollectionID(), '<>');
                 $this->list->filterByTopic($topic);
             }
         }
     }
     if ($this->filterByCustomTopic) {
         $this->list->filterByTopic(intval($this->customTopicTreeNodeID));
     }
     $db = Database::connection();
     $columns = $db->MetaColumnNames(CollectionAttributeKey::getDefaultIndexedSearchTable());
     if (in_array('ak_exclude_page_list', $columns)) {
         $this->list->filter(false, '(ak_exclude_page_list = 0 or ak_exclude_page_list is null)');
     }
     if (intval($this->cParentID) != 0) {
         $cParentID = $this->cThis ? $this->cID : $this->cParentID;
         if ($this->includeAllDescendents) {
             $this->list->filterByPath(Page::getByID($cParentID)->getCollectionPath());
         } else {
             $this->list->filterByParentID($cParentID);
         }
     }
     return $this->list;
 }
Exemplo n.º 26
0
 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;
 }
Exemplo n.º 27
0
 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);
 }
Exemplo n.º 28
0
 protected function validate()
 {
     $vt = Loader::helper('validation/strings');
     $vn = Loader::Helper('validation/numbers');
     $dt = Loader::helper("form/date_time");
     if (!$vn->integer($this->post('cParentID'))) {
         $this->error->add(t('You must choose a parent page for this blog entry.'));
     }
     if (!$vt->notempty($this->post('blogTitle'))) {
         $this->error->add(t('Title is required'));
     }
     if (!$this->get('sections')) {
         $this->error->add(t('You must have at least one page in your website designated as a "blog section".'));
     }
     Loader::model("attribute/categories/collection");
     $akct = CollectionAttributeKey::getByHandle('blog_category');
     $ctKey = $akct->getAttributeKeyID();
     foreach ($this->post(akID) as $key => $value) {
         if ($key == $ctKey) {
             foreach ($value as $type => $values) {
                 if ($type == 'atSelectNewOption') {
                     foreach ($values as $cat => $valued) {
                         if ($valued == '') {
                             $this->error->add(t('Categories must have a value'));
                         }
                     }
                 }
             }
         }
     }
     if (!$this->error->has()) {
         $parent = Page::getByID($this->post('cParentID'));
         $cmp = new \Permissions($parent);
         $parentPermissions = $cmp->canAddSubpage();
         if (!$parentPermissions) {
             $this->error->add(t('You do not have permission to add a page of that type to that area of the site.'));
         }
     }
 }
Exemplo n.º 29
0
    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();
    }
Exemplo n.º 30
0
 public function getBlogVars($c)
 {
     Loader::model("attribute/categories/collection");
     //load settings
     $blog_settings = static::getBlogSettings();
     //set search path
     $vars['search'] = Loader::helper('navigation')->getLinkToCollection(Page::getByPath('/blogsearch')) . '/';
     //link url to page
     $vars['url'] = Loader::helper('navigation')->getLinkToCollection($c);
     //this pages collection ID
     $vars['cID'] = $c->getCollectionID();
     //set user
     $vars['u'] = new User();
     //get post title
     $vars['blogTitle'] = $c->getCollectionName();
     //get post public date
     $vars['blogDate'] = $c->getCollectionDatePublic();
     //get author
     $vars['authorID'] = $c->getAttribute('blog_author');
     if (!$vars['$authorID']) {
         $vars['authorID'] = $c->getCollectionUserID();
     }
     //if editing via page_type defaults, set bogus author
     if (!$vars['$authorID']) {
         $vars['authorID'] = '1';
     }
     //grab the user info object
     $vars['ui'] = UserInfo::getByID($vars['authorID']);
     //get tags
     $vars['tags'] = $c->getAttribute('tags');
     $ak_t = CollectionAttributeKey::getByHandle('tags');
     $vars['tag_list'] = $c->getCollectionAttributeValue($ak_t);
     //get category
     $vars['cat'] = $c->getAttribute('blog_category');
     //comment count
     $vars['comment_count'] = static::getNewCommentCount($c->getCollectionID());
     //thumbnail image
     $imgHelper = Loader::helper('image');
     $thumb = $c->getAttribute('thumbnail');
     $vars['thumb'] = $thumb;
     if ($thumb) {
         $vars['image'] = $imgHelper->getThumbnail($thumb, $blog_settings['thumb_width'], $blog_settings['thumb_height'])->src;
     }
     $vars['prev_link'] = $this->getPrevPost($c);
     $vars['next_link'] = $this->getNextPost($c);
     return $vars;
 }