本文整理汇总了PHP中Tienda::getInstance方法的典型用法代码示例。如果您正苦于以下问题:PHP Tienda::getInstance方法的具体用法?PHP Tienda::getInstance怎么用?PHP Tienda::getInstance使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Tienda
的用法示例。
在下文中一共展示了Tienda::getInstance方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _setModelState
/**
* Sets the model's state
*
* @return array()
*/
function _setModelState()
{
$state = parent::_setModelState();
$app = JFactory::getApplication();
$model = $this->getModel($this->get('suffix'));
$ns = $this->getNamespace();
$state['order'] = $app->getUserStateFromRequest($ns . '.filter_order', 'filter_order', 'tbl.created_datetime', 'cmd');
$state['direction'] = $app->getUserStateFromRequest($ns . '.filter_direction', 'filter_direction', 'DESC', 'word');
$state['filter_orderid'] = $app->getUserStateFromRequest($ns . 'filter_orderid', 'filter_orderid', '', '');
$state['filter_type'] = $app->getUserStateFromRequest($ns . 'filter_type', 'filter_type', '', '');
$state['filter_transactionid'] = $app->getUserStateFromRequest($ns . 'filter_transactionid', 'filter_transactionid', '', '');
$state['filter_user'] = $app->getUserStateFromRequest($ns . 'filter_user', 'filter_user', '', '');
$state['filter_userid'] = $app->getUserStateFromRequest($ns . 'filter_userid', 'filter_userid', '', '');
$state['filter_id_from'] = $app->getUserStateFromRequest($ns . 'id_from', 'filter_id_from', '', '');
$state['filter_id_to'] = $app->getUserStateFromRequest($ns . 'id_to', 'filter_id_to', '', '');
$state['filter_date_from'] = $app->getUserStateFromRequest($ns . 'date_from', 'filter_date_from', '', '');
$state['filter_date_to'] = $app->getUserStateFromRequest($ns . 'date_to', 'filter_date_to', '', '');
$state['filter_datetype'] = 'created';
$state['filter_total_from'] = $app->getUserStateFromRequest($ns . 'filter_total_from', 'filter_total_from', '', '');
$state['filter_total_to'] = $app->getUserStateFromRequest($ns . 'filter_total_to', 'filter_total_to', '', '');
$state['filter_enabled'] = $app->getUserStateFromRequest($ns . 'filter_enabled', 'filter_enabled', '', '');
$state['filter_lifetime'] = $app->getUserStateFromRequest($ns . 'filter_lifetime', 'filter_lifetime', '', '');
if (Tienda::getInstance()->get('display_subnum', 0)) {
$state['filter_subnum'] = $app->getUserStateFromRequest($ns . 'filter_subnum', 'filter_subnum', '', '');
}
foreach (@$state as $key => $value) {
$model->setState($key, $value);
}
return $state;
}
示例2: _getUser
/**
* Gets an existing user or creates a new one
*
* @param array $submitted_values Data for a new user
* @param int $user_id Existing user id (optional)
* @return JUser object
* @access protected
*/
function _getUser($submitted_values, $user_id = 0)
{
$config = Tienda::getInstance();
if ($user_id) {
$user = JFactory::getUser($user_id);
} else {
$user = JFactory::getUser();
}
if ($user->id) {
return $user;
}
Tienda::load('TiendaHelperUser', 'helpers.user');
$newuser_email = $submitted_values['email'];
// create user from email
jimport('joomla.user.helper');
$details['name'] = $newuser_email;
$details['username'] = $newuser_email;
$details['email'] = $newuser_email;
$details['password'] = JUserHelper::genRandomPassword();
$details['password2'] = $details['password'];
$details['block'] = $config->get('block_automatically_registered') ? '1' : '0';
if ($user = TiendaHelperUser::createNewUser($details)) {
if (!$config->get('block_automatically_registered')) {
// login the new user
$login = TiendaHelperUser::login($details, '1');
}
// indicate that user was registed by AS automatically
$user->set('automatically_registered', true);
}
return $user;
}
示例3: renderForm
/**
* Renders the DirectPayment form
*
* @param object $row
* @param array $prepop Array of values to fill in the form fields
* @param boolean $display_note
* @param boolean $display_typeinfo
* @return string
* @access public
*/
function renderForm($row, $prepop = array(), $display_note = '1', $display_typeinfo = '1')
{
$user = JFactory::getUser();
$secure_post = $this->_params->get('secure_post', '0');
$config = Tienda::getInstance();
/*
* get all necessary data and prepare vars for assigning to the template
*/
$vars = new JObject();
$vars->action_url = JRoute::_("index.php?option=com_tienda&controller=checkout&task=confirmPayment&orderpayment_type={$this->_plugin_type}&paction=process_direct_payment", false, $secure_post);
$vars->prepop = $prepop;
$vars->user = $user;
$vars->cctype_input = $this->_getCardTypesInput('cardtype', !empty($prepop['cardtype']) ? $prepop['cardtype'] : '');
$vars->country_input = $this->_getCountriesInput('country', !empty($prepop['country']) ? $prepop['country'] : '');
$vars->row = $row;
$vars->token_input = JHTML::_('form.token');
$vars->display_note = $display_note;
$vars->display_typeinfo = $display_typeinfo;
$vars->display_value = $config->get('display_value', '1');
$vars->display_period = $config->get('display_period', '1');
$vars->currency_preval = $config->get('currency_preval', '$');
$vars->currency_postval = $config->get('currency_postval', ' USD');
$html = $this->_getLayout('directpayment_form', $vars);
return $html;
}
示例4: _buildQueryFields
protected function _buildQueryFields(&$query)
{
$field = array();
$field[] = " p.product_name ";
$field[] = " p.product_sku ";
$field[] = " p.product_model ";
$field[] = " p.product_full_image ";
$field[] = " p.product_ships ";
$field[] = " p.product_weight ";
$field[] = " p.product_length ";
$field[] = " p.product_width ";
$field[] = " p.product_height ";
$field[] = " p.product_recurs ";
$field[] = " p.product_enabled ";
$field[] = " p.product_notforsale ";
$field[] = " p.product_rating ";
$field[] = " p.product_comments ";
$field[] = " m.manufacturer_name AS manufacturer_name ";
// This subquery returns the default price for the product and allows for sorting by price
$date = JFactory::getDate()->toMysql();
$default_group = Tienda::getInstance()->get('default_user_group', '1');
$filter_group = (int) $this->getState('filter_group');
if (empty($filter_group)) {
$filter_group = $default_group;
}
$field[] = "\n\t\t\t(\n\t\t\tSELECT\n\t\t\t\tprices.product_price\n\t\t\tFROM\n\t\t\t\t#__tienda_productprices AS prices\n\t\t\tWHERE\n\t\t\t\tprices.product_id = tbl.product_id\n\t\t\t\tAND prices.group_id = '{$filter_group}'\n\t\t\t\tAND prices.product_price_startdate <= '{$date}'\n\t\t\t\tAND (prices.product_price_enddate >= '{$date}' OR prices.product_price_enddate = '0000-00-00 00:00:00' )\n\t\t\t\tORDER BY prices.price_quantity_start ASC\n\t\t\tLIMIT 1\n\t\t\t)\n\t\tAS product_price ";
$query->select($this->getState('select', 'tbl.*'));
$query->select($field);
}
示例5: __construct
public function __construct($config = array())
{
parent::__construct($config);
$this->defines = Tienda::getInstance();
if (JDEBUG) {
$this->cache_enabled = false;
}
}
示例6: __construct
function __construct($config = array())
{
parent::__construct($config);
$this->defines = Tienda::getInstance();
Tienda::load("TiendaHelperRoute", 'helpers.route');
$this->router = new TiendaHelperRoute();
$this->user = JFactory::getUser();
}
示例7: setStatesCSV
/**
* Set the CSV of states to be reported on
* @param $csv
* @return unknown_type
*/
function setStatesCSV($csv = '')
{
if (empty($csv)) {
$csv = Tienda::getInstance()->get('orderstates_csv', '2, 3, 5, 17');
}
$array = explode(',', $csv);
$this->_statesCSV = "'" . implode("','", $array) . "'";
}
示例8: _default
/**
*
* @return void
**/
function _default($tpl = null)
{
Tienda::load('TiendaSelect', 'library.select');
Tienda::load('TiendaGrid', 'library.grid');
Tienda::load('TiendaTools', 'library.tools');
// check config
$row = Tienda::getInstance();
$this->assign('row', $row);
// add toolbar buttons
JToolBarHelper::apply('save');
JToolBarHelper::cancel('close', 'COM_TIENDA_CLOSE');
// plugins
$filtered = array();
$items = TiendaTools::getPlugins();
for ($i = 0; $i < count($items); $i++) {
$item =& $items[$i];
// Check if they have an event
if ($hasEvent = TiendaTools::hasEvent($item, 'onListConfigTienda')) {
// add item to filtered array
$filtered[] = $item;
}
}
$items = $filtered;
$this->assign('items_sliders', $items);
// Add pane
jimport('joomla.html.pane');
$sliders = JPane::getInstance('sliders');
$this->assign('sliders', $sliders);
// form
$validate = JUtility::getToken();
$form = array();
$view = strtolower(JRequest::getVar('view'));
$form['action'] = "index.php?option=com_tienda&controller={$view}&view={$view}";
$form['validate'] = "<input type='hidden' name='{$validate}' value='1' />";
$this->assign('form', $form);
// set the required image
// TODO Fix this to use defines
$required = new stdClass();
$required->text = JText::_('COM_TIENDA_REQUIRED');
$required->image = "<img src='" . JURI::root() . "/media/com_tienda/images/required_16.png' alt='{$required->text}'>";
$this->assign('required', $required);
// Elements
$elementArticleModel = JModel::getInstance('ElementArticle', 'TiendaModel');
$this->assign('elementArticleModel', $elementArticleModel);
// terms
$elementArticle_terms = $elementArticleModel->fetchElement('article_terms', @$row->get('article_terms'));
$resetArticle_terms = $elementArticleModel->clearElement('article_terms', '0');
$this->assign('elementArticle_terms', $elementArticle_terms);
$this->assign('resetArticle_terms', $resetArticle_terms);
// shipping
$elementArticle_shipping = $elementArticleModel->fetchElement('article_shipping', @$row->get('article_shipping'));
$resetArticle_shipping = $elementArticleModel->clearElement('article_shipping', '0');
$this->assign('elementArticle_shipping', $elementArticle_shipping);
$this->assign('resetArticle_shipping', $resetArticle_shipping);
}
示例9: save
/**
* save a record
* @return void
*/
function save()
{
$error = false;
$errorMsg = "";
$model = $this->getModel($this->get('suffix'));
$config = Tienda::getInstance();
$properties = $config->getProperties();
foreach (@$properties as $key => $value) {
unset($row);
$row = $model->getTable('config');
$newvalue = JRequest::getVar($key, '', 'post', 'string', JREQUEST_ALLOWRAW | JREQUEST_NOTRIM);
$value_exists = array_key_exists($key, $_POST);
if ($value_exists && !empty($key)) {
// proceed if newvalue present in request. prevents overwriting for non-existent values.
$row->load(array('config_name' => $key));
$row->config_name = $key;
$row->value = $newvalue;
if (!$row->save()) {
$error = true;
$errorMsg .= JText::_('COM_TIENDA_COULD_NOT_STORE') . " {$key} :: " . $row->getError() . " - ";
}
}
}
$model->clearCache();
if (!$error) {
$this->messagetype = 'message';
$this->message = JText::_('COM_TIENDA_SAVED');
$dispatcher = JDispatcher::getInstance();
$dispatcher->trigger('onAfterSave' . $this->get('suffix'), array($row));
} else {
$this->messagetype = 'notice';
$this->message = JText::_('COM_TIENDA_SAVE_FAILED') . " - " . $errorMsg;
}
$redirect = "index.php?option=com_tienda&view=" . $this->get('suffix');
$group = JRequest::getVar('group');
switch ($group) {
default:
if ($group) {
$redirect .= "&task=" . $group;
}
break;
}
$format = JRequest::getVar('format');
if ($format == 'raw') {
$response = array();
$response['error'] = $error;
$response['msg'] = $this->message;
echo json_encode($response);
return;
}
$redirect = JRoute::_($redirect, false);
$this->setRedirect($redirect, $this->message, $this->messagetype);
}
示例10: getAddressElementsData
/**
* Gets data about which address fields should be visible and validable on a form
*
* @params $address_type Address type
*
* @return 2-dimensional associative array with data
*/
public static function getAddressElementsData($address_type)
{
$config = Tienda::getInstance();
$address_fields = array('address_name', 'title', 'name', 'middle', 'last', 'address1', 'address2', 'country', 'city', 'zip', 'zone', 'phone', 'company', 'tax_number');
$elements = array();
for ($i = 0, $c = count($address_fields); $i < $c; $i++) {
$f = $address_fields[$i];
$show = $config->get('show_field_' . $f, '3');
$valid = $config->get('validate_field_' . $f, '3');
$elements[$f] = array($show == '3' || $show == $address_type, $valid == '3' || $valid == $address_type);
}
return $elements;
}
示例11: _isInstalled
/**
* Checks the extension is installed
*
* @return boolean
*/
function _isInstalled()
{
$success = false;
jimport('joomla.filesystem.file');
if (JFile::exists(JPATH_ADMINISTRATOR . '/components/com_tienda/defines.php')) {
$success = true;
if (!class_exists('Tienda')) {
JLoader::register("Tienda", JPATH_ADMINISTRATOR . "/components/com_tienda/defines.php");
}
$this->defines = Tienda::getInstance();
Tienda::load('TiendaHelperProduct', 'helpers.product');
}
return $success;
}
示例12: __construct
/**
* Sets the modules params as a property of the object
* @param unknown_type $params
* @return unknown_type
*/
function __construct($params)
{
$this->params = $params;
if (!class_exists('Tienda')) {
JLoader::register("Tienda", JPATH_ADMINISTRATOR . "/components/com_tienda/defines.php");
}
// load the config class
Tienda::load('Tienda', 'defines');
JTable::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_tienda/tables');
JModel::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_tienda/models');
$this->defines = Tienda::getInstance();
Tienda::load("TiendaHelperRoute", 'helpers.route');
$this->router = new TiendaHelperRoute();
$this->user = JFactory::getUser();
}
示例13: canRun
/**
* Checks params and lastchecked to see if function should run again today
*
* @return unknown_type
*/
function canRun()
{
$success = false;
// Use config to store & retrieve lastchecked from the __config table
$config = Tienda::getInstance();
$lastchecked = $config->get('subscriptions_last_checked');
$date = JFactory::getDate();
$today = $date->toFormat("%Y-%m-%d 00:00:00");
if ($lastchecked < $today) {
if (JFactory::getApplication()->isAdmin() && !empty(JFactory::getUser()->id)) {
JError::raiseNotice('plgSystemTienda_Subscriptions::canRun', sprintf(JText::_('COM_TIENDA_TIENDA_MSG_SENDING_SUBSCRIPTION_EMAIL_NOTICES'), $lastchecked, $today));
}
$success = true;
}
return $success;
}
示例14: checkLimit
/**
* Method to check if we can still add a product to compare
* @return boolean
*/
public function checkLimit()
{
$canAdd = true;
$model = JModel::getInstance('ProductCompare', 'TiendaModel');
$user = JFactory::getUser();
$model->setState('filter_user', $user->id);
if (empty($user->id)) {
$session = JFactory::getSession();
$model->setState('filter_session', $session->getId());
}
$total = $model->getTotal();
$limit = Tienda::getInstance()->get('compared_products', '5');
if ($total >= $limit) {
$canAdd = false;
}
return $canAdd;
}
示例15: check
/**
* Checks the entry to maintain DB integrity
* @return unknown_type
*/
function check()
{
$config = Tienda::getInstance();
if (!$this->addresstype_id) {
$this->addresstype_id = '1';
}
$address_type = $this->addresstype_id;
if (empty($this->user_id)) {
$this->user_id = JFactory::getUser()->id;
if (empty($this->user_id)) {
$this->setError(JText::_('COM_TIENDA_USER_REQUIRED'));
}
}
Tienda::load('TiendaHelperAddresses', 'helpers.addresses');
$elements = TiendaHelperAddresses::getAddressElementsData($address_type);
if (empty($this->address_name)) {
$this->address_name = $this->address_1;
}
if (empty($this->address_name) && $elements['address_name'][1]) {
$this->setError(JText::_("COM_TIENDA_PLEASE_INCLUDE_AN_ADDRESS_TITLE" . $address_type));
}
$address_checks = array(array('first_name', 'name', "COM_TIENDA_FIRST_NAME_REQUIRED"), array('middle_name', 'middle', "COM_TIENDA_MIDDLE_NAME_REQUIRED"), array('last_name', 'last', "COM_TIENDA_LAST_NAME_REQUIRED"), array('address_1', 'address1', "COM_TIENDA_AT_LEAST_ONE_ADDRESS_LINE_IS_REQUIRED"), array('address_2', 'address2', "COM_TIENDA_SECOND_ADDRESS_LINE_IS_REQUIRED"), array('company', 'company', "COM_TIENDA_COMPANY_REQUIRED"), array('tax_number', 'tax_number', "COM_TIENDA_COMPANY_TAX_NUMBER_REQUIRED"), array('city', 'city', "COM_TIENDA_CITY_REQUIRED"), array('postal_code', 'zip', "COM_TIENDA_POSTAL_CODE_REQUIRED"), array('phone_1', 'phone', "COM_TIENDA_PHONE_REQUIRED"));
for ($i = 0, $c = count($address_checks); $i < $c; $i++) {
$current = $address_checks[$i];
if (empty($this->{$current}[0]) && $elements[$current[1]][1]) {
$this->setError(JText::_($current[2]));
}
}
if (empty($this->country_id)) {
if ($elements['country'][1]) {
$this->setError(JText::_('COM_TIENDA_COUNTRY_REQUIRED'));
} else {
$this->country_id = 9999;
}
}
$countryA = explode(',', trim($config->get('ignored_countries', '83,188,190')));
if (empty($this->zone_id) && !in_array($this->country_id, $countryA)) {
if ($elements['zone'][1]) {
$this->setError(JText::_('COM_TIENDA_ZONE_REQUIRED'));
} else {
$this->zone_id = 9999;
}
}
return parent::check();
}