/** * Loop through all URIs * * @return void * @access public */ public function build() { // Process the queue $i = 0; foreach ($this->pageList as $page) { $uri = translateURL("page/{$page['id']}"); try { /** * check if customised template for indexing exists * this is DEPRECATED approach how to customise indexable content, use getExcludes() instead * remember that you need also to create controller for the template */ if (file_exists(ONXSHOP_PROJECT_DIR . "templates/node/page/{$page['node_controller']}_indexable.html")) { $toFetch = "request/sys/html5.node/page/{$page['node_controller']}_indexable~id={$page['id']}~"; } else { $toFetch = "request/sys/html5.node~id={$page['id']}~"; } msg("Fetching page {$page['id']}: {$uri} using {$toFetch}"); $this->client->setUri($this->profile['uri'] . $toFetch); $response = $this->client->request(); if ($response->isSuccessful() && !$response->isRedirect() && !$response->isError()) { $response_body = $this->filterHtmlDocument($response->getBody()); $this->index($uri, Zend_Search_Lucene_Document_Html::loadHTML($response_body, true)); } } catch (Exception $e) { msg("HTTP fetch exception: " . $e->getMessage()); } $i++; // if ($i == 10) break; } // Optimize index. $this->indexOptimize(); }
/** * main action */ public function mainAction() { //check if we are comming from backoffice if ($_SERVER['REQUEST_URI'] == '/edit') { if (is_array($_SESSION['active_pages']) && count($_SESSION['active_pages']) > 0) { $node_id = $_SESSION['active_pages'][0]; $request = translateURL("page/{$node_id}"); header("Location: {$request}"); exit; } else { header("Location: /"); } } return true; }
protected function getProductInfo($product_variety_id) { $variety = $this->Product->getProductVarietyDetail($product_variety_id); $product = $this->Product->productDetail($variety['product_id']); $homepage = $this->Product->getProductHomepage($variety['product_id']); $product['url'] = translateURL('page/' . $homepage['id']); $Image = new Onxshop_Request("component/image&relation=product&role=main&width=120&node_id={$product['id']}&limit=0,1"); $product['variety'] = $variety; $product['image'] = $Image->getContent(); return $product; }
/** * onxshop aware http forward * * @param unknown_type $request * @param unknown_type $type * type = 0: local path * type = 1: router syntax * type = 2: external URL */ function onxshopGoTo($request, $type = 0) { msg("calling onxshopGoTo({$request}, {$type})", 'ok', 2); session_write_close(); if ($_SERVER['HTTPS']) { $protocol = 'https'; } else { $protocol = 'http'; } //protection against HTTP CRLF injection $request = preg_replace("/\r\n/", "", $request); if ($type == 0) { $request = ltrim($request, '/'); if (preg_match('/^(page\\/[0-9]{1,})(.*)$/', $request, $matches)) { $request_path = translateURL($matches[1]); $request_params = $matches[2]; header("Location: {$protocol}://{$_SERVER['HTTP_HOST']}{$request_path}{$request_params}"); } else { header("Location: {$protocol}://{$_SERVER['HTTP_HOST']}/{$request}"); } } else { if ($type == 1) { $router = new Onxshop_Router(); $Onxshop = $router->processAction($request); $output = $Onxshop->finalOutput(); echo $output; } else { if ($type == 2) { header("Location: {$request}"); } else { header("Location: {$protocol}://{$_SERVER['HTTP_HOST']}/{$request}"); } } } //exit application processing immediately exit; }
protected function getProductInfo($product_variety_id) { // cache_local product info $key = "product_variety_id_{$product_variety_id}"; if (isset($this->cache_local[$key])) { return $this->cache_local[$key]; } require_once 'models/ecommerce/ecommerce_product.php'; $Product = new ecommerce_product(); $variety = $Product->getProductVarietyDetail($product_variety_id); $product = $Product->productDetail($variety['product_id']); $homepage = $Product->getProductHomepage($variety['product_id']); $product['url'] = translateURL('page/' . $homepage['id']); $Image = new Onxshop_Request("component/image&relation=product&role=main&width=120&node_id={$product['id']}&limit=0,1"); $product['variety'] = $variety; $product['image'] = $Image->getContent(); $this->cache_local[$key] = $product; return $product; }
function translateLink($url, $name, $parameters = [], $locale = null) { $extra_list = ''; foreach ($parameters as $k => $v) { $extra_list .= " {$k}=" . '"' . (is_array($v) ? implode(' ', $v) : $v) . '"'; } return '<a href="' . translateURL($url, $locale) . '"' . $extra_list . '>' . Lang::get($name) . '</a>'; }
protected function getShareUrl($code) { return "http://" . $_SERVER['HTTP_HOST'] . translateURL("page/" . $this->conf['referral_page_id']) . "?code=" . $code; }