本文整理匯總了PHP中Context::getcontext方法的典型用法代碼示例。如果您正苦於以下問題:PHP Context::getcontext方法的具體用法?PHP Context::getcontext怎麽用?PHP Context::getcontext使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Context
的用法示例。
在下文中一共展示了Context::getcontext方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: rev_get_token
function rev_get_token()
{
$token = Context::getcontext()->controller->token;
if (isset($token)) {
return $token;
}
return false;
}
示例2: register_fonts
public function register_fonts()
{
$fonts = $this->get_all_fonts();
if (!empty($fonts)) {
$http = is_ssl() ? 'https' : 'http';
foreach ($fonts as $font) {
if ($font !== '') {
$font_url = $http . '://fonts.googleapis.com/css?family=' . $font['url'];
Context::getcontext()->controller->addCSS($font_url);
}
}
}
}
示例3: hookdisplayBackOfficeHeader
public function hookdisplayBackOfficeHeader()
{
if (Tools::getvalue('configure') == 'revsliderprestashop') {
$this->context->controller->addCSS($this->_path . 'css/jui/new/jquery-ui-1.10.3.custom.min.css');
$this->context->controller->addCSS($this->_path . 'css/admin.css');
$this->context->controller->addCSS($this->_path . 'css/tipsy.css');
$this->context->controller->addCSS($this->_path . 'css/load-styles.css');
$this->context->controller->addCSS($this->_path . 'js/farbtastic/farbtastic.css');
$this->context->controller->addCSS($this->_path . 'js/codemirror/codemirror.css');
$this->context->controller->addCSS($this->_path . 'css/edit_layers.css');
$this->context->controller->addCSS($this->_path . 'css/thickbox.css');
$this->context->controller->addCSS($this->_path . 'rs-plugin/css/settings.css');
$this->context->controller->addCSS($this->_path . 'rs-plugin/css/static-captions.css');
$g_urlContent = UniteFunctionsWPRev::getUrlContent();
$dynamicadmincss = 'index.php?controller=Revolutionslider_ajax&token=' . Context::getcontext()->controller->token . '&revControllerAction=captions';
$this->smarty->assign('dynamicadmincss', $dynamicadmincss);
$this->smarty->assign('g_urlContent', $g_urlContent);
$this->smarty->assign('this_path', $this->_path);
return $this->display(__FILE__, 'views/templates/admin/revolution_admin.tpl');
}
}
示例4: isset
<th width='70px'><?php
echo RevsliderPrestashop::$lang['N_Slides'];
?>
</th>
<?php
}
?>
<th width='50%'><?php
echo RevsliderPrestashop::$lang['Actions'];
?>
</th>
</tr>
</thead>
<tbody>
<?php
if ($outputTemplates) {
$useSliders = $arrSlidersTemplates;
$pagenum = isset($_GET['pagenumt']) ? absint($_GET['pagenumt']) : 1;
$offset = ($pagenum - 1) * $limit;
} else {
$useSliders = $arrSliders;
$pagenum = isset($_GET['pagenum']) ? absint($_GET['pagenum']) : 1;
$offset = ($pagenum - 1) * $limit;
}
$cur_offset = 0;
$current_id_shop_group = Context::getcontext()->shop->id_shop_group;
$current_shop_id = Context::getcontext()->shop->id;
$shop_context = Context::getcontext()->cookie->shopContext;
if (!empty($shop_context) && isset($shop_context)) {
$shop_contexttype = substr($shop_context, 0, 1);
} else {
示例5: get_uploaded_files_markup
public static function get_uploaded_files_markup($results = array())
{
$lan_iso = Context::getcontext()->language->iso_code;
include_once _PS_ROOT_DIR_ . '/modules/revsliderprestashop/views/config/config.php';
// include_once(_PS_ROOT_DIR_.'/modules/revsliderprestashop/views/lang/'.$lan_iso.'.php');
include_once _PS_ROOT_DIR_ . '/modules/revsliderprestashop/views/include/utils.php';
$upload_dir = __PS_BASE_URI__ . 'modules/revsliderprestashop/uploads/';
$current_path = _PS_ROOT_DIR_ . '/modules/revsliderprestashop/uploads/';
$url = uploads_url();
ob_start();
if (!empty($results)) {
?>
<div id="divImageList" > <ul id="selectable" class="">
<?php
$num = 0;
foreach ($results as $id => $filename) {
//$img = $results[$num];
$thumbsize = GlobalsRevSlider::IMAGE_SIZE_THUMBNAIL;
$mediumsize = GlobalsRevSlider::IMAGE_SIZE_MEDIUM;
$largesize = GlobalsRevSlider::IMAGE_SIZE_LARGE;
$filerealname = substr($filename, 0, strrpos($filename, '.'));
$fileext = substr($filename, strrpos($filename, '.'), strlen($filename) - strlen($filerealname));
$thumbimg = $img = "{$filerealname}-{$thumbsize}x{$thumbsize}{$fileext}";
$mediumimg = "{$filerealname}-{$mediumsize}x{$mediumsize}{$fileext}";
$largeimg = "{$filerealname}-{$largesize}x{$largesize}{$fileext}";
$file_path = $file_path = $current_path . $largeimg;
$date = filemtime($file_path);
$size = filesize($file_path);
// $file_ext = substr(strrchr($file, '.'), 1);
$file_infos = pathinfo($file_path);
$file_ext = $file_infos['extension'];
// $sorted[$k] = array('file' => $file, 'date' => $date, 'size' => $size, 'extension' => $file_ext);
$extension_lower = fix_strtolower($file_ext);
$is_img = true;
list($img_width, $img_height, $img_type, $attr) = getimagesize($file_path);
// if (++$num % 4 === 1):
?>
<li data-image="<?php
echo $filename;
?>
" data-large="<?php
echo $upload_dir . $img;
?>
" data-medium="<?php
echo $upload_dir . $img;
?>
" data-thumb="<?php
echo $upload_dir . $img;
?>
" class="ff-item-type-2 file">
<figure data-type="img" data-name="1117858_1577750_graph-1024x1024.png">
<a data-function="apply" data-field_id="" data-file="<?php
echo $upload_dir . $img;
?>
" class="link" href="javascript:void('')">
<div class="img-precontainer">
<div class="img-container">
<span></span>
<img alt="<?php
echo $img;
?>
" src="<?php
echo $upload_dir . $img;
?>
" class="original " >
</div>
</div>
<div class="img-precontainer-mini original-thumb">
<div class="filetype png hide">png</div>
<div class="img-container-mini">
<span></span>
<img src="<?php
echo $upload_dir . $img;
?>
" class=" " alt="<?php
echo $img;
?>
thumbnails">
</div>
</div>
</a>
<div class="box">
<h4 class="ellipsis">
<a data-function="apply" data-field_id="" data-file="<?php
echo $img;
?>
" class="link" href="javascript:void('')">
<?php
echo $img;
?>
</a></h4>
</div>
<?php
$date = filemtime($current_path . $img);
?>
<input type="hidden" class="date" value="<?php
echo $date;
?>
"/>
<input type="hidden" class="size" value="<?php
//.........這裏部分代碼省略.........
示例6: getIdeasOrTipsByproductId
/**
* @param $iIdProduct
* @return mixed
*/
private static function getIdeasOrTipsByproductId($iIdProduct)
{
if (!array_key_exists($iIdProduct, self::$aNowIdeasOrTips)) {
self::$aNowIdeasOrTips[$iIdProduct] = NowIdeasOrTips::getItems($iIdProduct, Context::getcontext()->language->id);
}
return self::$aNowIdeasOrTips[$iIdProduct];
}
示例7: importSliderFromPost
//.........這裏部分代碼省略.........
$arrInsert = array();
$arrInsert["hover"] = json_encode($styles);
$arrInsert["settings"] = json_encode(array('hover' => 'true'));
} else {
$arrInsert = array();
$arrInsert["params"] = json_encode($styles);
}
//check if class exists
$result = $db->fetch(GlobalsRevSlider::$table_css, "handle = '" . $class . "'");
if (!empty($result)) {
//update
$db->update(GlobalsRevSlider::$table_css, $arrInsert, array('handle' => $class));
} else {
//insert
$arrInsert["handle"] = $class;
$db->insert(GlobalsRevSlider::$table_css, $arrInsert);
}
}
dmp(__("dynamic styles imported!", REVSLIDER_TEXTDOMAIN));
} else {
dmp(__("no dynamic styles found, if slider uses dynamic styles, the provided export may be broken...", REVSLIDER_TEXTDOMAIN));
}
}
// $content = preg_replace('!s:(\d+):"(.*?)";!', "'s:'.strlen('$2').':\"$2\";'", $content); //clear errors in string
$content = preg_replace_callback('!s:(\\d+):"(.*?)";!', create_function('$match', 'return "s:".strlen($match[2]).":\\"{$match[2]}\\";";'), $content);
//clear errors in string
$arrSlider = @unserialize($content);
if (empty($arrSlider)) {
UniteFunctionsRev::throwError("Wrong export slider file format! This could be caused because the ZipArchive extension is not enabled.");
}
//update slider params
$sliderParams = $arrSlider["params"];
$sliderParams["displayhook"] = '';
$sliderParams["id_shop"] = Context::getcontext()->shop->id;
if ($sliderExists) {
$sliderParams["title"] = $this->arrParams["title"];
$sliderParams["alias"] = $this->arrParams["alias"];
$sliderParams["id_shop"] = Context::getcontext()->shop->id;
//$sliderParams["shortcode"] = $this->arrParams["shortcode"];
}
if (isset($sliderParams["background_image"])) {
$sliderParams["background_image"] = UniteFunctionsWPRev::getImageUrlFromPath($sliderParams["background_image"]);
}
$json_params = json_encode($sliderParams);
//update slider or craete new
if ($sliderExists) {
$arrUpdate = array("params" => $json_params);
$this->db->update(GlobalsRevSlider::$table_sliders, $arrUpdate, array("id" => $sliderID));
} else {
//new slider
$arrInsert = array();
$arrInsert["params"] = $json_params;
$arrInsert["title"] = UniteFunctionsRev::getVal($sliderParams, "title", "Slider1");
$arrInsert["alias"] = UniteFunctionsRev::getVal($sliderParams, "alias", "slider1");
//$arrInsert["id_shop"] = Context::getcontext()->shop->id;
$sliderID = $this->db->insert(GlobalsRevSlider::$table_sliders, $arrInsert);
}
//-------- Slides Handle -----------
//delete current slides
if ($sliderExists) {
$this->deleteAllSlides();
}
//create all slides
$arrSlides = $arrSlider["slides"];
$alreadyImported = array();
foreach ($arrSlides as $slide) {
示例8: GetAllBlogPost
}
}
return $results;
}
public static function GetAllBlogPost()
{
$id_lang = (int) Context::getContext()->language->id;
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('
SELECT * FROM `' . _DB_PREFIX_ . 'smart_blog_category` sbc INNER JOIN `' . _DB_PREFIX_ . 'smart_blog_category_lang` sbcl ON(sbc.`id_smart_blog_category` = sbcl.`id_smart_blog_category` AND sbcl.`id_lang` = ' . (int) $id_lang . ')
INNER JOIN `' . _DB_PREFIX_ . 'smart_blog_category_shop` sbs ON sbs.id_smart_blog_category = sbc.id_smart_blog_category and sbs.id_shop = ' . (int) Context::getContext()->shop->id . ' WHERE sbc.`active`= 1');
return $result;
}
public static function GetCategoryNameById($id_category = '')
{
if (isset($id_category) && !empty($id_category) && $id_category != 0) {
$id_lang = (int) Context::getContext()->language->id;
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('
SELECT sbcl.`name` FROM `' . _DB_PREFIX_ . 'category` sbc INNER JOIN `' . _DB_PREFIX_ . 'category_lang` sbcl ON(sbc.`id_category` = sbcl.`id_category` AND sbcl.`id_lang` = ' . (int) $id_lang . ')
INNER JOIN `' . _DB_PREFIX_ . 'category_shop` sbs ON sbs.id_category = sbc.id_category and sbs.id_shop = ' . (int) Context::getContext()->shop->id . ' WHERE sbc.`active`= 1 and sbc.`id_category` = ' . $id_category);
return $result[0]['name'];
} else {
return false;
}
}
public static function GetAllProducts($id_category, $order_by = null, $order_way = null, $limit = null)
{
// start set prestashop value
$random = false;
if ($order_by == 'ID') {
$order_by = 'id_product';
} elseif ($order_by == 'date') {
$order_by = 'date_add';
} elseif ($order_by == 'title') {
$order_by = 'name';
} elseif ($order_by == 'price') {
$order_by = 'price';
} else {
$order_by = 'position';
}
if ($order_by == 'rand') {
$random = true;
}
// end set prestashop value
$random_number_products = 1;
$check_access = true;
$id_lang = Context::getcontext()->language->id;
$context = Context::getContext();
// if ($check_access && !$this->checkAccess($context->customer->id))
// return false;
$active = true;
$front = true;
if (!in_array($context->controller->controller_type, array('front', 'modulefront'))) {
$front = false;
}
if (empty($order_by)) {
$order_by = 'position';
} else {
$order_by = strtolower($order_by);
}
if (empty($order_way)) {
$order_way = 'ASC';
}
$order_by_prefix = false;
if ($order_by == 'id_product' || $order_by == 'date_add' || $order_by == 'date_upd') {
$order_by_prefix = 'p';
} elseif ($order_by == 'name') {
$order_by_prefix = 'pl';
} elseif ($order_by == 'manufacturer') {
$order_by_prefix = 'm';
$order_by = 'name';
} elseif ($order_by == 'position') {
$order_by_prefix = 'cp';
}
示例9: setLayersByPostData
$countdown_js = __PS_BASE_URI__ . 'modules/revsliderprestashop/js/countdown/jquery.countdown.js';
$countdown_css = __PS_BASE_URI__ . 'modules/revsliderprestashop/css/countdown/countdown.css';
Context::getcontext()->controller->addJs($countdown_js);
Context::getcontext()->controller->addCSS($countdown_css);
// end start countdown JS
}
}
return $html;
}
private function setLayersByPostData($postData, $sliderID)
{
$priceDisplay = Product::getTaxCalculationMethod((int) Context::getcontext()->cookie->id_customer);
if (!$priceDisplay) {
$productprice = Tools::displayPrice($postData["price"], Context::getContext()->currency);
} else {
$productprice = Tools::displayPrice($postData["price_tax_exc"], Context::getContext()->currency);
}
$postID = $postData["id_product"];
$countdown = $this->SetCountDown($postData);
// $imgsrc = $this->SetImageSrc($postData);
$title = UniteFunctionsRev::getVal($postData, "name");
$excerpt_limit = $this->getSliderParam($sliderID, "excerpt_limit", 55, RevSlider::VALIDATE_NUMERIC);
$excerpt_limit = (int) $excerpt_limit;
$description = substr($postData["description"], $excerpt_limit);
$description_short = $postData["description_short"];
// $alias = UniteFunctionsRev::getVal($postData, "post_name");
// $content = UniteFunctionsRev::getVal($postData, "post_content");
//$link = get_permalink($postID);
$link = $postData["link"];
$date_add = $postData["date_add"];
//$date_add = UniteFunctionsWPRev::convertPostDate($date_add);
$date_upd = $postData["date_upd"];
//$date_upd = UniteFunctionsWPRev::convertPostDate($date_upd);
$category_default = $postData["category_default"];
$linkobj = new Link();
$addtocart = $linkobj->getPageLink('cart', false, NULL, "add=1&id_product=" . $postID, false);
foreach ($this->arrLayers as $key => $layer) {
$text = UniteFunctionsRev::getVal($layer, "text");
$text = str_replace("%title%", $title, $text);
$text = str_replace("%description_short%", $description_short, $text);
$text = str_replace("%description%", $description, $text);
$text = str_replace("%link%", $link, $text);
$text = str_replace("%addtocart%", $addtocart, $text);
$text = str_replace("%countdown%", $countdown, $text);
// $text = str_replace("%imgsrc%", $imgsrc, $text);
$text = str_replace("%date%", $date_add, $text);
$text = str_replace("%date_modified%", $date_upd, $text);
$text = str_replace("%product_price%", $productprice, $text);
$text = str_replace("%category_default%", $category_default, $text);
$arrMatches = array();
$text = str_replace('-', '_REVSLIDER_', $text);
preg_match_all('/%product:\\w+%/', $text, $arrMatches);
foreach ($arrMatches as $matched) {
foreach ($matched as $match) {
$meta = str_replace("%product:", "", $match);
$meta = str_replace("%", "", $meta);
$meta = str_replace('_REVSLIDER_', '-', $meta);
if (isset($postData[$meta]) && !empty($postData[$meta])) {
$metaValue = $postData[$meta];
$text = str_replace($match, $metaValue, $text);
}
}
}
$text = str_replace('_REVSLIDER_', '-', $text);
// start hook exec
$extra_hook_meta_exec = array();
Hook::exec('actionsdsrevinsertmetaexec', array('extra_hook_meta_exec' => &$extra_hook_meta_exec, 'id_product' => &$postID));
if (isset($extra_hook_meta_exec) && !empty($extra_hook_meta_exec)) {
foreach ($extra_hook_meta_exec as $svalue) {
$hook_title = "%" . $svalue['title'] . "%";
示例10:
<input type="hidden" name="id_shop" id="sds_rev_id_shop" value="<?php
echo Context::getcontext()->shop->id;
?>
">