/** * The {{ all_the_vars }} tag * * @return string */ public function index() { $remove_underscored = $this->fetchParam('remove_underscored', true, null, true); // Tidy up the context values $context = $this->context; foreach ($context as $key => $val) { // Remove objects. You can't use them in templates. if (is_object($val)) { unset($context[$key]); } // Remove underscored variables. if ($remove_underscored && Pattern::startsWith($key, '_')) { unset($context[$key]); } } // Get extra page data $this->page_data = Content::get(URL::getCurrent()); // CSS $output = $this->css->link('all_the_vars'); if (!$this->fetchParam('websafe_font', false, null, true)) { $output .= '<link rel="stylesheet" href="//fonts.googleapis.com/css?family=Ubuntu+Mono" />'; } // Create table $output .= $this->createTable($context, false); // Display on the screen die($output); }
/** * Retrieve the parent page * @return Array Array containing the content of the parent page */ private function getParent() { $parent = URL::assemble(URL::popLastSegment(URL::getCurrent())); if (Taxonomy::isTaxonomyURL($parent)) { $parent = URL::popLastSegment($parent); } return Content::get($parent); }
/** * @access public * @param aExtrinsicState * @ParamType aExtrinsicState */ public function doIt($tagRoute, $parameters) { $menuEntity = $GLOBALS['sys_menu']; $menuTemplate = new Content($menuEntity, $menuEntity); $menuTemplate->setFilter("sys_menu_parent_id", $parameters["parent_id"]); $menuTemplate->setOrderFields("sys_menu_position", 'sys_menu_parent', "sys_menu0_position"); return $menuTemplate->get(); }
function get_content() { $param['page'] = 1; $param['show'] = 20; // get recent 20 contents $condition = 'type = ' . BLOGPOST . ' AND author_id = ' . $_SESSION['user']['id']; $content = Content::get($param, $condition); return $content; }
public function testContent() { $content = new Content(null, TEST_ROOT_ETC . DS . 'content' . DS . 'site.txt'); $this->assertEquals(TEST_ROOT_ETC . DS . 'content' . DS . 'site.txt', $content->root); $this->assertEquals(TEST_ROOT_ETC . DS . 'content' . DS . 'site.txt', $content->root()); $this->assertEquals('site', $content->name()); $this->assertEquals(array_keys($this->dummyData()), $content->fields()); $this->assertEquals($this->dummyData(), $content->toArray()); $this->assertEquals($this->dummyData(), $content->data()); $this->assertTrue($content->exists()); $this->assertEquals(file_get_contents($content->root()), $content->raw()); foreach ($this->dummyData() as $field => $value) { $this->assertEquals($value, $content->{$field}()); $this->assertEquals($value, $content->get($field)); $this->assertInstanceOf('Field', $content->{$field}()); $this->assertInstanceOf('Field', $content->get($field)); } }
/** * Get the path of the current file * * @return string Full path */ public function getPath() { // Get the query string and remove the ordering $url = Path::pretty(Request::get('path')); // Remove the 'page' if it's a page.md $url = Pattern::endsWith($url, 'page') ? URL::popLastSegment($url) : $url; // Get the content $content = Content::get($url); // Path is inside the content return ltrim($content['_local_path'], '/'); }
public function orderHasDownloads() { $order_details = $this->addon->api('bison')->session->get('order_details'); // Return list of downloads in the order $download_products = array_filter($order_details['items'], function ($item) { $entry = Content::get($item['url']); return isset($entry['download_path']); }); // Check list for products return !empty($download_products); }
public static function add() { $visible = 0; if ($_POST['visible'] == "True") { $visible = 1; } $values = [self::TYPEID => intval($_POST['typeid']), self::TITLE => $_POST['title'], self::CONTENT => $_POST['content'], self::VISIBLE => $visible]; $newId = Database::insert(self::TABLE_NAME, $values); Content::get($newId); //TODO detect tags, and add them //Tag::add($newId, *); }
public function postSavenewhomepagemessage() { $validator = Validator::make(Input::all(), array('text' => 'required|min:5')); if ($validator->fails()) { $output = array('result' => 0, 'error' => ''); foreach ($validator->messages()->all() as $m) { $output['error'] .= $m . ' '; } return json_encode($output); } $message = new Content(); $message->type = 'homepage'; $message->body = Input::get('text'); $message->save(); $output['result'] = 1; $output['content'] = View::make('snippets.messagebox', array('message' => $message, 'position' => Content::get()->count()))->render(); return Response::json($output); }
function __construct() { parent::__construct(); $this->page = Content::get(URL::getCurrent()); // get control and location variables $this->ignore_seo_image_field = $this->fetchConfig('ignore_seo_image_field'); $this->sharable_image_default = $this->fetchConfig('default_image'); $this->sharable_image_source = $this->fetchConfig('sharable_image_source'); // get the variables that are actually printed in output $this->site_url = URL::getSiteURL(); $this->page_url = URL::tidy($this->site_url . URL::getCurrent(true)); $this->description = $this->getPageDescription(); $this->twitter = $this->fetchConfig('twitter'); $this->twitter_default_message = $this->fetchConfig('twitter_default_message'); $this->site_name = Config::getSiteName(); $this->image_url = $this->getShareableImage(); $this->page_title = $this->site_name . " | " . $this->getPageTitle(); $this->google_analytics = $this->fetchConfig('google_analytics_key'); }
function move_down() { $cont = new Content(); //$cont->where('parent_section',$this->parent_section );//same section $cont->where('parent_content', $this->parent_content); //same parent $cont->where('cell', $this->cell); // same cell $cont->where('sort >', $this->sort); //greater sort $cont->get(); //get them to process // if that content object exists then that place is taken // so we have to get a place for it if ($cont->exists()) { $this->deattach(); $this->sort++; $this->attach(); return TRUE; } return FALSE; }
/** * Deletes a content object * * Returns a JSON list of affected wallEntryIds. */ public function actionDelete() { $this->forcePostRequest(); // Json Array $json = array(); $json['success'] = false; $model = Yii::app()->request->getParam('model', ""); $id = (int) Yii::app()->request->getParam('id', 1); $content = Content::get($model, $id); if ($content->content->canDelete()) { // Save wall entry ids which belongs to this post $json['wallEntryIds'] = array(); // Wall Entry Ids foreach ($content->content->getWallEntries() as $entry) { $json['wallEntryIds'][] = $entry->id; } $json['wallEntryIds'][] = 0; if ($content->delete()) { $json['success'] = true; } } echo CJSON::encode($json); Yii::app()->end(); }
/** * Gets IPs allowed for a given $url * * @param string $url URL to retrieve IPs for * @return array */ public function getAllowedIPs($url) { // get data $data = Content::get($url); // is there data? if (empty($data['_protect']['ip_address']['allowed'])) { return array(); } // grab allowed passwords return Helper::ensureArray($data['_protect']['ip_address']['allowed']); }
/** * Raven form tag pair * * {{ raven:form }} {{ /raven:form }} * * @return string */ public function form() { /* |-------------------------------------------------------------------------- | Formset |-------------------------------------------------------------------------- | | Raven really needs a formset to make it useful and secure. We may even | write a form decorator in the future to generate forms from formsets. | */ $formset = $this->fetchParam('formset', false); $return = $this->fetchParam('return', URL::getCurrent()); $error_return = $this->fetchParam('error_return', URL::getCurrent()); $multipart = ($this->fetchParam('files', false)) ? "enctype='multipart/form-data'" : ''; $old_values = array(); // Fetch the content if in edit mode if ($edit = $this->fetchParam('edit')) { $old_values = Content::get($edit, false, false); // Throw exception if there's an invalid URL if (count($old_values) == 0) { throw new FatalException('Invalid URL for editing'); } $entry_hash = Helper::encrypt($edit); } // Merge old values $old_values = array_merge($this->flash->get('old_values', array()), $old_values); // Sanitize data before returning it for display // $old_values = array_map_deep($old_values, 'htmlspecialchars'); // Set old values to re-populate the form $data = array(); array_set($data, 'value', $old_values); array_set($data, 'old_values', $old_values); /* |-------------------------------------------------------------------------- | Form HTML |-------------------------------------------------------------------------- | | Raven writes a few hidden fields to the form to help processing data go | more smoothly. Form attributes are accepted as colon/piped options: | Example: attr="class:form|id:contact-form" | | Note: The content of the tag pair is inserted back into the template | */ $form_id = $this->fetchParam('id', true); $attributes_string = ''; if ($attr = $this->fetchParam('attr', false, null, false, false)) { $attributes_array = Helper::explodeOptions($attr, true); foreach ($attributes_array as $key => $value) { $attributes_string .= " {$key}='{$value}'"; } } $html = "<form method='post' {$multipart} {$attributes_string}>\n"; $html .= "<input type='hidden' name='hidden[raven]' value='{$form_id}' />\n"; $html .= "<input type='hidden' name='hidden[formset]' value='{$formset}' />\n"; $html .= "<input type='hidden' name='hidden[return]' value='{$return}' />\n"; $html .= "<input type='hidden' name='hidden[error_return]' value='{$error_return}' />\n"; if ($edit) { $html .= "<input type='hidden' name='hidden[edit]' value='{$entry_hash}' />\n"; } /* |-------------------------------------------------------------------------- | Hook: Form Begin |-------------------------------------------------------------------------- | | Occurs in the middle the form allowing additional fields to be added. | Has access to the current fieldset. Must return HTML. | */ $html .= Hook::run('raven', 'inside_form', 'cumulative', ''); /* |-------------------------------------------------------------------------- | Hook: Content Preparse |-------------------------------------------------------------------------- | | Allows the modification of the tag data inside the form. Also has access | to the current formset. | */ $html .= Hook::run('raven', 'content_preparse', 'replace', $this->content, $this->content); $html .= "</form>"; return Parse::template($html, $data, array('statamic_view', 'callback'), $this->context); }
/** * Returns the contents of the current page. * * @package Theme * @return string The content. */ function content() { return Content::get(); }
function build_autos($items, $data, $user) { foreach ($items as $index => &$item) { if (isset($item['auto'])) { if (isset($data['urls'][$item['auto']])) { $item['path'] = $data['urls'][$item['auto']]; } else { if ($item['auto'] === 'set') { $item['path'] = ''; } } if ($item['auto'] === 'profile') { switch ($item['id']) { case 'twitter': $item['path'] = 'https://twitter.com/' . $user->twitter; break; default: $item['path'] = $user->{$item['id']}; if (empty($item['path'])) { unset($items[$index]); continue; } break; } if (!isset($item['label']) || empty($item['label'])) { $item['label'] = ucwords($item['id']) . ($item['id'] === 'google' ? '+' : ''); } } else { if ($item['auto'] === 'rss') { $item['path'] = '/feed/' . $item['id'] . ($item['id'] === 'essay' ? 's' : '') . '/recent.rss'; if (!isset($item['label'])) { $item['label'] = $data['url_data'][$item['id']]['plural'] . ' RSS'; } } else { if (preg_match('/s$/', $item['auto']) || $item['auto'] === 'timeline') { if ($item['auto'] === 'timeline' && isset($item['year'])) { $item['path'] .= $item['year'] . '/'; if (isset($item['month']) && $item['month'] !== false && $item['month'] !== 'any') { $m = str_pad($item['month'], 2, '0', STR_PAD_LEFT); $item['path'] .= $m . '/'; } } if (strpos($item['auto'], '_') !== false) { foreach (array('id', 'slug', 'month', 'year', 'day') as $id) { if ($id === 'month') { if (!isset($item['month']) || $item['month'] === 'any' || $item['month'] === false) { $item['month'] = ''; } else { $item['month'] = str_pad($item['month'], 2, '0', STR_PAD_LEFT); } } if ($id === 'day' && !isset($item['day'])) { $item['day'] = ''; } if ($id === 'slug' && !isset($item['slug']) && isset($item['id'])) { if (strpos($item['auto'], 'tag_') === 0) { $item['slug'] = $item['id']; } else { $c = new Category(); if (is_numeric($item['id'])) { $c->select('slug')->get_by_id($item['id']); $item['slug'] = $c->slug; } else { $item['slug'] = $item['id']; } } } if (isset($item[$id])) { $item['path'] = str_replace(":{$id}", $item[$id], $item['path']); } } } else { if (!isset($item['label'])) { $item['label'] = $data['url_data'][$item['auto'] === 'categories' ? 'category' : rtrim($item['auto'], 's')]['plural']; } } } else { if ($item['auto'] === 'home') { if (!isset($item['label'])) { $item['label'] = $data['url_data']['home']; } $item['path'] = '/home/'; } else { if ($item['auto'] === 'album' || $item['auto'] === 'set') { $a = new Album(); $a->select('id,slug,created_on,title'); if (is_numeric($item['id'])) { $a->where('id', $item['id']); } else { $a->where('slug', $item['id'])->or_where('internal_id', $item['id']); } $a->get(); if (!$a->exists()) { unset($items[$index]); continue; } $item['path'] = str_replace(':id', $a->id, $item['path']); $item['path'] = str_replace(':slug', $a->slug, $item['path']); $item['path'] = str_replace(':year', date('Y', $a->created_on), $item['path']); $item['path'] = str_replace(':month', date('m', $a->created_on), $item['path']); $item['path'] = str_replace(':day', date('d', $a->created_on), $item['path']); if (!isset($item['label'])) { $item['label'] = $a->title; } } else { if ($item['auto'] === 'page' || $item['auto'] === 'essay') { $t = new Text(); $t->select('id,slug,published_on,title'); if (is_numeric($item['id'])) { $t->where('id', $item['id']); } else { $t->where('slug', $item['id']); } $t->get(); if (!$t->exists()) { unset($items[$index]); continue; } $item['path'] = str_replace(':id', $t->id, $item['path']); $item['path'] = str_replace(':slug', $t->slug, $item['path']); $item['path'] = str_replace(':year', date('Y', $t->published_on), $item['path']); $item['path'] = str_replace(':month', date('m', $t->published_on), $item['path']); $item['path'] = str_replace(':day', date('d', $t->published_on), $item['path']); if (!isset($item['label'])) { $item['label'] = $t->title; } } else { if ($item['auto'] === 'content') { $c = new Content(); $c->select('id,slug,captured_on,title'); if (isset($item['album_id'])) { $item['path'] = preg_replace('/:(id|slug)/', ':album_$1', $data['urls']['album']) . substr(str_replace(':year/:month/', '', $data['urls']['content']), 1); $a = new Album(); $a->select('id,slug,created_on,title'); if (is_numeric($item['album_id'])) { $a->where('id', $item['album_id']); } else { $a->where('slug', $item['album_id'])->or_where('internal_id', $item['album_id']); } $a->get(); if (!$a->exists()) { unset($items[$index]); continue; } $item['path'] = str_replace(':album_id', $a->id, $item['path']); $item['path'] = str_replace(':album_slug', $a->slug, $item['path']); $date = $a->created_on; } else { $date = $c->captured_on; } if (is_numeric($item['id'])) { $c->where('id', $item['id']); } else { $c->where('slug', $item['id'])->or_where('internal_id', $item['id']); } $c->get(); if (!$c->exists()) { unset($items[$index]); continue; } $item['path'] = str_replace(':id', $c->id, $item['path']); $item['path'] = str_replace(':slug', $c->slug, $item['path']); $item['path'] = str_replace(':year', date('Y', $date), $item['path']); $item['path'] = str_replace(':month', date('m', $date), $item['path']); $item['path'] = str_replace(':day', date('d', $date), $item['path']); if (!isset($item['label'])) { $item['label'] = $c->title; } if (isset($item['lightbox']) && $item['lightbox']) { $item['path'] .= 'lightbox/'; } } else { if ($item['auto'] === 'tag') { $item['path'] = str_replace(':slug', $item['id'], $item['path']); } } } } } } } } if ($item['auto'] !== 'profile') { $item['path'] = str_replace(array(':year', ':month'), '', $item['path']); $item['path'] = preg_replace('/[\\(\\)\\?\\:]/', '', $item['path']); $item['path'] = preg_replace('~[/]+~', '/', $item['path']); } } } return $items; }
public static function add_default_blog($user_id) { require_once "api/CNBlogPost/CNBlogPost.php"; $extra = unserialize(PA::$network_info->extra); if ($extra['user_defaults']['default_blog'] != NET_NO) { // if network operator has set a default blog $net_extra_blog_id = (int) $extra['user_defaults']['default_blog']; $condition = 'content_id = ' . $net_extra_blog_id; $admin_content = Content::get(NULL, $condition); $no_display_on_home_page = !DISPLAY_ON_HOMEPAGE; if (!empty($admin_content[0])) { try { $post_saved = CNBlogPost::save_blogpost(0, $user_id, $admin_content[0]['title'], $admin_content[0]['body'], NULL, NULL, -1, ACTIVE, $no_display_on_home_page, TRUE); } catch (CNException $e) { throw $e; } } } // end of if }
/** * Gets a tree of content information * * @param string $base_url URL for the base of the tree to load * @param int $depth Number of levels deep to return * @param boolean $folders_only Folders only * @param boolean $include_entries Should we include entries in our tree? * @param boolean $show_hidden Should we not include hidden content * @param boolean $include_content Should we include content from the found info? * @param mixed $exclude Array of URLs to exclude * @return array */ public static function getContentTree($base_url, $depth = 12, $folders_only = true, $include_entries = false, $show_hidden = false, $include_content = false, $exclude = false) { // load structure and set up variables self::loadStructure(); $output = array(); // exclude URLs $exclude = Helper::ensureArray($exclude); // no depth asked for if ($depth == 0) { return array(); } // make sure we can find the requested URL in the structure if (!isset(self::$structure[$base_url])) { Log::debug('Could not find URL in structure cache.', 'core', 'ContentService'); return array(); } // depth measurements $starting_depth = self::$structure[$base_url]['depth'] + 1; // start one deeper than the base URL's depth $current_depth = $starting_depth; // recursively grab the tree foreach (self::$structure as $url => $data) { // is this the right depth and not the 404 page? if ($data['depth'] !== $current_depth || $url == "/404") { continue; } // is this under the appropriate parent? if (!Pattern::startsWith(Path::tidy($data['parent'] . '/'), Path::tidy($base_url . '/'))) { continue; } // is this hidden? if ($data['is_draft'] || !$show_hidden && $data['is_hidden']) { continue; } // is this an entry when we don't want them? if (!$include_entries && $data['is_entry'] && !$data['is_page']) { continue; } // is this a non-folder when all we want is folders? if ($folders_only && $data['type'] != 'folder') { continue; } // is this in the excluded URLs list? if (in_array($url, $exclude)) { continue; } // get parent url $parent_url = substr($url, 0, strrpos($url, '/')); $parent_url = $parent_url == "" ? Config::getSiteRoot() : $parent_url; // look up parent data in cache if (!isset(self::$parent_cache[$parent_url])) { // doesn't exist, load it up $parent_data = Content::get($parent_url, $include_content, false); if ($include_content) { // give them everything $parent = $parent_data; } else { // just the bare necessities $parent = array('title' => isset($parent_data['title']) ? $parent_data['title'] : '', 'url' => isset($parent_data['url']) ? $parent_data['url'] : ''); } // now stick this in the cache for next time self::$parent_cache[$parent_url] = $parent; } // get information $content = Content::get($url, $include_content, false); // data to be returned to the tree $for_output = array('type' => $data['type'], 'title' => isset($content['title']) ? $content['title'] : '', 'slug' => $content['slug'], 'url' => $url, 'depth' => $current_depth, 'children' => self::getContentTree($url, $depth - 1, $folders_only, $include_entries, $show_hidden, $include_content, $exclude), 'is_current' => URL::getCurrent() == $url, 'is_parent' => URL::getCurrent() != $url && Pattern::startsWith(URL::getCurrent(), $url . '/'), 'is_entry' => $data['is_entry'], 'is_page' => $data['is_page'], 'is_folder' => $data['type'] == 'folder', 'order_key' => $data['order_key'], 'sub_order_key' => $data['sub_order_key'], 'parent' => array(self::$parent_cache[$parent_url])); // if we're including content, merge that in if ($include_content) { $for_output = $content + $for_output; } // add it to the list $output[] = $for_output; } // now we need to sort the nav items uasort($output, function ($a, $b) { // sort on order_key $result = Helper::compareValues($a['order_key'], $b['order_key']); // if those matched, sort on sub_order_key if ($result === 0) { $result = Helper::compareValues($a['sub_order_key'], $b['sub_order_key']); } // return 1 or 0 or -1, whatever we ended up with return $result; }); // re-key the array $output = array_values($output); // return what we know return $output; }
<?php session_start(); $luog = $_GET['luoghi_id']; $_SESSION['var'] = $luog; require "include/template2.inc.php"; require "include/beContent.inc.php"; require "include/content.inc.php"; if (!$_SESSION['username']) { $main = new Skin("nevia"); } else { $main = new Skin("loggato"); } $body = new Skinlet("home"); $rece = new Skinlet("recluogo"); $luoghi = new Content($luoghiEntity); $luoghi->setTemplate("luogo-i"); $main->setContent("body", $luoghi->get()); $recensioni = new Content($recensioniEntity); $recensioni->setTemplate("recluogo"); $recensioni->setParameter("id_luoghi", $luog); $recensioni->setOrderFields("id DESC"); $recensioni->setLimit(3); $recensioni->applyIndexed($recensioni); $recensioni->apply($rece); $main->setContent('recensioni', $rece->get()); $main->close();
// legacy status } elseif (isset($data['status']) && $data['status'] != 'live' && $data['status'] != 'hidden' && !$app->config['logged_in']) { $data = Content::get(Path::tidy(Config::getSiteRoot() . "/404")); $template_list = array('404'); $visible = false; $response_code = 404; } // find next/previous if ($add_prev_next && $visible) { $folder = substr(preg_replace(Pattern::ORDER_KEY, "", substr($path, 0, -1 * strlen($page) - 1)), 1); $relative = Statamic::find_relative($current_url, $folder); $data['prev'] = $relative['prev']; $data['next'] = $relative['next']; } // grab data for this folder $folder_data = Content::get(dirname($current_url)); // set defaults for template and layout if needed if (empty($data['_template']) && !empty($folder_data['_default_folder_template'])) { $data['_template'] = $folder_data['_default_folder_template']; } if (empty($data['_layout']) && !empty($folder_data['_default_folder_layout'])) { $data['_layout'] = $folder_data['_default_folder_layout']; } // set template and layout if (isset($data['_template'])) { $template_list[] = $data['_template']; } if (isset($data['_layout'])) { Statamic_View::set_layout("layouts/{$data['_layout']}"); } // set up the view
if (isset($law->previous_section)) { $content->set('prev_next', '<li><a href="' . $law->previous_section->url . '" class="prev" title="Previous section"><span>← Previous</span>' . $law->previous_section->section_number . ' ' . $law->previous_section->catch_line . '</a></li>'); $content->append('link_rel', '<link rel="prev" title="Previous" href="' . $law->previous_section->url . '" />'); } else { $content->set('prev_next', '<li></li>'); } /* * If there is a next section in this chapter, provide a forward arrow. */ if (isset($law->next_section)) { $content->append('prev_next', '<li><a href="' . $law->next_section->url . '" class="next" title="Next section"><span>Next →</span>' . $law->next_section->section_number . ' ' . $law->next_section->catch_line . '</a></li>'); $content->append('link_rel', '<link rel="next" title="Next" href="' . $law->next_section->url . '" />'); } else { $content->append('prev_next', '<li></li>'); } $content->set('heading', '<nav class="prevnext" role="navigation"><ul>' . $content->get('prev_next') . '</ul></nav><nav class="breadcrumbs" role="navigation">' . $content->get('breadcrumbs') . '</nav>'); /* * Store the URL for the containing structural unit. */ $content->append('link_rel', '<link rel="up" title="Up" href="' . $law->ancestry->{1}->url . '" />'); /* * Start assembling the body of this page by indicating the beginning of the text of the section. */ $body = '<article id="law">'; /* * Display the rendered HTML of this law. */ $body .= $law->html; /* * If we both the raw history text and translated (prose-style) history text, display both formats. */
if ($level == end($structure)) { $active = 'active'; } $content->append('breadcrumbs', '<li class="' . $active . '"> <a href="' . $level->url . '">' . $level->identifier . ': ' . $level->name . '</a> </li>'); /* * If this structural element is the same as the parent container, then use that knowledge * to populate the link rel="up" tag. */ if ($level->id == $struct->parent_id) { $content->set('link_rel', '<link rel="up" title="Up" href="' . $level->url . '" />'); } } } if (strlen($content->get('breadcrumbs')) > 0) { $content->prepend('breadcrumbs', '<ul class="steps-nav">'); $content->append('breadcrumbs', '</ul>'); $content->set('heading', '<nav class="breadcrumbs" role="navigation">' . $content->get('breadcrumbs') . '</nav>'); } else { /* * Make the "up" link a link to the home page. */ $content->set('link_rel', '<link rel="up" title="Up" href="/browse/" />'); } /* * Provide link relations for the previous and next sibling structural units. */ if (isset($struct->siblings)) { /* * Locate the instant structural unit within the structure listing.
<?php session_start(); require "include/template2.inc.php"; require "include/beContent.inc.php"; require "include/content.inc.php"; $main = new Skin("aqua"); $content = new Content($usersEntity, $facultyRoleEntity, $ssdEntity, $areaEntity); $content->setFilter("users.active_home = '*'"); $content->setStyle(HIERARCHICAL); $content->setOrderFields("facultyrole.position", "surname", "name"); $content->setPresentation("facultyrole_name_plural", "users_username", "users_name", "users_surname", "users_email", "area_id", "area_title", "ssd_id", "ssd_name"); $main->setContent("body", $content->get()); $main->close(); ?>
/** * Does the current member have access to a given $url? * * @param string $url URL to check * @return boolean * @throws Exception */ public function hasAccess($url = null) { // load data for the given $url $data = Content::get($url); if (!isset($data['_protect']) || !$data['_protect']) { return true; } // grab the protection scheme $scheme = $data['_protect']; // determine URLs $login_url = URL::prependSiteRoot(array_get($scheme, 'login_url', $this->fetchConfig('login_url', '/', null, false, false))); $no_access_url = URL::prependSiteRoot(array_get($scheme, 'no_access_url', $this->fetchConfig('no_access_url', '/', null, false, false))); $password_url = URL::prependSiteRoot(array_get($scheme, 'password_form_url', $this->fetchConfig('password_url', '/', null, false, false))); // support external log-in systems $require_member = array_get($scheme, 'require_member', $this->fetchConfig('require_member', true, null, true, false)); $return_variable = array_get($scheme, 'return_variable', $this->fetchConfig('return_variable', 'return', null, false, false)); $use_full_url = array_get($scheme, 'use_full_url', $this->fetchConfig('use_full_url', false, null, true, false)); // get the current URL $current_url = $use_full_url ? URL::tidy(Config::getSiteURL() . '/' . URL::getCurrent()) : URL::getCurrent(); // append query string if (!empty($_GET)) { $current_url .= '?' . http_build_query($_GET, '', '&'); } // store if we've matched $match = false; if (isset($scheme['password'])) { // this is a password-check // get the form URL $form_url = array_get($scheme['password'], 'form_url', Helper::pick($password_url, $no_access_url)); // check for passwords if (!$this->evaluatePassword($url)) { URL::redirect(URL::appendGetVariable($form_url, $return_variable, $current_url), 302); exit; } // we're good return true; } elseif (isset($scheme['ip_address'])) { // this is an IP-address-check if (!$this->evaluateIP($url)) { URL::redirect($no_access_url, 302); exit; } } else { try { // are we going to allow or deny people? if (isset($scheme['allow']) && is_array($scheme['allow'])) { $type = 'allow'; $rules = $scheme['allow']; } elseif (isset($scheme['deny']) && is_array($scheme['deny'])) { $type = 'deny'; $rules = $scheme['deny']; } else { throw new Exception('The `_protect` field is set for [' . $data['url'] . '](' . $data['url'] . '), but the configuration given could not be parsed. For caution’s sake, *everyone* is being blocked from this content.'); } // if $require_member is true, do a check up-front to see if // this user is currently logged in if ($require_member && !Auth::isLoggedIn()) { URL::redirect(URL::appendGetVariable($login_url, $return_variable, $current_url), 302); exit; } // parse the rules foreach ($rules as $key => $value) { if ($this->tasks->evaluateRule($key, $value)) { $match = true; break; } } // send to no access page if user didn't match and needed to, or did and shouldn't have if (!$match && $type === 'allow' || $match && $type === 'deny') { URL::redirect($no_access_url, 302); exit; } } catch (\Slim\Exception\Stop $e) { throw $e; } catch (Exception $e) { // something has gone wrong, log the message Log::error($e->getMessage(), "api", "security"); // always return false URL::redirect($no_access_url, 302); } } }
<?php session_start(); require "include/template2.inc.php"; require "include/beContent.inc.php"; require "include/content.inc.php"; $main = new Skin("nevia"); $page = new Content($pageEntity); $page->setTemplate("page_single_2"); $main->setContent("body", $page->get()); $main->close();
$more = 'There is a bad link on <a href="' . $local_referrer . '">' . $local_referrer . '</a>.'; $aspect = 'page'; } else { // external site linked to here $more = 'User clicked an outside bad link at <a href="' . $_SERVER['HTTP_REFERER'] . '">' . $_SERVER['HTTP_REFERER'] . '</a>.'; $aspect = 'external'; } } else { // user typing error $more = 'Visitor came directly to this page and may have typed the URL incorrectly.'; $aspect = 'visitor'; } Log::error("404 - Page not found. " . $more, $aspect, "content"); $data = Content::get(Path::tidy(Config::getSiteRoot() . "/404")); $template_list = array('404'); $response_code = 404; // set template and layout if (isset($data['_template'])) { $template_list[] = $data['_template']; } if (isset($data['_layout'])) { Statamic_View::set_layout("layouts/{$data['_layout']}"); } // set up the view Statamic_View::set_templates(array_reverse($template_list));
public function breadcrumbs() { $url = $this->fetchParam('from', URL::getCurrent()); $include_home = $this->fetchParam('include_home', true, false, true); $reverse = $this->fetchParam('reverse', false, false, true); $backspace = $this->fetchParam('backspace', false, 'is_numeric', false); $include_content = $this->fetchParam('include_content', false, null, true); $trim = $this->fetchParam('trim', true, null, true); $tag_content = $trim ? trim($this->content) : $this->content; // add in left-/ if not present if (substr($url, 0, 1) !== '/') { $url = '/' . $url; } // if this doesn't start with the site root, add the site root if (!Pattern::startsWith($url, Config::getSiteRoot())) { $url = Path::tidy(Config::getSiteRoot(), $url); } // start crumbs $crumbs = array(); // we only want to show breadcrumbs when we're not on the homepage if ($url !== Config::getSiteRoot()) { $segments = explode('/', ltrim(str_replace(Config::getSiteRoot(), '/', $url), '/')); $segment_count = count($segments); $segment_urls = array(); // create crumbs from segments for ($i = 1; $i <= $segment_count; $i++) { $segment_urls[] = '/' . join($segments, '/'); array_pop($segments); } // should we also include the homepage? if ($include_home) { $segment_urls[] = Config::getSiteRoot(); } // grab data for each foreach ($segment_urls as $url) { $this_url = Path::tidy(Config::getSiteRoot() . '/' . $url); $content = Content::get($this_url, $include_content); if ($content) { // standard stuff $crumbs[$this_url] = $content; } else { // no content found? this could be a taxonomy $crumbs[$this_url] = array('url' => $this_url, 'title' => ucwords(substr($url, strrpos($url, '/') + 1))); } $crumbs[$this_url]['is_current'] = URL::getCurrent() == $this_url; } // correct order if (!$reverse) { $crumbs = array_reverse($crumbs); } // add first, last, and index $i = 1; $crumb_count = count($crumbs); foreach ($crumbs as $key => $crumb) { $crumbs[$key]['first'] = $i === 1; $crumbs[$key]['last'] = $i === $crumb_count; $crumbs[$key]['index'] = $i; $i++; } if (!count($crumbs)) { $output = Parse::template($tag_content, array('no_results' => true)); if ($backspace) { $output = substr($output, 0, -$backspace); } } else { $output = Parse::tagLoop($tag_content, $crumbs); if ($backspace) { $output = substr($output, 0, -$backspace); } } } else { $output = Parse::template($tag_content, array('no_results' => true)); } // parse the loop return $output; }
public static function call() { $task = $_POST['task']; if ($task == 'getContent' && isset($_POST['title'])) { include_once 'Content.php'; Content::getFromTitle(); } else { if ($task == 'getContent') { include_once 'Content.php'; Content::get(); } else { if ($task == 'addContent') { include_once 'Content.php'; Content::add(); } else { if ($task == 'editContent') { include_once 'Content.php'; Content::edit(); } else { if ($task == 'deleteContent') { include_once 'Content.php'; Content::remove(); } else { if ($task == 'getType') { include_once 'Type.php'; Type::get(); } else { if ($task == 'addType') { include_once 'Type.php'; Type::add(); } else { if ($task == 'editType') { include_once 'Type.php'; Type::edit(); } else { if ($task == 'deleteType') { include_once 'Type.php'; Type::remove(); } else { if ($task == 'getContentOnUser') { include_once 'ContentOnUser.php'; ContentOnUser::get(); } else { if ($task == 'addContentToUser') { include_once 'ContentOnUser.php'; ContentOnUser::add(); } else { if ($task == 'editContentOnUser') { include_once 'ContentOnUser.php'; ContentOnUser::edit(); } else { if ($task == 'removeContentFromUser') { include_once 'ContentOnUser.php'; ContentOnUser::remove(); } else { if ($task == 'useContentOnUser') { include_once 'ContentOnUser.php'; ContentOnUser::useContentOnUser(); } else { if ($task == 'getUser') { include_once 'User.php'; User::get(); } else { echo "Task not recognized.<br>"; } } } } } } } } } } } } } } } }
<?php session_start(); require "include/template2.inc.php"; require "include/beContent.inc.php"; require "include/content.inc.php"; if (!$_SESSION['username']) { $main = new Skin("nevia"); } else { $main = new Skin("loggato"); } $generic = new Content($genEntity); $generic->setTemplate("comearrivare"); $generic->setParameter("id", 2); $main->setContent("body", $generic->get()); $main->close();
<?php session_start(); require "include/template2.inc.php"; require "include/beContent.inc.php"; require "include/content.inc.php"; $main = new Skin("aqua"); $news = new Content($newsEntity, $usersEntity, $newsCatEntity); $news->setOrderFields("date DESC"); $main->setContent("body", $news->get()); $main->close();