/** * Displays the view, collects needed data for the different layouts * * Okey I try now a completly new idea. * We make a function for every tab and the display is getting the right tabs by an own function * putting that in an array and after that we call the preparedataforlayoutBlub * * @author Oscar van Eijk * @author Max Milbers * * Original code from: \components\com_virtuemart\views\user\view.html.php * */ function display($tpl = null) { $useSSL = VmConfig::get('useSSL', 0); $useXHTML = true; $this->assignRef('useSSL', $useSSL); $this->assignRef('useXHTML', $useXHTML); $mainframe = JFactory::getApplication(); $pathway = $mainframe->getPathway(); $layoutName = $this->getLayout(); if (!defined('OPC_IN_REGISTRATION_MODE')) { define('OPC_IN_REGISTRATION_MODE', 1); } require_once JPATH_ROOT . DIRECTORY_SEPARATOR . 'components' . DIRECTORY_SEPARATOR . 'com_onepage' . DIRECTORY_SEPARATOR . 'helpers' . DIRECTORY_SEPARATOR . 'language.php'; OPCLang::loadLang(); $this->loadOPC(); // vmdebug('layout by view '.$layoutName); if (empty($layoutName) or $layoutName == 'default') { $layoutName = JRequest::getWord('layout', 'edit'); if ($layoutName == 'default') { $layoutName = 'edit'; } $this->setLayout($layoutName); } if (empty($this->fTask)) { $ftask = 'saveUser'; $this->assignRef('fTask', $ftask); } if (!class_exists('ShopFunctions')) { require JPATH_VM_ADMINISTRATOR . DS . 'helpers' . DS . 'shopfunctions.php'; } // vmdebug('my layoutname',$layoutName); if ($layoutName == 'login') { parent::display($tpl); return; } if (!class_exists('VirtuemartModelUser')) { require JPATH_VM_ADMINISTRATOR . DS . 'models' . DS . 'user.php'; } $this->_model = new VirtuemartModelUser(); // $this->_model->setCurrent(); //without this, the administrator can edit users in the FE, permission is handled in the usermodel, but maybe unsecure? $editor = JFactory::getEditor(); //the cuid is the id of the current user $this->_currentUser = JFactory::getUser(); $this->_cuid = $this->_lists['current_id'] = $this->_currentUser->get('id'); $this->assignRef('userId', $this->_cuid); $this->_userDetails = $this->_model->getUser(); $this->assignRef('userDetails', $this->_userDetails); $address_type = JRequest::getWord('addrtype', 'BT'); $this->assignRef('address_type', $address_type); //New Address is filled here with the data of the cart (we are in the cart) if (!class_exists('VirtueMartCart')) { require JPATH_VM_SITE . DS . 'helpers' . DS . 'cart.php'; } $cart = VirtueMartCart::getCart(); $new = false; if (JRequest::getInt('new', '0') == 1) { $new = true; } if ($new) { $virtuemart_userinfo_id = 0; } else { $virtuemart_userinfo_id = JRequest::getString('virtuemart_userinfo_id', '0', ''); if (empty($virtuemart_userinfo_id)) { require_once JPATH_ROOT . DIRECTORY_SEPARATOR . 'components' . DIRECTORY_SEPARATOR . 'com_onepage' . DIRECTORY_SEPARATOR . 'helpers' . DIRECTORY_SEPARATOR . 'mini.php'; $umodel = OPCmini::getModel('user'); //new VirtuemartModelUser(); $uid = JFactory::getUser()->id; $userDetails = $umodel->getUser(); $virtuemart_userinfo_id = $umodel->getBTuserinfo_id(); } } $this->assignRef('virtuemart_userinfo_id', $virtuemart_userinfo_id); $userFields = null; if ((strpos($this->fTask, 'cart') || strpos($this->fTask, 'checkout')) && empty($virtuemart_userinfo_id)) { $fieldtype = $address_type . 'address'; if (method_exists($cart, 'prepareAddressDataInCart')) { $cart->prepareAddressDataInCart($address_type, $new); } if (method_exists($cart, 'prepareAddressFieldsInCart')) { $cart->prepareAddressFieldsInCart(); } $userFields = $cart->{$fieldtype}; $task = JRequest::getWord('task', ''); } else { $userFields = $this->_model->getUserInfoInUserFields($layoutName, $address_type, $virtuemart_userinfo_id); if (!$new && empty($userFields[$virtuemart_userinfo_id])) { $virtuemart_userinfo_id = $this->_model->getBTuserinfo_id(); // vmdebug('Try to get $virtuemart_userinfo_id by type BT', $virtuemart_userinfo_id); } $userFields = $userFields[$virtuemart_userinfo_id]; $task = 'editaddressST'; } require_once JPATH_ROOT . DIRECTORY_SEPARATOR . 'components' . DIRECTORY_SEPARATOR . 'com_onepage' . DIRECTORY_SEPARATOR . 'helpers' . DIRECTORY_SEPARATOR . 'loader.php'; /* if (!class_exists('VirtueMartCart')) require(JPATH_VM_SITE . DS . 'helpers' . DS . 'cart.php'); $this->cart = VirtueMartCart::getCart(); */ $OPCloader = new OPCloader(); OPCloader::setRegType(); $action_url = JURI::root(true) . '/index.php?option=com_onepage&view=opc&controller=opc&task=opcregister&nosef=1'; require_once JPATH_SITE . DS . 'components' . DS . 'com_onepage' . DS . 'helpers' . DS . 'javascript.php'; OPCJavascript::getJavascript($this, $OPCloader, false, $action_url, 'com_onepage', 'opcregister'); $OPCloader->customizeFieldsPerOPCConfig($userFields); OPCloader::loadJavascriptFiles($this); $op_formvars = OPCloader::getFormVars($this); /* foreach ($userFields['fields'] as $key=>$val) { if (isset($val['formcode'])) { $val['formcode'] .= $html; break; } } */ $this->assignRef('userFields', $userFields); if ($layoutName == 'edit') { if ($this->_model->getId() == 0 && $this->_cuid == 0) { $button_lbl = JText::_('COM_VIRTUEMART_REGISTER'); } else { $button_lbl = JText::_('COM_VIRTUEMART_SAVE'); } $this->assignRef('button_lbl', $button_lbl); $this->lUser(); if (JVM_VERSION <= 2) { $this->shopper($userFields); } else { $this->shopper3($userFields); } $this->payment(); $this->lOrderlist(); $this->lVendor(); } $this->_lists['shipTo'] = $this->generateStAddressList($this, $this->_model, $task, $cart); if ($this->_openTab < 0) { $_paneOffset = array(); } else { if (defined('__VM_USER_USE_SLIDERS')) { $_paneOffset = array('startOffset' => $this->_openTab, 'startTransition' => 1, 'allowAllClose' => true); } else { $_paneOffset = array('startOffset' => $this->_openTab); } } // Implement the Joomla panels. If we need a ShipTo tab, make it the active one. // In tmpl/edit.php, this is the 4th tab (0-based, so set to 3 above) jimport('joomla.html.pane'); $pane = OPCPane::getInstance(defined('__VM_USER_USE_SLIDERS') ? 'Sliders' : 'Tabs', $_paneOffset); $this->assignRef('lists', $this->_lists); $this->assignRef('editor', $editor); $this->assignRef('pane', $pane); if ($layoutName == 'mailregisteruser') { $vendorModel = VmModel::getModel('vendor'); // $vendorModel->setId($this->_userDetails->virtuemart_vendor_id); $vendor = $vendorModel->getVendor(); $this->assignRef('vendor', $vendor); } if ($layoutName == 'editaddress') { $layoutName = 'edit_address'; $this->setLayout($layoutName); } if (!$this->userDetails->JUser->get('id')) { $corefield_title = JText::_('COM_VIRTUEMART_USER_CART_INFO_CREATE_ACCOUNT'); } else { $corefield_title = JText::_('COM_VIRTUEMART_YOUR_ACCOUNT_DETAILS'); } if (strpos($this->fTask, 'cart') || strpos($this->fTask, 'checkout')) { $pathway->addItem(JText::_('COM_VIRTUEMART_CART_OVERVIEW'), JRoute::_('index.php?option=com_virtuemart&view=cart', FALSE)); } else { //$pathway->addItem(JText::_('COM_VIRTUEMART_YOUR_ACCOUNT_DETAILS'), JRoute::_('index.php?option=com_virtuemart&view=user&&layout=edit')); } $pathway_text = JText::_('COM_VIRTUEMART_YOUR_ACCOUNT_DETAILS'); if (!$this->userDetails->JUser->get('id')) { if (strpos($this->fTask, 'cart') || strpos($this->fTask, 'checkout')) { if ($address_type == 'BT') { $vmfield_title = JText::_('COM_VIRTUEMART_USER_FORM_EDIT_BILLTO_LBL'); } else { $vmfield_title = JText::_('COM_VIRTUEMART_USER_FORM_ADD_SHIPTO_LBL'); } } else { if ($address_type == 'BT') { $vmfield_title = JText::_('COM_VIRTUEMART_USER_FORM_EDIT_BILLTO_LBL'); $title = JText::_('COM_VIRTUEMART_REGISTER'); } else { $vmfield_title = JText::_('COM_VIRTUEMART_USER_FORM_ADD_SHIPTO_LBL'); } } } else { if ($address_type == 'BT') { $vmfield_title = JText::_('COM_VIRTUEMART_USER_FORM_BILLTO_LBL'); } else { $vmfield_title = JText::_('COM_VIRTUEMART_USER_FORM_ADD_SHIPTO_LBL'); } } $add_product_link = ""; require_once JPATH_ROOT . DIRECTORY_SEPARATOR . 'components' . DIRECTORY_SEPARATOR . 'com_onepage' . DIRECTORY_SEPARATOR . 'helpers' . DIRECTORY_SEPARATOR . 'mini.php'; if (OPCmini::isSuperVendor()) { $add_product_link = JRoute::_('/index.php?option=com_virtuemart&tmpl=component&view=product&view=product&task=edit&virtuemart_product_id=0'); $add_product_link = $this->linkIcon($add_product_link, 'COM_VIRTUEMART_PRODUCT_ADD_PRODUCT', 'new', false, false, true, true); } $this->assignRef('add_product_link', $add_product_link); $document = JFactory::getDocument(); $document->setTitle($pathway_text); $pathway->additem($pathway_text); $document->setMetaData('robots', 'NOINDEX, NOFOLLOW, NOARCHIVE, NOSNIPPET'); $this->assignRef('page_title', $pathway_text); $this->assignRef('corefield_title', $corefield_title); $this->assignRef('vmfield_title', $vmfield_title); // if ($onlyindex) return JURI::root(true).'/index.php'; shopFunctionsF::setVmTemplate($this, 0, 0, $layoutName); require_once JPATH_SITE . DIRECTORY_SEPARATOR . 'components' . DIRECTORY_SEPARATOR . 'com_onepage' . DIRECTORY_SEPARATOR . 'helpers' . DIRECTORY_SEPARATOR . 'removemsgs.php'; OPCremoveMsgs::removeMsgs($cart); $jsvalidator = $OPCloader->getJSValidatorScript($this); $op_userfields = $OPCloader->getBTfields($this); $registration_html = $OPCloader->getRegistrationHhtml($this); require_once JPATH_ROOT . DIRECTORY_SEPARATOR . 'components' . DIRECTORY_SEPARATOR . 'com_onepage' . DIRECTORY_SEPARATOR . 'helpers' . DIRECTORY_SEPARATOR . 'commonhtml.php'; $reg_html = OPCCommonHtml::getFormVarsRegistration($OPCloader); $op_formvars = $reg_html . $jsvalidator; $op_userfields .= $op_formvars; $onsubmit = $op_onclick = $OPCloader->getJSValidator($this); $op_onclick = ' onclick="' . $op_onclick . '" '; ob_start(); //parent::display($tpl); include_once JPATH_OPC . DIRECTORY_SEPARATOR . 'helpers' . DIRECTORY_SEPARATOR . 'registration_templates.php'; $html = ob_get_clean(); //$html = str_replace('"com_virtuemart"', '"com_onepage"', $html); //$html = str_replace('=com_virtuemart', '=com_onepage', $html); $this->getActions($html); $html = $OPCloader->addListeners($html); echo $html; $extras = $OPCloader->getExtras($this); echo $extras; }