get() static public method

Retrieve object from catalog
static public get ( $key ) : object
$key string
return object
Example #1
0
 /**
  * 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'));
 }
Example #2
0
 /**
  * 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();
         }
     }
 }
Example #3
0
 /**
	 * Método mágico para pegar o registro de uma classe
	 * @param	type	$key	nome da classe
	 * @return	object	retorna uma instância de uma classe de acordo com a chave do registro
	 */
 public function __get($key)
 {
     if ($this->_registry == null) {
         $this->_registry = Registry::getInstance();
     }
     return $this->_registry->get($key);
 }
Example #4
0
 /**
  * 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();
         }
     }
 }
Example #5
0
 /**
  * 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']);
     }
 }
Example #6
0
 /**
  * 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']);
     }
 }
Example #7
0
    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();
            }
        }
    }
Example #8
0
 /**
  * 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);
     }
 }
Example #9
0
 /**
  * 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);
     }
 }
Example #10
0
 /**
  * @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);
         }
     }
 }
Example #11
0
 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;
     }
 }
Example #12
0
 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;
 }
Example #13
0
 /**
  * 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;
 }
Example #14
0
 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();
         }
     }
 }
Example #15
0
 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;
 }
 /**
  * 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;
 }
 /**
  * Handle a cache miss
  * @param $cache GenericCache
  * @param $id mixed ID that wasn't found in the cache
  * @return null
  */
 function _cacheMiss($cache, $id)
 {
     $allCodelistItems =& Registry::get('all' . $this->getName() . 'CodelistItems', true, null);
     if ($allCodelistItems === null) {
         // Add a locale load to the debug notes.
         $notes =& Registry::get('system.debug.notes');
         $locale = $cache->cacheId;
         if ($locale == null) {
             $locale = AppLocale::getLocale();
         }
         $filename = $this->getFilename($locale);
         $notes[] = array('debug.notes.codelistItemListLoad', array('filename' => $filename));
         // Reload locale registry file
         $xmlDao = new XMLDAO();
         $nodeName = $this->getName();
         // i.e., subject
         $data = $xmlDao->parseStruct($filename, array($nodeName));
         // Build array with ($charKey => array(stuff))
         if (isset($data[$nodeName])) {
             foreach ($data[$nodeName] as $codelistData) {
                 $allCodelistItems[$codelistData['attributes']['code']] = array($codelistData['attributes']['text']);
             }
         }
         if (is_array($allCodelistItems)) {
             asort($allCodelistItems);
         }
         $cache->setEntireCache($allCodelistItems);
     }
     return null;
 }
Example #18
0
 /**
  * add javascript to implement form behaviour based on form_edit_action parameter
  *
  * @return string
  */
 protected function addFormJs()
 {
     /**
      * @var ALanguageManager
      */
     $language = $this->registry->get('language');
     $view = new AView($this->registry, 0);
     switch ($this->form_edit_action) {
         case 'ST':
             //standards
             $view->batchAssign(array('id' => $this->form['form_name']));
             $output = $view->fetch('form/form_js_st.tpl');
             break;
         case 'HS':
             //highlight on change and show save button
             $view->batchAssign(array('id' => $this->form['form_name'], 'button_save' => $language->get('button_save'), 'button_reset' => $language->get('button_reset'), 'update' => $this->form['update'], 'text_processing' => $language->get('text_processing'), 'text_saved' => $language->get('text_saved')));
             $output = $view->fetch('form/form_js_hs.tpl');
             break;
         case 'HT':
             //highlight on change
             $view->batchAssign(array('id' => $this->form['form_name']));
             $output = $view->fetch('form/form_js_ht.tpl');
             break;
         default:
             $output = '';
     }
     return $output;
 }
Example #19
0
 public function model($model)
 {
     $class = 'Model' . preg_replace('/[^a-zA-Z0-9]/', '', $model);
     $model_cls = 'model_' . str_replace('/', '_', $model);
     if (!is_null($this->registry->get($model_cls))) {
         return;
     }
     $file = DIR_SITE . '/model/' . $model . '.php';
     if (file_exists($file)) {
         include $file;
         $this->registry->set($model_cls, new $class($this->registry));
     } else {
         trigger_error('Error: Could not load model ' . $model . '!');
         exit;
     }
 }
Example #20
0
 private function getController(&$file, &$controller, &$action, &$args)
 {
     $route = empty($_GET['route']) ? 'index/index' : $_GET['route'];
     $post = empty($_POST) ? null : $_POST;
     $route = Registry::get('maintenance') ? 'index/maintenance' : $route;
     // Получаем раздельные части
     $route = trim($route, '/\\');
     $parts = explode('/', $route);
     // Находим правильный контроллер
     $cmd_path = $this->path;
     $controller = ucfirst(array_shift($parts));
     if (!is_file($cmd_path . $controller . '.php')) {
         $controller = 'Index';
     }
     // Получаем действие
     $action = array_shift($parts);
     $action = empty($action) ? 'index' : $action;
     if (!empty($parts)) {
         foreach ($parts as $key => $val) {
             if (($key + 1) % 2) {
                 $get[$val] = empty($parts[$key + 1]) ? null : $parts[$key + 1];
             }
         }
     }
     $file = $cmd_path . $controller . '.php';
     $args['get'] = empty($get) ? [] : $get;
     $args['post'] = empty($post) ? [] : $post;
 }
function post_list()
{
    // only run on the first call
    if (!Registry::has('rwar_post_archive')) {
        // capture original article if one is set
        if ($article = Registry::get('article')) {
            Registry::set('original_article', $article);
        }
    }
    if (!($posts = Registry::get('rwar_post_archive'))) {
        $posts = Post::where('status', '=', 'published')->sort('created', 'desc')->get();
        Registry::set('rwar_post_archive', $posts = new Items($posts));
    }
    if ($result = $posts->valid()) {
        // register single post
        Registry::set('article', $posts->current());
        // move to next
        $posts->next();
    } else {
        // back to the start
        $posts->rewind();
        // reset original article
        Registry::set('article', Registry::get('original_article'));
        // remove items
        Registry::set('rwar_post_archive', false);
    }
    return $result;
}
Example #22
0
 private function __construct()
 {
     $dbConf = Registry::get('dbConf');
     $this->mysqli = new mysqli(DB_HOST, DB_USER, DB_PWD, DB_NAME);
     $this->mysqli->query("SET lc_time_names = 'ru_RU'");
     $this->mysqli->query("SET NAMES 'utf8'");
 }
Example #23
0
 public static function start()
 {
     $config = Registry::get('config');
     if (isset($config->session)) {
         // optional parameters sent to the constructor
         if (isset($config->session->params)) {
             $sessionParams = $config->session->params;
         }
         if (is_object($config->session->handler)) {
             $sessionHandler = self::factory($config->session->handler->namespace, $config->session->handler->class, $sessionParams, $config->session->lifetime);
         } else {
             $sessionHandler = self::factory('Nf\\Session', $config->session->handler, $sessionParams, $config->session->lifetime);
         }
         session_name($config->session->cookie->name);
         session_set_cookie_params(0, $config->session->cookie->path, $config->session->cookie->domain, false, true);
         session_set_save_handler(array(&$sessionHandler, 'open'), array(&$sessionHandler, 'close'), array(&$sessionHandler, 'read'), array(&$sessionHandler, 'write'), array(&$sessionHandler, 'destroy'), array(&$sessionHandler, 'gc'));
         register_shutdown_function('session_write_close');
         session_start();
         // session_regenerate_id(true);
         Registry::set('session', $sessionHandler);
         return $sessionHandler;
     } else {
         return false;
     }
 }
Example #24
0
 /**
  * Fill childs data array for tree panel
  * @param Tree $tree
  * @param mixed $root
  * @return array
  */
 protected function _fillChilds(Tree $tree, $root = 0)
 {
     $result = array();
     $childs = $tree->getChilds($root);
     if (empty($childs)) {
         return array();
     }
     $appConfig = Registry::get('main', 'config');
     foreach ($childs as $k => $v) {
         $row = $v['data'];
         $obj = new stdClass();
         $obj->id = $row['id'];
         $obj->text = $row['menu_title'] . ' <i>(' . $row['code'] . $appConfig['urlExtension'] . ')</i>';
         $obj->expanded = true;
         $obj->leaf = false;
         if ($row['published']) {
             $obj->qtip = $row['menu_title'] . ' <i>(' . $row['code'] . $appConfig['urlExtension'] . ')</i> published';
             $obj->iconCls = 'pagePublic';
         } else {
             $obj->qtip = $row['menu_title'] . ' <i>(' . $row['code'] . $appConfig['urlExtension'] . ')</i> not published';
             $obj->iconCls = 'pageHidden';
         }
         if ($row['is_fixed']) {
             $obj->allowDrag = false;
         }
         $cld = array();
         if ($tree->hasChilds($row['id'])) {
             $cld = $this->_fillChilds($tree, $row['id']);
         }
         $obj->children = $cld;
         $result[] = $obj;
     }
     return $result;
 }
 /**
  * @param array $data
  * @param array $allow_filters
  * @throws ApiException
  * @return string
  */
 public function buildCondition(array $data, $allow_filters = array())
 {
     /** @var PDO $db */
     $db = Registry::get('db');
     $conditions = [];
     //OR
     $conditions[] = " AND (";
     foreach ($data as $key => $value) {
         $andConditionsData = array();
         foreach ($value as $k => $v) {
             if (!is_array($v)) {
                 $andConditionsData[$k] = $v;
             }
         }
         $andCondition = $this->buildAndCondition($andConditionsData, $allow_filters);
         $andCondition = "({$andCondition})";
         if (count($conditions) == 1) {
             $conditions[] = $andCondition;
         } else {
             $conditions[] = "OR {$andCondition}";
         }
     }
     $conditions[] = ")";
     return implode(" ", $conditions);
 }
Example #26
0
 /**
  * add javascript to implement form behaviour based on form_edit_action parameter
  *
  * @return string
  */
 protected function addFormJs()
 {
     /**
      * @var AHtml
      */
     $html = $this->registry->get('html');
     /**
      * @var ALanguageManager
      */
     $language = $this->registry->get('language');
     $view = new AView($this->registry, 0);
     switch ($this->form_edit_action) {
         case 'ST':
             //standards
             $view->batchAssign(array('id' => $this->form['form_name']));
             $output = $view->fetch('form/form_js_st.tpl');
             break;
         case 'HS':
             //highlight on change and show save button
             $view->batchAssign(array('id' => $this->form['form_name'], 'button_save' => str_replace("\r\n", "", $html->buildButton(array('name' => 'btn_save', 'text' => $language->get('button_save'), 'style' => 'button3'))), 'button_reset' => str_replace("\r\n", "", $html->buildButton(array('name' => 'btn_reset', 'text' => $language->get('button_reset'), 'style' => 'button2'))), 'update' => $this->form['update']));
             $output = $view->fetch('form/form_js_hs.tpl');
             break;
         case 'HT':
             //highlight on change
             $view->batchAssign(array('id' => $this->form['form_name']));
             $output = $view->fetch('form/form_js_ht.tpl');
             break;
         default:
             $output = '';
     }
     return $output;
 }
Example #27
0
 function _cacheMiss($cache, $id)
 {
     $allLanguages =& Registry::get('allLanguages-' . $cache->cacheId, true, null);
     if ($allLanguages === null) {
         // Add a locale load to the debug notes.
         $notes =& Registry::get('system.debug.notes');
         $locale = $cache->cacheId;
         if ($locale == null) {
             $locale = AppLocale::getLocale();
         }
         $filename = $this->getLanguageFilename($locale);
         $notes[] = array('debug.notes.languageListLoad', array('filename' => $filename));
         // Reload locale registry file
         $xmlDao = new XMLDAO();
         $data = $xmlDao->parseStruct($filename, array('language'));
         // Build array with ($charKey => array(stuff))
         if (isset($data['language'])) {
             foreach ($data['language'] as $languageData) {
                 $allLanguages[$languageData['attributes']['code']] = array($languageData['attributes']['name']);
             }
         }
         if (is_array($allLanguages)) {
             asort($allLanguages);
         }
         $cache->setEntireCache($allLanguages);
     }
     if (isset($allLanguages[$id])) {
         return $allLanguages[$id];
     } else {
         return null;
     }
 }
 function _cacheMiss(&$cache, $id)
 {
     $allCodelistItems =& Registry::get('all' . $this->getListName() . 'CodelistItems', true, null);
     if ($allCodelistItems === null) {
         // Add a locale load to the debug notes.
         $notes =& Registry::get('system.debug.notes');
         $locale = $cache->cacheId;
         if ($locale == null) {
             $locale = AppLocale::getLocale();
         }
         $filename = $this->getFilename($locale);
         $notes[] = array('debug.notes.codelistItemListLoad', array('filename' => $filename));
         // Reload locale registry file
         $xmlDao = new XMLDAO();
         $listName = $this->getListName();
         // i.e., 'List30'
         import('lib.pkp.classes.codelist.ONIXParserDOMHandler');
         $handler = new ONIXParserDOMHandler($listName);
         import('lib.pkp.classes.xslt.XSLTransformer');
         import('lib.pkp.classes.file.FileManager');
         import('classes.file.TemporaryFileManager');
         $temporaryFileManager = new TemporaryFileManager();
         $fileManager = new FileManager();
         // Ensure that the temporary file dir exists
         $tmpDir = $temporaryFileManager->getBasePath();
         if (!file_exists($tmpDir)) {
             mkdir($tmpDir);
         }
         $tmpName = tempnam($tmpDir, 'ONX');
         $xslTransformer = new XSLTransformer();
         $xslTransformer->setParameters(array('listName' => $listName));
         $xslTransformer->setRegisterPHPFunctions(true);
         $xslFile = 'lib/pkp/xml/onixFilter.xsl';
         $filteredXml = $xslTransformer->transform($filename, XSL_TRANSFORMER_DOCTYPE_FILE, $xslFile, XSL_TRANSFORMER_DOCTYPE_FILE, XSL_TRANSFORMER_DOCTYPE_STRING);
         if (!$filteredXml) {
             assert(false);
         }
         $data = null;
         if (is_writeable($tmpName)) {
             $fp = fopen($tmpName, 'wb');
             fwrite($fp, $filteredXml);
             fclose($fp);
             $data = $xmlDao->parseWithHandler($tmpName, $handler);
             $fileManager->deleteFile($tmpName);
         } else {
             fatalError('misconfigured directory permissions on: ' . $tmpDir);
         }
         // Build array with ($charKey => array(stuff))
         if (isset($data[$listName])) {
             foreach ($data[$listName] as $code => $codelistData) {
                 $allCodelistItems[$code] = $codelistData;
             }
         }
         if (is_array($allCodelistItems)) {
             asort($allCodelistItems);
         }
         $cache->setEntireCache($allCodelistItems);
     }
     return null;
 }
Example #29
0
 /**
  * Получение настроек
  * @param  string $key Имя настройки
  * @return string Значение настройки
  */
 public static function get($key)
 {
     if (!Registry::has('setting')) {
         Registry::set('setting', App::arrayAssoc(self::all(), 'name', 'value'));
     }
     return Registry::get('setting')[$key];
 }
 protected function setUp()
 {
     // Create a test file on the file system.
     $this->testFile = tempnam(TMP_FILES, 'SubmissionFile');
     // Mock a press
     import('classes.press.Press');
     $press = new Press();
     $press->setPrimaryLocale('en_US');
     $press->setPath('press-path');
     $press->setId(SUBMISSION_FILE_DAO_TEST_PRESS_ID);
     // Mock a request
     $mockRequest = $this->getMock('PKPRequest', array('getContext'));
     $mockRequest->expects($this->any())->method('getContext')->will($this->returnValue($press));
     Registry::get('request', true, $mockRequest);
     // Register a mock monograph DAO.
     $monographDao = $this->getMock('MonographDAO', array('getById'));
     $monograph = new Monograph();
     $monograph->setId(SUBMISSION_FILE_DAO_TEST_SUBMISSION_ID);
     $monograph->setPressId(SUBMISSION_FILE_DAO_TEST_PRESS_ID);
     $monographDao->expects($this->any())->method('getById')->will($this->returnValue($monograph));
     DAORegistry::registerDAO('MonographDAO', $monographDao);
     // Register a mock genre DAO.
     $genreDao = $this->getMock('GenreDAO', array('getById'));
     DAORegistry::registerDAO('GenreDAO', $genreDao);
     $genreDao->expects($this->any())->method('getById')->will($this->returnCallback(array($this, 'getTestGenre')));
     $this->_cleanFiles();
     $application = PKPApplication::getApplication();
     $request = $application->getRequest();
     if (is_null($request->getRouter())) {
         $router = new PKPRouter();
         $request->setRouter($router);
     }
 }