本文整理匯總了PHP中Shop::initialize方法的典型用法代碼示例。如果您正苦於以下問題:PHP Shop::initialize方法的具體用法?PHP Shop::initialize怎麽用?PHP Shop::initialize使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Shop
的用法示例。
在下文中一共展示了Shop::initialize方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: renderForm
public function renderForm()
{
$update_htaccess = Tools::modRewriteActive() && (file_exists('.htaccess') && is_writable('.htaccess') || is_writable(dirname('.htaccess')));
$this->multiple_fieldsets = true;
if (!$update_htaccess) {
$desc_virtual_uri = array('<span class="warning_mod_rewrite">' . $this->l('You need to activate URL Rewriting if you want to add a virtual URL.') . '</span>');
} else {
$desc_virtual_uri = array($this->l('You can use this option if you want to create a store with a URL that doesn\'t exist on your server (e.g. if you want your store to be available with the URL www.my-prestashop.com/my-store/shoes/, you have to set shoes/ in this field, assuming that my-store/ is your Physical URL).'), '<strong>' . $this->l('URL rewriting must be activated on your server to use this feature.') . '</strong>');
}
$this->fields_form = array(array('form' => array('legend' => array('title' => $this->l('URL options'), 'icon' => 'icon-cogs'), 'input' => array(array('type' => 'select', 'label' => $this->l('Shop'), 'name' => 'id_shop', 'onchange' => 'checkMainUrlInfo(this.value);', 'options' => array('optiongroup' => array('query' => Shop::getTree(), 'label' => 'name'), 'options' => array('query' => 'shops', 'id' => 'id_shop', 'name' => 'name'))), array('type' => 'switch', 'label' => $this->l('Main URL'), 'name' => 'main', 'class' => 't', 'values' => array(array('id' => 'main_on', 'value' => 1), array('id' => 'main_off', 'value' => 0)), 'desc' => array($this->l('If you set this URL as the Main URL for the selected shop, all URLs set to this shop will be redirected to this URL (you can only have one Main URL per shop).'), array('text' => $this->l('Since the selected shop has no main URL, you have to set this URL as the Main URL.'), 'id' => 'mainUrlInfo'), array('text' => $this->l('The selected shop already has a Main URL. Therefore, if you set this one as the Main URL, the older of the two will be set as the normal URL.'), 'id' => 'mainUrlInfoExplain'))), array('type' => 'switch', 'label' => $this->l('Enabled'), 'name' => 'active', 'required' => false, 'class' => 't', 'values' => array(array('id' => 'active_on', 'value' => 1), array('id' => 'active_off', 'value' => 0)))), 'submit' => array('title' => $this->l('Save')))), array('form' => array('legend' => array('title' => $this->l('Shop URL'), 'icon' => 'icon-shopping-cart'), 'input' => array(array('type' => 'text', 'label' => $this->l('Domain'), 'name' => 'domain', 'size' => 50), array('type' => 'text', 'label' => $this->l('Domain SSL'), 'name' => 'domain_ssl', 'size' => 50)), 'submit' => array('title' => $this->l('Save')))));
if (!defined('_PS_HOST_MODE_')) {
$this->fields_form[1]['form']['input'] = array_merge($this->fields_form[1]['form']['input'], array(array('type' => 'text', 'label' => $this->l('Physical URL'), 'name' => 'physical_uri', 'desc' => $this->l('This is the physical folder for your store on the server. Leave this field empty if your store is installed on the root path (e.g. if your store is available at www.my-prestashop.com/my-store/, you input my-store/ in this field).'), 'size' => 50)));
}
$this->fields_form[1]['form']['input'] = array_merge($this->fields_form[1]['form']['input'], array(array('type' => 'text', 'label' => $this->l('Virtual URL'), 'name' => 'virtual_uri', 'desc' => $desc_virtual_uri, 'size' => 50, 'hint' => !$update_htaccess ? $this->l('Warning: URL rewriting (e.g. mod_rewrite for Apache) seems to be disabled. If your URL doesn\'t work, please check with your host provider on how to activate URL rewriting.') : null), array('type' => 'text', 'label' => $this->l('Your final URL will be'), 'name' => 'final_url', 'size' => 76, 'readonly' => true)));
if (!($obj = $this->loadObject(true))) {
return;
}
self::$currentIndex = self::$currentIndex . '&id_shop=' . $obj->id;
$current_shop = Shop::initialize();
$list_shop_with_url = array();
foreach (Shop::getShops(false, null, true) as $id) {
$list_shop_with_url[$id] = (bool) count(ShopUrl::getShopUrls($id));
}
$this->tpl_form_vars = array('js_shop_url' => Tools::jsonEncode($list_shop_with_url));
$this->fields_value = array('domain' => Validate::isLoadedObject($obj) ? $this->getFieldValue($obj, 'domain') : $current_shop->domain, 'domain_ssl' => Validate::isLoadedObject($obj) ? $this->getFieldValue($obj, 'domain_ssl') : $current_shop->domain_ssl, 'physical_uri' => Validate::isLoadedObject($obj) ? $this->getFieldValue($obj, 'physical_uri') : $current_shop->physical_uri, 'active' => true);
return parent::renderForm();
}
示例2: getSingleMapData
private function getSingleMapData($params)
{
$cart = Cart::getCartByOrderId((int) $params['id_order']);
if (Validate::isLoadedObject($cart)) {
$products = $cart->getProducts();
if (count($products) == 0 && method_exists('Shop', 'getContextShopID') && Shop::getContextShopID() != (int) $cart->id_shop) {
Shop::initialize();
$products = $cart->getProducts(true);
}
$currency = Currency::getCurrencyInstance((int) $cart->id_currency);
if (!is_null($products) && is_array($products) && Validate::isLoadedObject($currency)) {
$data = array();
$data['order_date'] = $params['date_add'];
$data['email'] = $params['email'];
$data['customer_name'] = $params['firstname'] . ' ' . $params['lastname'];
$data['order_id'] = (int) $params['id_order'];
$data['currency_iso'] = $currency->iso_code;
$products_arr = array();
foreach ($products as $product) {
$product_data = array();
$product_data['url'] = $this->getProductLink($product['id_product'], $product['link_rewrite']);
$product_data['name'] = $product['name'];
$product_data['image'] = $this->getProductImageUrl((int) $product['id_product']);
$product_data['description'] = $this->getDescritpion($product, (int) $params['id_lang']);
$product_data['price'] = $product['price'];
$products_arr[(int) $product['id_product']] = $product_data;
}
$data['products'] = $products_arr;
return $data;
}
}
return null;
}
示例3: Theme
} else {
$_SERVER['REQUEST_URI'] = $_SERVER['SCRIPT_NAME'];
if (isset($_SERVER['QUERY_STRING']) && !empty($_SERVER['QUERY_STRING'])) {
$_SERVER['REQUEST_URI'] .= '?' . $_SERVER['QUERY_STRING'];
}
}
}
}
/* Trying to redefine HTTP_HOST if empty (on some webservers...) */
if (!isset($_SERVER['HTTP_HOST']) || empty($_SERVER['HTTP_HOST'])) {
$_SERVER['HTTP_HOST'] = @getenv('HTTP_HOST');
}
$context = Context::getContext();
/* Initialize the current Shop */
try {
$context->shop = Shop::initialize();
$context->theme = new Theme((int) $context->shop->id_theme);
if ((Tools::isEmpty($theme_name = $context->shop->getTheme()) || !Validate::isLoadedObject($context->theme)) && !defined('_PS_ADMIN_DIR_')) {
throw new PrestaShopException(Tools::displayError('Current theme unselected. Please check your theme configuration.'));
}
} catch (PrestaShopException $e) {
$e->displayMessage();
}
define('_THEME_NAME_', $theme_name);
define('__PS_BASE_URI__', $context->shop->getBaseURI());
/* Include all defines related to base uri and theme name */
require_once dirname(__FILE__) . '/defines_uri.inc.php';
global $_MODULES;
$_MODULES = array();
define('_PS_PRICE_DISPLAY_PRECISION_', Configuration::get('PS_PRICE_DISPLAY_PRECISION'));
define('_PS_PRICE_COMPUTE_PRECISION_', _PS_PRICE_DISPLAY_PRECISION_);
示例4: str_replace
//echo $Version;
$Version = str_replace('.', '', $Version);
//echo $Version;
//if (_PS_VERSION_ == '1.4.0.6') { version 1406
$left_part_of_version = substr($Version, 0, 2);
if ($left_part_of_version >= 14) {
/* Autoload V14 pas ok sur V12*/
require dirname(__FILE__) . '/autoload.php';
} else {
/* Autoload V12 et pas OK sur 14 */
function __autoload($className)
{
if (!class_exists($className, false)) {
require_once dirname(__FILE__) . '/../classes/' . $className . '.php';
}
}
}
/* Redefine REQUEST_URI if empty (on some webservers...) */
if (!isset($_SERVER['REQUEST_URI']) or empty($_SERVER['REQUEST_URI'])) {
$_SERVER['REQUEST_URI'] = $_SERVER['SCRIPT_NAME'];
if (isset($_SERVER['QUERY_STRING']) and !empty($_SERVER['QUERY_STRING'])) {
$_SERVER['REQUEST_URI'] .= '?' . $_SERVER['QUERY_STRING'];
}
}
/* Initialize the current Shop */
//V1.7
if ($left_part_of_version >= 15) {
Context::getContext()->shop = Shop::initialize();
}
/* Load all configuration keys */
Configuration::loadConfiguration();