Beispiel #1
0
 public function create($filename, \App_Config_Ini $config, $template, $mtime)
 {
     //Add the meta config to this config
     $meta_config = $this->get_meta_config();
     //First load the page that matches the slug
     $existing = current(R::findOrDispense('page', 'slug = :slug', ['slug' => $config->page->slug]));
     if ($existing->getID() && $existing->gen_filename != $filename) {
         throw new Exception("A page already exists inside the database with the same slug but built with the onscreen page creator");
         return false;
     }
     $page = current(R::findOrDispense('page', 'gen_filename = :file', ['file' => $filename]));
     /* @var $page \RedBeanPHP\OODBBean */
     /**
      * Creates the page database object
      */
     if (!$page->getID()) {
         // The Page does not exist
         $page->gen_filename = $filename;
         $page->title = $config->page->title;
         $page->description = $config->page->description;
     } else {
         $old_slug = $page->slug;
         $meta = new Meta_Generator($meta_config);
         $page->title = !empty($config->page->title) ? $config->page->title : $meta->get_title($page->slug);
         $page->description = !empty($config->page->description) ? $config->page->description : $meta->get_description($page->slug);
     }
     $page->slug = $config->page->slug;
     $page->layout = $this->theme->load_layout($config->page->layout ? $config->page->layout : 'layouts.default.twig', $this->theme->theme)->file;
     /*
      * Create the template file in the theme
      */
     $page->template = $this->theme->generate_template($filename, $template, $mtime);
     R::store($page);
     // Create a route for this page for loading
     $r_func = function ($slug) use($page) {
         //Load the front end instance loader
         $theme = Theme_Loader::get_instance();
         $theme->set_theme(THEME);
         G2_User::init();
         if (G()->logged_in()) {
             $theme->logged_in();
         }
         $_SESSION['theme'] = $theme;
         //Render the theme
         if ($theme->page_exists($page->slug)) {
             $theme->render($page->slug);
         }
     };
     $route = new Router();
     if (isset($old_slug)) {
         $route->delete_route($old_slug);
     }
     $route->create_route($page->slug, $r_func);
 }
Beispiel #2
0
 /**
  * Retrieves the correct page titles from the meta class to create the appropriate links
  * @param type $page
  */
 function collect_information($page)
 {
     //Split the given page url up in sections
     $sections = explode('/', $page);
     //Start looking at the begining of the string and get the correct title from the meta class
     $config = $this->get_package_instance(true)->get_config('meta.ini');
     $meta_gen = new Meta_Generator($config);
     $crumbs = [];
     $link_build = [];
     $check_page = [];
     foreach ($sections as $page) {
         $check_page[] = $page;
         $title = $meta_gen->get_clean_title(implode('/', $check_page));
         $link_build[] = $page;
         $link = implode('/', $link_build);
         $crumbs[] = ['label' => $title, 'link' => $link];
     }
     return $crumbs;
 }
Beispiel #3
0
 public function __before($params, $action = false)
 {
     G2_User::init();
     $page = '';
     $page = implode('/', $params);
     if (!$page) {
         $page = 'index';
     }
     if ($action != 'index') {
         $page = $action;
     }
     $config = Package_Admin::getInstance()->get_config('meta.ini');
     $this->meta = new Meta_Generator($config);
     $this->template->meta_title = $this->meta->get_title($page);
     $this->template->meta_description = $this->meta->get_description($page);
     if (!G()->logged_in() && $page != 'login') {
         $this->redirect($this->get_package_uri(true) . 'login');
     }
     parent::__before();
 }
Beispiel #4
0
 /**
  * Update titles of pages in site
  * 
  */
 function update_titles()
 {
     echo 'Load Config <br>';
     $config = new Zend_Config_Ini('meta.ini', APP_DEPLOY);
     $title = $config->meta->title->change;
     $pages_slugs = [];
     $this->filter($title, $pages_slugs);
     $pages = R::findAll('page');
     $meta = new Meta_Generator($config);
     foreach ($pages as $page) {
         $old = clone $page;
         echo "{$page->title} ==== " . $meta->get_title($page->slug) . '<br>';
         echo "{$page->description} ==== " . $meta->get_description($page->slug) . '<br>';
         $page->title = $meta->get_title($page->slug);
         $page->description = $meta->get_description($page->slug);
         Audit::create($old, $page, "Script updated Meta Data");
         R::store($page);
     }
     //		foreach($pages_slugs as $slug => $title){
     //			$page = R::findOne('page','slug = :slug',['slug' => $slug]);
     //			if($page){
     //				echo "$page->title => $title ====   $page->slug<br>";
     //			} else {
     //				echo "$slug Page not Found <br>";
     //			}
     //		}
 }