/** * Base URL * * Create a local URL based on your basepath. * Segments can be passed in as a string or an array, same as site_url * or a URL to a file can be passed in, e.g. to an image file. * * @param string $uri * @param string $protocol * @return string */ function base_url($uri = '', $protocol = NULL) { static $_base_url; /** * Check if function executed */ $key = $uri . '-' . $protocol; if (isset($_base_url[$key])) { return $_base_url[$key]; } $_base_url[$key] = fa_instance()->config->base_url($uri, $protocol); return $_base_url[$key]; }
function counter($what) { static $_counter; if (isset($_counter[$what])) { return $_counter[$what]; } $fa = fa_instance(); /** * Load account model */ $fa->load->model($what); $model = $fa->model->{$what}; $_counter[$what] = $model->count(); return $_counter[$what]; }
/** * FA_Models constructor. */ public function __construct() { /** * Log info */ log_message(MSG_INFO, 'Models Class Initialized'); /** * Get FA instance */ $this->_fa_instance =& fa_instance(); /** * Init database */ $database_params = empty($this->_settings['database_params']) ? '' : $this->_settings['database_params']; if (!empty($this->_settings['database'])) { $this->load->database($database_params, FALSE, TRUE); } }
/** * Get user data * If $uid is int, return data of this uid with current column $col * If $uid is string, return current data of current user_id (logged) with column $col * * @param int|string $uid * @param null|string $col * @return array|null */ function user($uid, $col = NULL) { static $_user; $key = $uid . '-' . $col; if (isset($_user[$key])) { return $_user[$key]; } /** * Get fa instance */ $fa = fa_instance(); /** * @var \FA\MODELS\M_FANSWERS\account $acc_model */ $acc_model = $fa->model->account; $col_first = false; if (preg_match('/^[0-9]+$/', $uid)) { $user_id = $uid; } else { $user_id = user_id(); $col_first = true; $col = $uid; } if (!$user_id) { $out = NULL; } else { if ($col_first) { $user_data = $acc_model->user_data($user_id, $col); if (count($user_data) == 1) { $out = isset($user_data[$col]) ? $user_data[$col] : NULL; } else { $out = $user_data; } } else { $user_data = $acc_model->user_data($user_id, $col); $out = $user_data; } } $_user[$key] = $out; return $out; }
/** * paging constructor. */ function __construct() { $this->_page = 0; $this->_limit = 0; $this->_max_page = 0; $this->_total = 0; $this->_current_page = 1; /** * Get FA instance */ $fa = fa_instance(); /** * Load paging language file */ $fa->lang->load('paging_lib', NULL, TRUE); $this->_map = array('start' => '<ul class="pagination pagination-sm">', 'end' => '</ul>', 'item' => '<li><a href="{url}" title="{txt_page} {page}">{content}</a></li>', 'item_current' => '<li class="active"><a href="{url}" title="{txt_page} {page}">{content}</a></li>', 'txt_page' => $fa->lang->lng('Page'), 'next_fast' => '<i class="fa fa-angle-double-right"></i>', 'prev_fast' => '<i class="fa fa-angle-double-left"></i>', 'next_class' => 'next', 'prev_class' => 'previous', 'last_class' => 'last'); /** * ************************************** * Hook "paging_map" * ************************************** */ $this->_map = $fa->hook->filter(FA, 'paging_map', $this->_map); }
/** * Fetch an item from the COOKIE array * * @param mixed $name Index for item to be fetched from $_COOKIE * @param bool $xss_clean Whether to apply XSS filtering * @return mixed */ public function get($name, $xss_clean = NULL) { $fa = fa_instance(); return $fa->input->cookie($name, $xss_clean); }
$site_title = $fa->config->item('site_title'); $title = $fa->load->data('title'); if ($title) { $view_title = $title . ' | ' . $site_title; } else { $view_title = $site_title; } $fa->load->data('view_title', $view_title); }); $HOOK->add_action(FA, 'pre_action', function () { $IS_LOGGED = FALSE; $USER_ID = NULL; /** * Get fa instance */ $fa = fa_instance(); /** * Get session library */ $fa->load->library('session'); /** * Get cookie library */ $fa->load->library('cookie'); /** * Get session object * @var \FA\LIBRARIES\session $session */ $session = $fa->lib->session; /** * Get cookie object
/** * Load the language file * * @param string $file * @param string|null $using * @param bool $from_system */ public function load($file, $using = NULL, $from_system = false) { if ($using) { $code = $using; } else { $code = $this->_code; } if (!$code) { show_error('You do not select the display language'); } if (is_array($file)) { foreach ($file as $item) { $this->load($item, $using, $from_system); } } else { if ($from_system) { $location = SYS_PATH . 'languages/' . $code . '/'; } else { /** * Get FA instance */ $FA = fa_instance(); $location = APP_PATH . 'modules/' . $FA->module . '/config/languages/' . $code . '/'; } $file_name = $file . '.lng.php'; $file_path = $location . $file_name; /** * Just load once */ if (!isset($this->_loaded[$file_path])) { if (!file_exists($file_path)) { show_error('Unable to load the language file: languages/' . $code . '/' . $file_name); } else { /** * Load language file */ include $file_path; /** * Log file loaded */ $this->_loaded[$file_path] = true; log_message(MSG_INFO, 'Language file loaded: languages/' . $code . '/' . $file_name); if (isset($lng)) { $this->languages = array_merge($this->languages, $lng); } } } } }
/** * Database Loader * * @param mixed $params Database configuration options * @param bool $return Whether to return the database object * @param bool $query_builder Whether to enable Query Builder * (overrides the configuration setting) * * @return object|bool Database object if $return is set to TRUE, * FALSE on failure, FA_Loader instance in any other case */ public function database($params = '', $return = FALSE, $query_builder = NULL) { /** * Grab the super object */ $FA =& fa_instance(); /** * Do we even need to load the database class? */ if ($return === FALSE && $query_builder === NULL && isset($FA->db) && is_object($FA->db) && !empty($FA->db->conn_id)) { return FALSE; } /** * Load Database class */ $databaseObj =& load_class('Database', 'core'); $FA->db =& $databaseObj->loader($params, $query_builder); if ($return === TRUE) { return $FA->db; } return $this; }