本文整理汇总了PHP中JeproshopContext类的典型用法代码示例。如果您正苦于以下问题:PHP JeproshopContext类的具体用法?PHP JeproshopContext怎么用?PHP JeproshopContext使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了JeproshopContext类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: addShopRestriction
public static function addShopRestriction($shop = NULL, $alias = NULL)
{
$context = JeproshopContext::getContext();
if (!empty($alias)) {
$alias .= '.';
}
/** If there is no shop id, get the context one **/
if ($shop === null) {
if (JeproshopShopModelShop::getShopContext() == JeproshopShopModelShop::CONTEXT_GROUP) {
$shop_group = JeproshopShopModelShop::getContextShopGroup();
} else {
$shop_group = $context->shop->getShopGroup();
}
$shop = $context->shop;
} elseif (is_object($shop)) {
$shop_group = $shop->getShopGroup();
} else {
$shop = new JeproshopShopModelShop($shop);
$shop_group = $shop->getShopGroup();
}
/* if quantities are shared between shops of the group */
$db = JFactory::getDBO();
if ($shop_group->share_stock) {
$query = " AND " . $db->escape($alias) . "shop_group_id = " . (int) $shop_group->shop_group_id . " AND " . $db->escape($alias) . "shop_id = 0 ";
} else {
$query = " AND " . $db->escape($alias) . "shop_id = " . (int) $shop->shop_id . ' ';
}
return $query;
}
示例2: display
public function display($tpl = null)
{
if (!isset($this->context) || $this->context == null) {
$this->context = JeproshopContext::getContext();
}
if (!$this->context->controller->isInitialized()) {
$this->context->controller->initialize();
}
$app = JFactory::getApplication();
$useSSL = isset($this->context->controller->ssl_enabled) && $this->context->conteoller->ssl_enabled && $app->input->get('enable_ssl') || JeproshopTools::usingSecureMode() ? true : false;
$protocol_content = $useSSL ? 'https://' : 'http://';
/*$contextParams = $this->context->controller->getContextParams();
foreach ($contextParams as $assign_key => $assign_value){
if (!is_array($assign_value) && mb_substr($assign_value, 0, 1, 'utf-8') == '/' || $protocol_content == 'https://'){
$this->assignRef($assign_key, $protocol_content.JeproshopTools::getMediaServer($assign_value).$assign_value);
}else{
$this->assignRef($assign_key, $assign_value);
}
}*/
if (!isset(self::$cache_products)) {
$category = new JeproshopCategoryModelCategory(JeproshopContext::getContext()->shop->getCategoryId(), (int) JeproshopContext::getContext()->language->lang_id);
$nb = (int) JeproshopSettingModelSetting::getValue('number_of_products_on_page');
self::$cache_products = JeproshopDefaultModelDefault::getProducts((int) JeproshopContext::getContext()->language->lang_id, 0, $nb ? $nb : 8, 'position');
}
if (self::$cache_products === false || empty(self::$cache_products)) {
self::$cache_products = false;
}
$this->assignRef('products', self::$cache_products);
$display_add_product = JeproshopSettingModelSetting::getValue('display_category_attribute');
$this->assignRef('display_add_product', $display_add_product);
$homeSize = JeproshopImageModelImage::getSize(JeproshopImageTypeModelImageType::getFormatName('home'));
$this->assignRef('homeSize', $homeSize);
$this->assignRef('pagination', JeproshopDefaultModelDefault::$_pagination);
parent::display($tpl);
}
示例3: renderEditForm
public function renderEditForm($tpl = null)
{
$helper = new JeproshopHelper();
$this->assignRef('helper', $helper);
$tax_rules_groups = JeproshopTaxRulesGroupModelTaxRulesGroup::getTaxRulesGroups(true);
$this->assignRef('tax_rules_groups', $tax_rules_groups);
$carrier_logo = JeproshopTools::isLoadedObject($this->carrier, 'carrier_id') && file_exists(COM_JEPROSHOP_CARRIER_IMAGE_DIR . $this->carrier->carrier_id . '.jpg') ? COM_JEPROSHOP_CARRIER_IMAGE_DIR . $this->carrier->carrier_id . '.jpg' : false;
$this->assignRef('carrier_logo', $carrier_logo);
$groups = JeproshopGroupModelGroup::getGroups(JeproshopContext::getContext()->language->lang_id);
$this->assignRef('groups', $groups);
$zones = JeproshopZoneModelZone::getZones();
$this->assignRef('zones', $zones);
$carrierZones = $this->carrier->getZones();
$carrier_zones_ids = array();
if (is_array($carrierZones)) {
foreach ($carrierZones as $carrier_zone) {
$carrier_zones_ids[] = $carrier_zone->zone_id;
}
}
$this->assignRef('selected_zones', $carrier_zones_ids);
if ($this->getLayout() != 'modal') {
$this->addToolBar();
$this->sideBar = JHtmlSidebar::render();
}
parent::display($tpl);
}
示例4: getScenes
/**
* Get all scenes of a category
*
* @param $category_id
* @param null $lang_id
* @param bool $only_published
* @param bool $lite_result
* @param bool $hide_scene_position
* @param JeproshopContext $context
* @return array Products
*/
public static function getScenes($category_id, $lang_id = null, $only_published = true, $lite_result = true, $hide_scene_position = true, JeproshopContext $context = null)
{
if (!JeproshopSceneModelScene::isFeaturePublished()) {
return array();
}
$cache_key = 'jeproshop_scene_get_scenes_' . $category_id . '_' . (int) $lite_result;
if (!JeproshopCache::isStored($cache_key)) {
if (!$context) {
$context = JeproshopContext::getContext();
}
$lang_id = is_null($lang_id) ? $context->language->lang_id : $lang_id;
$db = JFactory::getDBO();
$query = "SELECT scene.* FROM " . $db->quoteName('#__jeproshop_scene_category') . " scene_category LEFT JOIN " . $db->quoteName('#__jeproshop_scene');
$query .= " AS scene ON (scene_category.scene_id = scene.scene_id) " . JeproshopShopModelShop::addSqlAssociation('scene') . " LEFT JOIN ";
$query .= $db->quoteName('#__jeproshop_scene_lang') . " AS scene_lang ON (scene_lang.scene_id = scene.scene_id) WHERE scene_category.category_id = ";
$query .= (int) $category_id . "\tAND scene_lang.lang_id = " . (int) $lang_id . ($only_published ? " AND scene.published = 1" : "") . " ORDER BY scene_lang.name ASC";
$db->setQuery($query);
$scenes = $db->loadObjectList();
if (!$lite_result && $scenes) {
foreach ($scenes as &$scene) {
$scene = new Scene($scene->scene_id, $lang_id, false, $hide_scene_position);
}
}
JeproshopCache::store($cache_key, $scenes);
}
$scenes = JeproshopCache::retrieve($cache_key);
return $scenes;
}
示例5: getWarningDomainName
protected function getWarningDomainName()
{
$warning = false;
if (JeproshopShopModelShop::isFeaturePublished()) {
return null;
}
$shop = JeproshopContext::getContext()->shop;
return $warning;
}
示例6: renderView
public function renderView($tpl = null)
{
$app = JFactory::getApplication();
$this->context = JeproshopContext::getContext();
$customerList = $this->group->getCustomersList();
$this->assignRef('customers', $customerList);
$categoryReductions = $this->formatCategoryDiscountList($this->group->group_id);
$this->assignRef('category_reductions', $categoryReductions);
$this->addToolBar();
$this->sideBar = JHtmlSidebar::render();
parent::display($tpl);
}
示例7: addFeatureValue
public function addFeatureValue($tpl = null)
{
if (!isset($this->context)) {
$this->context = JeproshopContext::getContext();
}
$helper = new JeproshopHelper();
$this->assignRef('helper', $helper);
$features = JeproshopFeatureModelFeature::getFeatures($this->context->language->lang_id);
$this->assignRef('features', $features);
$this->addToolBar();
$this->sideBar = JHtmlSideBar::render();
parent::display($tpl);
}
示例8: getAttributeMinimalQty
/**
* Get minimal quantity for product with attributes quantity
*
* @acces public static
* @param integer $id_product_attribute
* @return mixed Minimal Quantity or false
*/
public static function getAttributeMinimalQty($product_attribute_id)
{
$db = JFactory::getDBO();
$query = "SELECT " . $db->quoteName('minimal_quantity') . " FROM " . $db->quoteName('#__jeproshop_product_attribute_shop') . " AS product_attribute_shop ";
$query .= " WHERE " . $db->quoteName('shop_id') . " = " . (int) JeproshopContext::getContext()->shop->shop_id . " AND " . $db->quoteName('product_attribute_id');
$query .= (int) $product_attribute_id;
$db->setQuery($query);
$minimal_quantity = $db->loaResult();
if ($minimal_quantity > 1) {
return (int) $minimal_quantity;
}
return false;
}
示例9: initialize
public function initialize()
{
parent::initialize();
$app = JFactory::getApplication();
$context = JeproshopContext::getContext();
// Get address ID
$address_id = 0;
$type = $app->input->get('type');
if ($this->use_ajax && isset($type)) {
if ($type == 'delivery' && isset($context->cart->address_delivery_id)) {
$address_id = (int) $context->cart->address_delivery_id;
} else {
if ($type == 'invoice' && isset($context->cart->address_invoice_id) && $context->cart->id_address_invoice != $context->cart->address_delivery_id) {
$address_id = (int) $context->cart->address_invoice_id;
}
}
} else {
$address_id = (int) $app->input->get('address_id', 0);
}
// Initialize address
if ($address_id) {
$address = new JeproshopAddressModelAddress($address_id);
$view = $app->input->get('view');
$viewClass = $this->getView($view, JFactory::getDocument()->getType());
if (JeproshopTools::isLoadedObject($address, 'address_id') && JeproshopCustomerModelCustomer::customerHasAddress($context->customer->customer_id, $address_id)) {
$task = $app->input->get('task');
if (isset($task) && $task == 'delete') {
if ($address->delete()) {
if ($context->cart->address_invoice_id == $address->address_id) {
unset($context->cart->address_invoice_id);
}
if ($context->cart->id_address_delivery == $address->address_id) {
unset($context->cart->id_address_delivery);
$context->cart->updateAddressId($address->address_id, (int) JeproshopAddressModelAddress::getCustomerFirstAddressId($context->customer->customer_id));
}
$app->redirect('index.php?option=com_jeproshop&view=address');
}
$this->has_errors = true;
JError::raiseError(500, 'This address cannot be deleted.');
}
} elseif ($this->use_ajax) {
$app->close;
} else {
$app->redirect('index.php?option=com_jeproshop&view=address');
}
}
}
示例10: addShop
public function addShop($tpl = null)
{
if ($this->context == null) {
$this->context = JeproshopContext::getContext();
}
$display_group_list = true;
if ($display_group_list) {
$shop_groups = JeproshopShopGroupModelShopGroup::getShopGroups();
$this->assignRef('shop_groups', $shop_groups);
}
$categories = JeproshopCategoryModelCategory::getRootCategories($this->context->language->lang_id);
$themes = JeproshopThemeModelTheme::getThemes();
$this->assignRef('themes', $themes);
$this->assignRef('categories', $categories);
$this->addToolBar();
$this->sideBar = JHtmlSidebar::render();
parent::display($tpl);
}
示例11: assignCountries
/**
* Assign template vars related to countries display
*/
protected function assignCountries()
{
$context = JeproshopContext::getContext();
$app = JFactory::getApplication();
$country_id = $app->input->get('country_id');
// Get selected country
if (isset($country_id) && !is_null($country_id) && is_numeric($country_id)) {
$selected_country = (int) $country_id;
} else {
if (isset($this->address) && isset($this->address->country_id) && !empty($this->address->country_id) && is_numeric($this->address->country_id)) {
$selected_country = (int) $this->address->country_id;
} else {
if (isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
// get all countries as language (xy) or language-country (wz-XY)
$array = array();
preg_match("#(?<=-)\\w\\w|\\w\\w(?!-)#", $_SERVER['HTTP_ACCEPT_LANGUAGE'], $array);
if (!JeproshopTools::isLanguageIsoCode($array[0]) || !($selected_country = JeproshopCountryModelCountry::getByIso($array[0]))) {
$selected_country = (int) JeproshopSettingModelSetting::getValue('default_country');
}
} else {
$selected_country = (int) JeproshopSettingModelSetting::getValue('default_country');
}
}
}
// Generate countries list
if (JeproshopSettingModelSetting::getValue('restrict_delivered_countries')) {
$countries = JeproshopCarrierModelCarrier::getDeliveredCountries($context->language->lang_id, true, true);
} else {
$countries = JeproshopCountryModelCountry::getCountries($context->language->lang_id, true);
}
// @todo use helper
$list = '';
foreach ($countries as $country) {
$selected = $country->country_id == $selected_country ? 'selected="selected"' : '';
$list .= '<option value="' . (int) $country->country_id . '" ' . $selected . '>' . htmlentities(ucfirst($country->name)) . '</option>';
}
// Assign vars
$this->assignRef('countries_list', $list);
$this->assignRef('countries', $countries);
}
示例12: initialize
public function initialize()
{
$app = JFactory::getApplication();
$context = JeproshopContext::getContext();
parent::initialize();
$category_id = $app->input->get('category_id');
$task = $app->input->get('task');
if ($category_id && $task != 'delete') {
$this->category = new JeproshopCategoryModelCategory($category_id);
} else {
if (JeproshopShopModelShop::isFeaturePublished() && JeproshopShopModelShop::getShopContext() == JeproshopShopModelShop::CONTEXT_SHOP) {
$this->category = new JeproshopCategoryModelCategory($context->shop->category_id);
} elseif (count(JeproshopCategoryModelCategory::getCategoriesWithoutParent()) > 1 && JeproshopSettingModelSetting::getValue('multishop_feature_active') && count(JeproshopShopModelShop::getShops(true, null, true)) != 1) {
$this->category = JeproshopCategoryModelCategory::getTopCategory();
} else {
$this->category = new JeproshopCategoryModelCategory(JeproshopSettingModelSetting::getValue('root_category'));
}
}
if (JeproshopTools::isLoadedObject($this->category, 'category_id') && !$this->category->isAssociatedToShop() && JeproshopShopModelShop::getShopContext() == JeproshopShopModelShop::CONTEXT_SHOP) {
$app->redirect('index.php?option=com_jeproshop&view=category&task=edit&category_id=' . (int) $context->shop->getCategoryId() . '&' . JeproshopTools::getCategoryToken() . '=1');
}
}
示例13: getProductWarehouseList
/**
* For a given {product, product attribute} gets warehouse list
*
* @param int $product_id ID of the product
* @param int $product_attribute_id Optional, uses 0 if this product does not have attributes
* @param int $shop_id Optional, ID of the shop. Uses the context shop id (@see JeproshopContext::shop)
* @return array Warehouses (ID, reference/name concatenated)
*/
public static function getProductWarehouseList($product_id, $product_attribute_id = 0, $shop_id = null)
{
$db = JFactory::getDBO();
// if it's a pack, returns warehouses if and only if some products use the advanced stock management
if (JeproshopProductPack::isPack($product_id)) {
$warehouses = JeproshopWarehouseModelWarehouse::getPackWarehouses($product_id);
/*$res = array();
foreach ($warehouses as $warehouse)
$res[]['id_warehouse'] = $warehouse; */
return $warehouses;
}
$share_stock = false;
if ($shop_id === null) {
if (JeproshopShopModelShop::getShopContext() == JeproshopShopModelShop::CONTEXT_GROUP) {
$shop_group = JeproshopShopModelShop::getContextShopGroup();
} else {
$shop_group = JeproshopContext::getContext()->shop->getShopGroup();
$shop_id = (int) JeproshopContext::getContext()->shop->shop_id;
}
$share_stock = $shop_group->share_stock;
} else {
$shop_group = JeproshopShopModelShop::getGroupFromShop($shop_id);
$share_stock = $shop_group->share_stock;
}
if ($share_stock) {
$shop_ids = JeproshopShopModelShop::getShops(true, (int) $shop_group->shop_group_id, true);
} else {
$shop_ids = array((int) $shop_id);
}
$query = "SELECT warehouse_product_location.warehouse_id, CONCAT(warehouse.reference, ' - ', warehouse.name)";
$query .= " AS name FROM " . $db->QuoteName('#__jeproshop_warehouse_product_location') . " AS warehouse_product_location";
$query .= " INNER JOIN " . $db->quoteName('#__jeproshop_warehouse_shop') . " AS warehouse_shop ON(warehouse_shop.";
$query .= "warehouse_id = warehouse_product_location.warehouse_id AND shop_id IN (" . implode(',', array_map('intval', $shop_ids));
$query .= " )) INNER JOIN " . $db->quoteName('#__jeproshop_warehouse') . " AS warehouse ON (warehouse.warehouse_id = warehouse_shop.";
$query .= "warehouse_id ) WHERE product_id = " . (int) $product_id . " AND product_attribute_id = " . (int) $product_attribute_id;
$query .= " AND warehouse.deleted = 0 GROUP BY warehouse_product_location.warehouse_id";
$db->setQuery($query);
return $db->loadObjectList();
}
示例14: thumbnail
/**
* Generate a cached thumbnail for object lists (eg. carrier, order statuses...etc)
*
* @param string $image Real image filename
* @param string $cache_image Cached filename
* @param int $size Desired size
* @param string $image_type Image type
* @param bool $disable_cache When turned on a timestamp will be added to the image URI to disable the HTTP cache
* @param bool $regenerate When turned on and the file already exist, the file will be regenerated
* @return string
*/
public static function thumbnail($image, $cache_image, $size, $image_type = 'jpg', $disable_cache = true, $regenerate = false)
{
if (!file_exists($image)) {
return '';
}
if (file_exists(COM_JEPROSHOP_TMP_IMG_DIR . $cache_image) && $regenerate) {
@unlink(COM_JEPROSHOP_TMP_IMG_DIR . $cache_image);
}
if ($regenerate || !file_exists(COM_JEPROSHOP_TMP_IMG_DIR . $cache_image)) {
$infos = getimagesize($image);
// Evaluate the memory required to resize the image: if it's too much, you can't resize it.
if (!JeproshopImageManager::checkImageMemoryLimit($image)) {
return false;
}
$x = $infos[0];
$y = $infos[1];
$max_x = $size * 3;
// Size is already ok
if ($y < $size && $x <= $max_x) {
copy($image, COM_JEPROSHOP_TMP_IMG_DIR . $cache_image);
// We need to resize */
} else {
$ratio_x = $x / ($y / $size);
if ($ratio_x > $max_x) {
$ratio_x = $max_x;
$size = $y / ($x / $max_x);
}
JeproshopImageManager::resize($image, COM_JEPROSHOP_TMP_IMG_DIR . $cache_image, $ratio_x, $size, $image_type);
}
}
// Relative link will always work, whatever the base uri set in the admin
if (JeproshopContext::getContext()->controller->controller_type == 'admin') {
return '<img src="../img/tmp/' . $cache_image . ($disable_cache ? '?time=' . time() : '') . '" alt="" class="imgm img-thumbnail" />';
} else {
return '<img src="' . _PS_TMP_IMG_ . $cache_image . ($disable_cache ? '?time=' . time() : '') . '" alt="" class="imgm img-thumbnail" />';
}
}
示例15: getMessagesByOrderId
/**
* Return messages from Order ID
*
* @param integer $order_id Order ID
* @param boolean $private return WITH private messages
* @param JeproshopContext $context
* @return array Messages
*/
public static function getMessagesByOrderId($order_id, $private = false, JeproshopContext $context = null)
{
if (!JeproshopTools::isBool($private)) {
die(JError::raiseError());
}
if (!$context) {
$context = JeproshopContext::getContext();
}
$db = JFactory::getDBO();
$query = "SELECT message.*, customer." . $db->quoteName('firstname') . " AS customer_firstname, customer.";
$query .= $db->quoteName('lastname') . " AS customer_lastname, employee." . $db->quoteName('name') . " AS employee_name, ";
$query .= "employee." . $db->quoteName('username') . " AS employee_user_name, (COUNT(message_readed.message_id) = 0 AND ";
$query .= "message.customer_id != 0) AS is_new_for_me FROM " . $db->quoteName('#__jeproshop_message') . " AS message LEFT JOIN ";
$query .= $db->quoteName('#__jeproshop_customer') . " AS customer ON message." . $db->quoteName('customer_id') . " = ";
$query .= "customer." . $db->quoteName('customer_id') . " LEFT JOIN " . $db->quoteName('#__jeproshop_message_readed');
$query .= " AS message_readed ON message_readed." . $db->quoteName('message_id') . " = message." . $db->quoteName('message_id');
$query .= " AND message_readed." . $db->quoteName('employee_id') . " = " . (isset($context->employee) ? (int) $context->employee->employee_id : "");
$query .= " LEFT OUTER JOIN " . $db->quoteName('#__users') . " AS employee ON employee." . $db->quoteName('id');
$query .= " = message." . $db->quoteName('employee_id') . "\tWHERE order_id = " . (int) $order_id;
$query .= (!$private ? " AND message." . $db->quoteName('private') . " = 0" : "") . " GROUP BY message.message_id";
$query .= " ORDER BY message.date_add DESC";
$db->setQuery($query);
return $db->loadObjectList();
}