sentence1 stringlengths 52 3.87M | sentence2 stringlengths 1 47.2k | label stringclasses 1
value |
|---|---|---|
protected function setLanguageProperties()
{
if (!$this->isInternalRoute()) {
$langcode = $this->route->getLangcode();
if (!empty($langcode)) {
$this->langcode = $langcode;
$this->translation->set($langcode, $this->current_route['simple_pattern']);
... | Sets the current language data | entailment |
protected function setUserProperties()
{
if (!$this->isInstall()) {
$this->cart_uid = $this->cart->getUid();
$this->uid = $this->user->getId();
if (!empty($this->uid)) {
$this->current_user = $this->user->get($this->uid);
}
}
... | Sets user/access properties | entailment |
protected function setStoreProperties()
{
$this->current_store = $this->store->get();
if (isset($this->current_store['store_id'])) {
$this->store_id = $this->current_store['store_id'];
$this->is_maintenance = empty($this->current_store['status']) && !$this->access('maintenan... | Sets the current store data | entailment |
public function url($path = '', array $query = array(), $absolute = false, $exclude_lang = false)
{
return $this->url->get($path, $query, $absolute, $exclude_lang);
} | Returns a formatted URL
@param string $path
@param array $query
@param boolean $absolute
@param boolean $exclude_lang
@return string | entailment |
public function lurl($langcode, $path = '', array $query = array())
{
if ($langcode === $this->language->getDefault()) {
$langcode = '';
}
return $this->url->language($langcode, $path, $query);
} | Returns a formatted URL with a language code
@param string $langcode
@param string $path
@param array $query
@return string | entailment |
public function image($path, $imagestyle_id = null, $absolute = false)
{
return $this->image->getUrl($path, $imagestyle_id, $absolute);
} | Returns an image URL
@param string $path
@param integer|null $imagestyle_id
@param boolean $absolute
@return string | entailment |
public function download($file, $filename = '', $options = array())
{
$this->response->download($file, $filename, $options);
} | Download a file
@param string $file
@param string $filename
@param array $options | entailment |
public function jstext($strings, $print = true)
{
$code = '';
foreach ((array) $strings as $string) {
$key = gplcart_json_encode($string);
$text = $this->translation->text($string);
$translation = gplcart_json_encode(array($text));
$code .= "Gplcart.t... | Prints and/or returns JS array with translations
@param string|array $strings
@param bool $print
@return string | entailment |
public function error($key = null, $return_error = null, $return_no_error = '')
{
if (isset($key)) {
$result = gplcart_array_get($this->errors, $key);
} else {
$result = empty($this->errors) ? null : $this->errors;
}
if (isset($result)) {
return i... | Returns a value if an error occurred
@param string|array $key
@param mixed $return_error
@param mixed $return_no_error
@return mixed | entailment |
public function getStore($item = null)
{
if (isset($item)) {
return gplcart_array_get($this->current_store, $item);
}
return $this->current_store;
} | Returns a data of the current store
@param mixed $item
@return mixed | entailment |
public function getUser($item = null)
{
if (isset($item)) {
return gplcart_array_get($this->current_user, $item);
}
return $this->current_user;
} | Returns a data of the current user
@param mixed $item
@return mixed | entailment |
public function getJs($position)
{
$js = $this->asset->get('js', $position);
if (isset($js['js_settings']['asset'])) {
$json = gplcart_json_encode($js['js_settings']['asset']);
$js['js_settings']['asset'] = "Gplcart.settings=$json;";
}
return $js;
} | Returns an array of JS scripts
@param string $position
@return array | entailment |
public function date($timestamp = null, $full = true)
{
if (!isset($timestamp)) {
$timestamp = GC_TIME;
}
if ($full) {
$format = $this->config->get('date_full_format', 'd.m.Y H:i');
} else {
$format = $this->config->get('date_short_format', 'd.m.y... | Formats a local time/date
@param null|integer $timestamp
@param bool $full
@return string | entailment |
public function format($format, array $arguments = array(), $glue = '<br>')
{
if (is_array($format)) {
$format = implode($glue, gplcart_array_flatten($format));
}
return vsprintf($format, $arguments);
} | Return a formatted string
@param string|array $format
@param array $arguments
@param string $glue
@return string | entailment |
public function configTheme($key = null, $default = null)
{
if (!isset($key)) {
return $this->theme_settings;
}
$value = gplcart_array_get($this->theme_settings, $key);
return isset($value) ? $value : $default;
} | Returns a setting from the current theme settings
@param mixed $key
@param mixed $default
@return mixed | entailment |
public function filter($string, $filter = null)
{
if (!isset($filter)) {
$filter = $this->current_filter;
}
$delimiter = $this->config('teaser_delimiter', '<!--teaser-->');
$string = str_replace($delimiter, htmlspecialchars($delimiter), $string);
return $this->fi... | Clean up HTML string using defined HTML filters
@param string $string
@param mixed $filter
@return string | entailment |
protected function explodeText($text)
{
$delimiter = $this->config('teaser_delimiter', '<!--teaser-->');
$text = str_replace(htmlspecialchars($delimiter), $delimiter, $text);
$parts = array_filter(array_map('trim', explode($delimiter, $text, 2)));
return array_pad($parts, 2, '');
... | Explodes a text by teaser and full text
@param string $text
@return array | entailment |
public function attributes(array $attributes)
{
foreach ($attributes as $attribute => &$data) {
$data = implode(' ', (array) $data);
$data = $attribute . '="' . htmlspecialchars($data, ENT_QUOTES, 'UTF-8') . '"';
}
return empty($attributes) ? '' : ' ' . implode(' ', ... | Formats tag attributes
@param array $attributes
@return string | entailment |
public function teaser($text, $enable_filter = true, $filter_id = null)
{
$summary = '';
if ($text !== '') {
$parts = $this->explodeText($text);
$summary = reset($parts);
}
if ($summary !== '' && $enable_filter) {
$summary = $this->filter($summar... | Returns a string from a text before the teaser delimiter
@param string $text
@param boolean $enable_filter
@param mixed $filter_id
@return string | entailment |
public function path($pattern = null)
{
if (isset($pattern)) {
return preg_match("~$pattern~i", $this->path) === 1;
}
return $this->path;
} | If $path is set - returns TRUE if the path pattern mathes the current URL path
If $path is not set or NULL - returns the current URL path
@param null|string $pattern
@return string|bool | entailment |
public function render($file, $data = array(), $merge = true, $default = '')
{
settype($data, 'array');
$templates = $this->getTemplateFiles($file);
if ($merge) {
$data = array_merge($data, $this->getDefaultData());
}
$rendered = null;
$this->hook->attac... | Renders a template
@param string $file
@param array $data
@param boolean $merge
@param string $default
@return string | entailment |
protected function getTemplateFiles($file)
{
$module_id = $this->theme;
if (strpos($file, '|') !== false) {
list($module_id, $file) = explode('|', $file, 2);
} else if (gplcart_path_is_absolute($file)) {
$template = substr($file, 0, (strrpos($file, '.')));
... | Returns an array of full template paths without file extension
@param string $file
@return array | entailment |
public function isPosted($key = null)
{
if (isset($key)) {
$value = $this->request->post($key, null);
return isset($value);
}
return $this->server->requestMethod() === 'POST';
} | Whether the key exists in POST query or current query is POST type
@param string|null $key
@return boolean | entailment |
public function getPosted($name, $default = null, $filter = true, $type = 'string')
{
return $this->request->post($name, $default, $filter, $type);
} | Returns a data from POST query
@param string $name
@param mixed $default
@param bool|string $filter
@param string $type
@return mixed | entailment |
public function isQuery($key = null)
{
$value = $this->request->get($key);
return !empty($value);
} | Whether a key is presented in the GET query
@param string|null $key
@return boolean | entailment |
public function getQuery($key = null, $default = null, $type = 'string')
{
return $this->request->get($key, $default, $type);
} | Returns a GET query
@param string|null $key
@param mixed $default
@param string|null $type
@return mixed | entailment |
protected function setThemeProperties()
{
$this->theme_frontend = $this->config('theme', 'frontend');
$this->theme_backend = $this->config('theme_backend', 'backend');
if ($this->is_backend) {
$this->theme = $this->theme_backend;
} elseif ($this->is_install) {
... | Sets theme properties | entailment |
public function getModuleSettings($module_id, $key = null, $default = null)
{
return $this->module->getSettings($module_id, $key, $default);
} | Returns all or a single module setting
@param string $module_id
@param null|string $key
@param mixed $default
@return mixed | entailment |
public function setData($key, $value)
{
gplcart_array_set($this->data, $key, $value);
return $this->data;
} | Sets a template variable
@param string|array $key
@param mixed $value
@return array | entailment |
public function setError($key, $value)
{
if (isset($key)) {
gplcart_array_set($this->errors, $key, $value);
} else {
$this->errors = (array) $value;
}
return $this->errors;
} | Sets an error
@param null|string|array $key
@param mixed $value
@return array | entailment |
public function setSubmitted($key = null, $value = null, $filter = true)
{
if (!isset($key)) {
if (isset($value)) {
return $this->submitted = (array) $value;
}
$this->submitted = (array) $this->request->post(null, array(), $filter, 'array');
... | Sets an array of submitted data
@param string|array|null $key
@param mixed $value
@param boolean|string $filter
@return array | entailment |
public function filterSubmitted(array $allowed)
{
$this->submitted = array_intersect_key($this->submitted, array_flip($allowed));
return $this->submitted;
} | Limit an array of submitted data to the allowed keys
@param array $allowed
@return array | entailment |
public function setSubmittedBool($key)
{
$bool = (bool) $this->getSubmitted($key);
$this->setSubmitted($key, $bool);
return $bool;
} | Converts a submitted value to boolean
@param string|array $key
@return boolean | entailment |
public function setSubmittedArray($key)
{
$value = $this->getSubmitted($key);
if (isset($value) && is_string($value)) {
$array = gplcart_string_explode_multiline($value);
$this->setSubmitted($key, $array);
return $array;
}
return array();
} | Converts a submitted value to array using multiline delimiter
@param string|array $key
@return array | entailment |
public function getSubmitted($key = null, $default = null)
{
if (isset($key)) {
$result = gplcart_array_get($this->submitted, $key);
return isset($result) ? $result : $default;
}
return $this->submitted;
} | Returns a submitted value
@param string|array $key
@param mixed $default
@return mixed | entailment |
public function getData($key = null, $default = null)
{
if (!isset($key)) {
return $this->data;
}
$result = gplcart_array_get($this->data, $key);
return isset($result) ? $result : $default;
} | Returns a value from an array of template variables
@param string|array|null $key
@param mixed
@return mixed | entailment |
protected function controlCommonAccess()
{
if (!$this->isInstall()) {
if (!empty($this->uid)) {
$this->controlAccessCredentials();
}
$this->controlCsrf();
$this->controlAccessUpload();
$this->controlAccessRestrictedArea();
... | Controls user access to the current page | entailment |
protected function controlAccessCredentials()
{
if (empty($this->current_user['hash']) || empty($this->current_user['status'])) {
$this->session->delete();
$this->url->redirect('login');
}
if (!gplcart_string_equals($this->current_user['hash'], $this->user->getSessio... | Controls the current user credentials, such as status, role, password hash... | entailment |
protected function controlAccessRestrictedArea()
{
if (($this->is_backend || $this->url->isAccount()) && empty($this->uid)) {
$this->url->redirect('login', array('target' => $this->path));
}
} | Controls access to restricted areas | entailment |
protected function controlCsrf()
{
if ($this->isPosted()
&& !$this->isInternalRoute()
&& (!isset($this->current_route['token']) || !empty($this->current_route['token']))) {
$token = $this->request->post('token', '', false, 'string');
if (!gplcart_string_equa... | Prevent Cross-Site Request Forgery (CSRF) | entailment |
protected function controlToken($key = null)
{
$control = isset($key) ? isset($this->query[$key]) : !empty($this->query);
if ($control && (empty($this->query['token']) || !gplcart_string_equals($this->token, $this->query['token']))) {
$this->response->outputError403();
}
} | Controls token in the URL query
@param null|string $key | entailment |
protected function controlAccessAdmin()
{
if ($this->is_backend && !$this->isSuperadmin()) {
if (empty($this->current_user['role_status']) || !$this->access('admin')) {
$this->redirect('/', $this->text('No access'), 'warning');
}
if (isset($this->current... | Controls access to admin pages | entailment |
protected function controlAccessAccount()
{
$account_id = $this->url->getAccountId();
if ($account_id === false || $this->uid === $account_id) {
return null;
}
if ($this->isSuperadmin($account_id) && !$this->isSuperadmin()) {
$this->setHttpStatus(403);
... | Controls access to account pages | entailment |
protected function controlMaintenanceMode()
{
$allowed_path = $this->is_install
|| $this->is_backend
|| in_array($this->path, array('login', 'logout', 'forgot'));
if ($this->is_maintenance && !$allowed_path) {
if (!$this->isFront()) {
$this->redi... | Switches the site to maintenance mode | entailment |
public function redirect($url = '', $message = '', $severity = 'info', $exclude_lang = false)
{
$this->setMessage($message, $severity, true);
$parsed = parse_url($url);
$query = array();
if (isset($parsed['query'])) {
parse_str($parsed['query'], $query);
}
... | Redirects to a new location
@param string $url
@param string $message
@param string $severity
@param boolean $exclude_lang | entailment |
public function setTitle($title, $both = true)
{
$this->data['_head_title'] = strip_tags($title);
if ($both && !isset($this->data['_page_title'])) {
$this->setPageTitle($title);
}
} | Sets page <title> tag
@param string $title
@param boolean $both | entailment |
protected function setJsTranslation(array $scripts)
{
if (!empty($this->langcode) && !is_file($this->translation->getContextJsFile())) {
foreach ($scripts as $key => $script) {
if (strpos($key, 'system/modules/') === 0
&& strpos($key, '/vendor/') === false
... | Extracts translatable strings from JS files and creates translation
@param array $scripts | entailment |
protected function prepareOutput(&$templates, array &$options)
{
if (!empty($this->http_status)) {
$title = (string) $this->response->getStatus($this->http_status);
$this->setTitle($title, false);
$templates = "common/status/{$this->http_status}";
$options['he... | Prepare output
@param mixed $templates
@param array $options | entailment |
protected function prepareDataOutput()
{
$this->data['_css'] = $this->getCss();
foreach (array('top', 'bottom') as $position) {
$this->data["_js_$position"] = $this->getJs($position);
$this->setJsTranslation($this->data["_js_$position"]);
}
$this->hook->atta... | Prepare template data variables before output | entailment |
protected function renderOutput($templates)
{
$html = '';
if (!$this->isInternalRoute()) {
if (!is_array($templates)) {
$templates = array('region_content' => (string) $templates);
}
$templates = array_merge($this->templates, $templates);
... | Renders all templates before sending them to a browser
@param array|string $templates
@return string | entailment |
protected function renderRegion($region, $template)
{
if (!isset($this->data[$region])) {
return $this->render($template, $this->data);
}
$this->data[$region] = (array) $this->data[$region];
gplcart_array_sort($this->data[$region]);
$items = array();
fo... | Renders a region
@param string $region
@param string $template
@return string | entailment |
final public function output($templates = null, array $options = array())
{
if (empty($templates)) {
$templates = $this->templates;
}
$this->prepareDataOutput();
$this->prepareOutput($templates, $options);
$this->response->outputHtml($this->renderOutput($template... | Outputs rendered page
@param null|array|string $templates
@param array $options | entailment |
public function setRegion($region, $item)
{
if (is_array($item)) {
$template = array_shift($item);
$data = $item ? reset($item) : array();
$content = $this->render($template, $data);
} else {
$content = trim($item);
}
if ($content !== ... | Adds an item to a region
@param string $region
@param string|array $item Expected array format:
first item - template, second - variables for $this->render() | entailment |
public function renderPhpTemplate($template, array $data)
{
extract($data, EXTR_SKIP);
unset($data); // Kill duplicates
ob_start();
include $template;
return ob_get_clean();
} | Renders PHP templates
@param string $template
@param array $data
@return string | entailment |
protected function setDefaultJs()
{
foreach ($this->getDefaultData() as $key => $value) {
$this->setJsSettings(ltrim($key, '_'), $value, 60);
}
$json = gplcart_json_encode($this->translation->loadJsTranslation());
$this->setJs("Gplcart.translations=$json;");
} | Adds default JS | entailment |
public function setJsSettings($key, $data, $weight = null)
{
$asset = array(
'type' => 'js',
'weight' => $weight,
'key' => 'js_settings',
'merge' => 'js_settings',
'asset' => array($key => $data)
);
$this->asset->set($asset);
} | Adds JSON string with JS settings
@param string $key
@param mixed $data
@param integer|null $weight | entailment |
protected function getDefaultData()
{
$data = array();
$data['_uid'] = $this->uid;
$data['_uri'] = $this->uri;
$data['_path'] = $this->path;
$data['_base'] = $this->base;
$data['_host'] = $this->host;
$data['_token'] = $this->token;
$data['_query'] = ... | Returns global template variables
@return array | entailment |
protected function setDefaultData()
{
$this->data = array_merge($this->data, $this->getDefaultData());
$this->data['_version'] = gplcart_version();
$this->data['_user'] = $this->current_user;
$this->data['_store'] = $this->current_store;
$this->data['_language'] = $this->cur... | Sets default template variables | entailment |
protected function setClasses()
{
$classes = array();
if (isset($this->current_route['pattern'])) {
$pattern = $this->current_route['pattern'] ? $this->current_route['pattern'] : 'front';
foreach (explode('/', $pattern) as $part) {
if (ctype_alpha($part)) {
... | Sets an array of body CSS classes | entailment |
public function setJs($script, array $options = array())
{
$options['type'] = 'js';
$options['asset'] = $script;
return $this->asset->set($options);
} | Adds a JS on the page
@param string $script
@param array $options
@return bool|array | entailment |
public function setCss($css, array $options = array())
{
$options['asset'] = $css;
$options['type'] = 'css';
return $this->asset->set($options);
} | Adds a CSS on the page
@param string $css
@param array $options
@return bool|array | entailment |
public function addAssetLibrary($library_id, array $options = array())
{
$added = array();
foreach ($this->library->getFiles($library_id) as $file) {
$extension = pathinfo($file, PATHINFO_EXTENSION);
if ($extension === 'js') {
$result = $this->setJs($file, ... | Adds single or multiple asset libraries
@param string|array $library_id
@param array $options
@return array | entailment |
public function setMeta($content)
{
$key = '_meta_tags';
if (!isset($this->data[$key])) {
$this->data[$key] = array();
}
$this->data[$key][] = $content;
} | Sets a meta tag on the page
@param array $content | entailment |
public function setBreadcrumb(array $breadcrumb)
{
$key = '_breadcrumbs';
if (!isset($this->data[$key])) {
$this->data[$key] = array();
}
$this->data[$key][] = $breadcrumb;
} | Sets a single page breadcrumb
@param array $breadcrumb | entailment |
protected function setMetaEntity(array $data)
{
if (!empty($data['meta_title'])) {
$this->setTitle($data['meta_title'], false);
}
if (!empty($data['meta_description'])) {
$this->setMeta(array('name' => 'description', 'content' => $data['meta_description']));
... | Set meta tags on entity page
@param array $data | entailment |
public function setHtmlFilter($data)
{
$role_id = isset($data['role_id']) ? $data['role_id'] : 0;
$this->current_filter = $this->filter->getByRole($role_id);
} | Sets HTML filter globally
@param array $data | entailment |
public function hasErrors($message = true)
{
if (empty($this->errors)) {
return false;
}
if ($message) {
$this->setMessage($this->text('One or more errors occurred'), 'danger');
}
if (isset($this->post_key)) {
$this->setData($this->post_k... | Returns true if an error occurred and pass back to template the submitted data
@param boolean $message
@return boolean | entailment |
public function validateComponent($handler_id, array $options = array())
{
$result = $this->validator->run($handler_id, $this->submitted, $options);
if ($result === true) {
return array();
}
return $this->errors = (array) $result;
} | Validates a submitted set of elements
@param string $handler_id
@param array $options
@return array | entailment |
protected function validateElement($field, $handler_id, $arguments = array())
{
if (is_array($field)) {
$label = reset($field);
$field = key($field);
}
$options = array(
'field' => $field,
'arguments' => (array) $arguments,
'label'... | Validates a single element
@param string|array $field
@param string $handler_id
@param string|array $arguments
@return boolean | entailment |
public function setMessage($messages, $severity = 'info', $once = false)
{
if (!empty($messages)) {
foreach (gplcart_array_flatten((array) $messages) as $message) {
if ($once) {
$this->session->setMessage($message, $severity);
} else {
... | Sets a message or an array of messages
@param string|array $messages
@param string $severity
@param bool $once | entailment |
public function setFilter(array $allowed = array(), $query = null)
{
if (!isset($query)) {
$query = $this->getFilterQuery();
}
$this->setFilterData($allowed, $query);
$this->query_filter = array_filter($query, 'is_string');
} | Sets filter variables to the data array
@param array $allowed
@param array $query | entailment |
public function getFilterQuery(array $default = array(), $allowed = array())
{
$query = $this->query;
foreach ($query as $key => $value) {
if (!is_string($value)) {
continue;
}
if ($key === 'sort' && strpos($value, '-') !== false) {
... | Returns an array of prepared GET values used for filtering and sorting
@param array $default
@param array $allowed
@return array | entailment |
public function setPager(array $options)
{
$pager = $this->getPager($options);
$this->data['_pager'] = $pager['rendered'];
return $pager['limit'];
} | Sets the pager
@param array $options
@return array | entailment |
public function getPager(array $options = array())
{
$options += array(
'query' => $this->getFilterQuery(),
'limit' => $this->config('list_limit', 20)
);
return array(
'rendered' => $this->getWidgetPager($options),
'limit' => $this->pager->get... | Returns a rendered pager
@param array $options
@return array | entailment |
public function getWidgetPager(array $options)
{
$options += array(
'key' => 'p',
'page' => 1,
'template' => 'common/pager',
'query' => $this->getQuery(null, array(), 'array')
);
if (isset($options['query'][$options['key']])) {
$op... | Returns the rendered pager
@param array $options
@return string | entailment |
public function routeHttp()
{
if ($this->config->isInitialized() || $this->url->isInstall()) {
$this->route->process();
} else {
$this->url->redirect('install');
}
} | Routes HTTP requests | entailment |
public function init(Request $request, $postType, $id, $method, $customId = '')
{
// Lets validate if the post type exists and if so, continue.
$postTypeModel = $this->getPostType($postType);
if(!$postTypeModel){
$errorMessages = 'You are not authorized to do this.';
return $this->abort($err... | Display a single post | entailment |
public function get($zone_id)
{
$result = null;
$this->hook->attach('zone.get.before', $zone_id, $result, $this);
if (isset($result)) {
return $result;
}
$result = $this->db->fetch('SELECT * FROM zone WHERE zone_id=?', array($zone_id));
$this->hook->atta... | Loads a zone from the database
@param int $zone_id
@return array | entailment |
public static function setLogin($user, $isAdmin = false, $expires = null)
{
if($expires === false)
$expires = time() + 31536000;
Cookie::set('user', $user, array('expires' => $expires));
Cookie::set('is_admin', $isAdmin, array('expires' => $expires));
} | 设置自动登录 | entailment |
public static function hasPurview($controller = null, $method = null)
{
if($controller && $method){
$ctr = ucfirst(Config::$application) . '\\' . Config::$controller['0'] . '\\' . ucfirst($controller);
}else{
$ctr = Request::$controller;
$explode = explode('\\', $... | 判断是否有权限 | entailment |
public function validator(Factory $factory)
{
if (!$this->shouldBeValidated()) {
return $factory->make([], []);
}
$rules = app()->call([$this, 'rules']);
return $factory->make(
$this->all(), $rules, $this->messages(), $this->attributes()
);
... | Injects validator with rules and data if validation is required
@param Factory $factory
@return Validator | entailment |
protected function execute(InputInterface $input, OutputInterface $output)
{
$targetArg = rtrim($input->getArgument('target'), '/');
if (!is_dir($targetArg)) {
throw new \InvalidArgumentException(sprintf('The target directory "%s" does not exist.', $input->getArgument('target')));
... | {@inheritdoc}
@throws \InvalidArgumentException When the target directory does not exist or symlink cannot be used | entailment |
public function category(array &$submitted, array $options = array())
{
$this->options = $options;
$this->submitted = &$submitted;
$this->validateCategory();
$this->validateWeight();
$this->validateBool('status');
$this->validateTitle();
$this->validateMetaTi... | Performs full category data validation
@param array $submitted
@param array $options
@return boolean|array | entailment |
protected function validateCategory()
{
$id = $this->getUpdatingId();
if ($id === false) {
return null;
}
$data = $this->category->get($id);
if (empty($data)) {
$this->setErrorUnavailable('update', $this->translation->text('Category'));
... | Validates a category to be updated
@return boolean|null | entailment |
protected function validateParentCategory()
{
$field = 'parent_id';
$value = $this->getSubmitted($field);
if (empty($value)) {
return null;
}
$label = $this->translation->text('Parent category');
if (!is_numeric($value)) {
$this->setErrorNum... | Validates parent category group ID
@return boolean|null | entailment |
protected function validateDescriptionCategory()
{
$fields = array(
'description_1' => $this->translation->text('First description'),
'description_2' => $this->translation->text('Second description')
);
$errors = 0;
foreach ($fields as $field => $label) {
... | Validates first and second description
@return boolean | entailment |
public function userLogOut()
{
$result = $this->user_action->logout();
$this->redirect($result['redirect'], $result['message'], $result['severity']);
} | Logs out a user | entailment |
public function createService(ServiceLocatorInterface $serviceLocator)
{
$pluginManagerClass = static::PLUGIN_MANAGER_CLASS;
/* @var $plugins \Zend\ServiceManager\AbstractPluginManager */
$plugins = new $pluginManagerClass();
$plugins->setServiceLocator($serviceLocator);
ret... | Create and return a plugin manager.
Classes that extend this should provide a valid class for
the PLUGIN_MANGER_CLASS constant.
@param ServiceLocatorInterface $serviceLocator
@return \Zend\ServiceManager\AbstractPluginManager | entailment |
public function listFile()
{
$this->downloadFile();
$this->actionListFile();
$this->setTitleListFile();
$this->setBreadcrumbListFile();
$this->setFilterListFile();
$this->setPagerListFile();
$this->setData('files', $this->getListFile());
$this->setDat... | Displays the file overview page | entailment |
protected function downloadFile()
{
$file_id = $this->getQuery('download');
if (!empty($file_id)) {
$file = $this->file->get($file_id);
$this->download(gplcart_file_absolute($file['path']));
}
} | Downloads a file | entailment |
protected function actionListFile()
{
list($selected, $action) = $this->getPostedAction();
$disk = $db = 0;
foreach ($selected as $file_id) {
if ($action === 'delete' && $this->access('file_delete')) {
$this->file->deleteAll($file_id, $db, $disk);
}
... | Applies an action to the selected files | entailment |
protected function setPagerListFile()
{
$conditions = $this->query_filter;
$conditions['count'] = true;
$pager = array(
'query' => $this->query_filter,
'total' => (int) $this->file->getList($conditions)
);
return $this->data_limit = $this->setPager($... | Set pager
@return array | entailment |
protected function getListFile()
{
$conditions = $this->query_filter;
$conditions['limit'] = $this->data_limit;
$list = (array) $this->file->getList($conditions);
$this->prepareListFile($list);
return $list;
} | Returns an array of files
@return array | entailment |
protected function prepareListFile(array &$list)
{
foreach ($list as &$item) {
$path = strval(str_replace("\0", "", $item['path']));
$item['url'] = '';
if ($path && file_exists(GC_DIR_FILE . '/' . $path)) {
$item['url'] = $this->url->file($item['path']);... | Prepare an array of files
@param array $list | entailment |
public function editFile($file_id = null)
{
$this->downloadFile();
$this->setFile($file_id);
$this->setTitleEditFile();
$this->setBreadcrumbEditFile();
$this->controlAccessEditFile();
$this->setData('file', $this->data_file);
$this->setData('can_delete', $thi... | Displays the file edit page
@param null|integer $file_id | entailment |
protected function canDeleteFile()
{
return isset($this->data_file['file_id'])
&& $this->access('file_delete')
&& $this->file->canDelete($this->data_file['file_id']);
} | Whether the file can be deleted
@return bool | entailment |
protected function setFile($file_id)
{
$this->data_file = array();
if (is_numeric($file_id)) {
$conditions = array(
'language' => 'und',
'file_id' => $file_id
);
$this->data_file = $this->file->get($conditions);
if (... | Sets a file data
@param integer $file_id | entailment |
protected function submitEditFile()
{
if ($this->isPosted('delete') && isset($this->data_file['file_id'])) {
$this->deleteFile();
} else if ($this->isPosted('save') && $this->validateEditFile()) {
if (isset($this->data_file['file_id'])) {
$this->updateFile();
... | Saves an array of submitted values | entailment |
protected function deleteFile()
{
$this->controlAccess('file_delete');
if ($this->file->deleteAll($this->data_file['file_id'])) {
$this->redirect('admin/content/file', $this->text('File has been deleted from database and disk'), 'success');
}
// Redirect in any case as ... | Deletes a file from the database an disk | entailment |
protected function validateEditFile()
{
$this->setSubmitted('file');
$this->setSubmitted('update', $this->data_file);
$this->validateComponent('file');
return !$this->hasErrors();
} | Validates a submitted data | entailment |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.