本文整理汇总了PHP中Enlight函数的典型用法代码示例。如果您正苦于以下问题:PHP Enlight函数的具体用法?PHP Enlight怎么用?PHP Enlight使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Enlight函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: populate
/**
* populate Source Object with meta data from Resource
*
* @param Smarty_Template_Source $source source object
* @param Smarty_Internal_Template $_template template object
*/
public function populate(Smarty_Template_Source $source, Smarty_Internal_Template $_template = null)
{
Enlight()->Events()->notify('Profiler_Smarty_Render', new Enlight_Event_EventArgs(['name' => $source->name]));
$uid = '';
$sources = array();
$components = explode('|', $source->name);
$exists = true;
foreach ($components as $component) {
$s = Smarty_Resource::source(null, $source->smarty, $component);
if ($s->type == 'php') {
throw new SmartyException("Resource type {$s->type} cannot be used with the extends resource type");
}
$sources[$s->uid] = $s;
$uid .= $s->filepath;
if ($_template && $_template->smarty->compile_check) {
$exists = $exists && $s->exists;
}
}
$source->components = $sources;
$source->filepath = $s->filepath;
$source->uid = sha1($uid);
if ($_template && $_template->smarty->compile_check) {
$source->timestamp = $s->timestamp;
$source->exists = $exists;
}
// need the template at getContent()
$source->template = $_template;
}
示例2: errorAction
public function errorAction()
{
$error = $this->Request()->getParam('error_handler');
if (!empty($error)) {
if ($this->Front()->getParam('showException')) {
$paths = array(Enlight()->Path(), Enlight()->AppPath(), Enlight()->OldPath());
$replace = array('', Enlight()->App() . '/', '');
$exception = $error->exception;
$error_file = $exception->getFile();
$error_file = str_replace($paths, $replace, $error_file);
$error_trace = $error->exception->getTraceAsString();
$error_trace = str_replace($paths, $replace, $error_trace);
$this->View()->assign(array('exception' => $exception, 'error_message' => $exception->getMessage(), 'error_file' => $error_file, 'error_trace' => $error_trace));
}
$code = $error->exception->getCode();
switch ($code) {
case 404:
case 401:
$this->Response()->setHttpResponseCode($code);
break;
default:
$this->Response()->setHttpResponseCode(503);
break;
}
if ($this->View()->getAssign('success') !== null) {
$this->Response()->setHttpResponseCode(200);
$this->View()->clearAssign('exception');
$this->View()->assign('message', $error->exception->getMessage());
}
}
}
示例3: logResults
/**
* @param Logger $log
* @return mixed
*/
public function logResults(Logger $log)
{
foreach (array_keys($this->results) as $event) {
if (empty($this->results[$event][0])) {
unset($this->results[$event]);
continue;
}
$listeners = array();
foreach (Enlight()->Events()->getListeners($event) as $listener) {
$listener = $listener->getListener();
if ($listener[0] === $this) {
continue;
}
if (is_array($listener) && is_object($listener[0])) {
$listener[0] = get_class($listener[0]);
}
if (is_array($listener)) {
$listener = implode('::', $listener);
}
$listeners[] = $listener;
}
$this->results[$event] = array(0 => $event, 1 => $this->utils->formatMemory(0 - $this->results[$event][1]), 2 => $this->utils->formatTime(0 - $this->results[$event][2]), 3 => $listeners);
}
$this->results = array_values($this->results);
foreach ($this->results as $result) {
$order[] = $result[2];
}
array_multisort($order, SORT_NUMERIC, SORT_DESC, $this->results);
array_unshift($this->results, array('name', 'memory', 'time', 'listeners'));
$label = 'Benchmark Events';
$table = array($label, $this->results);
$log->table($table);
}
示例4: indexAction
/**
* Shows a category tree
*/
public function indexAction()
{
$categoryTree = Shopware()->Modules()->sCategories()->sGetWholeCategoryTree();
$additionalTrees = $this->getAdditionalTrees();
$additionalTrees = Enlight()->Events()->filter('Shopware_Modules_Sitemap_indexAction', $additionalTrees, array('subject' => $this));
$categoryTree = array_merge($categoryTree, $additionalTrees);
$this->View()->sCategoryTree = $categoryTree;
}
示例5: ajaxSearch
/**
* perform autocompletion suggestion
* @param Enlight_Event_EventArgs $arguments
* @return boolean
*/
public function ajaxSearch(Enlight_Event_EventArgs $arguments)
{
if (!$this->Config()->get('boxalino_search_enabled')) {
return null;
}
$this->init($arguments);
Enlight()->Plugins()->Controller()->Json()->setPadding();
$term = $this->getSearchTerm();
if (empty($term)) {
return false;
}
$requests = array();
$offset = 0;
$hitCount = $this->Helper()->getSearchLimit();
$requests[] = $this->Helper()->newAutocompleteRequest($term, $hitCount);
$requests = array_merge($requests, $this->createAutocompleteRequests($term, $offset, $hitCount));
$responses = $this->Helper()->autocompleteAll($requests);
$suggestions = $this->Helper()->getAutocompleteSuggestions($responses, $hitCount);
$response = array_shift($responses);
$sResults = $this->getAjaxResult($response);
$router = Shopware()->Front()->Router();
foreach ($sResults as $key => $result) {
$sResults[$key]['name'] = $result['articleName'];
$sResults[$key]['link'] = $router->assemble(array('controller' => 'detail', 'sArticle' => $result['articleID'], 'title' => $result['articleName']));
}
if (version_compare(Shopware::VERSION, '5.0.0', '>=')) {
$this->View()->loadTemplate('frontend/search/ajax.tpl');
$this->View()->addTemplateDir($this->Bootstrap()->Path() . 'Views/');
$this->View()->extendsTemplate('frontend/ajax.tpl');
} else {
$this->View()->addTemplateDir($this->Bootstrap()->Path() . 'Views/');
$this->View()->loadTemplate('frontend/ajax4.tpl');
}
$totalHitCount = count($sResults);
if (isset($response->prefixSearchResult) && isset($response->prefixSearchResult->totalHitCount)) {
$totalHitCount = $response->prefixSearchResult->totalHitCount;
}
if ($totalHitCount == 0) {
$totalHitCount = $suggestions[0]['hits'];
}
$templateProperties = array_merge(array('sSearchRequest' => array('sSearch' => $term), 'sSearchResults' => array('sResults' => $sResults, 'sArticlesCount' => $totalHitCount, 'sSuggestions' => $suggestions), 'bxHasOtherItemTypes' => !empty($responses)), $this->extractAutocompleteTemplateProperties($responses, $hitCount));
if ($this->Config()->get('boxalino_categoryautocomplete_enabled')) {
foreach ($response->propertyResults as $propertyResult) {
if ($propertyResult->name == 'categories') {
$propertyHits = array_map(function ($hit) {
$categoryId = preg_replace('/\\/.*/', '', $hit->label);
$categoryPath = Shopware()->Modules()->Categories()->sGetCategoryPath($categoryId);
return array('value' => $hit->value, 'label' => $hit->label, 'total' => $hit->totalHitCount, 'link' => $categoryPath);
}, $propertyResult->hits);
$templateProperties = array_merge(array('bxCategorySuggestions' => $propertyHits, 'bxCategorySuggestionTotal' => count($propertyHits)), $templateProperties);
break;
}
}
}
$this->View()->assign($templateProperties);
return false;
}
示例6: populate
/**
* populate Source Object with meta data from Resource
*
* @param Smarty_Template_Source $source source object
* @param Smarty_Internal_Template $_template template object
*/
public function populate(Smarty_Template_Source $source, Smarty_Internal_Template $_template = null)
{
Enlight()->Events()->notify('Profiler_Smarty_Render', new Enlight_Event_EventArgs(['name' => $source->name]));
$source->filepath = $this->buildFilepath($source, $_template);
if ($source->filepath !== false) {
if (is_object($source->smarty->security_policy)) {
$source->smarty->security_policy->isTrustedResourceDir($source->filepath);
}
$source->uid = sha1($source->filepath);
if ($source->smarty->compile_check && !isset($source->timestamp)) {
$source->timestamp = @filemtime($source->filepath);
$source->exists = !!$source->timestamp;
}
}
}
示例7: compile
/**
* Compiles code for the {block} tag
*
* @param array $args array with attributes from parser
* @param object $compiler compiler object
* @return boolean true
*/
public function compile($args, $compiler)
{
Enlight()->Events()->notify('Profiler_Smarty_Render_Block');
// check and get attributes
$_attr = $this->getAttributes($compiler, $args);
$save = array($_attr, $compiler->parser->current_buffer, $compiler->nocache, $compiler->smarty->merge_compiled_includes, $compiler->merged_templates, $compiler->smarty->merged_templates_func, $compiler->template->properties, $compiler->template->has_nocache_code);
$this->openTag($compiler, 'block', $save);
if ($_attr['nocache'] == true) {
$compiler->nocache = true;
}
// set flag for {block} tag
$compiler->inheritance = true;
// must merge includes
$compiler->smarty->merge_compiled_includes = true;
$compiler->parser->current_buffer = new _smarty_template_buffer($compiler->parser);
$compiler->has_code = false;
return true;
}
示例8: indexAction
/**
* Index action - get searchterm from request (sSearch) and start search
* @return void
*/
public function indexAction()
{
Enlight()->Plugins()->Controller()->Json()->setPadding();
$this->View()->loadTemplate('frontend/search/ajax.tpl');
$term = $this->Request()->getParam('sSearch');
$term = trim(stripslashes(html_entity_decode($term)));
if (!$term || strlen($term) < Shopware()->Config()->MinSearchLenght) {
return false;
}
/**@var $context ProductContextInterface*/
$context = $this->get('shopware_storefront.context_service')->getProductContext();
$criteria = $this->get('shopware_search.store_front_criteria_factory')->createAjaxSearchCriteria($this->Request(), $context);
/**@var $result ProductSearchResult*/
$result = $this->get('shopware_search.product_search')->search($criteria, $context);
if ($result->getTotalCount() > 0) {
$articles = $this->convertProducts($result);
$this->View()->searchResult = $result;
$this->View()->sSearchRequest = array("sSearch" => $term);
$this->View()->sSearchResults = array("sResults" => $articles, "sArticlesCount" => $result->getTotalCount());
}
}
示例9: doSearch
/**
* Search for $term with shopware default search object
* @param $term
* @return bool Successfully ?
*/
public function doSearch($term)
{
$adapter = Enlight()->Events()->filter('Shopware_Controllers_Frontend_Search_SelectAdapter', null);
if (empty($adapter)) {
$adapter = new Shopware_Components_Search_Adapter_Default(Shopware()->Db(), Shopware()->Cache(), new Shopware_Components_Search_Result_Default(), Shopware()->Config());
}
$search = new Shopware_Components_Search($adapter);
$searchResults = $search->search($term, $this->getConfig());
if ($searchResults !== false) {
$resultCount = $searchResults->getResultCount();
$resultArticles = $searchResults->getResult();
} else {
return false;
}
$basePath = $this->Request()->getScheme() . '://' . $this->Request()->getHttpHost() . $this->Request()->getBasePath();
if (!empty($resultArticles)) {
foreach ($resultArticles as &$result) {
if (empty($result['type'])) {
$result['type'] = 'article';
}
if (!empty($result["mediaId"])) {
/**@var $mediaModel \Shopware\Models\Media\Media*/
$mediaModel = Shopware()->Models()->find('Shopware\\Models\\Media\\Media', $result["mediaId"]);
if ($mediaModel != null) {
$result["thumbNails"] = array_values($mediaModel->getThumbnails());
//deprecated just for the downward compatibility use the thumbNail Array instead
$result["image"] = $result["thumbNails"][1];
}
}
$result['link'] = $this->Front()->Router()->assemble(array('controller' => 'detail', 'sArticle' => $result['articleID'], 'title' => $result['name']));
}
}
// Set result & count of result
$this->setResults($resultArticles);
$this->setCountResults($resultCount);
return true;
}
示例10: doSearch
/**
* Search for $term with shopware default search object
* @param $term
* @return bool Successfully ?
*/
public function doSearch($term)
{
$adapter = Enlight()->Events()->filter('Shopware_Controllers_Frontend_Search_SelectAdapter',null);
if (empty($adapter)){
$adapter = new Shopware_Components_Search_Adapter_Default(Shopware()->Db(), Shopware()->Cache(), new Shopware_Components_Search_Result_Default(), Shopware()->Config());
}
$search = new Shopware_Components_Search($adapter);
$searchResults = $search->search($term, $this->getConfig());
if ($searchResults !== false) {
$resultCount = $searchResults->getResultCount();
$resultArticles = $searchResults->getResult();
} else {
return false;
}
$basePath = $this->Request()->getScheme() . '://' . $this->Request()->getHttpHost() . $this->Request()->getBasePath();
if (!empty($resultArticles)) {
foreach ($resultArticles as &$result) {
if (empty($result['type'])) $result['type'] = 'article';
if (!empty($result['image'])) {
$result['image'] = $basePath
. '/media/image/thumbnail/' . $result['image']
. '_57x57.'
. $result['extension'];
}
$result['link'] = $this->Front()->Router()->assemble(array('controller' => 'detail', 'sArticle' => $result['articleID'], 'title' => $result['name']));
}
}
// Set result & count of result
$this->setResults($resultArticles);
$this->setCountResults($resultCount);
return true;
}
示例11: ajaxLogoutAction
/**
* Logout account by ajax request
*/
public function ajaxLogoutAction()
{
Enlight()->Plugins()->Controller()->Json()->setPadding();
Shopware()->Session()->unsetAll();
$this->refreshBasket();
}
示例12: ajaxListingAction
/**
* listing action for asynchronous fetching listing pages
* by infinite scrolling plugin
*/
public function ajaxListingAction()
{
Enlight()->Plugins()->Controller()->Json()->setPadding();
$categoryId = $this->Request()->getParam('sCategory');
$pageIndex = $this->Request()->getParam('sPage');
$context = $this->get('shopware_storefront.context_service')->getProductContext();
$productStreamId = $this->findStreamIdByCategoryId($categoryId);
if ($productStreamId) {
/** @var \Shopware\Components\ProductStream\CriteriaFactoryInterface $factory */
$factory = $this->get('shopware_product_stream.criteria_factory');
$criteria = $factory->createCriteria($this->Request(), $context);
/** @var \Shopware\Components\ProductStream\RepositoryInterface $streamRepository */
$streamRepository = $this->get('shopware_product_stream.repository');
$streamRepository->prepareCriteria($criteria, $productStreamId);
} else {
$criteria = $this->get('shopware_search.store_front_criteria_factory')->createAjaxListingCriteria($this->Request(), $context);
}
$articles = Shopware()->Modules()->Articles()->sGetArticlesByCategory($categoryId, $criteria);
$articles = $articles['sArticles'];
$this->View()->loadTemplate('frontend/listing/listing_ajax.tpl');
$layout = Shopware()->Modules()->Categories()->getProductBoxLayout($categoryId);
$this->View()->assign(array('sArticles' => $articles, 'pageIndex' => $pageIndex, 'productBoxLayout' => $layout));
}
示例13: __construct
/**
* Constructor
*/
public function __construct($environment, $options = null)
{
Enlight($this);
parent::__construct($environment, $options);
}
示例14: defaultSearchAction
/**
* Default search
*/
public function defaultSearchAction()
{
$term = urldecode(trim(strip_tags(htmlspecialchars_decode(stripslashes($this->Request()->sSearch)))));
// Load search configuration
$config = $this->getSearchConfiguration($term);
// Check if we have a one to one match for ordernumber, then redirect
$location = $this->searchFuzzyCheck($term);
if (!empty($location)) {
return $this->redirect($location);
}
$this->View()->loadTemplate('frontend/search/fuzzy.tpl');
// Prepare links for template
$links = $this->searchDefaultPrepareLinks($config);
$minLengthSearchTerm = Shopware()->Config()->sMINSEARCHLENGHT;
// Check if search term met minimum length
if (strlen($term) >= (int)$minLengthSearchTerm) {
// Configure search adapter
$adapter = Enlight()->Events()->filter('Shopware_Controllers_Frontend_Search_SelectAdapter',null);
if (empty($adapter)){
$adapter = new Shopware_Components_Search_Adapter_Default(Shopware()->Db(), Shopware()->Cache(), new Shopware_Components_Search_Result_Default(), Shopware()->Config());
}
$search = new Shopware_Components_Search($adapter);
// Submit search request
$searchResults = $search->search($term, $config);
// Initiate variables
$resultCount = 0;
$resultArticles = array();
$resultSuppliersAffected = array();
$resultPriceRangesAffected = array();
$resultCurrentCategory = array();
// If search has results
if ($searchResults !== false) {
$resultCount = $searchResults->getResultCount();
$resultArticles = $searchResults->getResult();
$resultSuppliersAffected = $searchResults->getAffectedSuppliers();
$resultPriceRangesAffected = $searchResults->getAffectedPriceRanges();
$resultAffectedCategories = $searchResults->getAffectedCategories();
$resultCurrentCategory = $searchResults->getCurrentCategoryFilter();
}
// Update search statistics
$this->updateSearchStatistics($term, $resultCount);
// Generate page array
$sPages = $this->generatePagesResultArray($resultCount, $config['resultsPerPage'], $config["currentPage"]);
// Get additional information for each search result
$articles = array();
foreach ($resultArticles as $article) {
$article = Shopware()->Modules()->Articles()->sGetPromotionById('fix', 0, (int)$article["articleID"]);
if (!empty($article['articleID'])) {
$articles[] = $article;
}
}
// todo@all Build old template base compatibility array
$resultSmartyArray = array(
'sArticles' => $articles,
'sArticlesCount' => $resultCount,
'sSuppliers' => $resultSuppliersAffected,
'sPrices' => $resultPriceRangesAffected,
'sCategories' => $resultAffectedCategories,
'sLastCategory' => $resultCurrentCategory
);
// Assign result to template
$this->View()->sRequests = $config;
$this->View()->sSearchResults = $resultSmartyArray;
$this->View()->sPerPage = array_values(explode("|", Shopware()->Config()->sFUZZYSEARCHSELECTPERPAGE));
$this->View()->sLinks = $links;
$this->View()->sPages = $sPages;
$this->View()->sPriceFilter = $search->getAdapter()->getPriceRanges();
Enlight()->Events()->notify('Shopware_Controllers_Frontend_Search_ModifySearchResult',array("subject" => $this,"search"=>$search,"result"=>$searchResults));
$this->View()->sCategoriesTree = $this->getCategoryTree(
$resultCurrentCategory, $config['restrictSearchResultsToCategory']
);
}
}
示例15: exportOrder
//.........这里部分代码省略.........
$itemText = null;
}
}
// Coupon
if ($Item->getMode() == 2) {
$itemId = -1;
$rowType = 'Coupon';
}
// Additional coupon identifiers für 3rd party plugins
$couponIdentifiers = PyConf()->get('OrderAdditionalCouponIdentifiers', '');
$couponIdentifiers = explode('|', $couponIdentifiers);
if (in_array($number, $couponIdentifiers)) {
$itemId = -1;
$rowType = 'Coupon';
} else {
// PAYONE fix
if ($number == 'SHIPPING' && !$Object_OrderHead->ShippingCosts) {
$Object_OrderHead->ShippingCosts = $Item->getPrice();
continue;
}
$discountNumber = Shopware()->Config()->get('discountnumber');
$surchargeNumber = Shopware()->Config()->get('surchargenumber');
$paymentSurchargeNumber = Shopware()->Config()->get('paymentsurchargenumber');
$paymentSurchargeAbsoluteNumber = Shopware()->Config()->get('paymentSurchargeAbsoluteNumber');
$shippingDiscountNumber = Shopware()->Config()->get('shippingdiscountnumber');
switch ($number) {
case $paymentSurchargeNumber:
case $paymentSurchargeAbsoluteNumber:
$rowType = 'SurchargeForPaymentMethod';
break;
case $discountNumber:
$rowType = 'Discount';
break;
case $surchargeNumber:
$rowType = 'Surcharge';
break;
case $shippingDiscountNumber:
$rowType = 'SurchargeForShippingMethod';
break;
default:
$rowType = 'Default';
break;
}
}
if ($isOrderNet) {
// Calculate the gross amount (needed by plentymakets even though it is a net sales order)
$itemPrice = $Item->getPrice() * ((100 + (double) $Item->getTaxRate()) / 100);
} else {
$itemPrice = $Item->getPrice();
}
$Object_OrderItem = new PlentySoapObject_OrderItem();
$Object_OrderItem->ExternalOrderItemID = $number;
$Object_OrderItem->ItemID = $itemId;
$Object_OrderItem->ReferrerID = $Object_OrderHead->ReferrerID;
$Object_OrderItem->ItemText = $itemText;
$Object_OrderItem->Price = $itemPrice;
$Object_OrderItem->Quantity = $Item->getQuantity();
$Object_OrderItem->SKU = $sku;
$Object_OrderItem->VAT = $Item->getTaxRate();
$Object_OrderItem->RowType = $rowType;
$Object_Order->OrderItems[] = $Object_OrderItem;
}
$Request_AddOrders->Orders[] = $Object_Order;
// Allow plugins to change the data
$Request_AddOrders = Enlight()->Events()->filter('PlentyConnector_ExportEntityOrder_BeforeAddOrders', $Request_AddOrders, array('subject' => $this, 'order' => $this->Order));
// Do the request
$Response_AddOrders = PlentymarketsSoapClient::getInstance()->AddOrders($Request_AddOrders);
if (!$Response_AddOrders->Success) {
// Set the error end quit
$this->setError(self::CODE_ERROR_SOAP);
throw new PlentymarketsExportEntityException('The order with the number »' . $this->Order->getNumber() . '« could not be exported', 4010);
}
//
$plentyOrderID = null;
$plentyOrderStatus = 0.0;
foreach ($Response_AddOrders->ResponseMessages->item[0]->SuccessMessages->item as $SuccessMessage) {
switch ($SuccessMessage->Key) {
case 'OrderID':
$plentyOrderID = (int) $SuccessMessage->Value;
break;
case 'Status':
$plentyOrderStatus = (double) $SuccessMessage->Value;
break;
}
}
if ($plentyOrderID && $plentyOrderStatus) {
$this->setSuccess($plentyOrderID, $plentyOrderStatus);
} else {
// Set the error end quit
$this->setError(self::CODE_ERROR_SOAP);
throw new PlentymarketsExportEntityException('The order with the number »' . $this->Order->getNumber() . '« could not be exported (no order id or order status respectively)', 4020);
}
$paymentStatusPaid = explode('|', PlentymarketsConfig::getInstance()->getOrderPaidStatusID(12));
// Directly book the incoming payment
if ($this->Order->getPaymentStatus() && in_array($this->Order->getPaymentStatus()->getId(), $paymentStatusPaid)) {
// May throw an exception
$IncomingPayment = new PlentymarketsExportEntityOrderIncomingPayment($this->Order->getId());
$IncomingPayment->book();
}
}
开发者ID:jochenmanz,项目名称:plentymarkets-shopware-connector,代码行数:101,代码来源:PlentymarketsExportEntityOrder.php