Пример #1
0
function apache_specific_request_path()
{
    if (!apache_specific_is_rewrite_engine_on()) {
        return default_request_path();
    }
    return _apache_specific_request_path(server_var('REQUEST_URI'), uri_path(server_var('PHP_SELF')));
}
Пример #2
0
 function _render($view, $vars = array(), $return = FALSE, $layout = '')
 {
     if (empty($layout)) {
         $layout = '_layouts/' . $this->fuel_blog->layout();
     }
     $this->load->module_library(FUEL_FOLDER, 'fuel_pagevars');
     // get any global variables for the headers and footers
     $_vars = $this->fuel_pagevars->retrieve(uri_path());
     if (is_array($_vars)) {
         $vars = array_merge($_vars, $vars);
     }
     $view_folder = $this->fuel_blog->theme_path();
     $vars['CI'] =& get_instance();
     if (!empty($layout)) {
         $vars['body'] = $this->load->module_view($this->fuel_blog->settings('theme_module'), $view_folder . $view, $vars, TRUE);
         $view = $this->fuel_blog->theme_path() . $this->fuel_blog->layout();
     } else {
         $view = $view_folder . $view;
     }
     $output = $this->load->module_view($this->fuel_blog->settings('theme_module'), $view, $vars, TRUE);
     $this->load->module_library(FUEL_FOLDER, 'fuel_page');
     $this->fuel_page->initialize();
     $output = $this->fuel_page->fuelify($output);
     if ($return) {
         return $output;
     } else {
         $this->output->set_output($output);
     }
 }
Пример #3
0
 public function _remap()
 {
     if ($this->fuel->modules->exists('user_guide') and defined('USER_GUIDE_FOLDER')) {
         $this->load->helper(USER_GUIDE_FOLDER, 'user_guide');
     }
     $this->load->helper('text');
     $page = uri_path(TRUE, 1);
     if (empty($page)) {
         $page = 'index';
     }
     $this->fuel->pagevars->vars_path = APPPATH . 'views/_variables/';
     $this->fuel->pagevars->location = $page;
     $vars = $this->fuel->pagevars->view('site_docs');
     $vars['body'] = 'index';
     // render page
     if (file_exists(APPPATH . '/views/_docs/' . $page . '.php')) {
         // use app module which is the application directory
         $vars['body'] = $this->load->module_view('app', '_docs/' . $page, $vars, TRUE);
         // get layout page
         if (file_exists(APPPATH . 'views/_layouts/documentation.php')) {
             $this->load->module_view(NULL, '_layouts/documentation', $vars);
         } else {
             if (file_exists(FUEL_PATH . 'views/_layouts/documentation' . EXT)) {
                 $vars['page_title'] = $this->config->item('site_name', 'fuel');
                 $this->load->view('_layouts/documentation', $vars);
             } else {
                 $this->output->set_output($vars['body']);
             }
         }
     } else {
         show_404();
     }
 }
Пример #4
0
 function _remap($method)
 {
     $this->location = uri_path(TRUE);
     // if the rerouted file can't be found, look for the non-routed file'
     if (!file_exists(APPPATH . 'views/' . $this->location . EXT)) {
         $this->location = uri_path(FALSE);
     }
     if (empty($this->location)) {
         $this->location = $this->config->item('default_home_view', 'fuel');
     }
     $this->load->module_library(FUEL_FOLDER, 'fuel_page');
     $config = array();
     $config['location'] = $this->location;
     if ($this->config->item('fuel_mode', 'fuel') == 'views') {
         $config['render_mode'] = 'views';
         $this->fuel_page->initialize($config);
         $this->_remap_variables($method);
     } else {
         if ($this->config->item('fuel_mode', 'fuel') != 'cms') {
             $config['render_mode'] = 'auto';
             $this->fuel_page->initialize($config);
             if (!$this->fuel_page->has_cms_data()) {
                 $this->_remap_variables();
                 return;
             }
         }
         $this->_remap_cms();
     }
 }
Пример #5
0
 function _get_page()
 {
     $uri = uri_path(FALSE);
     $root_url = $this->config->item('user_guide_root_url');
     if (substr($root_url, -1) == '/') {
         $root_url = substr($root_url, 0, strlen($root_url) - 1);
     }
     $new_uri = preg_replace('#^' . $root_url . '#', '', $uri);
     return $new_uri;
 }
Пример #6
0
 function dev_password()
 {
     $CI =& get_instance();
     if ($CI->config->item('dev_password', 'fuel') and !$CI->fuel_auth->is_logged_in() and !preg_match('#^' . fuel_uri('login') . '#', uri_path(FALSE))) {
         $CI->load->library('session');
         if (!$CI->session->userdata('dev_password')) {
             redirect('fuel/login/dev');
         }
     }
 }
Пример #7
0
 public function offline()
 {
     if (!USE_FUEL_ROUTES) {
         $CI =& get_instance();
         if ($CI->fuel->config('offline') and !$CI->fuel->auth->is_logged_in() and !preg_match('#^' . fuel_uri('login') . '#', uri_path(FALSE))) {
             echo $CI->fuel->pages->render('offline', array(), array(), TRUE);
             exit;
         }
     }
 }
Пример #8
0
 public function initialize($params = array())
 {
     parent::initialize($params);
     if (empty($this->location)) {
         $this->location = uri_path();
     }
     $default_home = $this->fuel->config('default_home_view');
     if (empty($this->location) or $this->location == $this->CI->router->routes['404_override']) {
         $this->location = $default_home;
     }
 }
Пример #9
0
 public function initialize($params)
 {
     parent::initialize($params);
     if (empty($this->location)) {
         $this->location = uri_path();
     }
     $default_home = $this->fuel->config('default_home_view');
     if (empty($this->location) or $this->location == 'page_router') {
         $this->location = $default_home;
     }
 }
 protected function _last_page($key = NULL)
 {
     if (!isset($key)) {
         $key = uri_path(FALSE);
     }
     $invalid = array(fuel_uri('recent'));
     $session_key = $this->fuel_auth->get_session_namespace();
     $user_data = $this->fuel_auth->user_data();
     if (!is_ajax() and empty($_POST) and !in_array($key, $invalid)) {
         $user_data['last_page'] = $key;
         $this->session->set_userdata($session_key, $user_data);
     }
 }
Пример #11
0
 public function _remap($method)
 {
     $this->location = uri_path(TRUE);
     // if the rerouted file can't be found, look for the non-routed file'
     if (!file_exists(APPPATH . 'views/' . $this->location . EXT)) {
         $non_routed_uri = uri_path(FALSE);
         if (file_exists(APPPATH . 'views/' . $non_routed_uri . EXT)) {
             $this->location = $non_routed_uri;
         }
         unset($non_routed_uri);
     }
     if (empty($this->location)) {
         $this->location = $this->fuel->config('default_home_view');
     }
     $config = array();
     $config['location'] = $this->location;
     if ($this->fuel->pages->mode() == 'views') {
         $config['render_mode'] = 'views';
         $page = $this->fuel->pages->create($config);
         $this->_remap_variables($page);
     } else {
         if ($this->fuel->pages->mode() != 'cms') {
             $config['render_mode'] = 'auto';
             if ($this->fuel->config('uri_view_overwrites')) {
                 // loop through the pages array looking for wild-cards
                 foreach ($this->fuel->config('uri_view_overwrites') as $val) {
                     // convert wild-cards to RegEx
                     $key = str_replace(':any', '.+', str_replace(':num', '[0-9]+', $val));
                     // does the RegEx match?
                     if (preg_match('#^' . $val . '$#', $config['location'])) {
                         $config['render_mode'] = 'views';
                     }
                 }
             }
             $page = $this->fuel->pages->create($config);
             if (!$page->has_cms_data() and $config['render_mode'] == 'auto' or $config['render_mode'] == 'views') {
                 $this->_remap_variables($page);
                 return;
             }
         } else {
             $config['render_mode'] = 'cms';
             $page = $this->fuel->pages->create($config);
         }
         $this->_remap_cms($page);
     }
 }
Пример #12
0
 /**
  * Returns an array of site variables pertaining to a given URI path
  *
  * @access	public
  * @param	string	A URI path. If left blank, the current URI path will be used (optional)
  * @return	array
  */
 public function get($location = NULL)
 {
     if (is_null($location)) {
         $location = uri_path();
     }
     $this->fuel->load_model('fuel_sitevariables');
     $site_vars = $this->CI->fuel_sitevariables_model->find_all_array(array('active' => 'yes'));
     $vars = array();
     // Loop through the pages array looking for wild-cards
     foreach ($site_vars as $site_var) {
         // Convert wild-cards to RegEx
         $key = str_replace(':any', '.+', str_replace(':num', '[0-9]+', $site_var['scope']));
         // Does the RegEx match?
         if (empty($key) or preg_match('#^' . $key . '$#', $location)) {
             $vars[$site_var['name']] = $site_var['value'];
         }
     }
     return $vars;
 }
Пример #13
0
 function _remap()
 {
     $this->load->module_library(FUEL_FOLDER, 'fuel_pagevars');
     if ($this->_has_module('user_guide')) {
         $this->load->helper(USER_GUIDE_FOLDER, 'user_guide');
     }
     $this->load->helper('text');
     $page = uri_path(TRUE, 1);
     if (empty($page)) {
         $page = 'index';
     }
     $this->fuel_pagevars->vars_path = APPPATH . 'views/_variables/';
     $vars = $this->fuel_pagevars->view_variables($page, 'site_docs');
     $vars['body'] = 'index';
     // render page
     if (file_exists(APPPATH . '/views/_docs/' . $page . '.php')) {
         // HACK to get it to go to the application directory set the _directories array to empty
         $matchbox_dirs = $this->matchbox->_directories;
         $this->matchbox->_directories = array();
         $vars['body'] = $this->load->view('_docs/' . $page, $vars, TRUE);
         // get layout page
         if (file_exists(APPPATH . 'views/_layouts/documentation.php')) {
             $this->load->module_view(NULL, '_layouts/documentation', $vars);
         } else {
             if ($this->_has_module('user_guide')) {
                 $this->matchbox->_directories = $matchbox_dirs;
                 $vars['page_title'] = $this->config->item('site_name', 'fuel');
                 $this->load->view('_layouts/documentation', $vars);
             } else {
                 $this->output->set_output($vars['body']);
             }
         }
     } else {
         show_404();
     }
 }
Пример #14
0
 function is_home()
 {
     $uri_path = uri_path(FALSE);
     $CI =& get_instance();
     $segs = explode('/', $CI->router->routes['404_override']);
     return $uri_path == 'home' or $uri_path == '' or $uri_path == end($segs);
 }
Пример #15
0
 *
 * Bombay is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * General Public License for more details.
 *
 * To read the license please visit http://www.gnu.org/copyleft/gpl.html
 *
 *
 *-------10--------20--------30--------40--------50--------60---------72
 */
requires('helpers', 'webserver');
define('URI_SCHEME', uri_scheme(server_var('HTTPS')));
define('URI_HOST', uri_host(server_var('HTTP_HOST')));
define('URI_PORT', uri_port(server_var('HTTP_HOST')));
define('URI_PATH', uri_path(server_var('PHP_SELF')));
define('URI_ABSOLUTE_BASE', uri_absolute_base(URI_SCHEME, URI_HOST, URI_PORT, URI_PATH));
define('URI_RELATIVE_BASE', uri_relative_base(URI_PATH));
define('URI_SECURE_ABSOLUTE_BASE', uri_absolute_base('https', URI_HOST, URI_PORT, URI_PATH));
function uri_scheme($https)
{
    $ssl = !is_null($https) and is_equal('on', $https);
    $scheme = $ssl ? 'https' : 'http';
    return $scheme;
}
function uri_host($http_host)
{
    $pieces = explode(':', $http_host);
    if (str_contains(':', $http_host)) {
        $host = array_shift($pieces);
    } else {
 function _remap()
 {
     $this->current_page = $this->fuel->user_guide->current_page();
     $cache_id = $this->current_page;
     if ($this->fuel->user_guide->config('use_cache') and $this->fuel->cache->is_cached($cache_id)) {
         $output = $this->fuel->cache->get($cache_id);
     } else {
         $this->fuel->pagevars->vars_path = USER_GUIDE_PATH . 'views/_variables/';
         $vars = array();
         // get modules
         $modules = array('', 'fuel');
         $modules = array_merge($modules, $this->fuel->config('modules_allowed'));
         $vars = $this->fuel->user_guide->get_vars($this->current_page);
         foreach ($modules as $m) {
             if ((!$this->fuel->user_guide->config('authenticate') or $this->fuel->auth->has_permission('user_guide_' . $m)) and file_exists(MODULES_PATH . $m . '/views/_docs/index' . EXT)) {
                 $module_view = $this->load->module_view($m, '_docs/index', array(), TRUE);
                 $mod_page_title = $this->fuel->user_guide->page_title($module_view);
                 $vars['modules'][$m] = !empty($mod_page_title) ? $mod_page_title : humanize($m) . ' Module';
             }
         }
         // render page
         // pull from modules folder if URI says so
         $uri_path_index = count(explode('/', $this->fuel->user_guide->config('root_url'))) + 1;
         $module_page = uri_path(FALSE, $uri_path_index);
         $module_view_path = !empty($module_page) ? '_docs/' . $module_page : '_docs/index';
         $allow_auto_generation = $this->fuel->user_guide->config('allow_auto_generation');
         if (is_file(USER_GUIDE_PATH . 'views/' . $this->current_page . EXT)) {
             $vars['body'] = $this->load->module_view(USER_GUIDE_FOLDER, $this->current_page, $vars, TRUE);
             if ($this->fuel->user_guide->page_segment(2)) {
                 $vars['sections'] = $this->fuel->user_guide->breadcrumb($this->current_page);
             }
         } else {
             if (is_file(FUEL_PATH . 'views/_docs/' . $this->current_page . EXT)) {
                 $vars['body'] = $this->load->module_view(FUEL_FOLDER, '_docs/' . $this->current_page, $vars, TRUE);
                 if ($this->fuel->user_guide->page_segment(2)) {
                     $vars['sections'] = $this->fuel->user_guide->breadcrumb($this->current_page);
                 }
             } else {
                 if ($this->fuel->user_guide->page_segment(2)) {
                     if (in_array($this->fuel->user_guide->page_segment(1), $this->fuel->user_guide->valid_folders)) {
                         $module = FUEL_FOLDER;
                         $file = $this->fuel->user_guide->page_segment(2);
                         $uri_path_index = count(explode('/', $this->fuel->user_guide->config('root_url'))) - 2;
                         $module_view_path = '_docs/' . uri_path(FALSE, $uri_path_index);
                     } else {
                         $module = $this->fuel->user_guide->page_segment(2);
                         $file = $this->fuel->user_guide->page_segment(3);
                         if (!empty($file) and $file != 'index') {
                             $module_view_path = '_docs/' . $file;
                         }
                     }
                     $body = '';
                     if (file_exists(MODULES_PATH . $module . '/views/' . $module_view_path . EXT)) {
                         $body = $this->load->module_view($module, $module_view_path, $vars, TRUE);
                     } else {
                         if ($allow_auto_generation === TRUE or in_array($module, $allow_auto_generation)) {
                             if (!empty($file)) {
                                 $uri_folder = $this->fuel->user_guide->page_segment(4);
                                 $valid_folders = $this->fuel->user_guide->valid_folders;
                                 $file_name = ucfirst($file);
                                 $folder = ($uri_folder and in_array($uri_folder, $valid_folders)) ? $uri_folder : 'libraries';
                                 if (preg_match('#_helper$#', $file)) {
                                     $folder = 'helpers';
                                     $file_name = strtolower($file);
                                 } else {
                                     if (preg_match('#_model$#', $file)) {
                                         $folder = 'models';
                                         $file_name = strtolower($file);
                                     }
                                 }
                                 $file_name = preg_replace('#^my_(\\w+)#', 'MY_$1', $file_name);
                                 $file_path = MODULES_PATH . $module . '/' . $folder . '/' . $file_name . EXT;
                                 if (file_exists($file_path)) {
                                     $body = $this->fuel->user_guide->generate_docs($file_name, $folder, $module, array());
                                 } else {
                                     $file_path = APPPATH . '/' . $folder . '/' . $file_name . EXT;
                                     if (file_exists($file_path)) {
                                         $body = $this->fuel->user_guide->generate_docs($file_name, $folder, $module, array());
                                     }
                                 }
                                 if ($this->fuel->user_guide->page_segment(2)) {
                                     $vars['sections'] = $this->fuel->user_guide->breadcrumb($this->current_page);
                                 }
                             }
                         }
                     }
                     if (!$this->fuel->user_guide->config('authenticate') or $this->fuel->auth->has_permission('user_guide_' . $module) and isset($body)) {
                         $vars['body'] = $body;
                         if ($file) {
                             if (isset($vars['modules'][$module])) {
                                 if ($module != FUEL_FOLDER) {
                                     $vars['sections'] = array($vars['modules'][$module] => 'modules/' . $module);
                                 }
                             } else {
                                 redirect_404();
                             }
                         }
                     }
                 } else {
                     redirect_404();
                 }
             }
         }
         if (empty($vars['body'])) {
             redirect_404();
         }
         $vars['page_title'] = $this->fuel->user_guide->page_title($vars['body']);
         $output = $this->load->module_view(USER_GUIDE_FOLDER, '_layouts/user_guide', $vars, TRUE);
         if ($this->fuel->user_guide->config('use_cache')) {
             $this->fuel->cache->save($cache_id, $output);
         }
     }
     $this->output->set_output($output);
 }
Пример #17
0
 /**
  * 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;
 }
Пример #18
0
 function __construct()
 {
     $this->_CI =& get_instance();
     $this->location = uri_path();
 }
 /**
  * Initializes the user guide page
  * 
  * @access	public
  * @return	void
  */
 function init_page()
 {
     $uri = uri_path(FALSE);
     $root_url = $this->config('root_url');
     if (substr($root_url, -1) == '/') {
         $root_url = trim(substr($root_url, 0, strlen($root_url) - 1), '/');
     }
     $new_uri = preg_replace('#^' . $root_url . '#', '', trim($uri, '/'));
     if (empty($new_uri)) {
         $new_uri = 'home';
     }
     $this->set_current_page($new_uri);
 }
Пример #20
0
 /**
  * Returns the maximum number of page parameters associated with the current page
  *
  * @access	public
  * @return	int
  */
 public function get_max_page_param()
 {
     static $max_page_params;
     // determine max page params
     if (is_null($max_page_params)) {
         $max_page_params = 0;
     }
     if (is_array($this->fuel->config('max_page_params'))) {
         //$location = implode('/', $this->CI->uri->rsegment_array());
         $location = uri_path();
         // use this function instead so it will remove any language parameters
         foreach ($this->fuel->config('max_page_params') as $key => $val) {
             // add any match to the end of the key in case it doesn't exist (no problems if it already does)'
             $key .= ':any';
             // convert wild-cards to RegEx
             $key = str_replace(':any', '.+', str_replace(':num', '[0-9]+', $key));
             // does the RegEx match?
             if (preg_match('#^' . $key . '$#', $location)) {
                 $max_page_params = $val;
                 break;
             }
         }
     } else {
         $max_page_params = (int) $this->fuel->config('max_page_params');
     }
     return $max_page_params;
 }
Пример #21
0
	function fuelify($output)
	{
		// if not logged in then we remove the markers
		if (!$this->_CI->config->item('admin_enabled', 'fuel') OR $this->variables('fuelified') === FALSE OR 
			!$this->_fuelified OR empty($output) OR (defined('FUELIFY') AND FUELIFY === FALSE)) 
		{
			return $this->remove_markers($output);
		} 
		
		$this->_CI->load->library('session');
		$this->_CI->load->helper('convert');
		
		
		// add top edit bar for fuel
		$this->_CI->config->module_load('fuel', 'fuel', TRUE);
		
		// render the markers to the proper html
		$output = $this->render_all_markers($output);
		
		// set main image and assets path before switching to fuel assets path
		$vars['init_params'] = array(
			'assetsImgPath' => img_path(''),
			'assetsPath' => assets_path(''),
			);
		
		$this->_CI->asset->assets_path = $this->_CI->config->item('fuel_assets_path', 'fuel');
		$this->_CI->load->helper('ajax');
		$this->_CI->load->library('form');
		$vars['page'] = $this->properties();
		$vars['layouts'] = $this->_CI->fuel_layouts->layouts_list(TRUE);
		$last_page = uri_path();
		if (empty($last_page)) $last_page = $this->_CI->config->item('default_home_view', 'fuel');
		$vars['last_page'] = uri_safe_encode($last_page);

		$editable_asset_types = $this->_CI->config->item('editable_asset_filetypes', 'fuel');


		// add javascript
		$vars['init_params']['pageId'] = (!empty($vars['page']['id']) ? $vars['page']['id'] : 0);
		$vars['init_params']['basePath'] = WEB_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->_CI->config->item('text_editor', 'fuel');
		$vars['init_params']['editorConfig'] = $this->_CI->config->item('ck_editor_settings', 'fuel');
		
		// load language files
		$this->_CI->load->module_language(FUEL_FOLDER, 'fuel_inline_edit');
		$this->_CI->load->module_language(FUEL_FOLDER, 'fuel_js');
		
		
		// json localization
		$vars['js_localized'] = json_lang('fuel/fuel_js');
		$vars['assetsAccept']['assetsAccept'] = (!empty($editable_asset_types['media']) ? $editable_asset_types['media'] : 'jpg|gif|png');
		
		// database specific... so we must check the fuel mode to see if we actually need to make a call to the database. 
		// otherwise we get an error when the mode is set to views
		if ($this->_CI->config->item('fuel_mode', 'fuel') == 'views')
		{
			$vars['others'] = array();
		}
		else
		{
			$this->_CI->load->module_model(FUEL_FOLDER, 'pages_model');
			$vars['others'] = $this->_CI->pages_model->get_others('location', $this->location, 'location');
		}
		
		if (!$this->_fuelified_processed)
		{
			$inline_edit_bar = $this->_CI->load->module_view(FUEL_FOLDER, '_blocks/inline_edit_bar', $vars, TRUE);
			$output = preg_replace('#(</head>)#i', css('fuel_inline', 'fuel')."\n$1", $output);
			$output = preg_replace('#(</body>)#i', $inline_edit_bar."\n$1", $output);
			$this->_CI->config->set_item('assets_path', $this->_CI->config->item('assets_path'));
		}
		$this->_fuelified_processed = TRUE;
		return $output;
	}
Пример #22
0
 public function offline()
 {
     if (!USE_FUEL_ROUTES) {
         $CI =& get_instance();
         // Already in offline page
         if (preg_match('#^offline(/?)$#', uri_path(FALSE))) {
             return;
         }
         if ($CI->fuel->config('offline') and !$CI->fuel->auth->is_logged_in() and !preg_match('#^' . fuel_uri('login') . '#', uri_path(FALSE))) {
             // By pass offline page if password inputed.
             $CI->load->library('session');
             if ($CI->session->userdata('dev_password')) {
                 return;
             }
             // Display allowed page
             $allowed_uri = $CI->fuel->config('offline_allowed_uri');
             if (!empty($allowed_uri)) {
                 foreach ($allowed_uri as $uri_item) {
                     if (preg_match('#^' . $uri_item . '(/?)$#', uri_path(FALSE))) {
                         return;
                     }
                 }
             }
             // Instead of using render, changed to redirect
             redirect('offline');
             //echo $CI->fuel->pages->render('offline', array(), array(), TRUE);
             //exit();
         }
     }
 }
Пример #23
0
var jqx_config = {};
jqx_config.basePath =  "<?php 
echo trim(site_url(), '/') . '/';
?>
";
jqx_config.jsPath = "<?php 
echo js_path('', 'fuel');
?>
";
jqx_config.imgPath = "<?php 
echo img_path('', 'fuel');
?>
";

jqx_config.uriPath = "<?php 
echo uri_path(FALSE);
?>
";
jqx_config.assetsImgPath = "<?php 
echo img_path('');
?>
";
jqx_config.assetsPath = "<?php 
echo assets_path('');
?>
";
jqx_config.assetsCssPath = "<?php 
echo css_path('');
?>
";
jqx_config.controllerName = 'fuel';
Пример #24
0
/**
 * Creates a menu structure
 *
 * @access	public
 * @param	mixed
 * @return	string
 */
function fuel_nav($params = array())
{
	$CI =& get_instance();
	$CI->load->library('menu');
	$valid = array( 'items' => array(),
					'file' => 'nav',
					'var' => 'nav',
					'root' => NULL,
					'group_id' => 1,
					'parent' => NULL, 
					'render_type' => 'basic', 
					'active_class' => 'active', 
					'active' => (uri_path(FALSE) !== '') ? uri_path(FALSE) : 'home',
					'styles' => array(),
					'first_class' => 'first', 
					'last_class' => 'last', 
					'depth' => NULL, 
					'use_titles' => TRUE,
					'container_tag' => 'ul',
					'container_tag_attrs' => '',
					'container_tag_id' => '',
					'container_tag_class' => '',
					'cascade_selected' => TRUE,
					'include_hidden' => FALSE,
					'item_tag' => 'li',
					'item_id_prefix' => '',
					'item_id_key' => 'id',
					'pre_render_func' => '',
					'delimiter' => FALSE,
					'arrow_class' => 'arrow',
					'display_current' => TRUE,
					'home_link' => 'Home',
					'order' => 'asc',
					'exclude' => array(),
					'return_normalized' => FALSE,
					);

	if (!is_array($params))
	{
		$CI->load->helper('array');
		$params = parse_string_to_array($params);
	}

	$p = array();
	foreach($valid as $param => $default)
	{
		$p[$param] = (isset($params[$param])) ? $params[$param] : $default;
	}
	
	if (empty($p['items']))
	{
		// get the menu data based on the FUEL mode or if the file parameter is specified use that
		if ($CI->config->item('fuel_mode', 'fuel') == 'views' OR !empty($params['file']))
		{
			if (file_exists(APPPATH.'views/_variables/'.$p['file'].'.php'))
			{
				include(APPPATH.'views/_variables/'.$p['file'].'.php');
			}
			else
			{
				$$p['var'] = array();
			}
		}

		// using FUEL admin
		else
		{
			if ($CI->config->item('fuel_mode', 'fuel') != 'cms')
			{
				// load in navigation file as a starting poing
				if (file_exists(APPPATH.'views/_variables/'.$p['file'].'.php'))
				{
					$p['root_value'] = NULL;
					include(APPPATH.'views/_variables/'.$p['file'].'.php');
				}
			}
			// now load from FUEL and overwrite
			$CI->load->module_model(FUEL_FOLDER, 'navigation_model');
			
			// grab all menu items by group
			$menu_items = $CI->navigation_model->find_all_by_group($p['group_id']);

			// if menu items isn't empty, then we overwrite the variable with those menu items and change any parent value'
			if (!empty($menu_items)) 
			{
				$$p['var'] = $menu_items;
				
				// if parent exists, then assume it is a uri location and you need to convert it to a database id value
				if (!empty($p['parent']) AND is_string($p['parent']))
				{
					// WARNING... it is possible to have more then one navigation item with the same location so it's best not to location values but instead use ids
					$parent = $CI->navigation_model->find_by_location($p['parent']);
					if (!empty($parent['id']))
					{
						$p['parent'] = $parent['id'];
					}
				}

				// if active exists, then assume it is a uri location and you need to convert it to a database id value
				if (!empty($p['active']) AND is_string($p['active']))
				{
					// WARNING... it is possible to have more then one navigation item with the same location so it's best not to location values but instead use ids'
					$active = $CI->navigation_model->find_by_location($p['active'], $p['group_id']);
					if (!empty($active['id']))
					{
						$p['active'] = $active['id'];
					}
				}
				$p['root_value'] = 0;
			}
		}
	}
	else
	{
		$$p['var'] = $p['items'];
	}
	if (!empty($params['root'])) $p['root_value'] = $params['root'];

	$CI->menu->reset();
	$CI->menu->initialize($p);
	
	$items = (!empty($$p['var'])) ? $$p['var'] : array();
	if (!empty($p['exclude']))
	{
		$p['exclude'] = (array) $p['exclude'];
		foreach($items as $key => $item)
		{
			if (is_int($key) AND !empty($item['location']))
			{
				$check = $item['location'];
			}
			else
			{
				$check = $key;
			}
			if (in_array($check, $p['exclude']))
			{
				unset($items[$key]);
			}
			
		}
	}
	
	if ($p['return_normalized'] !== FALSE)
	{
		return $CI->menu->normalize_items($items);
	}
	return $CI->menu->render($items, $p['active'], $p['parent']);
}
Пример #25
0
 /**
  * Returns a boolean value whether it is the home page.
  *
  * @access	public
  * @return	boolean
  */
 public function is_home()
 {
     if (uri_path(FALSE) == trim($this->module_config('base_uri'), '/')) {
         return TRUE;
     }
     return FALSE;
 }
Пример #26
0
 /**
 * Renders a navigation structure using the <a href="[user_guide_url]libraries/menu">Menu class</a>.
 *
 * The <a href="[user_guide_url]helpers/fuel_helper">fuel_nav helper</a> function is an alias to this method.
 *
 	<ul>
 		<li><strong>items</strong> - the navigation items to use. By default, this is empty and will look for the nav.php file or the records in the Navigation module</li>
 		<li><strong>file</strong> - the name of the file containing the navigation information</li>
 		<li><strong>var</strong> - the variable name in the file to use</li>
 		<li><strong>parent</strong> - the parent id you would like to start rendering from. This is either the database ID or the nav array key of the menu item</li>
 		<li><strong>root</strong> - the equivalent to the root_value attribute in the Menu class. It states what the root value of the menu structure should be. Normally you don't need to worry about this</li>
 		<li><strong>group_id</strong> - the group ID in the database to use. The default is <dfn>1</dfn>. Only applies to navigation items saved in the admin</li>
 		<li><strong>exclude</strong> - nav items to exclude from the menu. Can be an array or a regular expression string</li>
 		<li><strong>return_normalized</strong> - returns the raw normalized array that gets used to generate the menu</li>
 		<li><strong>render_type</strong>: options are basic, breadcrumb, page_title, collapsible, delimited, array. Default is 'basic'</li>
 		<li><strong>active_class</strong>: the active css class. Default is 'active'</li>
 		<li><strong>active</strong>: the active menu item</li>
 		<li><strong>styles</strong>: css class styles to apply to menu items... can be a nested array</li>
 		<li><strong>first_class</strong>: the css class for the first menu item. Default is first</li>
 		<li><strong>last_class</strong>: the css class for the last menu item. Default is last</li>
 		<li><strong>depth</strong>: the depth of the menu to render at</li>
 		<li><strong>use_titles</strong>: use the title attribute in the links. Default is FALSE</li>
 		<li><strong>container_tag</strong>: the html tag for the container of a set of menu items. Default is ul</li>
 		<li><strong>container_tag_attrs</strong>: html attributes for the container tag</li>
 		<li><strong>container_tag_id</strong>: html container id</li>
 		<li><strong>container_tag_class</strong>: html container class</li>
 		<li><strong>cascade_selected</strong>: cascade the selected items. Default is TRUE</li>
 		<li><strong>include_hidden</strong>: include menu items with the hidden attribute. Default is FALSE</li>
 		<li><strong>item_tag</strong>: the html list item element. Default is 'li'</li>
 		<li><strong>item_id_prefix</strong>: the prefix to the item id</li>
 		<li><strong>item_id_key</strong>: either id or location. Default is 'id'</li>
 		<li><strong>use_nav_key</strong>: determines whether to use the nav_key or the location for the active state. Default is "AUTO"</li>
 		<li><strong>pre_render_func</strong>: function to apply to menu labels before rendering</li>
 		<li><strong>delimiter</strong>: the html element between the links </li>
 		<li><strong>arrow_class</strong>: the class for the arrows used in breadcrumb type menus</li>
 		<li><strong>display_current</strong>: determines whether to display the current active breadcrumb item</li>
 		<li><strong>home_link</strong>: the root home link</li>
 		<li><strong>append</strong>: appends additional menu items to those items already set (e.g. from the $nav array or from the navigation module). Good to use on dynamic pages where you need to dynamically set a navigation item for a page</li>
 		<li><strong>order</strong>: the order to display... for page_title ONLY</li>
 		<li><strong>language</strong>: select the appropriate language</li>
 		<li><strong>include_default_language</strong>: will merge in the default language with the results. Default is FALSE</li>
 		<li><strong>language_default_group</strong>: the default group to be used when including a default language. Default is FALSE</li>
 	</ul>
 		
 * @access	public
 * @param	array	config preferences
 * @return	string
 */
 public function render($params = array())
 {
     $this->CI->load->library('menu');
     $valid = array('items' => array(), 'file' => 'nav', 'var' => 'nav', 'root' => NULL, 'group_id' => 1, 'parent' => NULL, 'render_type' => 'basic', 'active_class' => 'active', 'active' => uri_path(FALSE) !== '' ? uri_path(FALSE) : 'home', 'styles' => array(), 'first_class' => 'first', 'last_class' => 'last', 'depth' => NULL, 'use_titles' => FALSE, 'container_tag' => 'ul', 'container_tag_attrs' => '', 'container_tag_id' => '', 'container_tag_class' => '', 'subcontainer_tag_class' => array(), 'cascade_selected' => TRUE, 'include_hidden' => FALSE, 'item_tag' => 'li', 'item_id_prefix' => '', 'item_id_key' => 'id', 'use_nav_key' => 'AUTO', 'pre_render_func' => '', 'delimiter' => FALSE, 'arrow_class' => 'arrow', 'display_current' => TRUE, 'home_link' => 'Home', 'order' => 'asc', 'exclude' => array(), 'return_normalized' => FALSE, 'append' => array(), 'language' => NULL, 'include_default_language' => FALSE, 'language_default_group' => FALSE, 'cache' => FALSE);
     if (!is_array($params)) {
         $this->CI->load->helper('array');
         $params = parse_string_to_array($params);
     }
     $p = array();
     foreach ($valid as $param => $default) {
         $p[$param] = isset($params[$param]) ? $params[$param] : $default;
     }
     // get language value... possible to get menu items from different languages so commented out for now
     // if ($this->fuel->language->has_multiple() AND empty($p['language']))
     // {
     // 	$p['language'] = (!empty($p['language'])) ? $p['language'] : $this->fuel->language->detect();
     // }
     if ($p['cache'] === TRUE) {
         // cache id and group
         $cache_id = md5(json_encode($params));
         $cache_group = $this->CI->fuel->config('page_cache_group');
         $cache = $this->CI->fuel->cache->get($cache_id, $cache_group);
         if (!empty($cache)) {
             return $cache;
         }
     }
     if (empty($p['items'])) {
         // get the menu data based on the FUEL mode or if the file parameter is specified use that
         if ($this->CI->fuel->navigation->mode() == 'views' or !empty($params['file'])) {
             if (file_exists(APPPATH . 'views/_variables/' . $p['file'] . '.php')) {
                 include APPPATH . 'views/_variables/' . $p['file'] . '.php';
             } else {
                 ${$p}['var'] = array();
             }
         } else {
             if ($this->CI->fuel->navigation->mode() != 'cms') {
                 // load in navigation file as a starting poing
                 if (file_exists(APPPATH . 'views/_variables/' . $p['file'] . '.php')) {
                     $p['root_value'] = NULL;
                     include APPPATH . 'views/_variables/' . $p['file'] . '.php';
                 }
             }
             // now load the models
             $this->fuel->load_model('fuel_navigation');
             // grab all menu items by group
             $menu_items = $this->model()->find_all_by_group($p['group_id'], $p['language'], 'nav_key');
             // if you want to simply augment the navigation, you can grab the defaults and merge in the menu items
             if (!empty($params['include_default_language'])) {
                 // get the default language value for the query
                 $default_lang = $this->fuel->language->default_option();
                 // grab all menu items by group
                 $group = !empty($params['language_default_group']) ? $params['language_default_group'] : $p['group_id'];
                 $default_menu_items = $this->model()->find_all_by_group($group, $default_lang, 'nav_key');
                 // loop through and add defaults if there is no matching nav_key
                 foreach ($default_menu_items as $key => $item) {
                     if (!isset($menu_items[$item['nav_key']])) {
                         $menu_items[$key] = $default_menu_items[$item['nav_key']];
                     }
                 }
             }
             // if menu items isn't empty, then we overwrite the variable with those menu items and change any parent value'
             if (!empty($menu_items)) {
                 ${$p}['var'] = $menu_items;
                 // if parent exists, then assume it is a uri location and you need to convert it to a database id value
                 if (!empty($p['parent']) and is_string($p['parent'])) {
                     $parent = $this->model()->find_by_nav_key($p['parent'], $p['group_id'], $p['language']);
                     if (!empty($parent['id'])) {
                         $p['parent'] = $parent['id'];
                     }
                 }
                 // if active exists, then assume it is a uri location and you need to convert it to a database id value
                 if (!empty($p['active']) and is_string($p['active'])) {
                     $active = $this->model()->find_by_nav_key($p['active'], $p['group_id'], $p['language']);
                     if (!empty($active['id'])) {
                         $p['active'] = $active['id'];
                     }
                 }
                 $p['root_value'] = 0;
             }
         }
     } else {
         ${$p}['var'] = $p['items'];
     }
     if (!empty($params['root'])) {
         $p['root_value'] = $params['root'];
     }
     $this->CI->menu->reset();
     $this->CI->menu->initialize($p);
     $items = !empty(${$p}['var']) ? ${$p}['var'] : array();
     // append additional values
     if (!empty($p['append'])) {
         $items = array_merge($items, $p['append']);
     }
     // exclude any items
     if (!empty($p['exclude'])) {
         foreach ($items as $key => $item) {
             if (is_int($key)) {
                 $check = !empty($item['nav_key']) ? $item['nav_key'] : $item['location'];
             } else {
                 $check = $key;
             }
             if (is_string($p['exclude'])) {
                 $p['exclude'] = str_replace(':any', '.+', str_replace(':num', '[0-9]+', $p['exclude']));
                 if (preg_match('#' . $p['exclude'] . '#', $check)) {
                     unset($items[$key]);
                 }
             } else {
                 if (is_array($p['exclude'])) {
                     if (in_array($check, $p['exclude'])) {
                         unset($items[$key]);
                     }
                 }
             }
         }
     }
     if ($p['return_normalized'] !== FALSE) {
         $return = $this->CI->menu->normalize_items($items);
     } else {
         $return = $this->CI->menu->render($items, $p['active'], $p['parent']);
     }
     if ($p['cache'] === TRUE) {
         $this->CI->fuel->cache->save($cache_id, $return, $cache_group, $this->CI->fuel->config('page_cache_ttl'));
     }
     return $return;
 }
Пример #27
0
/**
 * Determines if the page is the homepage or not
 *
 * @access	public
 * @return	boolean
 */
function is_home()
{
    $uri_path = uri_path(FALSE);
    return $uri_path == 'home' or $uri_path == '';
}
Пример #28
0
 /**
  * Returns a boolean value whether it is the home page
  *
  * @access	public
  * @return	boolean
  */
 function is_home()
 {
     if (uri_path(FALSE) == trim($this->config('uri'), '/')) {
         return TRUE;
     }
     return FALSE;
 }