/** * 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 static function get_listings() { $listings = array(); $finder = new Finder(); $files = $finder->files()->in(Config::getContentRoot())->name('fields.yaml')->followLinks(); foreach ($files as $file) { $slug = Path::trimSlashes(Path::makeRelative($file->getPath(), Config::getContentRoot())); $meta = array('slug' => $slug, 'title' => ucwords(ltrim(Path::pretty('/' . $slug), '/'))); $item = self::yamlize_content(BASE_PATH . '/' . $file->getPath() . '/page.' . Config::getContentType()); $listings[] = is_array($item) ? array_merge($meta, $item) : $meta; } // Sort by Title uasort($listings, function ($a, $b) { return strcmp($a['title'], $b['title']); }); return $listings; }
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 ($new) { $data['status_message'] .= ' ' . Localization::fetch('in', null, true); } // Set the return URL if ($custom_return = Request::get('return')) { $data['return'] = $app->request()->getRootUri() . $custom_return; } else { $data['return'] = $data['type'] == 'none' ? $app->urlFor('pages') . "?path=" . Path::addStartingSlash($folder) : $app->urlFor('entries') . "?path=" . Path::addStartingSlash($folder); } $data['templates'] = Theme::getTemplates(); $data['layouts'] = Theme::getLayouts(); $template_list = array("publish"); Statamic_View::set_templates(array_reverse($template_list)); /*