sentence1 stringlengths 52 3.87M | sentence2 stringlengths 1 47.2k | label stringclasses 1
value |
|---|---|---|
public function createService(ServiceLocatorInterface $serviceLocator)
{
$request = $serviceLocator->get('Request');
$requestContext = $serviceLocator->get('RouterRequestContext');
$routerOptions = array();
$logger = $serviceLocator->has('Logger') ? $serviceLocator->get('Logger')... | @todo - move this to a separate method() - consider how to inject custom-defined arbitrary chain router entries
@param ServiceLocatorInterface $serviceLocator
@throws \Exception
@return ChainRouter | entailment |
public function getList()
{
$result = &gplcart_static('product.compare.list');
if (isset($result)) {
return (array) $result;
}
$this->hook->attach('product.compare.list.before', $result, $this);
if (isset($result)) {
return (array) $result;
... | Returns an array of product ID to be compared
@return array | entailment |
public function add($product_id)
{
$result = null;
$this->hook->attach('product.compare.add.before', $product_id, $result, $this);
if (isset($result)) {
return (bool) $result;
}
$product_ids = $this->getList();
if (in_array($product_id, $product_ids)) {... | Adds a product to comparison
@param integer $product_id
@return boolean | entailment |
public function delete($product_id)
{
$result = null;
$this->hook->attach('product.compare.delete.before', $product_id, $result, $this);
if (isset($result)) {
return (bool) $result;
}
$compared = $this->getList();
if (empty($compared)) {
ret... | Removes a products from comparison
@param integer $product_id
@return array|boolean | entailment |
public function set(array $product_ids)
{
$lifespan = $this->getCookieLifespan();
$result = $this->request->setCookie('product_compare', implode('|', (array) $product_ids), $lifespan);
gplcart_static_clear();
return $result;
} | Saves an array of product ID in cookie
@param array $product_ids
@return boolean | entailment |
protected function controlLimit(array &$product_ids)
{
$limit = $this->getLimit();
if (!empty($limit)) {
$product_ids = array_slice($product_ids, 0, $limit);
}
} | Reduces a number of items to save
@param array $product_ids | entailment |
public function install(array $data, $db)
{
$this->db = $db;
$this->data = $data;
try {
$this->start();
$this->process();
return $this->finish();
} catch (Exception $ex) {
return array(
'redirect' => '',
... | Performs full system installation
@param array $data
@param \gplcart\core\Database $db
@return array | entailment |
public function parseParams($argv)
{
if (is_string($argv)) {
$argv = gplcart_string_explode_whitespace($argv);
}
array_shift($argv);
$out = array();
for ($i = 0, $j = count($argv); $i < $j; $i++) {
$key = null;
$arg = $argv[$i];
... | Parses command line parameters
@param array|string $argv
@return array | entailment |
public function in($format = '')
{
if (empty($format)) {
$line = fgets(STDIN);
} else {
$line = fscanf(STDIN, $format . PHP_EOL, $line);
}
return trim($line);
} | Reads a user input
@param string $format
@return string | entailment |
public function prompt($question, $default = null, $marker = ': ')
{
if (isset($default) && strpos($question, '[') === false) {
$question .= ' [default: ' . $default . ']';
}
$this->out($question . $marker);
$input = $this->in();
if ($input === '') {
... | Displays an input prompt
@param string $question
@param string|null $default
@param string $marker
@return mixed | entailment |
public function menu($items, $default = null, $title = 'Choose an item')
{
if (isset($items[$default]) && strpos($title, '[') === false) {
$title .= ' [default: ' . $items[$default] . ']';
}
$this->line(sprintf('%s: ', $title));
$i = 1;
$keys = array();
... | Displays a menu where a user can enter a number to choose an option
@param array $items An array like array('key' => 'Label')
@param mixed $default
@param string $title
@return mixed | entailment |
public function choose($question, $choice = 'yn', $default = 'n')
{
if (!is_string($choice)) {
$choice = implode('', $choice);
}
$lowercase = str_ireplace($default, strtoupper($default), strtolower($choice));
$choices = trim(implode('/', preg_split('//', $lowercase)), '/... | Presents a user with a multiple choice questions
@param string $question
@param string|array $choice
@param string $default
@return string | entailment |
public function exec($command, $message = true, $output = true)
{
$shell_output = array();
exec($command . ' 2>&1', $shell_output, $result);
if (empty($result)) {
if ($message) {
$this->out('OK');
}
} else {
if ($message) {
... | Executes a Shell command using exec() function
@param string $command
@param boolean $message
@param boolean $output
@return integer | entailment |
public function table(array $data)
{
$columns = array();
foreach ($data as $rkey => $row) {
foreach ($row as $ckey => $cell) {
$length = strlen($cell);
if (empty($columns[$ckey]) || $columns[$ckey] < $length) {
$columns[$ckey] = $lengt... | Output simple table
@param array $data | entailment |
public function addConfig($resource, $type)
{
if (!$this->skipConfig) {
$this->configs[] = array(
'resource' => $resource,
'type' => $type,
);
}
return $this;
} | @param mixed $resource The resource
@param string $type The resource type
@return $this | entailment |
public function set($data = null)
{
$this->server = isset($data) ? $data : $_SERVER;
return $this;
} | Sets $_SERVER variables
@param null|array $data
@return $this | entailment |
public function get($name = null, $default = '', $sanitize = true)
{
if (!isset($name)) {
return $this->server;
}
if (!array_key_exists($name, $this->server)) {
return $default;
}
if (is_array($this->server[$name])) {
gplcart_array_trim($... | Returns a server data
@param string $name
@param mixed $default
@param bool $sanitize
@return mixed | entailment |
public function header($name, $default = null, $sanitize = true)
{
$headers = $this->headers();
$name = ucfirst(strtolower($name));
if (array_key_exists($name, $headers)) {
return $sanitize ? filter_var($headers[$name], FILTER_SANITIZE_STRING) : $headers[$name];
}
... | Returns an HTTP header
@param string $name
@param mixed $default
@param bool $sanitize
@return string | entailment |
public function headers()
{
if (function_exists('getallheaders')) {
$headers = getallheaders();
return empty($headers) ? array() : $headers;
}
$headers = array();
foreach ($_SERVER as $name => $value) {
if (substr($name, 0, 5) == 'HTTP_') {
... | Returns an array of HTTP headers
$_SERVER is not entirely complete (e.g doesn't contain Authorization header)
so first it tries to use getallheaders() function which works only on Apache server
@return array | entailment |
public function get($key)
{
$key = strtolower($key);
if (!isset($this->services[$key])) {
throw new \InvalidArgumentException('Service not found: ' . $key);
}
// Have we been here before?
if (isset($this->loadedService[$key])) {
return $this->loadedS... | Get a registered service by its name.
@param string $key
@throws \Exception|\InvalidArgumentException
@return mixed | entailment |
protected function validateCastValue($val)
{
if (isset($this->descriptor()->bareNumber) && $this->descriptor()->bareNumber === false) {
return mb_ereg_replace('((^\D*)|(\D*$))', '', $val);
}
$isPercent = false;
if (is_string($val)) {
if (substr($val, -1) == '%... | @param mixed $val
@return float
@throws \frictionlessdata\tableschema\Exceptions\FieldValidationException; | entailment |
public function getCollectionItems(array $conditions, array $options, $model)
{
$conditions += array(
'status' => 1,
'store_id' => $this->getStoreId()
);
$items = $model->getItems($conditions);
if (!empty($items)) {
$item = reset($items);
... | Returns an array of collection items
@param array $conditions
@param array $options
@param \gplcart\core\models\CollectionItem $model
@return array | entailment |
public function listCategory()
{
$this->setTitleListCategory();
$this->setBreadcrumbListCategory();
$this->setData('categories', $this->data_categories);
$this->outputListCategory();
} | Page callback
Displays the catalog page | entailment |
public function indexCategory($category_id)
{
$this->setCategory($category_id);
$this->setTitleIndexCategory();
$this->setBreadcrumbIndexCategory();
$this->setHtmlFilterIndexCategory();
$this->setTotalIndexCategory();
$this->setFilterIndexCategory();
$this->se... | Page callback
Displays the category page
@param integer $category_id | entailment |
protected function setFilterIndexCategory()
{
$default = array(
'view' => $this->configTheme('catalog_view', 'grid'),
'sort' => $this->configTheme('catalog_sort', 'price'),
'order' => $this->configTheme('catalog_order', 'asc')
);
$this->setFilter(array(),... | Sets filter on the category page | entailment |
protected function setTotalIndexCategory()
{
$options = $this->query_filter;
$options['count'] = true;
$options['category_id'] = $this->data_category['category_id'];
return $this->data_total = (int) $this->product->getList($options);
} | Sets a total number of products found for the category
@return int | entailment |
protected function setPagerIndexCategory()
{
$pager = array(
'total' => $this->data_total,
'query' => $this->query_filter,
'limit' => $this->configTheme('catalog_limit', 20)
);
return $this->data_limit = $this->setPager($pager);
} | Sets pager
@return array | entailment |
protected function setDataImagesIndexCategory()
{
$options = array('imagestyle' => $this->configTheme('image_style_category', 3));
$this->setItemThumb($this->data_category, $this->image, $options);
$this->setData('images', $this->render('category/images', array('category' => $this->data_cat... | Sets the category images | entailment |
protected function setDataNavbarIndexCategory()
{
$data = array(
'total' => $this->data_total,
'view' => $this->query_filter['view'],
'quantity' => count($this->data_products),
'sort' => "{$this->query_filter['sort']}-{$this->query_filter['order']}"
);... | Sets navigation bar on the category page | entailment |
protected function setListProductCategory()
{
$options = $this->query_filter;
$options['placeholder'] = true;
$conditions = array(
'limit' => $this->data_limit,
'category_id' => $this->data_category['category_id']) + $this->query_filter;
$this->data_... | Sets an array of products for the category | entailment |
protected function setMetaIndexCategory()
{
$this->setMetaEntity($this->data_category);
if (empty($this->data_children) && empty($this->data_products)) {
$this->setMeta(array('name' => 'robots', 'content' => 'noindex'));
}
} | Sets the meta tags on the category page | entailment |
protected function setChildrenCategory()
{
$this->data_children = array();
foreach ($this->data_categories as $item) {
if (in_array($this->data_category['category_id'], $item['parents'])) {
$this->data_children[] = $item;
}
}
} | Sets an array of children categories for the given category | entailment |
protected function setTitleIndexCategory()
{
$metatitle = $this->data_category['meta_title'];
if (empty($metatitle)) {
$metatitle = $this->data_category['title'];
}
$this->setTitle($metatitle, false);
$this->setPageTitle($this->data_category['title']);
} | Sets titles on the category page | entailment |
protected function setCategory($category_id)
{
$options = array(
'category_id' => $category_id,
'language' => $this->langcode,
'store_id' => $this->store_id
);
$this->data_category = $this->category->get($options);
if (empty($this->data_category[... | Sets a category data
@param integer $category_id | entailment |
public function doRun(InputInterface $input, OutputInterface $output)
{
$this->registerCommands();
if (true === $input->hasParameterOption(array('--shell', '-s'))) {
$shell = new Shell($this);
$shell->setProcessIsolation($input->hasParameterOption(array('--process-isolation')... | Runs the current application.
@param InputInterface $input An Input instance
@param OutputInterface $output An Output instance
@return int 0 if everything went fine, or an error code | entailment |
public function indexFront()
{
$this->setTitleIndexFront();
$this->setDataCollectionFront('page');
$this->setDataCollectionFront('file');
$this->setDataCollectionFront('product');
$this->outputIndexFront();
} | Displays the store front page | entailment |
protected function setDataCollectionFront($type)
{
$collection_id = $this->getStore("data.collection_$type");
if (!empty($collection_id)) {
$conditions = array('collection_id' => $collection_id);
$options = array('imagestyle' => $this->configTheme("image_style_collection_$ty... | Adds a collection block
@param string $type | entailment |
protected function getPostType($group)
{
// Receive the config variable where we have whitelisted all models
$nikuConfig = config('niku-cms');
// Validating if the model exists in the array
if(array_key_exists($group, $nikuConfig['config_types'])){
// Setting the model class
$postT... | Validating if the post type exists and returning the model. | entailment |
public function add(array $product, array $data)
{
$result = array();
$this->hook->attach('product.compare.add.product.before', $product, $data, $result, $this);
if (!empty($result)) {
return (array) $result;
}
if (!$this->compare->add($product['product_id'])) {... | Adds a product to comparison and returns an array of results
@param array $product
@param array $data
@return array | entailment |
public function delete($product_id)
{
$result = null;
$this->hook->attach('product.compare.delete.product.before', $product_id, $result, $this);
if (!empty($result)) {
return (array) $result;
}
if (!$this->compare->delete($product_id)) {
return $this... | Removes a product from comparison and returns an array of result data
@param integer $product_id
@return array | entailment |
protected function getResultAdded()
{
$quantity = count($this->compare->getList());
if ($quantity < $this->compare->getLimit()) {
$quantity++;
}
$message = $this->translation->text('Product has been added to <a href="@url">comparison</a>', array(
'@url' => $... | Returns an array of resulting data when a product has been added to comparison
@return array | entailment |
public function up()
{
Schema::create('cms_taxonomy', function (Blueprint $table) {
$table->bigIncrements('id');
$table->bigInteger('post_id')->unsigned();
$table->bigInteger('taxonomy_post_id')->unsigned();
$table->string('taxonomy')->nullable();
... | Run the migrations.
@return void | entailment |
public function parse($controller)
{
list($module, $moduleName, $controller, $action) = $this->getPartsFromControllerName($controller);
if (null === $module) {
// this throws an exception if there is no such module
$msg = sprintf('Unable to find controller "%s:%s" - module a... | Converts a short notation a:b:c to a class::method.
@param string $controller A short notation controller (a:b:c)
@throws \InvalidArgumentException when the specified module is not enabled
or the controller cannot be found
@return string A string with class::method | entailment |
private function getPartsFromControllerName($controller)
{
if (3 != count($parts = explode(':', $controller))) {
throw new \InvalidArgumentException(sprintf('The "%s" controller is not a valid a:b:c controller string.', $controller));
}
list($moduleName, $controller, $action) = ... | @param string $controller
@return array | entailment |
public function countryCode(array $values)
{
$existing = array_filter($values, function ($code) {
$country = $this->country->get($code);
return isset($country['code']);
});
if (count($values) != count($existing)) {
return $this->translation->text('@name i... | Validates the country code condition
@param array $values
@return boolean|string | entailment |
public function stateId(array $values)
{
$count = count($values);
$ids = array_filter($values, 'ctype_digit');
if ($count != count($ids)) {
return $this->translation->text('@field has invalid value', array(
'@field' => $this->translation->text('Condition')));
... | Validates the country state condition
@param array $values
@return boolean|string | entailment |
public function zoneId(array $values, $operator)
{
if (!in_array($operator, array('=', '!='))) {
return $this->translation->text('Unsupported operator');
}
$zone = $this->zone->get(reset($values));
if (empty($zone)) {
return $this->translation->text('@name i... | Validates a zone ID condition
@param array $values
@param string $operator
@return boolean | entailment |
public function getUser($nullIfGuest = false)
{
$user = $this->user;
$token = $this->tokenStorage->getToken();
if (!$user && null !== $token) {
$user = $token->getUser();
}
if (!$user instanceof User) {
if ($nullIfGuest) {
return nul... | @param bool $nullIfGuest
@return User|null | entailment |
public function listPage()
{
$this->actionPage();
$this->setTitleListPage();
$this->setBreadcrumbListPage();
$this->setFilterListPage();
$this->setPagerListPage();
$this->setData('pages', $this->getListPage());
$this->outputListPage();
} | Displays the page overview | entailment |
protected function actionPage()
{
list($selected, $action, $value) = $this->getPostedAction();
$deleted = $updated = 0;
foreach ($selected as $page_id) {
if ($this->access('page_edit')) {
if ($action === 'status') {
$updated += (int) $this->... | Applies an action to the selected pages | entailment |
protected function setPagerListPage()
{
$conditions = $this->query_filter;
$conditions['count'] = true;
$pager = array(
'query' => $this->query_filter,
'total' => (int) $this->page->getList($conditions)
);
return $this->data_limit = $this->setPager($... | Sets pager
@return array | entailment |
protected function getListPage()
{
$conditions = $this->query_filter;
$conditions['limit'] = $this->data_limit;
$list = (array) $this->page->getList($conditions);
$this->prepareListPage($list);
return $list;
} | Returns an array of pages
@return array | entailment |
protected function prepareListPage(array &$list)
{
foreach ($list as &$item) {
$this->setItemUrlEntity($item, $this->store, 'page');
}
} | Prepare an array of pages
@param array $list | entailment |
public function editPage($page_id = null)
{
$this->setPage($page_id);
$this->setTitleEditPage();
$this->setBreadcrumbEditPage();
$this->setData('page', $this->data_page);
$this->setData('languages', $this->language->getList(array('enabled' => true)));
$this->submitE... | Displays the page edit form
@param integer|null $page_id | entailment |
protected function setPage($page_id)
{
$this->data_page = array();
if (is_numeric($page_id)) {
$conditions = array(
'language' => 'und',
'page_id' => $page_id
);
$this->data_page = $this->page->get($conditions);
if (... | Set a page data
@param integer $page_id | entailment |
protected function preparePage(array &$page)
{
$user = $this->user->get($page['user_id']);
$this->setItemAlias($page, 'page', $this->alias);
$this->setItemImages($page, 'page', $this->image);
$this->setItemTranslation($page, 'page', $this->translation_entity);
if (!empty($p... | Prepares an array of page data
@param array $page | entailment |
protected function submitEditPage()
{
if ($this->isPosted('delete')) {
$this->deletePage();
} else if ($this->isPosted('save') && $this->validateEditPage()) {
$this->deleteImagesPage();
if (isset($this->data_page['page_id'])) {
$this->updatePage();... | Handles a submitted page | entailment |
protected function deleteImagesPage()
{
$this->controlAccess('page_edit');
$file_ids = $this->getPosted('delete_images', array(), true, 'array');
return $this->image->delete($file_ids);
} | Delete page images
@return boolean | entailment |
protected function validateEditPage()
{
$this->setSubmitted('page', null, false);
$this->setSubmitted('form', true);
$this->setSubmitted('update', $this->data_page);
$this->setSubmittedBool('status');
$this->setSubmittedBool('blog_post');
if (empty($this->data_page['... | Validates a submitted page
@return bool | entailment |
protected function deletePage()
{
$this->controlAccess('page_delete');
if ($this->page->delete($this->data_page['page_id'])) {
$this->redirect('admin/content/page', $this->text('Page has been deleted'), 'success');
}
$this->redirect('', $this->text('Page has not been de... | Deletes a page | entailment |
protected function updatePage()
{
$this->controlAccess('page_edit');
if ($this->page->update($this->data_page['page_id'], $this->getSubmitted())) {
$this->redirect('admin/content/page', $this->text('Page has been updated'), 'success');
}
$this->redirect('', $this->text(... | Updates a page | entailment |
protected function addPage()
{
$this->controlAccess('page_add');
if ($this->page->add($this->getSubmitted())) {
$this->redirect('admin/content/page', $this->text('Page has been added'), 'success');
}
$this->redirect('', $this->text('Page has not been added'), 'warning')... | Adds a new page | entailment |
protected function setDataImagesEditPage()
{
$options = array(
'entity' => 'page',
'images' => $this->getData('page.images', array())
);
$this->setItemThumb($options, $this->image);
$this->setData('attached_images', $this->getWidgetImages($this->language, $op... | Adds images on the page edit form | entailment |
protected function setDataCategoriesEditPage()
{
$op = array('store_id' => $this->getData('page.store_id', $this->store->getDefault()));
$categories = $this->getCategoryOptionsByStore($this->category, $this->category_group, $op);
$this->setData('categories', $categories);
} | Adds list of categories on the page edit form | entailment |
protected function setTitleEditPage()
{
if (isset($this->data_page['page_id'])) {
$title = $this->text('Edit %name', array('%name' => $this->data_page['title']));
} else {
$title = $this->text('Add page');
}
$this->setTitle($title);
} | Sets titles on the page edit | entailment |
protected function setBreadcrumbEditPage()
{
$breadcrumbs = array();
$breadcrumbs[] = array(
'url' => $this->url('admin'),
'text' => $this->text('Dashboard')
);
$breadcrumbs[] = array(
'text' => $this->text('Pages'),
'url' => $this->u... | Sets breadcrumbs on the page edit | entailment |
public function addIndex($text, $entity, $entity_id, $language)
{
$values = array(
'text' => $text,
'entity' => $entity,
'language' => $language,
'entity_id' => $entity_id
);
return (bool) $this->db->insert('search_index', $values);
} | Adds an item to the search index
@param string $text
@param string $entity
@param integer $entity_id
@param string $language
@return boolean | entailment |
public function deleteIndex($entity, $entity_id, $language)
{
$values = array(
'entity' => $entity,
'language' => $language,
'entity_id' => $entity_id
);
return (bool) $this->db->delete('search_index', $values);
} | Deletes an item from the search index
@param string $entity
@param integer $entity_id
@param string $language
@return boolean | entailment |
public function setIndex($text, $entity, $entity_id, $language)
{
$this->deleteIndex($entity, $entity_id, $language);
if (empty($text)) {
return false;
}
return $this->addIndex($text, $entity, $entity_id, $language);
} | Sets an item to the search index
@param string $text
@param string $entity
@param integer $entity_id
@param string $language
@return boolean | entailment |
public function index($handler_id, $data)
{
$result = null;
$this->hook->attach('search.index', $handler_id, $data, $result, $this);
if (isset($result)) {
return $result;
}
return $this->callHandler($handler_id, 'index', array($data, $this));
} | Indexes an item
@param string $handler_id
@param array|string $data
@return mixed | entailment |
public function search($handler_id, $query, array $options = array())
{
if (!isset($options['language'])) {
$options['language'] = 'und';
}
$result = null;
$this->hook->attach('search', $handler_id, $query, $options, $result, $this);
if (isset($result)) {
... | Returns an array of items found for the search query
@param string $handler_id
@param string $query
@param array $options
@return mixed | entailment |
public function callHandler($handler_id, $method, array $args)
{
try {
$handlers = $this->getHandlers();
return Handler::call($handlers, $handler_id, $method, $args);
} catch (Exception $ex) {
return null;
}
} | Calls a search handler
@param string $handler_id
@param string $method
@param array $args
@return mixed | entailment |
public function getSnippet(array $data, $language)
{
$parts = array();
if (isset($data['title'])) {
// Repeat title twice to make it more important
$parts = array($data['title'], $data['title']);
}
if (isset($data['description'])) {
$parts[] = str... | Returns a text string to be saved in the index table
@param array $data
@param string $language
@return string | entailment |
public function getHandlers()
{
$handlers = &gplcart_static('search.handlers');
if (isset($handlers)) {
return $handlers;
}
$handlers = $this->getDefaultHandlers();
$this->hook->attach('search.handlers', $handlers, $this);
return $handlers;
} | Returns an array of handlers
@return array | entailment |
public function filterStopwords($string, $language)
{
$prepared = trim(strip_tags($string));
if ($prepared === '') {
return '';
}
$stopwords = array();
$path = GC_DIR_PRIVATE . "/stopwords/$language.txt";
if (is_readable($path)) {
$stopwords... | Filters out stop-words for a given language
@param string $string
@param string $language
@return string | entailment |
protected function parseItem(string $itemName, ServerRequestInterface $request, bool $isSingle = false) : string
{
$item = $this->settings[$itemName];
// we allow callables to be set (along with strings) so we can vary things upon requests.
if (true === is_callable($item)) {
// a... | Parse an item from string/int/callable/array to an expected value.
Generic used function for quite a few possible configuration settings.
@param string $itemName Which settings item are we accessing?.
@param ServerRequestInterface $request What is the request object? (for callables).
@param boolean ... | entailment |
protected function parseAllowCredentials(ServerRequestInterface $request) : bool
{
// read in the current setting
$item = $this->settings['allowCredentials'];
// we allow callables to be set (along with strings) so we can vary things upon requests.
if (true === is_callable($item)) {
... | Parse the allow credentials setting.
@param ServerRequestInterface $request What is the request object? (for callables).
@throws \InvalidArgumentException If the item is missing from settings or is invalid.
@return boolean | entailment |
protected function parseMaxAge(ServerRequestInterface $request) : int
{
$item = $this->settings['maxAge'];
// we allow callables to be set (along with strings) so we can vary things upon requests.
if (true === is_callable($item)) {
// all callbacks are made with the request as th... | Parse the maxAge setting.
@param ServerRequestInterface $request What is the request object? (for callables).
@throws \InvalidArgumentException If the item is missing from settings or is invalid.
@return integer | entailment |
protected function parseOrigin(ServerRequestInterface $request, array &$allowedOrigins = []) : string
{
// read the client provided origin header
$origin = $request->getHeaderLine('origin');
// if it isn't a string or is empty, the return as we will not have a matching
// origin sett... | Parse the origin setting using wildcards where necessary.
Can return * for "all hosts", '' for "no origin/do not allow" or a string/hostname.
@param ServerRequestInterface $request The server request with the origin header.
@param array|callable $allowedOrigins The returned list of allowed origins found... | entailment |
protected function addProtocolPortIfNeeded(string $matched, array $parsed) : string
{
if ('' === $matched || '*' === $matched) {
$return = $matched;
return $return;
}
$protocol = 'https://';
$port = 0;
if (true === isset($parsed['scheme'])) {
... | Returns the protocol if needed.
@param string $matched The matched host.
@param array $parsed The results of parse_url.
@return string | entailment |
protected function parseOriginMatch(string $item, string $origin) :string
{
$this->addLog('Checking configuration origin of "'.$item.'" against user "'.$origin.'"');
if ('' === $item || '*' === $item) {
$this->addLog('Origin is either an empty string or wildcarded star. Returning '.$item... | Check to see if an origin string matches an item (wildcarded or not).
@param string $item The string (possible * wildcarded) to compare against.
@param string $origin The origin to check.
@return string The matching origin (can be *) or '' for empty/not matched | entailment |
public function indexProduct($product_id)
{
$this->setProduct($product_id);
$this->setMetaIndexProduct();
$this->setTitleIndexProduct();
$this->setBreadcrumbIndexProduct();
$this->setHtmlFilterIndexProduct();
$this->setData('product', $this->data_product);
$... | Displays the product page
@param integer $product_id | entailment |
protected function setDataSummaryIndexProduct()
{
$summary = '';
if (!empty($this->data_product['description'])) {
$exploded = $this->explodeText($this->data_product['description']);
$summary = strip_tags($exploded[0]);
}
$this->setData('summary', $summary);... | Sets the description summary on the product page | entailment |
protected function setDataCartFormIndexProduct()
{
$data = array(
'product' => $this->data_product,
'share' => $this->getWidgetShare()
);
$this->setData('cart_form', $this->render('cart/add', $data, true));
} | Sets the "Add to cart" form | entailment |
protected function setDataRatingWidgetIndexProduct()
{
$data = array(
'product' => $this->data_product,
'rating' => $this->rating->getByProduct($this->data_product['product_id'])
);
$this->setData('rating', $this->render('common/rating/static', $data));
} | Sets the product rating widget | entailment |
protected function setDataDescriptionIndexProduct()
{
$description = $this->data_product['description'];
if (!empty($description)) {
$exploded = $this->explodeText($description);
if (!empty($exploded[1])) {
$description = $exploded[1];
}
}... | Sets the product description | entailment |
protected function setDataReviewsIndexProduct()
{
if ($this->config('review_enabled', 1) && !empty($this->data_product['total_reviews'])) {
$pager_options = array(
'key' => 'rep',
'total' => $this->data_product['total_reviews'],
'limit' => (int) $... | Sets the product reviews | entailment |
protected function setDataRecentIndexProduct()
{
$products = $this->getRecentProduct();
if (!empty($products)) {
$pager_options = array(
'key' => 'pwp',
'total' => count($products),
'limit' => $this->config('product_view_pager_limit', 4)
... | Sets the recent products block | entailment |
protected function setDataRelatedIndexProduct()
{
$products = $this->getRelatedProduct();
if (!empty($products)) {
$pager_options = array(
'key' => 'rlp',
'total' => count($products),
'limit' => $this->config('related_pager_limit', 4)
... | Sets the related products | entailment |
protected function prepareReviewsProduct(array &$reviews)
{
if (!empty($reviews)) {
$users = array();
foreach ($reviews as $review) {
$users[] = $review['user_id'];
}
$ratings = null;
if (!empty($users)) {
$rating... | Prepare an array of reviews
@param array $reviews | entailment |
protected function getReviewsProduct(array $limit)
{
$options = array(
'status' => 1,
'limit' => $limit,
'user_status' => 1,
'sort' => 'created',
'order' => 'desc',
'product_id' => $this->data_product['product_id']
);
$... | Returns an array of reviews for the product
@param array $limit
@return array | entailment |
protected function setBreadcrumbIndexProduct()
{
$breadcrumbs = array();
$breadcrumbs[] = array(
'url' => $this->url('/'),
'text' => $this->text('Home')
);
$categories = $this->getCategorytBreadcrumbsProduct($this->data_product['category_id']);
$this... | Sets breadcrumbs on the product page | entailment |
protected function buildCategoryBreadcrumbsProduct($category_id, array &$breadcrumbs)
{
if (!empty($this->data_categories[$category_id]['parents'])) {
$category = $this->data_categories[$category_id];
$parent = reset($category['parents']);
$url = empty($category['alias']... | Builds an array of breadcrumbs containing all parent categories
@param integer $category_id
@param array $breadcrumbs | entailment |
protected function getTotalReviewsProduct(array $product)
{
$options = array(
'status' => 1,
'count' => true,
'user_status' => 1,
'product_id' => $product['product_id']
);
return (int) $this->review->getList($options);
} | Returns a total number of reviews for the product
@param array $product
@return integer | entailment |
protected function setProduct($product_id)
{
$this->data_product = $this->product->get($product_id);
if (empty($this->data_product)) {
$this->outputHttpStatus(404);
}
$this->controlAccessProduct();
$this->prepareProduct($this->data_product);
} | Set a product data
@param integer $product_id | entailment |
protected function controlAccessProduct()
{
if (empty($this->data_product['store_id']) || $this->data_product['store_id'] != $this->store_id) {
$this->outputHttpStatus(403);
}
if (empty($this->data_product['status']) && !$this->access('product')) {
$this->outputHttp... | Controls access to the product | entailment |
protected function prepareProduct(array &$product)
{
$selected = $this->getSelectedCombinationProduct($product);
$this->unshiftSelectedImageProduct($selected, $product);
$this->setItemImages($product, 'product', $this->image);
$this->setItemThumbProduct($product, $this->image);
... | Prepare an array of product data
@param array $product | entailment |
protected function getSelectedCombinationProduct(array $product)
{
$field_value_ids = array();
if (!empty($product['default_field_values'])) {
$field_value_ids = $product['default_field_values'];
}
$selected = $this->sku->selectCombination($product, $field_value_ids);
... | Returns selected product combination
@param array $product
@return array | entailment |
protected function unshiftSelectedImageProduct($selected, &$product)
{
if (isset($selected['combination']['file_id']) && isset($product['images'][$selected['combination']['file_id']])) {
$image = $product['images'][$selected['combination']['file_id']];
unset($product['images'][$selec... | Put default selected image on the first position
@param array $selected
@param array $product
@todo Replace with a trait | entailment |
protected function getRelatedProduct()
{
$options = array(
'status' => 1,
'store_id' => $this->store_id,
'product_id' => $this->data_product['product_id'],
'limit' => array(0, $this->config('related_limit', 12))
);
$product_ids = (array) $this... | Returns an array of related products
@return array | entailment |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.