本文整理汇总了PHP中registry类的典型用法代码示例。如果您正苦于以下问题:PHP registry类的具体用法?PHP registry怎么用?PHP registry使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了registry类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* Construct
*
* @param registry $registry
* @param int $currency_id Current currency_id id
*/
public function __construct($registry, $currency_id)
{
$this->_db = $registry->get('db');
try {
$statement = $this->_db->prepare('SELECT * FROM `currency`');
$statement->execute();
} catch (PDOException $e) {
if ($this->db->inTransaction()) {
$this->db->rollBack();
}
trigger_error($e->getMessage());
}
if ($statement->rowCount()) {
foreach ($statement->fetchAll() as $currency) {
$this->_currencies[$currency->currency_id] = array('currency_id' => $currency->currency_id, 'code' => $currency->code, 'rate' => $currency->rate, 'symbol' => $currency->symbol, 'name' => $currency->name);
if ($currency->currency_id == $currency_id) {
$this->_currency_id = $currency->currency_id;
$this->_currency_code = $currency->code;
$this->_currency_rate = $currency->rate;
$this->_currency_name = $currency->name;
$this->_currency_symbol = $currency->symbol;
}
}
}
}
示例2: __construct
public function __construct()
{
parent::__construct();
$this->registry = registry::getInstance();
$this->html = html::getInstance();
$this->plugin = plugin::getInstance();
}
示例3: execute
/**
* executes all controllers and compile the final HTML Document.
*
* @return string finalHTML
*/
public function execute()
{
if (HANDHELD) {
header('Pragma: public');
header("Expires: " . gmdate("Y-m-d\\TH:i:s\\Z", time() + 60 * 30));
header('Cache-Control: no-store, must-revalidate, post-check=0, pre-check=0, no-transform, max-age=1800');
}
foreach ($this->mountPoints as $column => $controllers) {
${$column} = "";
foreach ($controllers as $c) {
${$column} .= $c->execute();
}
}
$pageTitle = $this->title;
$pageDescription = $this->description;
$bodyClass = $this->bodyClass;
foreach (registry::getInstance() as $k => $v) {
${$k} = $v;
}
isset($contentType) ? http_response::content($contentType) : http_response::content(CONTENT_TYPE);
ob_start();
require $this->file;
// output is gzipped and minified (NO; PROBLEMS WITH CODE BLOCKS!).
// ob_postprocess(trim(preg_replace('/\s+/', ' ', ob_get_clean())));
echo ob_get_clean();
}
示例4: add
public function add()
{
if (isset($_POST['save_user_btn'])) {
$row = [];
if ($_GET['id']) {
$row['id'] = $_GET['id'];
} else {
$row['create_date'] = date('Y-m-d H:i:s');
}
$row['email'] = $_POST['email'];
$row['user_name'] = $_POST['user_name'];
$row['user_surname'] = $_POST['user_surname'];
$row['user_group_id'] = $_POST['user_group_id'];
if ($_POST['user_password']) {
$row['user_password'] = md5($_POST['user_password']);
}
$this->model('backend_users')->insert($row);
if ($_POST['user_password']) {
$this->logOut();
$this->auth(registry::get('user')['email'], md5($_POST['user_password']));
registry::remove('user');
$this->checkAuth();
}
header('Location: ' . SITE_DIR . 'users/');
exit;
}
$this->render('user_groups', $this->model('user_groups')->getAll());
if ($_GET['id']) {
$this->render('user', $this->model('backend_users')->getById($_GET['id']));
}
$this->view('users' . DS . 'add');
}
示例5: output
public function output()
{
include_once $this->root_path . 'portal/twitter/twittermodule.class.php';
$rss_feeds = registry::register('twittermodule');
$this->header = $this->user->lang('twitter');
return $rss_feeds->output_left;
}
示例6: __construct
public function __construct()
{
$registry = registry::getInstance();
$path = empty($_SERVER['REQUEST_URI']) || $_SERVER['REQUEST_URI'] == "/" ? $registry->config['default_controller'] : ltrim(strtolower($_SERVER['REQUEST_URI']), "/");
if (strstr($path, "/")) {
$arr = explode('/', $path);
$page = $arr[0];
$action = empty($arr[1]) ? 'index' : $arr[1];
} else {
$page = $path;
$action = "index";
}
$file = 'application/controllers/controller.' . $page . '.php';
if (file_exists($file)) {
$class = strtolower($page);
if (class_exists($class)) {
$controller = new $class();
if (!is_callable(array($controller, $action))) {
$this->handle404();
} else {
$controller->{$action}();
}
} else {
$this->handle404();
}
} else {
$this->handle404();
}
}
示例7: __construct
/**
* Session Constructor
*
* The constructor runs the session routines automatically
* whenever the class is instantiated.
*/
public function __construct()
{
// Set the super object to a local variable for use throughout the class
$this->registry =& registry::instance();
// Do we need use cookie? If so, load the input library
$this->registry->load->library('input');
// Do we need encryption? If so, load the encryption library
if ($this->session_encrypt_cookie == true) {
$this->registry->load->library('encrypt');
}
// Set the "now" time. Can either be GMT or server time, based on the
// config prefs. We use this to set the "last activity" time
$this->now = $this->_get_time();
// Set the session length. If the session expiration is
// set to zero we'll set the expiration two years from now.
if ($this->session_expiration == 0) {
$this->session_expiration = 60 * 60 * 24 * 365 * 2;
}
// Set the cookie name
$this->session_cookie_name = $this->cookie_prefix . $this->session_cookie_name;
// Run the Session routine. If a session doesn't exist we'll
// create a new one. If it does, we'll update it.
if (!$this->session_read()) {
$this->session_create();
} else {
$this->session_update();
}
}
示例8: __construct
/**
* Constructor
* Initialize all informations for installing/uninstalling plugin
*/
public function __construct()
{
parent::__construct();
$this->add_data(array('name' => 'Awards', 'code' => 'awards', 'path' => 'awards', 'contact' => 'support@assasinen.5cz.de', 'template_path' => 'plugins/awards/templates/', 'icon' => 'fa fa-list-alt', 'version' => $this->version, 'author' => $this->copyright, 'description' => $this->user->lang('awards_short_desc'), 'long_description' => $this->user->lang('awards_long_desc'), 'homepage' => 'https://eqdkp-plus.eu/', 'manuallink' => 'https://eqdkp-plus.eu/wiki/Plugin:_Awards', 'plus_version' => '2.0', 'build' => $this->build));
$this->add_dependency(array('plus_version' => '2.0'));
// -- Register our permissions ------------------------
// permissions: 'a'=admins, 'u'=user
// ('a'/'u', Permission-Name, Enable? 'Y'/'N', Language string, array of user-group-ids that should have this permission)
// Groups: 1 = Guests, 2 = Super-Admin, 3 = Admin, 4 = Member
$this->add_permission('u', 'view', 'Y', $this->user->lang('view'), array(2, 3, 4));
$this->add_permission('a', 'add', 'N', $this->user->lang('add'), array(2, 3));
$this->add_permission('a', 'manage', 'N', $this->user->lang('manage'), array(2, 3));
// -- PDH Modules -------------------------------------
$this->add_pdh_read_module('awards_achievements');
$this->add_pdh_read_module('awards_assignments');
$this->add_pdh_read_module('awards_library');
$this->add_pdh_write_module('awards_achievements');
$this->add_pdh_write_module('awards_assignments');
// -- Classes -----------------------------------------
registry::add_class('awards_plugin', 'plugins/awards/classes/', 'awards');
// -- Routing -----------------------------------------
$this->routing->addRoute('Awards', 'awards', 'plugins/awards/pageobjects');
// -- Hooks -------------------------------------------
$this->add_hook('portal', 'awards_portal_hook', 'portal');
$this->add_hook('userprofile_customtabs', 'awards_userprofile_customtabs_hook', 'userprofile_customtabs');
// -- Menu --------------------------------------------
$this->add_menu('admin', $this->gen_admin_menu());
$this->add_menu('main', $this->gen_main_menu());
$this->add_menu('settings', $this->usersettings());
}
示例9: __construct
/**
* @author Damien Lasserre <dlasserre@talen.com>
* @param $_config_file
*/
public function __construct($_config_file)
{
/** @var string $log_path */
$log_path = APPLICATION_PATH . '/tmp/application.log';
if (file_exists($_config_file)) {
/** @var array $_attributes */
$_attributes = parse_ini_file($_config_file, true);
/** @var definition\config[] $_config */
$_config = new \stdClass();
foreach ($_attributes as $_env => $_parameters) {
if ($_env == APPLICATION_ENV) {
foreach ($_parameters as $_parameter => $value) {
/** @var definition\config _parameter */
$_config->{$_parameter} = new definition\config();
$_config->{$_parameter}->_setName($_parameter)->_setValue($value)->_activate();
}
}
}
if (isset($_config->log_path) and $_config->log_path->isActivated()) {
$log_path = $_config->log_path;
}
if (is_file($log_path)) {
defined('APPLICATION_PATH_LOG') || define('APPLICATION_PATH_LOG', $log_path);
}
$this->_configuration = $_config;
/** Set in registry */
registry::getInstance()->add('config', $this);
}
}
示例10: __construct
public function __construct($controller, $action)
{
if (isset($_POST['log_out_btn'])) {
$this->logOut();
header('Location: ' . SITE_DIR);
exit;
}
if (isset($_POST['login_btn'])) {
if ($this->auth($_POST['email'], md5($_POST['password']), $_POST['remember'])) {
header('Location: ' . SITE_DIR);
} else {
$this->render('error', true);
}
}
registry::set('log', array());
$this->controller_name = $controller;
$this->check_auth = $this->checkAuth();
if ($this->check_auth) {
// $this->sidebar();
}
$this->action_name = $action . ($this->check_auth ? '_na' : '');
$config = [];
foreach ($this->model('asanatt_system_config')->getAll() as $v) {
$config[$v['config_key']] = $v['config_value'];
}
registry::set('config', $config);
}
示例11: output
public function output()
{
$strModule = $this->config('module');
if (!strlen($strModule)) {
$strModule = "ts3";
}
$arrSettingsArray = $this->get_settings('fetch_new');
$arrOptions = array();
foreach ($arrSettingsArray as $key => $value) {
$arrOptions[$key] = $this->config($key);
}
$out = "";
if ($strModule == "ts3") {
include_once $this->root_path . 'portal/voice/modules/teamspeak3/teamspeak3_voice.class.php';
$ts3 = registry::register('teamspeak3_voice', array($arrOptions));
$out = $ts3->output();
} elseif ($strModule == "ventrilo") {
include_once $this->root_path . 'portal/voice/modules/ventrilo/ventrilo_voice.class.php';
$ventrilo = new ventrilo_voice($arrOptions);
$out = $ventrilo->output();
} elseif ($strModule == "mumble") {
include_once $this->root_path . 'portal/voice/modules/mumble/mumble_voice.class.php';
$mumble = registry::register('mumble_voice', array($arrOptions));
$out = $mumble->output();
}
$this->header = $this->user->lang($strModule);
return $out;
}
示例12: unites_ajax
public function unites_ajax()
{
switch ($_REQUEST['action']) {
case "save_taste":
$taste = $_POST['taste'];
$taste['id'] = $this->model('tastes')->insert($taste);
$taste['status'] = 1;
echo json_encode($taste);
exit;
break;
case "save_unit":
$rows = [];
$date = date('Y-m-d H:i:s');
for ($i = 0; $i < $_POST['quantity']; $i++) {
$rows[$i] = $_POST['unit'];
$rows[$i]['create_date'] = $date;
$rows[$i]['creator'] = registry::get('user')['id'];
}
$this->model('stock_units')->insertRows($rows);
echo json_encode(array('status' => 1));
exit;
break;
case "get_unites":
$params = [];
$params['table'] = 'stock_units u';
$params['join']['tastes'] = array('as' => 't', 'on' => 't.id = u.taste_id', 'left' => true);
$params['join']['products'] = array('as' => 'p', 'on' => 'p.id = u.product_id');
$params['select'] = array('p.product_name', 'IF(t.taste_name, t.taste_name, " - ")', 'IF(t.expiration_date, t.expiration_date, " - ")');
exit;
break;
}
}
示例13: __construct
function __construct()
{
parent::__construct();
$this->registry = registry::getInstance();
$this->addAction('index_init', 'init');
$this->addAction('index_load', 'addToolbar');
}
示例14: __construct
public function __construct($cache_type = false)
{
$this->global_prefix = $this->config->get('prefix', 'pdc') ? $this->config->get('prefix', 'pdc') : $this->table_prefix;
$this->cache_folder = $this->pfh->FolderPath('data', 'cache');
if ($this->config->get('dttl', 'pdc')) {
$this->default_ttl = $this->config->get('dttl', 'pdc');
}
//make sure the folder is protected by a .htaccess file
$this->pfh->secure_folder('data', 'cache');
//read expiry date tab
$result = @file_get_contents($this->cache_folder . 'expiry_dates.php');
if ($result !== false) {
$this->expiry_dates = unserialize($result);
} else {
$this->save_expiry_dates();
}
//create our cache object
if (!$cache_type) {
$cache_type = $this->config->get('mode', 'pdc') ? 'cache_' . $this->config->get('mode', 'pdc') : 'cache_none';
}
require_once $this->root_path . 'core/cache/cache.iface.php';
require_once $this->root_path . 'core/cache/' . $cache_type . '.class.php';
$this->cache = registry::register($cache_type);
//pdl fun
if (!$this->pdl->type_known("pdc_query")) {
$this->pdl->register_type("pdc_query", null, array($this, 'pdl_html_format_pdc_query'), array(2, 3, 4));
}
}
示例15: display
public function display()
{
$strTag = utf8_strtolower($this->patharray[0]);
if (!strlen($strTag)) {
redirect($this->controller_path_plain . $this->SID);
}
$arrArticleIDs = $this->pdh->get('articles', 'articles_for_tag', array($strTag));
$arrArticleIDs = $this->pdh->sort($arrArticleIDs, 'articles', 'date', 'desc');
$intStart = $this->in->get('start', 0);
$arrLimitedIDs = $this->pdh->limit($arrArticleIDs, $intStart, $this->user->data['user_nlimit']);
//Articles to template
foreach ($arrLimitedIDs as $intArticleID) {
$userlink = '<a href="' . $this->routing->build('user', $this->pdh->geth('articles', 'user_id', array($intArticleID)), 'u' . $this->pdh->get('articles', 'user_id', array($intArticleID))) . '">' . $this->pdh->geth('articles', 'user_id', array($intArticleID)) . '</a>';
//Content dependet from list_type
//1 = until readmore
//2 = Headlines only
//3 = only first 600 characters
$strText = $this->pdh->get('articles', 'text', array($intArticleID));
$arrContent = preg_split('#<hr(.*)id="system-readmore"(.*)\\/>#iU', xhtml_entity_decode($strText));
$strText = $this->bbcode->parse_shorttags($arrContent[0]);
$strPath = $this->pdh->get('articles', 'path', array($intArticleID));
$intCategoryID = $this->pdh->get('articles', 'category', array($intArticleID));
//Replace Image Gallery
$arrGalleryObjects = array();
preg_match_all('#<p(.*)class="system-gallery"(.*) data-sort="(.*)" data-folder="(.*)">(.*)</p>#iU', $strText, $arrGalleryObjects, PREG_PATTERN_ORDER);
if (count($arrGalleryObjects[0])) {
include_once $this->root_path . 'core/gallery.class.php';
foreach ($arrGalleryObjects[4] as $key => $val) {
$objGallery = registry::register('gallery');
$strGalleryContent = $objGallery->create($val, (int) $arrGalleryObjects[3][$key], $this->server_path . $strPath, 1);
$strText = str_replace($arrGalleryObjects[0][$key], $strGalleryContent, $strText);
}
}
//Replace Raidloot
$arrRaidlootObjects = array();
preg_match_all('#<p(.*)class="system-raidloot"(.*) data-id="(.*)"(.*) data-chars="(.*)">(.*)</p>#iU', $strText, $arrRaidlootObjects, PREG_PATTERN_ORDER);
if (count($arrRaidlootObjects[0])) {
include_once $this->root_path . 'core/gallery.class.php';
foreach ($arrRaidlootObjects[3] as $key => $val) {
$objGallery = registry::register('gallery');
$withChars = $arrRaidlootObjects[5][$key] == "true" ? true : false;
$strRaidlootContent = $objGallery->raidloot((int) $val, $withChars);
$strText = str_replace($arrRaidlootObjects[0][$key], $strRaidlootContent, $strText);
}
}
$this->comments->SetVars(array('attach_id' => $intArticleID, 'page' => 'articles'));
$intCommentsCount = $this->comments->Count();
//Tags
$arrTags = $this->pdh->get('articles', 'tags', array($intArticleID));
$this->tpl->assign_block_vars('article_row', array('ARTICLE_CONTENT' => $strText, 'ARTICLE_TITLE' => $this->pdh->get('articles', 'title', array($intArticleID)), 'ARTICLE_SUBMITTED' => sprintf($this->user->lang('news_submitter'), $userlink, $this->time->user_date($this->pdh->get('articles', 'date', array($intArticleID)), false, true)), 'ARTICLE_DATE' => $this->time->user_date($this->pdh->get('articles', 'date', array($intArticleID)), false, false, true), 'ARTICLE_PATH' => $this->controller_path . $this->pdh->get('articles', 'path', array($intArticleID)), 'ARTICLE_SOCIAL_BUTTONS' => $arrCategory['social_share_buttons'] ? $this->social->createSocialButtons($this->env->link . $this->pdh->get('articles', 'path', array($intArticleID)), strip_tags($this->pdh->get('articles', 'title', array($intArticleID)))) : '', 'PERMALINK' => $this->pdh->get('articles', 'permalink', array($intArticleID)), 'S_TAGS' => count($arrTags) && $arrTags[0] != "" ? true : false, 'ARTICLE_CUTTED_CONTENT' => truncate($strText, 600, '...', false, true), 'S_READMORE' => isset($arrContent[1]) ? true : false, 'COMMENTS_COUNTER' => $intCommentsCount == 1 ? $intCommentsCount . ' ' . $this->user->lang('comment') : $intCommentsCount . ' ' . $this->user->lang('comments'), 'S_COMMENTS' => $this->pdh->get('articles', 'comments', array($intArticleID)) ? true : false, 'S_FEATURED' => $this->pdh->get('articles', 'featured', array($intArticleID))));
if (count($arrTags) && $arrTags[0] != "") {
foreach ($arrTags as $tag) {
$this->tpl->assign_block_vars('article_row.tag_row', array('TAG' => $tag, 'U_TAG' => $this->routing->build('tag', $tag)));
}
}
}
$this->tpl->assign_vars(array('TAG' => sanitize($strTag), 'PAGINATION' => generate_pagination($this->strPath . $this->SID, count($arrArticleIDs), $this->user->data['user_nlimit'], $intStart, 'start')));
$this->tpl->add_meta('<link rel="canonical" href="' . $this->env->link . $this->routing->build('tag', $tag, false, false, true) . '" />');
$this->core->set_vars(array('page_title' => $this->user->lang("tag") . ': ' . sanitize($strTag), 'template_file' => 'tag.html', 'display' => true));
}