Beispiel #1
0
 function _remap($category = NULL)
 {
     $cache_id = fuel_cache_id();
     if ($cache = $this->fuel_blog->get_cache($cache_id)) {
         $output =& $cache;
     } else {
         $vars = $this->_common_vars();
         $vars['pagination'] = '';
         // check if RSS feed
         if ($this->uri->rsegment(3) == 'feed') {
             $type = $this->uri->rsegment(4) == 'atom' ? 'atom' : 'rss';
             // set the header type
             $this->fuel_blog->feed_header();
             // set the output
             $output = $this->fuel_blog->feed_output($type, $category);
         } else {
             if (!empty($category) && $category != 'index') {
                 $vars['posts'] = $this->fuel_blog->get_category_posts($category);
                 $vars['page_title'] = $category;
                 //if (empty($vars['posts'])) show_404();
                 $output = $this->_render('posts', $vars, TRUE);
             } else {
                 $vars['categories'] = $this->fuel_blog->get_categories();
                 $vars['page_title'] = lang('blog_categories_page_title');
                 $output = $this->_render('post', $vars, TRUE);
             }
         }
         $this->fuel_blog->save_cache($cache_id, $output);
     }
     $this->output->set_output($output);
 }
Beispiel #2
0
 function index()
 {
     $cache_id = fuel_cache_id();
     $vars = $this->_common_vars();
     if ($cache = $this->fuel_blog->get_cache($cache_id)) {
         $output =& $cache;
     } else {
         $vars['archives_by_month'] = $this->fuel_blog->get_post_archives();
         $vars['page_title'] = lang('blog_archives_page_title');
         $output = $this->_render('archives', $vars, TRUE);
         $this->fuel_blog->save_cache($cache_id, $output);
     }
     $this->output->set_output($output);
 }
 function _remap($category = NULL)
 {
     $cache_id = fuel_cache_id();
     $vars = $this->_common_vars();
     if ($cache = $this->fuel->blog->get_cache($cache_id)) {
         $output =& $cache;
     } else {
         $where = array();
         if (!empty($category) and $category != 'index') {
             $tables = $this->config->item('tables');
             $where[$tables['blog_categories'] . '.slug'] = $category;
         }
         $vars['archives_by_month'] = $this->fuel->blog->get_post_archives($where);
         $vars['page_title'] = lang('blog_archives_page_title');
         $output = $this->_render('archives', $vars, TRUE);
         $this->fuel->blog->save_cache($cache_id, $output);
     }
     $this->output->set_output($output);
 }
 function _remap($category = NULL)
 {
     $cache_id = fuel_cache_id();
     if ($cache = $this->fuel->blog->get_cache($cache_id)) {
         $output =& $cache;
     } else {
         $vars = $this->_common_vars();
         $vars['pagination'] = '';
         // check if RSS feed
         if ($this->uri->rsegment(3) == 'feed') {
             $type = $this->uri->rsegment(4) == 'atom' ? 'atom' : 'rss';
             // set the header type
             $this->fuel->blog->feed_header();
             // set the output
             $output = $this->fuel->blog->feed_output($type, $category);
         } else {
             if (!empty($category) and $category != 'index') {
                 $year = (int) $this->uri->rsegment(3);
                 $month = (int) $this->uri->rsegment(4);
                 $day = (int) $this->uri->rsegment(5);
                 $category_obj = $this->fuel->blog->get_category($category);
                 if (!isset($category_obj->id)) {
                     show_404();
                 }
                 // run before_posts_by_date hook
                 $hook_params = array('category' => $category_obj, 'category_slug' => $category);
                 $this->fuel->blog->run_hook('before_posts_by_category', $hook_params);
                 $vars = array_merge($vars, $hook_params);
                 $vars['posts'] = $this->fuel->blog->get_category_posts_by_date($category, $year, $month, $day);
                 $vars['page_title'] = $this->fuel->blog->page_title(array($category_obj->name, lang('blog_categories_page_title')));
                 $output = $this->_render('category', $vars, TRUE);
             } else {
                 $vars['categories'] = $this->fuel->blog->get_categories();
                 $vars['page_title'] = lang('blog_categories_page_title');
                 $output = $this->_render('categories', $vars, TRUE);
             }
         }
         $this->fuel->blog->save_cache($cache_id, $output);
     }
     $this->output->set_output($output);
 }
 function _remap($id = NULL)
 {
     $cache_id = fuel_cache_id();
     if ($cache = $this->fuel->blog->get_cache($cache_id)) {
         $output =& $cache;
     } else {
         $vars = $this->_common_vars();
         if ($id == 'posts') {
             $author_id = (int) $this->uri->rsegment(3);
             $author = $this->fuel->blog->get_user($author_id);
             if (empty($author)) {
                 show_404();
             }
             $where['author_id'] = $author_id;
             // run before_posts_by_date hook
             $hook_params = array('author' => $author);
             $this->fuel->blog->run_hook('before_posts_by_author', $hook_params);
             $vars['posts'] = $this->fuel->blog->get_posts($where);
             $vars['page_title'] = lang('blog_author_posts_page_title', $author->name);
             $output = $this->_render('posts', $vars, TRUE);
         } else {
             if (!empty($id) && $id != 'index') {
                 $author = $this->fuel->blog->get_user($id);
                 if (empty($author)) {
                     show_404();
                 }
                 $vars['author'] = $author;
                 $vars['page_title'] = $author->name;
                 $output = $this->_render('author', $vars, TRUE);
             } else {
                 $vars['authors'] = $this->fuel->blog->get_users();
                 $vars['page_title'] = lang('blog_authors_list_page_title');
                 $output = $this->_render('authors', $vars, TRUE);
             }
         }
         $this->fuel->blog->save_cache($cache_id, $output);
     }
     $this->output->set_output($output);
 }
Beispiel #6
0
 function _remap_variables()
 {
     // set up cache info
     $cache_group = $this->config->item('page_cache_group', 'fuel');
     $cache_id = fuel_cache_id();
     if ($this->config->item('use_page_cache', 'fuel') !== 'cms' and $this->cache->get($cache_id, $cache_group, FALSE) and !is_fuelified()) {
         $output = $this->cache->get($cache_id, $cache_group);
     } else {
         // get the output
         $output = $this->fuel_page->variables_render(TRUE, FALSE);
         // save to cache but you must not be logged in for it to save
         if ($this->config->item('use_page_cache', 'fuel') !== FALSE and $this->config->item('use_page_cache', 'fuel') !== 'cms' and !is_fuelified()) {
             $this->cache->save($cache_id, $output, $cache_group, $this->config->item('page_cache_ttl', 'fuel'));
         }
     }
     // show 404 if output is explicitly set to FALSE
     if ($output === FALSE) {
         // do any redirects... will exit script if any
         $this->_redirects();
         // else show 404
         show_404();
     }
     // fuelify output
     $output = $this->fuel_page->fuelify($output);
     // render output
     $this->output->set_output($output);
 }
Beispiel #7
0
 function _save_page_vars($id, $posted)
 {
     //$vars = $this->input->post('vars');
     $vars = array();
     // process post vars... can't use an array because of file upload complications'
     foreach ($posted as $key => $val) {
         if (strncmp('vars--', $key, 4) === 0) {
             $new_key = end(explode('--', $key));
             $vars[$new_key] = $val;
         }
     }
     if (!empty($vars) && is_array($vars)) {
         $fields = $this->fuel_layouts->fields($this->input->post('layout'));
         $save = array();
         // clear out all other variables
         $this->pagevariables_model->delete(array('page_id' => $id));
         $pagevariable_table = $this->db->table_info($this->pagevariables_model->table_name());
         $var_types = $pagevariable_table['type']['options'];
         $page_variables_archive = array();
         foreach ($fields as $key => $val) {
             $value = !empty($vars[$key]) ? $vars[$key] : NULL;
             if ($val['type'] == 'array' or $val['type'] == 'multi') {
                 $value = serialize($value);
                 $val['type'] = 'array';
                 // force the type to be an array
             }
             if (!in_array($val['type'], $var_types)) {
                 $val['type'] = 'string';
             }
             $save = array('page_id' => $id, 'name' => $key, 'value' => $value, 'type' => $val['type']);
             $where = !empty($id) ? array('page_id' => $id, 'name' => $key) : array();
             if ($this->pagevariables_model->save($save, $where)) {
                 $page_variables_archive[$key] = $this->pagevariables_model->cleaned_data();
             }
         }
         // archive
         $archive = $this->model->cleaned_data();
         $archive['variables'] = $page_variables_archive;
         $this->model->archive($id, $archive);
         // save to navigation if config allows it
         if ($this->input->post('navigation_label')) {
             $this->load->module_model(FUEL_FOLDER, 'navigation_model');
             $save = array();
             $save['label'] = $this->input->post('navigation_label');
             $save['location'] = $this->input->post('location');
             $save['group_id'] = $this->config->item('auto_page_navigation_group_id', 'fuel');
             $save['parent_id'] = 0;
             // reset $where and create where clause to try and find an existing navigation item
             $where = array();
             $where['location'] = $save['location'];
             $where['group_id'] = $save['group_id'];
             $where['parent_id'] = $save['parent_id'];
             $does_it_exist_already = $this->navigation_model->record_exists($where);
             if (!$does_it_exist_already) {
                 // determine parent based off of location
                 $location_arr = explode('/', $this->input->post('location'));
                 $parent_location = implode('/', array_slice($location_arr, 0, count($location_arr) - 1));
                 if (!empty($parent_location)) {
                     $parent = $this->navigation_model->find_by_location($parent_location);
                 }
                 if (!empty($parent)) {
                     $save['parent_id'] = $parent['id'];
                 }
                 $this->navigation_model->add_validation('parent_id', array(&$this->navigation_model, 'no_location_and_parent_match'), lang('error_location_parents_match'), '{location}');
                 $this->navigation_model->save($save, array('location' => $this->input->post('location'), 'group_id' => $save['group_id']));
             }
         }
     }
     $this->session->set_flashdata('success', lang('data_saved'));
     // reset cache for that page only
     if ($this->input->post('location')) {
         $this->load->library('cache');
         $cache_group = $this->config->item('page_cache_group', 'fuel');
         $this->cache->remove(fuel_cache_id($this->input->post('location')), $cache_group);
     }
 }
Beispiel #8
0
 function post($permalink = null)
 {
     if (empty($permalink)) {
         show_404();
     }
     $this->load->library('session');
     $blog_config = $this->config->item('blog');
     $post = $this->fuel_blog->get_post($permalink);
     if (isset($post->id)) {
         $vars = $this->_common_vars();
         $vars['post'] = $post;
         $vars['user'] = $this->fuel_blog->logged_in_user();
         $vars['page_title'] = $post->title;
         $vars['next'] = $this->fuel_blog->get_next_post($post);
         $vars['prev'] = $this->fuel_blog->get_prev_post($post);
         $antispam = md5(random_string('unique'));
         $field_values = array();
         // post comment
         if (!empty($_POST)) {
             $field_values = $_POST;
             // the id of "content" is a likely ID on the front end, so we use comment_content and need to remap
             $field_values['content'] = $field_values['new_comment'];
             unset($field_values['antispam']);
             if (!empty($_POST['new_comment'])) {
                 $vars['processed'] = $this->_process_comment($post);
             } else {
                 add_error(lang('blog_error_blank_comment'));
             }
         }
         $cache_id = fuel_cache_id();
         $cache = $this->fuel_blog->get_cache($cache_id);
         if (!empty($cache) and empty($_POST)) {
             $output =& $cache;
         } else {
             $this->load->library('form');
             if (is_true_val($this->fuel_blog->settings('use_captchas'))) {
                 $captcha = $this->_render_captcha();
                 $vars['captcha'] = $captcha;
             }
             $vars['thanks'] = $this->session->flashdata('thanks') ? blog_block('comment_thanks', $vars, TRUE) : '';
             $vars['comment_form'] = '';
             $this->session->set_userdata('antispam', $antispam);
             if (is_true_val($this->fuel_blog->settings('allow_comments'))) {
                 $this->load->module_model(BLOG_FOLDER, 'blog_comments_model');
                 $this->load->library('form_builder', $blog_config['comment_form']);
                 $fields['author_name'] = array('label' => 'Name', 'required' => TRUE);
                 $fields['author_email'] = array('label' => 'Email', 'required' => TRUE);
                 $fields['author_website'] = array('label' => 'Website');
                 $fields['new_comment'] = array('label' => 'Comment', 'type' => 'textarea', 'required' => TRUE);
                 $fields['post_id'] = array('type' => 'hidden', 'value' => $post->id);
                 $fields['antispam'] = array('type' => 'hidden', 'value' => $antispam);
                 if (!empty($vars['captcha'])) {
                     $fields['captcha'] = array('required' => TRUE, 'label' => 'Security Text', 'value' => '', 'after_html' => ' <span class="captcha">' . $vars['captcha']['image'] . '</span><br /><span class="captcha_text">' . lang('blog_captcha_text') . '</span>');
                 }
                 // now merge with config... can't do array_merge_recursive'
                 foreach ($blog_config['comment_form']['fields'] as $key => $field) {
                     if (isset($fields[$key])) {
                         $fields[$key] = array_merge($fields[$key], $field);
                     }
                 }
                 if (!isset($blog_config['comment_form']['label_layout'])) {
                     $this->form_builder->label_layout = 'left';
                 }
                 if (!isset($blog_config['comment_form']['submit_value'])) {
                     $this->form_builder->submit_value = 'Submit Comment';
                 }
                 if (!isset($blog_config['comment_form']['use_form_tag'])) {
                     $this->form_builder->use_form_tag = TRUE;
                 }
                 if (!isset($blog_config['comment_form']['display_errors'])) {
                     $this->form_builder->display_errors = TRUE;
                 }
                 $this->form_builder->form_attrs = 'method="post" action="' . site_url($this->uri->uri_string()) . '#comments_form"';
                 $this->form_builder->set_fields($fields);
                 $this->form_builder->set_field_values($field_values);
                 $this->form_builder->set_validator($this->blog_comments_model->get_validation());
                 $vars['comment_form'] = $this->form_builder->render();
                 $vars['fields'] = $fields;
             }
             $output = $this->_render('post', $vars, TRUE);
             // save cache only if we are not posting data
             if (!empty($_POST)) {
                 $this->fuel_blog->save_cache($cache_id, $output);
             }
         }
         if (!empty($output)) {
             $this->output->set_output($output);
             return;
         }
     } else {
         show_404();
     }
 }
 /**
  * Returns a data summary for multiple campaigns
  *
  * @access	public
  * @return	array
  */
 function summaries()
 {
     $summaries = array();
     $cache_id = fuel_cache_id();
     if ($this->config('use_cache')) {
         $cached_file = $this->CI->cache->get($cache_id, $this->config('cache_folder'));
         if (!empty($cached_file)) {
             $summaries = $cached_file;
         }
     }
     if (empty($summaries)) {
         $client_id = $this->client_id();
         if (!empty($client_id)) {
             $campaigns = $this->campaigns($client_id);
             if (!empty($campaigns)) {
                 foreach ($campaigns as $campaign) {
                     $summary = $this->campaign_summary($campaign['CampaignID']);
                     if (!empty($summary)) {
                         $summaries[$campaign['Name']] = $summary;
                     }
                 }
             }
             if ($this->config('use_cache')) {
                 $this->CI->cache->save($cache_id, $summaries, $this->config('cache_folder'), $this->config('cache_ttl'));
             }
         }
     }
     return $summaries;
 }