public function form() { Loader::model('page_list'); $pl = new PageList(); $lastParent = ''; $selected = $_REQUEST['akID'][$this->getAttributeKey()->getAttributeKeyID()]['value']; if (!$selected && $this->getAttributeValueID() > 0) { $selected = $this->getValue()->cID; } $selectString = "<select id='{$this->field('value')}' name='{$this->field('value')}' ><option value=''>--</option>"; $pl->filterByCollectionTypeHandle('city'); $pages = $pl->get(); uasort($pages, function ($a, $b) { $ap = $a->getCollectionParentID(); $bp = $b->getCollectionParentID(); return $ap === $bp ? 0 : strcmp(Page::getByID($ap)->getCollectionName(), Page::getByID($bp)->getCollectionName()); }); foreach ($pages as $page) { $parent = Page::getByID($page->getCollectionParentID())->getCollectionName(); if ($lastParent != $parent) { if ($lastParent !== '') { $selectString .= '</optgroup>'; } $selectString .= "<optgroup label='{$parent}'>"; $lastParent = $parent; } $selectedAttributeVal = ''; if ($selected === $page->cID) { $selectedAttributeVal = ' selected="selected"'; } $selectString .= "<option value=\"{$page->getCollectionID()}\"" . $selectedAttributeVal . ">{$page->getCollectionName()}</option>"; } $selectString .= '</select>'; echo $selectString; }
public function run() { $js = Loader::helper('json'); $pl = new PageList(); $pl->filterByCollectionTypeHandle('city'); $pages = $pl->get(); $updated = 0; $not = 0; echo "Loading city coordinates.. \n"; foreach ($pages as $page) { if (!trim($page->getAttribute('latlng')) || trim($page->getAttribute('latlng')) === ',') { $parent = Page::getByID($page->getCollectionParentID()); $city = "{$page->getCollectionName()}, {$parent->getCollectionName()}"; $cityLocation = file_get_contents("https://maps.google.com/maps/api/geocode/json?address=" . urlencode($city) . "&sensor=false&key=AIzaSyAvsH_wiFHJCuMPPuVifJ7QgaRCStKTdZM"); $responseObj = $js->decode($cityLocation); if ($responseObj->status != 'ZERO_RESULTS') { $page->setAttribute('latlng', $responseObj->results[0]->geometry->location->lat . "," . $responseObj->results[0]->geometry->location->lng); $updated++; } else { $not++; } } } return t("{$updated} cities geocoded, {$not} cities failed lookup."); }
function getPages($query = null) { Loader::model('page_list'); $db = Loader::db(); $bID = $this->bID; if ($this->bID) { $q = "select * from btDateNav 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; } $pl = new PageList(); $pl->setNameSpace('b' . $this->bID); $cArray = array(); //$pl->sortByPublicDate(); $pl->sortByPublicDateDescending(); $num = (int) $row['num']; if ($num > 0) { $pl->setItemsPerPage($num); } $c = $this->getCollectionObject(); if (is_object($c)) { $this->cID = $c->getCollectionID(); } $cParentID = $row['cThis'] ? $this->cID : $row['cParentID']; if ($this->displayFeaturedOnly == 1) { Loader::model('attribute/categories/collection'); $cak = CollectionAttributeKey::getByHandle('is_featured'); if (is_object($cak)) { $pl->filterByIsFeatured(1); } } $pl->filter('cvName', '', '!='); if ($row['ctID']) { $pl->filterByCollectionTypeID($row['ctID']); } $pl->filterByAttribute('exclude_nav', false); if ($row['cParentID'] != 0) { $pl->filterByParentID($cParentID); } if ($num > 0) { $pages = $pl->getPage(); } else { $pages = $pl->get(); } $this->set('pl', $pl); return $pages; }
protected function loadNewsSections() { $newsSectionList = new PageList(); $newsSectionList->filterByEasynewsSection(1); $newsSectionList->sortBy('cvName', 'asc'); $tmpSections = $newsSectionList->get(); $sections = array(); foreach ($tmpSections as $_c) { $sections[$_c->getCollectionID()] = $_c->getCollectionName(); } $this->set('sections', $sections); }
public function run() { $pl = new PageList(); $pl->filterByCollectionTypeHandle('walk'); $pl->filterByName('', true); $pages = $pl->get(); $pagecount = count($pages); foreach ($pages as $page) { $page->moveToTrash(); } return $pagecount . ' ' . t2('page', 'pages', $pagecount) . ' moved to the trash'; }
public function run() { $db = Loader::db(); Cache::disableLocalCache(); Loader::model('attribute/categories/collection'); $cak = CollectionAttributeKey::getByHandle('exclude_page_list'); if (!is_object($cak)) { $boolt = AttributeType::getByHandle('boolean'); $cab4b = CollectionAttributeKey::add($boolt, array('akHandle' => 'exclude_page_list', 'akName' => t('Exclude From Page List'), 'akIsSearchable' => true)); Loader::model('page_list'); $pl = new PageList(); $pl->filterByExcludeNav(1); $list = $pl->get(); foreach ($list as $c) { $c->setAttribute('exclude_page_list', 1); $c->reindex(); } } Cache::enableLocalCache(); }
public function createGatheringItems(GatheringDataSourceConfiguration $configuration) { $pl = new PageList(); $pl->ignoreAliases(); $pl->ignorePermissions(); $gathering = $configuration->getGatheringObject(); if ($gathering->getGatheringDateLastUpdated()) { $pl->filterByPublicDate($gathering->getGatheringDateLastUpdated(), '>'); } $ptID = $configuration->getPageTypeID(); if ($ptID > 0) { $pl->filterByPageTypeID($ptID); } $pages = $pl->get(); $items = array(); foreach ($pages as $c) { $item = PageGatheringItem::add($configuration, $c); if (is_object($item)) { $items[] = $item; } } return $items; }
function getSubNodes($cID, $level = 0, $keywords = '', $autoOpenNodes = true) { $db = Loader::db(); $obj = new stdClass(); if (isset($cID) && (Loader::helper('validation/numbers')->integer($cID) || $cID == 0)) { if ($keywords != '' && $keywords != false) { $nc = Page::getByID($cID, 'RECENT'); $pl = new PageList(); if (PERMISSIONS_MODEL != 'simple') { $pl->setViewPagePermissionKeyHandle('view_page_in_sitemap'); } $obj->keywords = $keywords; $pl->filterByName($keywords); $pl->ignoreAliases(); $pl->filterByPath($nc->getCollectionPath()); $pl->displayUnapprovedPages(); $pl->sortByDisplayOrder(); $results = $pl->get(SITEMAP_PAGES_LIMIT); $total = $pl->getTotal(); } else { $pl = new PageList(); if (PERMISSIONS_MODEL != 'simple') { $pl->setViewPagePermissionKeyHandle('view_page_in_sitemap'); } $pl->sortByDisplayOrder(); if (ConcreteDashboardSitemapHelper::showSystemPages()) { $pl->includeSystemPages(); $pl->includeInactivePages(); } $pl->filterByParentID($cID); $pl->displayUnapprovedPages(); $total = $pl->getTotal(); if ($cID == 1) { $results = $pl->get(); } else { $pl->setItemsPerPage(SITEMAP_PAGES_LIMIT); $results = $pl->getPage(); } } $nodes = array(); foreach ($results as $c) { $n = ConcreteDashboardSitemapHelper::getNode($c, $level + 1, $autoOpenNodes); if ($n != false) { $nodes[] = $n; } } $obj->total = $total; $obj->nodeID = $cID; $obj->pageList = $pl; $obj->results = $nodes; } else { $obj->total = 0; $obj->nodeID = 0; $obj->pageList = null; $obj->results = null; } return $obj; }
/** * Reindexes the search engine. */ public function reindexAll($fullReindex = false) { Cache::disableLocalCache(); $db = Loader::db(); Loader::model('collection_attributes'); if ($fullReindex) { $db->Execute("truncate table PageSearchIndex"); } $pl = new PageList(); $pl->ignoreAliases(); $pl->ignorePermissions(); $pl->sortByCollectionIDAscending(); $pl->filter(false, '(c.cDateModified > psi.cDateLastIndexed or UNIX_TIMESTAMP(NOW()) - UNIX_TIMESTAMP(psi.cDateLastIndexed) > ' . $this->searchReindexTimeout . ' or psi.cID is null or psi.cDateLastIndexed is null)'); $pl->filter(false, '(ak_exclude_search_index is null or ak_exclude_search_index = 0)'); $pages = $pl->get($this->searchBatchSize); $num = 0; foreach ($pages as $c) { // make sure something is approved $cv = $c->getVersionObject(); if (!$cv->cvIsApproved) { continue; } $c->reindex($this, true); $num++; unset($c); } $pnum = Collection::reindexPendingPages(); $num = $num + $pnum; Cache::enableLocalCache(); $result = new stdClass(); $result->count = $num; return $result; }
if ($i % 6 == 0) { ?> <div class="clearfix"> <p> </p> </div> <?php } ?> <?php $url = ''; $page = Page::getCurrentPage(); $pageList = new PageList(); $pageList->filterByParentID($page->getCollectionId()); $pageList->filterByAttribute('worldskills_member_id', $member['id']); $pages = $pageList->get(1); if (is_array($pages) && isset($pages[0])) { $url = $nh->getLinkToCollection($pages[0]); } ?> <div class="col-sm-2"> <p> <?php if ($url) { ?> <a href="<?php echo h($url); ?> "> <?php
<? defined('C5_EXECUTE') or die("Access Denied."); $dh = Loader::helper('concrete/dashboard/sitemap'); if (!$dh->canRead()) { die(t("Access Denied.")); } $trash = Page::getByPath(TRASH_PAGE_PATH); $i = 0; if (is_object($trash) && !$trash->isError()) { Loader::model('page_list'); $pl = new PageList(); $pl->filterByParentID($trash->getCollectionID()); $pl->includeInactivePages(); $pages = $pl->get(); foreach($pages as $pc) { $cp = new Permissions($pc); if ($cp->canDeleteCollection()) { $i++; $pc->delete(); } } } if ($i == 1) { $message = t('1 page deleted.'); } else { $message = t('%s pages deleted', $i); }
<style> html,body { height:100%; width:100%;background:#90c2ff } #map_canvas { height:100%; width:100%; background:#90c2ff } </style> </head> <body> <div id="map_canvas"></div> <script src="http://maps.googleapis.com/maps/api/js?key=AIzaSyAvsH_wiFHJCuMPPuVifJ7QgaRCStKTdZM&sensor=false"></script> <script> <?php $cities = Cache::get('map', 'world') ?: []; if (empty($cities)) { $nh = Loader::helper('navigation'); $pl = new PageList(); $pl->filterByCollectionTypeHandle('City'); foreach ($pl->get() as $page) { $parent = Page::getByID($page->getCollectionParentID()); $pageOwnerID = $page->getCollectionUserID(); $pageOwner = UserInfo::getByID($pageOwnerID); $cityName = t($page->getCollectionName()); $countryName = t($parent->getCollectionName()); $latlng = array_map(function ($e) { return (double) trim($e); }, explode(',', $page->getAttribute('latlng'))); $info = '<a href="' . $nh->getCollectionURL($page) . '" target="_blank">' . $cityName . ' Walks' . '</a>'; // If the owner is set if ($pageOwnerID > 1) { $coName = [$pageOwner->getAttribute('first_name'), $pageOwner->getAttribute('last_name')]; $info .= '<br />' . $coName[0] . ', City Organizer'; } else { $coName = [];
public function exportPages($xml = null, PageList $pl = null) { if (!$xml) { $this->x = $this->getXMLRoot(); } $node = $this->x->addChild("pages"); if (!$pl) { $pl = new PageList(); } $pl->ignorePermissions(); $pl->ignoreAliases(); $pl->filter(false, 'cFilename is null or cFilename = \'\''); $pages = $pl->get(); foreach ($pages as $pc) { $pc->export($node); } }
foreach ($doc->getElementsByTagName('country') as $country) { $countries = new PageList(); $countries->filterByCollectionTypeHandle('country'); $countries->filterByName($country->getAttribute('name')); $countryPage = $countries->get(1)[0]; if ($countryPage) { echo "exists: {$countryPage->getCollectionName()}<br/>"; } else { echo "creating: {$country->getAttribute('name')}<br/>"; $countryPage = Page::getByID(1)->add(CollectionType::getByHandle('country'), ['cName' => $country->getAttribute('name')]); } foreach ($country->getElementsByTagName('city') as $city) { $cities = new PageList(); $cities->filterByCollectionTypeHandle('city'); $cities->filterByName($city->getAttribute('name')); $cityPage = $cities->get(1)[0]; if ($cityPage) { $ui = UserInfo::getByEmail($city->getAttribute('owner_email')); echo "exists: {$cityPage->getCollectionName()} new owner: " . ($ui ? $ui->getUserID() : "") . "<br/>"; } else { echo "creating: {$city->getAttribute('name')}<br/>"; $ui = UserInfo::getByEmail($city->getAttribute('owner_email')); $cityPage = $countryPage->add(CollectionType::getByHandle('city'), ['cName' => $city->getAttribute('name'), 'uID' => $ui ? $ui->getUserID() : 1]); } $ui && $cityPage->update(['uID' => $ui->getUserID()]); } } /* foreach($user->childNodes as $attr) { if($attr->nodeName == 'social_login') { foreach($attr->childNodes as $social) { $newUser['oauth_auths'][$social->nodeName] = $social->nodeValue;
function getSubNodes($cID, $level = 0, $keywords = '', $autoOpenNodes = true) { $db = Loader::db(); $obj = new stdClass; if ($keywords != '' && $keywords != false) { $nc = Page::getByID($cID, 'RECENT'); $pl = new PageList(); $obj->keywords = $keywords; $pl->filterByName($keywords); $pl->filterByPath($nc->getCollectionPath()); $pl->displayUnapprovedPages(); $pl->sortByDisplayOrder(); $results = $pl->get(SITEMAP_PAGES_LIMIT); $total = $pl->getTotal(); } else { $pl = new PageList(); $pl->sortByDisplayOrder(); if (ConcreteDashboardSitemapHelper::showSystemPages()) { $pl->includeSystemPages(); } $pl->filterByParentID($cID); $pl->displayUnapprovedPages(); $total = $pl->getTotal(); if ($cID == 1) { $results = $pl->get(); } else { $pl->setItemsPerPage(SITEMAP_PAGES_LIMIT); $results = $pl->getPage(); } } $nodes = array(); foreach($results as $c) { $n = ConcreteDashboardSitemapHelper::getNode($c, $level+1, $autoOpenNodes); if ($n != false) { $nodes[] = $n; } } $obj->total = $total; $obj->nodeID = $cID; $obj->pageList = $pl; $obj->results = $nodes; return $obj; }
public function view() { parent::view(); $bg = $this->city->fullbg; if ($bg) { $this->bodyData['bg'] = $bg->getURL(); } $this->bodyData['classes'][] = 'city-page'; $this->bodyData['pageViewName'] = 'CityPageView'; $this->set('bodyData', $this->bodyData); $this->set('pageType', 'city-page'); $this->set('isCityOrganizer', (new User())->getUserID() === $this->city->cityOrganizer->getUserID()); $this->set('isLoggedIn', (bool) Loader::helper('concrete/dashboard')->canRead()); $this->set('isCampaignActive', false); // Is the donations campaign running? $this->set('canEdit', is_object(ComposerPage::getByID($this->c->getCollectionID()))); $this->set('city', $this->city); // Make JSON available $this->addToJanesWalk(['city' => $this->city]); // Are there blog entries for this city? $blog = new PageList(); $blog->filterByCollectionTypeHandle('city_blog'); $blog->filterByParentID($this->c->getCollectionID()); $this->set('blog', $blog->get(1)[0]); }
Loader::model('user_list'); /* Set up the KML XML */ // Creates the Document. $dom = new DOMDocument('1.0', 'UTF-8'); $dnode = $dom->createElement('geography'); $docNode = $dom->appendChild($dnode); $countries = new PageList(); $countries->filterByCollectionTypeHandle('country'); foreach ($countries->get() as $country) { $node = $dom->createElement('country'); $node->setAttribute('name', $country->getCollectionName()); $countryNode = $docNode->appendChild($node); $cities = new PageList(); $cities->filterByCollectionTypeHandle('city'); $cities->filterByParentID($country->getCollectionID()); foreach ($cities->get() as $city) { $node = $dom->createElement('city'); $node->setAttribute('name', $city->getCollectionName()); $node->setAttribute('owner_email', UserInfo::getByID($city->getCollectionUserID())->getUserEmail()); $countryNode->appendChild($node); } } /*foreach((new UserList())->get(3000) as $user) { $ui = UserInfo::getByID($user->getUserID()); $node = $dom->createElement('User'); $userNode = $docNode->appendChild($node); $node = $dom->createElement('email'); $cdata = $node->ownerDocument->createCDATASection($user->getUserEmail()); $node->appendChild($cdata); $userNode->appendChild($node);
/** * Call model data needed by view * * @param int $userID The user ID of who we're viewing * @return null */ public function view($userID = 0) { // Load helpers Loader::model('page_list'); $nh = Loader::helper('navigation'); $ah = Loader::helper('concrete/avatar'); $th = Loader::helper('text'); $ih = Loader::helper('image'); // Set helpers for view // Set the page view first $this->set('bodyData', ['pageViewName' => 'ProfilePageView']); parent::view($userID); // Load the current user $u = new User(); $ui = UserInfo::getByID($u->getUserID()); $profile = $this->get('profile'); // Basic flags identifying the type of user // Whether or not the logged in user is viewing their own "profile" $userIsViewingSelf = $u->getUserID() === $profile->getUserID(); // User is a CO $userIsCityOrganizer = in_array('City Organizers', $profile->getUserObject()->getUserGroups()); /** * New dashboard variables * */ // Remaining variables/logic only needed for "self viewing" if ($userIsViewingSelf) { /** * Helper * */ $html = Loader::helper('html'); $this->addHeaderItem($html->javascript('swfobject.js')); /** * User data * */ // Whether the logged in user has set their first and last name $this->set('userHasSetName', (bool) trim($ui->getAttribute('first_name') . ' ' . $ui->getAttribute('last_name'))); // The home city for the logged in user (false otherwise) $userHomeCity = $ui->getAttribute('home_city'); $this->set('userHomeCity', $userHomeCity); // Whether the logged in user has chosen an avatar/display picture $this->set('userPicture', $ah->getImagePath($ui)); // Walks owned by user $pl = new PageList(); $pl->filterByCollectionTypeHandle('walk'); $pl->filterByUserID($u->getUserID()); // Include the names of draft walks, not last published $pl->displayUnapprovedPages(); $this->set('userWalks', $pl->get()); // Whether the logged in user has created any blog posts $pl = new PageList(); $pl->filterByCollectionTypeHandle(['walk_blog_entry', 'city_blog_entry']); $pl->filterByUserID($u->getUserID()); $this->set('userBlogPosts', $pl->get()); /** * User city data * */ if ($userHomeCity) { // Set the city $city = $ui->getAttribute('home_city'); // Load organizer user for this city $cityOrganizer = UserInfo::getByID($userHomeCity->getCollectionUserID()); if ($cityOrganizer) { // The email address of the city organizer for the logged in user's // home city $cityOrganizerEmailAddress = $cityOrganizer->getUserEmail(); $this->set('cityOrganizerEmailAddress', $cityOrganizerEmailAddress); } // Whether the city has a blog page set up for it $pl = new PageList(); $pl->filterByCollectionTypeHandle('blog'); $pl->filterByParentID($userHomeCity->getCollectionID()); $cityHasBlogSetup = (bool) $pl->getTotal(); $this->set('cityHasBlogSetup', $cityHasBlogSetup); // List of basic data for three walks we want to highlight to city // organizers/walk leaders that showcase creative/unique walks $pl = new PageList(); $pl->filterByCollectionTypeHandle('walk'); $pl->filter(false, 'p1.uID !=' . $u->getUserID()); $pl->filterByAttribute('exclude_page_list', false); $pl->sortBy('RAND()'); // Load this list of featured walks $featuredWalkData = array_map(function ($page) use($nh, $ih) { $_city = Page::getByID($page->getCollectionParentID()); $_country = Page::getByID($_city->getCollectionParentID()); $_thumb = $page->getAttribute('thumbnail'); $countryName = $_country->getCollectionName(); if ($countryName === 'United States') { $countryName = 'United States of America'; } $countryName = str_replace(' ', '_', $countryName); $walkImage = $_thumb ? $ih->getThumbnail($_thumb, 800, 800)->src : ''; return ['walkImagePath' => $walkImage, 'countryName' => $countryName, 'cityName' => $_city->getCollectionName(), 'walkTitle' => $page->getCollectionName(), 'walkPath' => $nh->getLinkToCollection($page)]; }, (array) $pl->get(3)); // Whether the city has any walks posted to it // Whether the city has a blog page set up for it $pl = new PageList(); $pl->filterByCollectionTypeHandle('walk'); $pl->filterByParentID($userHomeCity->getCollectionID()); $pl->filterByAttribute('exclude_page_list', false); $cityWalks = $pl->get(); // Export to view $this->set('cityWalks', $cityWalks); $this->set('cityHasWalks', !empty($cityWalks)); $this->set('city', $city); $this->set('featuredWalkData', $featuredWalkData); // If the user is a city organizer if ($userIsCityOrganizer === true) { // Whether the city organizer's city has its header info set $cityHeaderInfo = $userHomeCity->getCollectionDescription(); $cityHeaderInfoIsEmpty = !trim($cityHeaderInfo); if ($cityHeaderInfoIsEmpty === false) { $cityHeaderInfo = $th->shorten($cityHeaderInfo, 150); } $this->set('cityHeaderInfoIsEmpty', $cityHeaderInfoIsEmpty); $this->set('cityHeaderInfo', $cityHeaderInfo); // Whether the city organizer's city has its short description // set $cityDescription = $userHomeCity->getAttribute('longdescription'); $cityDescriptionIsEmpty = !trim($cityDescription); if ($cityDescriptionIsEmpty === false) { $cityDescription = $th->shorten($cityDescription, 150); } $this->set('cityDescriptionIsEmpty', $cityDescriptionIsEmpty); $this->set('cityDescription', $cityDescription); // Whether the city organizer's city has its background photo // set $cityBackgroundPhotoAttribute = $userHomeCity->getAttribute('full_bg'); $cityBackgroundPhotoIsEmpty = !$cityBackgroundPhotoAttribute; $this->set('cityBackgroundPhotoIsEmpty', $cityBackgroundPhotoIsEmpty); if (!$cityBackgroundPhotoIsEmpty) { $this->set('cityBackgroundPhoto', $cityBackgroundPhotoAttribute->getURL()); } // Whether the header, description and photo are set for the // city organizer's home city $cityHasFullDetails = !($cityHeaderInfoIsEmpty || $cityDescriptionIsEmpty || $cityBackgroundPhotoIsEmpty); $this->set('cityHasFullDetails', $cityHasFullDetails); // Load the cities this CO organizes $pl = new PageList(); $pl->filterByCollectionTypeHandle('city'); $pl->ignoreAliases(); $pl->filterByUserID($u->getUserID()); $cityUsers = []; foreach ($pl->get() as $city) { // Load the user list for this city $ul = new UserList(); $ul->filterByHomeCity($city->getCollectionID()); foreach ($ul->get(65535) as $user) { $cityUsers[] = ['id' => $user->getUserID(), 'firstName' => $user->getAttribute('first_name'), 'lastName' => $user->getAttribute('last_name')]; } } // Sort the users -- needed here for multi-city COs usort($cityUsers, function ($a, $b) { return strcmp(strtoupper($a['first-name']), strtoupper($b['first-name'])); }); $this->set('cityUsers', $cityUsers); // Link to city-editor $this->set('cityComposerURL', View::url('/dashboard/composer/write/-/edit/' . $city->getCollectionID())); } } // Resources $resources = ['showCityOrganizers' => false, 'showGlobalWalks' => true, 'showTips' => true, 'showFiles' => false]; if ($userIsCityOrganizer === true) { $resources['showCityOrganizers'] = true; $resources['showFiles'] = true; // List of basic details for three city organizers that can be // recommended to other city organizers // TODO add an attribute to select 'featured' cities, so we // don't simply grab all cities. Expand this out into a // smart way to recommend other cities. $pl = new PageList(); $pl->filterByCollectionTypeHandle('city'); $pl->filter(false, 'p1.uID !=' . $u->getUserID()); $pl->filterByAttribute('exclude_page_list', false); $pl->sortBy('RAND()'); $recommendedCities = $pl->get(3); $cityOrganizerData = array_map(function ($page) use($ah) { $_co = UserInfo::getByID($page->getCollectionUserID()); return ['cityName' => $page->getCollectionName(), 'organizerImagePath' => $ah->getImagePath($_co), 'organizerName' => trim($_co->getAttribute('first_name') . ' ' . $_co->getAttribute('last_name')), 'organizerEmail' => $_co->getUserEmail()]; }, $pl->get(3)); $this->set('cityOrganizerData', $cityOrganizerData); } $this->set('resources', $resources); } $this->set('nh', $nh); $this->set('u', $u); $this->set('newWalkForm', Page::getByPath('/walk/form')); $this->set('userIsCityOrganizer', $userIsCityOrganizer); $this->set('userIsViewingSelf', $userIsViewingSelf); // Validation helper for form tokens $this->set('valt', Loader::helper('validation/token')); }
} ?> </div> <?php } ?> <div> <?php if ($u->getUserID() == $profile->getUserID()) { $nc = Page::getByPath('/profile'); $pl = new PageList(); $pl->filterByParentID($nc->getCollectionID()); $pages = $pl->get(0); if (is_array($pages) && !empty($pages)) { $nh = Loader::helper('navigation'); ?> <ul class="nav"> <?php foreach ($pages as $page) { ?> <li><a href="<?php echo $nh->getLinkToCollection($page); ?> "><?php echo t($page->getCollectionName()); ?> </a></li> <?php
public function getPages() { // returns an array of pages of this type. Does not check permissions // since this can get pretty long it actually returns a limited amount of data; $pl = new PageList(); $pl->filterByCollectionTypeID($this->getCollectionTypeID()); $pl->ignorePermissions(); $pl->ignoreAliases(); $pages = $pl->get(); return $pages; }
<?php defined('C5_EXECUTE') || die('Access Denied.'); $th = Loader::helper('text'); $av = Loader::helper('concrete/avatar'); $ih = Loader::helper('image'); $doc = new DOMDocument(); $pagesEl = $doc->appendChild($doc->createElement('pages')); foreach ($pages as $page) { $pageEl = $pagesEl->appendChild($doc->createElement('page', $page->getCollectionName())); $cities = new PageList(); $cities->filterByCollectionTypeHandle('city'); $cities->filterByParentID($page->getCollectionID()); foreach ($cities->get(1000) as $city) { $uid = (int) $city->getCollectionUserID(); // We don't need to see the admin for every city she default-owns if ($uid === 175 || $uid === 1) { continue; } $page_owner = UserInfo::getByID($uid); $cityEl = $pageEl->appendChild($doc->createElement('city', $city->getCollectionName())); $cityEl->setAttribute('href', $nh->getLinkToCollection($city)); $cityEl->setAttribute('placeholder', 'placeholder' . ord($page_owner->getUserID()) % 3); $avatar = $av->getImagePath($page_owner); if ($avatar) { $cityEl->setAttribute('background', $avatar); } $cityEl->setAttribute('fullname', trim($page_owner->getAttribute('first_name') . ' ' . $page_owner->getAttribute('last_name'))); $cityEl->setAttribute('email', $page_owner->getUserEmail()); // TODO: See if there's a nice XSLT templates way to shorten this, // or at least define the icons in the template
function getPages($query = null) { Loader::model('page_list'); $db = Loader::db(); $bID = $this->bID; if ($this->bID) { $q = "select num, cParentID, cThis, orderBy, ctID, displayAliases, rss from btEasyNewsList 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; } $pl = new PageList(); $pl->setNameSpace('b' . $this->bID); $cArray = array(); switch ($row['orderBy']) { case 'public_desc': $pl->sortBy('cvDatePublic', 'desc'); break; case 'public_asc': $pl->sortBy('cvDatePublic', 'asc'); break; case 'display_asc': $pl->sortByDisplayOrder(); break; case 'display_desc': $pl->sortByDisplayOrderDescending(); break; case 'chrono_asc': $pl->sortByPublicDate(); 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']; 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']) { $pl->filterByCollectionTypeID($row['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($row['cParentID']) != 0) { $pl->filterByParentID($cParentID); } //Publish Date Filter $dt = Loader::helper('date'); $pl->filter('cvDatePublic', $dt->getLocalDateTime(), '<'); if ($num > 0) { $pages = $pl->getPage(); } else { $pages = $pl->get(); } $this->set('pl', $pl); return $pages; }
public function view() { $fields_template_relative_path = "/view_form_fields/{$this->form_key}.php"; $fields_template_absolute_path = dirname(__FILE__) . $fields_template_relative_path; if (!file_exists($fields_template_absolute_path)) { throw new Exception(t('Custom Contact Form Error: Missing form fields template file %s', $fields_template_absolute_path)); } $this->set('fields_template', $fields_template_relative_path); $has_files = CustomContactForm::hasFileFields($this->form_key); $this->set('has_files', $has_files); $this->set('show_thanks', !empty($_GET['thanks']) && $_GET['thanks'] == $this->bID); $this->set('honeypot_blank_field_name', CustomContactForm::$honeypot_blank_field_name); $this->set('honeypot_blank_field_label', CustomContactForm::$honeypot_blank_field_label); $this->set('honeypot_retained_field_name', CustomContactForm::$honeypot_retained_field_name); $this->set('honeypot_retained_field_value', CustomContactForm::$honeypot_retained_field_value); // get the product pages children pID 130 $pl = new PageList(); $pl->filterByParentID('130'); $pl->sortByDisplayOrder(); $productpages = $pl->get(); $this->set('productpages', $productpages); // Bi fold doors // get the Aluminium - bi fold pages pID 154 $pl = new PageList(); $pl->filterByParentID('154'); $pl->sortByDisplayOrder(); $aluminium_productpages = $pl->get(); $this->set('aluminium_productpages', $aluminium_productpages); // get page name $p = Page::getByID(154); $p_name = $p->getCollectionName(); $this->set('aluminium_productpage_name', $p_name); // get the Timber - bi fold pages pID 155 $pl = new PageList(); $pl->filterByParentID('155'); $pl->sortByDisplayOrder(); $timber_productpages = $pl->get(); $this->set('timber_productpages', $timber_productpages); // get page name $p = Page::getByID(155); $p_name = $p->getCollectionName(); $this->set('timber_productpage_name', $p_name); // get the Composite - bi fold pages pID 156 $pl = new PageList(); $pl->filterByParentID('156'); $pl->sortByDisplayOrder(); $composite_productpages = $pl->get(); $this->set('composite_productpages', $composite_productpages); // get page name $p = Page::getByID(156); $p_name = $p->getCollectionName(); $this->set('composite_productpage_name', $p_name); // Sliding doors // get Sliding doors pages pID 132 $pl = new PageList(); $pl->filterByParentID('132'); $pl->sortByDisplayOrder(); $sliding_doors_productpages = $pl->get(); $this->set('sliding_doors_productpages', $sliding_doors_productpages); // get page name $p = Page::getByID(132); $p_name = $p->getCollectionName(); $this->set('sliding_doors_productpage_name', $p_name); // Sliding turn systems // get Sliding Sliding turn systems pages pID 133 $pl = new PageList(); $pl->filterByParentID('133'); $pl->sortByDisplayOrder(); $sliding_turn_systems_productpages = $pl->get(); $this->set('sliding_turn_systems_productpages', $sliding_turn_systems_productpages); // get page name $p = Page::getByID(133); $p_name = $p->getCollectionName(); $this->set('sliding_turn_systems_productpage_name', $p_name); // Sliding Horizontal walls // get Sliding Horizontal walls pages pID 138 $pl = new PageList(); $pl->filterByParentID('138'); $pl->sortByDisplayOrder(); $moveable_walls_productpages = $pl->get(); $this->set('moveable_walls_productpages', $moveable_walls_productpages); // get page name $p = Page::getByID(138); $p_name = $p->getCollectionName(); $this->set('moveable_walls_productpage_name', $p_name); // Windows // pID 139 //$pl = new PageList; //$pl->filterByParentID('138'); //$pl->sortByDisplayOrder(); //$moveable_walls_productpages = $pl->get(); //$this->set('moveable_walls_productpages', $moveable_walls_productpages); // get page name $p = Page::getByID(139); $p_name = $p->getCollectionName(); $this->set('windows_productpage_name', $p_name); }
public function swapContent($options) { if ($this->validateClearSiteContents($options)) { Loader::model("page_list"); Loader::model("file_list"); Loader::model("stack/list"); $pl = new PageList(); $pages = $pl->get(); foreach ($pages as $c) { $c->delete(); } $fl = new FileList(); $files = $fl->get(); foreach ($files as $f) { $f->delete(); } // clear stacks $sl = new StackList(); foreach ($sl->get() as $c) { $c->delete(); } $home = Page::getByID(HOME_CID); $blocks = $home->getBlocks(); foreach ($blocks as $b) { $b->deleteBlock(); } $pageTypes = CollectionType::getList(); foreach ($pageTypes as $ct) { $ct->delete(); } // now we add in any files that this package has if (is_dir($this->getPackagePath() . '/content_files')) { Loader::library('file/importer'); $fh = new FileImporter(); $contents = Loader::helper('file')->getDirectoryContents($this->getPackagePath() . '/content_files'); foreach ($contents as $filename) { $f = $fh->import($this->getPackagePath() . '/content_files/' . $filename, $filename); } } // now we parse the content.xml if it exists. Loader::library('content/importer'); $ci = new ContentImporter(); $ci->importContentFile($this->getPackagePath() . '/content.xml'); } }
<?php $importArray = json_decode(file_get_contents(__DIR__ . '/walkexport.json'), true); foreach ($importArray as $walk) { $pl = new PageList(); $pl->filterByCollectionTypeHandle('country'); $pl->filterByName($walk['country']); $country = $pl->get(1)[0]; if (!$country) { $country = Page::getByID(1)->add(CollectionType::getByHandle('country'), ['cName' => $walk['country']]); } $pl = new PageList(); $pl->filterByCollectionTypeHandle('city'); $pl->filterByName($walk['city']); $city = $pl->get(1)[0]; if (!$city) { $city = $country->add(CollectionType::getByHandle('city'), ['cName' => $walk['city']]); } $ui = UserInfo::getByEmail($walk['owner']); if (!$ui) { $ui = UserInfo::add(['uName' => $walk['owner'], 'uEmail' => $walk['owner']]); } $walkPage = $city->add(CollectionType::getByHandle('walk'), ['cName' => $walk['title'], 'uID' => $ui->getUserID()]); $walkController = Loader::controller($walkPage); $walkController->setJson(json_encode($walk), true); }