作者:Cloudrex
项目:cloudrex
/**
* Use this to parse your backend page
*
* You will get the template located in /View/Template/{CMD}.html
* You can access Cx class using $this->cx
* To show messages, use \Message class
*
* @param \Cx\Core\Html\Sigma $template Template for current CMD
* @param array $cmd CMD separated by slashes
*/
public function parsePage(\Cx\Core\Html\Sigma $template, array $cmd)
{
$uploader = new Uploader();
$uploader->setFinishedCallback('\\Cx\\Core_Modules\\Uploader\\Model\\DefaultUploadCallback');
$uploader->setCallback('gallery.uploader');
$template->setVariable('UPLOADER_CODE', $uploader->getXHtml('Open Uploader 1'));
$uploader2 = new Uploader();
$uploader2->setUploadLimit(1);
$uploader2->setFinishedCallback('\\Cx\\Core_Modules\\Uploader\\Model\\DefaultUploadCallback');
$uploader2->setCallback('gallery.uploader2');
$uploader2->setType(Uploader::UPLOADER_TYPE_INLINE);
$template->setVariable('UPLOADER_CODE2', $uploader2->getXHtml('Open Uploader 2'));
$configurations = array(array(), array('startview' => 'sitestructure', 'views' => 'sitestructure'), array('views' => 'uploader'), array('views' => 'sitestructure'), array('views' => 'filebrowser'), array('startmediatype' => 'gallery'), array('mediatypes' => 'gallery, files'), array('multipleselect' => true), array('data-cx-Mb-Cb-Js-modalopened' => 'testfunction'));
foreach ($configurations as $configuration) {
$mediaBrowser = new MediaBrowser();
$mediaBrowser->setOptions($configuration);
$mediaBrowser->setCallback('gallery.fancyCallback');
$template->setVariable('MEDIABROWSER_CODE', $mediaBrowser->getXHtml('MediaBrowser'));
$template->setVariable('MEDIABROWSER_OPTIONS', var_export($configuration, true));
$template->setVariable('MEDIABROWSER_CODE_RAW', htmlspecialchars($mediaBrowser->getXHtml('MediaBrowser')));
$template->parse('mediabrowser_demo');
}
$template->setVariable('MEDIABROWSER_FOLDER_WIDGET', new \Cx\Core_Modules\MediaBrowser\Model\Entity\FolderWidget($this->cx->getWebsiteImagesContentPath()));
$template->setVariable('MEDIABROWSER_FOLDER_WIDGET_VIEW_MODE', new \Cx\Core_Modules\MediaBrowser\Model\Entity\FolderWidget($this->cx->getWebsiteImagesContentPath(), true));
}
作者:hbdskl
项目:LimeCM
/**
* Render the option in the frontend.
*
* @param Sigma $template
*/
public function renderTheme($template)
{
$blockName = strtolower('TEMPLATE_EDITOR_' . $this->name);
if ($template->blockExists($blockName) && $this->active) {
$template->touchBlock($blockName);
}
}
作者:Cloudrex
项目:cloudrex
/**
* Parses a rudimentary system log backend page
* @param \Cx\Core\Html\Sigma $template Backend template for this page
* @param array $cmd Supplied CMD
*/
public function parsePage(\Cx\Core\Html\Sigma $template, array $cmd)
{
$em = $this->cx->getDb()->getEntityManager();
$logRepo = $em->getRepository('Cx\\Core_Modules\\SysLog\\Model\\Entity\\Log');
// @todo: parse message if no entries (template block exists already)
$parseObject = $this->getNamespace() . '\\Model\\Entity\\Log';
// set default sorting
if (!isset($_GET['order'])) {
$_GET['order'] = 'timestamp/DESC';
}
// configure view
$viewGenerator = new \Cx\Core\Html\Controller\ViewGenerator('Cx\\Core_Modules\\SysLog\\Model\\Entity\\Log', $this->getAllViewGeneratorOptions());
$template->setVariable('ENTITY_VIEW', $viewGenerator);
}
作者:nahakiol
项目:cloudrex
/**
* Show the shadowbox
*/
function shadowbox()
{
global $objDatabase, $_ARRAYLANG, $objInit;
$id = intval($_GET['id']);
$lang = intval($_GET['lang']);
$entries = $this->createEntryArray();
$entry = $entries[$id];
$settings = $this->createSettingsArray();
$title = $entry['translation'][$lang]['subject'];
$content = $entry['translation'][$lang]['content'];
$picture = !empty($entry['translation'][$lang]['image']) ? $entry['translation'][$lang]['image'] : "none";
$this->_objTpl = new \Cx\Core\Html\Sigma(ASCMS_THEMES_PATH);
\Cx\Core\Csrf\Controller\Csrf::add_placeholder($this->_objTpl);
$this->_objTpl->setCurrentBlock("shadowbox");
$objResult = $objDatabase->SelectLimit("\n SELECT foldername\n FROM " . DBPREFIX . "skins\n WHERE id='{$objInit->currentThemesId}'", 1);
if ($objResult !== false) {
$themesPath = $objResult->fields['foldername'];
}
$template = preg_replace('/\\[\\[([A-Z_]+)\\]\\]/', '{$1}', $settings['data_template_shadowbox']);
$this->_objTpl->setTemplate($template);
if ($entry['translation'][$lang]['attachment']) {
$this->_objTpl->setVariable(array("HREF" => $entry['translation'][$lang]['attachment'], "TXT_DOWNLOAD" => empty($entry['translation'][$lang]['attachment_desc']) ? $_ARRAYLANG['TXT_DATA_DOWNLOAD_ATTACHMENT'] : $entry['translation'][$lang]['attachment_desc']));
$this->_objTpl->parse("attachment");
}
$this->_objTpl->setVariable(array("TITLE" => $title, "CONTENT" => $content, "PICTURE" => $picture, "THEMES_PATH" => $themesPath));
if ($picture != "none") {
$this->_objTpl->parse("image");
} else {
$this->_objTpl->hideBlock("image");
}
$this->_objTpl->parse("shadowbox");
$this->_objTpl->show();
die;
}
作者:nahakiol
项目:cloudrex
/**
* Parses a rudimentary system log backend page
* @param \Cx\Core\Html\Sigma $template Backend template for this page
* @param array $cmd Supplied CMD
*/
public function parsePage(\Cx\Core\Html\Sigma $template, array $cmd)
{
$em = $this->cx->getDb()->getEntityManager();
$logRepo = $em->getRepository('Cx\\Core_Modules\\SysLog\\Model\\Entity\\Log');
// @todo: parse message if no entries (template block exists already)
$parseObject = $this->getNamespace() . '\\Model\\Entity\\Log';
// set default sorting
if (!isset($_GET['order'])) {
$_GET['order'] = 'timestamp/DESC';
}
// configure view
$viewGenerator = new \Cx\Core\Html\Controller\ViewGenerator($parseObject, array('functions' => array('delete' => 'true', 'paging' => true, 'sorting' => true, 'edit' => true), 'fields' => array('id' => array('showOverview' => false), 'timestamp' => array('readonly' => true), 'severity' => array('readonly' => true, 'table' => array('parse' => function ($data, $rows) {
return '<span class="' . contrexx_raw2xhtml(strtolower($data)) . '_background">' . contrexx_raw2xhtml($data) . '</span>';
})), 'message' => array('readonly' => true, 'table' => array('parse' => function ($data, $rows) {
$url = clone \Cx\Core\Routing\Url::fromRequest();
$url->setMode('backend');
$url->setParam('editid', $rows['id']);
return '<a href="' . $url . '">' . contrexx_raw2xhtml($data) . '</a>';
})), 'data' => array('readonly' => true, 'showOverview' => false, 'type' => 'text'), 'logger' => array('readonly' => true))));
$template->setVariable('ENTITY_VIEW', $viewGenerator);
}
作者:nahakiol
项目:cloudrex
/**
* Use this to parse your backend page
*
* You will get the template located in /View/Template/{CMD}.html
* You can access Cx class using $this->cx
* To show messages, use \Message class
*
* @param \Cx\Core\Html\Sigma $template Template for current CMD
* @param array $cmd CMD separated by slashes
*/
public function parsePage(\Cx\Core\Html\Sigma $template, array $cmd)
{
$uploader = new Uploader();
$uploader->setFinishedCallback('\\Cx\\Core_Modules\\Uploader\\Model\\DefaultUploadCallback');
$uploader->setCallback('gallery.uploader');
$template->setVariable('UPLOADER_CODE', $uploader->getXHtml('Open Uploader 1'));
$uploader2 = new Uploader();
$uploader2->setFinishedCallback('\\Cx\\Core_Modules\\Uploader\\Model\\DefaultUploadCallback');
$uploader2->setCallback('gallery.uploader2');
$uploader2->setType(Uploader::UPLOADER_TYPE_INLINE);
$template->setVariable('UPLOADER_CODE2', $uploader2->getXHtml('Open Uploader 2'));
$mediaBrowser = new MediaBrowser();
$mediaBrowser->setCallback('gallery.fancyCallback');
$template->setVariable('MEDIABROWSER_CODE1', $mediaBrowser->getXHtml('MediaBrowser'));
$template->setVariable('MEDIABROWSER_CODE1_RAW', htmlspecialchars($mediaBrowser->getXHtml('MediaBrowser')));
$template->setVariable('MEDIABROWSER_FOLDER_WIDGET', new \Cx\Core_Modules\MediaBrowser\Model\Entity\FolderWidget($this->cx->getWebsiteImagesContentPath()));
$template->setVariable('MEDIABROWSER_FOLDER_WIDGET_VIEW_MODE', new \Cx\Core_Modules\MediaBrowser\Model\Entity\FolderWidget($this->cx->getWebsiteImagesContentPath(), true));
}
作者:Cloudrex
项目:cloudrex
/**
* Use this to parse your backend page
*
* You will get the template located in /View/Template/{CMD}.html
* You can access Cx class using $this->cx
* To show messages, use \Message class
* @param \Cx\Core\Html\Sigma $template Template for current CMD
* @param array $cmd CMD separated by slashes
*/
public function parsePage(\Cx\Core\Html\Sigma $template, array $cmd)
{
global $_ARRAYLANG, $objInit;
$objTpl = new \Cx\Core\Html\Sigma($this->getDirectory(true) . '/View/Template/Backend');
//merge language
$langData = $objInit->loadLanguageData('Pdf');
$_ARRAYLANG = array_merge($_ARRAYLANG, $langData);
$objTpl->setGlobalVariable($_ARRAYLANG);
$objTpl->loadTemplatefile('Default.html');
// Not an entity, parse overview or settings
switch (current($cmd)) {
default:
// Parse entity view generation pages
$entityClassName = $this->getNamespace() . '\\Model\\Entity\\PdfTemplate';
$this->parseEntityClassPage($objTpl, $entityClassName, 'PdfTemplate');
if ($objTpl->blockExists('overview')) {
$objTpl->touchBlock('overview');
}
break;
}
\JS::registerCSS(substr($this->getDirectory(false, true) . '/View/Style/Backend.css', 1));
$template->setVariable(array('CONTENT_TITLE' => $_ARRAYLANG['TXT_CORE_MODULE_PDF'], 'ADMIN_CONTENT' => $objTpl->get()));
}
作者:Cloudrex
项目:cloudrex
/**
* Do something before main template gets parsed
*
* @param \Cx\Core\Html\Sigma $template The main template
*/
public function preFinalize(\Cx\Core\Html\Sigma $template)
{
if ($this->cx->getMode() != \Cx\Core\Core\Controller\Cx::MODE_FRONTEND) {
return;
}
// make all language data of Access component globally available
$template->setVariable(\Env::get('init')->getComponentSpecificLanguageData($this->getName()));
}
作者:Cloudrex
项目:cloudrex
/**
* parse the settings dropdown
*
* @param object $objTemplate template object
* @param array $settingValues array of setting values
* @param string $selected selected dropdown value
* @param string $blockName block name for template parsing
*
* @return null
*/
public function parseSettingsDropDown(\Cx\Core\Html\Sigma $objTemplate, $settingValues, $selected, $blockName)
{
global $_ARRAYLANG;
if (empty($settingValues)) {
return;
}
foreach (array_keys($settingValues) as $key) {
$selectedOption = $selected == $key ? 'selected="selected"' : '';
$objTemplate->setVariable(array('DOWNLOADS_SETTINGS_DROPDOWN_OPTION_VALUE' => $key, 'DOWNLOADS_SETTINGS_DROPDOWN_OPTION_NAME' => $_ARRAYLANG['TXT_DOWNLOADS_SETTINGS_' . strtoupper($key) . '_LABEL'], 'DOWNLOADS_SETTINGS_DROPDOWN_SELECTED_OPTION' => $selectedOption));
$objTemplate->parse('downloads_settings_sorting_dropdown_' . $blockName);
}
}
作者:nahakiol
项目:cloudrex
/**
* Parsing the related News
*
* @global object $objDatabase
* @global type $_ARRAYLANG
*
* @param Object $objTpl Template Object
* @param Interger $newsId News Id
* @param Interger $langId Language id
* @param type $blockName Block Name
* @param type $limit Limit
*
* @return null
*/
public function parseRelatedNews(\Cx\Core\Html\Sigma $objTpl, $newsId = null, $langId = null, $blockName = 'related_news', $limit = 0)
{
global $_ARRAYLANG, $objDatabase;
if (empty($newsId) || !$objTpl->blockExists($blockName)) {
return;
}
//Getting the related news ids
$relatedNewsIds = $this->getRelatedNews($newsId);
$defaultLangId = \FWLanguage::getDefaultLangId();
//Getting the related news details for the given languages
$relatedNewsDetails = $this->getRelatedNewsDetails($relatedNewsIds, array($langId, $defaultLangId));
if (!empty($relatedNewsDetails)) {
$defaultImage = \Cx\Core\Core\Controller\Cx::instanciate()->getCodeBaseCoreModulePath() . '/News/View/Media/default_news_image.png';
$currentCount = 1;
foreach ($relatedNewsIds as $relatedNewsId) {
//If the limit is reached then the loop is stopped
if (!empty($limit) && $currentCount > $limit) {
break;
}
/*
* Checking the related news is available in the current
* acitve front-end language if not available then the default
* language details are getting used
* Comment/Uncomment the following line if this condition
* is required
*/
//$currentRelatedDetails = isset($relatedNewsDetails[$relatedNewsId][$langId])
// ? $relatedNewsDetails[$relatedNewsId][$langId]
// : $relatedNewsDetails[$relatedNewsId][$defaultLangId];
/*
* Checking the related news is available in the current
* acitve front-end language if not available then the related
* News not listed Comment/Uncomment the following
* line if this condition is required
*/
$currentRelatedDetails = isset($relatedNewsDetails[$relatedNewsId][$langId]) ? $relatedNewsDetails[$relatedNewsId][$langId] : false;
if (!$currentRelatedDetails) {
continue;
}
++$currentCount;
$categories = $this->getCategoriesByNewsId($relatedNewsId);
$newsUrl = empty($currentRelatedDetails['redirect']) ? empty($currentRelatedDetails['newscontent']) ? '' : \Cx\Core\Routing\Url::fromModuleAndCmd('news', $this->findCmdById('details', array_keys($categories)), FRONTEND_LANG_ID, array('newsid' => $relatedNewsId)) : $currentRelatedDetails['redirect'];
$newstitle = $currentRelatedDetails['title'];
$htmlLink = self::parseLink($newsUrl, $newstitle, contrexx_raw2xhtml('[' . $_ARRAYLANG['TXT_NEWS_MORE'] . '...]'));
$htmlLinkTitle = self::parseLink($newsUrl, $newstitle, contrexx_raw2xhtml($newstitle));
// in case that the message is a stub,
// we shall just display the news title instead of a html-a-tag
// with no href target
if (empty($htmlLinkTitle)) {
$htmlLinkTitle = contrexx_raw2xhtml($newstitle);
}
$imagePath = !empty($currentRelatedDetails['teaser_image_path']) ? $currentRelatedDetails['teaser_image_path'] : $defaultImage;
$imageThumbPath = !empty($currentRelatedDetails['teaser_image_thumbnail_path']) ? $currentRelatedDetails['teaser_image_thumbnail_path'] : $defaultImage;
$this->parseImageBlock($objTpl, $imagePath, $newstitle, $newsUrl, 'related_news_image');
$this->parseImageBlock($objTpl, $imageThumbPath, $newstitle, $newsUrl, 'related_news_image_thumb');
$author = \FWUser::getParsedUserTitle($currentRelatedDetails['author_id'], $currentRelatedDetails['author']);
$publisher = \FWUser::getParsedUserTitle($currentRelatedDetails['publisher_id'], $currentRelatedDetails['publisher']);
$objSubResult = $objDatabase->Execute('
SELECT count(`id`) AS `countComments`
FROM `' . DBPREFIX . 'module_news_comments`
WHERE `newsid` = ' . $relatedNewsId);
$objTpl->setVariable(array('NEWS_RELATED_NEWS_ID' => contrexx_raw2xhtml($relatedNewsId), 'NEWS_RELATED_NEWS_URL' => contrexx_raw2xhtml($newsUrl), 'NEWS_RELATED_NEWS_LINK' => $htmlLink, 'NEWS_RELATED_NEWS_TITLE' => contrexx_raw2xhtml($currentRelatedDetails['title']), 'NEWS_RELATED_NEWS_TITLE_SHORT' => strlen($currentRelatedDetails['title']) > 35 ? substr(strip_tags($currentRelatedDetails['title']), 0, 35) . '...' : strip_tags($currentRelatedDetails['title']), 'NEWS_RELATED_NEWS_TITLE_LINK' => $htmlLinkTitle, 'NEWS_RELATED_NEWS_TEXT' => $currentRelatedDetails['text'], 'NEWS_RELATED_NEWS_TEXT_SHORT' => strlen($currentRelatedDetails['text']) > 250 ? substr(strip_tags($currentRelatedDetails['text']), 0, 247) . '...' : strip_tags($currentRelatedDetails['text']), 'NEWS_RELATED_NEWS_TEASER_TEXT' => nl2br($currentRelatedDetails['teaser_text']), 'NEWS_RELATED_NEWS_AUTHOR' => contrexx_raw2xhtml($author), 'NEWS_RELATED_NEWS_PUBLISHER' => contrexx_raw2xhtml($publisher), 'NEWS_RELATED_NEWS_CATEGORY_NAMES' => implode(', ', contrexx_raw2xhtml($categories)), 'NEWS_RELATED_NEWS_LONG_DATE' => date(ASCMS_DATE_FORMAT, $currentRelatedDetails['newsdate']), 'NEWS_RELATED_NEWS_DATE' => date(ASCMS_DATE_FORMAT_DATE, $currentRelatedDetails['newsdate']), 'NEWS_RELATED_NEWS_TIME' => date(ASCMS_DATE_FORMAT_TIME, $currentRelatedDetails['newsdate']), 'NEWS_RELATED_NEWS_COUNT_COMMENTS' => $currentRelatedDetails['commentactive'] && $this->arrSettings['news_comments_activated'] ? contrexx_raw2xhtml($objSubResult->fields['countComments'] . ' ' . $_ARRAYLANG['TXT_NEWS_COMMENTS']) : ''));
if (!$objSubResult->fields['countComments'] || !$this->arrSettings['news_comments_activated']) {
if ($objTpl->blockExists('related_news_comments_count')) {
$objTpl->hideBlock('related_news_comments_count');
}
}
if ($this->arrSettings['news_use_teaser_text'] != '1' && $objTpl->blockExists('news_use_teaser_text')) {
$objTpl->hideBlock('news_use_teaser_text');
}
$objTpl->parse($blockName);
}
if ($objTpl->blockExists('related_news_block')) {
$objTpl->setVariable('TXT_NEWS_RELATED_NEWS', $_ARRAYLANG['TXT_NEWS_RELATED_NEWS']);
$objTpl->touchBlock('related_news_block');
}
}
}
作者:Cloudrex
项目:cloudrex
/**
* Set the registration fields placeholders to the template
*
* @param \Cx\Core\Html\Sigma $objTpl Template instance
* @param integer $regId Registration id
*/
function showRegistrationInputfields(\Cx\Core\Html\Sigma $objTpl, $regId = null)
{
global $_LANGID, $_ARRAYLANG;
$i = 0;
$objForm = new \Cx\Modules\Calendar\Controller\CalendarForm($this->formId);
$objRegistration = new \Cx\Modules\Calendar\Controller\CalendarRegistration($this->formId, $regId);
// parse the registration type for the add/edit subscription
$regType = isset($_POST['registrationType']) ? (int) $_POST['registrationType'] : (!empty($regId) ? $objRegistration->type : 1);
$regTypeField = '<select style="width: 208px;" class="calendarSelect" name="registrationType">
<option value="1" ' . ($regType == 1 ? "selected='selected'" : '') . ' />' . $_ARRAYLANG['TXT_CALENDAR_REG_REGISTRATION'] . '</option>
<option value="0" ' . ($regType == 0 ? "selected='selected'" : '') . ' />' . $_ARRAYLANG['TXT_CALENDAR_REG_SIGNOFF'] . '</option>
<option value="2" ' . ($regType == 2 ? "selected='selected'" : '') . ' />' . $_ARRAYLANG['TXT_CALENDAR_REG_WAITLIST'] . '</option>
</select>';
$objTpl->setVariable(array($this->moduleLangVar . '_ROW' => $i % 2 == 0 ? 'row1' : 'row2', $this->moduleLangVar . '_REGISTRATION_INPUTFIELD_NAME' => $_ARRAYLANG['TXT_CALENDAR_TYPE'], $this->moduleLangVar . '_REGISTRATION_INPUTFIELD_VALUE' => $regTypeField));
$objTpl->parse('calendar_registration_inputfield');
$i++;
if ($this->event && $this->event->seriesStatus && $this->event->independentSeries) {
$endDate = new \DateTime();
$endDate->modify('+10 years');
$eventManager = new CalendarEventManager(null, $endDate);
$objEvent = new \Cx\Modules\Calendar\Controller\CalendarEvent($this->event->id);
if ($eventManager->_addToEventList($objEvent)) {
$eventManager->eventList[] = $objEvent;
}
$eventManager->_setNextSeriesElement($objEvent);
$regEventDateField = '<select style="width: 208px;" class="calendarSelect" name="registrationEventDate">';
foreach ($eventManager->eventList as $event) {
$selectedDate = $objRegistration->eventDate == $event->startDate->getTimestamp() ? 'selected="selected"' : '';
$regEventDateField .= '<option value="' . $event->startDate->getTimestamp() . '" ' . $selectedDate . ' />' . $this->format2userDate($event->startDate) . '</option>';
}
$regEventDateField .= '</select>';
$objTpl->setVariable(array($this->moduleLangVar . '_ROW' => $i % 2 == 0 ? 'row1' : 'row2', $this->moduleLangVar . '_REGISTRATION_INPUTFIELD_NAME' => $_ARRAYLANG['TXT_CALENDAR_DATE_OF_THE_EVENT'], $this->moduleLangVar . '_REGISTRATION_INPUTFIELD_VALUE' => $regEventDateField));
$objTpl->parse('calendar_registration_inputfield');
$i++;
}
foreach ($objForm->inputfields as $arrInputfield) {
$inputfield = '';
$options = explode(',', $arrInputfield['default_value'][$_LANGID]);
$optionSelect = true;
if (isset($_POST['registrationField'][$arrInputfield['id']])) {
$value = $_POST['registrationField'][$arrInputfield['id']];
} else {
$value = $regId != null ? $objRegistration->fields[$arrInputfield['id']]['value'] : '';
}
switch ($arrInputfield['type']) {
case 'inputtext':
case 'mail':
case 'firstname':
case 'lastname':
$inputfield = '<input style="width: 200px;" type="text" class="calendarInputText" name="registrationField[' . $arrInputfield['id'] . ']" value="' . $value . '" />';
break;
case 'textarea':
$inputfield = '<textarea style="width: 196px;" class="calendarTextarea" name="registrationField[' . $arrInputfield['id'] . ']">' . $value . '</textarea>';
break;
case 'seating':
$optionSelect = false;
case 'select':
case 'salutation':
$inputfield = '<select style="width: 208px;" class="calendarSelect" name="registrationField[' . $arrInputfield['id'] . ']">';
$selected = empty($_POST) ? 'selected="selected"' : '';
$inputfield .= $optionSelect ? '<option value="" ' . $selected . '>' . $_ARRAYLANG['TXT_CALENDAR_PLEASE_CHOOSE'] . '</option>' : '';
foreach ($options as $key => $name) {
$selected = $key + 1 == $value ? 'selected="selected"' : '';
$inputfield .= '<option value="' . intval($key + 1) . '" ' . $selected . '>' . $name . '</option>';
}
$inputfield .= '</select>';
break;
case 'radio':
$arrValue = explode('[[', $value);
$value = $arrValue[0];
$input = str_replace(']]', '', $arrValue[1]);
foreach ($options as $key => $name) {
$checked = $key + 1 == $value || in_array($key + 1, $_POST['registrationField'][$arrInputfield['id']]) ? 'checked="checked"' : '';
$textfield = '<input type="text" class="calendarInputCheckboxAdditional" name="registrationFieldAdditional[' . $arrInputfield['id'] . '][' . $key . ']" value="' . ($checked ? $input : '') . '" />';
$name = str_replace('[[INPUT]]', $textfield, $name);
$inputfield .= '<input type="radio" class="calendarInputCheckbox" name="registrationField[' . $arrInputfield['id'] . ']" value="' . intval($key + 1) . '" ' . $checked . '/> ' . $name . '<br />';
}
break;
case 'checkbox':
$results = explode(',', $value);
foreach ($results as $result) {
list($value, $input) = explode('[[', $result);
$value = !empty($value) ? $value : 0;
$input = str_replace(']]', '', $input);
$newResult[$value] = $input;
}
foreach ($options as $key => $name) {
$checked = array_key_exists($key + 1, $newResult) || in_array($key + 1, $_POST['registrationField'][$arrInputfield['id']]) ? 'checked="checked"' : '';
$textfield = '<input type="text" class="calendarInputCheckboxAdditional" name="registrationFieldAdditional[' . $arrInputfield['id'] . '][' . $key . ']" value="' . ($checked ? $newResult[$key + 1] : '') . '" />';
$name = str_replace('[[INPUT]]', $textfield, $name);
$inputfield .= '<input ' . $checked . ' type="checkbox" class="calendarInputCheckbox" name="registrationField[' . $arrInputfield['id'] . '][]" value="' . intval($key + 1) . '" /> ' . $name . '<br />';
}
break;
case 'agb':
//.........这里部分代码省略.........
作者:nahakiol
项目:cloudrex
/**
* @param Sigma $template
*/
public function preFinalize(Sigma $template)
{
if (count($this->mediaBrowserInstances) == 0) {
return;
} else {
global $_ARRAYLANG;
/**
* @var $init \InitCMS
*/
$init = \Env::get('init');
$init->loadLanguageData('MediaBrowser');
foreach ($_ARRAYLANG as $key => $value) {
if (preg_match("/TXT_FILEBROWSER_[A-Za-z0-9]+/", $key)) {
\ContrexxJavascript::getInstance()->setVariable($key, $value, 'mediabrowser');
}
}
$thumbnailsTemplate = new Sigma();
$thumbnailsTemplate->loadTemplateFile($this->cx->getCoreModuleFolderName() . '/MediaBrowser/View/Template/Thumbnails.html');
$thumbnailsTemplate->setVariable('TXT_FILEBROWSER_THUMBNAIL_ORIGINAL_SIZE', sprintf($_ARRAYLANG['TXT_FILEBROWSER_THUMBNAIL_ORIGINAL_SIZE']));
foreach (UploaderConfiguration::getInstance()->getThumbnails() as $thumbnail) {
$thumbnailsTemplate->setVariable(array('THUMBNAIL_NAME' => sprintf($_ARRAYLANG['TXT_FILEBROWSER_THUMBNAIL_' . strtoupper($thumbnail['name']) . '_SIZE'], $thumbnail['size']), 'THUMBNAIL_ID' => $thumbnail['id'], 'THUMBNAIL_SIZE' => $thumbnail['size']));
$thumbnailsTemplate->parse('thumbnails');
}
\ContrexxJavascript::getInstance()->setVariable('thumbnails_template', $thumbnailsTemplate->get(), 'mediabrowser');
\JS::activate('mediabrowser');
\JS::registerJS('core_modules/MediaBrowser/View/Script/mediabrowser.js');
}
}
作者:Nigg
项目:cloudrex
/**
* Edit coupons
* @param \Cx\Core\Html\Sigma $objTemplate The Template
*/
static function edit($objTemplate)
{
global $_ARRAYLANG;
//DBG::activate(DBG_ADODB|DBG_LOG_FIREPHP|DBG_PHP);
$result = true;
if (isset($_GET['delete'])) {
list($code, $customer_id) = explode('-', $_GET['delete']);
$result &= self::delete(contrexx_input2raw($code), intval($customer_id));
}
$edit = isset($_REQUEST['edit']) ? contrexx_input2raw($_REQUEST['edit']) : null;
//DBG::log("Edit: ".($edit ? $edit : 'NULL'));
$code = isset($_POST['code']) ? contrexx_input2raw($_POST['code']) : null;
$payment_id = empty($_POST['payment_id']) ? 0 : intval($_POST['payment_id']);
$start_time = empty($_POST['start_date']) ? 0 : strtotime(contrexx_input2raw($_POST['start_date']));
$end_time = empty($_POST['end_date_unlimited']) ? empty($_POST['end_date']) ? 0 : strtotime(contrexx_input2raw($_POST['end_date'])) : 0;
$coupon_type = empty($_POST['coupon_type']) ? null : contrexx_input2raw($_POST['coupon_type']);
$discount_rate = intval(empty($_POST['discount_rate']) ? 0 : floatval($_POST['discount_rate']));
$discount_amount = Currency::formatPrice(empty($_POST['discount_amount']) ? 0 : floatval($_POST['discount_amount']));
if ($coupon_type == 'rate') {
$discount_amount = 0;
}
if ($coupon_type == 'amount') {
$discount_rate = 0;
}
$minimum_amount = Currency::formatPrice(empty($_POST['minimum_amount']) ? 0 : floatval($_POST['minimum_amount']));
$uses = empty($_POST['unlimited']) ? empty($_POST['uses']) ? 1 : intval($_POST['uses']) : self::USES_UNLIMITED;
$customer_id = empty($_POST['customer_id']) ? 0 : intval($_POST['customer_id']);
$product_id = empty($_POST['product_id']) ? 0 : intval($_POST['product_id']);
$global = !empty($_POST['global_or_customer']);
//DBG::log("code $code, start_time $start_time, end_time $end_time, minimum amount $minimum_amount, discount_rate $discount_rate, discount_amount $discount_amount, uses $uses, customer_id $customer_id");
if (isset($code)) {
$result &= self::storeCode($code, $payment_id, $minimum_amount, $discount_rate, $discount_amount, $start_time, $end_time, $uses, $global, $customer_id, $product_id, $edit);
if ($result) {
$code = $edit = null;
} else {
if (empty($edit)) {
$edit = "{$code}-{$customer_id}";
}
}
}
// Reset the end time if it's in the past
if ($end_time < time()) {
$end_time = 0;
}
$uri = \Html::getRelativeUri();
\Html::stripUriParam($uri, 'view');
\Html::stripUriParam($uri, 'edit');
\Html::stripUriParam($uri, 'order_coupon');
$arrSortingFields = array('code' => $_ARRAYLANG['TXT_SHOP_DISCOUNT_COUPON_CODE'], 'start_time' => $_ARRAYLANG['TXT_SHOP_DISCOUNT_COUPON_START_TIME'], 'end_time' => $_ARRAYLANG['TXT_SHOP_DISCOUNT_COUPON_END_TIME'], 'minimum_amount' => sprintf($_ARRAYLANG['TXT_SHOP_DISCOUNT_COUPON_MINIMUM_AMOUNT_FORMAT'], Currency::getDefaultCurrencyCode()), 'discount_rate' => $_ARRAYLANG['TXT_SHOP_DISCOUNT_COUPON_RATE'], 'discount_amount' => sprintf($_ARRAYLANG['TXT_SHOP_DISCOUNT_COUPON_AMOUNT_FORMAT'], Currency::getDefaultCurrencyCode()), 'uses' => $_ARRAYLANG['TXT_SHOP_DISCOUNT_COUPON_USES'], 'global' => $_ARRAYLANG['TXT_SHOP_DISCOUNT_COUPON_SCOPE'], 'customer_id' => $_ARRAYLANG['TXT_SHOP_DISCOUNT_COUPON_CUSTOMER'], 'product_id' => $_ARRAYLANG['TXT_SHOP_DISCOUNT_COUPON_PRODUCT'], 'payment_id' => $_ARRAYLANG['TXT_SHOP_DISCOUNT_COUPON_PAYMENT']);
$objSorting = new \Sorting($uri, $arrSortingFields, true, 'order_coupon');
$objTemplate->setGlobalVariable($_ARRAYLANG + array('TXT_SHOP_DISCOUNT_COUPON_MINIMUM_AMOUNT_CURRENCY' => sprintf($_ARRAYLANG['TXT_SHOP_DISCOUNT_COUPON_MINIMUM_AMOUNT_FORMAT'], Currency::getDefaultCurrencyCode()), 'TXT_SHOP_DISCOUNT_COUPON_AMOUNT_CURRENCY' => sprintf($_ARRAYLANG['TXT_SHOP_DISCOUNT_COUPON_AMOUNT_FORMAT'], Currency::getDefaultCurrencyCode()), 'TXT_SHOP_DISCOUNT_COUPON_ADD_OR_EDIT' => $_ARRAYLANG[$edit ? 'TXT_SHOP_DISCOUNT_COUPON_EDIT' : 'TXT_SHOP_DISCOUNT_COUPON_ADD'], 'SHOP_DISCOUNT_COUPON_VIEW_ACTIVE' => $edit ? '' : 'active', 'SHOP_DISCOUNT_COUPON_EDIT_ACTIVE' => $edit ? 'active' : '', 'SHOP_DISCOUNT_COUPON_VIEW_DISPLAY' => $edit ? 'none' : 'block', 'SHOP_DISCOUNT_COUPON_EDIT_DISPLAY' => $edit ? 'block' : 'none', 'HEADER_SHOP_DISCOUNT_COUPON_CODE' => $objSorting->getHeaderForField('code'), 'HEADER_SHOP_DISCOUNT_COUPON_START_TIME' => $objSorting->getHeaderForField('start_time'), 'HEADER_SHOP_DISCOUNT_COUPON_END_TIME' => $objSorting->getHeaderForField('end_time'), 'HEADER_SHOP_DISCOUNT_COUPON_MINIMUM_AMOUNT_CURRENCY' => $objSorting->getHeaderForField('minimum_amount'), 'HEADER_SHOP_DISCOUNT_COUPON_RATE' => $objSorting->getHeaderForField('discount_rate'), 'HEADER_SHOP_DISCOUNT_COUPON_AMOUNT_CURRENCY' => $objSorting->getHeaderForField('discount_amount'), 'HEADER_SHOP_DISCOUNT_COUPON_USES' => $objSorting->getHeaderForField('uses'), 'HEADER_SHOP_DISCOUNT_COUPON_SCOPE' => $objSorting->getHeaderForField('global'), 'HEADER_SHOP_DISCOUNT_COUPON_CUSTOMER' => $objSorting->getHeaderForField('customer_id'), 'HEADER_SHOP_DISCOUNT_COUPON_PRODUCT' => $objSorting->getHeaderForField('product_id'), 'HEADER_SHOP_DISCOUNT_COUPON_PAYMENT' => $objSorting->getHeaderForField('payment_id')));
$count = 0;
$limit = \Cx\Core\Setting\Controller\Setting::getValue('numof_coupon_per_page_backend', 'Shop');
if (empty($limit)) {
self::errorHandler();
}
$arrCoupons = self::getArray(\Paging::getPosition(), $limit, $count, $objSorting->getOrder());
$arrProductName = Products::getNameArray(true, $_ARRAYLANG['TXT_SHOP_DISCOUNT_COUPON_PRODUCT_FORMAT']);
$arrPaymentName = Payment::getNameArray();
$i = 0;
$row = 0;
$objCouponEdit = new Coupon();
$objCouponEdit->code($code);
$objCouponEdit->payment_id($payment_id);
$objCouponEdit->minimum_amount($minimum_amount);
$objCouponEdit->discount_rate($discount_rate);
$objCouponEdit->discount_amount($discount_amount);
$objCouponEdit->start_time($start_time);
$objCouponEdit->end_time($end_time);
$objCouponEdit->uses($uses);
$objCouponEdit->is_global($global);
$objCouponEdit->customer_id($customer_id);
$objCouponEdit->product_id($product_id);
global $_CONFIG;
foreach ($arrCoupons as $index => $objCoupon) {
$coupon_uri_id = 'coupon_uri_' . $index;
$objTemplate->setVariable(array('SHOP_ROWCLASS' => 'row' . (++$row % 2 + 1), 'SHOP_DISCOUNT_COUPON_CODE' => $objCoupon->code, 'SHOP_DISCOUNT_COUPON_URI_ICON' => '<div class="icon_url"' . '> </div>', 'SHOP_DISCOUNT_COUPON_URI_INPUT' => '<div class="layer_url" id="' . $coupon_uri_id . '">' . \Html::getInputText('dummy', 'http://' . $_CONFIG['domainUrl'] . \Cx\Core\Core\Controller\Cx::instanciate()->getWebsiteOffsetPath() . '/' . CONTREXX_DIRECTORY_INDEX . '?section=Shop' . MODULE_INDEX . '&coupon_code=' . $objCoupon->code, false, 'readonly="readonly"' . ' style="width: 200px;"' . ' onfocus="this.select();"' . ' onblur="cx.jQuery(\'#' . $coupon_uri_id . '\').hide();"') . '</div>', 'SHOP_DISCOUNT_COUPON_START_TIME' => $objCoupon->start_time ? date(ASCMS_DATE_FORMAT_DATE, $objCoupon->start_time) : $_ARRAYLANG['TXT_SHOP_DATE_NONE'], 'SHOP_DISCOUNT_COUPON_END_TIME' => $objCoupon->end_time ? date(ASCMS_DATE_FORMAT_DATE, $objCoupon->end_time) : $_ARRAYLANG['TXT_SHOP_DISCOUNT_COUPON_END_TIME_UNLIMITED'], 'SHOP_DISCOUNT_COUPON_MINIMUM_AMOUNT' => $objCoupon->minimum_amount > 0 ? $objCoupon->minimum_amount : $_ARRAYLANG['TXT_SHOP_AMOUNT_NONE'], 'SHOP_DISCOUNT_COUPON_RATE' => $objCoupon->discount_rate > 0 ? $objCoupon->discount_rate : $_ARRAYLANG['TXT_SHOP_RATE_NONE'], 'SHOP_DISCOUNT_COUPON_AMOUNT' => $objCoupon->discount_amount > 0 ? $objCoupon->discount_amount : $_ARRAYLANG['TXT_SHOP_AMOUNT_NONE'], 'SHOP_DISCOUNT_COUPON_USES' => sprintf($_ARRAYLANG['TXT_SHOP_COUPON_USES_FORMAT'], $objCoupon->used, $objCoupon->uses < 1000000000.0 ? $objCoupon->uses : $_ARRAYLANG['TXT_SHOP_DISCOUNT_COUPON_USES_UNLIMITED']), 'SHOP_DISCOUNT_COUPON_SCOPE' => $objCoupon->global ? $_ARRAYLANG['TXT_SHOP_DISCOUNT_COUPON_GLOBALLY'] : $_ARRAYLANG['TXT_SHOP_DISCOUNT_COUPON_PER_CUSTOMER'], 'SHOP_DISCOUNT_COUPON_PER_CUSTOMER' => !$objCoupon->global ? \Html::getRadio('foo_' . ++$i, '', false, true, '', \Html::ATTRIBUTE_DISABLED) : ' ', 'SHOP_DISCOUNT_COUPON_CUSTOMER' => $objCoupon->customer_id ? Customers::getNameById($objCoupon->customer_id, '%4$s (%3$u)') : $_ARRAYLANG['TXT_SHOP_CUSTOMER_ANY'], 'SHOP_DISCOUNT_COUPON_PRODUCT' => $objCoupon->product_id ? isset($arrProductName[$objCoupon->product_id]) ? $arrProductName[$objCoupon->product_id] : $_ARRAYLANG['TXT_SHOP_DISCOUNT_COUPON_PRODUCT_INVALID'] : $_ARRAYLANG['TXT_SHOP_PRODUCT_ANY'], 'SHOP_DISCOUNT_COUPON_PAYMENT' => $objCoupon->payment_id ? sprintf($_ARRAYLANG['TXT_SHOP_DISCOUNT_COUPON_PAYMENT_FORMAT'], $objCoupon->payment_id, $arrPaymentName[$objCoupon->payment_id]) : $_ARRAYLANG['TXT_SHOP_PAYMENT_ANY'], 'SHOP_DISCOUNT_COUPON_FUNCTIONS' => \Html::getBackendFunctions(array('edit' => ADMIN_SCRIPT_PATH . '?cmd=Shop&act=settings&tpl=coupon&edit=' . urlencode($index), 'delete' => "javascript:delete_coupon('" . urlencode($index) . "');"))));
$objTemplate->parse('shopDiscountCouponView');
if ($index === $edit) {
$objCouponEdit = $objCoupon;
}
}
$objTemplate->replaceBlock('shopDiscountCouponView', '', true);
$paging = \Paging::get($uri, $_ARRAYLANG['TXT_SHOP_DISCOUNT_COUPON_CODES'], $count, $limit);
//DBG::log("Paging: $paging");
$objTemplate->setVariable('SHOP_PAGING', $paging);
$attribute_code = 'style="width: 230px; text-align: left;" maxlength="20"';
$attribute_time = 'style="width: 230px; text-align: left;" maxlength="10"';
$attribute_discount_rate = 'style="width: 230px; text-align: right;" maxlength="3"';
$attribute_discount_amount = 'style="width: 230px; text-align: right;" maxlength="9"';
$attribute_minimum_amount = 'style="width: 230px; text-align: right;" maxlength="9"';
$attribute_uses = 'style="width: 230px; text-align: right;" maxlength="6"';
// Superseded by the widget, see below
// $attribute_customer = 'style="width: 230px;"';
$attribute_product = 'style="width: 230px;"';
$attribute_payment = 'style="width: 230px;"';
//.........这里部分代码省略.........
作者:nahakiol
项目:cloudrex
/**
* Adds an external settings view to the current template
*
* The content must contain the full view, including the surrounding form
* tags and submit button.
* Note that these are always appended on the right end of the tab list.
* @param \Cx\Core\Html\Sigma $objTemplateLocal Template object
* @param string $tab_name The tab name to add
* @param string $content The external content
* @return boolean True on success
*/
static function show_external(&$objTemplateLocal, $tab_name, $content)
{
if (empty($objTemplateLocal) || !$objTemplateLocal->blockExists('core_setting_row')) {
$objTemplateLocal = new \Cx\Core\Html\Sigma(\Env::get('cx')->getCodeBaseDocumentRootPath() . '/core/Setting/View/Template/Generic');
if (!$objTemplateLocal->loadTemplateFile('Form.html')) {
die("Failed to load template Form.html");
}
}
$active_tab = isset($_REQUEST['active_tab']) ? $_REQUEST['active_tab'] : 1;
// The tabindex must be set in the form name in any case
$objTemplateLocal->setGlobalVariable(array('CORE_SETTING_TAB_INDEX' => self::$tab_index, 'CORE_SETTING_EXTERNAL' => $content));
// Set up the tab, if any
if (!empty($tab_name)) {
$objTemplateLocal->setGlobalVariable(array('CORE_SETTING_TAB_NAME' => $tab_name, 'CORE_SETTING_TAB_INDEX' => self::$tab_index, 'CORE_SETTING_TAB_CLASS' => self::$tab_index == $active_tab ? 'active' : '', 'CORE_SETTING_TAB_DISPLAY' => self::$tab_index++ == $active_tab ? 'block' : 'none', 'CORE_SETTING_CURRENT_TAB' => 'tab-' . $active_tab));
$objTemplateLocal->touchBlock('core_setting_tab_row');
$objTemplateLocal->parse('core_setting_tab_row');
$objTemplateLocal->touchBlock('core_setting_tab_div_external');
$objTemplateLocal->parse('core_setting_tab_div_external');
}
return true;
}
作者:Cloudrex
项目:cloudrex
/**
* Render the option in the frontend.
*
* @param Sigma $template
*/
public function renderTheme($template)
{
$template->setVariable('TEMPLATE_EDITOR_' . strtoupper($this->name), $this->activeChoice);
}
作者:nahakiol
项目:cloudrex
/**
* Parse the current navigation item
*
* @global array $_ARRAYLANG
*
* @param \Cx\Core\Html\Sigma $navigation
* @param string $blockName
* @param string $currentCmd
* @param string $mainCmd
* @param boolean $isActiveNav
* @param boolean $isSubNav
*/
protected function parseCurrentNavItem(\Cx\Core\Html\Sigma $navigation, $blockName, $currentCmd, $mainCmd, $isActiveNav, $isSubNav)
{
global $_ARRAYLANG;
if (empty($blockName)) {
return;
}
$isActiveNav ? $navigation->touchBlock($blockName . '_active') : $navigation->hideBlock($blockName . '_active');
if (empty($isSubNav)) {
$act = empty($currentCmd) ? '' : '&act=' . $currentCmd;
$txt = empty($currentCmd) ? 'DEFAULT' : $currentCmd;
} else {
$act = '&act=' . $mainCmd . '/' . $currentCmd;
$txt = (empty($mainCmd) ? 'DEFAULT' : $mainCmd) . '_';
$txt .= empty($currentCmd) ? 'DEFAULT' : strtoupper($currentCmd);
}
$actTxtKey = 'TXT_' . strtoupper($this->getType()) . '_' . strtoupper($this->getName() . '_ACT_' . $txt);
$actTitle = isset($_ARRAYLANG[$actTxtKey]) ? $_ARRAYLANG[$actTxtKey] : $actTxtKey;
$navigation->setVariable(array('HREF' => 'index.php?cmd=' . $this->getName() . $act, 'TITLE' => $actTitle));
$navigation->parse($blockName . '_entry');
}
作者:Nigg
项目:cloudrex
/**
* Shows the collected messages, if any
*
* Frontend use only.
* Returns a status according to the message classes:
* - null, if no message is present
* - false, if any message of class CLASS_ERROR is encountered
* - true, if no messages of class CLASS_ERROR are found
* @param \Cx\Core\Html\Sigma $objTemplateLocal
* The optional Template
* @return boolean The status
*/
private static function show_frontend($objTemplateLocal = null)
{
if (empty($_SESSION['messages'])) {
return null;
}
global $objTemplate;
if (empty($objTemplateLocal)) {
$objTemplateLocal =& $objTemplate;
}
foreach (self::$message_classes as $class) {
if (empty($_SESSION['messages'][$class])) {
continue;
}
$objTemplateLocal->setVariable(array('MESSAGE_CLASS' => $class, 'MESSAGE_TEXT' => join('<br />', $_SESSION['messages'][$class]->toArray())));
if ($objTemplateLocal->blockExists('messages')) {
$objTemplateLocal->parse('messages');
} else {
// If no block can be parsed, leave after the first
// non-empty message class.
// Note: This is why classes are parsed in descending
// order of severity!
break;
}
}
// Fail when there are error messages
if (isset($_SESSION['messages'][self::CLASS_ERROR])) {
return false;
}
return true;
}
作者:Cloudrex
项目:cloudrex
protected function preRender($lang)
{
if ($this->template->placeholderExists('LEVELS_FULL') || $this->template->placeholderExists('levels_full')) {
$this->rootNode = \Env::get('em')->getRepository('Cx\\Core\\ContentManager\\Model\\Entity\\Node')->getRoot();
}
$this->realPreRender($lang);
}
作者:nahakiol
项目:cloudrex
public function showPrices()
{
global $_ARRAYLANG;
$prices = $this->priceRepository->findAll();
if (empty($prices)) {
$prices = new \Cx\Modules\Pim\Model\Entity\Price();
}
$view = new \Cx\Core\Html\Controller\ViewGenerator($prices, array('header' => $_ARRAYLANG['TXT_MODULE_PIM_ACT_PRICE'], 'validate' => function ($formGenerator) {
// this validation checks whether already a price for the currency and product exists
$data = $formGenerator->getData()->toArray();
$currency = $data['currency'];
$product = $data['product'];
$priceRepository = \Env::get('cx')->getDb()->getEntityManager()->getRepository('Cx\\Modules\\Pim\\Model\\Entity\\Price');
$prices = $priceRepository->createQueryBuilder('p')->where('p.currency = ?1')->setParameter(1, $currency)->andWhere('p.product = ?2')->setParameter(2, $product);
$prices = $prices->getQuery()->getResult();
if (!empty($data['editid']) && count($prices) > 1) {
return false;
}
if (empty($data['editid']) && count($prices) > 0) {
return false;
}
return true;
}, 'functions' => array('add' => true, 'edit' => true, 'delete' => true, 'sorting' => true, 'paging' => true, 'filtering' => false)));
$this->template->setVariable('PRICES_CONTENT', $view->render());
}
作者:nahakiol
项目:cloudrex
/**
* Set up the full set of discount information placeholders
* @param integer $groupCustomerId The customer group ID of the current customer
* @param integer $groupArticleId The article group ID of the current article
* @param integer $groupCountId The count discount group ID of the current article
* @param integer $count The number of articles to be used for the count discount
* @static
* @author Reto Kohli <reto.kohli@comvation.com>
*/
static function showDiscountInfo($groupCustomerId, $groupArticleId, $groupCountId, $count)
{
// Pick the unit for this product (count, meter, kilo, ...)
$unit = Discount::getUnit($groupCountId);
if (!empty($unit)) {
self::$objTemplate->setVariable('SHOP_PRODUCT_UNIT', $unit);
}
if ($groupCustomerId > 0) {
$rateCustomer = Discount::getDiscountRateCustomer($groupCustomerId, $groupArticleId);
if ($rateCustomer > 0) {
self::$objTemplate->setVariable(array('SHOP_DISCOUNT_RATE_CUSTOMER' => $rateCustomer));
}
}
if ($groupCountId > 0) {
$rateCount = Discount::getDiscountRateCount($groupCountId, $count);
$listCount = self::getDiscountCountString($groupCountId);
if ($rateCount > 0) {
// Show discount rate if applicable
self::$objTemplate->setVariable('SHOP_DISCOUNT_RATE_COUNT', $rateCount);
}
if (!empty($listCount)) {
// Show discount rate string if applicable
self::$objTemplate->setVariable('SHOP_DISCOUNT_RATE_COUNT_LIST', $listCount);
}
}
}