sentence1 stringlengths 52 3.87M | sentence2 stringlengths 1 47.2k | label stringclasses 1
value |
|---|---|---|
protected function getRecentProduct()
{
$items = $this->product_view->set($this->data_product['product_id'], $this->cart_uid);
$product_ids = array();
foreach ((array) $items as $id => $item) {
if ($item['product_id'] != $this->data_product['product_id']) {
$pro... | Returns an array of recent products
@return array | entailment |
protected function setBackendInstances()
{
$this->job = $this->getInstance('gplcart\\core\\models\\Job');
$this->help = $this->getInstance('gplcart\\core\\models\\Help');
$this->bookmark = $this->getInstance('gplcart\\core\\models\\Bookmark');
} | Sets default class instances | entailment |
protected function setBackendData()
{
$this->data['_job'] = $this->getWidgetJob($this->job);
$this->data['_stores'] = (array) $this->store->getList();
$this->data['_menu'] = $this->getWidgetAdminMenu($this->route);
$this->data['_help'] = $this->help->getByPattern($this->current_route... | Sets default variables for backend templates | entailment |
protected function setCron()
{
$interval = (int) $this->config('cron_interval', 24 * 60 * 60);
if (!empty($interval) && (GC_TIME - $this->config('cron_last_run', 0)) > $interval) {
$url = $this->url('cron', array('key' => $this->config('cron_key', '')));
$this->setJs("\$(fun... | Set up self-executing CRON | entailment |
protected function getPostedAction($message = true)
{
$action = $this->getPosted('action', array(), true, 'array');
if (!empty($action)) {
if (empty($action['name'])) {
$error = $this->text('An error occurred');
} else if (empty($action['items'])) {
... | Returns an array of submitted bulk action
@param bool $message
@return array | entailment |
protected function validateCastValue($val)
{
try {
$val = (string) $val;
} catch (\Exception $e) {
$val = json_encode($val);
}
switch ($this->format()) {
case 'email':
if (strpos($val, '@') === false) {
throw $th... | @param mixed $val
@return string
@throws \frictionlessdata\tableschema\Exceptions\FieldValidationException; | entailment |
public function createService(ServiceLocatorInterface $serviceLocator)
{
$em = new EventManager();
$em->setSharedManager($serviceLocator->get('SharedEventManager'));
return $em;
} | Create an EventManager instance.
Creates a new EventManager instance, seeding it with a shared instance
of SharedEventManager.
@param ServiceLocatorInterface $serviceLocator
@return EventManager | entailment |
public function field(array &$submitted, array $options = array())
{
$this->options = $options;
$this->submitted = &$submitted;
$this->validateField();
$this->validateTitle();
$this->validateWeight();
$this->validateTranslation();
$this->validateTypeField();
... | Performs full field data validation
@param array $submitted
@param array $options
@return boolean|array | entailment |
protected function validateField()
{
$id = $this->getUpdatingId();
if ($id === false) {
return null;
}
$data = $this->field->get($id);
if (empty($data)) {
$this->setErrorUnavailable('update', $this->translation->text('Field'));
return fa... | Validates a field to be updated
@return boolean|null | entailment |
protected function validateWidgetField()
{
$field = 'widget';
if ($this->isExcluded($field)) {
return null;
}
$value = $this->getSubmitted($field);
if ($this->isUpdating() && !isset($value)) {
$this->unsetSubmitted($field);
return null;
... | Validates a field widget type
@return boolean|null | entailment |
public function upload($post, $handler, $path = null)
{
$result = $this->transferred = null;
$this->hook->attach('file.upload.before', $post, $handler, $path, $result, $this);
if (isset($result)) {
return $result;
}
if (!empty($post['error']) || empty($post['tmp... | Uploads a file
@param array $post
@param null|string|false $handler
@param string|null $path
@return mixed | entailment |
public function uploadMultiple($files, $handler, $path = null)
{
$return = array(
'errors' => array(),
'transferred' => array()
);
if (!gplcart_file_multi_upload($files)) {
return $return;
}
foreach ($files as $key => $file) {
... | Multiple file upload
@param array $files
@param null|string|false $handler
@param string|null $path
@return array | entailment |
public function download($url, $handler, $path = null)
{
$result = $this->transferred = null;
$this->hook->attach('file.download.before', $url, $handler, $path, $result, $this);
if (isset($result)) {
return $result;
}
$this->setHandler($handler);
$this->... | Downloads a file from a remote URL
@param string $url
@param null|false|string $handler
@param string|null $path
@return mixed | entailment |
protected function downloadTempFile($url)
{
$temp = $this->file->getTempFile();
$fh = fopen($temp, "w");
if (!is_resource($fh)) {
throw new UnexpectedValueException($this->translation->text('File handle is not a valid resource'));
}
$response = $this->http->req... | Writes a temporary file from a remote file
@param string $url
@return string
@throws UnexpectedValueException | entailment |
protected function finalize($temp, $to, $upload)
{
if (!isset($this->destination)) {
$this->transferred = $temp;
return true;
}
$directory = gplcart_file_absolute(gplcart_file_relative($this->destination));
$pathinfo = $upload ? pathinfo($to) : pathinfo($dire... | Finalize file transfer
@param string $temp
@param string $to
@param bool $upload
@return boolean
@throws UnexpectedValueException | entailment |
protected function prepareFileName($filename, $extension)
{
if ($this->config->get('file_upload_translit', 1)) {
$filename = $this->language->translit($filename, null);
}
$suffix = gplcart_string_random(6);
$clean = gplcart_file_sanitize($filename);
return "$clea... | Sanitize and transliterate a filename
@param string $filename
@param string $extension
@return string | entailment |
public function validate($path, $filename = null)
{
$pathinfo = isset($filename) ? pathinfo($filename) : pathinfo($path);
if (empty($pathinfo['filename'])) {
return $this->translation->text('Unknown filename');
}
if (empty($pathinfo['extension'])) {
return $... | Validate a file
@param string $path
@param null|string $filename
@return boolean|string | entailment |
protected function validateHandler($file, $extension = null)
{
if (empty($this->handler['validator'])) {
throw new UnexpectedValueException($this->translation->text('Unknown handler'));
}
if (!empty($this->handler['extensions']) && isset($extension) && !in_array($extension, $thi... | Validates a file using a validator
@param string $file
@param string|null $extension
@return bool
@throws UnexpectedValueException
@throws RuntimeException | entailment |
public function setHandler($id)
{
if (is_string($id)) {
$this->handler = $this->file->getHandler($id);
} else {
$this->handler = $id;
}
return $this;
} | Sets the current transfer handler
@param mixed $id
- string: load by validator ID
- false: disable validator at all,
- null: detect validator by file extension
@return $this | entailment |
protected function setHandlerByExtension($extension)
{
if (!in_array($extension, $this->file->supportedExtensions())) {
throw new RuntimeException($this->translation->text('Unsupported file extension'));
}
return $this->handler = $this->file->getHandler(".$extension");
} | Find and set handler by a file extension
@param string $extension
@return array
@throws RuntimeException | entailment |
public function listReportLibrary()
{
$this->setTitleListReportLibrary();
$this->setBreadcrumbListReportLibrary();
$this->setFilterListReportLibrary();
$this->setPagerListReportLibrary();
$this->setData('types', $this->getTypesLibrary());
$this->setData('libraries', ... | Displays the library overview page | entailment |
protected function setPagerListReportLibrary()
{
$pager = array(
'query' => $this->query_filter,
'total' => (int) $this->getListReportLibrary(true)
);
return $this->data_limit = $this->setPager($pager);
} | Sets pager
@return array | entailment |
protected function getListReportLibrary($count = false)
{
$list = $this->library->getList();
$this->prepareListLibrary($list);
$allowed = $this->getAllowedFiltersReportLibrary();
$this->filterList($list, $allowed, $this->query_filter);
$this->sortList($list, $allowed, $this... | Returns an array of libraries
@param bool $count
@return array|int | entailment |
protected function prepareListLibrary(array &$list)
{
foreach ($list as &$item) {
$item['status'] = empty($item['errors']);
$item['has_dependencies'] = !empty($item['requires']) || !empty($item['required_by']);
}
} | Prepare an array of libraries
@param array $list | entailment |
protected function getTypesLibrary()
{
$types = array();
foreach (array_keys($this->library->getTypes()) as $id) {
$types[$id] = $this->text(ucfirst($id));
}
return $types;
} | Returns an array of library type names
@return array | entailment |
public function validateDependencies(array &$items, $enabled = false)
{
foreach ($items as &$item) {
$this->validateDependency($item, $items, $enabled);
}
return $items;
} | Validates dependency for an array of items
@param array $items
@param bool $enabled
@return array | entailment |
protected function validateDependency(&$item, $items, $enabled = false)
{
if (empty($item['dependencies'])) {
return null;
}
foreach ($item['dependencies'] as $id => $version) {
if (!isset($items[$id])) {
$item['errors'][] = array('Unknown dependency... | Validates dependency for a single item
@param array $item
@param array $items
@param bool $enabled
@return null | entailment |
public function getVersionComponents($data)
{
$string = str_replace(' ', '', $data);
$matches = array();
preg_match_all('/(^(==|=|!=|<>|>|<|>=|<=)?(?=\d))(.*)/', $string, $matches);
if (empty($matches[3][0])) {
return array();
}
$operator = empty($match... | Extracts an array of components from strings like ">= 1.0.0"
@param string $data
@return array | entailment |
public function getDynamicProperty($name, $default = null)
{
return isset($this->dynamicProperties[$name]) ? $this->dynamicProperties[$name] : $default;
} | Read dynamic property
@param $name
@param null $default
@return mixed|null | entailment |
protected function reset()
{
$this->open = null;
$this->close = null;
$this->model = null;
$this->style = $this->config->get('style');
$this->elements = [];
} | Reset all of the properties | entailment |
public function up()
{
Schema::create('cms_config', function (Blueprint $table) {
$table->bigIncrements('id');
$table->string('option_name')->nullable();
$table->longText('option_value')->nullable();
$table->string('group')->nullable()->default('default');
$table->longText('custom')->nullable();
$... | Run the migrations.
@return void | entailment |
public function set($type = null, $key = null, $value = null)
{
if (isset($type)) {
$this->request[$type]["$key"] = $value;
} else {
$this->request = array(
'get' => $_GET,
'post' => $_POST,
'files' => $_FILES,
'... | Sets a request parameter
@param null|string $type
@param null|string $key
@param mixed $value
@return $this | entailment |
public function base($exclude_langcode = false)
{
$base = GC_BASE;
if ($base !== '/') {
$base .= '/';
}
if (!empty($this->langcode)) {
$suffix = "{$this->langcode}/";
$base .= $suffix;
}
if ($exclude_langcode && !empty($suffix)) ... | Returns the current base path
@param boolean $exclude_langcode
@return string | entailment |
public function post($name = null, $default = null, $filter = true, $type = null)
{
$post = $this->request['post'];
if ($filter !== 'raw') {
gplcart_array_trim($post, (bool) $filter);
}
if (isset($name)) {
$result = gplcart_array_get($post, $name);
... | Returns a data from POST request
@param string|array $name
@param mixed $default
@param bool|string $filter
@param null|string $type
@return mixed | entailment |
public function get($name = null, $default = null, $type = null)
{
$get = $this->request['get'];
gplcart_array_trim($get, true);
if (isset($name)) {
$result = gplcart_array_get($get, $name);
$return = isset($result) ? $result : $default;
} else {
... | Returns a data from GET request
@param string $name
@param mixed $default
@param null|string $type
@return mixed | entailment |
public function file($name = null, $default = null)
{
$files = $this->request['files'];
if (isset($name)) {
return !empty($files[$name]['name']) ? $files[$name] : $default;
}
return $files;
} | Returns a data from FILES request
@param string $name
@param mixed $default
@return mixed | entailment |
public function cookie($name = null, $default = null, $type = null)
{
$cookie = $this->request['cookie'];
gplcart_array_trim($cookie, true);
if (isset($name)) {
$return = isset($cookie[$name]) ? $cookie[$name] : $default;
} else {
$return = $cookie;
}... | Returns a data from COOKIE
@param string $name
@param mixed $default
@param null|string $type
@return mixed | entailment |
public function deleteCookie($name = null)
{
if (isset($name)) {
if (isset($this->request['cookie'][$name])) {
unset($this->request['cookie'][$name]);
return setcookie($name, '', GC_TIME - 3600, '/');
}
return false;
}
fo... | Deletes a cookie
@param string $name
@return boolean | entailment |
public static function bankAppId($bankApp)
{
if ($bankApp == 'swedbank_företag')
throw new UserException('Bank type "swedbank_företag" is no longer valid. Please "swedbank_foretag" instead.', 1);
elseif (!isset(self::$appData[$bankApp]))
throw new UserException('Bank type do... | Bank type settings
@param string $bankApp Bank type
@return array | entailment |
public function update($field_id, array $data)
{
$result = null;
$this->hook->attach('field.update.before', $field_id, $data, $result, $this);
if (isset($result)) {
return (bool) $result;
}
unset($data['type']);
$updated = $this->db->update('field', $da... | Updates a field
@param integer $field_id
@param array $data
@return boolean | entailment |
public function getWidgetTypes()
{
$types = &gplcart_static('field.widget.types');
if (isset($types)) {
return $types;
}
$types = array(
'button' => $this->translation->text('Button'),
'radio' => $this->translation->text('Radio buttons'),
... | Returns an array of widget types
@return array | entailment |
protected function deleteLinkedFieldValues($field_id)
{
$sql = 'DELETE fvt
FROM field_value_translation AS fvt
WHERE fvt.field_value_id IN (SELECT DISTINCT(fv.field_value_id)
FROM field_value AS fv
INNER JOIN field_value AS fv2
... | Delete all field values and their translations related to the field
@param int $field_id
@return bool | entailment |
protected function deleteLinked($field_id)
{
$this->db->delete('field_value', array('field_id' => $field_id));
$this->db->delete('field_translation', array('field_id' => $field_id));
$this->db->delete('product_class_field', array('field_id' => $field_id));
} | Delete all database tables related to the field
@param int $field_id | entailment |
public function getSettings($module_id, $key = null, $default = null)
{
$module = $this->get($module_id);
if (empty($module['settings'])) {
return $default;
}
if (!isset($key)) {
return (array) $module['settings'];
}
$value = gplcart_array_g... | Returns module setting(s)
@param string $module_id
@param string $key
@param mixed $default
@return mixed | entailment |
public function setSettings($module_id, array $settings)
{
$result = false;
if ($this->isInstalled($module_id)) {
$this->update($module_id, array('settings' => $settings));
$result = true;
} else if ($this->isActiveTheme($module_id)) {
$data = array('stat... | Adds/updates settings for a given module
@param string $module_id
@param array $settings
@return boolean | entailment |
public function update($module_id, array $data)
{
$data['modified'] = GC_TIME;
$this->db->update('module', $data, array('module_id' => $module_id));
} | Updates a module
@param string $module_id
@param array $data | entailment |
public function add(array $data)
{
$weight = (int) $this->db->fetchColumn('SELECT COUNT(*) FROM module', array());
$data += array('weight' => $weight + 1);
$data['created'] = $data['modified'] = GC_TIME;
$this->db->insert('module', $data);
} | Adds (installs) a module to the database
@param array $data | entailment |
public function getActiveThemes()
{
$themes = &gplcart_static('module.active.themes');
if (isset($themes)) {
return $themes;
}
$themes = array($this->config->get('theme_backend', 'backend'));
if (!$this->db->isInitialized()) {
return $themes;
... | Returns an array of active theme modules
@return array | entailment |
public function getList()
{
$modules = &gplcart_static('module.list');
if (isset($modules)) {
return $modules;
}
$installed = $this->getInstalled();
$modules = array();
foreach ($this->scan() as $module_id => $info) {
$modules[$module_id] =... | Returns an array of all available modules
@return array | entailment |
public function scan($directory = GC_DIR_MODULE)
{
$modules = array();
foreach (scandir($directory) as $module_id) {
if (!$this->isValidId($module_id)) {
continue;
}
$info = $this->getInfo($module_id);
if (!isset($info['core'])) {
... | Returns an array of scanned module IDs
@param string $directory
@return array | entailment |
protected function prepareInfo($module_id, array $info, array $installed)
{
$info['directory'] = $this->getDirectory($module_id);
$info += array(
'type' => 'module',
'name' => $module_id,
'version' => null
);
// Do not override status set in modu... | Prepare module info
@param string $module_id
@param array $info
@param array $installed
@return array | entailment |
public function get($module_id)
{
$modules = $this->getList();
return empty($modules[$module_id]) ? array() : $modules[$module_id];
} | Returns an array of module data
@param string $module_id
@return array | entailment |
public function getInfo($module_id)
{
static $information = array();
if (isset($information[$module_id])) {
return $information[$module_id];
}
$file = $this->getModuleInfoFile($module_id);
$decoded = null;
if (is_file($file)) {
$decoded = j... | Returns an array of module data from module.json file
@param string $module_id
@todo - remove 'id' key everywhere
@return array | entailment |
public function getInstalled()
{
if (!$this->db->isInitialized()) {
return array();
}
$modules = &gplcart_static('module.installed.list');
if (isset($modules)) {
return $modules;
}
$options = array(
'index' => 'module_id',
... | Returns an array of all installed modules
@return array | entailment |
public function getHooks($class)
{
$hooks = array();
foreach (get_class_methods($class) as $method) {
if (strpos($method, 'hook') === 0) {
$hooks[] = $method;
}
}
return $hooks;
} | Returns an array of class methods which are hooks
@param object|string $class
@return array | entailment |
public function getByType($type, $enabled = false)
{
$modules = $enabled ? $this->getEnabled() : $this->getList();
foreach ($modules as $id => $info) {
if ($type !== $info['type']) {
unset($modules[$id]);
}
}
return $modules;
} | Returns an array of modules by the type
@param string $type
@param boolean $enabled
@return array | entailment |
public function get($product_class_field_id)
{
$result = null;
$this->hook->attach('product.class.field.get.before', $product_class_field_id, $result, $this);
if (isset($result)) {
return $result;
}
$sql = 'SELECT * FROM product_class_field WHERE product_class_f... | Loads a product class field from the database
@param integer $product_class_field_id
@return array | entailment |
public function delete($condition)
{
$result = null;
$this->hook->attach('product.class.field.delete.before', $condition, $result, $this);
if (isset($result)) {
return (bool) $result;
}
if (!is_array($condition)) {
$condition = array('product_class_f... | Deletes a product class field
@param int|array $condition
@return boolean | entailment |
public static function inferDescriptor($descriptor)
{
if (isset($descriptor->type) && $descriptor->type == static::type()) {
return new static($descriptor);
} else {
return false;
}
} | try to create a field object based on the descriptor
by default uses the type attribute
return the created field object or false if the descriptor does not match this field.
@param object $descriptor
@return bool|BaseField | entailment |
public static function infer($val, $descriptor = null, $lenient = false)
{
$field = new static($descriptor);
try {
$field->castValue($val);
} catch (FieldValidationException $e) {
return false;
}
$field->inferProperties($val, $lenient);
return... | try to create a new field object based on the given value.
@param mixed $val
@param null|object $descriptor
@param bool @lenient
@return bool|BaseField | entailment |
final public function castValue($val)
{
if ($this->isEmptyValue($val)) {
if ($this->required()) {
throw $this->getValidationException('field is required', $val);
}
return null;
} else {
$val = $this->validateCastValue($val);
... | @param mixed $val
@return mixed
@throws \frictionlessdata\tableschema\Exceptions\FieldValidationException; | entailment |
public function listSearch()
{
$this->setTermSearch();
$this->setTitleListSearch();
$this->setBreadcrumbListSearch();
$this->setFilterQueryListSearch();
$this->setPagerListSearch();
$this->setResultsSearch();
$this->setDataNavbarListSearch();
$this->se... | Displays the search page | entailment |
protected function setDataNavbarListSearch()
{
$options = array(
'total' => $this->data_limit,
'view' => $this->query_filter['view'],
'quantity' => count($this->data_results),
'sort' => "{$this->query_filter['sort']}-{$this->query_filter['order']}"
);
... | Sets the navbar on the search page | entailment |
protected function setFilterQueryListSearch()
{
$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 search page | entailment |
protected function setPagerListSearch()
{
$options = array(
'status' => 1,
'count' => true,
'store_id' => $this->store_id,
'language' => $this->langcode
);
$pager = array(
'query' => $this->query_filter,
'limit' => $thi... | Sets pager
@return array | entailment |
protected function setTitleListSearch()
{
$title = $this->text('Search');
if ($this->data_term !== '') {
$title = $this->text('Search for «@term»', array('@term' => $this->data_term));
}
$this->setTitle($title);
} | Sets titles on the search page | entailment |
protected function setResultsSearch()
{
$options = array(
'status' => 1,
'entity' => 'product',
'limit' => $this->data_limit,
'language' => $this->langcode,
'store_id' => $this->store_id
);
$options += $this->query_filter;
... | Sets an array of search results | entailment |
public function editLanguage($code = null)
{
$this->setLanguage($code);
$this->setTitleEditLanguage();
$this->setBreadcrumbEditLanguage();
$this->setData('edit', isset($code));
$this->setData('language', $this->data_language);
$this->setData('can_delete', $this->canD... | Displays the language edit form
@param string|null $code | entailment |
protected function canDeleteLanguage()
{
return isset($this->data_language['code'])
&& $this->access('language_delete')
&& $this->language->canDelete($this->data_language['code']);
} | Whether the language can be deleted
@return bool | entailment |
protected function setLanguage($code)
{
$this->data_language = array();
if (!empty($code)) {
$this->data_language = $this->language->get($code);
if (empty($this->data_language)) {
$this->outputHttpStatus(404);
}
}
} | Set a language data
@param string $code | entailment |
protected function submitEditLanguage()
{
if ($this->isPosted('delete')) {
$this->deleteLanguage();
} else if ($this->isPosted('save') && $this->validateLanguage()) {
if (isset($this->data_language['code'])) {
$this->updateLanguage();
} else {
... | Handles a submitted language data | entailment |
protected function deleteLanguage()
{
$this->controlAccess('language_delete');
if ($this->language->delete($this->data_language['code'])) {
$this->redirect('admin/settings/language', $this->text('Language has been deleted'), 'success');
}
$this->redirect('', $this->text... | Deletes a language | entailment |
protected function validateLanguage()
{
$this->setSubmitted('language');
$this->setSubmittedBool('status');
$this->setSubmittedBool('default');
$this->setSubmitted('update', $this->data_language);
$this->validateComponent('language');
return !$this->hasErrors();
... | Validates a language
@return boolean | entailment |
protected function updateLanguage()
{
$this->controlAccess('language_edit');
if ($this->language->update($this->data_language['code'], $this->getSubmitted())) {
$this->redirect('admin/settings/language', $this->text('Language has been updated'), 'success', true);
}
$thi... | Updates a language | entailment |
protected function addLanguage()
{
$this->controlAccess('language_add');
if ($this->language->add($this->getSubmitted())) {
$this->redirect('admin/settings/language', $this->text('Language has been added'), 'success');
}
$this->redirect('', $this->text('Language has not... | Adds a new language | entailment |
protected function setTitleEditLanguage()
{
if (isset($this->data_language['code'])) {
$title = $this->text('Edit %name', array('%name' => $this->data_language['native_name']));
} else {
$title = $this->text('Add language');
}
$this->setTitle($title);
} | Sets titles on the edit language page | entailment |
protected function setBreadcrumbEditLanguage()
{
$breadcrumbs = array();
$breadcrumbs[] = array(
'url' => $this->url('admin'),
'text' => $this->text('Dashboard')
);
$breadcrumbs[] = array(
'url' => $this->url('admin/settings/language'),
... | Sets breadcrumbs on the edit language page | entailment |
public function listLanguage()
{
$this->refreshLanguage();
$this->setTitleListLanguage();
$this->setBreadcrumbListLanguage();
$this->setFilterListLanguage();
$this->setPagerListLanguage();
$this->setData('languages', (array) $this->getListLanguage());
$this->... | Displays the language overview page | entailment |
protected function setPagerListLanguage()
{
$pager = array(
'query' => $this->query_filter,
'total' => (int) $this->getListLanguage(true)
);
return $this->data_limit = $this->setPager($pager);
} | Sets pager
@return array | entailment |
protected function getListLanguage($count = false)
{
$list = $this->language->getList();
$allowed = $this->getAllowedFiltersLanguage();
$this->filterList($list, $allowed, $this->query_filter);
$this->sortList($list, $allowed, $this->query_filter, array('code' => 'asc'));
if... | Returns an array of prepared languages
@param bool $count
@return array|int | entailment |
protected function prepareListLanguage(array &$list)
{
foreach ($list as $id => &$item) {
$item['file_exists'] = is_file($this->translation->getFile($id));
}
} | Prepare an array of languages
@param array $list | entailment |
protected function refreshLanguage()
{
$this->controlToken('refresh');
$code = $this->getQuery('refresh');
if (!empty($code) && $this->access('language_edit') && $this->translation->refresh($code)) {
$this->redirect('', $this->text('Language has been refreshed'), 'success');
... | Removes a cached translation | entailment |
public function sendHeaders()
{
if (!headers_sent()) {
foreach ($this->headers as $header) {
header($header, true);
}
}
$this->headers = array();
return $this;
} | Sends HTTP headers
@return $this | entailment |
public function addHeader($name, $value = null)
{
if (is_numeric($name)) {
$status = $this->getStatus($name);
if (!empty($status)) {
$this->headers[] = "{$_SERVER['SERVER_PROTOCOL']} $name $status";
}
} elseif (isset($value)) {
$this->h... | Adds a header
@param string|int $name
@param string $value
@return $this | entailment |
protected function addOptionalHeaders($options)
{
if (!empty($options['headers'])) {
foreach ((array) $options['headers'] as $header) {
list($name, $value) = array_pad((array) $header, 2, null);
$this->addHeader($name, $value);
}
}
ret... | Adds headers from options
@param array $options
@return $this | entailment |
public function getStatus($status = null)
{
$statuses = array(
100 => 'Continue',
101 => 'Switching Protocols',
200 => 'OK',
201 => 'Created',
202 => 'Accepted',
203 => 'Non-Authoritative Information',
204 => 'No Content',
... | Returns a single status message or an array of HTTP statuses keyed by code
@param null|int $status
@return array|string | entailment |
public function outputHtml($html, $options = array())
{
$this->addHeader('Content-Type', 'text/html; charset=utf-8')
->addOptionalHeaders($options)
->sendHeaders();
echo $html;
exit;
} | Output HTML page
@param string $html
@param array $options | entailment |
public function outputJson($data, $options = array())
{
$this->addHeader('Content-Type', 'application/json')
->addOptionalHeaders($options)
->sendHeaders();
echo gplcart_json_encode($data);
exit;
} | Output JSON string
@param mixed $data
@param array $options | entailment |
public function download($file, $filename = '', $options = array())
{
$readfile = empty($options['text']);
if ($readfile && !is_file($file)) {
return null;
}
if ($readfile && empty($filename)) {
$filename = basename($file);
}
$size = $readfi... | Download a file
@param string $file Absolute path to the file
@param string $filename An alternative filename
@param array $options
@return null | entailment |
public function outputStatus($code, $message = null)
{
$this->addHeader($code)->sendHeaders();
if (isset($message)) {
echo $message;
}
exit;
} | Output an HTTP status and abort script execution
@param int $code
@param null|string $message | entailment |
public function outputError403($show_message = true)
{
$message = $show_message ? $this->getError403() : null;
$this->outputStatus(403, $message);
} | Output 403 error page
@param bool $show_message | entailment |
public function outputError404($show_message = true)
{
$message = $show_message ? $this->getError404() : null;
$this->outputStatus(404, $message);
} | Output 404 error page
@param bool $show_message | entailment |
public function outputError500($show_message = true, $error = '')
{
$message = $show_message ? $this->getError500($error) : null;
$this->outputStatus(500, $message);
} | Output 500 error page
@param bool $show_message
@param string $error | entailment |
public static function url()
{
$regex = ucfirst(\Tiny\Config::$application) . '\\\\' . 'Controller\\\\'; // 需要考虑到route的目录,所以需要用正则
$ctrl = preg_replace('/^(' . $regex . ')/', '', self::$controller);
$ctrl = implode('/', array_map('lcfirst', explode('\\', $ctrl))); // 首字母小写处理
return \... | 当前请求的url | entailment |
public function listImageStyle()
{
$this->clearCacheImageStyle();
$this->setTitleListImageStyle();
$this->setBreadcrumbListImageStyle();
$this->setFilterListImageStyle();
$this->setPagerListImageStyle();
$this->setData('image_styles', (array) $this->getListImageStyle... | Displays the image style overview page | entailment |
protected function setPagerListImageStyle()
{
$pager = array(
'query' => $this->query_filter,
'total' => (int) $this->getListImageStyle(true)
);
return $this->data_limit = $this->setPager($pager);
} | Sets pager
@return array | entailment |
protected function getListImageStyle($count = false)
{
$list = $this->image_style->getList();
$allowed = $this->getAllowedFiltersImageStyle();
$this->filterList($list, $allowed, $this->query_filter);
$this->sortList($list, $allowed, $this->query_filter, array('name' => 'desc'));
... | Returns an array of image styles
@param bool $count
@return array|int | entailment |
protected function prepareListImageStyle(array &$list)
{
foreach ($list as $id => &$item) {
$item['directory_exists'] = is_dir($this->image_style->getDirectory($id));
}
} | Prepare an array of image styles
@param array $list | entailment |
protected function clearCacheImageStyle()
{
$this->controlToken('clear');
$style_id = $this->getQuery('clear');
if (!empty($style_id)) {
if ($this->image_style->clearCache($style_id)) {
$this->redirect('', $this->text('Cache has been deleted'), 'success');
... | Clear cached images | entailment |
public function editImageStyle($style_id = null)
{
$this->setImageStyle($style_id);
$this->setTitleEditImageStyle();
$this->setBreadcrumbEditImageStyle();
$this->setData('imagestyle', $this->data_imagestyle);
$this->setData('actions', $this->getActionsImageStyle());
... | Displays the imagestyle edit form
@param integer|null $style_id | entailment |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.