public function getTinymcePageList()
 {
     $pages = array();
     $all_pages = Page::all();
     foreach ($all_pages as $page) {
         if (config('coaster::admin.advanced_permissions') && !Auth::action('pages', ['page_id' => $page->id])) {
             continue;
         }
         $pages[] = $page->id;
     }
     $page_details = Path::getFullPaths($pages, html_entity_decode(' » '));
     $json_array = array();
     foreach ($page_details as $page_detail) {
         $details = new \stdClass();
         $details->title = $page_detail->fullName;
         $details->value = $page_detail->fullUrl;
         $json_array[] = $details;
     }
     usort($json_array, function ($a, $b) {
         return strcmp($a->title, $b->title);
     });
     return json_encode($json_array);
 }
Example #2
0
 public static function get_page_list($options = array())
 {
     $default_options = array('links' => true, 'group_pages' => true, 'language_id' => Language::current(), 'parent' => null);
     $options = array_merge($default_options, $options);
     if ($parent = !empty($options['parent']) ? self::find($options['parent']) : null) {
         if ($parent->group_container > 0) {
             $group = PageGroup::preload($parent->group_container);
             $pages = $group->itemPageFiltered($parent->id);
         } else {
             $pages = self::where('parent', '=', $options['parent'])->get();
         }
     } else {
         $pages = self::all();
     }
     $pages_array = array();
     $max_link = $options['links'] ? 1 : 0;
     $min_parent = $options['group_pages'] ? -1 : 0;
     foreach ($pages as $page) {
         if (config('coaster::admin.advanced_permissions') && !Auth::action('pages', ['page_id' => $page->id])) {
             continue;
         }
         if ($page->link <= $max_link && $page->parent >= $min_parent) {
             $pages_array[] = $page->id;
         }
     }
     $paths = $options['group_pages'] ? Path::getFullPathsVariations($pages_array) : Path::getFullPaths($pages_array);
     $list = array();
     foreach ($paths as $page_id => $path) {
         if ((!isset($options['exclude_home']) || $path->fullUrl != '/') && !is_null($path->fullUrl)) {
             $list[$page_id] = $path->fullName;
         }
     }
     // order
     asort($list);
     return $list;
 }