protected function _check_login() { // load this after the the above because it needs a database connection. Avoids a database connection error if there isn't one' $this->load->module_library(FUEL_FOLDER, 'fuel_auth'); // check if logged in if (!$this->fuel_auth->is_logged_in() or !is_fuelified()) { $login = $this->config->item('fuel_path', 'fuel') . 'login'; $cookie = array('name' => $this->fuel_auth->get_fuel_trigger_cookie_name(), 'path' => WEB_PATH); delete_cookie($cookie); if (!is_ajax()) { redirect($login . '/' . uri_safe_encode($this->uri->uri_string())); } else { $output = "<script type=\"text/javascript\" charset=\"utf-8\">\n"; $output .= "top.window.location = '" . site_url($login) . "'\n"; $output .= "</script>\n"; $this->output->set_output($output); return; } } }
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); }
/** * Common query that will automatically hide non-published/active items from view on the front end * * @access public * @param boolean whether to display unpublished content in the front end if logged in * @return void */ public function _common_query($display_unpublished_if_logged_in = NULL) { if (!isset($display_unpublished_if_logged_in)) { $display_unpublished_if_logged_in = $this->display_unpublished_if_logged_in; } if (!defined('FUEL_ADMIN') and $display_unpublished_if_logged_in === FALSE or $display_unpublished_if_logged_in and !is_fuelified()) { $this->_publish_status(); } }
/** * Returns where condition based on the users logged in state * * @access protected * @param string * @param mixed * @return array */ protected function _publish_status($t = 'blog_posts', $where = array()) { $this->_CI->load->module_helper(FUEL_FOLDER, 'fuel'); $tables = $this->_CI->config->item('tables'); if (!is_fuelified()) { $where[$tables[$t] . '.published'] = 'yes'; } return $where; }
/** * Renders a marker on the page which is used on the front end to create the inline editng pencil icons with some javascript * * @access public * @param string The markers key value used to identify it on the apge * @return string */ public function render_marker($key) { if (!isset($this->markers[$key])) { return ''; } $marker = $this->markers[$key]; if (empty($marker)) { return ''; } extract($marker); // fix for pages permission $perm = $permission == 'pagevariables' ? 'pages' : $permission; $perm_type = $perm == 'create' ? 'create' : 'edit'; if ($this->fuel->config('admin_enabled') and is_fuelified() and (is_null($this->CI->load->get_var('fuelified')) or $this->CI->load->get_var('fuelified') === TRUE) and $this->CI->fuel->auth->has_permission($perm, $perm_type)) { if (empty($label)) { $label_arr = explode('|', $id); $label = !empty($label_arr[1]) ? $label_arr[1] : $label_arr[0]; $label = ucfirst(str_replace('_', ' ', $label)); } // must use span tags because nesting anchors can cause issues; $published = is_true_val($marker['published']) ? '1' : '0'; $edit_method = (empty($id) or substr($id, 0, 6) == 'create') ? 'inline_create' : 'inline_edit'; $output = '<span class="__fuel_marker__" data-href="' . fuel_url($module) . '/' . $edit_method . '/" data-rel="' . $id . '" title="' . $label . '" data-module="' . $module . '" data-published="' . $published . '"'; if (isset($xoffset) or isset($yoffset)) { $output .= ' style="'; if (isset($xoffset)) { $output .= 'left:' . $xoffset . 'px;'; } if (isset($yoffset)) { $output .= 'top:' . $yoffset . 'px;'; } $output .= '"'; } $output .= "></span>"; return $output; } return ''; }
function render_marker($key) { if (!isset($this->markers[$key])) { return ''; } $marker = $this->markers[$key]; if (empty($marker)) { return ''; } extract($marker); if ($this->_CI->config->item('admin_enabled', 'fuel') and is_fuelified() and (!isset($this->_CI->load->_ci_cached_vars['fuelified']) or $this->_CI->load->_ci_cached_vars['fuelified'] === TRUE)) { if (empty($label)) { $label_arr = explode('|', $id); $label = !empty($label_arr[1]) ? $label_arr[1] : $label_arr[0]; $label = ucfirst(str_replace('_', ' ', $label)); } $output = '<a class="__fuel_marker__" href="' . fuel_url($module) . '/inline_edit/" rel="' . $id . '" title="' . $label . '" data-module="' . $module . '"'; if (isset($xoffset) or isset($yoffset)) { $output .= ' style="'; if (isset($xoffset)) { $output .= 'left:' . $xoffset . 'px;'; } if (isset($yoffset)) { $output .= 'top:' . $yoffset . 'px;'; } $output .= '"'; } $output .= "></a>"; return $output; } return ''; }
/** * Returns where condition based on the users logged in state * * @access protected * @param string * @param mixed * @return array */ protected function _publish_status($t = 'blog_posts', $where = array()) { $this->CI->load->module_helper(FUEL_FOLDER, 'fuel'); $tables = Base_module_model::$tables; if (!is_fuelified()) { if (empty($where) or is_array($where)) { // taken care of in the model //$where[$tables[$t].'.published'] = 'yes'; // don't show posts in the future' if ($t == 'blog_posts') { $where[$tables[$t] . '.post_date <= '] = datetime_now(); } } else { // $where .= ' AND '.$tables[$t].'.published = "yes"'; // don't show posts in the future' if ($t == 'blog_posts') { // $where .= ' AND '.$tables[$t].'.post_date <= "'.datetime_now().'"'; } } } return $where; }
function render_marker($key) { if (!isset($this->markers[$key])) return ''; $marker = $this->markers[$key]; if (empty($marker)) return ''; extract($marker); if ($this->_CI->config->item('admin_enabled', 'fuel') AND is_fuelified() AND (!isset($this->_CI->load->_ci_cached_vars['fuelified']) OR $this->_CI->load->_ci_cached_vars['fuelified'] === TRUE) ) { if (empty($label)) { $label_arr = explode('|', $id); $label = (!empty($label_arr[1])) ? $label_arr[1] : $label_arr[0]; $label = ucfirst(str_replace('_', ' ', $label)); } // must use span tags because nesting anchors can cause issues $output = '<span class="__fuel_marker__" data-href="'.fuel_url($module).'/inline_edit/" data-rel="'.$id.'" title="'.$label.'" data-module="'.$module.'"'; if (isset($xoffset) OR isset($yoffset)) { $output .= ' style="'; if (isset($xoffset)) $output .= 'left:'.$xoffset.'px;'; if (isset($yoffset)) $output .= 'top:'.$yoffset.'px;'; $output .= '"'; } $output .= "></span>"; return $output; } return ''; }
/** * Returns the inline editing toolbar HTML * * @access public * @return void */ public function toolbar() { $user_lang = $this->fuel->auth->user_lang(); $this->fuel->load_language('fuel_inline_edit', $user_lang); $this->fuel->load_language('fuel_js', $user_lang); $vars['page'] = $this->fuel->page->properties(); $vars['layouts'] = $this->fuel->layouts->options_list(); $vars['language'] = $this->fuel->language->detect(); $vars['language_mode'] = $this->fuel->language->mode(); $vars['language_default'] = $this->fuel->language->default_option(); $vars['tools'] = $this->toolbar_tools(); $vars['js_localized'] = json_lang('fuel/fuel_js', $user_lang); $vars['is_fuelified'] = is_fuelified(); $vars['can_edit_pages'] = $this->CI->fuel->auth->has_permission('pages', 'edit'); if ($this->fuel->pages->mode() == 'views') { $vars['others'] = array(); } else { $location = uri_path(); $this->CI->load->module_model(FUEL_FOLDER, 'fuel_pages_model'); $vars['others'] = $this->CI->fuel_pages_model->get_others('location', $location, 'location'); } $vars['init_params']['pageId'] = !empty($vars['page']['id']) ? $vars['page']['id'] : 0; $vars['init_params']['pageLocation'] = !empty($vars['page']['location']) ? $vars['page']['location'] : uri_path(); $vars['init_params']['basePath'] = WEB_PATH; $vars['init_params']['cookiePath'] = $this->CI->fuel->config('fuel_cookie_path'); $vars['init_params']['imgPath'] = img_path('', 'fuel'); $vars['init_params']['cssPath'] = css_path('', 'fuel'); $vars['init_params']['jsPath'] = js_path('', 'fuel'); $vars['init_params']['editor'] = $this->fuel->config('text_editor'); $vars['init_params']['editorConfig'] = $this->fuel->config('ck_editor_settings'); $last_page = uri_path(); if (empty($last_page)) { $last_page = $this->fuel->config('default_home_view'); } $vars['last_page'] = uri_safe_encode($last_page); $output = $this->CI->load->module_view(FUEL_FOLDER, '_blocks/inline_edit_bar', $vars, TRUE); return $output; }
protected function _check_login() { // set no cache headers to prevent back button problems in FF $this->_no_cache(); // load this after the the above because it needs a database connection. Avoids a database connection error if there isn't one' $this->load->module_library(FUEL_FOLDER, 'fuel_auth'); // check if logged in if (!$this->fuel_auth->is_logged_in() OR !is_fuelified()) { $login = $this->config->item('fuel_path', 'fuel').'login'; // logout officially to unset the cookie data $this->fuel_auth->logout(); if (!is_ajax()) { redirect($login.'/'.uri_safe_encode($this->uri->uri_string())); } else { $output = "<script type=\"text/javascript\" charset=\"utf-8\">\n"; $output .= "top.window.location = '".site_url($login)."'\n"; $output .= "</script>\n"; $this->output->set_output($output); return; } } }