本文整理汇总了PHP中Context::getContext方法的典型用法代码示例。如果您正苦于以下问题:PHP Context::getContext方法的具体用法?PHP Context::getContext怎么用?PHP Context::getContext使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Context
的用法示例。
在下文中一共展示了Context::getContext方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: renderContent
public function renderContent($setting)
{
$t = array('name' => '', 'html' => '');
$setting = array_merge($t, $setting);
$html = '';
$language_id = Context::getContext()->language->id;
if (is_array($setting['html']) && isset($setting['html'][$language_id])) {
$html = $setting['html'][$language_id];
$html = html_entity_decode($html, ENT_QUOTES, 'UTF-8');
}
$header = '';
$content = $html;
$ac = array();
$language_id = Context::getContext()->language->id;
for ($i = 1; $i <= 6; $i++) {
$header = isset($setting['header_' . $i . '_' . $language_id]) ? $setting['header_' . $i . '_' . $language_id] : '';
if (!empty($header)) {
$content = isset($setting['content_' . $i . '_' . $language_id]) ? $setting['content_' . $i . '_' . $language_id] : '';
$ac[] = array('header' => $header, 'content' => trim($content));
}
}
$setting['accordions'] = $ac;
$setting['id'] = rand() + rand() + count($ac);
$output = array('type' => 'accordion', 'data' => $setting);
return $output;
}
示例2: __construct
public function __construct()
{
/** Backward compatibility */
include_once _PS_MODULE_DIR_ . '/paypal/backward_compatibility/backward.php';
$this->context = Context::getContext();
parent::__construct();
}
示例3: __construct
public function __construct()
{
$this->bootstrap = true;
$this->required_database = true;
$this->required_fields = array('company', 'address2', 'postcode', 'other', 'phone', 'phone_mobile', 'vat_number', 'dni');
$this->table = 'address';
$this->className = 'Address';
$this->lang = false;
$this->addressType = 'customer';
$this->explicitSelect = true;
$this->context = Context::getContext();
$this->addRowAction('edit');
$this->addRowAction('delete');
$this->bulk_actions = array('delete' => array('text' => $this->l('Delete selected'), 'confirm' => $this->l('Delete selected items?'), 'icon' => 'icon-trash'));
$this->allow_export = true;
if (!Tools::getValue('realedit')) {
$this->deleted = true;
}
$countries = Country::getCountries($this->context->language->id);
foreach ($countries as $country) {
$this->countries_array[$country['id_country']] = $country['name'];
}
$this->fields_list = array('id_address' => array('title' => $this->l('ID'), 'align' => 'center', 'class' => 'fixed-width-xs'), 'firstname' => array('title' => $this->l('First Name'), 'filter_key' => 'a!firstname'), 'lastname' => array('title' => $this->l('Last Name'), 'filter_key' => 'a!lastname'), 'address1' => array('title' => $this->l('Address')), 'postcode' => array('title' => $this->l('Zip/Postal Code'), 'align' => 'right'), 'city' => array('title' => $this->l('City')), 'country' => array('title' => $this->l('Country'), 'type' => 'select', 'list' => $this->countries_array, 'filter_key' => 'cl!id_country'));
parent::__construct();
$this->_select = 'cl.`name` as country';
$this->_join = '
LEFT JOIN `' . _DB_PREFIX_ . 'country_lang` cl ON (cl.`id_country` = a.`id_country` AND cl.`id_lang` = ' . (int) $this->context->language->id . ')
LEFT JOIN `' . _DB_PREFIX_ . 'customer` c ON a.id_customer = c.id_customer
';
$this->_where = 'AND a.id_customer != 0 ' . Shop::addSqlRestriction(Shop::SHARE_CUSTOMER, 'c');
}
示例4: renderContent
public function renderContent($setting)
{
$t = array('categorytab' => '', 'categoryBox' => '', 'show_image' => 1, 'show_cat_title' => 1, 'show_description' => 0, 'limit_description' => 25, 'show_sub_category' => 0, 'limit_subcategory' => 5, 'show_nb_product' => 0, 'show_products' => 0, 'limit' => 6, 'columns' => 4, 'list_mode' => 'grid', 'display_mode' => 'carousel', 'nbr_desktops' => 4, 'nbr_tablets' => 2, 'nbr_mobile' => 1);
$setting = array_merge($t, $setting);
$context = Context::getContext();
//$categories = $setting['categoryBox'] ? explode(',', $setting['categoryBox']) : false;
$categorytab = $setting['categorytab'] ? Tools::jsonDecode($setting['categorytab'], true) : array();
//echo "<pre>".print_r($categorytab,1); die;
$categories = $this->getCategories($setting['categoryBox'], $context->language->id);
if ($categories) {
foreach ($categories as &$category) {
$obj = new Category($category['id_category']);
$category['nb_products'] = $obj->getProducts($context->language->id, 0, 1, null, null, true);
$category['products'] = $obj->getProducts($context->language->id, 0, $setting['limit'], null, null, false);
$category['id_image'] = file_exists(_PS_CAT_IMG_DIR_ . (int) $category['id_category'] . '.jpg') ? (int) $category['id_category'] : false;
$category['subcategories'] = $this->getSubCategories($category['id_category'], $setting['limit_subcategory'], $context->language->id);
$tg = isset($categorytab[$category['id_category']]) ? $categorytab[$category['id_category']] : '';
if (is_file(_PAGEBUILDER_IMAGE_DIR_ . $tg['icon'])) {
$category['icon'] = _PAGEBUILDER_IMAGE_URL_ . $tg['icon'];
} else {
$category['icon'] = '';
}
$category['icon_class'] = $tg['icon_class'];
}
}
$setting['list_mode_tpl'] = $this->getProductListStyleFile($setting['list_mode'], $setting['product_style']);
$setting['categories_info'] = $categories;
$output = array('type' => 'categoriesinfo', 'data' => $setting);
return $output;
}
示例5: initPageHeaderToolbar
public function initPageHeaderToolbar()
{
if ($this->display == 'details') {
$this->page_header_toolbar_btn['back_to_list'] = array('href' => Context::getContext()->link->getAdminLink('AdminStockManagement'), 'desc' => $this->l('Back to list', null, null, false), 'icon' => 'process-icon-back');
}
parent::initPageHeaderToolbar();
}
示例6: upgrade_module_0_9
function upgrade_module_0_9($module)
{
$module_path = $module->getLocalPath();
$img_folder_path = $module->getLocalPath() . 'img';
$fixture_img_path = $module->getLocalPath() . 'img' . DIRECTORY_SEPARATOR . 'fixtures';
if (!Tools::file_exists_cache($img_folder_path)) {
mkdir($img_folder_path);
}
if (!Tools::file_exists_cache($fixture_img_path)) {
mkdir($fixture_img_path);
}
$files = scandir($module->getLocalPath());
foreach ($files as $file) {
if (strncmp($file, 'advertising', 11) == 0) {
if ($file == 'advertising.jpg') {
copy($module_path . $file, $fixture_img_path . DIRECTORY_SEPARATOR . $file);
} else {
copy($module_path . $file, $img_folder_path . DIRECTORY_SEPARATOR . $file);
}
unlink($module_path . $file);
}
}
Tools::clearCache(Context::getContext()->smarty, $module->getTemplatePath('blockadvertising.tpl'));
return true;
}
示例7: __construct
public function __construct()
{
$this->bootstrap = true;
$this->table = 'neo_whitelist';
$this->identifier = 'id_neo_whitelist';
$this->className = 'NeoWhitelist';
$this->deleted = false;
$this->explicitSelect = true;
$this->allow_export = true;
$this->addRowAction('edit');
$this->addRowAction('delete');
$this->bulk_actions = array('delete' => array('text' => $this->l('Delete selected'), 'confirm' => $this->l('Delete selected items?'), 'icon' => 'icon-trash'));
$this->context = Context::getContext();
$this->default_form_language = $this->context->language->id;
$this->_select = '
a.`id_neo_whitelist`,
a.`price`,
p.`price` AS `pprice`,
pl.`name`';
$this->_join = '
LEFT JOIN `' . _DB_PREFIX_ . 'product` p ON (p.`id_product` = a.`id_product`)
LEFT JOIN `' . _DB_PREFIX_ . 'product_lang` pl ON (pl.`id_product` = a.`id_product`)
';
$this->_orderBy = 'id_neo_whitelist';
$this->_orderWay = 'DESC';
$this->fields_list = array('id_neo_whitelist' => array('title' => $this->l('ID'), 'align' => 'text-center', 'class' => 'fixed-width-xs'), 'name' => array('title' => $this->l('Nombre'), 'havingFilter' => true), 'pprice' => array('title' => $this->l('Precio Real')), 'price' => array('title' => $this->l('Precio Intercambio')));
parent::__construct();
}
示例8: thumbnail
/**
* Generate a cached thumbnail for object lists (eg. carrier, order states...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
* @return string
*/
public static function thumbnail($image, $cache_image, $size, $image_type = 'jpg', $disable_cache = false)
{
if (!file_exists($image)) {
return '';
}
if (!file_exists(_PS_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 (!ImageManager::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, _PS_TMP_IMG_DIR_ . $cache_image);
} else {
$ratio_x = $x / ($y / $size);
if ($ratio_x > $max_x) {
$ratio_x = $max_x;
$size = $y / ($x / $max_x);
}
ImageManager::resize($image, _PS_TMP_IMG_DIR_ . $cache_image, $ratio_x, $size, $image_type);
}
}
// Relative link will always work, whatever the base uri set in the admin
if (Context::getContext()->controller->controller_type == 'admin') {
return '<img src="../img/tmp/' . $cache_image . (!$disable_cache ? '?time=' . time() : '') . '" alt="" class="imgm" />';
} else {
return '<img src="' . _PS_TMP_IMG_ . $cache_image . (!$disable_cache ? '?time=' . time() : '') . '" alt="" class="imgm" />';
}
}
示例9: redirectAdmin
public static function redirectAdmin($url)
{
if (!is_object(Context::getContext()->controller)) {
Context::getContext()->controller = new StdClass();
}
Context::getContext()->controller->setRedirectAfter($url);
}
示例10: __construct
public function __construct()
{
parent::__construct();
$this->context = Context::getContext();
$aResponse['error'] = false;
$aResponse['message'] = '';
if (isset($_POST['action'])) {
$id_video = $_POST['idBox'];
$ratting = $_POST['rate'];
if (VideosRatting::checkRatting($id_video)) {
$videosRatting = new VideosRatting();
$videosRatting->add(array('id_video' => $id_video, 'ratting' => $ratting));
$aResponse['error'] = FALSE;
$aResponse['message'] = 'Your rate has been successfuly recorded. Thanks for your rate';
} else {
$aResponse['error'] = true;
$aResponse['message'] = 'Your have rated for images';
}
} else {
$aResponse['error'] = true;
$aResponse['message'] = 'An error occured during the request. Please retry';
}
echo json_encode($aResponse);
die;
}
示例11: getGlossaries
/**
* Get all available glossaries
*
* @param integer $id_lang Language id
* @param array $criteria Criterias for where clause
* @param integer $start Start number
* @param integer $limit Number of glossaries to return
* @param string $order_by Field for ordering
* @param string $order_way Way for ordering (ASC or DESC)
* @param boolean $only_active Returns only active glossaries if TRUE
* @param Context|null $context
*
* @return array list of glossaries
*/
public static function getGlossaries($id_lang, $criteria = array(), $start = null, $limit = null, $order_by = null, $order_way = null, $only_active = false, Context $context = null)
{
$where = '';
if (!$context) {
$context = Context::getContext();
}
if ($order_by !== null) {
if (!Validate::isOrderBy($order_by) || !Validate::isOrderWay($order_way)) {
die(Tools::displayError());
}
if ($order_by == 'id') {
$order_by_prefix = 'l';
} else {
$order_by_prefix = 'll';
}
if (strpos($order_by, '.') > 0) {
$order_by = explode('.', $order_by);
$order_by_prefix = $order_by[0];
$order_by = $order_by[1];
}
}
if (isset($criteria['k'])) {
$where .= " AND ll.name LIKE '" . pSQL($criteria['k']) . "%' ";
}
$sql = 'SELECT l.*, ll.*
FROM `' . _DB_PREFIX_ . 'lexikotron` l
LEFT JOIN `' . _DB_PREFIX_ . 'lexikotron_lang` ll ON (l.`id_lexikotron` = ll.`id_lexikotron`)
WHERE ll.`id_lang` = ' . (int) $id_lang . ($only_active ? ' AND l.`active` = 1' : '') . '
' . $where . '
' . ($order_by != null ? 'ORDER BY ' . (isset($order_by_prefix) ? pSQL($order_by_prefix) . '.' : '') . '`' . pSQL($order_by) . '` ' . pSQL($order_way) : '') . ($limit > 0 ? ' LIMIT ' . (int) $start . ',' . (int) $limit : '');
$rows = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql);
return $rows;
}
示例12: renderContent
public function renderContent($args, $setting)
{
$t = array('name' => '', 'html' => '');
$setting = array_merge($t, $setting);
$nb = $setting['itemstab'] ? (int) $setting['itemstab'] : 6;
$catids = $setting['categories'] ? $setting['categories'] : array();
$orderby = $setting['orderby'] ? $setting['orderby'] : 'position';
$orderway = $setting['orderway'] ? $setting['orderway'] : 'ASC';
$items_page = $setting['itemspage'] ? (int) $setting['itemspage'] : 3;
$columns_page = $setting['columns'] ? (int) $setting['columns'] : 3;
$categories = array();
foreach ($catids as $catid) {
$category = new Category($catid, (int) Context::getContext()->language->id);
if ($category->id) {
$categories[$catid]['id'] = $category->id;
$categories[$catid]['name'] = $category->name;
$categories[$catid]['link'] = $category->getLink();
$products = $category->getProducts((int) Context::getContext()->language->id, 1, $nb, $orderby, $orderway);
Context::getContext()->controller->addColorsToProductList($products);
$categories[$catid]['products'] = $products;
}
}
$setting['leocategories'] = $categories;
$setting['itemsperpage'] = $items_page;
$setting['columnspage'] = $columns_page;
$setting['scolumn'] = 12 / $columns_page;
$setting['myTab'] = 'leocategorytab' . rand(20, rand());
$output = array('type' => 'categoriestabs', 'data' => $setting);
return $output;
}
示例13: __construct
function __construct()
{
$this->context = Context::getContext();
$this->setDefaultSmartyVars();
$this->getLanguageInterface();
$this->getNavigationLinks();
}
示例14: renderForm
public function renderForm($data)
{
$key = time();
$helper = $this->getFormHelper();
$soption = array(array('id' => 'active_on', 'value' => 1, 'label' => $this->l('Enabled')), array('id' => 'active_off', 'value' => 0, 'label' => $this->l('Disabled')));
$this->fields_form[1]['form'] = array('legend' => array('title' => $this->l('Widget Form.')), 'input' => array(array('type' => 'text', 'label' => $this->l('Image Folder Path'), 'name' => 'imageslist', 'class' => 'imageupload', 'default' => '', 'id' => 'imageslist' . $key, 'desc' => 'Put image folder in the image folder ROOT_SHOP_DIR/img/'), array('type' => 'text', 'label' => $this->l('Image size'), 'name' => 'size', 'class' => 'image', 'default' => '', 'id' => 'imagesize' . $key, 'desc' => 'Enter image size. Example: thumbnail, medium, large, full or other sizes defined by current theme.
Alternatively enter image size in pixels: 200x100 (Width x Height). Leave empty to use \'thumbnail\' size.'), array('type' => 'select', 'label' => $this->l('Columns'), 'name' => 'columns', 'options' => array('query' => array(array('id' => '1', 'name' => $this->l('1 Column')), array('id' => '2', 'name' => $this->l('2 Columns')), array('id' => '3', 'name' => $this->l('3 Columns')), array('id' => '4', 'name' => $this->l('4 Columns')), array('id' => '5', 'name' => $this->l('5 Columns'))), 'id' => 'id', 'name' => 'name'), 'default' => 4), array('type' => 'select', 'label' => $this->l('Type'), 'name' => 'type', 'options' => array('query' => array(array('id' => 'grid', 'name' => $this->l('Grid')), array('id' => 'slider-nivo', 'name' => $this->l('Nivo Slider')), array('id' => 'slider-bt', 'name' => $this->l('Bootstrap Slider'))), 'id' => 'id', 'name' => 'name'), 'default' => 'grid'), array('type' => 'textarea', 'label' => $this->l('Custom links'), 'name' => 'links', 'desc' => 'Enter links for each slide here. Divide links with linebreaks (Enter).', 'rows' => '20'), array('type' => 'switch', 'label' => $this->l('Enable Popup Image'), 'desc' => $this->l('Show the original image on a modal box'), 'name' => 'ispopup', 'default' => 1, 'values' => $soption)), 'submit' => array('title' => $this->l('Save'), 'class' => 'button'));
$default_lang = (int) Configuration::get('PS_LANG_DEFAULT');
$helper->tpl_vars = array('fields_value' => $this->getConfigFieldsValues($data), 'languages' => Context::getContext()->controller->getLanguages(), 'id_language' => $default_lang);
$string = '<fieldset class="panel">
<h3>' . $this->l('Images Management') . '</h3>
<div class="alert aleart-info">
<div id="imagelist' . $key . '">
<button class="btn btn-info">' . $this->l('Add Images') . '</button>
<div class="images-content"></div>
</div>
</div>
</fieldset>
<script type="text/javascript">
$(".imageupload").WPO_Gallery({gallery:true});
</script>
';
return '<div id="imageslist' . $key . '">' . $helper->generateForm($this->fields_form) . $string . '</div>';
}
示例15: __construct
public function __construct()
{
$this->bootstrap = true;
$this->table = 'cms';
$this->list_id = 'cms';
$this->className = 'CMS';
$this->lang = true;
$this->addRowAction('edit');
$this->addRowAction('delete');
$this->bulk_actions = array('delete' => array('text' => $this->l('Delete selected'), 'confirm' => $this->l('Delete selected items?'), 'icon' => 'icon-trash'));
$this->fields_list = array('id_cms' => array('title' => $this->l('ID'), 'align' => 'center', 'class' => 'fixed-width-xs'), 'link_rewrite' => array('title' => $this->l('URL')), 'meta_title' => array('title' => $this->l('Title'), 'filter_key' => 'b!meta_title'), 'position' => array('title' => $this->l('Position'), 'filter_key' => 'position', 'align' => 'center', 'class' => 'fixed-width-sm', 'position' => 'position'), 'active' => array('title' => $this->l('Displayed'), 'align' => 'center', 'active' => 'status', 'class' => 'fixed-width-sm', 'type' => 'bool', 'orderby' => false));
// The controller can't be call directly
// In this case, AdminCmsContentController::getCurrentCMSCategory() is null
if (!AdminCmsContentController::getCurrentCMSCategory()) {
$this->redirect_after = '?controller=AdminCmsContent&token=' . Tools::getAdminTokenLite('AdminCmsContent');
$this->redirect();
}
$this->_category = AdminCmsContentController::getCurrentCMSCategory();
$this->tpl_list_vars['icon'] = 'icon-folder-close';
$this->tpl_list_vars['title'] = sprintf($this->l('Pages in category "%s"'), $this->_category->name[Context::getContext()->employee->id_lang]);
$this->_join = '
LEFT JOIN `' . _DB_PREFIX_ . 'cms_category` c ON (c.`id_cms_category` = a.`id_cms_category`)';
$this->_select = 'a.position ';
$this->_where = ' AND c.id_cms_category = ' . (int) $this->_category->id;
parent::__construct();
}