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]); }
public function view() { parent::view(); $headImage = $this->c->getAttribute('full_bg'); if ($headImage) { $this->bodyData['bg'] = $headImage->getURL(); } $this->bodyData['classes'][] = 'home'; $this->bodyData['pageViewName'] = 'HomePageView'; $this->set('bodyData', $this->bodyData); }
public function view() { parent::view(); $dh = Loader::helper('concrete/dashboard'); $im = Loader::helper('image'); $c = Page::getCurrentPage(); $ui = UserInfo::getByID($c->getCollectionUserID()); if ($imAtt = $c->getAttribute('main_image')) { $this->set('headImage', $im->getThumbnail($imAtt, 800, 800)); } $this->set('isLoggedIn', $dh->canRead()); $this->set('canEdit', is_object(ComposerPage::getByID($c->getCollectionID()))); $this->set('authorName', ($first_name = $ui->getAttribute('first_name')) ? "{$first_name} {$ui->getAttribute('last_name')}" : $ui->getUserObject()->getUserName()); $this->set('publishDate', $c->getCollectionDatePublic(DATE_APP_GENERIC_MDY_FULL)); $this->set('pageType', 'blog'); }
public function view() { parent::view(); $u = new User(); $ui = UserInfo::getByID($u->getUserID()); $nh = Loader::helper('navigation'); $av = Loader::helper('concrete/avatar'); $valt = Loader::helper('validation/token'); $imgHelper = Loader::helper('image'); /* If no page is passed to edit, create a new page. */ $load = $_REQUEST['load']; if (empty($load)) { // Find the parent page this should go under $cityPage = ($parentCID = $_REQUEST['parentCID']) ? Page::getByID($parentCID) : ($ui->getAttribute('home_city') ?: Page::getByPath('/canada/toronto')); $c = $this->getUnstartedWalk($u, $cityPage); } else { $c = Page::getByPath($load); $cityPage = Page::getByID($c->getCollectionParentID()); } $walk_ward = trim((string) $c->getAttribute('walk_wards')); $city_wards = $cityPage->getAttribute('city_wards'); if ($city_wards) { $wards = array_map(function ($ward) use($walk_ward) { if ($ward->value == $walk_ward) { $ward->selected = true; } return $ward; }, $city_wards->getOptions()); } else { $wards = null; } // Set the language based on a trail to the city /* Set the city language to the first one matched, recursing from where we are */ $crumbs = $nh->getTrailToCollection($c); $crumbs[] = $c; // Must check the current page first foreach ($crumbs as $crumb) { if ($lang = (string) $crumb->getAttribute('lang')) { Localization::changeLocale($lang); break; } } // Load our city $latlng = explode(',', $cityPage->getAttribute('latlng')); // If you don't have a lat and a lng, final resort is Toronto. It's at least better than being 400km off the coast of Nigeria. if (count((array) $latlng) !== 2) { $latlng = [43.653226, -79.3831843]; } // Instantiate as models, for JSON serialization $city = new City($cityPage); $walk = new Walk($c); // Build data needed by frontend $this->addToJanesWalk(['city' => $city, 'form' => ['valt' => $valt->generate('upload')], 'walk' => ['name' => (string) $walk, 'data' => $walk, 'url' => $nh->getCollectionURL($c)], 'locale' => ['name' => Localization::activeLocale(), 'translation' => Localization::getActiveTranslateJsonURL()]]); // Set the view name $this->bodyData['pageViewName'] = 'CreateWalkView'; $this->set('u', $u); $this->set('ui', $ui); $this->set('owner', UserInfo::getByID($c->getCollectionUserID())); $this->set('nh', $nh); $this->set('av', $av); $this->set('load', $load); $this->set('c', $c); $this->set('city', $city); $this->set('country', $city->country); $this->set('ui_cityorganizer', $city->city_organizer); $this->set('imgHelper', $imgHelper); $this->set('wards', $wards); $this->set('is_nyc', $is_nyc); $this->set('lat', $latlng[0]); $this->set('lng', $latlng[1]); $this->set('bodyData', $this->bodyData); // Load JS we need in the form $html = Loader::helper('html'); // Set default stylesheets for libs $this->addHeaderItem($html->css('jquery.ui.css')); // Set libs we'll need on the page $this->addFooterItem(Loader::helper('html')->javascript('jquery.ui.js')); }
public function view() { parent::view(); $nh = Loader::helper('navigation'); $im = Loader::helper('image'); $c = $this->getCollectionObject(); // Put the preview image for Facebook/Twitter to pick up $doc = new DOMDocument(); $thumb = $c->getAttribute('thumbnail'); if ($thumb) { $meta = $doc->appendChild($doc->createElement('meta')); $meta->setAttribute('property', 'og:image'); $meta->setAttribute('content', BASE_URL . $im->getThumbnail($thumb, 340, 720)->src); $this->set('thumb', $thumb); } $meta = $doc->appendChild($doc->createElement('meta')); $meta->setAttribute('property', 'og:url'); $meta->setAttribute('content', $nh->getCollectionURL($c)); $meta = $doc->appendChild($doc->createElement('meta')); $meta->setAttribute('property', 'og:title'); $meta->setAttribute('content', $c->getCollectionName()); $meta = $doc->appendChild($doc->createElement('meta')); $meta->setAttribute('property', 'og:description'); $meta->setAttribute('content', $c->getAttribute('shortdescription')); $this->addHeaderItem($doc->saveHTML()); // Breadcrumb trail to walk $bc = $doc->appendChild($doc->createElement('ul')); $bc->setAttribute('class', 'breadcrumb'); foreach ((array) $this->walk->crumbs as $crumb) { if ($crumb->getCollectionTypeHandle() !== 'country') { $li = $bc->appendChild($doc->createElement('li')); $a = $li->appendChild($doc->createElement('a')); $a->setAttribute('href', $nh->getLinkToCollection($crumb)); if ($crumb->getCollectionID() === '1') { $a->appendChild($doc->createElement('i'))->setAttribute('class', 'fa fa-home'); } else { $linkText = $crumb->getCollectionName(); if ($crumb->getCollectionTypeHandle() === 'city') { $linkText .= ' walks'; } $a->appendChild($doc->createTextNode(t($linkText))); } } } $li = $bc->appendChild($doc->createElement('li')); $li->setAttribute('class', 'active'); $li->appendChild($doc->createTextNode($c->getCollectionName())); $this->set('breadcrumb', $doc->saveHTML($bc)); /* Helpers to use in the view */ $this->set('im', $im); $this->set('th', Loader::helper('theme')); $this->set('eid', $c->getAttribute('eventbrite')); $this->set('w', $this->walk); // Body variables $this->bodyData['classes'][] = 'walk-page'; $this->bodyData['classes'][] = 'active-walk'; $this->bodyData['pageViewName'] = 'WalkPageView'; $this->set('bodyData', $this->bodyData); // Setup the page data needed in the script block $this->addToJanesWalk(['page' => ['description' => strip_tags($c->getAttribute('longdescription'))], 'city' => $this->walk->city, 'walk' => $this->walk]); }