function link_tag($href = '', $rel = 'stylesheet', $type = 'text/css', $title = '', $media = '', $index_page = FALSE) { $OB = base::getInstance(); $link = '<link '; if (is_array($href)) { foreach ($href as $k => $v) { if ($k == 'href' and strpos($v, '://') === FALSE) { if ($index_page === TRUE) { $link .= ' href="' . $OB->config->site_url($v) . '" '; } else { $link .= ' href="' . $OB->config->slash_item('base_url') . $v . '" '; } } else { $link .= "{$k}=\"{$v}\" "; } } $link .= "/>"; } else { if (strpos($href, '://') !== FALSE) { $link .= ' href="' . $href . '" '; } elseif ($index_page === TRUE) { $link .= ' href="' . $OB->config->site_url($href) . '" '; } else { $link .= ' href="' . $OB->config->slash_item('base_url') . $href . '" '; } $link .= 'rel="' . $rel . '" type="' . $type . '" '; if ($media != '') { $link .= 'media="' . $media . '" '; } if ($title != '') { $link .= 'title="' . $title . '" '; } $link .= '/>'; } return $link; }
function this() { return base::getInstance(); }
public function _assign_db_objects() { foreach (base::$databases as $key) { $this->{$key} =& base::getInstance()->{$key}; } }
public function _write_cache($output) { $OB = base::getInstance(); //$path = common::config_item('cache_path', 'cache'); $cache_path = APP . 'cache' . DS; //= ($path == '') ? APP.'system'.DS.'cache'.DS : $path; if (!is_dir($cache_path) or !common::is_really_writable($cache_path)) { throw new Exception('Unable to write cache file: ' . $cache_path); return; } $uri = $OB->config->item('base_url') . $OB->config->item('index_page') . $OB->uri->uri_string(); $cache_path .= md5($uri); if (!($fp = @fopen($cache_path, FOPEN_WRITE_CREATE_DESTRUCTIVE))) { throw new Exception('Unable to write cache file: ' . $cache_path); return; } $expire = time() + $this->cache_expiration * 60; if (flock($fp, LOCK_EX)) { fwrite($fp, $expire . 'TS--->' . $output); flock($fp, LOCK_UN); } else { throw new Exception('Unable to secure a file lock for file at: ' . $cache_path); return; } fclose($fp); @chmod($cache_path, DIR_WRITE_MODE); //log_message('debug', "Cache file written: ".$cache_path); }
public static function database($db_name = 'db') { $db_var = $db_name; $obj = base::getInstance(); if (isset($obj->{$db_var}) and is_object($obj->{$db_var})) { return; } require SYS . 'database' . DS . 'db_factory' . PHP_EXT; $obj->{$db_var} = db_factory::callDB($db_name); base::$databases[$db_var] = $db_var; if (count(base::$models) >= 0) { foreach (base::$models as $model_name) { $obj->{$model_name}->{$db_var} =& $obj->{$db_var}; } } }