sentence1
stringlengths
52
3.87M
sentence2
stringlengths
1
47.2k
label
stringclasses
1 value
public function validateActionsImageStyle() { $field = 'actions'; if ($this->isExcluded($field)) { return null; } $actions = $this->getSubmitted($field); if ($this->isUpdating() && !isset($actions)) { $this->unsetSubmitted($field); retur...
Validates image actions @return boolean|null
entailment
protected function validateActionImageStyle($action_id, array &$value) { $handler = $this->image_style->getActionHandler($action_id); if (empty($handler)) { return false; } try { $callback = static::get($handler, null, 'validate'); return call_us...
Calls an appropriate validator method for the given action ID @param string $action_id @param array $value @return boolean
entailment
public function route(array $values, $operator) { if (!in_array($operator, array('=', '!='))) { return $this->translation->text('Unsupported operator'); } $existing = $this->route->getList(); foreach ($values as $pattern) { if (empty($existing[$pattern])) { ...
Validates the route pattern @param array $values @param string $operator @return boolean|string
entailment
public function path(array $values, $operator) { if (!in_array($operator, array('=', '!='))) { return $this->translation->text('Unsupported operator'); } foreach ($values as $pattern) { if (!gplcart_string_is_regexp($pattern)) { return $this->translat...
Validates the path pattern @param array $values @param string $operator @return boolean|string
entailment
public function getHandlers() { $handlers = &gplcart_static('mail.handlers'); if (isset($handlers)) { return $handlers; } $handlers = (array) gplcart_config_get(GC_FILE_CONFIG_MAIL); $this->hook->attach('mail.handlers', $handlers, $this); return $handler...
Returns an array of email handlers @return array
entailment
public function send($to, $subject, $message, $options) { if (!is_array($options)) { $options = array('from' => (string) $options); } settype($to, 'array'); $result = null; $this->hook->attach('mail.send', $to, $subject, $message, $options, $result); if...
Sends an e-mail @param string|array $to @param string $subject @param string $message @param array|string $options @return mixed
entailment
public function set($handler_id, array $arguments) { try { $handlers = $this->getHandlers(); $data = Handler::call($handlers, $handler_id, 'data', $arguments); return call_user_func_array(array($this, 'send'), $data); } catch (Exception $ex) { trigger_...
Sends E-mail with predefined parameters using a handler ID @param string $handler_id @param array $arguments @return boolean
entailment
public function mail(array $receivers, $subject, $message, array $options) { $subject = "=?UTF-8?B?" . base64_encode($subject) . "?="; $from = "=?UTF-8?B?" . base64_encode($options['from']) . "?="; $headers = array(); $headers[] = "From: $from <$from>"; $headers[] = "MIME-Ve...
Send E-mail using PHP mail() function @param array $receivers @param string $subject @param string $message @param array $options @return boolean
entailment
public static function get($name, $config = NULL) { if(isset($_COOKIE[$name])) { // Decrypt cookie using cookie key if($v = json_decode(Cipher::decrypt(base64_decode($_COOKIE[$name]), Config::config()->key), true)) { return $v; } ...
Decrypt and fetch cookie data @param string $name of cookie @param array $config settings @return mixed
entailment
public static function set($name, $value, $config = array()) { // Use default config settings if needed extract(array_merge(static::$settings, $config)); // If the cookie is being removed we want it left blank $value = $value ? base64_encode(Cipher::encrypt(json_encode($value), Conf...
Called before any output is sent to create an encrypted cookie with the given value. @param $name @param mixed $value to save @param array $config settings return boolean @internal param string $key cookie name
entailment
protected function copyFiles($skeletonDir, $moduleDir, $files) { foreach ($files as $file) { $srcFile = $skeletonDir . DIRECTORY_SEPARATOR . $file; $dstFile = $moduleDir . DIRECTORY_SEPARATOR . $file; if (!file_exists($srcFile)) { throw new \InvalidArgumen...
@param string $skeletonDir @param string $moduleDir @param array $files @throws \InvalidArgumentException When a file path being created already exists
entailment
protected function createModuleStructure($moduleDir, $moduleName) { if (is_dir($moduleDir)) { throw new \InvalidArgumentException(sprintf('Unable to create module: %s it already exists at %s%s', $moduleName, $moduleDir, $moduleName)); } @mkdir($moduleDir); // Create bas...
@param string $moduleDir @param string $moduleName @throws \InvalidArgumentException When a dir path being created already exists
entailment
public function add(array $data) { $result = array(); $this->hook->attach('wishlist.add.product.before', $data, $result, $this); if (!empty($result)) { return (array) $result; } if ($this->wishlist->exists($data)) { return $this->getResultErrorExists...
Adds a product to a wishlist and returns an array of result data @param array $data @return array
entailment
public function delete(array $data) { $result = array(); $this->hook->attach('wishlist.delete.product.before', $data, $result, $this); if (!empty($result)) { return (array) $result; } if (!$this->wishlist->delete($data)) { return $this->getResultErro...
Delete a product from the wishlist @param array $data @return array
entailment
protected function getResultAdded(array $data) { $options = array( 'user_id' => $data['user_id'], 'store_id' => $data['store_id'] ); $href = $this->url->get('wishlist'); $existing = $this->wishlist->getList($options); return array( 'redir...
Returns an array of resulting data when a product has been added to the wishlist @param array $data @return array
entailment
protected function getResultErrorExceeds(array $data) { $vars = array('%num' => $this->wishlist->getLimit($data['user_id'])); return array( 'redirect' => '', 'severity' => 'warning', 'message' => $this->translation->text("You're exceeding limit of %num items", $v...
Returns an array of resulting data when a user exceeds the max allowed number of products in the wishlist @param array $data @return array
entailment
protected function getResultErrorExists(array $data) { $vars = array('@url' => $this->url->get('wishlist')); return array( 'redirect' => '', 'severity' => 'warning', 'wishlist_id' => $data['wishlist_id'], 'message' => $this->translation->text('Product...
Returns an array of resulting data when a product already exists in the wishlist @param array $data @return array
entailment
protected function getResultDelete(array $data) { unset($data['product_id']); $existing = $this->wishlist->getList($data); return array( 'message' => '', 'severity' => 'success', 'quantity' => count($existing), 'redirect' => empty($existing) ...
Returns an array of resulting data when a product has been deleted from a wishlist @param array $data @return array
entailment
public function listReportEvent() { $this->clearReportEvent(); $this->actionListReportEvent(); $this->setTitleListReportEvent(); $this->setBreadcrumbListReportEvent(); $this->setFilterListReportEvent(); $this->setPagerListReportEvent(); $this->setData('types...
Displays the event overview page
entailment
protected function actionListReportEvent() { list($selected, $action) = $this->getPostedAction(); if ($action === 'delete' && $this->access('report_events')) { if ($this->report->delete(array('log_id' => $selected))) { $message = $this->text('Deleted %num item(s)', array...
Applies an action to the selected aliases
entailment
protected function setPagerListReportEvent() { $conditions = $this->query_filter; $conditions['count'] = true; $pager = array( 'query' => $this->query_filter, 'total' => (int) $this->report->getList($conditions) ); return $this->data_limit = $this->s...
Sets pager @return array
entailment
protected function clearReportEvent() { $key = 'clear'; $this->controlToken($key); if ($this->isQuery($key)) { $this->report->delete(); $this->redirect('admin/report/events'); } }
Deletes all system events from the database
entailment
protected function getListReportEvent() { $conditions = $this->query_filter; $conditions['limit'] = $this->data_limit; $list = (array) $this->report->getList($conditions); $this->prepareListReportEvent($list); return $list; }
Returns an array of system events @return array
entailment
protected function prepareListReportEvent(array &$list) { foreach ($list as &$item) { $variables = array(); if (!empty($item['data']['variables'])) { $variables = $item['data']['variables']; } $item['created'] = $this->date($item['created'])...
Prepare an array of system events @param array $list
entailment
public function getList(array $options) { $result = null; $this->hook->attach('translation.entity.list.before', $options, $result, $this); if (isset($result)) { return (array) $result; } $table = $this->getTable($options['entity']); $sql = "SELECT * FROM...
Returns an array of translations @param array $options @return array
entailment
public function delete(array $conditions) { $result = null; $this->hook->attach('translation.entity.delete.before', $conditions, $result, $this); if (isset($result)) { return (bool) $result; } $table = $this->getTable($conditions['entity']); unset($cond...
Deletes translation(s) @param array $conditions @return bool
entailment
public function getTable($entity) { $tables = $this->getTables(); if (empty($tables[$entity])) { throw new OutOfBoundsException("Entity $entity is not supported for translations"); } return $tables[$entity]; }
Returns a database table name for the entity @param string $entity @return string @throws OutOfBoundsException
entailment
public function validate(array $object, Schema $schema, array $schemaExtensions = []) { $validationResult = new ValidationResult(); /** @var Schema[] $otherSchemas */ $otherSchemas = []; foreach ($schemaExtensions as $schemaExtension) { $otherSchemas[$schemaExtension->get...
@param array $object @param Schema $schema @param Schema[] $schemaExtensions @return ValidationResult
entailment
public function categoryGroup(array &$submitted, array $options = array()) { $this->options = $options; $this->submitted = &$submitted; $this->validateCategoryGroup(); $this->validateTitle(); $this->validateTranslation(); $this->validateStoreId(); $this->vali...
Performs full category group data validation @param array $submitted @param array $options @return boolean|array
entailment
protected function validateCategoryGroup() { $id = $this->getUpdatingId(); if ($id === false) { return null; } $data = $this->category_group->get($id); if (empty($data)) { $this->setErrorUnavailable('update', $this->translation->text('Category group...
Validates a category group to be updated @return boolean|null
entailment
protected function validateTypeCategoryGroup() { $field = 'type'; if ($this->isExcluded($field) || $this->isError('store_id')) { return null; } $type = $this->getSubmitted($field); if ($this->isUpdating() && !isset($type)) { return null; } ...
Validates category group type @return boolean|null
entailment
public function thumbnail(&$source, $target, array $action) { list($width, $height) = $action['value']; if ($this->image->set($source)->thumbnail($width, $height)->save($target)) { $source = $target; return true; } return false; }
Make thumbnail @param string $source @param string $target @param array $action @return bool
entailment
public function crop(&$source, $target, array $action) { list($x1, $y1, $x2, $y2) = $action['value']; if ($this->image->set($source)->crop($x1, $y1, $x2, $y2)->save($target)) { $source = $target; return true; } return false; }
Crop @param string $source @param string $target @param array $action @return bool
entailment
public function fitWidth(&$source, $target, array $action) { $width = reset($action['value']); if ($this->image->set($source)->fitToWidth($width)->save($target)) { $source = $target; return true; } return false; }
Fit to width @param string $source @param string $target @param array $action @return bool
entailment
public function fitHeight(&$source, $target, array $action) { $height = reset($action['value']); if ($this->image->set($source)->fitToHeight($height)->save($target)) { $source = $target; return true; } return false; }
Fit to height @param string $source @param string $target @param array $action @return bool
entailment
protected function helper($helperName) { if (!isset($this->helpers[$helperName])) { throw new \InvalidArgumentException('Unable to locate controller helper: ' . $helperName); } return $this->helpers[$helperName]; }
Obtain a controller helper by its key name. @param string $helperName @throws \InvalidArgumentException @return mixed
entailment
protected function server($key = null, $default = null, $deep = false) { return $key === null ? $this->getServer()->all() : $this->getServer()->get($key, $default, $deep); }
Returns a server parameter by name. @param string $key The key @param mixed $default The default value if the parameter key does not exist @param bool $deep If true, a path like foo[bar] will find deeper items @return string
entailment
protected function post($key = null, $default = null, $deep = false) { return $key === null ? $this->getPost()->all() : $this->getPost()->get($key, $default, $deep); }
Returns a post parameter by name. @param string $key The key @param mixed $default The default value if the parameter key does not exist @param bool $deep If true, a path like foo[bar] will find deeper items @return string
entailment
protected function files($key = null, $default = null, $deep = false) { return $key === null ? $this->getFiles()->all() : $this->getFiles()->get($key, $default, $deep); }
Returns a files parameter by name. @param string $key The key @param mixed $default The default value if the parameter key does not exist @param bool $deep If true, a path like foo[bar] will find deeper items @return string
entailment
protected function queryString($key = null, $default = null, $deep = false) { return $key === null ? $this->getQueryString()->all() : $this->getQueryString()->get($key, $default, $deep); }
Returns a query string parameter by name. @param string $key The key @param mixed $default The default value if the parameter key does not exist @param bool $deep If true, a path like foo[bar] will find deeper items @return string
entailment
protected function cookie($key = null, $default = null, $deep = false) { return $key === null ? $this->getCookie()->all() : $this->getCookie()->get($key, $default, $deep); }
Returns a server parameter by name. @param string $key The key @param mixed $default The default value if the parameter key does not exist @param bool $deep If true, a path like foo[bar] will find deeper items @return string
entailment
protected function session($key = null, $default = null) { return $key === null ? $this->getSession()->all() : $this->getSession()->get($key, $default); }
Get/Set a session value. @param string $key @param null|mixed $default If this is not null, it enters setter mode @return mixed
entailment
protected function is($key) { switch ($key = strtolower($key)) { case 'ajax': if (!isset($this->isCache['ajax'])) { return $this->isCache['ajax'] = $this->getService('Request')->isXmlHttpRequest(); } return $this->isCache['aja...
Check if a condition 'is' true. @param string $key @throws InvalidArgumentException @return bool
entailment
protected function render($template, array $params = array(), array $options = array()) { $renderer = $this->serviceLocator->get('templating'); // Helpers if (isset($options['helpers'])) { foreach ($options['helpers'] as $helper) { $renderer->addHelper($helper); ...
Render a template. @param string $template The template to render @param array $params The params to pass to the renderer @param array $options Extra options @return string
entailment
protected function redirect($url, $statusCode = 302) { $response = new RedirectResponse($url, $statusCode); $this->getServiceLocator()->set('Response', $response); return $response; }
Create a RedirectResponse object with your $url and $statusCode. @param string $url @param int $statusCode @return RedirectResponse
entailment
protected function redirectToRoute($route, $parameters = array(), $absolute = false) { return $this->redirect($this->getService('Router')->generate($route, $parameters, $absolute)); }
Shortcut function for redirecting to a route without manually calling $this->generateUrl() You just specify a route name and it goes there. @param $route @param array $parameters @param bool|false $absolute @return RedirectResponse
entailment
protected function generateUrl($route, $parameters = array(), $absolute = false) { return $this->getService('Router')->generate($route, $parameters, $absolute); }
Generate a URL from the specified route name. @param string $route @param array $parameters @param bool $absolute @return string
entailment
public function shippingMethod(array $condition, array $data) { if (!isset($data['order']['shipping'])) { return false; } return $this->compare($data['order']['shipping'], $condition['value'], $condition['operator']); }
Whether the shipping service condition is met @param array $condition @param array $data @return boolean
entailment
public function paymentMethod(array $condition, array $data) { if (!isset($data['order']['payment'])) { return false; } return $this->compare($data['order']['payment'], $condition['value'], $condition['operator']); }
Whether the payment service condition is met @param array $condition @param array $data @return boolean
entailment
public function findAttribute($name) { foreach ($this->attributes as $attribute) { if ($attribute->getName() === $name) { return $attribute; } } return null; }
@param string $name @return null|Schema\Attribute
entailment
public static function deserializeObject(array $data) { /** @var Schema $result */ $result = self::deserializeCommonAttributes($data); $result->name = $data['name']; $result->description = $data['description']; $result->attributes = []; foreach ($data['attributes'] as...
@param array $data @return Schema
entailment
protected function setProductClassProductClassField($product_class_id) { $this->data_product_class = array(); if (is_numeric($product_class_id)) { $this->data_product_class = $this->product_class->get($product_class_id); if (empty($this->data_product_class)) { ...
Sets the product class data @param integer $product_class_id
entailment
public function listProductClassField($product_class_id) { $this->setProductClassProductClassField($product_class_id); $this->setTitleListProductClassField(); $this->setBreadcrumbListProductClassField(); $this->setFilterListProductClassField(); $this->setData('field_types', ...
Route callback for the product class field overview page @param integer $product_class_id
entailment
protected function getListProductClassField(array $conditions = array()) { $conditions += $this->query_filter; $conditions['product_class_id'] = $this->data_product_class['product_class_id']; return (array) $this->product_class_field->getList($conditions); }
Returns an array of fields for the given product class @param array $conditions @return array
entailment
protected function getUniqueListProductClassField() { $types = $this->field->getTypes(); $fields = $this->getListProductClassField(array('index' => 'field_id')); $unique = array(); foreach ((array) $this->field->getList() as $field) { if (empty($fields[$field['field_id'...
Returns an array of product class fields indexed by field ID which are unique for the product class @return array
entailment
protected function updateListProductClassField() { $this->controlAccess('product_class_edit'); foreach ((array) $this->setSubmitted('fields') as $id => $field) { if (!empty($field['remove'])) { $this->product_class_field->delete($id); continue; ...
Updates product class fields
entailment
protected function setBreadcrumbListProductClassField() { $breadcrumbs = array(); $breadcrumbs[] = array( 'url' => $this->url('admin'), 'text' => $this->text('Dashboard') ); $breadcrumbs[] = array( 'text' => $this->text('Product classes'), ...
Sets breadcrumbs on the product class field overview page
entailment
public function editProductClassField($product_class_id) { $this->setProductClassProductClassField($product_class_id); $this->setTitleEditProductClassField(); $this->setBreadcrumbEditProductClassField(); $this->setData('product_class', $this->data_product_class); $this->setD...
Route callback Displays the edit product class field page @param integer $product_class_id
entailment
protected function validateEditProductClassField() { $this->setSubmitted('product_class'); $this->setSubmitted('product_class_id', $this->data_product_class['product_class_id']); $this->validateComponent('product_class_field'); return !$this->hasErrors(false); }
Validates an array of submitted product class fields @return bool
entailment
protected function addProductClassField() { $this->controlAccess('product_class_edit'); foreach ((array) $this->getSubmitted('field_id', array()) as $field_id) { $field = array( 'field_id' => $field_id, 'product_class_id' => $this->data_product_class['pr...
Adds product class fields
entailment
protected function setBreadcrumbEditProductClassField() { $breadcrumbs = array(); $breadcrumbs[] = array( 'url' => $this->url('admin'), 'text' => $this->text('Dashboard') ); $breadcrumbs[] = array( 'text' => $this->text('Product classes'), ...
Sets breadcrumbs on the edit product class field page
entailment
public function listCollection() { $this->actionListCollection(); $this->setTitleListCollection(); $this->setBreadcrumbListCollection(); $this->setFilterListCollection(); $this->setPagerListCollection(); $this->setData('collections', $this->getListCollection()); ...
Displays the collection overview page
entailment
protected function setPagerListCollection() { $options = $this->query_filter; $options['count'] = true; $pager = array( 'query' => $this->query_filter, 'total' => (int) $this->collection->getList($options) ); return $this->data_limit = $this->setPage...
Set pager @return array
entailment
protected function getListCollection() { $conditions = $this->query_filter; $conditions['limit'] = $this->data_limit; return (array) $this->collection->getList($conditions); }
Returns an array of collections @return array
entailment
public function editCollection($collection_id = null) { $this->setCollection($collection_id); $this->setTitleEditCollection(); $this->setBreadcrumbEditCollection(); $this->setData('types', $this->collection->getTypes()); $this->setData('collection', $this->data_collection); ...
Displays the edit collection page @param null|integer $collection_id
entailment
protected function submitEditCollection() { if ($this->isPosted('delete')) { $this->deleteCollection(); } else if ($this->isPosted('save') && $this->validateEditCollection()) { if (isset($this->data_collection['collection_id'])) { $this->updateCollection(); ...
Saves an array of submitted collection data
entailment
protected function validateEditCollection() { $this->setSubmitted('collection'); $this->setSubmittedBool('status'); $this->setSubmitted('update', $this->data_collection); $this->validateComponent('collection'); return !$this->hasErrors(); }
Validates a submitted collection @return bool
entailment
protected function canDeleteCollection() { return isset($this->data_collection['collection_id']) && $this->access('collection_delete') && $this->collection->canDelete($this->data_collection['collection_id']); }
Whether the current collection can be deleted @return bool
entailment
protected function setCollection($collection_id) { $this->data_collection = array(); if (is_numeric($collection_id)) { $conditions = array( 'language' => 'und', 'collection_id' => $collection_id ); $this->data_collection = $this-...
Sets a collection data @param integer $collection_id
entailment
protected function deleteCollection() { $this->controlAccess('collection_delete'); if ($this->collection->delete($this->data_collection['collection_id'])) { $this->redirect('admin/content/collection', $this->text('Collection has been deleted'), 'success'); } $this->redi...
Deletes a collection
entailment
protected function updateCollection() { $this->controlAccess('collection_edit'); if ($this->collection->update($this->data_collection['collection_id'], $this->getSubmitted())) { $this->redirect('admin/content/collection', $this->text('Collection has been updated'), 'success'); }...
Updates a collection
entailment
protected function addCollection() { $this->controlAccess('collection_add'); if ($this->collection->add($this->getSubmitted())) { $this->redirect('admin/content/collection', $this->text('Collection has been added'), 'success'); } $this->redirect('', $this->text('Collect...
Adds a new collection
entailment
protected function setTitleEditCollection() { if (isset($this->data_collection['title'])) { $title = $this->text('Edit %name', array('%name' => $this->data_collection['title'])); } else { $title = $this->text('Add collection'); } $this->setTitle($title); ...
Sets title on the edit collection page
entailment
protected function setBreadcrumbEditCollection() { $breadcrumbs = array(); $breadcrumbs[] = array( 'url' => $this->url('admin'), 'text' => $this->text('Dashboard') ); $breadcrumbs[] = array( 'text' => $this->text('Collections'), 'url'...
Sets breadcrumbs on the edit collection page
entailment
public function startTLS() { if (!$this->sendCommand('STARTTLS', 'STARTTLS', 220)) { return false; } // Begin encrypted connection if (!stream_socket_enable_crypto( $this->smtp_conn, true, STREAM_CRYPTO_METHOD_TLS_CLIENT )) { ...
Initiate a TLS (encrypted) session. @access public @return boolean
entailment
public function authenticate( $username, $password, $authtype = null, $realm = '', $workstation = '' ) { if (!$this->server_caps) { $this->error = array('error' => 'Authentication is not allowed before HELO/EHLO'); return false; } ...
Perform SMTP authentication. Must be run after hello(). @see hello() @param string $username The user name @param string $password The password @param string $authtype The auth type (PLAIN, LOGIN, NTLM, CRAM-MD5) @param string $realm The auth realm for NTLM @param string $workstation The auth workstation...
entailment
protected function parseHelloFields($type) { $this->server_caps = array(); $lines = explode("\n", $this->last_reply); foreach ($lines as $n => $s) { $s = trim(substr($s, 4)); if (!$s) { continue; } $fields = explode(' ', $s); ...
Parse a reply to HELO/EHLO command to discover server extensions. In case of HELO, the only parameter that can be discovered is a server name. @access protected @param string $type - 'HELO' or 'EHLO'
entailment
public function client_send($data) { $this->edebug("CLIENT -> SERVER: $data", self::DEBUG_CLIENT); return fwrite($this->smtp_conn, $data); }
Send raw data to the server. @param string $data The data to send @access public @return integer|boolean The number of bytes sent to the server or false on error
entailment
public function getServerExt($name) { if (!$this->server_caps) { $this->error = array('No HELO/EHLO was sent'); return null; } // the tight logic knot ;) if (!array_key_exists($name, $this->server_caps)) { if ($name == 'HELO') { re...
A multipurpose method The method works in three ways, dependent on argument value and current state 1. HELO/EHLO was not sent - returns null and set up $this->error 2. HELO was sent $name = 'HELO': returns server name $name = 'EHLO': returns boolean false $name = any string: returns null and set up $this->error 3. EHLO...
entailment
public function route() { $path = Url::pathInfo(); $pathInfo = explode('/', $path); if($pathInfo['0'] == '') // 访问的是根目录 return array(ucfirst(Config::$application) . '\\' . Config::$controller['0'] . '\\Index', 'index', array()); else{ // 需要路由分发处理 if($this->ro...
路由分发处理 @return array controller, method, params todo: 路由中参数的类型支持 route配置举例: 'admin' => 'admin', // 方式1,子模块模式 'admin/test/xx/{id1}/{id2}' => function($id1, $id2, &$controller, &$method){ // 方式2,指定c,m,p $controller = 'Index'; $method = 'index'; }, 'page/{id}' => function($id){ // 方式3,直接处理数据 var_dump($id); }, 'category...
entailment
protected function setAdminModeCheckout($mode) { $this->admin = null; if ($this->access('order_add')) { if ($mode === 'add') { $this->admin = 'add'; } if ($mode === 'clone' && $this->access('order_edit')) { $this->admin = 'clone'...
Sets the current admin mode @param string
entailment
protected function setUserCheckout($user_id) { $this->data_user = array(); if (!is_numeric($user_id)) { $this->outputHttpStatus(403); } $this->data_user = $this->user->get($user_id); if (empty($this->data_user['status'])) { $this->outputHttpStatus(4...
Loads a user from the database @param integer $user_id
entailment
public function editCheckout() { $this->setCartContentCheckout(); $this->setTitleEditCheckout(); $this->setBreadcrumbEditCheckout(); $this->controlAccessCheckout(); $this->setFormDataBeforeCheckout(); $this->submitEditCheckout(); $this->setFormDataAfterChecko...
Page callback Displays the checkout page
entailment
protected function setOrderCheckout($order_id) { $this->data_order = $this->order->get($order_id); if (empty($this->data_order)) { $this->outputHttpStatus(404); } $this->prepareOrder($this->data_order); $this->order_id = $order_id; $this->order_user_id ...
Load and set an order from the database @param integer $order_id
entailment
protected function prepareOrder(array &$order) { $this->setItemTotalFormatted($order, $this->price); $this->setItemTotalFormattedNumber($order, $this->price); }
Prepare an array of order data @param array $order
entailment
protected function setCartContentCheckout() { $options = array( 'user_id' => $this->cart_uid, 'order_id' => $this->order_id, 'store_id' => $this->order_store_id ); return $this->data_cart = $this->getCart($options); }
Load and set the current cart content @return array
entailment
protected function setTitleEditCheckout() { if ($this->admin === 'clone') { $text = $this->text('Cloning order #@num', array('@num' => $this->data_order['order_id'])); } else if ($this->admin === 'add') { $text = $this->text('Add order for user %name', array('%name' => $this-...
Sets title on the checkout page
entailment
protected function controlAccessCheckout() { if (empty($this->data_cart['items'])) { $form = $this->render('checkout/form', array('admin' => $this->admin), true); $this->setData('checkout_form', $form); $this->output('checkout/checkout'); } }
Controls access to the checkout page
entailment
protected function setFormDataBeforeCheckout() { $this->data_form = array(); $default_order = $this->getDefaultOrder(); $order = gplcart_array_merge($default_order, $this->data_order); $payment_methods = $this->getPaymentMethodsCheckout(); $shipping_methods = $this->getShip...
Sets initial form data
entailment
protected function getDefaultOrder() { return array( 'comment' => '', 'payment' => '', 'shipping' => '', 'user_id' => $this->order_user_id, 'creator' => $this->admin_user_id, 'store_id' => $this->order_store_id, 'currency' =...
Returns an array of default order data @return array
entailment
protected function getPaymentMethodsCheckout() { $list = $this->payment->getList(array('status' => true)); $this->prepareMethodsCheckout($list); return $list; }
Returns an array of enabled payment methods @return array
entailment
protected function getShippingMethodsCheckout() { $list = $this->shipping->getList(array('status' => true)); $this->prepareMethodsCheckout($list); return $list; }
Returns an array of enabled shipping methods @return array
entailment
protected function prepareMethodsCheckout(array &$list) { foreach ($list as &$item) { if (isset($item['module']) && isset($item['image'])) { $path = GC_DIR_MODULE . "/{$item['module']}/{$item['image']}"; $item['image'] = $this->url(gplcart_path_relative($path)); ...
Prepare payment and shipping methods @param array $list
entailment
protected function setFormDataAfterCheckout() { if (empty($this->data_cart)) { return null; } $this->data_form['cart'] = $this->data_cart; $this->setFormDataAddressCheckout(); if (empty($this->data_form['addresses'])) { $this->show_shipping_address_...
Prepares the form data before passing to the templates
entailment
protected function setFormDataAddressCheckout() { $countries = array(); foreach ((array) $this->country->getList(array('status' => true)) as $code => $country) { $countries[$code] = $country['native_name']; } $default_country = count($countries) == 1 ? key($countries) :...
Sets the checkout address variables
entailment
protected function setFormDataRequestServicesCheckout($type) { $this->data_form["request_{$type}_methods"] = false; if (!empty($this->data_form["get_{$type}_methods"]) || (!empty($this->data_form['order'][$type]) && !empty($this->data_form["has_dynamic_{$type}_methods"]))) { ...
Sets boolean flags to request dynamic shipping/payment methods @param string $type
entailment
protected function setFormDataDimensionsCheckout() { if (!empty($this->data_cart)) { $order = $this->data_form['order']; // Cart data passed by reference to convert product dimensions and measurement units $this->data_form['order']['volume'] = $this->order_dimension->ge...
Calculates and sets order dimensions
entailment
protected function setFormDataCalculatedCheckout() { $result = $this->order->calculate($this->data_form); $this->data_form['total'] = $result['total']; $this->data_form['total_decimal'] = $result['total_decimal']; $this->data_form['total_formatted'] = $result['total_formatted']; ...
Calculates order total and price components
entailment
protected function setFormDataPanesCheckout() { $panes = array('login', 'review', 'payment_methods', 'shipping_methods', 'shipping_address', 'payment_address', 'comment', 'action'); foreach ($panes as $pane) { $this->data_form["pane_$pane"] = $this->render("checkout/panes/$p...
Sets rendered panes
entailment
protected function submitEditCheckout() { $this->setSubmitted('order'); $this->setAddressFormCheckout(); $this->submitAddAddressCheckout(); if ($this->isPosted('checkout_login') && empty($this->uid)) { $this->show_login_form = true; } $this->same_paymen...
Handles submitted actions
entailment