Example #1
0
 protected function _format_slider_item(&$obj)
 {
     parent::_format_object($obj);
     // --------------------------------------------------------------------------
     $obj->slider_id = (int) $obj->slider_id;
     $obj->object_id = $obj->object_id ? (int) $obj->object_id : NULL;
     $obj->page_id = $obj->page_id ? (int) $obj->page_id : NULL;
     unset($obj->slider_id);
 }
 protected function _format_object(&$obj)
 {
     parent::_format_object($obj);
     if (!empty($obj->item_id)) {
         $obj->item_id = (int) $obj->item_id;
     }
     $obj->changes = @unserialize($obj->changes);
     $obj->user = new stdClass();
     $obj->user->id = $obj->user_id;
     $obj->user->first_name = $obj->first_name;
     $obj->user->last_name = $obj->last_name;
     $obj->user->gender = $obj->gender;
     $obj->user->profile_img = $obj->profile_img;
     $obj->user->email = $obj->email;
     unset($obj->user_id);
     unset($obj->first_name);
     unset($obj->last_name);
     unset($obj->gender);
     unset($obj->profile_img);
     unset($obj->email);
 }
Example #3
0
 protected function _format_menu_item(&$obj)
 {
     parent::_format_object($obj);
     // --------------------------------------------------------------------------
     $obj->menu_id = (int) $obj->menu_id;
     $obj->parent_id = $obj->parent_id ? (int) $obj->parent_id : NULL;
     $obj->page_id = $obj->page_id ? (int) $obj->page_id : NULL;
 }
Example #4
0
 protected function _format_object(&$post)
 {
     parent::_format_object($post);
     // --------------------------------------------------------------------------
     //	Type casting
     $post->is_published = (bool) $post->is_published;
     $post->is_deleted = (bool) $post->is_deleted;
     //	Generate URL
     $post->url = $this->format_url($post->slug);
     //	Author
     $post->author = new stdClass();
     $post->author->id = (int) $post->modified_by;
     $post->author->first_name = $post->first_name;
     $post->author->last_name = $post->last_name;
     $post->author->email = $post->email;
     $post->author->profile_img = $post->profile_img;
     $post->author->gender = $post->gender;
     unset($post->modified_by);
     unset($post->first_name);
     unset($post->last_name);
     unset($post->email);
     unset($post->profile_img);
     unset($post->gender);
 }
Example #5
0
 protected function _format_object(&$page)
 {
     parent::_format_object($page);
     $page->is_published = (bool) $page->is_published;
     $page->is_deleted = (bool) $page->is_deleted;
     //	Loop properties and sort into published data and draft data
     $page->published = new stdClass();
     $page->draft = new stdClass();
     foreach ($page as $property => $value) {
         preg_match('/^(published|draft)_(.*)$/', $property, $_match);
         if (!empty($_match[1]) && !empty($_match[2]) && $_match[1] == 'published') {
             $page->published->{$_match[2]} = $value;
             unset($page->{$property});
         } elseif (!empty($_match[1]) && !empty($_match[2]) && $_match[1] == 'draft') {
             $page->draft->{$_match[2]} = $value;
             unset($page->{$property});
         }
     }
     //	Other data
     $page->published->depth = count(explode('/', $page->published->slug)) - 1;
     $page->published->url = site_url($page->published->slug);
     $page->draft->depth = count(explode('/', $page->draft->slug)) - 1;
     $page->draft->url = site_url($page->draft->slug);
     //	Decode JSON
     $page->published->template_data = json_decode($page->published->template_data);
     $page->draft->template_data = json_decode($page->draft->template_data);
     $page->published->breadcrumbs = json_decode($page->published->breadcrumbs);
     $page->draft->breadcrumbs = json_decode($page->draft->breadcrumbs);
     //	Unpublished changes?
     $page->has_unpublished_changes = $page->is_published && $page->draft->hash != $page->published->hash;
     // --------------------------------------------------------------------------
     //	Owner
     $_modified_by = (int) $page->modified_by;
     $page->modified_by = new stdClass();
     $page->modified_by->id = $_modified_by;
     $page->modified_by->first_name = $page->first_name;
     $page->modified_by->last_name = $page->last_name;
     $page->modified_by->email = $page->email;
     $page->modified_by->profile_img = $page->profile_img;
     $page->modified_by->gender = $page->gender;
     unset($page->first_name);
     unset($page->last_name);
     unset($page->email);
     unset($page->profile_img);
     unset($page->gender);
     unset($page->template_data);
     // --------------------------------------------------------------------------
     //	SEO Title
     //	If not set then fallback to the page title
     if (empty($page->seo_title) && !empty($page->title)) {
         $page->seo_title = $page->title;
     }
 }