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 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); }
/** * __construct * Constructor * * @ */ public function __construct($settings) { $this->settings = array_merge(array('extension' => 'log', 'path' => './_logs', 'file_prefix' => 'site'), $settings); $this->settings['path'] = rtrim($this->settings['path'], DIRECTORY_SEPARATOR); if (!in_array(substr($this->settings['path'], 0, 1), array("/", "."))) { $this->settings['path'] = Path::tidy(BASE_PATH . DIRECTORY_SEPARATOR . $this->settings['path']); } }
/** * 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); }
/** * 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']); } }
public function process() { if ($this->field_data['tmp_name'] !== '') { $destination = BASE_PATH . '/' . $this->settings['destination']; $filename = File::cleanFilename($this->field_data['name']); if (File::upload($this->field_data['tmp_name'], $destination, $filename)) { return Path::tidy('/' . $this->settings['destination'] . '/' . $filename); } else { Log::fatal($this->field_data['tmp_name'] . ' could up not be uploaded to ' . $destination, 'core'); return ''; } } }
/** * Loads the member cache into the local cache variable if not done yet * * @return void */ public static function loadMembers() { if (self::$members_loaded) { return; } // set that we've loaded things self::$members_loaded = true; self::$path = Config::getConfigPath() . '/users/%s.yaml'; self::$members = unserialize(File::get(Path::tidy(BASE_PATH . "/_cache/_app/members/members.php"))); // no members found, that's ok, load a blank array if (!is_array(self::$members)) { self::$members = array(); } }
public function redactor__fetch_files() { $this->authCheck(); $dir = Path::tidy(ltrim(Request::get('path'), '/') . '/'); $file_list = glob($dir . "*.*", GLOB_BRACE); $files = array(); if (count($file_list) > 0) { foreach ($file_list as $file) { $pi = pathinfo($file); $files[] = array('link' => Path::toAsset($file), 'title' => $pi['filename'], 'name' => $pi['basename'], 'size' => File::getHumanSize(File::getSize(Path::assemble(BASE_PATH, $file)))); } } echo json_encode($files); }
public function control_panel__post_publish($publish_data) { // check that caching is turned on if (!$this->core->isEnabled()) { return; } // we only need one key from the hook's value $file = $publish_data['file']; // update the cache _Cache::update(); ContentService::loadCache(true); // grab data $triggers = $this->fetchConfig('publish_invalidation', array(), 'is_array', false, false); $content = Content::find(Path::tidy(str_replace(Config::getContentRoot(), '/', $file))); if ($triggers && $content) { foreach ($triggers as $trigger) { $folders = Parse::pipeList(array_get($trigger, 'folder', null)); $key = array_get($trigger, 'key', null); if (!$folders || !$key) { // not checking this continue; } // check $invalidate = false; foreach ($folders as $folder) { if ($folder === "*" || $folder === "/*") { // include all $invalidate = true; break; } elseif (substr($folder, -1) === "*") { // wildcard check if (strpos($content['_folder'], substr($folder, 0, -1)) === 0) { $invalidate = true; break; } } else { // plain check if ($folder == $content['_folder']) { $invalidate = true; break; } } } // invalidate if needed if ($invalidate) { $this->core->deleteByKey(Parse::pipeList($key)); } } } }
public function redactor__fetch_images() { if (!Statamic_Auth::get_current_user()) { 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 markitup__upload() { if (!Auth::getCurrentMember()) { exit("Invalid Request"); } $path = Request::get('path'); $is_image = Request::get('is_image'); if (isset($path)) { // build directory $dir = Path::tidy(ltrim($path, '/') . '/'); $file_type = strtolower($_FILES['file']['type']); $file_info = pathinfo($_FILES['file']['name']); // pull out the filename bits $filename = $file_info['filename']; $ext = $file_info['extension']; // build filename $file = $dir . $filename . '.' . $ext; // check for dupes if (File::exists($file)) { $file = BASE_PATH . '/' . $dir . $filename . '-' . date('YmdHis') . '.' . $ext; } if (!Folder::isWritable($dir)) { $this->log->error('Upload failed. Directory "' . $dir . '" is not writable.'); die('Upload directory not writable'); } if ($is_image && ($_FILES['file']['type'] == 'image/png' || $_FILES['file']['type'] == 'image/jpg' || $_FILES['file']['type'] == 'image/gif' || $_FILES['file']['type'] == 'image/jpeg')) { if (Request::get('resize', false)) { $image = Image::make($_FILES['file']['tmp_name']); $width = Request::get('width', null); $height = Request::get('height', null); $ratio = Request::get('ratio', true); $upsize = Request::get('upsize', false); $quality = Request::get('quality', '75'); $image->resize($width, $height, $ratio, $upsize)->save($file, $quality); } else { move_uploaded_file($_FILES['file']['tmp_name'], $file); } } else { move_uploaded_file($_FILES['file']['tmp_name'], $file); } $return = array('filelink' => Path::toAsset($file)); die(stripslashes(json_encode($return))); } else { die('Upload directory not set.'); } }
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 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; }
/** * Updates the internal content cache * * @return boolean */ public static function update() { // track if any files have changed $files_changed = false; // grab length of content type extension $content_type = Config::getContentType(); $full_content_root = rtrim(Path::tidy(BASE_PATH . "/" . Config::getContentRoot()), "/"); $content_type_length = strlen($content_type) + 1; // the cache file we'll use $cache_file = BASE_PATH . "/_cache/_app/content/content.php"; $time_file = BASE_PATH . "/_cache/_app/content/last.php"; $now = time(); // grab the existing cache $cache = unserialize(File::get($cache_file)); if (!is_array($cache)) { $cache = array("urls" => array(), "content" => array(), "taxonomies" => array()); } $last = File::get($time_file); // grab a list of all files $finder = new Finder(); $files = $finder->files()->name("*." . Config::getContentType())->in(Config::getContentRoot()); // grab a separate list of files that have changed since last check $updated_files = clone $files; $updated = array(); if ($last) { $updated_files->date(">= " . Date::format("Y-m-d H:i:s", $last)); foreach ($updated_files as $file) { // we don't want directories, they may show up as being modified // if a file inside them has changed or been renamed if (is_dir($file)) { continue; } // this isn't a directory, add it to the list $updated[] = Path::trimFilesystem(Path::standardize($file->getRealPath())); } } // loop over current files $current_files = array(); foreach ($files as $file) { $current_files[] = Path::trimFilesystem(Path::standardize($file->getRealPath())); } // get a diff of files we know about and files currently existing $new_files = array_diff($current_files, $cache['urls']); // create a master list of files that need updating $changed_files = array_unique(array_merge($new_files, $updated)); // add to the cache if files have been updated if (count($changed_files)) { $files_changed = true; // build content cache foreach ($changed_files as $file) { $file = $full_content_root . $file; $local_path = Path::trimFilesystem($file); $local_filename = Path::clean($local_path); // file parsing $content = substr(File::get($file), 3); $divide = strpos($content, "\n---"); $front_matter = trim(substr($content, 0, $divide)); // parse data $data = YAML::parse($front_matter); // set additional information $data['_file'] = $file; $data['_local_path'] = $local_path; $data['_order_key'] = null; $data['datetimestamp'] = null; // legacy $data['datestamp'] = null; $data['date'] = null; $data['time'] = null; $data['numeric'] = null; $data['last_modified'] = filemtime($file); $data['_is_hidden'] = false; $data['_is_draft'] = false; // folder $data['_folder'] = preg_replace(Pattern::ORDER_KEY, "", str_replace($full_content_root, "", $data['_file'])); $slash = strrpos($data['_folder'], "/"); $data['_folder'] = $slash === 0 ? "" : substr($data['_folder'], 1, $slash - 1); // fix hidden/draft files $slug = basename($file, "." . $content_type); if (substr($slug, 0, 2) === "__") { $data['_is_hidden'] = true; $data['slug'] = substr($slug, 2); } elseif (substr($slug, 0, 1) === "_") { $data['_is_draft'] = true; $data['slug'] = substr($slug, 1); } else { $data['slug'] = $slug; } $data['_basename'] = $data['slug'] . "." . $content_type; $data['_filename'] = $data['slug']; $data['_is_entry'] = preg_match(Pattern::ENTRY_FILEPATH, $data['_basename']); $data['_is_page'] = preg_match(Pattern::PAGE_FILEPATH, $data['_basename']); // 404 is special if ($data['_local_path'] === "/404.{$content_type}") { $local_filename = $local_path; // order key } elseif (preg_match(Pattern::DATE_OR_DATETIME, $data['_basename'], $matches)) { $date = $matches[1] . '-' . $matches[2] . '-' . $matches[3]; $time = NULL; if (isset($matches[4])) { $time = substr($matches[4], 0, 2) . ":" . substr($matches[4], 2); $date = $date . " " . $time; $data['slug'] = substr($data['slug'], 16); $data['datetimestamp'] = $data['_order_key']; } else { $data['slug'] = substr($data['slug'], 11); } $data['_order_key'] = strtotime($date); $data['datestamp'] = $data['_order_key']; $data['date'] = Date::format(Config::getDateFormat(), $data['_order_key']); $data['time'] = $time ? Date::format(Config::getTimeFormat(), $data['_order_key']) : NULL; } elseif (preg_match(Pattern::NUMERIC, $data['_basename'], $matches)) { $data['_order_key'] = $matches[1]; $data['numeric'] = $data['_order_key']; $data['slug'] = substr($data['slug'], strlen($matches[1]) + 1); } else { $data['_order_key'] = $data['_basename']; } // determine url $data['url'] = preg_replace("/\\/__?/", "/", $local_filename); // remove any content type extensions from the end of filename if (substr($data['url'], -$content_type_length) === "." . $content_type) { $data['url'] = substr($data['url'], 0, strlen($data['url']) - $content_type_length); } // remove any base pages from filename if (substr($data['url'], -5) == "/page") { $data['url'] = substr($data['url'], 0, strlen($data['url']) - 5); } // add the site root $data['url'] = Path::tidy(Config::getSiteRoot() . $data['url']); // add the site URL to get the permalink $data['permalink'] = Path::tidy(Config::getSiteURL() . $data['url']); // add to cache file $cache['content'][$local_path] = $data; $cache['urls'][$data['url']] = $local_path; } } // loop through all cached content for deleted files // this isn't as expensive as you'd think in real-world situations foreach ($cache['content'] as $local_path => $data) { if (File::exists($full_content_root . $local_path)) { continue; } $files_changed = TRUE; // remove from content cache unset($cache['content'][$local_path]); // remove from url cache $url = array_search($local_path, $cache['urls']); if ($url !== FALSE) { unset($cache['urls'][$url]); } } // build taxonomy cache // only happens if files were added, updated, or deleted above if ($files_changed) { $taxonomies = Config::getTaxonomies(); $force_lowercase = Config::getTaxonomyForceLowercase(); $case_sensitive = Config::getTaxonomyCaseSensitive(); $cache['taxonomies'] = array(); if (count($taxonomies)) { // set up taxonomy array foreach ($taxonomies as $taxonomy) { $cache['taxonomies'][$taxonomy] = array(); } // loop through content to build cached array foreach ($cache['content'] as $file => $data) { // do not grab anything not public if (array_get($data, '_is_hidden', FALSE) || array_get($data, '_is_draft', FALSE)) { continue; } // loop through the types of taxonomies foreach ($taxonomies as $taxonomy) { // if this file contains this type of taxonomy if (isset($data[$taxonomy])) { $values = Helper::ensureArray($data[$taxonomy]); // add the file name to the list of found files for a given taxonomy value foreach ($values as $value) { if (!$value) { continue; } $key = !$case_sensitive ? strtolower($value) : $value; if (!isset($cache['taxonomies'][$taxonomy][$key])) { $cache['taxonomies'][$taxonomy][$key] = array("name" => $force_lowercase ? strtolower($value) : $value, "files" => array()); } array_push($cache['taxonomies'][$taxonomy][$key]['files'], $data['url']); } } } } } if (File::put($cache_file, serialize($cache)) === false) { if (!File::isWritable($cache_file)) { Log::fatal("Cache folder is not writable.", "core", "content-cache"); } Log::fatal("Could not write to the cache.", "core", "content-cache"); return false; } } File::put($time_file, $now); return true; }
/** * Get folder data for a given path * * @param string $path Path to retrieve data for * @return array */ protected function getFolderData($path) { $local_path = str_replace(Path::tidy(BASE_PATH . '/' . Config::getContentRoot()), '', $path); $segments = explode('/', $local_path); $path = Path::tidy(BASE_PATH . '/' . Config::getContentRoot()); $data = array(); $content_type = Config::getContentType(); foreach ($segments as $segment) { $path = Path::tidy($path . '/' . $segment); if (strpos($path, '.' . $content_type) !== false) { continue; } $data = $this->loadFolderData($path) + $data; } return $data; }
/** * 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; }
$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));
/** * Cleans up a given $path, removing any order keys (date-based or number-based) * * @param string $path Path to clean * @return string */ public static function clean($path) { // remove draft and hidden flags $path = preg_replace("#/_[_]?#", "/", $path); // if we don't want entry timestamps, handle things manually if (!Config::getEntryTimestamps()) { $file = substr($path, strrpos($path, "/")); // trim path if needed if (-strlen($file) + 1 !== 0) { $path = substr($path, 0, -strlen($file) + 1); } $path = preg_replace(Pattern::ORDER_KEY, "", $path); $pattern = preg_match(Pattern::DATE, $file) ? Pattern::DATE : Pattern::ORDER_KEY; $file = preg_replace($pattern, "", $file); return Path::tidy($path . $file); } // otherwise, just remove all order-keys return preg_replace(Pattern::ORDER_KEY, "", $path); }
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 }
/** * Removes occurrences of "//" in a $path (except when part of a protocol) * Alias of Path::tidy() * * @param string $url URL to remove "//" from * @return string */ public static function tidy($url) { return Path::tidy($url); }
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 ''; }
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; }
/** * Finds content by path * * @param string $path Path to use to look for content * @return array|false */ public static function find($path) { $hash = Debug::markStart('content', 'finding'); // ensure it starts with / $path = Path::tidy('/' . $path); ContentService::loadCache(); $urls = ContentService::$cache['urls']; foreach ($urls as $url => $data) { if ($data['path'] === $path) { return Content::get($url, false, false); } } Debug::markEnd($hash); return false; }
public function index() { /* |-------------------------------------------------------------------------- | Check for image |-------------------------------------------------------------------------- | | Transform just needs the path to an image to get started. If it exists, | the fun begins. | | The way to do this changes depending on whether its an internal or | external file. | */ $image_src = $this->fetchParam('src', null, false, false, false); // External URL if ($is_external = URL::isExternalUrl($image_src)) { $image_path = $image_src; // Check if file is an image before doing anything. // @TODO: Maybe check that the file exists. $img_info = pathinfo($image_src); $is_image = in_array($img_info['extension'], array('jpg', 'jpeg', 'png', 'gif')); if ( ! $is_image) { Log::error("Requested file is not an image: " . $image_path, "core", "Transform"); return; } } // Internal URL else { // Set full system path $image_path = Path::standardize(Path::fromAsset($image_src)); // Check if image exists before doing anything. if ( ! File::isImage($image_path)) { Log::error("Could not find requested image to transform: " . $image_path, "core", "Transform"); return; } } /* |-------------------------------------------------------------------------- | Resizing and cropping options |-------------------------------------------------------------------------- | | The first transformations we want to run is for size to reduce the | memory usage for future effects. | */ $width = $this->fetchParam('width', null, 'is_numeric'); $height = $this->fetchParam('height', null, 'is_numeric'); // resize specific $ratio = $this->fetchParam('ratio', true, false, true); $upsize = $this->fetchParam('upsize', true, false, true); // crop specific $pos_x = $this->fetchParam('pos_x', 0, 'is_numeric'); $pos_y = $this->fetchParam('pos_y', 0, 'is_numeric'); $quality = $this->fetchParam('quality', '75', 'is_numeric'); /* |-------------------------------------------------------------------------- | Action |-------------------------------------------------------------------------- | | Available actions: resize, crop, and guess. | | "Guess" will find the best fitting aspect ratio of your given width and | height on the current image automatically, cut it out and resize it to | the given dimension. | */ $action = $this->fetchParam('action', 'resize'); /* |-------------------------------------------------------------------------- | Extra bits |-------------------------------------------------------------------------- | | Delicious and probably rarely used options. | */ $angle = $this->fetchParam('rotate', false); $flip_side = $this->fetchParam('flip' , false); $blur = $this->fetchParam('blur', false, 'is_numeric'); $pixelate = $this->fetchParam('pixelate', false, 'is_numeric'); $greyscale = $this->fetchParam(array('greyscale', 'grayscale'), false, false, true); $watermark = $this->fetchParam('watermark', false, false, false, false); /* |-------------------------------------------------------------------------- | Assemble filename and check for duplicate |-------------------------------------------------------------------------- | | We need to make sure we don't already have this image created, so we | defer any action until we've processed the parameters, which create | a unique filename. | */ // Late modified time of original image $last_modified = ($is_external) ? false : File::getLastModified($image_path); // Find .jpg, .png, etc $extension = File::getExtension($image_path); // Filename with the extension removed so we can append our unique filename flags $stripped_image_path = str_replace('.' . $extension, '', $image_path); // The possible filename flags $parameter_flags = array( 'width' => $width, 'height' => $height, 'quality' => $quality, 'rotate' => $angle, 'flip' => $flip_side, 'pos_x' => $pos_x, 'pos_y' => $pos_y, 'blur' => $blur, 'pixelate' => $pixelate, 'greyscale' => $greyscale, 'modified' => $last_modified ); // Start with a 1 character action flag $file_breadcrumbs = '-'.$action[0]; foreach ($parameter_flags as $param => $value) { if ($value) { $flag = is_bool($value) ? '' : $value; // don't show boolean flags $file_breadcrumbs .= '-' . $param[0] . $flag; } } // Allow converting filetypes (jpg, png, gif) $extension = $this->fetchParam('type', $extension); // Allow saving in a different directory $destination = $this->fetchParam('destination', Config::get('transform_destination', false), false, false, false); if ($destination) { $destination = Path::tidy(BASE_PATH . '/' . $destination); // Method checks to see if folder exists before creating it Folder::make($destination); $stripped_image_path = Path::tidy($destination . '/' . basename($stripped_image_path)); } // Reassembled filename with all flags filtered and delimited $new_image_path = $stripped_image_path . $file_breadcrumbs . '.' . $extension; // Check if we've already built this image before if (File::exists($new_image_path)) { return Path::toAsset($new_image_path); } /* |-------------------------------------------------------------------------- | Create Image |-------------------------------------------------------------------------- | | Transform just needs the path to an image to get started. The image is | created in memory so we can start manipulating it. | */ $image = Image::make($image_path); /* |-------------------------------------------------------------------------- | Perform Actions |-------------------------------------------------------------------------- | | This is fresh transformation. Time to work the magic! | */ if ($action === 'resize' && ($width || $height) ) { $image->resize($width, $height, $ratio, $upsize); } if ($action === 'crop' && $width && $height) { $image->crop($width, $height, $pos_x, $pos_y); } if ($action === 'smart') { $image->grab($width, $height); } $resize = $this->fetchParam('resize', null); if ($resize) { $resize_options = Helper::explodeOptions($resize, true); $image->resize( array_get($resize_options, 'width'), array_get($resize_options, 'height'), array_get($resize_options, 'ratio', true), array_get($resize_options, 'upsize', true) ); } $crop = $this->fetchParam('crop', null); if ($crop) { $crop_options = Helper::explodeOptions($crop, true); $image->crop( array_get($crop_options, 'width'), array_get($crop_options, 'height'), array_get($crop_options, 'x'), array_get($crop_options, 'y') ); } if ($angle) { $image->rotate($angle); } if ($flip_side === 'h' || $flip_side === 'v') { $image->flip($flip_side); } if ($greyscale) { $image->greyscale(); } if ($blur) { $image->blur($blur); } if ($pixelate) { $image->pixelate($pixelate); } // Positioning options via ordered pipe settings: // source|position|x offset|y offset if ($watermark) { $watermark_options = Helper::explodeOptions($watermark); $source = Path::tidy(BASE_PATH . '/' . array_get($watermark_options, 0, null)); $anchor = array_get($watermark_options, 1, null); $pos_x = array_get($watermark_options, 2, 0); $pos_y = array_get($watermark_options, 3, 0); $image->insert($source, $pos_x, $pos_y, $anchor); } /* |-------------------------------------------------------------------------- | Save |-------------------------------------------------------------------------- | | Get out of dodge! | */ try { $image->save($new_image_path, $quality); } catch(Exception $e) { Log::fatal('Could not write new images. Try checking your file permissions.', 'core', 'Transform'); throw new Exception('Could not write new images. Try checking your file permissions.'); } return File::cleanURL($new_image_path); }
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; }
} else { print "NO PATH"; } // We want to respect the Status field, but not run it through Fieldset::render() $data['status'] = $new ? array_get($data, 'fields:status:default', 'live') : $data['status']; unset($data['fields']['status']); // Content $content_defaults = array_get($data, 'fields:content', array()); $content_defaults['display'] = array_get($data, 'fields:content:display', 'Content'); $content_defaults['type'] = array_get($data, 'fields:content:type', 'markitup'); $content_defaults['required'] = array_get($data, 'fields:content:required', false) === true ? 'required' : ''; $content_defaults['instructions'] = array_get($data, 'fields:content:instructions', ''); $content_defaults['required'] = array_get($data, 'fields:content:required', false); $content_defaults['input_key'] = ''; array_set($data, 'fields:content', $content_defaults); $data['full_slug'] = Path::tidy($data['full_slug']); /* |-------------------------------------------------------------------------- | Status bar message |-------------------------------------------------------------------------- | | Gawd this is awful. Can't wait to refactor this spaghetti. | */ if ($data['type'] === 'none' || $data['type'] === 'none' && $original_slug !== 'page') { $data['status_message'] = isset($new) ? Localization::fetch('editing_page') : Localization::fetch('edit_page'); $data['identifier'] = $data['page'] === 'page' ? Path::pretty($data['folder']) : Path::pretty($data['full_slug']); } else { $data['status_message'] = isset($new) ? Localization::fetch('new_entry') : Localization::fetch('editing_entry'); $data['identifier'] = isset($new) ? Path::pretty($folder . '/') : Path::pretty($data['full_slug']); }
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>
?> <input type="checkbox" name="entries[]" value="<?php echo "{$path}/{$slug}"; ?> " data-bind="checked: selectedEntries" > <?php } ?> </td> <td class="title"> <a href="<?php print $app->urlFor('publish'); ?> ?path=<?php echo Path::tidy($path . '/'); echo $slug; ?> "><?php print isset($entry['title']) && $entry['title'] != '' ? $entry['title'] : Slug::prettify($entry['slug']); ?> </a> </td> <?php if ($type == 'date') { ?> <td data-fulldate="<?php echo $entry['datestamp']; ?> ">
public function index() { /* |-------------------------------------------------------------------------- | Check for image |-------------------------------------------------------------------------- | | Transform just needs the path to an image to get started. If it exists, | the fun begins. | */ $image_src = $this->fetchParam('src', null, false, false, false); // Set full system path $image_path = Path::tidy(BASE_PATH . '/' . $image_src); // Check if image exists before doing anything. if (!File::isImage($image_path)) { Log::error("Could not find requested image to transform: " . $image_path, "core", "Transform"); return; } /* |-------------------------------------------------------------------------- | Resizing and cropping options |-------------------------------------------------------------------------- | | The first transformations we want to run is for size to reduce the | memory usage for future effects. | */ $width = $this->fetchParam('width', null, 'is_numeric'); $height = $this->fetchParam('height', null, 'is_numeric'); // resize specific $ratio = $this->fetchParam('ratio', true, false, true); $upsize = $this->fetchParam('upsize', true, false, true); // crop specific $pos_x = $this->fetchParam('pos_x', 0, 'is_numeric'); $pos_y = $this->fetchParam('pos_y', 0, 'is_numeric'); $quality = $this->fetchParam('quality', '75', 'is_numeric'); /* |-------------------------------------------------------------------------- | Action |-------------------------------------------------------------------------- | | Available actions: resize, crop, and guess. | | "Guess" will find the best fitting aspect ratio of your given width and | height on the current image automatically, cut it out and resize it to | the given dimension. | */ $action = $this->fetchParam('action', 'resize'); /* |-------------------------------------------------------------------------- | Extra bits |-------------------------------------------------------------------------- | | Delicious and probably rarely used options. | */ $angle = $this->fetchParam('rotate', false); $flip_side = $this->fetchParam('flip', false); $blur = $this->fetchParam('blur', false, 'is_numeric'); $pixelate = $this->fetchParam('pixelate', false, 'is_numeric'); $grayscale = $this->fetchParam('grayscale', false, false, true); // Silly brits $greyscale = $this->fetchParam('greyscale', $grayscale, false, true); /* |-------------------------------------------------------------------------- | Assemble filename and check for duplicate |-------------------------------------------------------------------------- | | We need to make sure we don't already have this image created, so we | defer any action until we've processed the parameters, which create | a unique filename. | */ // Find .jpg, .png, etc $extension = File::getExtension($image_path); // Filename with the extension removed so we can append our unique filename flags $stripped_image_path = str_replace('.' . $extension, '', $image_path); // The possible filename flags $parameter_flags = array('width' => $width, 'height' => $height, 'quality' => $quality, 'rotate' => $angle, 'flip' => $flip_side, 'pos_x' => $pos_x, 'pos_y' => $pos_y, 'blur' => $blur, 'pixelate' => $pixelate, 'greyscale' => $greyscale); // Start with a 1 character action flag $file_breadcrumbs = '-' . $action[0]; foreach ($parameter_flags as $param => $value) { if ($value) { $flag = is_bool($value) ? '' : $value; // don't show boolean flags $file_breadcrumbs .= '-' . $param[0] . $flag; } } // Allow converting filetypes (jpg, png, gif) $extension = $this->fetchParam('type', $extension); // Allow saving in a different directory $destination = $this->fetchParam('destination', Config::get('transform_destination', false), false, false, false); if ($destination) { $destination = Path::tidy(BASE_PATH . '/' . $destination); // Method checks to see if folder exists before creating it Folder::make($destination); $stripped_image_path = Path::tidy($destination . '/' . basename($stripped_image_path)); } // Reassembled filename with all flags filtered and delimited $new_image_path = $stripped_image_path . $file_breadcrumbs . '.' . $extension; // Check if we've already built this image before if (File::exists($new_image_path)) { return File::cleanURL($new_image_path); } /* |-------------------------------------------------------------------------- | Create Image |-------------------------------------------------------------------------- | | Transform just needs the path to an image to get started. The image is | created in memory so we can start manipulating it. | */ $image = Image::make($image_path); /* |-------------------------------------------------------------------------- | Perform Actions |-------------------------------------------------------------------------- | | This is fresh transformation. Time to work the magic! | */ if ($action === 'resize' && ($width || $height)) { $image->resize($width, $height, $ratio, $upsize); } if ($action === 'crop' && $width && $height) { $image->crop($width, $height, $pos_x, $pos_y); } if ($action === 'smart') { $image->grab($width, $height); } if ($angle) { $image->rotate($angle); } if ($flip_side === 'h' || $flip_side === 'v') { $image->flip($flip_side); } if ($greyscale) { $image->greyscale(); } if ($blur) { $image->blur($blur); } if ($pixelate) { $image->pixelate($pixelate); } /* |-------------------------------------------------------------------------- | Save |-------------------------------------------------------------------------- | | Get out of dodge! | */ $image->save($new_image_path, $quality); return File::cleanURL($new_image_path); }
public static function get_content_tree($directory = '/', $depth = 1, $max_depth = 5, $folders_only = false, $include_entries = false, $hide_hidden = true, $include_content = false, $site_root = false) { // $folders_only = true only page.md // folders_only = false includes any numbered or non-numbered page (excluding anything with a fields.yaml file) // if include_entries is true then any numbered files are included $content_root = Config::getContentRoot(); $content_type = Config::getContentType(); $site_root = $site_root ? $site_root : Config::getSiteRoot(); $current_url = Path::tidy($site_root . '/' . Request::getResourceURI()); $taxonomy_url = false; if (Taxonomy::isTaxonomyURL($current_url)) { list($taxonomy_type, $taxonomy_name) = Taxonomy::getCriteria($current_url); $taxonomy_url = self::remove_taxonomy_from_path($current_url, $taxonomy_type, $taxonomy_name); } $directory = '/' . $directory . '/'; #ensure proper slashing if ($directory != '/') { $base = Path::tidy("{$content_root}/{$directory}"); } elseif ($directory == '/') { $base = "{$content_root}"; } else { $base = "{$content_root}"; } $files = glob("{$base}/*"); $data = array(); if ($files) { foreach ($files as $path) { $current_name = basename($path); if (!Pattern::endsWith($current_name, '.yaml')) { // Hidden page that should be removed if ($hide_hidden && Pattern::startsWith($current_name, '_')) { continue; } $node = array(); $file = substr($path, strlen($base) + 1, strlen($path) - strlen($base) - strlen($content_type) - 2); if (is_dir($path)) { $folder = substr($path, strlen($base) + 1); $node['type'] = 'folder'; $node['slug'] = basename($folder); $node['title'] = ucwords(basename($folder)); $node['numeric'] = Slug::getOrderNumber($folder); $node['file_path'] = Path::tidy($site_root . '/' . $directory . '/' . $folder . '/page'); if (Slug::isNumeric($folder)) { $pos = strpos($folder, "."); if ($pos !== false) { $node['raw_url'] = Path::tidy(Path::clean($site_root . '/' . $directory . '/' . $folder)); $node['url'] = Path::clean($node['raw_url']); $node['title'] = ucwords(basename(substr($folder, $pos + 1))); } else { $node['title'] = ucwords(basename($folder)); $node['raw_url'] = Path::tidy($site_root . '/' . $directory . '/' . $folder); $node['url'] = Path::clean($node['raw_url']); } } else { $node['title'] = ucwords(basename($folder)); $node['raw_url'] = Path::tidy($site_root . '/' . $directory . '/' . $folder); $node['url'] = Path::clean($node['raw_url']); } $node['depth'] = $depth; $node['children'] = $depth < $max_depth ? self::get_content_tree($directory . $folder . '/', $depth + 1, $max_depth, $folders_only, $include_entries, $hide_hidden, $include_content, $site_root) : null; $node['is_current'] = $node['raw_url'] == $current_url || $node['url'] == $current_url ? true : false; $node['is_parent'] = false; if ($node['url'] == URL::popLastSegment($current_url) || $taxonomy_url && $node['url'] == $taxonomy_url) { $node['is_parent'] = true; } $node['has_children'] = $node['children'] ? true : false; // has entries? if (File::exists(Path::tidy($path . "/fields.yaml"))) { $node['has_entries'] = true; } else { $node['has_entries'] = false; } $meta = self::get_content_meta("page", Path::tidy($directory . "/" . $folder), false, true); //$meta = self::get_content_meta("page", Statamic_Helper::reduce_double_slashes($directory."/".$folder)); if (isset($meta['title'])) { $node['title'] = $meta['title']; } if (isset($meta['last_modified'])) { $node['last_modified'] = $meta['last_modified']; } if ($hide_hidden === true && (isset($meta['status']) && ($meta['status'] == 'hidden' || $meta['status'] == 'draft'))) { // placeholder condition } else { $data[] = $include_content ? array_merge($meta, $node) : $node; // print_r($data); } } else { if (Pattern::endsWith($path, $content_type)) { if ($folders_only == false) { if ($file == 'page' || $file == 'feed' || $file == '404') { // $node['url'] = $directory; // $node['title'] = basename($directory); // $meta = self::get_content_meta('page', substr($directory, 1)); // $node['depth'] = $depth; } else { $include = true; // date based is never included if (Config::getEntryTimestamps() && Slug::isDateTime(basename($path))) { $include = false; } elseif (Slug::isDate(basename($path))) { $include = false; } elseif (Slug::isNumeric(basename($path))) { if ($include_entries == false) { if (File::exists(Path::tidy(dirname($path) . "/fields.yaml"))) { $include = false; } } } if ($include) { $node['type'] = 'file'; $node['raw_url'] = Path::tidy($directory) . basename($path); $pretty_url = Path::clean($node['raw_url']); $node['url'] = substr($pretty_url, 0, -1 * (strlen($content_type) + 1)); $node['is_current'] = $node['url'] == $current_url || $node['url'] == $current_url ? true : false; $node['slug'] = substr(basename($path), 0, -1 * (strlen($content_type) + 1)); $meta = self::get_content_meta(substr(basename($path), 0, -1 * (strlen($content_type) + 1)), substr($directory, 1), false, true); //$node['meta'] = $meta; if (isset($meta['title'])) { $node['title'] = $meta['title']; } $node['depth'] = $depth; if ($hide_hidden === true && (isset($meta['status']) && ($meta['status'] == 'hidden' || $meta['status'] == 'draft'))) { } else { $data[] = $include_content ? array_merge($meta, $node) : $node; } } } } } } } } } return $data; }