本文整理汇总了PHP中Registry::get方法的典型用法代码示例。如果您正苦于以下问题:PHP Registry::get方法的具体用法?PHP Registry::get怎么用?PHP Registry::get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Registry
的用法示例。
在下文中一共展示了Registry::get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* Tax constructor.
* @param Registry $registry
*/
public function __construct($registry)
{
$this->config = $registry->get('config');
$this->customer = $registry->get('customer');
$this->db = $registry->get('db');
$this->session = $registry->get('session');
// If shipping address is being used
if (isset($this->session->data['shipping_address_id'])) {
$address_query = $this->db->query("SELECT * FROM address WHERE address_id = '" . (int) $this->session->data['shipping_address_id'] . "'");
$this->setShippingAddress($address_query->row['country_id'], $address_query->row['zone_id']);
} elseif (isset($this->session->data['guest']['shipping'])) {
$this->setShippingAddress($this->session->data['guest']['shipping']['country_id'], $this->session->data['guest']['shipping']['zone_id']);
} elseif ($this->customer->isLogged() && $this->config->get('config_tax_customer') == 'shipping') {
$address_query = $this->db->query("SELECT * FROM address WHERE address_id = '" . (int) $this->customer->getAddressId() . "'");
$this->setShippingAddress($address_query->row['country_id'], $address_query->row['zone_id']);
} elseif ($this->config->get('config_tax_default') == 'shipping') {
$this->setShippingAddress($this->config->get('config_country_id'), $this->config->get('config_zone_id'));
}
if (isset($this->session->data['payment_address_id'])) {
$address_query = $this->db->query("SELECT * FROM address WHERE address_id = '" . (int) $this->session->data['payment_address_id'] . "'");
$this->setPaymentAddress($address_query->row['country_id'], $address_query->row['zone_id']);
} elseif (isset($this->session->data['guest']['payment'])) {
$this->setPaymentAddress($this->session->data['guest']['payment']['country_id'], $this->session->data['guest']['payment']['zone_id']);
} elseif ($this->customer->isLogged() && $this->config->get('config_tax_customer') == 'payment') {
$address_query = $this->db->query("SELECT * FROM address WHERE address_id = '" . (int) $this->customer->getAddressId() . "'");
$this->setPaymentAddress($address_query->row['country_id'], $address_query->row['zone_id']);
} elseif ($this->config->get('config_tax_default') == 'payment') {
$this->setPaymentAddress($this->config->get('config_country_id'), $this->config->get('config_zone_id'));
}
$this->setStoreAddress($this->config->get('config_country_id'), $this->config->get('config_zone_id'));
}
示例2: __construct
/**
* User constructor.
* @param Registry $registry
*/
public function __construct($registry)
{
$this->db = $registry->get('db');
$this->request = $registry->get('request');
$this->session = $registry->get('session');
if (isset($this->session->data['user_id'])) {
$user_query = $this->db->query("SELECT * FROM user WHERE user_id = '" . (int) $this->session->data['user_id'] . "' AND status = '1'");
if ($user_query->num_rows) {
$this->user_id = $user_query->row['user_id'];
$this->username = $user_query->row['username'];
/* [webme] deny order deletions by specified user_group - begin */
$this->usergroup_id = $user_query->row['user_group_id'];
/* [webme] deny order deletions by specified user_group - end */
$this->db->query("\r\n\t\t\t\t\tUPDATE user \r\n\t\t\t\t\tSET ip = :ip\r\n\t\t\t\t\tWHERE user_id = :userId\r\n\t\t\t\t\t", [':ip' => $this->request->server['REMOTE_ADDR'], ':userId' => $this->session->data['user_id']], false, true);
$user_group_query = $this->db->query("SELECT permission FROM user_group WHERE user_group_id = '" . (int) $user_query->row['user_group_id'] . "'");
$permissions = unserialize($user_group_query->row['permission']);
if (is_array($permissions)) {
foreach ($permissions as $key => $value) {
$this->permission[$key] = $value;
}
}
} else {
$this->logout();
}
}
}
示例3: __construct
/**
* Customer constructor.
*
* @param Registry $registry
*/
public function __construct($registry)
{
$this->config = $registry->get('config');
$this->db = $registry->get('db');
$this->request = $registry->get('request');
$this->session = $registry->get('session');
if (isset($this->session->data['customer_id'])) {
$customer_query = $this->db->query("SELECT * FROM " . DB_PREFIX . "customer WHERE customer_id = '" . (int) $this->session->data['customer_id'] . "' AND STATUS = '1'");
if ($customer_query->num_rows) {
$this->customer_id = $customer_query->row['customer_id'];
$this->firstname = $customer_query->row['firstname'];
$this->lastname = $customer_query->row['lastname'];
$this->email = $customer_query->row['email'];
$this->telephone = $customer_query->row['telephone'];
$this->fax = $customer_query->row['fax'];
$this->newsletter = $customer_query->row['newsletter'];
$this->customer_group_id = $customer_query->row['customer_group_id'];
$this->address_id = $customer_query->row['address_id'];
$this->db->query("UPDATE " . DB_PREFIX . "customer SET cart = '" . $this->db->escape(isset($this->session->data['cart']) ? serialize($this->session->data['cart']) : '') . "', wishlist = '" . $this->db->escape(isset($this->session->data['wishlist']) ? serialize($this->session->data['wishlist']) : '') . "', ip = '" . $this->db->escape($this->request->server['REMOTE_ADDR']) . "' WHERE customer_id = '" . (int) $this->customer_id . "'");
$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "customer_ip WHERE customer_id = '" . (int) $this->session->data['customer_id'] . "' AND ip = '" . $this->db->escape($this->request->server['REMOTE_ADDR']) . "'");
if (!$query->num_rows) {
$this->db->query("INSERT INTO " . DB_PREFIX . "customer_ip SET customer_id = '" . (int) $this->session->data['customer_id'] . "', ip = '" . $this->db->escape($this->request->server['REMOTE_ADDR']) . "', date_added = NOW()");
}
} else {
$this->logout();
}
}
}
示例4: __construct
/**
* Length constructor.
*
* @param Registry $registry
*/
public function __construct($registry)
{
$this->db = $registry->get('db');
$this->config = $registry->get('config');
$length_class_query = $this->db->query("SELECT * FROM " . DB_PREFIX . "length_class mc LEFT JOIN " . DB_PREFIX . "length_class_description mcd ON (mc.length_class_id = mcd.length_class_id) WHERE mcd.language_id = '" . (int) $this->config->get('config_language_id') . "'");
foreach ($length_class_query->rows as $result) {
$this->lengths[$result['length_class_id']] = array('length_class_id' => $result['length_class_id'], 'title' => $result['title'], 'unit' => $result['unit'], 'value' => $result['value']);
}
}
示例5: __construct
/**
* Weight constructor.
*
* @param Registry $registry
*/
public function __construct($registry)
{
$this->db = $registry->get('db');
$this->config = $registry->get('config');
$weight_class_query = $this->db->query("SELECT * FROM " . DB_PREFIX . "weight_class wc LEFT JOIN " . DB_PREFIX . "weight_class_description wcd ON (wc.weight_class_id = wcd.weight_class_id) WHERE wcd.language_id = '" . (int) $this->config->get('config_language_id') . "'");
foreach ($weight_class_query->rows as $result) {
$this->weights[$result['weight_class_id']] = array('weight_class_id' => $result['weight_class_id'], 'title' => $result['title'], 'unit' => $result['unit'], 'value' => $result['value']);
}
}
示例6: __construct
public function __construct(Registry $registry)
{
$this->db = $registry->get('db');
$this->request = $registry->get('request');
$this->session = $registry->get('session');
// If user has id
if ($this->session->getUserId()) {
// Find Customer in Database
try {
$statement = $this->db->prepare('
SELECT
`u`.`user_id`,
`u`.`file_quota`,
`u`.`status`,
`u`.`verified`,
`u`.`username`,
`u`.`date_added`,
`u`.`email`,
(SELECT `ue`.`approved` FROM `user_email` AS `ue` WHERE `ue`.`email` = `u`.`email` LIMIT 1) AS `approved`
FROM `user` AS `u`
WHERE `u`.`user_id` = ?
AND `u`.`status` = 1
LIMIT 1');
$statement->execute(array($this->session->getUserId()));
} catch (PDOException $e) {
if ($this->db->inTransaction()) {
$this->db->rollBack();
}
trigger_error($e->getMessage());
}
if ($statement->rowCount()) {
$user = $statement->fetch();
$this->_user_id = $user->user_id;
$this->_file_quota = $user->file_quota;
$this->_approved = $user->approved;
$this->_username = $user->username;
$this->_email = $user->email;
$this->_status = $user->status;
$this->_verified = $user->verified;
$this->_date_added = $user->date_added;
// Update IP Log
$this->_saveIP($this->session->getUserId(), $this->request->getRemoteAddress());
} else {
$this->logout();
}
}
}
示例7: __construct
/**
* Length constructor.
* @param Registry $registry
*/
public function __construct($registry)
{
$db = $registry->get('db');
$config = $registry->get('config');
/** @var Cache $cache */
$cache = $registry->get('cache');
$this->lengths = $cache->get('lengths.' . $config->get('config_language_id'));
if (is_null($this->lengths)) {
$length_class_query = $db->query("\r\n\t\t\tSELECT * \r\n\t\t\tFROM \r\n\t\t\t\tlength_class AS lc \r\n\t\t\t\tLEFT JOIN length_class_description AS lcd ON (lc.length_class_id = lcd.length_class_id) \r\n\t\t\t\tWHERE lcd.language_id = :languageId\r\n\t\t\t", [":languageId" => $config->get('config_language_id')]);
foreach ($length_class_query->rows as $result) {
$this->lengths[$result['length_class_id']] = array('length_class_id' => $result['length_class_id'], 'title' => $result['title'], 'unit' => $result['unit'], 'value' => $result['value']);
}
$cache->set('lengths.' . $config->get('config_language_id'), $this->lengths);
}
}
示例8: __construct
/**
* Weight constructor.
* @param Registry $registry
*/
public function __construct($registry)
{
$db = $registry->get('db');
$config = $registry->get('config');
/** @var Cache $cache */
$cache = $registry->get('cache');
$this->weights = $cache->get('weights.' . $config->get('config_language_id'));
if (is_null($this->weights)) {
$weight_class_query = $db->query("\r\n\t\t\tSELECT * \r\n\t\t\tFROM \r\n\t\t\t\tweight_class AS wc \r\n\t\t\t\tLEFT JOIN weight_class_description AS wcd ON (wc.weight_class_id = wcd.weight_class_id) \r\n\t\t\tWHERE wcd.language_id = :languageId\r\n\t\t\t", [':languageId' => $config->get('config_language_id')]);
foreach ($weight_class_query->rows as $result) {
$this->weights[$result['weight_class_id']] = array('weight_class_id' => $result['weight_class_id'], 'title' => $result['title'], 'unit' => $result['unit'], 'value' => $result['value']);
}
$cache->set('weights.' . $config->get('config_language_id'), $this->weights);
}
}
示例9: query
/**
* @param string $sql
* @param bool $noexcept
* @return bool|stdClass
* @throws AException
*/
public function query($sql, $noexcept = false)
{
//echo $this->database_name;
$time_start = microtime(true);
$sql = $this->_sql_prepare($sql);
$resource = pg_query($this->connection, $sql);
$this->result = $resource;
$time_exec = microtime(true) - $time_start;
// to avoid debug class init while setting was not yet loaded
if ($this->registry->get('config')) {
if ($this->registry->get('config')->has('config_debug')) {
$backtrace = debug_backtrace();
ADebug::set_query($sql, $time_exec, $backtrace[2]);
}
}
if ($resource) {
if (is_resource($resource)) {
//get last id for inserts
if (is_int(strpos($sql, 'INSERT INTO'))) {
$insert_query = pg_query("SELECT lastval();");
$insert_row = pg_fetch_row($insert_query);
$this->last_id = $insert_row[0];
}
$i = 0;
$data = array();
while ($result = pg_fetch_assoc($resource)) {
$data[$i] = $result;
$i++;
}
pg_free_result($resource);
$query = new stdClass();
$query->row = isset($data[0]) ? $data[0] : array();
$query->rows = $data;
$query->num_rows = $i;
unset($data);
return $query;
} else {
return TRUE;
}
} else {
if ($noexcept) {
$this->error = 'AbanteCart Error: ' . pg_result_error($resource) . '<br />' . $sql;
return FALSE;
} else {
throw new AException(AC_ERR_MYSQL, 'Error: ' . pg_result_error($resource) . '<br />' . $sql);
}
}
}
示例10: query
public function query($sql, $noexcept = false, $params = array())
{
if (!$noexcept) {
$this->connection->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$this->connection->setAttribute(PDO::ATTR_EMULATE_PREPARES, false);
}
$this->statement = $this->connection->prepare($sql);
$result = false;
$time_start = microtime(true);
try {
if ($this->statement && $this->statement->execute($params)) {
$data = array();
if ($this->statement->columnCount()) {
while ($row = $this->statement->fetch(PDO::FETCH_ASSOC)) {
$data[] = $row;
}
$result = new stdClass();
$result->row = isset($data[0]) ? $data[0] : array();
$result->rows = $data;
$result->num_rows = $this->statement->rowCount();
}
}
} catch (PDOException $e) {
$this->error = 'SQL Error: ' . $e->getMessage() . '<br />Error No: ' . $e->getCode() . '<br />SQL:' . $sql;
if ($noexcept) {
return false;
} else {
throw new AException(AC_ERR_MYSQL, $this->error);
}
}
$time_exec = microtime(true) - $time_start;
// to avoid debug class init while setting was not yet loaded
if ($this->registry->get('config')) {
if ($this->registry->get('config')->has('config_debug')) {
$backtrace = debug_backtrace();
ADebug::set_query($sql, $time_exec, $backtrace[2]);
}
}
if ($result) {
return $result;
} else {
$result = new stdClass();
$result->row = array();
$result->rows = array();
$result->num_rows = 0;
return $result;
}
}
示例11: process_sbrf_currencies
public static function process_sbrf_currencies($primary_currency = CART_PRIMARY_CURRENCY)
{
$date = date('d/m/Y');
$link = 'http://www.cbr.ru/scripts/XML_daily.asp?date_req=' . $date;
$xml = @simplexml_load_string(fn_get_contents($link));
$sbrf_currencies = self::format_sbrf_currensies($xml);
if (empty($sbrf_currencies) || $primary_currency != CURRENCY_RUB && !isset($sbrf_currencies[$primary_currency])) {
return false;
}
$currencies = Registry::get('currencies');
if ($primary_currency != CURRENCY_RUB) {
if (isset($sbrf_currencies[$primary_currency]) && isset($currencies[CURRENCY_RUB])) {
$primary_coefficient = $sbrf_currencies[$primary_currency]['nominal'] / $sbrf_currencies[$primary_currency]['value'];
$currency_data = array('coefficient' => $primary_coefficient);
db_query("UPDATE ?:currencies SET ?u WHERE currency_code = ?s", $currency_data, CURRENCY_RUB);
}
unset($sbrf_currencies[$primary_currency]);
foreach ($currencies as $curr_code => $curr_data) {
if (isset($sbrf_currencies[$curr_code])) {
$coefficient_rub = $sbrf_currencies[$curr_code]['nominal'] / $sbrf_currencies[$curr_code]['value'];
$currency_data = array('coefficient' => $primary_coefficient / $coefficient_rub);
db_query("UPDATE ?:currencies SET ?u WHERE currency_code = ?s ", $currency_data, $curr_code);
}
}
} else {
foreach ($currencies as $curr_code => $curr_data) {
if (isset($sbrf_currencies[$curr_code])) {
$currency_data = array('coefficient' => $sbrf_currencies[$curr_code]['value'] / $sbrf_currencies[$curr_code]['nominal']);
db_query("UPDATE ?:currencies SET ?u WHERE currency_code = ?s ", $currency_data, $curr_code);
}
}
}
return true;
}
示例12: callbackAddLinks
/**
* Add feed links to page <head> on select/all pages.
*/
function callbackAddLinks($hookName, $args)
{
if ($this->getEnabled()) {
// Only page requests will be handled
$request =& Registry::get('request');
if (!is_a($request->getRouter(), 'PKPPageRouter')) {
return false;
}
$templateManager =& $args[0];
$currentJournal =& $templateManager->get_template_vars('currentJournal');
$requestedPage = Request::getRequestedPage();
if ($currentJournal) {
$issueDao =& DAORegistry::getDAO('IssueDAO');
$currentIssue =& $issueDao->getCurrentIssue($currentJournal->getId(), true);
$displayPage = $this->getSetting($currentJournal->getId(), 'displayPage');
}
if ($currentIssue && ($displayPage == 'all' || $displayPage == 'homepage' && (empty($requestedPage) || $requestedPage == 'index' || $requestedPage == 'issue') || $displayPage == 'issue' && $displayPage == $requestedPage)) {
$additionalHeadData = $templateManager->get_template_vars('additionalHeadData');
$feedUrl1 = '<link rel="alternate" type="application/atom+xml" href="' . $currentJournal->getUrl() . '/gateway/plugin/WebFeedGatewayPlugin/atom" />';
$feedUrl2 = '<link rel="alternate" type="application/rdf+xml" href="' . $currentJournal->getUrl() . '/gateway/plugin/WebFeedGatewayPlugin/rss" />';
$feedUrl3 = '<link rel="alternate" type="application/rss+xml" href="' . $currentJournal->getUrl() . '/gateway/plugin/WebFeedGatewayPlugin/rss2" />';
$templateManager->assign('additionalHeadData', $additionalHeadData . "\n\t" . $feedUrl1 . "\n\t" . $feedUrl2 . "\n\t" . $feedUrl3);
}
}
return false;
}
示例13: __construct
public function __construct()
{
$this->db = Registry::get('db');
$this->request = Registry::get('request');
$this->session = Registry::get('session');
if (isset($this->session->data['customer_id'])) {
$customer_query = $this->db->query("SELECT * FROM " . DB_PREFIX . "customer WHERE customer_id = '" . (int) $this->session->data['customer_id'] . "' AND status = '1'");
if ($customer_query->num_rows) {
$this->customer_id = $customer_query->row['customer_id'];
$this->firstname = $customer_query->row['firstname'];
$this->lastname = $customer_query->row['lastname'];
$this->email = $customer_query->row['email'];
$this->telephone = $customer_query->row['telephone'];
$this->fax = $customer_query->row['fax'];
$this->newsletter = $customer_query->row['newsletter'];
$this->customer_group_id = $customer_query->row['customer_group_id'];
$this->address_id = $customer_query->row['address_id'];
$address_query = $this->db->query("SELECT *, c.name AS country, z.name AS zone FROM " . DB_PREFIX . "address a LEFT JOIN " . DB_PREFIX . "country c ON a.country_id = c.country_id LEFT JOIN " . DB_PREFIX . "zone z ON a.zone_id = z.zone_id WHERE a.customer_id = '" . (int) $this->session->data['customer_id'] . "'");
foreach ($address_query->rows as $result) {
$this->address[$result['address_id']] = array('firstname' => $result['firstname'], 'lastname' => $result['lastname'], 'company' => $result['company'], 'address_1' => $result['address_1'], 'address_2' => $result['address_2'], 'postcode' => $result['postcode'], 'city' => $result['city'], 'country_id' => $result['country_id'], 'zone_id' => $result['zone_id'], 'iso_code_2' => $result['iso_code_2'], 'iso_code_3' => $result['iso_code_3'], 'code' => $result['code'], 'zone' => $result['zone'], 'country' => $result['country'], 'address_format' => $result['address_format']);
}
$this->db->query("UPDATE " . DB_PREFIX . "customer SET cart = '" . $this->db->escape(serialize($this->session->data['cart'])) . "', ip = '" . $this->db->escape($this->request->server['REMOTE_ADDR']) . "' WHERE customer_id = '" . (int) $this->session->data['customer_id'] . "'");
} else {
$this->logout();
}
}
}
示例14: index
public function index()
{
$this->id = "content";
$this->template = "message/headers.tpl";
$this->layout = "common/layout-empty";
$request = Registry::get('request');
$db = Registry::get('db');
$this->load->model('search/search');
$this->load->model('search/message');
$this->document->title = $this->data['text_message'];
$this->data['id'] = @$this->request->get['id'];
$messageid = 0;
if (!verify_piler_id($this->data['id'])) {
AUDIT(ACTION_UNKNOWN, '', '', $this->data['id'], 'unknown id: ' . $this->data['id']);
die("invalid id: " . $this->data['id']);
}
$this->data['attachment'] = $this->model_search_message->get_attachment_by_id($this->data['id']);
if (!isset($this->data['attachment']['filename'])) {
die("invalid filename");
}
$messageid = $this->model_search_message->get_id_by_piler_id($this->data['attachment']['piler_id']);
AUDIT(ACTION_DOWNLOAD_ATTACHMENT, '', '', $messageid, $this->data['id']);
header("Cache-Control: public, must-revalidate");
header("Pragma: no-cache");
header("Content-Type: application/octet-stream");
header("Content-Disposition: attachment; filename=\"" . $this->data['attachment']['filename'] . "\"");
header("Content-Transfer-Encoding: binary\n");
print $this->data['attachment']['attachment'];
exit;
}
示例15: TranslatorHandler
/**
* Constructor
**/
function TranslatorHandler()
{
parent::Handler();
$this->addCheck(new HandlerValidatorRoles($this, true, null, null, array(ROLE_ID_SITE_ADMIN)));
$plugin =& Registry::get('plugin');
$this->plugin =& $plugin;
}