public function index($value, $parameters = array()) { $full_url_start = Config::getSiteURL() . Config::getSiteRoot(); return preg_replace_callback('/="(\\/[^"]+)"/ism', function ($item) use($full_url_start) { return '="' . Path::tidy($full_url_start . $item[1]) . '"'; }, $value); }
public function render() { $options = $this->getConfig(); $field_options = array_get($this->field_config, 'options', array()); $options = array_merge($options, $field_options); // File options if ($file_dir = array_get($this->field_config, 'file_dir', false)) { $file_dir = trim(array_get($this->field_config, 'file_dir'), '/') . '/'; $options['fileUpload'] = Config::getSiteRoot() . 'TRIGGER/redactor/upload?path=' . $file_dir; $options['fileManagerJson'] = Config::getSiteRoot() . 'TRIGGER/redactor/fetch_files?path=' . $file_dir; $options['plugins'][] = 'filemanager'; } // Image options if ($image_dir = array_get($this->field_config, 'image_dir', false)) { $image_dir = trim(array_get($this->field_config, 'image_dir'), '/') . '/'; $options['imageUpload'] = Config::getSiteRoot() . 'TRIGGER/redactor/upload?path=' . $image_dir; $options['imageManagerJson'] = Config::getSiteRoot() . 'TRIGGER/redactor/fetch_images?path=' . $image_dir; $options['plugins'][] = 'imagemanager'; if ($resize = array_get($this->field_config, 'resize')) { $options['imageUpload'] .= '&resize=1&' . http_build_query($resize); } } // Enable plugins $supported_plugins = array('table', 'video', 'fullscreen', 'fontcolor', 'fontsize', 'fontfamily'); foreach ($options['buttons'] as $button) { if (in_array($button, $supported_plugins)) { $options['plugins'][] = $button; } } $vars = array('field_id' => $this->field_id, 'field_name' => $this->fieldname, 'tabindex' => $this->tabindex, 'field_data' => $this->field_data, 'field_config' => $this->field_config, 'options' => $options); $template = File::get($this->getAddonLocation() . 'views/fieldtype.html'); return Parse::template($template, $vars); }
public static function errorRedirect($errorMessage) { $_SESSION['errorMessage'] = $errorMessage; $errorUrl = Config::getSiteRoot() . "/error.php"; header("Location: " . $errorUrl); die; }
public function getContent() { $url = URL::assemble(Config::getSiteRoot(), $this->fetchConfig('globals_url', null, null, false, false)); $content = ContentService::getContentByUrl($url); $content = current($content->extract()); return $content; }
public function index() { $from = $this->fetchParam('from', false); if (!$from) { return null; } // account for subfolder if (strpos($from, Config::getSiteRoot()) !== 0) { $from = Path::tidy(Config::getSiteRoot() . $from); } $from = Path::addStartingSlash($from); $content_set = ContentService::getContentByURL($from); // filter $content_set->filter(array('show_hidden' => $this->fetchParam('show_hidden', false, null, true, false), 'show_drafts' => $this->fetchParam('show_drafts', false, null, true, false), 'show_past' => $this->fetchParam('show_past', true, null, true), 'show_future' => $this->fetchParam('show_future', false, null, true), 'type' => 'all', 'conditions' => trim($this->fetchParam('conditions', null, false, false, false)))); // limit $limit = $this->fetchParam('limit', 1, 'is_numeric'); $offset = $this->fetchParam('offset', 0, 'is_numeric'); $content_set->limit($limit, $offset); // check for results if (!$content_set->count()) { return Parse::tagLoop($this->content, array(array('no_results' => true))); } // if content is used in this entries loop, parse it $parse_content = (bool) preg_match(Pattern::USING_CONTENT, $this->content); return Parse::tagLoop($this->content, $content_set->get($parse_content), false, $this->context); }
public function __construct() { parent::__construct(); $this->theme_assets_path = Config::getThemeAssetsPath(); $this->theme_path = Config::getCurrentthemePath(); $this->theme_root = Config::getTemplatesPath(); $this->site_root = Config::getSiteRoot(); }
/** * Get the full URL for the current request. * * @param boolean $include_root Should this include the site root itself? * @return string */ public static function getCurrent($include_root = true) { $url = Request::getResourceURI(); if ($include_root) { $url = Config::getSiteRoot() . '/' . $url; } return self::format($url); }
/** * Returns the URL for a given $taxonomy and $taxonomy_slug * * @param string $folder Folder to use * @param string $taxonomy Taxonomy to use * @param string $taxonomy_slug Taxonomy slug to use * @return string */ public static function getURL($folder, $taxonomy, $taxonomy_slug) { $url = Config::getSiteRoot() . '/' . $folder . '/' . $taxonomy . '/'; $url .= Config::getTaxonomySlugify() ? Slug::make($taxonomy_slug) : $taxonomy_slug; // if taxonomies are not case-sensitive, make it lowercase if (!Config::getTaxonomyCaseSensitive()) { $url = strtolower($url); } return Path::tidy($url); }
public function index() { // we need the local path if (!isset($this->context['_local_path'])) { return ''; } // local path exists, return the correct format $path = Config::get('_admin_path') . '.php/publish?path=' . substr($this->context['_local_path'], 1, strrpos($this->context['_local_path'], '.') - 1); return URL::assemble(Config::getSiteRoot(), $path); }
/** * Contextualizes taxonomy links for a given folder * * @param string $folder Folder to insert * @return void */ public function contextualize($folder = NULL) { // this may be empty, if so, abort if (!$folder) { return; } // create the contextual URL root that we'll append the slug to $contextual_url_root = Config::getSiteRoot() . $folder . "/"; // append the slug foreach ($this->data as $value => $parts) { $this->data[$value]['url'] = Path::tidy($contextual_url_root . $parts['slug']); } }
private function order_set($page_order, $entry_folder) { $content_path = Config::getContentRoot(); $entries = Statamic::get_content_tree('/' . $entry_folder, 3, 5, false, true); $result = array('linkage' => null, 'message' => 'Page order saved successfully!', 'status' => 'success'); // Array to store the links of old data coupled with new data. // We return this to the view so we can use JS to update the pathing on the page. $links = array(); // Loop over original folder structure and rename all folders to // reflect the new order. $entry_url = implode('/', explode('/', $page_order[0]->url, -1)); $entry_url = str_replace(Config::getSiteRoot(), '', $entry_folder); foreach ($page_order as $page) { $page_url = str_replace(Config::getSiteRoot(), '/', $page->url); foreach ($entries as $entry) { // Store original folder data. $file_ext = pathinfo($entry['raw_url'], PATHINFO_EXTENSION); // used to generate the old pathing info. $old_slug = $entry['slug']; // Match on the URL to get the correct order result for this item. if ($page_url == $entry['url']) { break; } } $slug = explode('/', $page->url); $slug = preg_replace("/^\\/(.+)/uis", "\$1", end($slug)); $new_name = sprintf("%02d", $page->index + 1) . '.' . $slug; $old_name = $old_slug; $links[] = array('old' => $old_name, 'new' => $new_name); $folder_path = $content_path . "/" . $entry_folder . "/"; // Generate pathing to pass to rename() $new_path = $folder_path . $new_name . '.' . $file_ext; $old_path = $folder_path . $old_name . '.' . $file_ext; if ($new_path !== $old_path) { // Check the old path actually exists and the new one doesn't. if (File::exists($old_path) && !File::exists($new_path)) { rename($old_path, $new_path); } else { $result['status'] = 'error'; $result['message'] = 'Aborting: Can\'t guarantee file integrity ' . 'for folders ' . $old_path . ' & ' . $new_path; Log::error($result['message'], 'pagereorder_redux'); break; } } } if ($result['status'] !== 'error') { // No error, set links $result['linkage'] = $links; } return $result; }
public function file__render_thumbnail() { if (!($path = Request::get('path'))) { exit('No path specified'); } $url = Path::toAsset($this->getTransformedImage($path)); $url = Config::getSiteRoot() !== '/' ? str_replace(Config::getSiteRoot(), '', $url) : $url; $file = Path::assemble(BASE_PATH, $url); header('Content-type: image/jpeg'); header('Content-length: ' . filesize($file)); if ($file = fopen($file, 'rb')) { fpassthru($file); } exit; }
public function process() { $data = json_decode($this->field_data); // Normalize paths if we are running in a subdirectory if (($site_root = Config::getSiteRoot()) != '/') { foreach ($data as $i => $file) { $data[$i] = preg_replace('#^' . $site_root . '#', '/', $file); } } // Turn an array with one key into a string unless we want to force it into an array if (count($data) == 1 && !array_get($this->settings, 'force_array', false)) { $data = $data[0]; } elseif (count($data) == 0) { $data = ''; } return $data; }
public function render() { $base_url = Config::getSiteRoot() . 'TRIGGER/markitup/upload'; // build file url $file_path = Path::tidy(array_get($this->field_config, 'file_dir') . '/'); $file_url = "{$base_url}?path={$file_path}"; // build image url $image_path = Path::tidy(array_get($this->field_config, 'image_dir') . '/'); $image_options = array('path' => $image_path, 'is_image' => true); $resize_options = array_get($this->field_config, 'resize', array()); if (count($resize_options)) { $image_options['resize'] = true; $image_options += $resize_options; } $image_options_string = http_build_query($image_options); $image_url = "{$base_url}?{$image_options_string}"; // build field $height = isset($this->field_config['height']) ? $this->field_config['height'] . 'px' : '300px'; $html = "\n <textarea\n name='{$this->fieldname}'\n style='height:{$height}'\n tabindex='{$this->tabindex}'\n class='input-textarea markitup'\n data-image-url='{$image_url}'\n data-file-url='{$file_url}'\n >{$this->field_data}</textarea>"; return $html; }
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); $url = Path::resolve($url); $crumbs = array(); if ($url != '/') { $segments = explode('/', ltrim($url, '/')); $segment_count = count($segments); $segment_urls = array(); for ($i = 1; $i <= $segment_count; $i++) { $segment_urls[] = implode($segments, '/'); array_pop($segments); } # Build array of breadcrumb pages foreach ($segment_urls as $key => $url) { $crumbs[$url] = Statamic::fetch_content_by_url($url); $page_url = '/' . rtrim(preg_replace(Pattern::NUMERIC, '', $url), '/'); $crumbs[$url]['url'] = $page_url; $crumbs[$url]['is_current'] = $page_url == URL::getCurrent(); } } # Add homepage if ($include_home) { $crumbs['/'] = Statamic::fetch_content_by_url('/'); $crumbs['/']['url'] = Config::getSiteRoot(); $crumbs['/']['is_current'] = URL::getCurrent() == '/'; } # correct order if ($reverse !== TRUE) { $crumbs = array_reverse($crumbs); } $output = Parse::tagLoop(trim($this->content), $crumbs); if ($backspace) { $output = substr($output, 0, -$backspace); } return $output; }
public function password_form() { // fetch parameters $return = $this->fetch('return', filter_input(INPUT_GET, 'return', FILTER_SANITIZE_STRING), null, false, false); $attr = $this->fetchParam('attr', false); // set up data to be parsed into content $data = array('error' => $this->flash->get('error', ''), 'field_name' => 'password'); // determine form attributes $attr_string = ''; if ($attr) { $attributes_array = Helper::explodeOptions($attr, true); foreach ($attributes_array as $key => $value) { $attr_string .= ' ' . $key . '="' . $value . '"'; } } // build the form $html = '<form action="' . Path::tidy(Config::getSiteRoot() . '/TRIGGER/protect/password') . '" method="post"' . $attr_string . '>'; $html .= '<input type="hidden" name="return" value="' . $return . '">'; $html .= '<input type="hidden" name="token" value="' . $this->tokens->create() . '">'; $html .= Parse::template($this->content, $data); $html .= '</form>'; // return the HTML return $html; }
public function login() { // deprecation warning $this->log->warn("Use of `login` is deprecated. Use `login_form` instead."); $site_root = Config::getSiteRoot(); $return = $this->fetchParam('return', $site_root); /* |-------------------------------------------------------------------------- | Form HTML |-------------------------------------------------------------------------- | | The login form writes a hidden field to the form to set the return url. | 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 | */ $attributes_string = ''; if ($attr = $this->fetchParam('attr', false)) { $attributes_array = Helper::explodeOptions($attr, true); foreach ($attributes_array as $key => $value) { $attributes_string .= " {$key}='{$value}'"; } } $html = "<form method='post' action='" . Path::tidy($site_root . "/TRIGGER/member/login") . "' {$attributes_string}>"; $html .= "<input type='hidden' name='return' value='{$return}' />"; $html .= $this->content; $html .= "</form>"; return $html; }
public function redactor__fetch_images() { if (!Auth::getCurrentMember()) { exit("Invalid Request"); } $dir = Path::tidy(ltrim(Request::get('path'), '/') . '/'); $image_list = glob($dir . "*.{jpg,jpeg,gif,png}", GLOB_BRACE); $images = array(); if (count($image_list) > 0) { foreach ($image_list as $image) { $images[] = array('thumb' => Config::getSiteRoot() . $image, 'image' => Config::getSiteRoot() . $image); } } echo json_encode($images); }
public function reset_password_form() { $data = array(); $errors = array(); // parse parameters and vars $attr_string = ''; $site_root = Config::getSiteRoot(); $logged_in_redirect = $this->fetchParam('logged_in_redirect', $this->fetchConfig('member_home', $site_root), null, false, false); $attr = $this->fetchParam('attr', false); $hash = filter_input(INPUT_GET, 'H', FILTER_SANITIZE_URL); // is user already logged in? forward as needed if (Auth::isLoggedIn()) { URL::redirect($logged_in_redirect, 302); } // no hash in URL? if (!$hash) { $errors[] = Localization::fetch('reset_password_url_invalid'); $data['url_invalid'] = true; } if (count($errors) == 0) { // cache file doesn't exist or is too old if (!$this->cache->exists($hash) || $this->cache->getAge($hash) > $this->fetchConfig('reset_password_age_limit') * 60) { $errors[] = Localization::fetch('reset_password_url_expired'); $data['expired'] = true; } // flash errors if ($flash_error = $this->flash->get('reset_password_error')) { $errors[] = $flash_error; } } // set up attributes if ($attr) { $attributes_array = Helper::explodeOptions($attr, true); foreach ($attributes_array as $key => $value) { $attr_string .= ' ' . $key . '="' . $value . '"'; } } // errors $data['errors'] = $errors; // set up form HTML $html = '<form method="post" action="' . Path::tidy($site_root . "/TRIGGER/member/reset_password") . '" ' . $attr_string . '>'; $html .= '<input type="hidden" name="token" value="' . $this->tokens->create() . '">'; $html .= '<input type="hidden" name="hash" value="' . $hash . '">'; $html .= Parse::template($this->content, $data); $html .= '</form>'; // return that HTML return $html; }
/** * Gets a list of taxonomy values by type * * @param string $type Taxonomy type to retrieve * @return TaxonomySet */ public static function getTaxonomiesByType($type) { self::loadCache(); $data = array(); // taxonomy type doesn't exist, return empty if (!isset(self::$cache['taxonomies'][$type])) { return new TaxonomySet(array()); } $url_root = Config::getSiteRoot() . $type; $values = self::$cache['taxonomies'][$type]; $slugify = Config::getTaxonomySlugify(); // what we need // - name // - count of related content // - related foreach ($values as $key => $parts) { $set = array(); $prepared_key = $slugify ? Slug::make($key) : rawurlencode($key); foreach ($parts['files'] as $url) { if (!isset(self::$cache['urls'][$url])) { continue; } $set[$url] = self::$cache["content"][self::$cache['urls'][$url]['folder']][self::$cache['urls'][$url]['file']]['data']; } $data[$key] = array('content' => new ContentSet($set), 'name' => $parts['name'], 'url' => $url_root . '/' . $prepared_key, 'slug' => $type . '/' . $prepared_key); $data[$key]['count'] = $data[$key]['content']->count(); } return new TaxonomySet($data); }
<?php /* a utility page that generates the SQL for the specified entity * needs type as GET parameter (e.g. generateSQL.php?type=patient) */ include_once dirname(__FILE__) . '/../core/partials/pageCheck.php'; include_once dirname(__FILE__) . '/../core/classes/service.php'; include_once dirname(__FILE__) . '/../core/classes/dataentity.php'; include_once dirname(__FILE__) . '/../classes/application.php'; include_once dirname(__FILE__) . '/../classes/config.php'; // must be an super user to access this page if ($userID == 0 || $user && !$user->hasRole('superuser', $tenantID)) { Log::debug('Non super user (id=' . $userID . ') attempted to access generateSQL.php page', 10); $path = Config::getSiteRoot() . '/403.php'; header('Location: ' . $path); die; } $type = Utility::getRequestVariable('type', ''); if (strlen($type) < 1) { Service::returnError('Please specify a type'); } $coretypes = array('tenant', 'tenantSetting', 'tenantProperty', 'category', 'menuItem', 'page', 'pageCollection', 'content', 'tenantContent', 'entityList', 'entityListItem', 'propertyBag'); if (!in_array($type, $coretypes, false) && !in_array($type, Application::$knowntypes, false)) { // unrecognized type requested can't do much from here. Service::returnError('Unknown type: ' . $type, 400, 'entityService?type=' . $type); } $classpath = dirname(__FILE__) . '/../classes/'; if (in_array($type, $coretypes, false)) { // core types will be in core subfolder $classpath = Config::$core_path . '/classes'; }
$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));
foreach ($roleSet as $role) { if ($user->hasRole($role, $tenantID)) { $visible = true; break; } } } if ($visible) { $className = ''; if ($thisPage == $item["name"]) { $className = 'class="active"'; } $link = $item["link"]; if (strtolower(substr($link, 0, 4)) != "http") { // assume all links on menus are relative to site root unless they start with http $link = Config::getSiteRoot() . '/' . $link; } echo '<li ' . $className . '><a href=" ' . $link . '">' . $item["name"] . '</a></li>'; } } } if ($userID > 0 && ($user->hasRole('admin', $tenantID) || $userID == 1)) { ?> <li <?php if ($thisPage == 'admin') { echo ' class="active"'; } ?> ><a href="<?php echo Config::getCoreRoot(); ?>
public function logout() { $return = $this->fetchParam('return', '/'); return URL::assemble(Config::getSiteRoot(), "TRIGGER", 'member', "logout?return={$return}"); }
public function member__reset_password() { $site_root = Config::getSiteRoot(); $password = filter_input(INPUT_POST, 'password', FILTER_SANITIZE_STRING); $password_confirm = filter_input(INPUT_POST, 'password_confirmation', FILTER_SANITIZE_STRING); $token = filter_input(INPUT_POST, 'token', FILTER_SANITIZE_STRING); $hash = filter_input(INPUT_POST, 'hash', FILTER_SANITIZE_STRING); $referrer = $_SERVER['HTTP_REFERER']; // validate form token if (!$this->tokens->validate($token)) { $this->flash->set('reset_password_error', 'Invalid token.'); URL::redirect($referrer); } // bail if cache doesnt exist or if its too old. // this should have been caught on the page itself, // but if it got submitted somehow, just redirect and the error logic will be in the plugin. if (!$this->cache->exists($hash) || $this->cache->getAge($hash) > $this->fetchConfig('reset_password_age_limit', 20, 'is_numeric') * 60) { URL::redirect($referrer); } // password check if (is_null($password) || $password == '') { $this->flash->set('reset_password_error', 'Password cannot be blank.'); URL::redirect($referrer); } // password confirmation check if (!is_null($password_confirm) && $password !== $password_confirm) { $this->flash->set('reset_password_error', 'Passwords did not match.'); URL::redirect($referrer); } // get username $cache = $this->cache->getYAML($hash); $username = $cache['username']; // change password $member = Member::load($username); $member->set('password', $password); $member->save(); // delete used cache $this->cache->delete($hash); // redirect URL::redirect(array_get($cache, 'return', $this->fetchConfig('member_home', $site_root, null, false, false))); }
if (!Config::get('disable_google_fonts', false)) { ?> <link rel="stylesheet" href="//fonts.googleapis.com/css?family=Raleway:400,700|Open+Sans:400italic,400,600" /> <?php } ?> <link rel="stylesheet" href="<?php echo Path::tidy(Config::getSiteRoot() . '/' . $app->config['theme_path']); ?> css/ascent.min.css"> <link rel="icon" href="<?php echo Path::tidy(Config::getSiteRoot() . '/' . $app->config['theme_path']); ?> img/favicon.png" sizes="16x16" type="img/png" /> <script type="text/javascript" src="<?php echo Path::tidy(Config::getSiteRoot() . '/' . $app->config['theme_path']); ?> js/ascent.min.js"></script> <?php echo Hook::run('control_panel', 'add_to_head', 'cumulative'); ?> </head> <body id="login"> <?php echo $_html; ?> <?php echo Hook::run('control_panel', 'add_to_foot', 'cumulative'); ?> </body> </html>
<?php if (strlen($feature["subhead"]) > 0) { echo '<h2>' . $feature["subhead"] . '</h2>'; } if (strlen($feature["authorName"]) > 0) { echo '<p class="author">By <a href="author.php?id=' . $feature["author"] . '">' . $feature["authorName"] . "</a></p>"; } if (strlen($feature["datePosted"]) > 0) { echo '<p class="postdate">Posted ' . Format::formatDateLine($feature["datePosted"], true) . "</p>"; } ?> </div> <div id="featureSocialBar"> <?php $text = urlencode($feature["headline"]); $url = urlencode(Config::getSiteRoot() . '/feature.php?id=' . $id); $twitterHandle = Utility::getTenantProperty($applicationID, $tenantID, $userID, 'twitterHandle'); ?> <ul class="socialList"> <li><a class="social icon icon-twitter" href="http://twitter.com/intent/tweet?text=<?php echo $text; ?> &url=<?php echo $url . '&ch=t'; ?> &via=<?php echo $twitterHandle; ?> " target="_blank" rel="nofollow" title="Share on Twitter" aria-label="Share on Twitter"></a></li> <li><div class="fb-like" data-layout="button" data-action="like" data-size="large" data-show-faces="true" data-share="true"></div></li> </ul>
/** * Creates a full system path from an asset URL * * @param string $path Path to start from * @return string */ public static function fromAsset($path, $with_variable = false) { if ($with_variable) { return self::tidy(BASE_PATH . '/' . str_replace('{{ _site_root }}', '/', $path)); } return self::tidy(BASE_PATH . '/' . str_replace(Config::getSiteRoot(), '/', $path)); }
public function count() { // grab parameters $from = $this->fetchParam('from', URL::getCurrent()); $exclude = $this->fetchParam('exclude', false); $max_depth = $this->fetchParam('max_depth', 1, 'is_numeric'); $include_entries = $this->fetchParam('include_entries', false, false, true); $folders_only = $this->fetchParam('folders_only', true, false, true); $include_content = $this->fetchParam('include_content', false, false, true); $show_hidden = $this->fetchParam('show_hidden', false, null, true); // add in left-/ if not present if (substr($from, 0, 1) !== '/') { $from = '/' . $from; } // if this doesn't start with the site root, add the site root if (!Pattern::startsWith($from, Config::getSiteRoot())) { $from = Path::tidy(Config::getSiteRoot() . '/' . $from); } // standardize excludes if ($exclude && !is_array($exclude)) { $exclude = Helper::explodeOptions($exclude, array()); foreach ($exclude as $key => $value) { $exclude[$key] = Path::tidy(Config::getSiteRoot() . '/' . $value); } } // option hash $hash = Helper::makeHash($from, $exclude, $max_depth, $include_entries, $folders_only, $include_content, $show_hidden); // load the content tree from cache if ($this->blink->exists($hash)) { $tree = $this->blink->get($hash); } else { $tree = ContentService::getContentTree($from, $max_depth, $folders_only, $include_entries, $show_hidden, $include_content, $exclude); $this->blink->set($hash, $tree); } if ($this->content) { return Parse::template($this->content, array('count' => count($tree))); } elseif (count($tree)) { return count($tree); } return ''; }
function display_folder($app, $folder, $base = "") { ?> <ul class="subpages"> <?php foreach ($folder as $page) { ?> <?php if (CP_Helper::is_page_visible($page)) { ?> <li class="page"> <div class="page-wrapper"> <div class="page-primary"> <!-- PAGE TITLE --> <?php if ($page['type'] == 'file') { ?> <a href="<?php print $app->urlFor('publish') . "?path={$base}/{$page['slug']}"; ?> "><span class="page-title"><?php print isset($page['title']) ? $page['title'] : Slug::prettify($page['slug']); ?> </span></a> <?php } else { ?> <a href="<?php print $app->urlFor('publish') . "?path={$page['file_path']}"; ?> "><span class="page-title"><?php print isset($page['title']) ? $page['title'] : Slug::prettify($page['slug']); ?> </span></a> <?php } ?> <!-- ENTRIES --> <?php if (isset($page['has_entries']) && $page['has_entries']) { ?> <div class="control-entries"> <span class="ss-icon">textfile</span> <span class="muted"><?php echo $page['entries_label']; ?> :</span> <a href="<?php print $app->urlFor('entries') . "?path={$base}/{$page['slug']}"; ?> "> <?php echo Localization::fetch('list'); ?> </a> <span class="muted"><?php echo Localization::fetch('or'); ?> </span> <a href="<?php print $app->urlFor('publish') . "?path={$base}/{$page['slug']}&new=true"; ?> "> <?php echo Localization::fetch('create'); ?> </a> </div> <?php } ?> </div> <!-- SLUG & VIEW PAGE LINK --> <div class="page-extras"> <div class="page-view"> <a href="<?php print Path::tidy(Config::getSiteRoot() . '/' . $page['url']); ?> " class="tip" title="View Page"> <span class="ss-icon">link</span> </a> </div> <?php if ($page['type'] != 'file' && Config::get('_enable_add_child_page', true)) { ?> <div class="page-add"><a href="#" data-path="<?php print $page['raw_url']; ?> " data-title="<?php print $page['title']; ?> " class="tip add-page-btn add-page-modal-trigger" title="<?php echo Localization::fetch('new_child_page'); ?> "><span class="ss-icon">addfile</span></a></div> <?php } ?> <?php if (Config::get('_enable_delete_page', true)) { ?> <div class="page-delete"> <?php if (array_get($page, '_admin:protected', false)) { ?> <a alt="This page is protected" class="tip"><span class="ss-icon protected">lock</span></a> <?php } else { ?> <a class="confirm tip" href="<?php print $app->urlFor('delete_page') . '?path=' . $page['raw_url'] . '&type=' . $page['type']; ?> " title="<?php echo Localization::fetch('delete_page'); ?> " data-confirm-message="<?php echo Localization::fetch('pagedelete_confirm'); ?> "> <span class="ss-icon">delete</span> </a> <?php } ?> </div> <?php } ?> <div class="slug-preview"> <?php print isset($page['url']) ? $page['url'] : $base . ' /' . $page['slug']; ?> </div> </div> </div> <?php if (isset($page['children']) && sizeof($page['children']) > 0) { display_folder($app, $page['children'], $base . "/" . $page['slug']); } ?> </li> <?php } ?> <?php } ?> </ul> <?php }