/** * Encodes a raw string or array thereof for use as a href or src * attribute value. * * Apply to any raw string or array that is to be used as a link or image * address in any tag attribute, such as a.href or img.src. * @param mixed $source The raw string or array * @param boolean $encodeDash Encode dashes ('-') if true. * Defaults to false * @return mixed The URL encoded string or array */ function contrexx_raw2encodedUrl($source, $encodeDash = false) { if (is_array($source)) { $arr = array(); foreach ($source as $i => $_source) { $arr[$i] = contrexx_raw2encodedUrl($_source, $encodeDash); } return $arr; } $cutHttp = false; if (!$encodeDash && substr($source, 0, 7) == 'http://') { $source = substr($source, 7); $cutHttp = true; } $source = array_map('rawurlencode', explode('/', $source)); if ($encodeDash) { $source = str_replace('-', '%2D', $source); } $result = implode('/', $source); if ($cutHttp) { $result = 'http://' . $result; } return $result; }
/** * Get Domain name Id * * @param Integer $websiteId website id * @param Integer $cusId customer id * @param String $domainName domain name * * @global ADO Connection $objDatabase * * @return Integer */ public function _getDomainNameId($websiteId, $cusId, $domainName) { global $objDatabase; if (empty($domainName)) { return 0; } $websiteId = (int) $websiteId; $cusId = (int) $cusId; $domainName = contrexx_input2db($domainName); $query = "SELECT\n `id`\n FROM `" . DBPREFIX . "module_{$this->moduleNameLC}_customer_contact_websites`\n WHERE (`url` = '{$domainName}')\n AND `contact_id` = {$cusId}"; $objResult = $objDatabase->Execute($query); if ($objResult->RecordCount() > 0) { return $objResult->fields['id']; } else { $insertWebsite = $objDatabase->Execute("INSERT INTO\n `" . DBPREFIX . "module_{$this->moduleNameLC}_customer_contact_websites`\n SET `contact_id` = {$cusId},\n `url_type` = 3,\n `url_profile`= 1,\n `is_primary` = '0',\n `url` = '" . contrexx_raw2encodedUrl($domainName) . "'"); return $objDatabase->Insert_Id(); } }
function _getNewsPage() { global $objDatabase, $objInit, $_ARRAYLANG; \JS::activate('cx'); // TODO: Unused // $objFWUser = \FWUser::getFWUserObject(); $newsdate = time() - 86400 * 30; if (!empty($_POST['newsDate'])) { $newsdate = $this->dateFromInput($_POST['newsDate']); } $this->_pageTitle = $_ARRAYLANG['TXT_NEWSLETTER_NEWS_IMPORT']; $this->_objTpl->loadTemplateFile('newsletter_news.html'); $this->_objTpl->setVariable(array('TXT_NEWS_IMPORT' => $_ARRAYLANG['TXT_NEWSLETTER_NEWS_IMPORT'], 'TXT_DATE_SINCE' => $_ARRAYLANG['TXT_NEWSLETTER_NEWS_DATE_SINCE'], 'TXT_SELECTED_MESSAGES' => $_ARRAYLANG['TXT_NEWSLETTER_NEWS_SELECTED_MESSAGES'], 'TXT_NEXT' => $_ARRAYLANG['TXT_NEWSLETTER_NEWS_NEXT'], 'NEWS_CREATE_DATE' => $this->valueFromDate($newsdate))); $query = "SELECT n.id, n.date, nl.title, nl.text, n.catid, cl.name as catname, n.userid, nl.teaser_text,\n n.teaser_image_path, n.teaser_image_thumbnail_path, tl.name as typename FROM " . DBPREFIX . "module_news n\n LEFT JOIN " . DBPREFIX . "module_news_locale nl ON n.id = nl.news_id AND nl.lang_id=" . $objInit->userFrontendLangId . "\n LEFT JOIN " . DBPREFIX . "module_news_categories_locale cl ON n.catid = cl.category_id AND cl.lang_id=" . $objInit->userFrontendLangId . "\n LEFT JOIN " . DBPREFIX . "module_news_types_locale tl ON n.typeid = tl.type_id AND tl.lang_id=" . $objInit->userFrontendLangId . "\n WHERE n.date > " . $newsdate . " AND n.status = 1 AND n.validated = '1'\n ORDER BY cl.name ASC, n.date DESC"; /*AND (n.startdate <> '0000-00-00 00:00:00' OR n.enddate <> '0000-00-00 00:00:00')*/ $objNews = $objDatabase->Execute($query); $current_category = ''; if ($objNews !== false) { while (!$objNews->EOF) { $this->_objTpl->setVariable(array('NEWS_CATEGORY_NAME' => contrexx_raw2xhtml($objNews->fields['catname']), 'NEWS_CATEGORY_ID' => $objNews->fields['catid'])); if ($current_category == $objNews->fields['catid']) { $this->_objTpl->hideBlock("news_category"); } $current_category = $objNews->fields['catid']; // TODO: Unused // $newstext = ltrim(strip_tags($objNews->fields['text'])); $newsteasertext = ltrim(strip_tags($objNews->fields['teaser_text'])); //$newslink = $this->newsletterUri.ASCMS_PROTOCOL."://".$_SERVER['HTTP_HOST'].ASCMS_PATH_OFFSET."/index.php?section=News&cmd=details&newsid=".$objNews->fields['id']; /*if ($objNews->fields['userid'] && ($objUser = $objFWUser->objUser->getUser($objNews->fields['userid']))) { $author = htmlentities($objUser->getUsername(), ENT_QUOTES, CONTREXX_CHARSET); } else { $author = $_ARRAYLANG['TXT_ANONYMOUS']; }*/ $image = $objNews->fields['teaser_image_path']; $thumbnail = $objNews->fields['teaser_image_thumbnail_path']; if (!empty($thumbnail)) { $imageSrc = $thumbnail; } elseif (!empty($image) && file_exists(\ImageManager::getThumbnailFilename(\Cx\Core\Core\Controller\Cx::instanciate()->getWebsitePath() . $image))) { $imageSrc = \ImageManager::getThumbnailFilename($image); } elseif (!empty($image)) { $imageSrc = $image; } else { $imageSrc = ''; } $this->_objTpl->setVariable(array('NEWS_ID' => $objNews->fields['id'], 'NEWS_CATEGORY_ID' => $objNews->fields['catid'], 'NEWS_TITLE' => contrexx_raw2xhtml($objNews->fields['title']), 'NEWS_IMAGE_PATH' => contrexx_raw2encodedUrl($imageSrc), 'NEWS_TEASER_TEXT' => contrexx_raw2xhtml($newsteasertext))); $this->_objTpl->parse("news_list"); $objNews->MoveNext(); } } else { $this->_objTpl->setVariable('NEWS_EMPTY_LIST', $_ARRAYLANG['TXT_NEWSLETTER_NEWS_EMPTY_LIST']); } }
function exportCSV($intFormId, $arrCategoryIds = null, $arrLevelIds = null, $intMaskId = null) { global $_ARRAYLANG, $_CORELANG, $_LANGID, $objDatabase; if ($intFormId != null) { $objValidator = new \FWValidator(); $arrEntries = array(); $arrEntriesData = array(); $arrInputfields = array(); $arrMask = array(); if ($intMaskId != null && $intMaskId != 0) { $objResultMask = $objDatabase->Execute("SELECT\n fields, form_id\n FROM\n " . DBPREFIX . "module_" . $this->moduleTablePrefix . "_masks\n WHERE id = '" . $intMaskId . "'\n "); if ($objResultMask !== false) { $arrMask = explode(',', $objResultMask->fields['fields']); $intFormId = $objResultMask->fields['form_id']; } } $objForm = new MediaDirectoryForm($intFormId, $this->moduleName); $objInputfields = new MediaDirectoryInputfield($intFormId, false, null, $this->moduleName); $strFilename = contrexx_raw2encodedUrl($objForm->arrForms[$intFormId]['formName'][0]) . "_" . mktime() . ".csv"; if ($arrCategoryIds != null) { foreach ($arrCategoryIds as $intKey => $intCategoryId) { if ($arrLevelIds != null) { $strDatabaseLevel = "," . DBPREFIX . "module_" . $this->moduleTablePrefix . "_rel_entry_levels AS level"; $strLevels = join(',', $arrLevelIds); $strWhereLevel = " AND ((cat.entry_id = level.entry_id) AND (level.level_id IN (" . $strLevels . ")))"; } $objResultCategories = $objDatabase->Execute("SELECT\n cat.entry_id AS entryId\n FROM\n " . DBPREFIX . "module_" . $this->moduleTablePrefix . "_rel_entry_categories AS cat\n " . $strDatabaseLevel . "\n WHERE\n cat.category_id ='" . $intCategoryId . "'\n " . $strWhereLevel . "\n "); if ($objResultCategories !== false) { while (!$objResultCategories->EOF) { $arrEntries[$objResultCategories->fields['entryId']] = $objResultCategories->fields['entryId']; $objResultCategories->MoveNext(); } } } } else { if ($arrLevelIds != null) { foreach ($arrLevelIds as $intKey => $intLevelId) { $objResultLevels = $objDatabase->Execute("SELECT\n level.entry_id AS entryId\n FROM\n " . DBPREFIX . "module_" . $this->moduleTablePrefix . "_rel_entry_levels AS level\n WHERE\n level.level_id ='" . $intLevelId . "'\n "); if ($objResultLevels !== false) { while (!$objResultLevels->EOF) { $arrEntries[$objResultLevels->fields['entryId']] = $objResultLevels->fields['entryId']; $objResultLevels->MoveNext(); } } } } else { $objEntry = new MediaDirectoryEntry($this->moduleName); $objEntry->getEntries(null, null, null, null, null, null, true, null, 'n', null, null, $intFormId); foreach ($objEntry->arrEntries as $intEntryId => $arrEntry) { $arrEntries[$intEntryId] = $intEntryId; } } } foreach ($arrEntries as $intKey => $intEntryId) { $objResultEntry = $objDatabase->Execute("SELECT\n entry.value AS value, entry.form_id AS formId, entry.field_id AS fieldId\n FROM\n " . DBPREFIX . "module_" . $this->moduleTablePrefix . "_rel_entry_inputfields AS entry\n WHERE\n entry.entry_id ='" . $intEntryId . "'\n AND\n entry.lang_id ='" . $_LANGID . "'\n "); if ($objResultEntry !== false) { while (!$objResultEntry->EOF) { if ($objResultEntry->fields['formId'] == $intFormId) { $arrEntriesData[$intEntryId][$objResultEntry->fields['fieldId']] = $objResultEntry->fields['value']; } $objResultEntry->MoveNext(); } } } foreach ($objInputfields->arrInputfields as $intFieldId => $arrField) { $arrInputfields[$arrField['order']]['id'] = $intFieldId; $arrInputfields[$arrField['order']]['name'] = $arrField['name'][0]; } ksort($arrInputfields); header("Content-Type: text/comma-separated-values; charset=" . CONTREXX_CHARSET, true); header("Content-Disposition: attachment; filename=\"{$strFilename}\"", true); foreach ($arrInputfields as $intKey => $arrField) { if ($intMaskId == null || $arrMask != null && in_array($arrField['id'], $arrMask)) { print self::escapeCsvValue($arrField['name']) . $this->csvSeparator; } } print "\r\n"; foreach ($arrEntriesData as $intEntryId => $arrEntry) { foreach ($arrInputfields as $intFieldOrder => $arrField) { if ($intMaskId == null || $arrMask != null && in_array($arrField['id'], $arrMask)) { switch ($arrField['id']) { case 1: $arrCategories = self::getCategoriesLevels(1, $intEntryId); $strFieldValue = join($this->elementSeparator, $arrCategories); break; case 2: $arrLevels = self::getCategoriesLevels(2, $intEntryId); $strFieldValue = join($this->elementSeparator, $arrLevels); break; default: $strFieldValue = isset($arrEntriesData[$intEntryId][$arrField['id']]) ? $arrEntriesData[$intEntryId][$arrField['id']] : ''; $strFieldValue = strip_tags($strFieldValue); $strFieldValue = self::escapeCsvValue($strFieldValue); $strFieldValue = html_entity_decode($strFieldValue, ENT_QUOTES, CONTREXX_CHARSET); break; } if (CONTREXX_CHARSET == 'UTF-8') { $strFieldValue = utf8_decode($strFieldValue); } print $strFieldValue . $this->csvSeparator; } } print "\r\n"; } exit; } else { return false; } }
/** * Shows all files / pages in filebrowser */ function _setContent() { global $_FRONTEND_LANGID; $this->_objTpl->addBlockfile('FILEBROWSER_CONTENT', 'fileBrowser_content', 'module_fileBrowser_content.html'); $ckEditorFuncNum = isset($_GET['CKEditorFuncNum']) ? '&CKEditorFuncNum=' . contrexx_raw2xhtml($_GET['CKEditorFuncNum']) : ''; $ckEditor = isset($_GET['CKEditor']) ? '&CKEditor=' . contrexx_raw2xhtml($_GET['CKEditor']) : ''; $rowNr = 0; switch ($this->_mediaType) { case 'webpages': $jd = new \Cx\Core\Json\JsonData(); $data = $jd->data('node', 'getTree', array('get' => array('recursive' => 'true'))); $pageStack = array(); $ref = 0; $data['data']['tree'] = array_reverse($data['data']['tree']); foreach ($data['data']['tree'] as &$entry) { $entry['attr']['level'] = 0; array_push($pageStack, $entry); } while (count($pageStack)) { $entry = array_pop($pageStack); $page = $entry['data'][0]; $arrPage['level'] = $entry['attr']['level']; $arrPage['node_id'] = $entry['attr']['rel_id']; $children = $entry['children']; $children = array_reverse($children); foreach ($children as &$entry) { $entry['attr']['level'] = $arrPage['level'] + 1; array_push($pageStack, $entry); } $arrPage['catname'] = $page['title']; $arrPage['catid'] = $page['attr']['id']; $arrPage['lang'] = BACKEND_LANG_ID; $arrPage['protected'] = $page['attr']['protected']; $arrPage['type'] = \Cx\Core\ContentManager\Model\Entity\Page::TYPE_CONTENT; $arrPage['alias'] = $page['title']; $arrPage['frontend_access_id'] = $page['attr']['frontend_access_id']; $arrPage['backend_access_id'] = $page['attr']['backend_access_id']; // JsonNode does not provide those //$arrPage['level'] = ; //$arrPage['type'] = ; //$arrPage['parcat'] = ; //$arrPage['displaystatus'] = ; //$arrPage['moduleid'] = ; //$arrPage['startdate'] = ; //$arrPage['enddate'] = ; // But we can simulate level and type for our purposes: (level above) $jsondata = json_decode($page['attr']['data-href']); $path = $jsondata->path; if (trim($jsondata->module) != '') { $arrPage['type'] = \Cx\Core\ContentManager\Model\Entity\Page::TYPE_APPLICATION; $module = explode(' ', $jsondata->module, 2); $arrPage['modulename'] = $module[0]; if (count($module) > 1) { $arrPage['cmd'] = $module[1]; } } $url = "'" . '[[' . \Cx\Core\ContentManager\Model\Entity\Page::PLACEHOLDER_PREFIX; // TODO: This only works for regular application pages. Pages of type fallback that are linked to an application // will be parsed using their node-id ({NODE_<ID>}) if ($arrPage['type'] == \Cx\Core\ContentManager\Model\Entity\Page::TYPE_APPLICATION && $this->_mediaMode !== 'alias') { $url .= $arrPage['modulename']; if (!empty($arrPage['cmd'])) { $url .= '_' . $arrPage['cmd']; } $url = strtoupper($url); } else { $url .= $arrPage['node_id']; } // if language != current language or $alwaysReturnLanguage if ($this->_frontendLanguageId != $_FRONTEND_LANGID || isset($_GET['alwaysReturnLanguage']) && $_GET['alwaysReturnLanguage'] == 'true') { $url .= '_' . $this->_frontendLanguageId; } $url .= "]]'"; $this->_objTpl->setVariable(array('FILEBROWSER_ROW_CLASS' => $rowNr % 2 == 0 ? "row1" : "row2", 'FILEBROWSER_FILE_PATH_CLICK' => "javascript:{setUrl({$url},null,null,'" . \FWLanguage::getLanguageCodeById($this->_frontendLanguageId) . $path . "','page')}", 'FILEBROWSER_FILE_NAME' => $arrPage['catname'], 'FILEBROWSER_FILESIZE' => ' ', 'FILEBROWSER_FILE_ICON' => $this->_iconPath . 'htm.png', 'FILEBROWSER_FILE_DIMENSION' => ' ', 'FILEBROWSER_SPACING_STYLE' => 'style="margin-left: ' . $arrPage['level'] * 15 . 'px;"')); $this->_objTpl->parse('content_files'); $rowNr++; } break; case 'Media1': case 'Media2': case 'Media3': case 'Media4': \Permission::checkAccess(7, 'static'); //Access Media-Archive \Permission::checkAccess(38, 'static'); //Edit Media-Files \Permission::checkAccess(39, 'static'); //Upload Media-Files //Hier soll wirklich kein break stehen! Beabsichtig! //Upload Media-Files //Hier soll wirklich kein break stehen! Beabsichtig! default: if (count($this->_arrDirectories) > 0) { foreach ($this->_arrDirectories as $arrDirectory) { $this->_objTpl->setVariable(array('FILEBROWSER_ROW_CLASS' => $rowNr % 2 == 0 ? "row1" : "row2", 'FILEBROWSER_FILE_PATH_CLICK' => "index.php?cmd=FileBrowser&standalone=true&langId={$this->_frontendLanguageId}&type={$this->_mediaType}&path={$arrDirectory['path']}" . $ckEditor . $ckEditorFuncNum, 'FILEBROWSER_FILE_NAME' => $arrDirectory['name'], 'FILEBROWSER_FILESIZE' => ' ', 'FILEBROWSER_FILE_ICON' => $arrDirectory['icon'], 'FILEBROWSER_FILE_DIMENSION' => ' ')); $this->_objTpl->parse('content_files'); $rowNr++; } } if (count($this->_arrFiles) > 0) { $arrEscapedPaths = array(); foreach ($this->_arrFiles as $arrFile) { $arrEscapedPaths[] = contrexx_raw2encodedUrl($arrFile['path']); $this->_objTpl->setVariable(array('FILEBROWSER_ROW_CLASS' => $rowNr % 2 == 0 ? "row1" : "row2", 'FILEBROWSER_ROW_STYLE' => in_array($arrFile['name'], $this->highlightedFiles) ? ' style="background: ' . $this->highlightColor . ';"' : '', 'FILEBROWSER_FILE_PATH_DBLCLICK' => "setUrl('" . contrexx_raw2xhtml($arrFile['path']) . "'," . $arrFile['width'] . "," . $arrFile['height'] . ",'')", 'FILEBROWSER_FILE_PATH_CLICK' => "javascript:{showPreview(" . (count($arrEscapedPaths) - 1) . "," . $arrFile['width'] . "," . $arrFile['height'] . ")}", 'FILEBROWSER_FILE_NAME' => contrexx_stripslashes($arrFile['name']), 'FILEBROWSER_FILESIZE' => $arrFile['size'] . ' KB', 'FILEBROWSER_FILE_ICON' => $arrFile['icon'], 'FILEBROWSER_FILE_DIMENSION' => empty($arrFile['width']) && empty($arrFile['height']) ? '' : intval($arrFile['width']) . 'x' . intval($arrFile['height']))); $this->_objTpl->parse('content_files'); $rowNr++; } $this->_objTpl->setVariable('FILEBROWSER_FILES_JS', "'" . implode("','", $arrEscapedPaths) . "'"); } if (array_key_exists($this->_mediaType, $this->mediaTypePaths)) { $this->_objTpl->setVariable('FILEBROWSER_IMAGE_PATH', $this->mediaTypePaths[$this->_mediaType][1]); } else { $this->_objTpl->setVariable('FILEBROWSER_IMAGE_PATH', ASCMS_CONTENT_IMAGE_WEB_PATH); } break; } $this->_objTpl->parse('fileBrowser_content'); }
protected function renderElement($title, $level, $hasChilds, $lang, $path, $current, $page) { //make sure the page to render is inside our branch if (!$this->isParentNodeInsideCurrentBranch($page->getNode())) { return ''; } //are we inside the layer bounds? if (!$this->isLevelInsideLayerBound($level)) { return ''; } if (!$page->isVisible()) { return ''; } $node = $page->getNode(); reset($this->branchNodeIds); while ($node && $node->getId() != $this->activeNode->getId()) { if ($node->getPage(FRONTEND_LANG_ID) && !$node->getPage(FRONTEND_LANG_ID)->isVisible()) { return ''; } $node = $node->getParent(); } if (!isset($this->navigationIds[$level])) { $this->navigationIds[$level] = 0; } else { $this->navigationIds[$level]++; } $block = trim($this->template->_blocks['level']); $output = " <li>" . $block; //check if we need to close any <ul>'s $this->lastLevel = $level; $style = $current ? self::StyleNameActive : self::StyleNameNormal; $output = str_replace('{NAME}', contrexx_raw2xhtml($title), $output); $output = str_replace('<li>', '<li class="' . $style . '">', $output); $output = str_replace('{URL}', \Cx\Core\Core\Controller\Cx::instanciate()->getWebsiteOffsetPath() . $this->virtualLanguageDirectory . contrexx_raw2encodedUrl($path), $output); $linkTarget = $page->getLinkTarget(); $output = str_replace('{TARGET}', empty($linkTarget) ? '_self' : $linkTarget, $output); $output = str_replace('{CSS_NAME}', $page->getCssNavName(), $output); $output = str_replace('{PAGE_ID}', $page->getId(), $output); $output = str_replace('{PAGE_NODE_ID}', $page->getNode()->getId(), $output); $output = str_replace('{NAVIGATION_ID}', $this->navigationIds[$level], $output); return $output; }
/** * Set up the shop page with products and discounts * * @param array $product_ids The optional array of Product IDs. * Overrides any URL parameters if set * @return boolean True on success, false otherwise * @global ADONewConnection $objDatabase Database connection object * @global array $_ARRAYLANG Language array * @global array $_CONFIG Core configuration array, see {@link /config/settings.php} * @global string(?) $themesPages Themes pages(?) */ static function view_product_overview($product_ids = null) { global $_ARRAYLANG; // activate javascript shadowbox \JS::activate('shadowbox'); $flagSpecialoffer = intval(\Cx\Core\Setting\Controller\Setting::getValue('show_products_default', 'Shop')); if (isset($_REQUEST['cmd']) && $_REQUEST['cmd'] == 'discounts') { $flagSpecialoffer = Products::DEFAULT_VIEW_DISCOUNTS; } $flagLastFive = isset($_REQUEST['lastFive']); $product_id = isset($_REQUEST['productId']) ? intval($_REQUEST['productId']) : null; $cart_id = null; if (isset($_REQUEST['referer']) && $_REQUEST['referer'] == 'cart') { $cart_id = $product_id; $product_id = Cart::get_product_id($cart_id); } $manufacturer_id = isset($_REQUEST['manufacturerId']) ? intval($_REQUEST['manufacturerId']) : null; $term = isset($_REQUEST['term']) ? trim(contrexx_input2raw($_REQUEST['term'])) : null; $category_id = isset($_REQUEST['catId']) ? intval($_REQUEST['catId']) : null; if (!($product_id || $category_id || $manufacturer_id || $term || $cart_id)) { // NOTE: This is different from NULL // in that it enables listing the subcategories $category_id = 0; } // Validate parameters if ($product_id && empty($category_id)) { $objProduct = Product::getById($product_id); if ($objProduct) { $category_id = $objProduct->category_id(); } if (isset($_SESSION['shop']['previous_category_id'])) { $category_id_previous = $_SESSION['shop']['previous_category_id']; foreach (preg_split('/\\s*,\\s*/', $category_id) as $id) { if ($category_id_previous == intval($id)) { $category_id = $category_id_previous; } } } } // Remember visited Products if ($product_id) { self::rememberVisitedProducts($product_id); } $objCategory = null; if ($category_id && empty($product_id)) { $objCategory = ShopCategory::getById($category_id); if (!$objCategory) { $category_id = null; } } $shopMenu = '<form method="post" action="' . \Cx\Core\Routing\Url::fromModuleAndCmd('Shop', '') . '">' . '<input type="text" name="term" value="' . htmlentities($term, ENT_QUOTES, CONTREXX_CHARSET) . '" style="width:150px;" /> ' . '<select name="catId" style="width:150px;">' . '<option value="0">' . $_ARRAYLANG['TXT_ALL_PRODUCT_GROUPS'] . '</option>' . ShopCategories::getMenuoptions($category_id) . '</select> ' . Manufacturer::getMenu('manufacturerId', $manufacturer_id, true) . '<input type="submit" name="bsubmit" value="' . $_ARRAYLANG['TXT_SEARCH'] . '" style="width:66px;" />' . '</form>'; self::$objTemplate->setGlobalVariable($_ARRAYLANG + array('SHOP_MENU' => $shopMenu, 'SHOP_SEARCH_TERM' => htmlentities($term, ENT_QUOTES, CONTREXX_CHARSET), 'SHOP_CATEGORIES_MENUOPTIONS' => ShopCategories::getMenuoptions($category_id, true, 0, true), 'SHOP_MANUFACTURER_MENUOPTIONS' => Manufacturer::getMenuoptions($manufacturer_id, true))); // Only show the cart info when the JS cart is not active! global $_CONFIGURATION; if (empty($_CONFIGURATION['custom']['shopJsCart'])) { self::$objTemplate->setVariable(array('SHOP_CART_INFO' => self::cart_info())); } // Exclude Category list from search results if ($term == '') { self::showCategories($category_id); } if (self::$objTemplate->blockExists('shopNextCategoryLink')) { $nextCat = ShopCategory::getNextShopCategoryId($category_id); $objCategory = ShopCategory::getById($nextCat); if ($objCategory) { self::$objTemplate->setVariable(array('SHOP_NEXT_CATEGORY_ID' => $nextCat, 'SHOP_NEXT_CATEGORY_TITLE' => str_replace('"', '"', $objCategory->name()))); } } $pagingCmd = !empty($_REQUEST['cmd']) ? '&cmd=' . contrexx_input2raw($_REQUEST['cmd']) : ''; $pagingCatId = ''; $pagingManId = ''; $pagingTerm = ''; // TODO: This probably breaks paging in search results! // Should only reset the flag conditionally, but add the URL parameters in // any case, methinks! if ($category_id > 0 && $term == '') { $flagSpecialoffer = false; $pagingCatId = "&catId={$category_id}"; } if ($manufacturer_id > 0) { $flagSpecialoffer = false; $pagingManId = "&manufacturer_id={$manufacturer_id}"; } if ($term != '') { $flagSpecialoffer = false; $pagingTerm = '&term=' . htmlentities($term, ENT_QUOTES, CONTREXX_CHARSET); } // The Product count is passed by reference and set to the total // number of records, though only as many as specified by the core // paging limit are returned in the array. $limit = \Cx\Core\Setting\Controller\Setting::getValue('numof_products_per_page_frontend', 'Shop'); //\DBG::activate(DBG_ERROR_FIREPHP); // Use Sorting class for the Product order $uri = \Html::getRelativeUri_entities(); $arrOrder = array('product.ord' => $_ARRAYLANG['TXT_SHOP_ORDER_PRODUCT_ORD'], 'name' => $_ARRAYLANG['TXT_SHOP_ORDER_PRODUCT_TITLE'], 'code' => $_ARRAYLANG['TXT_SHOP_ORDER_PRODUCT_CODE'], 'price' => $_ARRAYLANG['TXT_SHOP_ORDER_PRODUCT_PRICE'], 'id' => $_ARRAYLANG['TXT_SHOP_ORDER_PRODUCT_DATE'], 'bestseller' => $_ARRAYLANG['TXT_SHOP_ORDER_PRODUCT_BESTSELLER']); $defaultOrder = \Sorting::getFieldindex(Products::$arrProductOrder[\Cx\Core\Setting\Controller\Setting::getValue('product_sorting', 'Shop')]); $objSorting = new \Sorting($uri, $arrOrder, true, 'shop_order_products', $defaultOrder); //\DBG::log("Sorting headers: ".var_export($objSorting->getHeaderArray(), true)); $count = $limit; $arrProduct = array(); if ($product_ids) { $arrProduct = self::getValidProducts($product_ids); $product_id = null; // Suppress meta title from single Product } elseif ($product_id) { $arrProduct = self::getValidProducts(array($product_id)); } else { $arrProduct = Products::getByShopParams($count, \Paging::getPosition(), $product_id, $category_id, $manufacturer_id, $term, $flagSpecialoffer, $flagLastFive, $objSorting->getOrder(), self::$objCustomer && self::$objCustomer->is_reseller()); } // Only show sorting when there's enough to be sorted if ($count > 1) { $objSorting->parseHeaders(self::$objTemplate, 'shop_product_order'); } if ($count == 0 && !ShopCategories::getChildCategoryIdArray($category_id)) { //if ($term != '' || $manufacturer_id != 0 || $flagSpecialoffer) { if (self::$objTemplate->blockExists('no_product')) { self::$objTemplate->touchBlock('no_product'); } return true; } if ($objCategory) { // Only indicate the category name when there are products if ($count) { self::$objTemplate->setVariable(array('SHOP_CATEGORY_CURRENT_NAME' => contrexx_raw2xhtml($objCategory->name()), 'SHOP_PRODUCTS_IN_CATEGORY' => sprintf($_ARRAYLANG['TXT_SHOP_PRODUCTS_IN_CATEGORY'], contrexx_raw2xhtml($objCategory->name())))); } } else { // TODO: There are other cases of flag combinations that are not indivuidually // handled here yet. if ($term == '') { if ($flagSpecialoffer == Products::DEFAULT_VIEW_DISCOUNTS) { self::$objTemplate->setVariable('SHOP_PRODUCTS_IN_CATEGORY', $_ARRAYLANG['TXT_SHOP_PRODUCTS_SPECIAL_OFFER']); } else { if (self::$objTemplate->blockExists('products_in_category')) { self::$objTemplate->hideBlock('products_in_category'); } } } else { self::$objTemplate->setVariable('SHOP_PRODUCTS_IN_CATEGORY', sprintf($_ARRAYLANG['TXT_SHOP_PRODUCTS_SEARCH_RESULTS'], contrexx_raw2xhtml($term))); } } $uri = '&section=Shop' . MODULE_INDEX . $pagingCmd . $pagingCatId . $pagingManId . $pagingTerm; self::$objTemplate->setVariable(array('SHOP_PRODUCT_PAGING' => \Paging::get($uri, '', $count, $limit, $count > 0), 'SHOP_PRODUCT_TOTAL' => $count)); // Global microdata: Seller information $seller_url = \Cx\Core\Routing\Url::fromModuleAndCmd('Shop', '')->toString(); $seller_name = \Cx\Core\Setting\Controller\Setting::getValue('company', 'Shop'); if (empty($seller_name)) { $seller_name = $seller_url; } self::$objTemplate->setVariable(array('SHOP_SELLER_NAME' => $seller_name, 'SHOP_SELLER_URL' => $seller_url)); $formId = 0; $arrDefaultImageSize = $arrSize = null; foreach ($arrProduct as $objProduct) { if (!empty($product_id)) { self::$pageTitle = $objProduct->name(); } $id = $objProduct->id(); $productSubmitFunction = ''; $arrPictures = Products::get_image_array_from_base64($objProduct->pictures()); $havePicture = false; $arrProductImages = array(); foreach ($arrPictures as $index => $image) { $thumbnailPath = $pictureLink = ''; if (empty($image['img']) || $image['img'] == ShopLibrary::noPictureName) { // We have at least one picture on display already. // No need to show "no picture" three times! if ($havePicture) { continue; } $thumbnailPath = self::$defaultImage; $pictureLink = '#'; //"javascript:alert('".$_ARRAYLANG['TXT_NO_PICTURE_AVAILABLE']."');"; if (empty($arrDefaultImageSize)) { $arrDefaultImageSize = getimagesize(\Cx\Core\Core\Controller\Cx::instanciate()->getWebsitePath() . self::$defaultImage); self::scaleImageSizeToThumbnail($arrDefaultImageSize); } $arrSize = $arrDefaultImageSize; } else { $thumbnailPath = \Cx\Core\Core\Controller\Cx::instanciate()->getWebsiteImagesShopWebPath() . '/' . \ImageManager::getThumbnailFilename($image['img']); if ($image['width'] && $image['height']) { $pictureLink = contrexx_raw2encodedUrl(\Cx\Core\Core\Controller\Cx::instanciate()->getWebsiteImagesShopWebPath() . '/' . $image['img']) . '" rel="shadowbox[' . ($formId + 1) . ']'; // Thumbnail display size $arrSize = array($image['width'], $image['height']); } else { $pictureLink = '#'; if (!file_exists(\Cx\Core\Core\Controller\Cx::instanciate()->getWebsitePath() . $thumbnailPath)) { continue; } $arrSize = getimagesize(\Cx\Core\Core\Controller\Cx::instanciate()->getWebsitePath() . $thumbnailPath); } self::scaleImageSizeToThumbnail($arrSize); // Use the first available picture in microdata, if any if (!$havePicture) { $picture_url = \Cx\Core\Routing\Url::fromCapturedRequest(\Cx\Core\Core\Controller\Cx::instanciate()->getWebsiteImagesShopWebPath() . '/' . $image['img'], \Cx\Core\Core\Controller\Cx::instanciate()->getWebsiteOffsetPath(), array()); self::$objTemplate->setVariable('SHOP_PRODUCT_IMAGE', $picture_url->toString()); //\DBG::log("Set image to ".$picture_url->toString()); } } $arrProductImages[] = array('THUMBNAIL' => contrexx_raw2encodedUrl($thumbnailPath), 'THUMBNAIL_SIZE' => $arrSize[3], 'THUMBNAIL_LINK' => $pictureLink, 'POPUP_LINK' => $pictureLink, 'POPUP_LINK_NAME' => $_ARRAYLANG['TXT_SHOP_IMAGE'] . ' ' . $index); $havePicture = true; } $i = 1; foreach ($arrProductImages as $arrProductImage) { // TODO: Instead of several numbered image blocks, use a single one repeatedly self::$objTemplate->setVariable(array('SHOP_PRODUCT_THUMBNAIL_' . $i => $arrProductImage['THUMBNAIL'], 'SHOP_PRODUCT_THUMBNAIL_SIZE_' . $i => $arrProductImage['THUMBNAIL_SIZE'])); if (!empty($arrProductImage['THUMBNAIL_LINK'])) { self::$objTemplate->setVariable(array('SHOP_PRODUCT_THUMBNAIL_LINK_' . $i => $arrProductImage['THUMBNAIL_LINK'], 'TXT_SEE_LARGE_PICTURE' => $_ARRAYLANG['TXT_SEE_LARGE_PICTURE'])); } else { self::$objTemplate->setVariable('TXT_SEE_LARGE_PICTURE', contrexx_raw2xhtml($objProduct->name())); } if ($arrProductImage['POPUP_LINK']) { self::$objTemplate->setVariable('SHOP_PRODUCT_POPUP_LINK_' . $i, $arrProductImage['POPUP_LINK']); } self::$objTemplate->setVariable('SHOP_PRODUCT_POPUP_LINK_NAME_' . $i, $arrProductImage['POPUP_LINK_NAME']); ++$i; } $stock = $objProduct->stock_visible() ? $_ARRAYLANG['TXT_STOCK'] . ': ' . intval($objProduct->stock()) : ''; $price = $objProduct->get_custom_price(self::$objCustomer, 0, 1, true); // If there is a discountprice and it's enabled $discountPrice = ''; if ($objProduct->discountprice() > 0 && $objProduct->discount_active()) { $price = '<s>' . $price . '</s>'; $discountPrice = $objProduct->get_custom_price(self::$objCustomer, 0, 1, false); } $groupCountId = $objProduct->group_id(); $groupArticleId = $objProduct->article_id(); $groupCustomerId = 0; if (self::$objCustomer) { $groupCustomerId = self::$objCustomer->group_id(); } self::showDiscountInfo($groupCustomerId, $groupArticleId, $groupCountId, 1); /* OLD $price = Currency::getCurrencyPrice( $objProduct->getCustomerPrice(self::$objCustomer) ); $discountPrice = ''; $discount_active = $objProduct->discount_active(); if ($discount_active) { $discountPrice = $objProduct->discountprice(); if ($discountPrice > 0) { $price = "<s>$price</s>"; $discountPrice = Currency::getCurrencyPrice($discountPrice); } } */ $short = $objProduct->short(); $longDescription = $objProduct->long(); $detailLink = null; // Detaillink is required for microdata (even when longdesc // is empty) $detail_url = \Cx\Core\Routing\Url::fromModuleAndCmd('Shop', 'details', FRONTEND_LANG_ID, array('productId' => $objProduct->id()))->toString(); self::$objTemplate->setVariable('SHOP_PRODUCT_DETAIL_URL', $detail_url); if (!$product_id && !empty($longDescription)) { $detailLink = '<a href="' . $detail_url . '"' . ' title="' . $_ARRAYLANG['TXT_MORE_INFORMATIONS'] . '">' . $_ARRAYLANG['TXT_MORE_INFORMATIONS'] . '</a>'; self::$objTemplate->setVariable('SHOP_PRODUCT_DETAILLINK', $detailLink); } // Check Product flags. // Only the meter flag is currently implemented and in use. $flagMeter = $objProduct->testFlag('__METER__'); // Submit button name and function. // Calling productOptions() also sets the $flagMultipart variable // to the appropriate encoding type for the form if // any upload fields are in use. $flagMultipart = false; $productSubmitName = $productSubmitFunction = ''; if (isset($_GET['cmd']) && $_GET['cmd'] == 'details' && isset($_GET['referer']) && $_GET['referer'] == 'cart') { $productSubmitName = "updateProduct[{$cart_id}]"; $productSubmitFunction = self::productOptions($id, $formId, $cart_id, $flagMultipart); } else { $productSubmitName = 'addProduct'; $productSubmitFunction = self::productOptions($id, $formId, $cart_id, $flagMultipart); } $shopProductFormName = "shopProductForm{$formId}"; $row = $formId % 2 + 1; self::$objTemplate->setVariable(array('SHOP_ROWCLASS' => 'row' . $row, 'SHOP_PRODUCT_ID' => $objProduct->id(), 'SHOP_PRODUCT_TITLE' => contrexx_raw2xhtml($objProduct->name()), 'SHOP_PRODUCT_DESCRIPTION' => $short, 'SHOP_PRODUCT_DETAILDESCRIPTION' => $longDescription ? $longDescription : $short, 'SHOP_PRODUCT_FORM_NAME' => $shopProductFormName, 'SHOP_PRODUCT_SUBMIT_NAME' => $productSubmitName, 'SHOP_PRODUCT_SUBMIT_FUNCTION' => $productSubmitFunction, 'SHOP_FORM_ENCTYPE' => $flagMultipart ? ' enctype="multipart/form-data"' : '', 'TXT_SHOP_PRODUCT_COUNT' => $flagMeter ? $_ARRAYLANG['TXT_SHOP_PRODUCT_METER'] : $_ARRAYLANG['TXT_SHOP_PRODUCT_COUNT'], 'SHOP_CURRENCY_CODE' => Currency::getActiveCurrencyCode())); if ($objProduct->code()) { self::$objTemplate->setVariable('SHOP_PRODUCT_CUSTOM_ID', htmlentities($objProduct->code(), ENT_QUOTES, CONTREXX_CHARSET)); } $manufacturer_name = $manufacturer_url = $manufacturer_link = ''; $manufacturer_id = $objProduct->manufacturer_id(); if ($manufacturer_id) { $manufacturer_name = Manufacturer::getNameById($manufacturer_id, FRONTEND_LANG_ID); $manufacturer_url = Manufacturer::getUrlById($manufacturer_id, FRONTEND_LANG_ID); } if (!empty($manufacturer_url) || !empty($manufacturer_name)) { if (empty($manufacturer_name)) { $manufacturer_name = $manufacturer_url; } if (!empty($manufacturer_url)) { $manufacturer_link = '<a href="' . $manufacturer_url . '">' . $manufacturer_name . '</a>'; } // TODO: Test results for any combination of name and url self::$objTemplate->setVariable(array('SHOP_MANUFACTURER_NAME' => $manufacturer_name, 'SHOP_MANUFACTURER_URL' => $manufacturer_url, 'SHOP_MANUFACTURER_LINK' => $manufacturer_link, 'TXT_SHOP_MANUFACTURER_LINK' => $_ARRAYLANG['TXT_SHOP_MANUFACTURER_LINK'])); } // This is the old Product field for the Manufacturer URI. // This is now extended by the Manufacturer table and should thus // get a new purpose. As it is product specific, it could be // renamed and reused as a link to individual Products! $externalLink = $objProduct->uri(); if (!empty($externalLink)) { self::$objTemplate->setVariable(array('SHOP_EXTERNAL_LINK' => '<a href="' . $externalLink . '" title="' . $_ARRAYLANG['TXT_SHOP_EXTERNAL_LINK'] . '" target="_blank">' . $_ARRAYLANG['TXT_SHOP_EXTERNAL_LINK'] . '</a>')); } if ($price) { self::$objTemplate->setGlobalVariable(array('SHOP_PRODUCT_PRICE' => $price, 'SHOP_PRODUCT_PRICE_UNIT' => Currency::getActiveCurrencySymbol())); } // Only show the discount price if it's actually in use, // avoid an "empty <font> tag" HTML warning if ($discountPrice) { self::$objTemplate->setGlobalVariable(array('SHOP_PRODUCT_DISCOUNTPRICE' => $discountPrice, 'SHOP_PRODUCT_DISCOUNTPRICE_UNIT' => Currency::getActiveCurrencySymbol())); if (self::$objTemplate->blockExists('price_discount')) { self::$objTemplate->touchBlock('price_discount'); } } else { if (self::$objTemplate->blockExists('price')) { self::$objTemplate->touchBlock('price'); } } // Special outlet ShopCategory with discounts varying daily. // This should be implemented in a more generic way, in the // Discount class maybe. if ($objProduct->is_outlet()) { self::$objTemplate->setVariable(array('TXT_SHOP_DISCOUNT_TODAY' => $_ARRAYLANG['TXT_SHOP_DISCOUNT_TODAY'], 'SHOP_DISCOUNT_TODAY' => $objProduct->getOutletDiscountRate() . '%', 'TXT_SHOP_PRICE_TODAY' => $_ARRAYLANG['TXT_SHOP_PRICE_TODAY'], 'SHOP_PRICE_TODAY' => Currency::getCurrencyPrice($objProduct->getDiscountedPrice()), 'SHOP_PRICE_TODAY_UNIT' => Currency::getActiveCurrencySymbol())); } if ($objProduct->stock_visible()) { self::$objTemplate->setVariable(array('SHOP_PRODUCT_STOCK' => $stock)); } if ($detailLink) { self::$objTemplate->setVariable(array('SHOP_PRODUCT_DETAILLINK' => $detailLink)); } $distribution = $objProduct->distribution(); $weight = ''; if ($distribution == 'delivery') { $weight = $objProduct->weight(); } // Hide the weight if it is zero or disabled in the configuration if ($weight > 0 && \Cx\Core\Setting\Controller\Setting::getValue('weight_enable', 'Shop')) { self::$objTemplate->setVariable(array('TXT_SHOP_PRODUCT_WEIGHT' => $_ARRAYLANG['TXT_SHOP_PRODUCT_WEIGHT'], 'SHOP_PRODUCT_WEIGHT' => Weight::getWeightString($weight))); } if (Vat::isEnabled()) { self::$objTemplate->setVariable(array('SHOP_PRODUCT_TAX_PREFIX' => Vat::isIncluded() ? $_ARRAYLANG['TXT_SHOP_VAT_PREFIX_INCL'] : $_ARRAYLANG['TXT_SHOP_VAT_PREFIX_EXCL'], 'SHOP_PRODUCT_TAX' => Vat::getShort($objProduct->vat_id()))); } // Add flag images for flagged Products $strImage = ''; $strFlags = $objProduct->flags(); $arrVirtual = ShopCategories::getVirtualCategoryNameArray(FRONTEND_LANG_ID); foreach (explode(' ', $strFlags) as $strFlag) { if (in_array($strFlag, $arrVirtual)) { $strImage .= '<img src="images/content/' . $strFlag . '.jpg" alt="' . $strFlag . '" />'; } } if ($strImage) { self::$objTemplate->setVariable('SHOP_PRODUCT_FLAG_IMAGE', $strImage); } $minimum_order_quantity = $objProduct->minimum_order_quantity(); //Activate Quantity-Inputfield when minimum_order_quantity exists if (self::$objTemplate->blockExists('orderQuantity') && $minimum_order_quantity > 0) { self::$objTemplate->setVariable('SHOP_PRODUCT_MINIMUM_ORDER_QUANTITY', contrexx_raw2xhtml($objProduct->minimum_order_quantity())); } elseif (self::$objTemplate->blockExists('orderQuantity') && !$minimum_order_quantity) { self::$objTemplate->hideBlock('orderQuantity'); } if (self::$objTemplate->blockExists('shopProductRow')) { self::$objTemplate->parse('shopProductRow'); } ++$formId; } return true; }
private function parseDownloadAttributes($objDownload, $categoryId, $allowDeleteFilesFromCategory = false) { global $_ARRAYLANG, $_LANGID; $description = $objDownload->getDescription($_LANGID); if (strlen($description) > 100) { $shortDescription = substr($description, 0, 97) . '...'; } else { $shortDescription = $description; } $imageSrc = $objDownload->getImage(); if (!empty($imageSrc) && file_exists(\Cx\Core\Core\Controller\Cx::instanciate()->getWebsiteDocumentRootPath() . '/' . $imageSrc)) { $thumb_name = \ImageManager::getThumbnailFilename($imageSrc); if (file_exists(\Cx\Core\Core\Controller\Cx::instanciate()->getWebsiteDocumentRootPath() . '/' . $thumb_name)) { $thumbnailSrc = $thumb_name; } else { $thumbnailSrc = \ImageManager::getThumbnailFilename($this->defaultCategoryImage['src']); } $imageSrc = contrexx_raw2encodedUrl($imageSrc); $thumbnailSrc = contrexx_raw2encodedUrl($thumbnailSrc); $image = $this->getHtmlImageTag($imageSrc, htmlentities($objDownload->getName($_LANGID), ENT_QUOTES, CONTREXX_CHARSET)); $thumbnail = $this->getHtmlImageTag($thumbnailSrc, htmlentities($objDownload->getName($_LANGID), ENT_QUOTES, CONTREXX_CHARSET)); } else { $imageSrc = contrexx_raw2encodedUrl($this->defaultCategoryImage['src']); $thumbnailSrc = contrexx_raw2encodedUrl(\ImageManager::getThumbnailFilename($this->defaultCategoryImage['src'])); $image = $this->getHtmlImageTag($this->defaultCategoryImage['src'], htmlentities($objDownload->getName($_LANGID), ENT_QUOTES, CONTREXX_CHARSET)); $thumbnail = $this->getHtmlImageTag(\ImageManager::getThumbnailFilename($this->defaultCategoryImage['src']), htmlentities($objDownload->getName($_LANGID), ENT_QUOTES, CONTREXX_CHARSET)); } // parse delete icon link if ($allowDeleteFilesFromCategory || $this->userId && $objDownload->getOwnerId() == $this->userId) { $deleteIcon = $this->getHtmlDeleteLinkIcon($objDownload->getId(), htmlspecialchars(str_replace("'", "\\'", $objDownload->getName($_LANGID)), ENT_QUOTES, CONTREXX_CHARSET), 'downloadsDeleteFile'); } else { $deleteIcon = ''; } $this->objTemplate->setVariable(array('TXT_DOWNLOADS_DOWNLOAD' => $_ARRAYLANG['TXT_DOWNLOADS_DOWNLOAD'], 'TXT_DOWNLOADS_ADDED_BY' => $_ARRAYLANG['TXT_DOWNLOADS_ADDED_BY'], 'TXT_DOWNLOADS_LAST_UPDATED' => $_ARRAYLANG['TXT_DOWNLOADS_LAST_UPDATED'], 'TXT_DOWNLOADS_DOWNLOADED' => $_ARRAYLANG['TXT_DOWNLOADS_DOWNLOADED'], 'TXT_DOWNLOADS_VIEWED' => $_ARRAYLANG['TXT_DOWNLOADS_VIEWED'], 'DOWNLOADS_FILE_ID' => $objDownload->getId(), 'DOWNLOADS_FILE_DETAIL_SRC' => CONTREXX_SCRIPT_PATH . $this->moduleParamsHtml . '&category=' . $categoryId . '&id=' . $objDownload->getId(), 'DOWNLOADS_FILE_NAME' => htmlentities($objDownload->getName($_LANGID), ENT_QUOTES, CONTREXX_CHARSET), 'DOWNLOADS_FILE_DESCRIPTION' => nl2br(htmlentities($description, ENT_QUOTES, CONTREXX_CHARSET)), 'DOWNLOADS_FILE_SHORT_DESCRIPTION' => htmlentities($shortDescription, ENT_QUOTES, CONTREXX_CHARSET), 'DOWNLOADS_FILE_IMAGE' => $image, 'DOWNLOADS_FILE_IMAGE_SRC' => $imageSrc, 'DOWNLOADS_FILE_THUMBNAIL' => $thumbnail, 'DOWNLOADS_FILE_THUMBNAIL_SRC' => $thumbnailSrc, 'DOWNLOADS_FILE_ICON' => $this->getHtmlImageTag($objDownload->getIcon(), htmlentities($objDownload->getName($_LANGID), ENT_QUOTES, CONTREXX_CHARSET)), 'DOWNLOADS_FILE_FILE_TYPE_ICON' => $this->getHtmlImageTag($objDownload->getFileIcon(), htmlentities($objDownload->getName($_LANGID), ENT_QUOTES, CONTREXX_CHARSET)), 'DOWNLOADS_FILE_DELETE_ICON' => $deleteIcon, 'DOWNLOADS_FILE_DOWNLOAD_LINK_SRC' => CONTREXX_SCRIPT_PATH . $this->moduleParamsHtml . '&download=' . $objDownload->getId(), 'DOWNLOADS_FILE_OWNER' => $this->getParsedUsername($objDownload->getOwnerId()), 'DOWNLOADS_FILE_OWNER_ID' => $objDownload->getOwnerId(), 'DOWNLOADS_FILE_SRC' => htmlentities($objDownload->getSourceName(), ENT_QUOTES, CONTREXX_CHARSET), 'DOWNLOADS_FILE_LAST_UPDATED' => date(ASCMS_DATE_FORMAT, $objDownload->getMTime()), 'DOWNLOADS_FILE_VIEWS' => $objDownload->getViewCount(), 'DOWNLOADS_FILE_DOWNLOAD_COUNT' => $objDownload->getDownloadCount())); // parse size if ($this->arrConfig['use_attr_size']) { $this->objTemplate->setVariable(array('TXT_DOWNLOADS_SIZE' => $_ARRAYLANG['TXT_DOWNLOADS_SIZE'], 'DOWNLOADS_FILE_SIZE' => $this->getFormatedFileSize($objDownload->getSize()))); $this->objTemplate->touchBlock('download_size_information'); $this->objTemplate->touchBlock('download_size_list'); } else { $this->objTemplate->hideBlock('download_size_information'); $this->objTemplate->hideBlock('download_size_list'); } // parse license if ($this->arrConfig['use_attr_license']) { $this->objTemplate->setVariable(array('TXT_DOWNLOADS_LICENSE' => $_ARRAYLANG['TXT_DOWNLOADS_LICENSE'], 'DOWNLOADS_FILE_LICENSE' => htmlentities($objDownload->getLicense(), ENT_QUOTES, CONTREXX_CHARSET))); $this->objTemplate->touchBlock('download_license_information'); $this->objTemplate->touchBlock('download_license_list'); } else { $this->objTemplate->hideBlock('download_license_information'); $this->objTemplate->hideBlock('download_license_list'); } // parse version if ($this->arrConfig['use_attr_version']) { $this->objTemplate->setVariable(array('TXT_DOWNLOADS_VERSION' => $_ARRAYLANG['TXT_DOWNLOADS_VERSION'], 'DOWNLOADS_FILE_VERSION' => htmlentities($objDownload->getVersion(), ENT_QUOTES, CONTREXX_CHARSET))); $this->objTemplate->touchBlock('download_version_information'); $this->objTemplate->touchBlock('download_version_list'); } else { $this->objTemplate->hideBlock('download_version_information'); $this->objTemplate->hideBlock('download_version_list'); } // parse author if ($this->arrConfig['use_attr_author']) { $this->objTemplate->setVariable(array('TXT_DOWNLOADS_AUTHOR' => $_ARRAYLANG['TXT_DOWNLOADS_AUTHOR'], 'DOWNLOADS_FILE_AUTHOR' => htmlentities($objDownload->getAuthor(), ENT_QUOTES, CONTREXX_CHARSET))); $this->objTemplate->touchBlock('download_author_information'); $this->objTemplate->touchBlock('download_author_list'); } else { $this->objTemplate->hideBlock('download_author_information'); $this->objTemplate->hideBlock('download_author_list'); } // parse website if ($this->arrConfig['use_attr_website']) { $this->objTemplate->setVariable(array('TXT_DOWNLOADS_WEBSITE' => $_ARRAYLANG['TXT_DOWNLOADS_WEBSITE'], 'DOWNLOADS_FILE_WEBSITE' => $this->getHtmlLinkTag(htmlentities($objDownload->getWebsite(), ENT_QUOTES, CONTREXX_CHARSET), htmlentities($objDownload->getWebsite(), ENT_QUOTES, CONTREXX_CHARSET), htmlentities($objDownload->getWebsite(), ENT_QUOTES, CONTREXX_CHARSET)), 'DOWNLOADS_FILE_WEBSITE_SRC' => htmlentities($objDownload->getWebsite(), ENT_QUOTES, CONTREXX_CHARSET))); $this->objTemplate->touchBlock('download_website_information'); $this->objTemplate->touchBlock('download_website_list'); } else { $this->objTemplate->hideBlock('download_website_information'); $this->objTemplate->hideBlock('download_website_list'); } }
/** * Overview Media Data * * @global array $_CONFIG * @global array $_ARRAYLANG * @return string parsed content */ function _overviewMedia() { global $_CONFIG, $_ARRAYLANG; switch ($this->getAct) { case 'download': $this->_downloadMedia(); break; case 'newDir': $this->_createDirectory($_POST['media_directory_name']); break; case 'upload': $this->_uploadFiles(); break; case 'rename': $this->_renameFiles(); break; case 'delete': $this->_deleteFiles(); break; default: } // tree navigation $tmp = $this->arrWebPaths[$this->archive]; if (substr($this->webPath, 0, strlen($tmp)) == $tmp) { $this->_objTpl->setVariable(array('MEDIA_TREE_NAV_MAIN' => "Home /", 'MEDIA_TREE_NAV_MAIN_HREF' => CONTREXX_SCRIPT_PATH . '?section=' . $this->archive . $this->getCmd . '&path=' . rawurlencode($this->arrWebPaths[$this->archive]))); if (strlen($this->webPath) != strlen($tmp)) { $tmpPath = substr($this->webPath, -(strlen($this->webPath) - strlen($tmp))); $tmpPath = explode('/', $tmpPath); $tmpLink = ''; foreach ($tmpPath as $path) { if (!empty($path)) { $tmpLink .= $path . '/'; $this->_objTpl->setVariable(array('MEDIA_TREE_NAV_DIR' => $path, 'MEDIA_TREE_NAV_DIR_HREF' => CONTREXX_SCRIPT_PATH . '?section=' . $this->archive . $this->getCmd . '&path=' . rawurlencode($this->arrWebPaths[$this->archive] . $tmpLink))); $this->_objTpl->parse('mediaTreeNavigation'); } } } } if (isset($_GET['deletefolder']) && ($_GET['deletefolder'] = "success")) { $this->_strOkMessage = $_ARRAYLANG['TXT_MEDIA_FOLDER_DELETED_SUCESSFULLY']; } if (!empty($_GET['highlightFiles'])) { $this->highlightName = array_merge($this->highlightName, array_map('basename', json_decode(contrexx_stripslashes(urldecode($_GET['highlightFiles']))))); } // media directory tree $i = 0; $dirTree = $this->_dirTree($this->path); $dirTree = $this->_sortDirTree($dirTree); foreach (array_keys($dirTree) as $key) { if (is_array($dirTree[$key]['icon'])) { for ($x = 0; $x < count($dirTree[$key]['icon']); $x++) { if (MediaLibrary::isIllegalFileName($dirTree[$key]['name'][$x])) { continue; } $class = $i % 2 ? 'row2' : 'row1'; // highlight if (in_array($dirTree[$key]['name'][$x], $this->highlightName)) { $class .= '" style="background-color: ' . $this->highlightColor . ';'; } if (!$this->manageAccessGranted()) { //if the user is not allowed to delete or rename files -- hide those blocks if ($this->_objTpl->blockExists('manage_access_option')) { $this->_objTpl->hideBlock('manage_access_option'); } } $this->_objTpl->setVariable(array('MEDIA_DIR_TREE_ROW' => $class, 'MEDIA_FILE_ICON' => $dirTree[$key]['icon'][$x], 'MEDIA_FILE_NAME' => $dirTree[$key]['name'][$x], 'MEDIA_FILE_SIZE' => $this->_formatSize($dirTree[$key]['size'][$x]), 'MEDIA_FILE_TYPE' => $this->_formatType($dirTree[$key]['type'][$x]), 'MEDIA_FILE_DATE' => $this->_formatDate($dirTree[$key]['date'][$x]), 'MEDIA_RENAME_TITLE' => $_ARRAYLANG['TXT_MEDIA_RENAME'], 'MEDIA_DELETE_TITLE' => $_ARRAYLANG['TXT_MEDIA_DELETE'])); $tmpHref = $delHref = ''; if ($key == 'dir') { $tmpHref = CONTREXX_SCRIPT_PATH . '?section=' . $this->archive . $this->getCmd . '&path=' . rawurlencode($this->webPath . $dirTree[$key]['name'][$x] . '/'); $delHref = CONTREXX_SCRIPT_PATH . '?section=' . $this->archive . $this->getCmd . '&act=delete&path=' . rawurlencode($this->webPath . $dirTree[$key]['name'][$x] . '/'); } elseif ($key == 'file') { $delHref = CONTREXX_SCRIPT_PATH . '?section=' . $this->archive . $this->getCmd . '&act=delete&path=' . rawurlencode($this->webPath) . '&file=' . rawurlencode($dirTree[$key]['name'][$x]); if ($this->_isImage($this->path . $dirTree[$key]['name'][$x])) { $tmpSize = getimagesize($this->path . $dirTree[$key]['name'][$x]); $tmpHref = 'javascript: preview(\'' . $this->webPath . $dirTree[$key]['name'][$x] . '\', ' . $tmpSize[0] . ', ' . $tmpSize[1] . ');'; } else { $tmpHref = CONTREXX_SCRIPT_PATH . '?section=' . $this->archive . '&act=download&path=' . rawurlencode($this->webPath) . '&file=' . rawurlencode($dirTree[$key]['name'][$x]); } } $this->_objTpl->setVariable(array('MEDIA_FILE_NAME_HREF' => $tmpHref, 'MEDIA_FILE_DELETE_HREF' => $delHref)); $this->_objTpl->parse('mediaDirectoryTree'); $i++; } } } // empty dir or php safe mode restriction if ($i == 0 && !@opendir($this->rootPath)) { $tmpMessage = !@opendir($this->path) ? 'PHP Safe Mode Restriction or wrong path' : $_ARRAYLANG['TXT_MEDIA_DIR_EMPTY']; $this->_objTpl->setVariable(array('TXT_MEDIA_DIR_EMPTY' => $tmpMessage, 'MEDIA_SELECT_STATUS' => ' disabled')); $this->_objTpl->parse('mediaEmptyDirectory'); } // parse variables $tmpHref = CONTREXX_SCRIPT_PATH . '?section=' . $this->archive . $this->getCmd . '&path=' . rawurlencode($this->webPath); $tmpIcon = $this->_sortingIcons(); if ($this->_objTpl->blockExists('manage_access_header')) { if ($this->manageAccessGranted()) { $this->_objTpl->touchBlock('manage_access_header'); } else { $this->_objTpl->hideBlock('manage_access_header'); } } $this->_objTpl->setVariable(array('MEDIA_NAME_HREF' => $tmpHref . '&sort=name&sort_desc=' . ($this->sortBy == 'name' && !$this->sortDesc), 'MEDIA_SIZE_HREF' => $tmpHref . '&sort=size&sort_desc=' . ($this->sortBy == 'size' && !$this->sortDesc), 'MEDIA_TYPE_HREF' => $tmpHref . '&sort=type&sort_desc=' . ($this->sortBy == 'type' && !$this->sortDesc), 'MEDIA_DATE_HREF' => $tmpHref . '&sort=date&sort_desc=' . ($this->sortBy == 'date' && !$this->sortDesc), 'MEDIA_PERM_HREF' => $tmpHref . '&sort=perm&sort_desc=' . ($this->sortBy == 'perm' && !$this->sortDesc), 'TXT_MEDIA_FILE_NAME' => $_ARRAYLANG['TXT_MEDIA_FILE_NAME'], 'TXT_MEDIA_FILE_SIZE' => $_ARRAYLANG['TXT_MEDIA_FILE_SIZE'], 'TXT_MEDIA_FILE_TYPE' => $_ARRAYLANG['TXT_MEDIA_FILE_TYPE'], 'TXT_MEDIA_FILE_DATE' => $_ARRAYLANG['TXT_MEDIA_FILE_DATE'], 'TXT_MEDIA_FILE_PERM' => $_ARRAYLANG['TXT_MEDIA_FILE_PERM'], 'MEDIA_NAME_ICON' => $tmpIcon['name'], 'MEDIA_SIZE_ICON' => $tmpIcon['size'], 'MEDIA_TYPE_ICON' => $tmpIcon['type'], 'MEDIA_DATE_ICON' => $tmpIcon['date'], 'MEDIA_PERM_ICON' => $tmpIcon['perm'], 'MEDIA_JAVASCRIPT' => $this->_getJavaScriptCodePreview())); if (!$this->uploadAccessGranted()) { // if user not allowed to upload files and creating folders -- hide that blocks if ($this->_objTpl->blockExists('media_simple_file_upload')) { $this->_objTpl->hideBlock('media_simple_file_upload'); } if ($this->_objTpl->blockExists('media_advanced_file_upload')) { $this->_objTpl->hideBlock('media_advanced_file_upload'); } if ($this->_objTpl->blockExists('media_create_directory')) { $this->_objTpl->hideBlock('media_create_directory'); } } else { // forms for uploading files and creating folders if ($this->_objTpl->blockExists('media_simple_file_upload')) { //data we want to remember for handling the uploaded files $data = array('path' => $this->path, 'webPath' => $this->webPath); //new uploader $uploader = new \Cx\Core_Modules\Uploader\Model\Entity\Uploader(); $uploader->setData($data); $uploader->setCallback('mediaCallbackJs'); $uploader->setFinishedCallback(array(\Cx\Core\Core\Controller\Cx::instanciate()->getCodeBaseCoreModulePath() . '/Media/Controller/MediaLibrary.class.php', '\\Cx\\Core_modules\\Media\\Controller\\MediaLibrary', 'uploadFinished')); $this->_objTpl->setVariable(array('TXT_MEDIA_ADD_NEW_FILE' => $_ARRAYLANG['TXT_MEDIA_ADD_NEW_FILE'], 'MEDIA_UPLOADER_CODE' => $uploader->getXHtml($_ARRAYLANG['TXT_MEDIA_BROWSE']), 'REDIRECT_URL' => '?section=' . $_REQUEST['section'] . '&path=' . contrexx_raw2encodedUrl($this->webPath))); $this->_objTpl->parse('media_simple_file_upload'); } if ($this->_objTpl->blockExists('media_advanced_file_upload')) { $this->_objTpl->hideBlock('media_advanced_file_upload'); } // create directory $this->_objTpl->setVariable(array('TXT_MEDIA_CREATE_DIRECTORY' => $_ARRAYLANG['TXT_MEDIA_CREATE_DIRECTORY'], 'TXT_MEDIA_CREATE_NEW_DIRECTORY' => $_ARRAYLANG['TXT_MEDIA_CREATE_NEW_DIRECTORY'], 'MEDIA_CREATE_DIRECTORY_URL' => CONTREXX_SCRIPT_PATH . '?section=' . $this->archive . $this->getCmd . '&act=newDir&path=' . $this->webPath)); $this->_objTpl->parse('media_create_directory'); //custom uploader \JS::activate('cx'); // the uploader needs the framework $uploader = new \Cx\Core_Modules\Uploader\Model\Entity\Uploader(); //create an uploader $uploadId = $uploader->getId(); $uploader->setCallback('customUploader'); $uploader->setOptions(array('id' => 'custom_' . $uploadId)); $folderWidget = new \Cx\Core_Modules\MediaBrowser\Model\Entity\FolderWidget($_SESSION->getTempPath() . '/' . $uploadId, true); $folderWidgetId = $folderWidget->getId(); $extendedFileInputCode = <<<CODE <script type="text/javascript"> //uploader javascript callback function function customUploader(callback) { angular.element('#mediaBrowserfolderWidget_{$folderWidgetId}').scope().refreshBrowser(); } </script> CODE; $this->_objTpl->setVariable(array('UPLOADER_CODE' => $uploader->getXHtml(), 'UPLOADER_ID' => $uploadId, 'FILE_INPUT_CODE' => $extendedFileInputCode, 'FOLDER_WIDGET_CODE' => $folderWidget->getXHtml())); } }
/** * Gets the search results. * * @return mixed Parsed content. */ public function getSearchResults() { global $_ARRAYLANG; $this->template->addBlockfile('ADMIN_CONTENT', 'search', 'Default.html'); if (!empty($this->term)) { $pages = $this->getSearchedPages(); $countPages = $this->countSearchedPages(); usort($pages, array($this, 'sortPages')); if ($countPages > 0) { $parameter = '&cmd=Search' . (empty($this->term) ? '' : '&term=' . contrexx_raw2encodedUrl($this->term)); $paging = \Paging::get($parameter, '', $countPages, 0, true, null, 'pos'); $this->template->setVariable(array('TXT_SEARCH_RESULTS_COMMENT' => sprintf($_ARRAYLANG['TXT_SEARCH_RESULTS_COMMENT'], $this->term, $countPages), 'TXT_SEARCH_TITLE' => $_ARRAYLANG['TXT_NAVIGATION_TITLE'], 'TXT_SEARCH_CONTENT_TITLE' => $_ARRAYLANG['TXT_PAGETITLE'], 'TXT_SEARCH_SLUG' => $_ARRAYLANG['TXT_CORE_CM_SLUG'], 'TXT_SEARCH_LANG' => $_ARRAYLANG['TXT_LANGUAGE'], 'SEARCH_PAGING' => $paging)); foreach ($pages as $page) { // used for alias pages, because they have no language if ($page->getLang() == "") { $languages = ""; foreach (\FWLanguage::getIdArray('frontend') as $langId) { $languages[] = \FWLanguage::getLanguageCodeById($langId); } } else { $languages = array(\FWLanguage::getLanguageCodeById($page->getLang())); } $aliasLanguages = implode(', ', $languages); $originalPage = $page; $link = 'index.php?cmd=ContentManager&page=' . $page->getId(); if ($page->getType() == \Cx\Core\ContentManager\Model\Entity\Page::TYPE_ALIAS) { $pageRepo = \Env::get('em')->getRepository('Cx\\Core\\ContentManager\\Model\\Entity\\Page'); if ($originalPage->isTargetInternal()) { // is internal target, get target page $originalPage = $pageRepo->getTargetPage($page); } else { // is an external target, set the link to the external targets url $originalPage = new \Cx\Core\ContentManager\Model\Entity\Page(); $originalPage->setTitle($page->getTarget()); $link = $page->getTarget(); } } $this->template->setVariable(array('SEARCH_RESULT_BACKEND_LINK' => $link, 'SEARCH_RESULT_TITLE' => $originalPage->getTitle(), 'SEARCH_RESULT_CONTENT_TITLE' => $originalPage->getContentTitle(), 'SEARCH_RESULT_SLUG' => substr($page->getPath(), 1), 'SEARCH_RESULT_LANG' => $aliasLanguages, 'SEARCH_RESULT_FRONTEND_LINK' => \Cx\Core\Routing\Url::fromPage($page))); $this->template->parse('search_result_row'); } } else { $this->template->setVariable(array('TXT_SEARCH_NO_RESULTS' => sprintf($_ARRAYLANG['TXT_SEARCH_NO_RESULTS'], $this->term))); } } else { $this->template->setVariable(array('TXT_SEARCH_NO_TERM' => $_ARRAYLANG['TXT_SEARCH_NO_TERM'])); } }
public function getPage($pos, $page_content) { global $_CONFIG, $_ARRAYLANG; $objTpl = new \Cx\Core\Html\Sigma('.'); \Cx\Core\Csrf\Controller\Csrf::add_placeholder($objTpl); $objTpl->setErrorHandling(PEAR_ERROR_DIE); $objTpl->setTemplate($page_content); $objTpl->setGlobalVariable($_ARRAYLANG); // Load main template even if we have a cmd set if ($objTpl->placeholderExists('APPLICATION_DATA')) { $page = new \Cx\Core\ContentManager\Model\Entity\Page(); $page->setVirtual(true); $page->setType(\Cx\Core\ContentManager\Model\Entity\Page::TYPE_APPLICATION); $page->setModule('Search'); // load source code $applicationTemplate = \Cx\Core\Core\Controller\Cx::getContentTemplateOfPage($page); \LinkGenerator::parseTemplate($applicationTemplate); $objTpl->addBlock('APPLICATION_DATA', 'application_data', $applicationTemplate); } $term = isset($_REQUEST['term']) ? trim(contrexx_input2raw($_REQUEST['term'])) : ''; if (strlen($term) >= 3) { $term = trim(contrexx_input2raw($_REQUEST['term'])); $this->setTerm($term); $eventHandlerInstance = \Env::get('cx')->getEvents(); $eventHandlerInstance->triggerEvent('SearchFindContent', array($this)); if ($this->result->size() == 1) { $arraySearchResults[] = $this->result->toArray(); } else { $arraySearchResults = $this->result->toArray(); } usort($arraySearchResults, function ($a, $b) { if ($a['Score'] == $b['Score']) { if (isset($a['Date'])) { if ($a['Date'] == $b['Date']) { return 0; } if ($a['Date'] > $b['Date']) { return -1; } return 1; } return 0; } if ($a['Score'] > $b['Score']) { return -1; } return 1; }); $countResults = sizeof($arraySearchResults); if (!is_numeric($pos)) { $pos = 0; } $paging = getPaging($countResults, $pos, '&section=Search&term=' . contrexx_raw2encodedUrl($term), '<b>' . $_ARRAYLANG['TXT_SEARCH_RESULTS'] . '</b>', true); $objTpl->setVariable('SEARCH_PAGING', $paging); $objTpl->setVariable('SEARCH_TERM', contrexx_raw2xhtml($term)); if ($countResults > 0) { $searchComment = sprintf($_ARRAYLANG['TXT_SEARCH_RESULTS_ORDER_BY_RELEVANCE'], contrexx_raw2xhtml($term), $countResults); $objTpl->setVariable('SEARCH_TITLE', $searchComment); $arraySearchOut = array_slice($arraySearchResults, $pos, $_CONFIG['corePagingLimit']); foreach ($arraySearchOut as $details) { // append search term to result link $link = $details['Link']; if (strpos($link, '?') === false) { $link .= '?'; } else { $link .= '&'; } $link .= 'searchTerm=' . urlencode($term); // parse result into template $objTpl->setVariable(array('COUNT_MATCH' => $_ARRAYLANG['TXT_RELEVANCE'] . ' ' . $details['Score'] . '%', 'LINK' => '<b><a href="' . $link . '" title="' . contrexx_raw2xhtml($details['Title']) . '">' . contrexx_raw2xhtml($details['Title']) . '</a></b>', 'SHORT_CONTENT' => contrexx_raw2xhtml($details['Content']))); $objTpl->parse('search_result'); } return $objTpl->get(); } } $noresult = $term != '' ? sprintf($_ARRAYLANG['TXT_NO_SEARCH_RESULTS'], $term) : $_ARRAYLANG['TXT_PLEASE_ENTER_SEARCHTERM']; $objTpl->setVariable('SEARCH_TITLE', $noresult); return $objTpl->get(); }
/** * Returns HTML code for an image element that links to * the filebrowser for choosing an image file on the server * * If the optional $imagetype_key is missing (defaults to false), * no image type can be selected. If it's a string, the type of the * Image is set to this key. If it's an array of keys, the Image type * can be selected from these. * Uses the $id parameter as prefix for both the name and id attributes * of all HTML elements. The names and respective suffixes are: * - id+'img' for the name and id of the <img> tag * - id+'_src' for the name and id of the hidden <input> tag for the image URI * - id+'_width' for the name and id of the hidden <input> tag for the width * - id+'_height' for the name and id of the hidden <input> tag for the height * All of the elements with a suffix will provide the current selected * image information when the form is posted. * See {@see Image::updatePostImages()} and {@see Image::uploadAndStore()} * for more information and examples. * @param Image $objImage The image object * @param string $id The base name for the elements IDs * @param mixed $imagetype_key The optional Image type key * @return string The HTML code for all the elements */ static function getImageChooserBrowser($objImage, $id, $imagetype_key = false, $type = null, $path = null) { global $_CORELANG; JS::registerCode(self::getJavascript_Image(Image::PATH_NO_IMAGE)); if (empty($objImage)) { $objImage = new Image(0); } $type_element = ''; // '<input type="hidden" id="'.$id.'_type" name="'.$id.'_type"'. // ' value="'.$imagetype_key.'" />'."\n"; // TODO: Implement... /* if (is_array($imagetype_key)) { $arrImagetypeName = \Cx\Core\ImageType\Controller\ImageType::getNameArray(); $type_element = self::getSelect($id.'_type', $arrImagetypeName); } */ return $type_element . '<img id="' . $id . '_img" src="' . contrexx_raw2encodedUrl(ASCMS_PATH_OFFSET . '/' . $objImage->getPath()) . '"' . ' style="width:' . $objImage->getWidth() . 'px; height:' . $objImage->getHeight() . 'px;"' . ' title="' . $_CORELANG['TXT_CORE_HTML_IMAGE_PREVIEW'] . '"' . ' alt="' . $_CORELANG['TXT_CORE_HTML_IMAGE_PREVIEW'] . '" />' . "\n" . self::getHidden($id . '_type', $imagetype_key !== false ? $imagetype_key : $objImage->getImagetypeKey(), '') . ($objImage->getPath() ? self::getClearImageCode($id) . self::getHidden($id . '_id', $objImage->getId(), '') . self::getHidden($id . '_ord', $objImage->getOrd(), '') : '') . self::getHidden($id . '_src', $objImage->getPath(), '') . self::getHidden($id . '_width', '', '') . self::getHidden($id . '_height', '', '') . '<a href="javascript:void(0);" title="' . $_CORELANG['TXT_CORE_HTML_CHOOSE_IMAGE'] . '"' . ' tabindex="' . ++self::$index_tab . '"' . ' onclick="openBrowser(\'index.php?cmd=FileBrowser&standalone=true' . ($type ? '&type=' . $type : '') . ($path ? '&path=' . $path : '') . '\',\'' . $id . '\',' . '\'width=800,height=640,resizable=yes,status=no,scrollbars=yes\');">' . $_CORELANG['TXT_CORE_HTML_CHOOSE_IMAGE'] . "</a>\n"; }
public function getPage($pos, $page_content) { global $_CONFIG, $_ARRAYLANG; $objTpl = new \Cx\Core\Html\Sigma('.'); \Cx\Core\Csrf\Controller\Csrf::add_placeholder($objTpl); $objTpl->setErrorHandling(PEAR_ERROR_DIE); $objTpl->setTemplate($page_content); $objTpl->setGlobalVariable($_ARRAYLANG); $term = isset($_REQUEST['term']) ? trim(contrexx_input2raw($_REQUEST['term'])) : ''; if (strlen($term) >= 3) { $term = trim(contrexx_input2raw($_REQUEST['term'])); $this->setTerm($term); $eventHandlerInstance = \Env::get('cx')->getEvents(); $eventHandlerInstance->triggerEvent('SearchFindContent', array($this)); if ($this->result->size() == 1) { $arraySearchResults[] = $this->result->toArray(); } else { $arraySearchResults = $this->result->toArray(); } usort($arraySearchResults, function ($a, $b) { if ($a['Score'] == $b['Score']) { if (isset($a['Date'])) { if ($a['Date'] == $b['Date']) { return 0; } if ($a['Date'] > $b['Date']) { return -1; } return 1; } return 0; } if ($a['Score'] > $b['Score']) { return -1; } return 1; }); $countResults = sizeof($arraySearchResults); if (!is_numeric($pos)) { $pos = 0; } $paging = getPaging($countResults, $pos, '&section=Search&term=' . contrexx_raw2encodedUrl($term), '<b>' . $_ARRAYLANG['TXT_SEARCH_RESULTS'] . '</b>', true); $objTpl->setVariable('SEARCH_PAGING', $paging); $objTpl->setVariable('SEARCH_TERM', contrexx_raw2xhtml($term)); if ($countResults > 0) { $searchComment = sprintf($_ARRAYLANG['TXT_SEARCH_RESULTS_ORDER_BY_RELEVANCE'], contrexx_raw2xhtml($term), $countResults); $objTpl->setVariable('SEARCH_TITLE', $searchComment); $arraySearchOut = array_slice($arraySearchResults, $pos, $_CONFIG['corePagingLimit']); foreach ($arraySearchOut as $details) { $objTpl->setVariable(array('COUNT_MATCH' => $_ARRAYLANG['TXT_RELEVANCE'] . ' ' . $details['Score'] . '%', 'LINK' => '<b><a href="' . $details['Link'] . '" title="' . contrexx_raw2xhtml($details['Title']) . '">' . contrexx_raw2xhtml($details['Title']) . '</a></b>', 'SHORT_CONTENT' => contrexx_raw2xhtml($details['Content']))); $objTpl->parse('search_result'); } return $objTpl->get(); } } $noresult = $term != '' ? sprintf($_ARRAYLANG['TXT_NO_SEARCH_RESULTS'], $term) : $_ARRAYLANG['TXT_PLEASE_ENTER_SEARCHTERM']; $objTpl->setVariable('SEARCH_TITLE', $noresult); return $objTpl->get(); }
/** * Manage products * * Add and edit products * @access public * @return string * @author Reto Kohli <*****@*****.**> (parts) */ function view_product_edit() { global $_ARRAYLANG; self::store_product(); $product_id = isset($_REQUEST['id']) ? intval($_REQUEST['id']) : 0; $objProduct = null; self::$objTemplate->addBlockfile('SHOP_PRODUCTS_FILE', 'shop_products_block', 'module_shop_product_manage.html'); self::$objTemplate->setGlobalVariable($_ARRAYLANG); $cx = \Cx\Core\Core\Controller\Cx::instanciate(); self::$objTemplate->setVariable(array('SHOP_DELETE_ICON' => $cx->getCodeBaseCoreWebPath() . '/Core/View/Media/icons/delete.gif', 'SHOP_NO_PICTURE_ICON' => self::$defaultImage)); if ($product_id > 0) { $objProduct = Product::getById($product_id); } if (!$objProduct) { $objProduct = new Product('', 0, '', '', 0, 1, 0, 0); } $this->viewpart_product_attributes($product_id); $arrImages = Products::get_image_array_from_base64($objProduct->pictures()); // Virtual Categories are disabled FTTB // $flagsSelection = // ShopCategories::getVirtualCategoriesSelectionForFlags( // $objProduct->flags() // ); // if ($flagsSelection) { // self::$objTemplate->setVariable( // 'SHOP_FLAGS_SELECTION', $flagsSelection); // } // // media browser $mediaBrowserOptions = array('type' => 'button', 'data-cx-mb-startmediatype' => 'shop', 'data-cx-mb-views' => 'filebrowser', 'id' => 'media_browser_shop', 'style' => 'display:none'); self::$objTemplate->setVariable(array('MEDIABROWSER_BUTTON' => self::getMediaBrowserButton($mediaBrowserOptions, 'setSelectedImage'))); $distribution = $objProduct->distribution(); // Available active frontend groups, and those assigned to the product $objGroup = \FWUser::getFWUserObject()->objGroup->getGroups(array('type' => 'frontend', 'is_active' => true), array('group_id' => 'asc')); $usergroup_ids = $objProduct->usergroup_ids(); $arrAssignedFrontendGroupId = explode(',', $usergroup_ids); $strActiveFrontendGroupOptions = ''; $strAssignedFrontendGroupOptions = ''; while ($objGroup && !$objGroup->EOF) { $strOption = '<option value="' . $objGroup->getId() . '">' . htmlentities($objGroup->getName(), ENT_QUOTES, CONTREXX_CHARSET) . '</option>'; if (in_array($objGroup->getId(), $arrAssignedFrontendGroupId)) { $strAssignedFrontendGroupOptions .= $strOption; } else { $strActiveFrontendGroupOptions .= $strOption; } $objGroup->next(); } $discount_group_count_id = $objProduct->group_id(); $discount_group_article_id = $objProduct->article_id(); $keywords = $objProduct->keywords(); //die($objProduct->category_id()); // Product assigned to multiple Categories $arrAssignedCategories = ShopCategories::getAssignedShopCategoriesMenuoptions($objProduct->category_id()); // Date format for Datepicker: // Clear the date if none is set; there's no point in displaying // "01/01/1970" instead $start_date = $end_date = ''; $start_time = strtotime($objProduct->date_start()); // Note that the check for ">0" is necessary, as some systems return // crazy values for empty dates (it may even fail like this)! if ($start_time > 0) { $start_date = date(ASCMS_DATE_FORMAT_DATE, $start_time); } $end_time = strtotime($objProduct->date_end()); if ($end_time > 0) { $end_date = date(ASCMS_DATE_FORMAT_DATE, $end_time); } //DBG::log("Dates from ".$objProduct->date_start()." ($start_time, $start_date) to ".$objProduct->date_start()." ($end_time, $end_date)"); $websiteImagesShopPath = $cx->getWebsiteImagesShopPath() . '/'; $websiteImagesShopWebPath = $cx->getWebsiteImagesShopWebPath() . '/'; self::$objTemplate->setVariable(array('SHOP_PRODUCT_ID' => isset($_REQUEST['new']) ? 0 : $objProduct->id(), 'SHOP_PRODUCT_CODE' => contrexx_raw2xhtml($objProduct->code()), 'SHOP_PRODUCT_NAME' => contrexx_raw2xhtml($objProduct->name()), 'SHOP_CATEGORIES_ASSIGNED' => $arrAssignedCategories['assigned'], 'SHOP_CATEGORIES_AVAILABLE' => $arrAssignedCategories['available'], 'SHOP_CUSTOMER_PRICE' => contrexx_raw2xhtml(Currency::formatPrice($objProduct->price())), 'SHOP_RESELLER_PRICE' => contrexx_raw2xhtml(Currency::formatPrice($objProduct->resellerprice())), 'SHOP_DISCOUNT' => contrexx_raw2xhtml(Currency::formatPrice($objProduct->discountprice())), 'SHOP_SPECIAL_OFFER' => $objProduct->discount_active() ? \Html::ATTRIBUTE_CHECKED : '', 'SHOP_VAT_MENUOPTIONS' => Vat::getMenuoptions($objProduct->vat_id(), true), 'SHOP_SHORT_DESCRIPTION' => new \Cx\Core\Wysiwyg\Wysiwyg('short', $objProduct->short()), 'SHOP_DESCRIPTION' => new \Cx\Core\Wysiwyg\Wysiwyg('long', $objProduct->long(), 'full'), 'SHOP_STOCK' => $objProduct->stock(), 'SHOP_MIN_ORDER_QUANTITY' => $objProduct->minimum_order_quantity(), 'SHOP_MANUFACTURER_URL' => contrexx_raw2xhtml($objProduct->uri()), 'SHOP_DATE_START' => \Html::getDatepicker('date_start', array('defaultDate' => $start_date), ''), 'SHOP_DATE_END' => \Html::getDatepicker('date_end', array('defaultDate' => $end_date), ''), 'SHOP_ARTICLE_ACTIVE' => $objProduct->active() ? \Html::ATTRIBUTE_CHECKED : '', 'SHOP_B2B' => $objProduct->b2b() ? \Html::ATTRIBUTE_CHECKED : '', 'SHOP_B2C' => $objProduct->b2c() ? \Html::ATTRIBUTE_CHECKED : '', 'SHOP_STOCK_VISIBILITY' => $objProduct->stock_visible() ? \Html::ATTRIBUTE_CHECKED : '', 'SHOP_MANUFACTURER_MENUOPTIONS' => Manufacturer::getMenuoptions($objProduct->manufacturer_id()), 'SHOP_PICTURE1_IMG_SRC' => !empty($arrImages[1]['img']) && is_file(\ImageManager::getThumbnailFilename($websiteImagesShopPath . $arrImages[1]['img'])) ? contrexx_raw2encodedUrl(\ImageManager::getThumbnailFilename($websiteImagesShopWebPath . $arrImages[1]['img'])) : self::$defaultImage, 'SHOP_PICTURE2_IMG_SRC' => !empty($arrImages[2]['img']) && is_file(\ImageManager::getThumbnailFilename($websiteImagesShopPath . $arrImages[2]['img'])) ? contrexx_raw2encodedUrl(\ImageManager::getThumbnailFilename($websiteImagesShopWebPath . $arrImages[2]['img'])) : self::$defaultImage, 'SHOP_PICTURE3_IMG_SRC' => !empty($arrImages[3]['img']) && is_file(\ImageManager::getThumbnailFilename($websiteImagesShopPath . $arrImages[3]['img'])) ? contrexx_raw2encodedUrl(\ImageManager::getThumbnailFilename($websiteImagesShopWebPath . $arrImages[3]['img'])) : self::$defaultImage, 'SHOP_PICTURE1_IMG_SRC_NO_THUMB' => !empty($arrImages[1]['img']) && is_file($websiteImagesShopPath . $arrImages[1]['img']) ? $websiteImagesShopWebPath . $arrImages[1]['img'] : self::$defaultImage, 'SHOP_PICTURE2_IMG_SRC_NO_THUMB' => !empty($arrImages[2]['img']) && is_file($websiteImagesShopPath . $arrImages[2]['img']) ? $websiteImagesShopWebPath . $arrImages[2]['img'] : self::$defaultImage, 'SHOP_PICTURE3_IMG_SRC_NO_THUMB' => !empty($arrImages[3]['img']) && is_file($websiteImagesShopPath . $arrImages[3]['img']) ? $websiteImagesShopWebPath . $arrImages[3]['img'] : self::$defaultImage, 'SHOP_PICTURE1_IMG_WIDTH' => $arrImages[1]['width'], 'SHOP_PICTURE1_IMG_HEIGHT' => $arrImages[1]['height'], 'SHOP_PICTURE2_IMG_WIDTH' => $arrImages[2]['width'], 'SHOP_PICTURE2_IMG_HEIGHT' => $arrImages[2]['height'], 'SHOP_PICTURE3_IMG_WIDTH' => $arrImages[3]['width'], 'SHOP_PICTURE3_IMG_HEIGHT' => $arrImages[3]['height'], 'SHOP_DISTRIBUTION_MENU' => Distribution::getDistributionMenu($objProduct->distribution(), 'distribution', 'distributionChanged();', 'style="width: 220px"'), 'SHOP_WEIGHT' => $distribution == 'delivery' ? Weight::getWeightString($objProduct->weight()) : '0 g', 'SHOP_GROUPS_AVAILABLE' => $strActiveFrontendGroupOptions, 'SHOP_GROUPS_ASSIGNED' => $strAssignedFrontendGroupOptions, 'SHOP_ACCOUNT_VALIDITY_OPTIONS' => \FWUser::getValidityMenuOptions($distribution == 'download' ? $objProduct->weight() : 0), 'SHOP_CREATE_ACCOUNT_YES_CHECKED' => empty($usergroup_ids) ? '' : \Html::ATTRIBUTE_CHECKED, 'SHOP_CREATE_ACCOUNT_NO_CHECKED' => empty($usergroup_ids) ? \Html::ATTRIBUTE_CHECKED : '', 'SHOP_DISCOUNT_GROUP_COUNT_MENU_OPTIONS' => Discount::getMenuOptionsGroupCount($discount_group_count_id), 'SHOP_DISCOUNT_GROUP_ARTICLE_MENU_OPTIONS' => Discount::getMenuOptionsGroupArticle($discount_group_article_id), 'SHOP_KEYWORDS' => contrexx_raw2xhtml($keywords), 'SHOP_WEIGHT_ENABLED' => \Cx\Core\Setting\Controller\Setting::getValue('weight_enable', 'Shop') ? 1 : 0)); return true; }
/** * Shows the category-details-page * * @global ADONewConnection * @global array * @global array */ function showCategoryDetails($intCatId) { global $objDatabase, $_ARRAYLANG, $_CONFIG; try { if (!$this->checkCategoryAccess($intCatId)) { $this->overview(); return; } } catch (DatabaseError $e) { $this->strErrMessage = $_ARRAYLANG['TXT_GALLERY_CATEGORY_STATUS_MESSAGE_DATABASE_ERROR']; $this->strErrMessage .= $e; return; } \JS::activate('shadowbox'); $objFWUser = \FWUser::getFWUserObject(); $this->_objTpl->loadTemplateFile('module_gallery_category_details.html', true, true); $this->_objTpl->setGlobalVariable(array('TXT_TITLE_NAME' => $_ARRAYLANG['TXT_GALLERY_CAT_DETAILS_NAME'], 'TXT_TITLE_ORDER' => $_ARRAYLANG['TXT_GALLERY_CAT_DETAILS_ORDER'], 'TXT_TITLE_ACTION' => $_ARRAYLANG['TXT_GALLERY_CAT_DETAILS_ACTION'], 'TXT_TITLE_ATTR' => $_ARRAYLANG['TXT_GALLERY_CAT_DETAILS_ATTR'], 'TXT_TITLE_OTHER' => $_ARRAYLANG['TXT_GALLERY_CAT_DETAILS_OTHER'], 'TXT_TITLE_CATEGORY' => $_ARRAYLANG['TXT_CATEGORY'], 'TXT_ACTIVATE_PICTURE' => $_ARRAYLANG['TXT_GALLERY_CAT_DETAILS_DE_ACTIVATE'], 'TXT_SET_CATIMG' => $_ARRAYLANG['TXT_GALLERY_CAT_DETAILS_SET_CATIMG'], 'TXT_RESET_PICTURE' => $_ARRAYLANG['TXT_GALLERY_CAT_DETAILS_RESET_PICTURE_MSG'], 'TXT_DELETE_PICTURE' => $_ARRAYLANG['TXT_GALLERY_DELETE_IMAGE_MSG'], 'TXT_DELETE_PICTURE_ALL' => $_ARRAYLANG['TXT_GALLERY_DELETE_IMAGE_ALL_MSG'], 'TXT_IMG_ROTATE_ALT' => $_ARRAYLANG['TXT_GALLERY_ROTATE'], 'TXT_IMG_RESET_ALT' => $_ARRAYLANG['TXT_RESET'], 'TXT_IMG_EDIT_ALT' => $_ARRAYLANG['TXT_EDIT'], 'TXT_IMG_DELETE_ALT' => $_ARRAYLANG['TXT_DELETE'], 'TXT_BUTTON_SAVESORT' => $_ARRAYLANG['TXT_GALLERY_BUTTON_SAVE_SORT'], 'TXT_ORIG_CAPT' => $_ARRAYLANG['TXT_GALLERY_CAT_DETAILS_ORIG_CAPT'], 'TXT_THUMB_CAPT' => $_ARRAYLANG['TXT_GALLERY_CAT_DETAILS_THUMB_CAPT'], 'TXT_THUMB_QUALITY_CAPT' => $_ARRAYLANG['TXT_GALLERY_CAT_DETAILS_THUMB_QUALITY_CAPT'], 'TXT_SELECT_ALL' => $_ARRAYLANG['TXT_SELECT_ALL'], 'TXT_DESELECT_ALL' => $_ARRAYLANG['TXT_DESELECT_ALL'], 'TXT_SUBMIT_SELECT' => $_ARRAYLANG['TXT_GALLERY_CAT_DETAILS_SUBMIT_SELECT'], 'TXT_SUBMIT_DELETE' => $_ARRAYLANG['TXT_GALLERY_CAT_DETAILS_SUBMIT_DELETE'], 'TXT_SUBMIT_ACTIVATE' => $_ARRAYLANG['TXT_GALLERY_CAT_DETAILS_SUBMIT_ACTIVATE'], 'TXT_SUBMIT_DEACTIVATE' => $_ARRAYLANG['TXT_GALLERY_CAT_DETAILS_SUBMIT_DEACTIVATE'], 'TXT_SUBMIT_RESET' => $_ARRAYLANG['TXT_GALLERY_CAT_DETAILS_SUBMIT_RESET'], 'TXT_SUBMIT_MOVE' => $_ARRAYLANG['TXT_GALLERY_CAT_DETAILS_SUBMIT_MOVE'])); $objResult = $objDatabase->Execute('SELECT value FROM ' . DBPREFIX . 'module_gallery_language WHERE gallery_id=' . intval($intCatId) . ' AND lang_id=' . $objFWUser->objUser->getFrontendLanguage() . ' AND name="desc" '); $strCategoryComment = $objResult->fields['value']; $objResult = $objDatabase->Execute('SELECT comment, voting FROM ' . DBPREFIX . 'module_gallery_categories WHERE id=' . $intCatId); $boolComment = $objResult->fields['comment']; $boolVoting = $objResult->fields['voting']; $this->_objTpl->setGlobalVariable(array('CATEGORY_NAME' => $strCategoryComment, 'CATEGORY_ID' => $intCatId)); $selectQuery = 'FROM ' . DBPREFIX . 'module_gallery_pictures WHERE catid=' . $intCatId . ' AND validated="1" ORDER BY sorting ASC, id ASC'; $objCount = $objDatabase->SelectLimit('SELECT count(id) AS picCount ' . $selectQuery, 1); $pos = isset($_GET['pos']) ? intval($_GET['pos']) : 0; if ($objCount !== false && $objCount->fields['picCount'] > $_CONFIG['corePagingLimit']) { $this->_objTpl->setVariable('GALLERY_PAGING', '<br />' . getPaging($objCount->fields['picCount'], $pos, '&cmd=Gallery&act=cat_details&id=' . $intCatId, 'bilder')); } $objResult = $objDatabase->SelectLimit('SELECT id ' . $selectQuery, $_CONFIG['corePagingLimit'], $pos); if ($objResult->RecordCount() == 0) { $this->_objTpl->hideBlock('showImages'); } else { while (!$objResult->EOF) { $arrImages[$objResult->fields['id']] = $objResult->fields['id']; $objResult->MoveNext(); } $intRowCounter = 0; $this->_objTpl->setCurrentBlock('showImages'); foreach ($arrImages as $strValue) { $objResult = $objDatabase->Execute('SELECT * FROM ' . DBPREFIX . 'module_gallery_pictures WHERE id=' . $strValue); $objSubResult = $objDatabase->Execute(' SELECT name FROM ' . DBPREFIX . 'module_gallery_language_pics WHERE picture_id=' . $objResult->fields['id'] . ' AND lang_id=' . FRONTEND_LANG_ID . ' LIMIT 1 '); if ($objResult->fields['catimg'] == '1') { $this->_objTpl->setVariable('IMAGES_ROWCLASS', 'rowWarn'); } else { if ($intRowCounter % 2 == 0) { $this->_objTpl->setVariable('IMAGES_ROWCLASS', 'row0'); } else { $this->_objTpl->setVariable('IMAGES_ROWCLASS', 'row1'); } } ++$intRowCounter; if ($objResult->fields['status'] == '0') { $outputActiveIcon = 'led_red.gif'; } else { $outputActiveIcon = 'led_green.gif'; } if ($objResult->fields['catimg'] == '0') { $outputCatimgIcon = 'preview_grey.gif'; } else { $outputCatimgIcon = 'preview.gif'; } if ($objResult->fields['link'] == '') { // the linkfield is empty $outputLinkIconS = '<!--'; $outputLinkIconE = '-->'; } else { $outputLinkIconS = ''; $outputLinkIconE = ''; } $intOutputId = $objResult->fields['id']; $strOutputSorting = $objResult->fields['sorting']; $arrOrigFileInfo = getimagesize($this->strImagePath . $objResult->fields['path']); $arrThumbFileInfo = getimagesize($this->strThumbnailPath . $objResult->fields['path']); $strOutputThumbpath = $this->strThumbnailWebPath . $objResult->fields['path']; $strOutputOrigpath = $this->strImageWebPath . $objResult->fields['path']; $strOutputName = $objSubResult->fields['name']; $strOutputLastedit = date('d.m.Y', $objResult->fields['lastedit']); $strOutputOrigReso = $arrOrigFileInfo[0] . 'x' . $arrOrigFileInfo[1]; $strOutputOrigWidth = $arrOrigFileInfo[0] + 20; $strOutputOrigHeight = $arrOrigFileInfo[1] + 25; $strOutputOrigSize = round(filesize($this->strImagePath . $objResult->fields['path']) / 1024, 2); $strOutputThumbReso = $arrThumbFileInfo[0] . 'x' . $arrThumbFileInfo[1]; $strOutputThumbSize = round(filesize($this->strThumbnailPath . $objResult->fields['path']) / 1024, 2); if ($objResult->fields['size_type'] == 'abs') { $strOutputTypeMethod = $_ARRAYLANG['TXT_GALLERY_VALIDATE_THUMB_SIZE_ABS']; $strOutputTypeSize = $objResult->fields['quality'] . '%'; } else { $strOutputTypeMethod = $_ARRAYLANG['TXT_GALLERY_VALIDATE_THUMB_SIZE_PER'] . ' :' . $objResult->fields['size_proz']; $strOutputTypeSize = $objResult->fields['quality'] . '%'; } if ($this->arrSettings['show_comments'] == 'on' && $boolComment) { $objSubResult = $objDatabase->Execute(' SELECT id FROM ' . DBPREFIX . 'module_gallery_comments WHERE picid=' . $objResult->fields['id'] . ' '); $strOutputCommentCount = $objSubResult->RecordCount() . ' ' . $_ARRAYLANG['TXT_GALLERY_COMMENTS'] . '<br />'; } else { // show nothing $strOutputCommentCount = ""; } if ($this->arrSettings['show_voting'] == 'on' && $boolVoting) { $objSubResult = $objDatabase->Execute(' SELECT mark FROM ' . DBPREFIX . 'module_gallery_votes WHERE picid=' . $objResult->fields['id'] . ' '); $strOutputVotingCount = $objSubResult->RecordCount() . ' ' . $_ARRAYLANG['TXT_GALLERY_RATING']; if ($strOutputVotingCount > 0) { $intMark = 0; while (!$objSubResult->EOF) { $intMark = $intMark + $objSubResult->fields['mark']; $objSubResult->MoveNext(); } $outputVotingAverage = ', Ø ' . number_format(round($intMark / $strOutputVotingCount, 1), 1, '.', '\''); } else { $outputVotingAverage = ', Ø 0.0'; } } else { // show nothing $strOutputVotingCount = ""; $outputVotingAverage = ""; } // parse the dropdown for the categories try { $this->parseCategoryDropdown($intCatId, false); } catch (DatabaseError $e) { $this->strErrMessage = $_ARRAYLANG['TXT_GALLERY_CATEGORY_STATUS_MESSAGE_DATABASE_ERROR']; $this->strErrMessage .= $e; return; } // remove last part (file name ending) if any $imageNameParts = explode('.', $strOutputName); if (count($imageNameParts) > 1) { end($imageNameParts); unset($imageNameParts[key($imageNameParts)]); $strOutputName = implode('.', $imageNameParts); } $this->_objTpl->setVariable(array('IMAGES_ID' => contrexx_raw2xhtml($intOutputId), 'IMAGES_THUMB_PATH' => contrexx_raw2encodedUrl($strOutputThumbpath), 'IMAGE_ORIG_PATH' => contrexx_raw2encodedUrl($strOutputOrigpath), 'IMAGES_ACTIVE_ICON' => contrexx_raw2xhtml($outputActiveIcon), 'IMAGES_CATIMG_ICON' => contrexx_raw2xhtml($outputCatimgIcon), 'IMAGES_HIDE_LINKICON_S' => $outputLinkIconS, 'IMAGES_HIDE_LINKICON_E' => $outputLinkIconE, 'IMAGES_NAME' => contrexx_raw2xhtml($strOutputName), 'IMAGES_LASTEDIT' => contrexx_raw2xhtml($strOutputLastedit), 'IMAGES_ORIG_RESO' => contrexx_raw2xhtml($strOutputOrigReso), 'IMAGES_ORIG_WIDTH' => contrexx_raw2xhtml($strOutputOrigWidth), 'IMAGES_ORIG_HEIGHT' => contrexx_raw2xhtml($strOutputOrigHeight), 'IMAGES_ORIG_SIZE' => contrexx_raw2xhtml($strOutputOrigSize), 'IMAGES_THUMB_RESO' => contrexx_raw2xhtml($strOutputThumbReso), 'IMAGES_THUMB_SIZE' => contrexx_raw2xhtml($strOutputThumbSize), 'IMAGES_TYPE_METHOD' => contrexx_raw2xhtml($strOutputTypeMethod), 'IMAGES_TYPE_SIZE' => contrexx_raw2xhtml($strOutputTypeSize), 'IMAGES_SORTING' => contrexx_raw2xhtml($strOutputSorting), 'IMAGES_COMMENT_COUNT' => contrexx_raw2xhtml($strOutputCommentCount), 'IMAGES_VOTING_COUNT' => contrexx_raw2xhtml($strOutputVotingCount), 'IMAGES_VOTING_AVERAGE' => contrexx_raw2xhtml($outputVotingAverage), 'CLEAR_IMAGE_CATCH' => time())); $this->_objTpl->parseCurrentBlock(); } $this->parseCategoryDropdown($intCatId, false, 'showCategoriesMultiAction'); } }