Esempio n. 1
0
 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;
 }
 /**
  * Watch for moved content
  * 
  * @param array  $files  Array of old and new files
  * @return void
  */
 public function control_panel__move($files)
 {
     // master switch for revisions
     if (!$this->core->isEnabled()) {
         return;
     }
     // get files
     $old_file = $files['old_file'];
     $new_file = $files['new_file'];
     // normalize
     $old_file = rtrim(Path::makeRelative($old_file, Path::tidy(Config::getContentRoot())), '/');
     $old_file = $this->core->normalizePath($old_file);
     $new_file = rtrim(Path::makeRelative($new_file, Path::tidy(Config::getContentRoot())), '/');
     $new_file = $this->core->normalizePath($new_file);
     $this->core->moveFile($old_file, $new_file);
 }