Exemplo n.º 1
0
 /**
  * process
  *
  * @param string $request
  * @param object $subOnxshop
  * @return boolean
  */
 public function process($request, &$subOnxshop = false)
 {
     msg("ONXSHOP_REQUEST: BEGIN {$request}", "ok", 2);
     /**
      * save copy or GET request to local variable
      */
     $this->GET = $_GET;
     /**
      * check request
      */
     $this->setRequest($request);
     $module = $this->_explodeRequest($request);
     $this->_module_html = "{$module['view']}.html";
     $this->_template_dir = getTemplateDir($this->_module_html);
     $this->_module_php = ONXSHOP_PROJECT_DIR . "controllers/{$module['controller']}.php";
     if (!file_exists($this->_module_php)) {
         $this->_module_php = ONXSHOP_DIR . "controllers/{$module['controller']}.php";
     }
     if ($this->_template_dir != '') {
         $this->_initTemplate($this->_module_html);
     }
     //look for the Onxshop tags
     $this->parseContentTagsBefore();
     // main action controller
     // if some error comes from controller, save it into registry, this will not allow save cache in onxshop.bootstrap
     msg("mainAction html: " . $this->_template_dir . $this->_module_html, 'ok', 2);
     msg("mainAction php: " . $this->_module_php, 'ok', 2);
     if (!$this->mainAction()) {
         Zend_Registry::set('controller_error', $request);
         msg("Error in {$request}", 'error', 1);
     }
     /**
      * subcontent
      */
     if (is_object($subOnxshop)) {
         $this->tpl->assign('SUB_CONTENT', $subOnxshop->getContent());
     }
     if ($this->_template_dir != '') {
         //refresh variables after processing controller
         $this->_initTemplateVariables();
         $this->_parseTemplate();
     } else {
         msg("{$this->_module_html} " . 'does not exists.', 'error', 2);
     }
     msg("ONXSHOP_REQUEST: END {$request}", "ok", 2);
     //if all went OK, return true
     return true;
 }
Exemplo n.º 2
0
 /**
  * main action
  */
 public function mainAction()
 {
     if (is_numeric($this->GET['id'])) {
         $node_id = $this->GET['id'];
     } else {
         msg('node_edit: node_id is not numeric', 'error');
         return false;
     }
     require_once 'models/common/common_node.php';
     $Node = new common_node();
     $node_data = $Node->detail($node_id);
     $this->tpl->assign("NODE", $node_data);
     $_SESSION['active_pages'] = $Node->getActiveNodes($node_id, array('page', 'container'));
     $_SESSION['full_path'] = $Node->getFullPath($node_id);
     if ($_POST['node']['node_controller'] != '') {
         $node_controller = $_POST['node']['node_controller'];
     } else {
         $node_controller = $node_data['node_controller'];
     }
     $controller = "bo/node/{$node_data['node_group']}/{$node_controller}";
     if (getTemplateDir($controller . ".html") == '') {
         $controller_html = "bo/node/{$node_data['node_group']}/default";
     } else {
         $controller_html = $controller;
     }
     if (file_exists(ONXSHOP_DIR . "controllers/{$controller}.php") || file_exists(ONXSHOP_PROJECT_DIR . "controllers/{$controller}.php")) {
         $controller_php = $controller;
     } else {
         $controller_php = "bo/node/{$node_data['node_group']}/default";
     }
     $_Onxshop_Request = new Onxshop_Request("{$controller_php}@{$controller_html}&id={$node_id}&orig={$this->GET['orig']}&popup={$this->GET['popup']}", $this);
     $this->setContent($_Onxshop_Request->getContent());
     $this->tpl->assign("SUB_CONTENT", $this->content);
     if ($this->GET['ajax'] == 0) {
         $this->tpl->parse('content.form');
     }
     return true;
 }
Exemplo n.º 3
0
 /**
  * format a message
  * 
  * @param string $template
  * message template file name
  * 
  * @return array
  * formated message data
  */
 function _format($template)
 {
     $orig = $this->get('content');
     $this->content = nl2br($this->get('content'));
     $tpl = new XTemplate("{$template}.html", getTemplateDir("{$template}.html", 'mail/'));
     $vars = get_object_vars($this);
     $tpl->assign('EMAIL', $vars);
     //read passed data
     if (is_array($GLOBALS['common_email'])) {
         $tpl->assign('DATA', $GLOBALS['common_email']);
     }
     // from $Onxshop_Request->_initTemplateVariables
     if ($_SERVER['SSL_PROTOCOL'] || $_SERVER['HTTPS']) {
         $protocol = 'https';
     } else {
         $protocol = 'http';
     }
     $tpl->assign('PROTOCOL', $protocol);
     $tpl->assign('URI', "{$protocol}://{$_SERVER['SERVER_NAME']}{$_SERVER['REQUEST_URI']}");
     $tpl->assign('_SERVER', $_SERVER);
     $tpl->assign('_SESSION', $_SESSION);
     $tpl->assign('CONFIGURATION', $GLOBALS['onxshop_conf']);
     $tpl->assign('_POST', $_POST);
     $tpl->assign('_GET', $_GET);
     $tpl->assign('GET', $_GET);
     // assign also to GET variable to keep consitent with normal templates initiated via a controller
     $tpl->assign('TIME', time());
     /**
      * include node configuration
      */
     require_once 'models/common/common_node.php';
     $node_conf = common_node::initConfiguration();
     $tpl->assign('NODE_CONF', $node_conf);
     /**
      * parse
      */
     $tpl->parse('title');
     $tpl->parse('content');
     $this->content = $orig;
     $data['title'] = $tpl->text('title');
     $data['content']['html'] = $tpl->text('content');
     //get the text version
     $data['content']['txt'] = html2text($data['content']['html']);
     //convert relative links to absolute
     $data['content']['html'] = $this->rel2abs("http://{$_SERVER['HTTP_HOST']}", $data['content']['html']);
     $data['content']['txt'] = $this->rel2abs("http://{$_SERVER['HTTP_HOST']}", $data['content']['txt']);
     return $data;
 }
Exemplo n.º 4
0
 /**
  * main payment action
  */
 public function mainPaymentAction()
 {
     setlocale(LC_MONETARY, $GLOBALS['onxshop_conf']['global']['locale']);
     /**
      * check input values
      */
     if (is_numeric($this->GET['order_id'])) {
         $order_id = $this->GET['order_id'];
     } else {
         msg('Payment: Missing order_id', 'error', 1);
         onxshopGoTo("/page/" . $node_conf['id_map-404']);
         return false;
     }
     /**
      * include node configuration
      */
     require_once 'models/common/common_node.php';
     $node_conf = common_node::initConfiguration();
     $this->tpl->assign('NODE_CONF', $node_conf);
     /**
      * get order detail
      */
     $order_data = $this->Transaction->getOrderDetail($order_id);
     // need to assign ORDER detail into template before processing Google Analytics
     $this->tpl->assign("ORDER", $order_data);
     /**
      * google analytics
      */
     //TODO: NOTE: Do not include the square brackets when setting the values for the form. In addition, do not use commas to separate the thousands place in your total, tax, and shipping fields - any digits after the comma will be dropped.
     if ($GLOBALS['onxshop_conf']['global']['google_analytics'] != '') {
         foreach ($order_data['basket']['items'] as $item) {
             $this->tpl->assign("ITEM", $item);
             $this->tpl->parse('content.google_analytics.item');
         }
         $this->tpl->parse('content.google_analytics');
     }
     /**
      * Google Adwords, must be numeric
      */
     if (is_numeric($GLOBALS['onxshop_conf']['global']['google_adwords'])) {
         $this->tpl->parse('content.google_adwords');
     }
     /**
      * find what payment method we use
      */
     $payment_type = $this->Transaction->getPaymentTypeForOrder($order_id);
     /**
      * check whether payment is supported
      */
     $controller = "component/ecommerce/payment/{$payment_type}";
     if (getTemplateDir($controller . ".html") == '') {
         msg("Unsupported payment type {$payment_type}", 'error');
         return false;
     }
     /**
      * Check order permission
      */
     $is_owner = $order_data['basket']['customer_id'] == $_SESSION['client']['customer']['id'];
     $is_bo_user = Onxshop_Bo_Authentication::getInstance()->isAuthenticated();
     $is_guest_user = $order_data['client']['customer']['status'] == 5;
     $is_same_session = $order_data['php_session_id'] == session_id() || $order_data['php_session_id'] == $this->GET['php_session_id'];
     $has_code = !empty($this->GET['code']) && verifyHash($order_data['id'], $this->GET['code']);
     if ($is_bo_user || $is_owner || $is_guest_user && $is_same_session || $has_code) {
         /**
          * process payment method only if status = 0 unpaid or 5 failed payment 
          */
         if ($this->checkOrderStatusValidForPayment($order_data['status'])) {
             $total_payment_amount = $order_data['basket']['total'];
             if (round($total_payment_amount, 2) == 0) {
                 //nil payment - payment is not needed
                 if ($this->processNilPayment($order_data)) {
                     $this->tpl->parse('content.nil_payment');
                 } else {
                     msg("Cannot process nil payment for order ID {$order_id}", 'error');
                 }
             } else {
                 //process payment method as subcontent
                 $_Onxshop_Request = new Onxshop_Request("component/ecommerce/payment/{$payment_type}~order_id={$order_id}~");
                 $this->tpl->assign("RESULT", $_Onxshop_Request->getContent());
             }
         } else {
             msg("Order ID {$order_data['id']} cannot be paid, because order status is: {$order_data['status_title']}", 'error');
             return false;
         }
     } else {
         /**
          * forward to login
          */
         if ($_SESSION['client']['customer']['id'] == 0) {
             msg('You must login first.');
             onxshopGoTo("/page/" . $node_conf['id_map-login']);
         }
         msg('Unauthorised access to order detail');
         onxshopGoTo("/page/" . $node_conf['id_map-404']);
         return false;
     }
     setlocale(LC_MONETARY, LOCALE);
     return true;
 }