sentence1 stringlengths 52 3.87M | sentence2 stringlengths 1 47.2k | label stringclasses 1
value |
|---|---|---|
public function checkoutComplete($order_id)
{
$this->setOrderCheckoutComplete($order_id);
$this->controlAccessCheckoutComplete();
$this->setTitleCheckoutComplete();
$this->setBreadcrumbCheckoutComplete();
$this->setData('message', $this->getMessageCheckoutComplete());
... | Page callback
Displays the checkout complete page
@param int $order_id | entailment |
protected function setDataTemplatesCheckoutComplete()
{
$templates = array(
'payment' => $this->getPaymentMethodTemplate('complete', $this->data_order, $this->payment),
'shipping' => $this->getShippingMethodTemplate('complete', $this->data_order, $this->shipping)
);
... | Sets payment/shipping method templates on the checkout complete page | entailment |
protected function setOrderCheckoutComplete($order_id)
{
$this->data_order = $this->order->get($order_id);
if (empty($this->data_order)) {
$this->outputHttpStatus(404);
}
$this->prepareOrderCheckoutComplete($this->data_order);
} | Load and set an order from the database
@param integer $order_id | entailment |
protected function prepareOrderCheckoutComplete(array &$order)
{
$this->setItemTotalFormatted($order, $this->price);
$this->setItemTotalFormattedNumber($order, $this->price);
} | Prepare the order data
@param array $order | entailment |
protected function controlAccessCheckoutComplete()
{
if (empty($this->data_order['user_id']) || $this->data_order['user_id'] !== $this->cart_uid) {
$this->outputHttpStatus(403);
}
if (!$this->order->isPending($this->data_order)) {
$this->outputHttpStatus(403);
... | Controls access to the checkout complete page | entailment |
public function listAddress()
{
$this->actionListAddress();
$this->setTitleListAddress();
$this->setBreadcrumbListAddress();
$this->setFilterListAddress();
$this->setPagerlListAddress();
$this->setData('addresses', $this->getListAddress());
$this->outputListA... | Page callback
Displays the address overview page | entailment |
protected function actionListAddress()
{
list($selected, $action) = $this->getPostedAction();
$deleted = 0;
foreach ($selected as $id) {
if ($action === 'delete' && $this->access('address_delete')) {
$deleted += (int) $this->address->delete($id);
}
... | Applies an action to the selected aliases | entailment |
protected function setPagerlListAddress()
{
$conditions = $this->query_filter;
$conditions['count'] = true;
$pager = array(
'query' => $this->query_filter,
'total' => (int) $this->address->getList($conditions)
);
return $this->data_limit = $this->set... | Sets pager
@return array | entailment |
protected function getListAddress()
{
$conditions = $this->query_filter;
$conditions['limit'] = $this->data_limit;
$addresses = (array) $this->address->getList($conditions);
$this->prepareListAddress($addresses);
return $addresses;
} | Returns an array of addresses using pager limits and the URL query conditions
@return array | entailment |
protected function prepareListAddress(array &$addresses)
{
foreach ($addresses as &$address) {
$address['translated'] = $this->address->getTranslated($address, true);
}
} | Prepares an array of addresses
@param array $addresses | entailment |
public function listAlias()
{
$this->actionListAlias();
$this->setTitleListAlias();
$this->setBreadcrumbListAlias();
$this->setFilterListAlias();
$this->setPagerListAlias();
$this->setData('aliases', $this->getListAlias());
$this->setData('handlers', $this->a... | Page callback
Displays the alias overview page | entailment |
protected function actionListAlias()
{
list($selected, $action) = $this->getPostedAction();
$deleted = 0;
foreach ($selected as $id) {
if ($action === 'delete' && $this->access('alias_delete')) {
$deleted += (int) $this->alias->delete($id);
}
... | Applies an action to the selected aliases | entailment |
protected function setPagerListAlias()
{
$conditions = $this->query_filter;
$conditions['count'] = true;
$pager = array(
'query' => $this->query_filter,
'total' => (int) $this->alias->getList($conditions)
);
return $this->data_limit = $this->setPager... | Sets pager
@return array | entailment |
protected function getListAlias()
{
$conditions = $this->query_filter;
$conditions['limit'] = $this->data_limit;
return (array) $this->alias->getList($conditions);
} | Returns an array of aliases using the pager limits and conditions from the URL query
@return array | entailment |
public function load($file, $type = null)
{
$path = $this->locator->locate($file);
$config = array();
$result = parse_ini_file($path, true);
if (false === $result || array() === $result) {
throw new InvalidArgumentException(sprintf('The "%s" file is not valid.', $file)... | Loads a resource.
@param mixed $file The resource
@param string $type The resource type
@throws InvalidArgumentException When ini file is not valid | entailment |
public function handle($request, Closure $next, $acceptedPostTypes)
{
$acceptedPostTypes = explode('|', $acceptedPostTypes);
$message = $request->route('post_type') . ' post type is not supported. ';
$authorized = false;
// Lets verify that we are authorized to use this post type
if(in_array... | Handle an incoming request.
@param \Illuminate\Http\Request $request
@param \Closure $next
@param string|null $guard
@return mixed | entailment |
public function store(array &$submitted, array $options)
{
$this->options = $options;
$this->submitted = &$submitted;
$this->validateStore();
$this->validateBool('status');
$this->validateDomainStore();
$this->validateBasepathStore();
$this->validateName();
... | Performs store data validation
@param array $submitted
@param array $options
@return array|boolean | entailment |
protected function validateStore()
{
$id = $this->getUpdatingId();
if ($id === false) {
return null; // Adding a new store
}
$data = $this->store->get($id);
if (empty($data)) {
$this->setErrorUnavailable('update', $this->translation->text('Store'));... | Validates a store to be updated
@return boolean|null | entailment |
protected function validateDomainStore()
{
$field = 'domain';
if ($this->isExcluded($field)) {
return null;
}
$value = $this->getSubmitted($field);
if ($this->isUpdating() && !isset($value)) {
$this->unsetSubmitted($field);
return null;
... | Validates a domain
@return boolean|null | entailment |
protected function validateBasepathStore()
{
$field = 'basepath';
if ($this->isExcluded($field) || $this->isError('domain')) {
return null;
}
$value = $this->getSubmitted($field);
if ($this->isUpdating() && !isset($value)) {
$this->unsetSubmitted($f... | Validates a store base path
@return boolean|null | entailment |
protected function validateDataStore()
{
$field = 'data';
if ($this->isExcluded($field)) {
return null;
}
$value = $this->getSubmitted($field);
if ($this->isUpdating()) {
if (!isset($value)) {
$this->unsetSubmitted($field);
... | Validate "data" field
@return null|bool | entailment |
protected function validateDataTitleStore()
{
$field = 'data.title';
$value = $this->getSubmitted($field);
if (empty($value) && !$this->isError('name')) {
$this->setSubmitted($field, $this->getSubmitted('name'));
}
$options = $this->options;
$this->optio... | Validates a store title
@return boolean|null | entailment |
protected function validateDataEmailStore()
{
$field = 'data.email';
$value = $this->getSubmitted($field);
$label = $this->translation->text('E-mail');
if (empty($value)) {
$this->setErrorRequired($field, $label);
return false;
}
if (!is_arra... | Validates E-mails
@return boolean|null | entailment |
protected function validateDataMapStore()
{
$field = 'data.map';
$value = $this->getSubmitted($field);
if (empty($value)) {
return null;
}
$label = $this->translation->text('Map');
if (!is_array($value) || count($value) != 2) {
$this->setErr... | Validates map coordinates
@return boolean|null | entailment |
protected function validateDataMetaTitleStore()
{
$field = 'data.meta_title';
$value = $this->getSubmitted($field);
if (empty($value) && !$this->isError('name')) {
$this->setSubmitted($field, $this->getSubmitted('name'));
}
$options = $this->options;
$th... | Validates "meta_title" field
@return boolean|null | entailment |
protected function validateDataMetaDescriptionStore()
{
$options = $this->options;
$this->options += array('parents' => 'data');
$result = $this->validateMetaDescription();
$this->options = $options;
return $result;
} | Validates "meta_description" field
@return boolean|null | entailment |
protected function validateDataTranslationStore()
{
$options = $this->options;
$this->options += array('parents' => 'data');
$result = $this->validateTranslation();
$this->options = $options;
return $result;
} | Validates translatable fields
@return boolean|null | entailment |
protected function validateDataThemeStore()
{
$field = 'data.theme';
$value = $this->getSubmitted($field);
$module = $this->module->get($value);
if (isset($module['type']) && $module['type'] === 'theme' && !empty($module['status'])) {
return true;
}
$thi... | Validates theme module IDs
@return boolean | entailment |
protected function validateImagesStore()
{
if ($this->isError()) {
return null;
}
$error = false;
foreach (array('logo', 'favicon') as $field) {
if ($this->getSubmitted("delete_$field")) {
$this->setSubmitted("data.$field", '');
... | Validates uploaded favicon
@return boolean | entailment |
protected function validateDefaultStore()
{
$id = $this->getUpdatingId();
if (!empty($id) && $this->store->isDefault($id)) {
$this->unsetSubmitted('domain');
$this->unsetSubmitted('basepath');
}
} | Validates default store | entailment |
public function getItems(array $conditions = array())
{
$list = $this->getList($conditions);
if (empty($list)) {
return array();
}
$handler_id = null;
$items = array();
foreach ((array) $list as $item) {
$handler_id = $item['type'];
... | Returns an array of collection item entities
@param array $conditions
@return array | entailment |
public function getItem(array $conditions = array())
{
$list = $this->getItems($conditions);
if (empty($list)) {
return $list;
}
return reset($list);
} | Returns a single entity item
@param array $conditions
@return array | entailment |
public function getListEntities($collection_id, array $arguments)
{
try {
$handlers = $this->collection->getHandlers();
return Handler::call($handlers, $collection_id, 'list', array($arguments));
} catch (Exception $ex) {
trigger_error($ex->getMessage());
... | Returns an array of entities for the given collection ID
@param string $collection_id
@param array $arguments
@return array | entailment |
public function getNextWeight($collection_id)
{
$sql = 'SELECT MAX(weight) FROM collection_item WHERE collection_id=?';
$weight = (int) $this->db->fetchColumn($sql, array($collection_id));
return ++$weight;
} | Returns the next possible weight for a collection item
@param integer $collection_id
@return integer | entailment |
public function get($imagestyle_id)
{
$result = null;
$this->hook->attach('image.style.get.before', $imagestyle_id, $result, $this);
if (isset($result)) {
return (array) $result;
}
$imagestyles = $this->getList();
$result = isset($imagestyles[$imagestyle... | Loads an image style
@param integer $imagestyle_id
@return array | entailment |
public function getList()
{
$imagestyles = &gplcart_static('image.style.list');
if (isset($imagestyles)) {
return (array) $imagestyles;
}
$this->hook->attach('image.style.list.before', $imagestyles, $this);
if (isset($imagestyles)) {
return (array) ... | Returns an array of image styles
@return array | entailment |
public function add(array $data)
{
$result = null;
$this->hook->attach('image.style.add.before', $data, $result, $this);
if (isset($result)) {
return (int) $result;
}
$default = $this->getDefaultData();
$data += $default;
$imagestyle_id = count(... | Adds an image style
@param array $data
@return integer | entailment |
public function update($imagestyle_id, array $data)
{
$result = null;
$this->hook->attach('image.style.update.before', $imagestyle_id, $data, $result, $this);
if (isset($result)) {
return (bool) $result;
}
$existing = $this->getList();
if (empty($existi... | Updates an image style
@param integer $imagestyle_id
@param array $data
@return boolean | entailment |
public function delete($imagestyle_id, $check = true)
{
$result = null;
$this->hook->attach('image.style.delete.before', $imagestyle_id, $check, $result, $this);
if (isset($result)) {
return (bool) $result;
}
if ($check && !$this->canDelete($imagestyle_id)) {
... | Deletes an image style
@param integer $imagestyle_id
@param bool $check
@return boolean | entailment |
public function getActions($imagestyle_id)
{
$styles = $this->getList();
if (empty($styles[$imagestyle_id]['actions'])) {
return array();
}
$actions = $styles[$imagestyle_id]['actions'];
gplcart_array_sort($actions);
return $actions;
} | Returns an array of image style actions
@param integer $imagestyle_id
@return array | entailment |
public function getActionHandlers()
{
$handlers = &gplcart_static('image.style.action.handlers');
if (isset($handlers)) {
return (array) $handlers;
}
$handlers = (array) gplcart_config_get(GC_FILE_CONFIG_IMAGE_ACTION);
$this->hook->attach('image.style.action.han... | Returns an array of image style action handlers
@return array | entailment |
public function getActionHandler($action_id)
{
$handlers = $this->getActionHandlers();
return empty($handlers[$action_id]) ? array() : $handlers[$action_id];
} | Returns a single image action handler
@param string $action_id
@return array | entailment |
public function applyAction(&$source, &$target, $handler, &$action)
{
$result = null;
$this->hook->attach('image.style.apply.before', $source, $target, $handler, $action, $result);
if (isset($result)) {
return $result;
}
try {
$callback = Handler::ge... | Apply a single action to an image file
@param string $source
@param string $target
@param array $handler
@param array $action
@return boolean|string | entailment |
public function applyActions(array $actions, $source, $target)
{
$applied = 0;
foreach ($actions as $action_id => $data) {
$handler = $this->getActionHandler($action_id);
if (empty($handler)) {
continue;
}
$result = $this->applyActio... | Apply an array of actions
@param array $actions
@param string $source
@param string $target
@return int | entailment |
public function clearCache($imagestyle_id = null)
{
$result = null;
$this->hook->attach('image.style.clear.cache.before', $imagestyle_id, $result, $this);
if (isset($result)) {
return (bool) $result;
}
$result = gplcart_file_delete_recursive($this->getDirectory(... | Removes cached files for all or a certain image style
@param integer|null $imagestyle_id
@return boolean | entailment |
public function zip($file)
{
if (!function_exists('zip_open')) {
return false;
}
$zip = zip_open($file);
if (is_resource($zip)) {
zip_close($zip);
return true;
}
return false;
} | Whether the file is a ZIP file
@param string $file
@return boolean | entailment |
protected function addAnAddress($kind, $address, $name = '')
{
if (!preg_match('/^(to|cc|bcc|Reply-To)$/', $kind)) {
$this->setError($this->lang('Invalid recipient array') . ': ' . $kind);
$this->edebug($this->lang('Invalid recipient array') . ': ' . $kind);
if ($this->ex... | Add an address to one of the recipient arrays.
Addresses that have been added already return false, but do not throw exceptions
@param string $kind One of 'to', 'cc', 'bcc', 'ReplyTo'
@param string $address The email address to send to
@param string $name
@throws phpmailerException
@return boolean true on success, fals... | entailment |
public function setFrom($address, $name = '', $auto = true)
{
$address = trim($address);
$name = trim(preg_replace('/[\r\n]+/', '', $name)); //Strip breaks and trim
if (!$this->validateAddress($address)) {
$this->setError($this->lang('invalid_address') . ': ' . $address);
... | Set the From and FromName properties.
@param string $address
@param string $name
@param boolean $auto Whether to also set the Sender address, defaults to true
@throws phpmailerException
@return boolean | entailment |
public static function validateAddress($address, $patternselect = 'auto')
{
if (!$patternselect or $patternselect == 'auto') {
//Check this constant first so it works when extension_loaded() is disabled by safe mode
//Constant was added in PHP 5.2.4
if (defined('PCRE_VERS... | Check that a string looks like an email address.
@param string $address The email address to check
@param string $patternselect A selector for the validation pattern to use :
* `auto` Pick strictest one automatically;
* `pcre8` Use the squiloople.com pattern, requires PCRE > 8.0, PHP >= 5.3.2, 5.2.14;
* `pcre` Use old ... | entailment |
public function send()
{
try {
if (!$this->preSend()) {
return false;
}
return $this->postSend();
} catch (phpmailerException $exc) {
$this->mailHeader = '';
$this->setError($exc->getMessage());
if ($this->except... | Create a message and send it.
Uses the sending method specified by $Mailer.
@throws phpmailerException
@return boolean false on error - See the ErrorInfo property for details of the error. | entailment |
public function getSMTPInstance()
{
if (!is_object($this->smtp)) {
$this->smtp = new Mail\Smtp();
}
return $this->smtp;
} | Get an instance to use for SMTP operations.
Override this function to load your own SMTP implementation
@return SMTP | entailment |
protected function smtpSend($header, $body)
{
$bad_rcpt = array();
if (!$this->smtpConnect()) {
throw new Mail\MailerException($this->lang('smtp_connect_failed'), self::STOP_CRITICAL);
}
$smtp_from = ($this->Sender == '') ? $this->From : $this->Sender;
if (!$this... | Send mail via SMTP.
Returns false if there is a bad MAIL FROM, RCPT, or DATA input.
Uses the PHPMailerSMTP class by default.
@see PHPMailer::getSMTPInstance() to use a different class.
@param string $header The message headers
@param string $body The message body
@throws phpmailerException
@uses SMTP
@access protected
... | entailment |
public function addrFormat($addr)
{
if (empty($addr[1])) { // No name provided
return $this->secureHeader($addr[0]);
} else {
return $this->encodeHeader($this->secureHeader($addr[1]), 'phrase') . ' <' . $this->secureHeader(
$addr[0]
) . '>';
... | Format an address for use in a message header.
@access public
@param array $addr A 2-element indexed array, element 0 containing an address, element 1 containing a name
like array('joe@example.com', 'Joe User')
@return string | entailment |
public function wrapText($message, $length, $qp_mode = false)
{
$soft_break = ($qp_mode) ? sprintf(' =%s', $this->LE) : $this->LE;
// If utf-8 encoding is used, we will need to make sure we don't
// split multibyte characters when we wrap
$is_utf8 = (strtolower($this->CharSet) == 'ut... | Word-wrap message.
For use with mailers that do not automatically perform wrapping
and for quoted-printable encoded messages.
Original written by philippe.
@param string $message The message to wrap
@param integer $length The line length to wrap to
@param boolean $qp_mode Whether to run in Quoted-Printable mode
@access... | entailment |
public function utf8CharBoundary($encodedText, $maxLength)
{
$foundSplitPos = false;
$lookBack = 3;
while (!$foundSplitPos) {
$lastChunk = substr($encodedText, $maxLength - $lookBack, $lookBack);
$encodedCharPos = strpos($lastChunk, '=');
if (false !== $en... | Find the last character boundary prior to $maxLength in a utf-8
quoted (printable) encoded string.
Original written by Colin Brown.
@access public
@param string $encodedText utf-8 QP text
@param integer $maxLength find last character boundary prior to this length
@return integer | entailment |
public function getMailMIME()
{
$result = '';
$ismultipart = true;
switch ($this->message_type) {
case 'inline':
$result .= $this->headerLine('Content-Type', 'multipart/related;');
$result .= $this->textLine("\tboundary=\"" . $this->boundary[1] . '... | Get the message MIME type headers.
@access public
@return string | entailment |
public function encodeHeader($str, $position = 'text')
{
$matchcount = 0;
switch (strtolower($position)) {
case 'phrase':
if (!preg_match('/[\200-\377]/', $str)) {
// Can't use addslashes as we don't know the value of magic_quotes_sybase
... | Encode a header string optimally.
Picks shortest of Q, B, quoted-printable or none.
@access public
@param string $str
@param string $position
@return string | entailment |
public function hasMultiBytes($str)
{
if (function_exists('mb_strlen')) {
return (strlen($str) > mb_strlen($str, $this->CharSet));
} else { // Assume no multibytes (we can't handle without mbstring functions anyway)
return false;
}
} | Check if a string contains multi-byte characters.
@access public
@param string $str multi-byte text to wrap encode
@return boolean | entailment |
public function base64EncodeWrapMB($str, $linebreak = null)
{
$start = '=?' . $this->CharSet . '?B?';
$end = '?=';
$encoded = '';
if ($linebreak === null) {
$linebreak = $this->LE;
}
$mb_length = mb_strlen($str, $this->CharSet);
// Each line must ... | Encode and wrap long multibyte strings for mail headers
without breaking lines within a character.
Adapted from a function by paravoid
@link http://www.php.net/manual/en/function.mb-encode-mimeheader.php#60283
@access public
@param string $str multi-byte text to wrap encode
@param string $linebreak string to use as lin... | entailment |
public function addEmbeddedImage($path, $cid, $name = '', $encoding = 'base64', $type = '', $disposition = 'inline')
{
if (!@is_file($path)) {
$this->setError($this->lang('file_access') . $path);
return false;
}
// If a MIME type is not specified, try to work it out ... | Add an embedded (inline) attachment from a file.
This can include images, sounds, and just about any other document type.
These differ from 'regular' attachments in that they are intended to be
displayed inline with the message, not just attached for download.
This is used in HTML messages that embed the images
the HTM... | entailment |
public function clearCCs()
{
foreach ($this->cc as $cc) {
unset($this->all_recipients[strtolower($cc[0])]);
}
$this->cc = array();
} | Clear all CC recipients.
@return void | entailment |
protected function setError($msg)
{
$this->error_count++;
if ($this->Mailer == 'smtp' and !is_null($this->smtp)) {
$lasterror = $this->smtp->getError();
if (!empty($lasterror) and array_key_exists('smtp_msg', $lasterror)) {
$msg .= '<p>' . $this->lang('smtp_er... | Add an error message to the error container.
@access protected
@param string $msg
@return void | entailment |
protected function serverHostname()
{
$result = 'localhost.localdomain';
if (!empty($this->Hostname)) {
$result = $this->Hostname;
} elseif (isset($_SERVER) and array_key_exists('SERVER_NAME', $_SERVER) and !empty($_SERVER['SERVER_NAME'])) {
$result = $_SERVER['SERVER... | Get the server hostname.
Returns 'localhost.localdomain' if unknown.
@access protected
@return string | entailment |
protected function lang($key)
{
if (count($this->language) < 1) {
$this->setLanguage('en'); // set the default language
}
if (isset($this->language[$key])) {
return $this->language[$key];
} else {
return 'Language string failed to load: ' . $key;
... | Get an error message in the current language.
@access protected
@param string $key
@return string | entailment |
public function fixEOL($str)
{
// Normalise to \n
$nstr = str_replace(array("\r\n", "\r"), "\n", $str);
// Now convert LE as needed
if ($this->LE !== "\n") {
$nstr = str_replace("\n", $this->LE, $nstr);
}
return $nstr;
} | Ensure consistent line endings in a string.
Changes every end of line from CRLF, CR or LF to $this->LE.
@access public
@param string $str String to fixEOL
@return string | entailment |
public function msgHTML($message, $basedir = '', $advanced = false)
{
preg_match_all('/(src|background)=["\'](.*)["\']/Ui', $message, $images);
if (isset($images[2])) {
foreach ($images[2] as $imgindex => $url) {
// Convert data URIs into embedded images
i... | Create a message from an HTML string.
Automatically makes modifications for inline images and backgrounds
and creates a plain-text version by converting the HTML.
Overwrites any existing values in $this->Body and $this->AltBody
@access public
@param string $message HTML message string
@param string $basedir baseline di... | entailment |
public function html2text($html, $advanced = false)
{
if (is_callable($advanced)) {
return $advanced($html);
}
return html_entity_decode(
trim(strip_tags(preg_replace('/<(head|title|style|script)[^>]*>.*?<\/\\1>/si', '', $html))),
ENT_QUOTES,
$... | Convert an HTML string into plain text.
This is used by msgHTML().
Note - older versions of this function used a bundled advanced converter
which was been removed for license reasons in #232
Example usage:
<code>
// Use default conversion
$plain = $mail->html2text($html);
// Use your own custom converter
$plain = $mail... | entailment |
public function DKIM_Sign($signHeader)
{
if (!defined('PKCS7_TEXT')) {
if ($this->exceptions) {
throw new Mail\MailerException($this->lang('signing') . ' OpenSSL extension missing.');
}
return '';
}
$privKeyStr = file_get_contents($this->DK... | Generate a DKIM signature.
@access public
@param string $signHeader
@throws phpmailerException
@return string | entailment |
public function DKIM_BodyC($body)
{
if ($body == '') {
return "\r\n";
}
// stabilize line endings
$body = str_replace("\r\n", "\n", $body);
$body = str_replace("\n", "\r\n", $body);
// END stabilize line endings
while (substr($body, strlen($body) -... | Generate a DKIM canonicalization body.
@access public
@param string $body Message Body
@return string | entailment |
public function get($key, $default = null)
{
if (!GC_CLI && isset($_SESSION)) {
$value = gplcart_array_get($_SESSION, $key);
}
return isset($value) ? $value : $default;
} | Returns a session data
@param string|array $key
@param mixed $default
@return mixed | entailment |
public function set($key, $value = null)
{
if (!GC_CLI && isset($_SESSION)) {
gplcart_array_set($_SESSION, $key, $value);
return true;
}
return false;
} | Set a session data
@param string|array $key
@param mixed $value
@return bool | entailment |
public function delete($key = null)
{
if (!$this->isInitialized()) {
return false;
}
if (!isset($key)) {
session_unset();
if (!session_destroy()) {
throw new RuntimeException('Failed to delete the session');
}
re... | Deletes a data from the session
@param mixed $key
@return bool
@throws RuntimeException | entailment |
public function setMessage($message, $type = 'info', $key = 'messages')
{
if ($message !== '') {
$messages = (array) $this->get("$key.$type", array());
if (!in_array($message, $messages)) {
$messages[] = $message;
$this->set("$key.$type", $messages);... | Sets a message to be displayed to the user
@param string $message
@param string $type
@param string $key | entailment |
public function getMessage($type = null, $key = 'messages')
{
if (isset($type)) {
$key .= ".$type";
}
$message = $this->get($key, array());
$this->delete($key);
return $message;
} | Returns messages from the session
@param string $type
@param string $key
@return string|array | entailment |
public function city(array &$submitted, array $options = array())
{
$this->options = $options;
$this->submitted = &$submitted;
$this->validateCity();
$this->validateBool('status');
$this->validateName();
$this->validateStateCity();
$this->validateZoneCity();
... | Performs full city data validation
@param array $submitted
@param array $options
@return boolean|array | entailment |
protected function validateCity()
{
$id = $this->getUpdatingId();
if ($id === false) {
return null;
}
$data = $this->city->get($id);
if (empty($data)) {
$this->setErrorUnavailable('update', $this->translation->text('City'));
return false... | Validates a city to be updated
@return boolean|null | entailment |
protected function validateCountryCity()
{
$field = 'country';
if ($this->isExcluded($field)) {
return null;
}
$value = $this->getSubmitted($field);
if ($this->isUpdating() && !isset($value)) {
$this->unsetSubmitted($field);
return null;... | Validates a country code
@return boolean|null | entailment |
public function createService(ServiceLocatorInterface $serviceLocator)
{
$context = new RequestContext();
$context->fromRequest($serviceLocator->get('Request'));
return $context;
} | Create and return the router.
@param ServiceLocatorInterface $serviceLocator
@return \PPI\Framework\Router\RouterListener | entailment |
protected function processConfiguration(array $config, ServiceLocatorInterface $serviceLocator = null)
{
$defaults = $this->getConfigurationDefaults();
$defaults = $defaults['framework']['router'];
return isset($config['framework']['router']) ?
$this->mergeConfiguration($default... | {@inheritDoc} | entailment |
public function file(array &$submitted, array $options = array())
{
$this->options = $options;
$this->submitted = &$submitted;
$this->validateFile();
$this->validateTitleFile();
$this->validateDescription();
$this->validateWeight();
$this->validateTranslation... | Performs full file data validation
@param array $submitted
@param array $options
@return boolean|array | entailment |
protected function validateFile()
{
$id = $this->getUpdatingId();
if ($id === false) {
return null;
}
$data = $this->file->get($id);
if (empty($data)) {
$this->setErrorUnavailable('update', $this->translation->text('File'));
return false... | Validates a file to be updated
@return boolean|null | entailment |
protected function validateTitleFile()
{
$field = 'title';
$value = $this->getSubmitted($field);
if (isset($value) && mb_strlen($value) > 255) {
$this->setErrorLengthRange($field, $this->translation->text('Title'), 0, 255);
return false;
}
return tru... | Validates a title field
@return boolean | entailment |
protected function validatePathFile()
{
$field = 'path';
$value = $this->getSubmitted($field);
if ($this->isExcluded($field) || $this->isError()) {
return null;
}
if (!isset($value) && $this->isUpdating()) {
return null;
}
$label = $... | Validates a file path
@return boolean|null | entailment |
protected function validateUploadFile()
{
$file = $this->request->file('file');
if (empty($file)) {
return null;
}
$result = $this->file_transfer->upload($file, null);
if ($result !== true) {
$this->setError('path', (string) $result);
re... | Validates file upload
@return bool|null | entailment |
protected function validateEntityIdFile()
{
$field = 'entity_id';
if ($this->isExcluded($field)) {
return null;
}
$value = $this->getSubmitted($field);
if (!isset($value)) {
$this->unsetSubmitted($field);
return null;
}
... | Validates entity ID
@return bool|null | entailment |
public function createService(ServiceLocatorInterface $serviceLocator)
{
$router = $serviceLocator->get('Router');
$requestContext = $serviceLocator->get('RouterRequestContext');
$logger = $serviceLocator->has('Logger') ? $serviceLocator->get('Logger') : null;
$reques... | Create and return the router.
@param ServiceLocatorInterface $serviceLocator
@return \PPI\Framework\Router\RouterListener | entailment |
public function update($cart_id, array $data)
{
$result = null;
$this->hook->attach('cart.update.before', $cart_id, $data, $result, $this);
if (isset($result)) {
return (bool) $result;
}
$data['modified'] = GC_TIME;
$result = (bool) $this->db->update('ca... | Updates a cart
@param integer $cart_id
@param array $data
@return boolean | entailment |
public function getContent(array $data)
{
$result = &gplcart_static(gplcart_array_hash(array('cart.get.content' => $data)));
if (isset($result)) {
return $result;
}
$this->hook->attach('cart.get.content.before', $data, $result, $this);
if (isset($result)) {
... | Returns a cart content
@param array $data
@return array | entailment |
public function getUid()
{
$session_user_id = $this->user->getId();
if (!empty($session_user_id)) {
return (string) $session_user_id;
}
$cookie_name = $this->getCookieUserName();
$cookie_user_id = $this->request->cookie($cookie_name, '', 'string');
if (... | Returns the cart user ID
@return string | entailment |
public function getQuantity(array $options, $type = null)
{
$options += array('order_id' => 0);
$result = array(
'total' => 0,
'sku' => array()
);
foreach ((array) $this->getList($options) as $item) {
$result['total'] += (int) $item['quantity'];
... | Returns cart quantity
@param array $options
@param string $type
@return array|integer | entailment |
public function getLimits($item = null)
{
$limits = array(
'sku' => (int) $this->config->get('cart_sku_limit', 10),
'item' => (int) $this->config->get('cart_item_limit', 20)
);
return isset($item) ? $limits[$item] : $limits;
} | Returns cart limits
@param null|string $item
@return array|integer | entailment |
protected function prepareItem(array $item, array $data)
{
$product = $this->product->getBySku($item['sku'], $item['store_id']);
if (empty($product['status']) || $data['store_id'] != $product['store_id']) {
return array();
}
$product['price'] = $this->currency->convert(... | Prepare a cart item
@param array $item
@param array $data
@return array | entailment |
public function attach(EventManagerInterface $events)
{
$options = $this->getOptions();
$configListener = $this->getConfigListener();
// High priority, we assume module autoloading (for FooNamespace\Module classes) should be available before anything else
... | Override of attach(). Customising the events to be triggered upon the
'loadModule' event.
@param EventManagerInterface $events
@return $this | entailment |
public function routesTrigger(ModuleEvent $e)
{
$module = $e->getModule();
if (is_callable(array($module, 'getRoutes'))) {
$routes = $module->getRoutes();
$this->routes[$e->getModuleName()] = $routes;
}
return $this;
} | Callback for 'routesTrigger' event.
@param ModuleEvent $e
@throws \Exception if the module returns an invalid route type
@return $this | entailment |
public function getServicesTrigger(ModuleEvent $e)
{
$module = $e->getModule();
if (method_exists($module, 'getServiceConfig') && is_callable(array($module, 'getServiceConfig'))) {
$services = $module->getServiceConfig();
if (is_array($services) && isset($services['factories... | Event callback for 'initServicesTrigger'.
@param ModuleEvent $e
@return $this | entailment |
public function getServices()
{
$mergedModuleServices = array();
foreach ($this->services as $services) {
$mergedModuleServices = ArrayUtils::merge($mergedModuleServices, $services);
}
return $mergedModuleServices;
} | Get the registered services.
@return mixed | entailment |
public function update($review_id, array $data)
{
$result = null;
$this->hook->attach('review.update.before', $review_id, $data, $result, $this);
if (isset($result)) {
return (bool) $result;
}
$data['modified'] = GC_TIME;
$result = $this->db->update('rev... | Updates a review
@param integer $review_id
@param array $data
@return boolean | entailment |
public function delete($review_id)
{
$result = null;
$this->hook->attach('review.delete.before', $review_id, $result, $this);
if (isset($result)) {
return (bool) $result;
}
settype($review_id, 'array');
$placeholders = rtrim(str_repeat('?,', count($revi... | Deletes a review
@param integer|array $review_id
@return boolean | entailment |
public function rating(array &$submitted, array $options = array())
{
$this->options = $options;
$this->submitted = &$submitted;
$this->validateProductRating();
$this->validateUserId();
$this->validateValueRating();
return $this->getResult();
} | Performs full rating data validation
@param array $submitted
@param array $options
@return array|boolean | entailment |
protected function validateValueRating()
{
$field = 'rating';
if ($this->isExcluded($field)) {
return null;
}
$value = $this->getSubmitted($field);
$label = $this->translation->text('Rating');
if (!isset($value)) {
$this->setErrorRequired($f... | Validates a rating value
@return boolean | entailment |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.