sentence1
stringlengths
52
3.87M
sentence2
stringlengths
1
47.2k
label
stringclasses
1 value
protected function updateFile() { $this->controlAccess('file_edit'); if ($this->file->update($this->data_file['file_id'], $this->getSubmitted())) { $this->redirect('admin/content/file', $this->text('File has been updated'), 'success'); } $this->redirect('', $this->text(...
Updates a file
entailment
protected function addFile() { $this->controlAccess('file_add'); if ($this->file->add($this->getSubmitted())) { $this->redirect('admin/content/file', $this->text('File has been added'), 'success'); } $this->redirect('', $this->text('File has not been added'), 'warning')...
Adds a new file
entailment
protected function setTitleEditFile() { if (isset($this->data_file['file_id'])) { $title = $this->text('Edit %name', array('%name' => $this->data_file['title'])); } else { $title = $this->text('Add file'); } $this->setTitle($title); }
Sets titles on the edit file page
entailment
protected function setBreadcrumbEditFile() { $breadcrumbs = array(); $breadcrumbs[] = array( 'url' => $this->url('admin'), 'text' => $this->text('Dashboard') ); $breadcrumbs[] = array( 'url' => $this->url('admin/content/file'), 'text'...
Sets breadcrumbs on the edit file page
entailment
public function init() { $this->setLangcode(); $this->path = $this->url->path(); $this->db = $this->config->getDb(); }
Initialize route
entailment
public function getList() { $routes = &gplcart_static('route.list'); if (isset($routes)) { return $routes; } $routes = (array) gplcart_config_get(GC_FILE_CONFIG_ROUTE); $this->hook->attach('route.list', $routes, $this); return $routes; }
Returns an array of all available routes @return array
entailment
public function process() { try { $this->processAlias(); $this->processRoute(); $this->output404(); } catch (Exception $ex) { trigger_error($ex->getMessage()); $this->response->outputError500(); } }
Processes the route
entailment
protected function setLangcode() { $languages = $this->config->get('languages', array()); if (!empty($languages)) { $segments = $this->url->getSegments(true); $default = $this->config->get('language', 'en'); $found = !empty($languages[$segments[0]]['status']) |...
Sets language
entailment
public function processAlias($path = null) { if (!isset($path)) { $path = $this->path; } if ($this->db->isInitialized() && $this->config->get('alias', true)) { foreach (array_keys($this->findAlias($path)) as $pattern) { $this->callAliasController($pat...
Finds an alias for a path @param string|null $path
entailment
protected function findAlias($path) { $routes = $this->getList(); $alias = $this->db->fetch('SELECT entity, entity_id FROM alias WHERE alias=?', array($path)); foreach ($routes as $pattern => $route) { if (isset($route['status']) && empty($route['status'])) { un...
Try to find and call an alias handler using the URL path @param string $path @return array An array of active routes which don't support aliases
entailment
public function processRoute() { foreach ($this->getList() as $pattern => $route) { if (isset($route['status']) && empty($route['status'])) { continue; } $arguments = array(); if (gplcart_path_match($this->path, $pattern, $arguments)) { ...
Find an appropriate controller for the URL
entailment
public function aliasCallback($pattern, $path, $alias) { if (!empty($alias['entity']) && !empty($alias['entity_id'])) { if (strpos($pattern, "{$alias['entity']}/") === 0) { $this->callController($pattern, array($alias['entity_id'])); } } if (!isset($a...
Route alias callback @param string $pattern @param string $path @param array $alias
entailment
public function callController($route, array $arguments = array()) { $route = $this->set($route, $arguments); $callback = Handler::get($route, null, 'controller'); if (!$callback[0] instanceof Controller) { throw new LogicException('Controller must be instance of \gplcart\core\C...
Call a controller for the route @param string|array $route @param array $arguments @throws LogicException
entailment
public function callAliasController($pattern, $path, $alias) { $route = $this->set($pattern, array($pattern, $path, $alias)); Handler::call($route, null, 'alias', $route['arguments']); }
Calls an alias controller for the route @param string $pattern @param string $path @param array|null $alias
entailment
public function set($route, array $arguments = array()) { if (!is_array($route)) { $pattern = $route; $list = $this->getList(); if (empty($list[$pattern])) { throw new OutOfBoundsException("Unknown route pattern $pattern"); } $ro...
Sets a route @param array|string $route @param array $arguments @return array @throws OutOfBoundsException
entailment
public function used(array $condition, array $data) { if (!isset($data['rule']['used'])) { return false; } return $this->compare($data['rule']['used'], $condition['value'], $condition['operator']); }
Returns true if the "number of usage" condition is met @param array $condition @param array $data @return boolean
entailment
public function configureServiceManager(ServiceManager $serviceManager) { parent::configureServiceManager($serviceManager); /* * Parameters: * * 'session.class' => 'Symfony\Component\HttpFoundation\Session\Session', * 'session.storage.class' ...
{@inheritdoc}
entailment
public function shippingMethod(array $values) { $existing = array_filter($values, function ($method_id) { return (bool) $this->shipping->get($method_id); }); if (count($values) != count($existing)) { return $this->translation->text('@name is unavailable', array( ...
Validates the shipping method condition @param array $values @return boolean|string
entailment
public function paymentMethod(array $values) { $existing = array_filter($values, function ($method_id) { return (bool) $this->payment->get($method_id); }); if (count($values) != count($existing)) { return $this->translation->text('@name is unavailable', array( ...
Validates the payment method condition @param array $values @return boolean|string
entailment
public function editProductBundle($product_id) { $this->setProductProductBundle($product_id); $this->setTitleEditProductBundle(); $this->setBreadcrumbEditProductBundle(); $this->setData('product', $this->data_product); $this->submitEditProductBundle(); $this->setDat...
Displays the edit product bundle page @param integer $product_id
entailment
protected function setProductProductBundle($product_id) { $this->data_product = $this->product->get($product_id); if (empty($this->data_product)) { $this->outputHttpStatus(404); } $this->prepareProductBundle($this->data_product); }
Sets the product data @param integer $product_id
entailment
protected function validateEditProductBundle() { $this->setSubmitted('product'); $this->setSubmitted('product_id', $this->data_product['product_id']); $this->validateComponent('product_bundle'); return !$this->hasErrors(); }
Validates a product bundle data @return bool
entailment
protected function saveProductBundle() { $this->controlAccess('product_bundle_edit'); $product_id = $this->getSubmitted('product_id'); $products = $this->getSubmitted('products', array()); if ($this->product_bundle->set($product_id, $products)) { $this->redirect('admin/...
Saves a product bundle
entailment
protected function setBreadcrumbEditProductBundle() { $breadcrumbs = array(); $breadcrumbs[] = array( 'url' => $this->url('admin'), 'text' => $this->text('Dashboard') ); $breadcrumbs[] = array( 'text' => $this->text('Products'), 'url'...
Sets breadcrumbs on the edit product bundle page
entailment
public function build(array $items) { $this->graph = array(); // Reset all previous data foreach ($items as $id => $item) { $this->graph[$id]['edges'] = array(); if (empty($item['dependencies'])) { continue; } foreach ($item['depend...
Determines which components require and are required by each component @param array $items @return array
entailment
public function sort(array $ids, array $list) { $data = array(); foreach ($ids as $key) { if (!isset($list[$key])) { return array(); } $data[$key] = $list[$key]['sort']; foreach (array_keys($list[$key]['requires']) as $dependency) { ...
Sort a list of IDs according to their dependencies Dependent items always go last @param array $ids @param array $list @return array
entailment
protected function search() { $this->state = array( 'last_visit_order' => array(), 'components' => array(), ); foreach ($this->graph as $start => $data) { $this->searchComponent($start); } $component_weights = array(); foreach ($...
Performs a depth-first search and sort on a directed acyclic graph
entailment
protected function searchComponent($start) { if (!isset($this->component)) { $this->component = $start; } if (isset($this->graph[$start]['paths'])) { return null; } $this->graph[$start]['paths'] = array(); $this->graph[$start]['component'] = ...
Performs a depth-first search on a graph @param string $start @return null
entailment
public function addBookmark() { $this->setBookmark(); $this->controlAccess('bookmark_add'); $options = array( 'user_id' => $this->uid, 'title' => $this->data_title ); $this->bookmark->set($this->data_path, $options); $this->redirect($this->da...
Page callback to add a bookmark
entailment
public function deleteBookmark() { $this->setBookmark(); $this->controlAccess('bookmark_delete'); $this->bookmark->delete(array('path' => $this->data_path)); $this->redirect($this->data_target); }
Page callback to delete a bookmark
entailment
protected function setBookmark() { $this->data_path = $this->getQuery('path'); $this->data_title = $this->getQuery('title'); $this->data_target = $this->getQuery('target', $this->data_path); if (empty($this->data_path)) { $this->outputHttpStatus(403); } }
Sets bookmark data
entailment
public function listBookmark() { $this->setTitleListBookmark(); $this->setBreadcrumbListBookmark(); $this->setFilterListBookmark(); $this->setPagerlListBookmark(); $this->setData('bookmarks', $this->getListBookmark()); $this->outputListBookmark(); }
Displays the bookmark overview page
entailment
protected function setPagerlListBookmark() { $options = $this->query_filter; $options['count'] = true; $total = (int) $this->bookmark->getList($options); $pager = array( 'total' => $total, 'query' => $this->query_filter ); return $this->data_...
Sets pager @return array
entailment
protected function getListBookmark() { $conditions = $this->query_filter; $conditions['user_id'] = $this->uid; $conditions['limit'] = $this->data_limit; return (array) $this->bookmark->getList($conditions); }
Returns an array of bookmarks @return array
entailment
public function listReportPayment() { $this->setTitleListReportPayment(); $this->setBreadcrumbListReportPayment(); $this->setFilterListReportPayment(); $this->setPagerListReportPayment(); $this->setData('methods', (array) $this->getListReportPayment()); $this->output...
Displays the payment methods overview page
entailment
protected function setPagerListReportPayment() { $pager = array( 'query' => $this->query_filter, 'total' => (int) $this->getListReportPayment(true) ); return $this->data_limit = $this->setPager($pager); }
Sets pager @return array
entailment
protected function getListReportPayment($count = false) { $list = $this->payment->getList(); $allowed = $this->getAllowedFiltersReportPayment(); $this->filterList($list, $allowed, $this->query_filter); $this->sortList($list, $allowed, $this->query_filter, array('id' => 'asc')); ...
Returns an array of payment methods @param bool $count @return array|int
entailment
protected function updateNumPages() { $this->pages = ($this->limit == 0) ? 0 : (int) ceil($this->total / $this->limit); return $this; }
Updates the current number of pages @return $this
entailment
public function getPages() { $pages = array(); if ($this->pages <= 1) { return array(); } if ($this->pages <= $this->limit_pages) { for ($i = 1; $i <= $this->pages; $i++) { $pages[] = $this->createPage($i, $i == $this->current); }...
Get an array of paginated page data @return array
entailment
public function getCurrentPageLastItem() { $first = $this->getCurrentPageFirstItem(); if (empty($first)) { return 0; } $last = $first + $this->limit - 1; if ($last > $this->total) { return $this->total; } return $last; }
Returns the last item for the current page @return integer
entailment
public function getCurrentPageFirstItem() { $first = ($this->current - 1) * $this->limit; if ($first > $this->total) { return 0; } return $first; }
Returns the first item for the current page @return integer
entailment
public function build(array $data = array()) { $data += array( 'page' => 1, 'limit' => 0, 'total' => 0, 'mini' => false, 'max_pages' => 10, 'query' => array() ); $this->setPage($data['page']) ->setPerPage($d...
Set up pager from an array of parameters @param array $data @return $this
entailment
public function load($file, $type = null) { $path = $this->locator->locate($file); $this->setCurrentDir(dirname($path)); $config = require $path; // not an array if (!is_array($config)) { throw new \InvalidArgumentException(sprintf('The file "%s" must contain a ...
Loads a PHP file. @param mixed $file The resource @param string $type The resource type @throws \InvalidArgumentException @return array Array with configuration
entailment
public function editSettings() { $this->setTitleEditSettings(); $this->setBreadcrumbEditSettings(); $this->setData('settings', $this->getSettings()); $this->setData('timezones', gplcart_timezones()); $this->submitEditSettings(); $this->outputEditSettings(); }
Displays the edit settings page
entailment
protected function validateEditSettings() { $this->setSubmitted('settings'); if (!$this->getSubmitted('cron_key')) { $this->setSubmitted('cron_key', gplcart_string_random()); } return !$this->hasErrors(); }
Validates submitted settings @return bool
entailment
protected function updateSettings() { $this->controlAccess('settings_edit'); foreach ($this->getSubmitted() as $key => $value) { $this->config->set($key, $value); } $this->redirect('', $this->text('Settings have been updated'), 'success'); }
Updates settings
entailment
public function get($code) { $result = null; $this->hook->attach('language.get.before', $code, $result, $this); if (isset($result)) { return (array) $result; } $list = $this->getList(); $result = isset($list[$code]) ? $list[$code] : array(); $th...
Returns a language @param string $code @return array
entailment
public function getList(array $options = array()) { $options += array( 'enabled' => false, 'in_database' => false ); $languages = &gplcart_static(gplcart_array_hash(array('language.list' => $options))); if (isset($languages)) { return $languages;...
Returns an array of languages @param array $options @return array
entailment
public function add(array $data) { $result = null; $this->hook->attach('language.add.before', $data, $result, $this); if (isset($result)) { return (bool) $result; } if (!empty($data['default'])) { $this->setDefault($data['code']); } ...
Adds a language @param array $data @return boolean
entailment
public function translit($string, $language) { $result = null; $this->hook->attach('language.translit.before', $string, $language, $result, $this); if (isset($result)) { return $result; } $result = $string; if (function_exists('transliterator_transliter...
Transliterate a string @param string $string @param string $language @return string
entailment
public function getIso($code = null) { $data = (array) gplcart_config_get(GC_FILE_CONFIG_LANGUAGE); if (isset($code)) { return isset($data[$code]) ? (array) $data[$code] : array(); } return $data; }
Returns an array of common languages with their English and native names @param null|string $code @return array
entailment
public static function parseName($name, $type = 0) { if ($type) { return ucfirst(preg_replace_callback('/_([a-zA-Z])/', function ($match) { return strtoupper($match[1]); }, $name)); } else { return strtolower(trim(preg_replace('/[A-Z]/', '_\\0', $n...
驼峰与下划线的相互转化
entailment
public static function attributes(array $attributes = NULL) { if (!$attributes) return; asort($attributes); $h = ''; foreach ($attributes as $k => $v) { $h .= " $k=\"" . self::h($v) . '"'; } return $h; }
Compiles an array of HTML attributes into an attribute string and HTML escape it to prevent malformed (but not malicious) data. @param array $attributes the tag's attribute list @return string
entailment
public static function tag($tag, $text = '', array $attributes = NULL) { $autoClose = array('input', 'br', 'hr', 'img', 'col', 'area', 'base', 'link', 'meta', 'frame', 'param'); return "<$tag" . self::attributes($attributes) . (in_array($tag, $autoClose) ? ' />' : ">$text</$tag>"); }
Create an HTML tag @param string $tag the tag name @param string $text the text to insert between the tags @param array $attributes of additional tag settings @return string
entailment
public static function select($name, array $options, $selected = NULL, array $attributes = NULL) { $h = ''; foreach ($options as $k => $v) { $a = array('value' => $k); // Is this element one of the selected options? if ($selected AND in_array($k, (array)$selected...
Auto creates a form select dropdown from the options given . @param string $name the select element name @param array $options the select options @param mixed $selected the selected options(s) @param array $attributes of additional tag settings @return string
entailment
public function editUserRegister() { $this->controlAccessUserRegister(); $this->setTitleEditUserRegister(); $this->setBreadcrumbEditUserRegister(); $this->submitUserRegister(); $this->setData('password_limit', $this->user->getPasswordLength()); $this->outputEditUserR...
Displays the user registration page
entailment
protected function userRegister() { $result = $this->user_action->register($this->getSubmitted()); $this->redirect($result['redirect'], $result['message'], $result['severity']); }
Registers a user
entailment
protected function validateUserRegister() { $this->setSubmitted('user', null, false); $this->filterSubmitted(array('email', 'password', 'name')); $this->setSubmitted('store_id', $this->store_id); $this->validateComponent('user'); return !$this->hasErrors(); }
Validates an array of submitted data during registration @return bool
entailment
public function cart(array &$submitted, array $options = array()) { $this->options = $options; $this->submitted = &$submitted; $this->validateCart(); $this->validateStoreId(); $this->validateProductCart(); $this->validateSkuCart(); $this->validateUserCartId()...
Performs full cart data validation @param array $submitted @param array $options @return boolean|array
entailment
protected function validateCart() { $id = $this->getUpdatingId(); if ($id === false) { return null; } $data = $this->cart->get($id); if (empty($data)) { $this->setErrorUnavailable('update', $this->translation->text('Cart')); return false...
Validates a cart item to be updated @return boolean
entailment
protected function validateSkuCart() { if ($this->isError('store_id')) { return null; } $field = 'sku'; $value = $this->getSubmitted($field); if (!isset($value)) { return null; } $label = $this->translation->text('SKU'); if ...
Validates a cart item SKU @return boolean|null
entailment
protected function validateOrderCart() { $field = 'order_id'; $value = $this->getSubmitted($field); if (empty($value)) { return null; } $label = $this->translation->text('Order'); if (!is_numeric($value)) { $this->setErrorNumeric($field, $la...
Validates an order ID @return boolean|null
entailment
protected function validateQuantityCart() { $field = 'quantity'; if ($this->isExcluded($field)) { return null; } $value = $this->getSubmitted($field); if (!isset($value)) { if ($this->isUpdating()) { return null; } ...
Validates cart item quantity @return boolean|null
entailment
protected function validateLimitCart() { if ($this->isError()) { return null; } $admin = $this->getSubmitted('admin'); $product = $this->getSubmitted('product'); if (!empty($admin) || empty($product)) { return null; } $sku = $this->g...
Validates cart limits @return boolean|null
entailment
protected function validateOptionsCart() { $product = $this->getSubmitted('product'); if (empty($product) || $this->isError()) { return null; } $options = array_filter((array) $this->getSubmitted('options')); if (empty($options)) { $this->setSubmitt...
Validates products cart options @return boolean|null
entailment
public function address(array &$submitted, array $options = array()) { $this->options = $options; $this->submitted = &$submitted; $this->validateAddress(); $this->validateCountryAddress(); $this->validateStateAddress(); $this->validateCityAddress(); $this->v...
Performs full address data validation @param array $submitted @param array $options @return array|boolean
entailment
protected function validateAddress() { $id = $this->getUpdatingId(); if ($id === false) { return null; } $data = $this->address->get($id); if (empty($data)) { $this->setErrorUnavailable('update', $this->translation->text('Address')); ret...
Validates an address to be updated @return boolean
entailment
protected function validateUserIdAddress() { $field = 'user_id'; if ($this->isExcluded($field)) { return null; } $value = $this->getSubmitted($field); if ($this->isUpdating() && !isset($value)) { $this->unsetSubmitted($field); return nul...
Validates a user Id @return boolean
entailment
protected function validateCountryAddress() { $field = 'country'; $value = $this->getSubmitted($field); if (!isset($value)) { $this->unsetSubmitted($field); return null; } $country = $this->country->get($value); $label = $this->translation->t...
Validates a country code @return boolean|null
entailment
protected function validateStateAddress() { $field = 'state_id'; $value = $this->getSubmitted($field); if (!isset($value)) { $this->unsetSubmitted($field); return null; } $label = $this->translation->text('Country state'); $format = $this->ge...
Validates a country state @return boolean|null
entailment
protected function validateCityAddress() { $field = 'city_id'; if ($this->isExcluded($field) || $this->isError('country')) { return null; } $value = $this->getSubmitted($field); if ($this->isUpdating() && !isset($value)) { $this->unsetSubmitted($fie...
Validates a city @return boolean|null
entailment
protected function validateTypeAddress() { $field = 'type'; $value = $this->getSubmitted($field); if (!isset($value)) { $this->unsetSubmitted($field); return null; } if (!in_array($value, $this->address->getTypes())) { $this->setErrorUnav...
Validates an address type @return boolean|null
entailment
protected function validateFieldsAddress() { $this->validateFieldAddress('address_1'); $this->validateFieldAddress('address_2'); $this->validateFieldAddress('phone'); $this->validateFieldAddress('middle_name'); $this->validateFieldAddress('last_name'); $this->validate...
Validates address fields
entailment
protected function validateFieldAddress($field) { if ($this->isExcluded($field) || $this->isError('country')) { return null; } $value = $this->getSubmitted($field); if ($this->isUpdating() && !isset($value)) { $this->unsetSubmitted($field); retur...
Validates an address field associated with the country format @param string $field @return bool|null
entailment
protected function getCountryFormatAddress() { $updating = $this->getUpdating(); if (isset($updating['country_format'])) { return $updating['country_format']; } $field = 'country'; $code = $this->getSubmitted($field); if (!isset($code)) { re...
Returns the current country format @return array
entailment
public function indexPage($page_id) { $this->setPage($page_id); $this->setTitleIndexPage(); $this->setBreadcrumbIndexPage(); $this->setHtmlFilterIndexPage(); $this->setMetaIndexPage(); $this->setData('page', $this->data_page); $this->setDataImagesIndexPage();...
Displays a page @param integer $page_id
entailment
protected function setPage($page_id) { $this->data_page = $this->page->get($page_id); if (empty($this->data_page)) { $this->outputHttpStatus(404); } $this->controlAccessPage(); $this->preparePage($this->data_page); }
Sets a page data @param integer $page_id
entailment
protected function controlAccessPage() { if (empty($this->data_page['status']) && !$this->access('page')) { $this->outputHttpStatus(403); } if ($this->data_page['store_id'] != $this->store_id) { $this->outputHttpStatus(404); } }
Controls access to the page
entailment
protected function setDataImagesIndexPage() { $options = array( 'imagestyle' => $this->configTheme('image_style_page', 5) ); $this->setItemThumb($this->data_page, $this->image, $options); $this->setData('images', $this->render('page/images', array('page' => $this->data_p...
Sets the rendered images on the page
entailment
public function matchRequest(Request $request) { try { $parameters = parent::matchRequest($request); $this->matchedRouteRequest = $request; return $parameters; } catch (\Exception $e) { throw $e; } }
@param Request $request @throws \Exception
entailment
public function login(array $data, $check_password = true) { $result = array(); $this->hook->attach('user.login.before', $data, $check_password, $result, $this); if (!empty($result)) { return (array) $result; } if (empty($data['email'])) { return $th...
Logs in a user @param array $data @param bool $check_password @return array
entailment
public function register(array $data) { $result = array(); $this->hook->attach('user.register.before', $data, $result, $this); if (!empty($result)) { return (array) $result; } $data['status'] = $this->config->get('user_registration_status', true); $data[...
Registers a user @param array $data @return array
entailment
public function logout() { $result = array(); $user = $this->user->get($this->user->getId()); $this->hook->attach('user.logout.before', $user, $result, $this); if (!empty($result)) { return (array) $result; } $this->session->delete(); $result = ...
Logs out the current user @return array
entailment
public function resetPassword(array $data) { $result = array(); $this->hook->attach('user.reset.password.before', $data, $result, $this); if (!empty($result)) { return (array) $result; } if (empty($data['user']['user_id'])) { return $this->getResultE...
Performs reset password operation @param array $data @return array
entailment
protected function resetPasswordStart(array $data) { $data['user']['data']['reset_password'] = array( 'token' => gplcart_string_random(), 'expires' => GC_TIME + $this->user->getResetPasswordLifespan(), ); $this->user->update($data['user']['user_id'], array('data' => ...
Start the password reset operation @param array $data @return array
entailment
protected function resetPasswordFinish(array $data) { $data['user']['password'] = $data['password']; unset($data['user']['data']['reset_password']); $this->user->update($data['user']['user_id'], $data['user']); $this->mail->set('user_changed_password', array($data['user'])); ...
Finish the password reset operation @param array $data @return array
entailment
public function emailRegistration(array $data) { if ($this->config->get('user_registration_email_customer', true)) { $this->mail->set('user_registered_customer', array($data)); } if ($this->config->get('user_registration_email_admin', true)) { $this->mail->set('user_...
Sends e-mails on registration event @param array $data
entailment
protected function getLoginRedirect(array $user) { $redirect = "account/{$user['user_id']}"; if (!empty($user['role_redirect'])) { $redirect = $user['role_redirect']; } if ($this->user->isSuperadmin($user['user_id'])) { $redirect = 'admin'; } ...
Returns a redirect path for the user @param array $user @return string
entailment
public static function string2dateTime($string, \DateTimeZone $zone = null) { if (!$zone) { $zone = new \DateTimeZone('UTC'); } $dt = new \DateTime('now', $zone); $dt->setTimestamp(self::string2timestamp($string)); return $dt; }
@param string $string @param \DateTimeZone $zone @return \DateTime
entailment
public static function string2timestamp($string) { $matches = array(); if (!preg_match( '/^(\\d\\d\\d\\d)-(\\d\\d)-(\\d\\d)T(\\d\\d):(\\d\\d):(\\d\\d)(?:\\.\\d+)?Z$/D', $string, $matches ) ) { throw new \InvalidArgumentE...
@param $string @return int
entailment
public function init($file = GC_FILE_CONFIG_COMPILED) { $this->initialized = false; $this->setErrorHandlers(); if (is_file($file)) { $this->setConfig($file); $this->setErrorLevel(); $this->setKey(); $this->setLogger(); date_defaul...
Initialize the system configuration @param string $file @return bool
entailment
protected function setErrorLevel() { switch ($this->get('error_level', 2)) { case 0: error_reporting(0); break; case 1: error_reporting(E_ERROR | E_WARNING | E_PARSE | E_NOTICE); break; case 2: ...
Set PHP error reporting level
entailment
protected function setErrorHandlers() { register_shutdown_function(array($this->logger, 'shutdownHandler')); set_exception_handler(array($this->logger, 'exceptionHandler')); set_error_handler(array($this->logger, 'errorHandler'), error_reporting()); }
Sets PHP error handlers
entailment
protected function setLogger() { $this->logger->setDb($this->db) ->printError($this->get('error_print', false)) ->logBacktrace($this->get('error_log_backtrace', true)) ->printBacktrace($this->get('error_print_backtrace', false)) ->errorToException($this->get('...
Sets logger
entailment
public function setConfig($config) { if (is_array($config)) { $this->config = $config; } else { $this->config = (array) gplcart_config_get((string) $config); $this->setDb($this->config['database']); $this->config = array_merge($this->config, $this->sel...
Set array of configuration options @param array|string $config Either a file path or an array of configuration options
entailment
public function setKey($key = null) { if (empty($key)) { $key = $this->get('private_key'); if (empty($key)) { $key = gplcart_string_random(); $this->set('private_key', $key); } } else { $this->set('private_key', $key)...
Sets the private key @param null|string $key @return string
entailment
public function get($key = null, $default = null) { if (!isset($key)) { return $this->config; } if (array_key_exists($key, $this->config)) { return $this->config[$key]; } return $default; }
Returns a value from an array of configuration options @param string $key @param mixed $default @return mixed
entailment
public function set($key, $value) { if (!$this->db->isInitialized() || empty($key) || !isset($value)) { return false; } $this->reset($key); $serialized = 0; if (is_array($value)) { $value = serialize($value); $serialized = 1; } ...
Saves a configuration value in the database @param string $key @param mixed $value @return boolean
entailment
public function select($name = null, $default = null) { if (!$this->db->isInitialized()) { return isset($name) ? $default : array(); } $conditions = array(); $sql = 'SELECT * FROM settings'; if (isset($name)) { $conditions[] = $name; $sq...
Select all or a single setting from the database @param null|string $name @param mixed $default @return mixed
entailment
public function get($key) { $parts = explode('.', $key); $offset = $this->config; foreach($parts as $part) { if(!isset($offset[$part])) return null; $offset = $offset[$part]; } return $offset; }
Get configuration by key @param $key @return mixed
entailment