function getStateList(&$ref) { require_once JPATH_ROOT . DS . 'components' . DS . 'com_onepage' . DS . 'helpers' . DS . 'commonhtml.php'; return OPCCommonHtml::getStateList($ref); }
public static function getExtras(&$ref) { $html = OPCCommonHtml::getStateList($ref); //test ie8: //$html = ''; if (!empty(OPCloader::$extrahtml)) { $html .= OPCloader::$extrahtml; } $html .= '<div id="opc_totals_hash"> </div>'; $html2 = '<form action="#" name="hidden_form"> <div style="display: none;"> <input type="text" name="fool" value="1" required="required" class="required hasTip" title="fool::fool" /> <select class="vm-chzn-select " name="hidden"> <option value="1">test</option> </select> </div> <input type="hidden" name="opc_min_pov" id="opc_min_pov" value="" /> <div style="display: none;"> <a href="#" rel="{handler: \'iframe\', size: {x: 500, y: 400}}" class="opcmodal">a</a> <a href="#" rel="{handler: \'iframe\', size: {x: 500, y: 400}}" class="pfdmodal">a</a> </div> ' . $html . ' </form>'; return $html2; }
public static function getUserFields(&$userFields, &$OPCloader, &$cart, $remove = array(), $only = array(), $skipreorder = array()) { include JPATH_ROOT . DS . 'components' . DS . 'com_onepage' . DS . 'config' . DS . 'onepage.cfg.php'; $user = JFactory::getUser(); $uid = $user->get('id'); //$userFields = $userFieldsOrig; if (!empty($userFields)) { foreach ($userFields['fields'] as $key => $uf) { $userFields['fields'][$key]['formcode'] = str_replace('vm-chzn-select', '', $userFields['fields'][$key]['formcode']); $userFields['fields'][$key]['formcode'] = str_replace('maxlength', 'disabledmaxlength', $userFields['fields'][$key]['formcode']); if ($key == 'password') { $userFields['fields'][$key]['required'] = true; } if ($key == 'password2') { $userFields['fields'][$key]['required'] = true; } $arr = array('name', 'username'); if (in_array($key, $arr)) { $userFields['fields'][$key]['required'] = 1; } if (!empty($custom_rendering_fields)) { if (in_array($userFields['fields'][$key]['name'], $custom_rendering_fields)) { unset($userFields['fields'][$key]); continue; } } if ($key != 'email') { $userFields['fields'][$key]['formcode'] = str_replace('/>', ' autocomplete="off" />', $userFields['fields'][$key]['formcode']); } if ($key == 'email') { if (!empty($cart->BT['email'])) { $userFields['fields'][$key]['formcode'] = str_replace('value=""', ' value="' . $cart->BT['email'] . '"', $userFields['fields'][$key]['formcode']); $userFields['fields'][$key]['formcode'] = str_replace('type="text"', 'type="email"', $userFields['fields'][$key]['formcode']); } } $userFields['fields'][$key]['formcode'] = str_replace('size="0"', '', $userFields['fields'][$key]['formcode']); // get proper state listing: if ($key == 'virtuemart_state_id') { if (!empty($cart->BT['virtuemart_country_id'])) { $c = $cart->BT['virtuemart_country_id']; } else { $c = $default_shipping_country; } if (empty($c)) { $vendor = $OPCloader->getVendorInfo($cart); $c = $vendor['virtuemart_country_id']; } require_once JPATH_ROOT . DS . 'components' . DS . 'com_onepage' . DS . 'helpers' . DS . 'commonhtml.php'; $html = OPCCommonHtml::getStateHtmlOptions($cart, $c, 'BT'); if (!empty($cart->BT['virtuemart_state_id'])) { $html = str_replace('value="' . $cart->BT['virtuemart_state_id'] . '"', 'value="' . $cart->BT['virtuemart_state_id'] . '" selected="selected"', $html); } // if (!empty($userFields['fields']['virtuemart_state_id']['required'])) { $userFields['fields']['virtuemart_state_id']['formcode'] = '<select class="inputbox multiple opcrequired" id="virtuemart_state_id" opcrequired="opcrequired" size="1" name="virtuemart_state_id" >' . $html . '</select>'; } else { $userFields['fields']['virtuemart_state_id']['formcode'] = '<select class="inputbox multiple" id="virtuemart_state_id" size="1" name="virtuemart_state_id" >' . $html . '</select>'; } //$userFields['fields'][$key]['formcode'] = '<select class="inputbox multiple" id="virtuemart_state_id" size="1" name="virtuemart_state_id" >'.$html.'</select>'; } // add klarna button: if (!empty($klarna_se_get_address)) { if ($key == 'socialNumber') { $newhtml = '<input type="button" id="klarna_get_address_button" onclick="return Onepage.send_special_cmd(this, \'get_klarna_address\' );" value="' . OPCLang::_('COM_ONEPAGE_KLARNA_GET_ADDRESS') . '" />'; //$userFields['fields'][$key]['formcode'] = str_replace('name="socialNumber"', ' style="width: 70%;" name="socialNumber"', $userFields['fields'][$key]['formcode']).$newhtml; $userFields['fields'][$key]['formcode'] .= $newhtml; } } // mark email read only when logged in if ($key == 'email') { // user is logged, but does not have a VM account if (!OPCloader::logged($cart) && !empty($uid)) { // the user is logged in only in joomla, but does not have an account with virtuemart $userFields['fields'][$key]['formcode'] = str_replace('/>', ' readonly="readonly" />', $userFields['fields'][$key]['formcode']); } else { $userFields['fields'][$key]['formcode'] = str_replace('type="text"', 'type="email"', $userFields['fields'][$key]['formcode']); } } // remove autocomplete for multi dependant fields if ($key == 'virtuemart_country_id') { $userFields['fields'][$key]['formcode'] = str_replace('name=', ' autocomplete="off" name=', $userFields['fields'][$key]['formcode']); } // set required properly: if (isset($userFields['fields'][$key]['name'])) { if (!empty($uf['required']) && strpos($uf['formcode'], 'required') === false) { if ($userFields['fields'][$key]['name'] != 'virtuemart_state_id') { $x1 = strpos($uf['formcode'], 'class="'); if ($x1 !== false) { $userFields['fields'][$key]['formcode'] = str_replace('class="', 'class="required ', $uf['formcode']); } else { $userFields['fields'][$key]['formcode'] = str_replace('name="', 'class="required" name="', $uf['formcode']); } } } } if ($uf['type'] == 'date') { $userFields['fields'][$key]['formcode'] = str_replace(OPCLang::_('COM_VIRTUEMART_NEVER'), $userFields['fields'][$key]['title'], $userFields['fields'][$key]['formcode']); } if (!empty($op_no_display_name)) { if ($userFields['fields'][$key]['name'] == 'name') { unset($userFields['fields'][$key]); continue; } } if ($key == 'username') { if (!empty($op_usernameisemail) && $userFields['fields'][$key]['name'] == 'username') { unset($userFields['fields'][$key]); continue; } } if ($key == 'password') { $userFields['fields']['opc_password'] = $userFields['fields'][$key]; $userFields['fields']['opc_password']['formcode'] = str_replace('password', 'opc_password', $userFields['fields']['opc_password']['formcode']); $userFields['fields']['opc_password']['formcode'] = str_replace('type="opc_password"', 'type="password" autocomplete="off" ', $userFields['fields']['opc_password']['formcode']); $userFields['fields']['opc_password']['name'] = 'opc_password'; //unset($userFields['fields'][$key]); if (!empty($password_clear_text)) { $userFields['fields']['opc_password']['formcode'] = str_replace('type="password"', 'type="text" ', $userFields['fields']['opc_password']['formcode']); } unset($userFields['fields']['password']); //$l = $userFields['fields']['opc_password']; } if ($key == 'password2') { if (!empty($password_clear_text)) { $userFields['fields']['password2']['formcode'] = str_replace('type="password"', 'type="text" ', $userFields['fields']['password2']['formcode']); } $userFields['fields']['opc_password2'] = $userFields['fields']['password2']; unset($userFields['fields']['password2']); } if ($key == 'email') { $userFields['fields'][$key]['formcode'] = str_replace('class="required', 'class="required email ', $userFields['fields']['email']['formcode']); $userFields['fields'][$key]['formcode'] = str_replace('type="text"', 'type="email"', $userFields['fields'][$key]['formcode']); if (!empty($double_email)) { $email2 = $userFields['fields']['email']; $email2['name'] = 'email2'; $title = OPCLang::_('COM_ONEPAGE_EMAIL2'); if ($title != 'COM_ONEPAGE_EMAIL2') { $email2['title'] = $title; } $email2['formcode'] = str_replace('"email', '"email2', $email2['formcode']); $email2['formcode'] = str_replace('id=', ' onblur="javascript: doublemail_checkMail();" id=', $email2['formcode']); $email2['formcode'] = str_replace('type="email2"', 'type="email"', $email2['formcode']); $h = '<span style="display: none; position: relative; color: red; font-size: 10px; background: none; border: none; padding: 0; margin: 0;" id="email2_info" class="email2_class">'; $emailerr = OPCLang::_('COM_ONEPAGE_EMAIL_DONT_MATCH'); if ($emailerr != 'COM_ONEPAGE_EMAIL_DONT_MATCH') { $h .= $emailerr; } else { $h .= "Emails don't match!"; } $h .= '</span>'; $email2['formcode'] .= $h; } if (!empty($opc_check_email)) { if (!OPCloader::logged($cart) && empty($uid)) { if (!empty($userFields['fields']['email'])) { $un = $userFields['fields']['email']['formcode']; $un = str_replace('id=', ' onblur="javascript: Onepage.email_check(this);" id=', $un); $un .= '<span class="email_already_exist" style="display: none; position: relative; color: red; font-size: 10px; background: none; border: none; padding: 0; margin: 0;" id="email_already_exists">'; $un .= OPCLang::sprintf('COM_ONEPAGE_EMAIL_ALREADY_EXISTS', OPCLang::_('COM_VIRTUEMART_USER_FORM_EMAIL')); $un .= '</span>'; $userFields['fields']['email']['formcode'] = $un; } } } } if ($key == 'EUVatID' || $key == 'eu_vat_id') { $h = '<br /><span style="display: none; position: relative; float: left; clear: both; color: red; font-size: 10px; background: none; border: none; padding: 0; margin: 0;" id="vat_info" class="vat_info">'; $h .= '</span>'; $userFields['fields'][$key]['formcode'] .= $h; } if ($key == 'opc_vat') { if (!empty($opc_euvat)) { if (!empty($userFields['fields']['opc_vat'])) { $un = $userFields['fields']['opc_vat']['formcode']; if (!empty($opc_euvat_button)) { $un .= '<br /><input type="button" value="' . OPCLang::_('COM_ONEPAGE_VALIDATE_VAT_BUTTON') . '" onclick="javascript: Onepage.validateOpcEuVat(this);" class="opc_euvat_button" />'; } $un .= '<br /><span class="vat_info" style="display: none; position: relative; color: red; font-size: 10px; background: none; border: none; padding: 0; margin: 0;" id="vat_info">'; $un .= OPCLang::_('COM_ONEPAGE_VAT_CHECKER_INVALID'); $un .= '</span>'; $userFields['fields']['opc_vat']['formcode'] = $un; } } } if ($key == 'username') { if (!empty($opc_check_username)) { if (!OPCloader::logged($cart) && empty($uid)) { if (!empty($userFields['fields']['username'])) { $u = OPCLang::_('COM_VIRTUEMART_REGISTER_UNAME'); $un = $userFields['fields']['username']['formcode']; $un = str_replace('id=', ' onblur="javascript: Onepage.username_check(this);" id=', $un); $un .= '<span class="username_already_exist" style="display: none; position: relative; color: red; font-size: 10px; background: none; border: none; padding: 0; margin: 0;" id="username_already_exists">'; $un .= OPCLang::sprintf('COM_ONEPAGE_EMAIL_ALREADY_EXISTS', $u); $un .= '</span>'; $userFields['fields']['username']['formcode'] = $un; } } } } } } if (!empty($email2)) { $userFields['fields']['email2'] = $email2; } if (!defined('OPC_IN_REGISTRATION_MODE')) { jimport('joomla.html.parameter'); $plugin = JPluginHelper::getPlugin('system', 'vm_mailchimp'); if (!empty($plugin)) { if (class_exists('JParameter')) { $params = new JParameter($plugin->params); } else { $params = new JRegistry($plugin->params); } $opc = $params->get('disable_in_opc', false); if (!empty($opc)) { unset($userFields['fields']['mailchimp']); } } } if (!empty($userFields)) { self::reorderFields($userFields, $skipreorder); } }
/** * 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; }