/** * Retrieve property from the model object * * @param mixed $name Field/property name * * @return mixed */ protected function getModelObjectValue($name) { $result = parent::getModelObjectValue($name); switch ($name) { case 'date': $result = $this->formatTime($result); break; case 'method_name': $result = $this->getModelObject()->getPaymentMethod() ? $this->getModelObject()->getPaymentMethod()->getName() : $result; break; case 'type': $list = \XLite\Model\Payment\BackendTransaction::getTypes(); $result = $list[$result]; break; case 'status': $list = \XLite\Model\Payment\Transaction::getStatuses(); $result = $list[$result]; break; case 'value': $result = static::formatPrice($result, $this->getModelObject()->getCurrency()); break; case 'note': if (!$result) { $result = static::t('n/a'); } break; default: } return $result; }
/** * Return list of the "Button" widgets * * @return array */ protected function getFormButtons() { $result = parent::getFormButtons(); $label = $this->getModelObject()->getId() ? 'Update' : 'Create'; $result['submit'] = new \XLite\View\Button\Submit(array(\XLite\View\Button\AButton::PARAM_LABEL => $label, \XLite\View\Button\AButton::PARAM_BTN_TYPE => 'regular-main-button', \XLite\View\Button\AButton::PARAM_STYLE => 'action')); return $result; }
/** * Return list of the "Button" widgets * * @return array */ protected function getFormButtons() { $result = parent::getFormButtons(); $result['submit'] = new \XLite\View\Button\Submit(array(\XLite\View\Button\AButton::PARAM_LABEL => 'Confirm', \XLite\View\Button\AButton::PARAM_BTN_TYPE => 'regular-main-button', \XLite\View\Button\AButton::PARAM_STYLE => 'action')); $result['cancel'] = new \XLite\View\Button\Regular(array(\XLite\View\Button\AButton::PARAM_LABEL => 'Cancel', \XLite\View\Button\AButton::PARAM_STYLE => 'action always-enabled')); return $result; }
/** * Return list of the "Button" widgets * * @return array */ protected function getFormButtons() { $result = parent::getFormButtons(); if ($this->getModelObject()->getId()) { if ($this->isApproved()) { $result['submit'] = new \XLite\View\Button\Submit(array(\XLite\View\Button\AButton::PARAM_LABEL => 'Update', \XLite\View\Button\AButton::PARAM_BTN_TYPE => 'regular-main-button', \XLite\View\Button\AButton::PARAM_STYLE => 'action')); } else { $result['approve'] = new \XLite\View\Button\Submit(array(\XLite\View\Button\AButton::PARAM_LABEL => 'Approve', \XLite\View\Button\AButton::PARAM_BTN_TYPE => 'regular-main-button', \XLite\View\Button\AButton::PARAM_STYLE => 'action')); $result['remove'] = new \XLite\View\Button\Submit(array(\XLite\View\Button\AButton::PARAM_LABEL => 'Remove', \XLite\View\Button\AButton::PARAM_STYLE => 'action')); } } else { $result['submit'] = new \XLite\View\Button\Submit(array(\XLite\View\Button\AButton::PARAM_LABEL => 'Create', \XLite\View\Button\AButton::PARAM_BTN_TYPE => 'regular-main-button', \XLite\View\Button\AButton::PARAM_STYLE => 'action')); } return $result; }
/** * Return list of the "Button" widgets * * @return array */ protected function getFormButtons() { $result = parent::getFormButtons(); $result['submit'] = new \XLite\View\Button\Submit(array(\XLite\View\Button\AButton::PARAM_LABEL => 'Update', \XLite\View\Button\AButton::PARAM_BTN_TYPE => 'regular-main-button', \XLite\View\Button\AButton::PARAM_STYLE => 'action')); $result['notifications'] = new \XLite\View\Button\SimpleLink(array(\XLite\View\Button\Link::PARAM_LOCATION => $this->buildURL('notifications'), \XLite\View\Button\AButton::PARAM_LABEL => 'Back to notifications list', \XLite\View\Button\AButton::PARAM_STYLE => 'action')); return $result; }
/** * Return list of the "Button" widgets * * @return array */ protected function getFormButtons() { $result = parent::getFormButtons(); $label = $this->getModelObject()->getId() ? 'Update product' : 'Add product'; $result['submit'] = new \XLite\View\Button\Submit(array(\XLite\View\Button\AButton::PARAM_LABEL => $label, \XLite\View\Button\AButton::PARAM_BTN_TYPE => 'regular-main-button', \XLite\View\Button\AButton::PARAM_STYLE => 'action')); if ($this->getModelObject()->isPersistent()) { $url = $this->buildURL('product', 'clone', array('product_id' => $this->getModelObject()->getId())); $result['clone-product'] = new \XLite\View\Button\Link(array(\XLite\View\Button\AButton::PARAM_LABEL => 'Clone this product', \XLite\View\Button\AButton::PARAM_STYLE => 'model-button always-enabled', \XLite\View\Button\Link::PARAM_LOCATION => $url)); $url = $this->buildProductPreviewURL($this->getModelObject()->getId()); $result['preview-product'] = new \XLite\View\Button\SimpleLink(array(\XLite\View\Button\AButton::PARAM_LABEL => 'Preview product page', \XLite\View\Button\AButton::PARAM_STYLE => 'model-button link action', \XLite\View\Button\Link::PARAM_BLANK => true, \XLite\View\Button\Link::PARAM_LOCATION => $url)); } }
/** * Return list of the "Button" widgets * * @return array */ protected function getFormButtons() { $result = parent::getFormButtons(); $result['submit'] = new \XLite\View\Button\Submit(array(\XLite\View\Button\AButton::PARAM_LABEL => $this->getSubmitButtonLabel(), \XLite\View\Button\AButton::PARAM_BTN_TYPE => 'regular-main-button')); return $result; }
/** * callFormMethod * * @param string $method Class method to call * @param array $args Call arguments OPTIONAL * * @return mixed */ protected function callFormMethod($method, array $args = array()) { $form = \XLite\View\Model\AModel::getCurrentForm(); return $form ? call_user_func_array(array($form, $method), $args) : null; }
/** * Return list of the "Button" widgets * * @return array */ protected function getFormButtons() { $result = parent::getFormButtons(); $result['submit'] = new \XLite\View\Button\Submit(array(\XLite\View\Button\AButton::PARAM_LABEL => 'Save', \XLite\View\Button\AButton::PARAM_BTN_TYPE => 'regular-main-button', \XLite\View\Button\AButton::PARAM_STYLE => 'action')); $result['shipping_methods'] = new \XLite\View\Button\SimpleLink(array(\XLite\View\Button\AButton::PARAM_LABEL => static::t('Back to shipping methods'), \XLite\View\Button\AButton::PARAM_STYLE => 'action shipping-list-back-button', \XLite\View\Button\Link::PARAM_LOCATION => $this->buildURL('shipping_methods'))); return $result; }
/** * Populate model object properties by the passed data * * @param array $data Data to set * * @return void */ protected function setModelProperties(array $data) { unset($data['shippingZone']); parent::setModelProperties($data); }
/** * Return list of the "Button" widgets * * @return array */ protected function getFormButtons() { $result = parent::getFormButtons(); $result['submit'] = new \XLite\View\Button\Submit(array(\XLite\View\Button\AButton::PARAM_LABEL => $this->getSubmitButtonLabel(), \XLite\View\Button\AButton::PARAM_STYLE => $this->getSubmitButtonStyle())); return $result; }
/** * Populate model object properties by the passed data * * @param array $data Data to set * * @return void */ protected function setModelProperties(array $data) { $body = $data['body']; unset($data['body']); $data['date'] = LC_START_TIME; $localPath = ''; if (\XLite\Core\Request::getInstance()->template) { $localPath = \XLite\Core\Request::getInstance()->template; } elseif ($this->getModelObject()->getId()) { $localPath = $this->getModelObjectValue('template'); } if ($localPath) { $fullPath = $this->getFullPathByLocalPath($localPath, 'theme_tweaker/default'); \Includes\Utils\FileManager::write($fullPath, $body); $data['template'] = substr($fullPath, strlen(LC_DIR_SKINS)); \XLite\Core\FlexyCompiler::getInstance()->remove($fullPath); } parent::setModelProperties($data); }
/** * Return list of the "Button" widgets * * @return array */ protected function getFormButtons() { $result = parent::getFormButtons(); $label = $this->getModelObject()->getId() ? 'Save changes' : 'Next wizard'; $style = 'action ' . ($this->getModelObject()->getId() ? 'save' : 'next'); $result['submit'] = new \XLite\View\Button\Submit(array(\XLite\View\Button\AButton::PARAM_LABEL => $label, \XLite\View\Button\AButton::PARAM_BTN_TYPE => 'regular-main-button', \XLite\View\Button\AButton::PARAM_STYLE => $style)); return $result; }
/** * Return list of the "Button" widgets * * @return array */ protected function getFormButtons() { $result = parent::getFormButtons(); $result['submit'] = new \XLite\View\Button\Submit(array(\XLite\View\Button\AButton::PARAM_LABEL => 'Save', \XLite\View\Button\AButton::PARAM_BTN_TYPE => 'regular-main-button', \XLite\View\Button\AButton::PARAM_STYLE => 'action')); return $result; }
/** * Return list of targets allowed for this widget * * @return array */ public static function getAllowedTargets() { $result = parent::getAllowedTargets(); $result[] = 'order'; return $result; }
/** * Check if fields are valid * * @param array $data Current section data * @param string $section Current section name * * @return void */ protected function validateFields(array $data, $section) { $this->prepareDataToValidate($data); parent::validateFields($data, $section); }
/** * Change model object value * * @param string $name Object value name * * @return mixed */ protected function getModelObjectValue($name) { if ('contentTab' == $name) { $name = 'content'; } return parent::getModelObjectValue($name); }
/** * Populate model object properties by the passed data * * @param array $data Data to set * * @return void */ protected function setModelProperties(array $data) { if (isset($data['enabled'])) { $data['enabled'] = !empty($data['enabled']) ? 1 : 0; } parent::setModelProperties($data); }
/** * Populate model object properties by the passed data * * @param array $data Data to set * * @return void */ protected function setModelProperties(array $data) { if ($this->getPostedData('autogenerateCleanURL')) { $data['cleanURL'] = $this->generateCleanURL($data['name']); } if (!$data['cleanURL']) { unset($data['cleanURL']); } parent::setModelProperties($data); }
/** * Retrieve property from the model object * * @param mixed $name Field/property name * * @return mixed */ protected function getModelObjectValue($name) { return 'permissions' == $name && $this->getModelObject()->isPermanentRole() ? 'Root access' : parent::getModelObjectValue($name); }
/** * Populate model object properties by the passed data * * @param array $data Data to set * * @return void */ protected function setModelProperties(array $data) { parent::setModelProperties($data); }
/** * Return list of the "Button" widgets * * @return array */ protected function getFormButtons() { $result = parent::getFormButtons(); $result['submit'] = new \XLite\View\Button\Submit(array(\XLite\View\Button\AButton::PARAM_LABEL => 'Submit', \XLite\View\Button\AButton::PARAM_BTN_TYPE => 'regular-main-button', \XLite\View\Button\AButton::PARAM_STYLE => 'action')); if ('css_js_performance' === $this->getTarget()) { $url = $this->buildURL('css_js_performance', 'clean_aggregation_cache'); $result['clear_aggregation_cache'] = new \XLite\View\Button\Tooltip(array(\XLite\View\Button\AButton::PARAM_LABEL => 'Clean aggregation cache', \XLite\View\Button\AButton::PARAM_STYLE => 'action always-enabled', \XLite\View\Button\Tooltip::PARAM_SEPARATE_TOOLTIP => static::t('Clean aggregation cache help text'), \XLite\View\Button\Regular::PARAM_JS_CODE => 'self.location=\'' . $url . '\'')); $url = $this->buildURL('css_js_performance', 'clean_view_cache'); $result['clear_widgets_cache'] = new \XLite\View\Button\Tooltip(array(\XLite\View\Button\AButton::PARAM_LABEL => 'Clean widgets cache', \XLite\View\Button\AButton::PARAM_STYLE => 'action always-enabled', \XLite\View\Button\Tooltip::PARAM_SEPARATE_TOOLTIP => static::t('Clean widgets cache help text'), \XLite\View\Button\Regular::PARAM_JS_CODE => 'self.location=\'' . $url . '\'')); } if ('cache_management' === $this->getTarget()) { $url = $this->buildURL('cache_management', 'rebuild'); $result['re_deploy_cache'] = new \XLite\View\Button\Tooltip(array(\XLite\View\Button\AButton::PARAM_LABEL => 'Re-deploy the store', \XLite\View\Button\AButton::PARAM_STYLE => 'action always-enabled', \XLite\View\Button\Tooltip::PARAM_SEPARATE_TOOLTIP => static::t('Re-deploy the store help text'), \XLite\View\Button\Regular::PARAM_JS_CODE => sprintf('if (confirm(core.t("Are you sure?"))) self.location="%s";', $url))); $url = $this->buildURL('cache_management', 'quick_data'); $result['quick_data'] = new \XLite\View\Button\Tooltip(array(\XLite\View\Button\AButton::PARAM_LABEL => 'Calculate quick data', \XLite\View\Button\AButton::PARAM_STYLE => 'action always-enabled', \XLite\View\Button\Tooltip::PARAM_SEPARATE_TOOLTIP => static::t('Calculate quick data help text'), \XLite\View\Button\Regular::PARAM_JS_CODE => 'self.location=\'' . $url . '\'')); } return $result; }
/** * Return current form reference * * @return \XLite\View\Model\AModel */ protected function getCurrentForm() { return \XLite\View\Model\AModel::getCurrentForm() ?: $this->getModelForm(); }
/** * Retrieve property from the model object * * @param mixed $name Field/property name * * @return mixed */ protected function getModelObjectValue($name) { $value = parent::getModelObjectValue($name); if ('format' == $name) { $value = \XLite\View\FormField\Select\FloatFormat::getFormat($this->getModelObjectValue('thousandDelimiter'), $this->getModelObjectValue('decimalDelimiter')); } elseif ('trailing_zeroes' == $name) { $value = '' !== \XLite\Core\Config::getInstance()->General->trailing_zeroes; } return $value; }
/** * Check if field is valid and (if needed) set an error message * * @param array $data Current section data * @param string $section Current section name * * @return void */ protected function validateFields(array $data, $section) { parent::validateFields($data, $section); $cell = $data[self::SECTION_PARAM_FIELDS]; if (!$this->errorMessages && isset($cell['type'], $cell['value']) && '%' === $cell['type']->getValue() && 100 < (int) $cell['value']->getValue()) { $this->addErrorMessage('value', 'The discount should be less than 100%', $data); } }
/** * Populate model object properties by the passed data * * @param array $data Data to set * * @return void */ protected function setModelProperties(array $data) { if (!isset($data['onDemand'])) { $data['onDemand'] = array(); } if (!isset($data['carrierAccessorialFees'])) { $data['carrierAccessorialFees'] = array(); } parent::setModelProperties($data); }
/** * Retrieve property from the model object * * @param mixed $name Field/property name * * @return mixed */ protected function getModelObjectValue($name) { switch ($name) { case 'template': $result = \XLite\View\FormField\Select\Template::SKIN_STANDARD; $currentModule = \XLite\Core\Database::getRepo('XLite\\Model\\Module')->getCurrentSkinModule(); if ($currentModule) { $currentColor = \XLite\Core\Layout::getInstance()->getLayoutColorName(); $result = $currentModule->getModuleId() . ($currentColor ? '_' . $currentColor : ''); } break; default: $result = parent::getModelObjectValue($name); } return $result; }
/** * Return list of the "Button" widgets * * @return array */ protected function getFormButtons() { $result = parent::getFormButtons(); if (!$this->getModelObject() || !$this->getModelObject()->getAnonymous()) { $result['submit'] = new \XLite\View\Button\Submit(array(\XLite\View\Button\AButton::PARAM_LABEL => $this->getSubmitButtonLabel(), \XLite\View\Button\AButton::PARAM_BTN_TYPE => 'regular-main-button', \XLite\View\Button\AButton::PARAM_STYLE => $this->getSubmitButtonStyle())); } $same = \XLite\Core\Database::getRepo('XLite\\Model\\Profile')->findUserWithSameLogin($this->getModelObject()); if ($this->getModelObject() && $this->getModelObject()->isPersistent() && $this->getModelObject()->getAnonymous() && !$this->getModelObject()->getOrder()) { if (!$same) { $result['register'] = new \XLite\View\Button\Regular(array(\XLite\View\Button\AButton::PARAM_LABEL => static::t('Register user'), \XLite\View\Button\AButton::PARAM_BTN_TYPE => 'regular-main-button', \XLite\View\Button\AButton::PARAM_STYLE => 'register', \XLite\View\Button\Regular::PARAM_ACTION => 'registerAsNew', \XLite\View\Button\AButton::PARAM_ATTRIBUTES => array('title' => static::t('The user will be registered; a password will be sent to the user via email')))); } elseif ($same && !$same->isAdmin()) { $result['merge'] = new \XLite\View\Button\Regular(array(\XLite\View\Button\AButton::PARAM_LABEL => static::t('Merge with Registered'), \XLite\View\Button\AButton::PARAM_STYLE => 'merge', \XLite\View\Button\Regular::PARAM_ACTION => 'mergeWithRegistered')); } } return $result; }
/** * Populate model object properties by the passed data * * @param array $data Data to set * * @return void */ protected function setModelProperties(array $data) { $data['date'] = strtotime($data['date']); parent::setModelProperties($data); }