sentence1
stringlengths
52
3.87M
sentence2
stringlengths
1
47.2k
label
stringclasses
1 value
public function canDeleteImageStyle() { return isset($this->data_imagestyle['imagestyle_id']) && $this->access('image_style_delete') && $this->image_style->canDelete($this->data_imagestyle['imagestyle_id']); }
Whether an image style can be deleted @return bool
entailment
protected function setImageStyle($style_id) { $this->data_imagestyle = array(); if (is_numeric($style_id)) { $this->data_imagestyle = $this->image_style->get($style_id); if (empty($this->data_imagestyle)) { $this->outputHttpStatus(404); } ...
Sets an image style data @param integer $style_id
entailment
protected function submitEditImageStyle() { if ($this->isPosted('delete')) { $this->deleteImageStyle(); } else if ($this->isPosted('save') && $this->validateEditImageStyle()) { if (isset($this->data_imagestyle['imagestyle_id'])) { $this->updateImageStyle(); ...
Handles a submitted data
entailment
protected function deleteImageStyle() { if ($this->canDeleteImageStyle() && $this->image_style->delete($this->data_imagestyle['imagestyle_id'])) { $this->image_style->clearCache($this->data_imagestyle['imagestyle_id']); $this->redirect('admin/settings/imagestyle', $this->text('Image ...
Deletes an image style
entailment
protected function validateEditImageStyle() { $this->setSubmitted('imagestyle'); $this->setSubmittedBool('status'); $this->setSubmittedArray('actions'); $this->setSubmitted('update', $this->data_imagestyle); $this->validateComponent('image_style'); return !$this->ha...
Validates a submitted image style @return bool
entailment
protected function updateImageStyle() { $this->controlAccess('image_style_edit'); if ($this->image_style->update($this->data_imagestyle['imagestyle_id'], $this->getSubmitted())) { $this->image_style->clearCache($this->data_imagestyle['imagestyle_id']); $this->redirect('admin...
Updates an image style
entailment
protected function addImageStyle() { $this->controlAccess('image_style_add'); if ($this->image_style->add($this->getSubmitted())) { $this->redirect('admin/settings/imagestyle', $this->text('Image style has been added'), 'success'); } $this->redirect('', $this->text('Ima...
Adds a new image style
entailment
protected function setDataEditImageStyle() { $actions = $this->getData('imagestyle.actions'); if (!$this->isError()) { gplcart_array_sort($actions); } $modified = array(); foreach ($actions as $action_id => $info) { if (is_string($info)) { ...
Sets template data on the edit image style page
entailment
protected function setTitleEditImageStyle() { if (isset($this->data_imagestyle['imagestyle_id'])) { $title = $this->text('Edit %name', array('%name' => $this->data_imagestyle['name'])); } else { $title = $this->text('Add image style'); } $this->setTitle($titl...
Sets title on the edit image style page
entailment
protected function setBreadcrumbEditImageStyle() { $breadcrumbs = array(); $breadcrumbs[] = array( 'url' => $this->url('admin'), 'text' => $this->text('Dashboard') ); $breadcrumbs[] = array( 'url' => $this->url('admin/settings/imagestyle'), ...
Sets breadcrumbs on the edit image style page
entailment
public function parseRow($line, $continueLine = null) { // RFC4180 - Each record is located on a separate line, delimited by a line break (CRLF) // Tabular Data - The line terminator character MUST be LF or CRLF $line = rtrim($line, "\r\n"); // RFC4180 - Within the header ...
Parses the csv row according to the csv dialect. Returns an array of fields parsed form the line In case of line termination inside an enclosed field, the last field will contain a ContinueEnclosedField object @param $line string @return array @throws DataSourceException @throws \Exception
entailment
private function _renderDefault($mod) { if(isset($mod['value'])){ return $mod['value']; }elseif($this->data && isset($this->data->$mod['name'])){ return $this->data->$mod['name']; }elseif(isset($mod['default'])) return $mod['default']; else ...
获取默认值 value的优先级最高,其次是id的model值,最后是default
entailment
public function editUserLogin() { $this->controlAccessUserLogin(); $this->setTitleEditUserLogin(); $this->setBreadcrumbEditUserLogin(); $this->submitUserLogin(); $this->outputEditUserLogin(); }
Displays the login page
entailment
protected function loginUser() { $user = $this->getSubmitted(); $result = $this->user_action->login($user); if (empty($result['user'])) { $this->setData('user', $user); $this->setMessage($result['message'], $result['severity']); } else { $this->re...
Log in a user
entailment
protected function validateUserLogin() { $this->setSubmitted('user', null, false); $this->filterSubmitted(array('email', 'password')); $this->validateComponent('user_login'); return !$this->hasErrors(); }
Validates submitted login credentials @return bool
entailment
public function indexOrder($order_id) { $this->setOrder($order_id); $this->submitIndexOrder(); $this->setTitleIndexOrder(); $this->setBreadcrumbIndexOrder(); $this->setData('order', $this->data_order); $this->setDataPanelLogsIndexOrder(); $this->setDataPanel...
Displays the order overview page @param integer $order_id
entailment
protected function submitIndexOrder() { if ($this->isPosted('delete')) { $this->deleteOrder(); } else if ($this->isPosted('status') && $this->validateIndexOrder()) { $this->updateStatusOrder(); } else if ($this->isPosted('clone') && $this->validateIndexOrder()) { ...
Handles a submitted order
entailment
protected function deleteOrder() { $this->controlAccess('order_delete'); if ($this->order->delete($this->data_order['order_id'])) { $this->redirect('admin/sale/order', $this->text('Order has been deleted'), 'success'); } $this->redirect('', $this->text('Order has not be...
Deletes an order
entailment
protected function updateStatusOrder() { $this->controlAccess('order_edit'); $submitted = array('status' => $this->getSubmitted('status')); if ($this->order->update($this->data_order['order_id'], $submitted)) { $submitted['notify'] = $this->setNotificationUpdateOrder($this->dat...
Update an order status
entailment
protected function logUpdateStatusOrder(array $submitted) { if ($this->data_order['status'] != $submitted['status']) { $log = array( 'user_id' => $this->uid, 'order_id' => $this->data_order['order_id'], 'text' => $this->text('Update order status t...
Log the status updated event @param array $submitted
entailment
protected function setNotificationUpdateOrder($order_id) { if (!$this->config('order_update_notify_customer', 1)) { return static::NOTIFICATION_DISABLED; } $order = $this->order->get($order_id); if ($this->order_action->notifyUpdated($order) === true) { retur...
Notify a customer when an order has been updated @param integer $order_id @return integer
entailment
protected function cloneOrder() { $this->controlAccess('order_edit'); $this->controlAccess('order_add'); $update = array('status' => $this->order->getStatusCanceled()); if ($this->createTempCartOrder() && $this->order->update($this->data_order['order_id'], $update)) { $...
Copy an order
entailment
protected function createTempCartOrder() { // Purge cart of the current user // It will be populated with the items from the cloning order $this->cart->delete(array('user_id' => $this->uid)); $added = $count = 0; // Populate admin's cart foreach ($this->data_order['...
Creates temporary cart for the current admin @return bool
entailment
protected function getTotalLogOrder() { $conditions = array( 'count' => true, 'order_id' => $this->data_order['order_id'] ); return (int) $this->order_history->getList($conditions); }
Returns a total log records found for the order Used for pager @return integer
entailment
protected function getListLogOrder(array $limit) { $conditions = array( 'limit' => $limit, 'order_id' => $this->data_order['order_id'] ); return (array) $this->order_history->getList($conditions); }
Returns an array of log records for the order @param array $limit @return array
entailment
protected function setBreadcrumbIndexOrder() { $breadcrumbs = array(); $breadcrumbs[] = array( 'url' => $this->url('admin'), 'text' => $this->text('Dashboard') ); $breadcrumbs[] = array( 'text' => $this->text('Orders'), 'url' => $this...
Sets bread crumbs on the order overview page
entailment
protected function setOrder($order_id) { $this->data_order = array(); if (is_numeric($order_id)) { $this->data_order = $this->order->get($order_id); if (empty($this->data_order)) { $this->outputHttpStatus(404); } $this->order_histor...
Returns an order @param integer $order_id
entailment
protected function prepareOrder(array &$order) { $this->setItemTotalFormatted($order, $this->price); $this->setItemOrderAddress($order, $this->address); $this->setItemOrderStoreName($order, $this->store); $this->setItemOrderStatusName($order, $this->order); $this->setItemOrde...
Prepare an array of order data @param array $order
entailment
protected function setDataPanelLogsIndexOrder() { $pager_options = array( 'total' => $this->getTotalLogOrder(), 'limit' => $this->config('order_log_limit', 5) ); $pager = $this->getPager($pager_options); $data = array( 'order' => $this->data_orde...
Adds the order logs panel on the order overview page
entailment
protected function setDataPanelSummaryIndexOrder() { $data = array( 'order' => $this->data_order, 'statuses' => $this->order->getStatuses() ); $this->setData('pane_summary', $this->render('sale/order/panes/summary', $data)); }
Adds the summary panel on the order overview page
entailment
protected function setDataPanelComponentsIndexOrder() { if (!empty($this->data_order['data']['components'])) { $this->setItemOrderCartComponent($this->data_order, $this->price); $this->setItemOrderPriceRuleComponent($this->data_order, $this->price, $this->pricerule); $th...
Adds the order components panel on the order overview page
entailment
public function listOrder() { $this->actionListOrder(); $this->setTitleListOrder(); $this->setBreadcrumbListOrder(); $this->setData('statuses', $this->order->getStatuses()); $this->setFilterListOrder(); $this->setPagerListOrder(); $this->setData('orders', $th...
Displays the order list page
entailment
protected function setPagerListOrder() { $conditions = $this->query_filter; $conditions['count'] = true; $pager = array( 'query' => $this->query_filter, 'total' => (int) $this->order->getList($conditions) ); return $this->data_limit = $this->setPager...
Sets pager @return array
entailment
protected function actionListOrder() { list($selected, $action, $value) = $this->getPostedAction(); $deleted = $updated = 0; $failed_notifications = array(); foreach ($selected as $id) { if ($action === 'status' && $this->access('order_edit')) { $updat...
Applies an action to the selected orders
entailment
protected function getListOrder() { $conditions = $this->query_filter; $conditions['limit'] = $this->data_limit; $list = (array) $this->order->getList($conditions); $this->prepareListOrder($list); return $list; }
Returns an array of orders @return array
entailment
protected function prepareListOrder(array &$list) { foreach ($list as &$item) { $this->setItemOrderNew($item, $this->order_history); $this->setItemTotalFormatted($item, $this->price); } }
Prepare an array of orders @param array $list
entailment
protected function loadSymfonyRoutes($path) { if ($this->routes === null) { $loader = new YamlFileLoader(new FileLocator(array(dirname($path)))); $loader->setDefaults(array('_module' => $this->getName())); $routesCollection = $loader->load(pathinfo($path, PATHINFO_FILENA...
Load up our routes. @param string $path @return \Symfony\Component\Routing\RouteCollection
entailment
protected function loadLaravelRoutes($path) { $router = (new LaravelRoutesLoader( new LaravelRouter(new Dispatcher()) ))->load($path); $router->setModuleName($this->getName()); return $router; }
@param string $path @throws \Exception when the included routes file doesn't return an AuraRouter back @return AuraRouter
entailment
protected function loadFastRouteRoutes($path) { $routeParser = new \FastRoute\RouteParser\Std(); $dataGenerator = new \FastRoute\DataGenerator\GroupCountBased(); $routeCollector = new \FastRoute\RouteCollector($routeParser, $dataGenerator); if (!is_readable($path)) { thr...
@param $path @return FastRouteWrapper
entailment
protected function loadAuraRoutes($path) { if (!is_readable($path)) { throw new \InvalidArgumentException('Invalid aura routes path found: ' . $path); } $router = (new AuraRouterFactory())->newInstance(); // The included file must return the aura router $router ...
@todo - move part of this into AuraRouterWrapper->load() @todo - consider adding a setModuleName() to the AuraRouterWrapper instead of _module to each route. @param string $path @throws \Exception when the included routes file doesn't return an AuraRouter back @return AuraRouter
entailment
public function mergeConfig($resources) { $configs = array(); foreach (is_array($resources) ? $resources : func_get_args() as $resource) { $configs = ArrayUtils::merge($configs, $this->loadConfig($resource)); } return $configs; }
Loads and merges the configuration. @param mixed $resources @return array
entailment
public function getName() { if (null !== $this->name) { return $this->name; } $this->name = str_replace('\\', '', $this->getNamespace()); return $this->name; }
Returns the module name. Defaults to the module namespace stripped of backslashes. @return string The Module name
entailment
public function getNamespace() { if (null === $this->reflected) { $this->reflected = new \ReflectionObject($this); } return $this->reflected->getNamespaceName(); }
Gets the Module namespace. @return string The Module namespace @api
entailment
public function registerCommands(Application $application) { if (!is_dir($dir = $this->getCommandsPath())) { return; } $finder = new Finder(); $finder->files()->name('*Command.php')->in($dir); $prefix = $this->getNamespace() . '\\Command'; foreach ($find...
Finds and registers Commands. Override this method if your module commands do not follow the conventions: * Commands are in the 'Command' sub-directory * Commands extend PPI\Framework\Console\Command\AbstractCommand @param Application $application An Application instance
entailment
protected function getConfigLoader() { if (null === $this->configLoader) { $this->configLoader = new ConfigLoader($this->getPath() . '/resources/config'); } return $this->configLoader; }
Returns a ConfigLoader instance. @return \PPI\Framework\Config\ConfigLoader
entailment
public function total(array $condition, array $data) { if (!isset($data['cart']['total']) || empty($data['cart']['currency'])) { return false; } $condition_value = explode('|', reset($condition['value']), 2); $condition_currency = $data['cart']['currency']; if (...
Whether the cart total condition is met @param array $condition @param array $data @return boolean
entailment
public function productId(array $condition, array $data) { if (empty($data['cart']['items']) || !in_array($condition['operator'], array('=', '!='))) { return false; } $ids = array(); foreach ($data['cart']['items'] as $item) { $ids[] = $item['product_id']; ...
Whether the cart product ID condition is met @param array $condition @param array $data @return boolean
entailment
public function sku(array $condition, array $data) { if (empty($data['cart']['items']) || !in_array($condition['operator'], array('=', '!='))) { return false; } return $this->compare(array_keys($data['cart']['items']), $condition['value'], $condition['operator']); }
Whether the cart product SKU condition is met @param array $condition @param array $data @return boolean
entailment
public function add(array $data) { $result = null; $this->hook->attach('product.add.before', $data, $result, $this); if (isset($result)) { return (int) $result; } $data['created'] = $data['modified'] = GC_TIME; $data += array('currency' => $this->config-...
Adds a product @param array $data @return integer
entailment
public function update($product_id, array $data) { $result = null; $this->hook->attach('product.update.before', $product_id, $data, $result, $this); if (isset($result)) { return (bool) $result; } $data['modified'] = GC_TIME; $data['product_id'] = $produc...
Updates a product @param integer $product_id @param array $data @return boolean
entailment
public function setRelated(array $data, $delete_old = true) { if (empty($data['form']) && empty($data['related'])) { return false; } if ($delete_old) { $this->product_relation->delete($data['product_id']); } if (!empty($data['related'])) { ...
Deletes and/or adds related products @param array $data @param boolean $delete_old @return boolean
entailment
public function generateSku(array $data) { $data += array('placeholders' => $this->sku->getPatternPlaceholders()); return $this->sku->generate($this->sku->getPattern(), $data); }
Generate a product SKU @param array $data @return string
entailment
public function delete($product_id, $check = true) { $result = null; $this->hook->attach('product.delete.before', $product_id, $check, $result, $this); if (isset($result)) { return (bool) $result; } if ($check && !$this->canDelete($product_id)) { ret...
Deletes a product @param integer $product_id @param bool $check @return boolean
entailment
public function calculate(array $product, array $options = array()) { $options += array( 'status' => 1, 'store_id' => $product['store_id'] ); $components = array(); $total = $product['price']; foreach ($this->price_rule->getTriggered($product, $optio...
Calculates the product price @param array $product @param array $options @return int
entailment
protected function deleteLinked($product_id) { $conditions = array('product_id' => $product_id); $conditions2 = array('entity' => 'product', 'entity_id' => $product_id); $this->db->delete('cart', $conditions); $this->db->delete('review', $conditions); $this->db->delete('rati...
Delete all database records associated with the product ID @param int $product_id
entailment
protected function setPrice(array &$data) { if (!empty($data['price']) && !empty($data['currency'])) { $data['price'] = $this->price->amount($data['price'], $data['currency']); } }
Converts a price value to minor units @param array $data
entailment
protected function attachFields(array &$product) { if (empty($product)) { return $product; } $product['field'] = $this->product_field->getList($product['product_id']); if (empty($product['field']['option'])) { return $product; } foreach ($pr...
Adds fields to the product @param array $product @return array
entailment
protected function attachSku(array &$product) { if (empty($product)) { return $product; } $product['default_field_values'] = array(); $codes = (array) $this->sku->getList(array('product_id' => $product['product_id'])); foreach ($codes as $code) { if...
Adds option combinations to the product @param array $product @return array
entailment
protected function setSku(array &$data, $delete_old = true) { if (empty($data['form']) && empty($data['sku'])) { return false; } if ($delete_old) { $this->sku->delete($data['product_id'], array('base' => true)); return (bool) $this->sku->add($data); ...
Deletes and/or adds a new base SKU @param array $data @param boolean $delete_old @return bool
entailment
protected function setSkuCombinations(array $data, $delete_old = true) { if (empty($data['form']) && empty($data['combination'])) { return false; } if ($delete_old) { $this->sku->delete($data['product_id'], array('combinations' => true)); } return $t...
Deletes and/or adds product combinations @param array $data @param boolean $delete_old @return boolean
entailment
protected function addSkuCombinations(array $data) { if (empty($data['combination'])) { return false; } foreach ($data['combination'] as $combination) { if (empty($combination['fields'])) { continue; } if (!empty($combination...
Add SKUs for an array of product combinations @param array $data @return boolean
entailment
protected function setCombinationFileId(array &$combination, array $data) { foreach ($data['images'] as $image) { if ($image['path'] === $combination['path']) { $combination['file_id'] = $image['file_id']; } } return $combination; }
Adds a file ID from uploaded images to the combination item @param array $combination @param array $data @return array
entailment
protected function setOptions(array $data, $delete_old = true) { if (empty($data['form']) && empty($data['combination'])) { return false; } if ($delete_old) { $this->product_field->delete(array('type' => 'option', 'product_id' => $data['product_id'])); } ...
Deletes and/or adds product option fields @param array $data @param boolean $delete_old @return boolean
entailment
protected function setAttributes(array $data, $delete_old = true) { if (empty($data['form']) && empty($data['field']['attribute'])) { return false; } if ($delete_old) { $this->product_field->delete(array('type' => 'attribute', 'product_id' => $data['product_id'])); ...
Deletes and/or adds product attribute fields @param array $data @param boolean $delete_old @return boolean
entailment
protected function addOptions(array $data) { if (empty($data['combination'])) { return false; } foreach ($data['combination'] as $combination) { if (empty($combination['fields'])) { continue; } foreach ($combination['fields']...
Adds multiple options @param array $data @return boolean
entailment
protected function addAttributes(array $data) { if (empty($data['field']['attribute'])) { return false; } foreach ($data['field']['attribute'] as $field_id => $field_value_ids) { foreach ((array) $field_value_ids as $field_value_id) { $options = arra...
Adds multiple attributes @param array $data @return boolean
entailment
public static function pathInfo() { $scriptName = self::getScriptPreg(); if($scriptName){ $url = parse_url(preg_replace('/^'.$scriptName.'/', '', $_SERVER['REQUEST_URI'])); // 支持加public和不加public return isset($url['path']) ? $url['path'] : ''; }else return ...
nginx下无法获取pathinfo,手动构建path_info 支持子目录,例如正常模式:/tinymvc/public/controller/action,隐藏public模式(需.htaccess支持):/tinymvc/controller/action 或根目录:/controller/action 可额外加get参数,如:/controller/action?xx=oo
entailment
final protected function validateBool($value, array $allowed) : bool { if (true === in_array('bool', $allowed)) { if (true === is_bool($value)) { return true; } } return false; }
Validates an bool setting. @param mixed $value The value we are validating. @param array $allowed Which items are allowed. @throws \InvalidArgumentException If the data is inaccurate/incorrect. @return bool True if validated, false if not
entailment
final protected function validateString($value, array $allowed) : bool { if (true === in_array('string', $allowed)) { if (true === is_string($value)) { return true; } } return false; }
Validates an string setting. @param mixed $value The value we are validating. @param array $allowed Which items are allowed. @throws \InvalidArgumentException If the data is inaccurate/incorrect. @return bool True if validated, false if not
entailment
final protected function validateCallable($value, array $allowed) : bool { if (true === in_array('callable', $allowed)) { if (true === is_callable($value)) { return true; } } return false; }
Validates an callable setting. @param mixed $value The value we are validating. @param array $allowed Which items are allowed. @throws \InvalidArgumentException If the data is inaccurate/incorrect. @return bool True if validated, false if not
entailment
final protected function validateInt(string $name, $value, array $allowed) : bool { if (true === in_array('int', $allowed)) { if (true === is_int($value)) { if ($value >= 0) { return true; } else { throw new \InvalidArgument...
Validates an int setting. @param string $name The name of the setting we are validating. @param mixed $value The value we are validating. @param array $allowed Which items are allowed. @throws \InvalidArgumentException If the data is inaccurate/incorrect. @return bool True if validated, false if not
entailment
final protected function validateArray(string $name, $value, array $allowed) : bool { if (true === in_array('array', $allowed)) { if (true === is_array($value)) { if (true === empty($value)) { throw new \InvalidArgumentException('Array for '.$name.' is empty')...
Validates an array setting. @param string $name The name of the setting we are validating. @param mixed $value The value we are validating. @param array $allowed Which items are allowed. @throws \InvalidArgumentException If the data is inaccurate/incorrect. @return bool True if validated, false if not
entailment
public function generate($name, $parameters = array(), $referenceType = self::ABSOLUTE_PATH) { $ret = $this->router->generate($name, $parameters); if ($ret === false) { throw new RouteNotFoundException('Unable to generate route for: ' . $name); } return $ret; }
@param string $name @param array $parameters @param bool|string $referenceType @return false|string
entailment
protected function doMatch($pathinfo, Request $request = null) { $matchedRoute = $this->router->match($pathinfo, $request->server->all()); if ($matchedRoute === false) { throw new ResourceNotFoundException(); } $routeParams = $matchedRoute->params; // The 'actio...
@param $pathinfo @param Request $request @throws \Exception @return array
entailment
public function listCollectionItem($collection_id) { $this->setCollectionCollection($collection_id); $this->actionListCollectionItem(); $this->setTitleListCollectionItem(); $this->setBreadcrumbListCollectionItem(); $this->setFilterListCollectionItem(); $this->setPage...
Displays the collection item overview page @param integer $collection_id
entailment
protected function setPagerListCollectionItem() { $options = $this->query_filter; $options['count'] = true; $options['collection_id'] = $this->data_collection['collection_id']; $pager = array( 'query' => $this->query_filter, 'total' => (int) $this->collection...
Set pager @return array
entailment
protected function setCollectionCollection($collection_id) { $this->data_collection = $this->collection->get($collection_id); if (empty($this->data_collection)) { $this->outputHttpStatus(404); } }
Sets a collection data @param integer $collection_id
entailment
protected function setCollectionCollectionItem($collection_item_id) { $this->data_collection_item = array(); if (is_numeric($collection_item_id)) { $this->data_collection_item = $this->collection_item->get($collection_item_id); if (empty($this->data_collection_item)) { ...
Sets a collection item data @param integer $collection_item_id
entailment
protected function prepareCollectionItem(array &$collection_item) { $item = $this->collection_item->getItem(array( 'collection_item_id' => $collection_item['collection_item_id'])); $collection_item['title'] = isset($item['title']) ? $item['title'] : ''; }
Prepare an array of collection item data @param array $collection_item
entailment
protected function getListCollectionItem() { $conditions = $this->query_filter; $conditions['limit'] = $this->data_limit; $conditions['collection_id'] = $this->data_collection['collection_id']; return $this->collection_item->getItems($conditions); }
Returns an array of collection items @return array
entailment
protected function setBreadcrumbListCollectionItem() { $breadcrumbs = array(); $breadcrumbs[] = array( 'url' => $this->url('admin'), 'text' => $this->text('Dashboard') ); $breadcrumbs[] = array( 'text' => $this->text('Collections'), '...
Sets breadcrumbs on the collection item overview page
entailment
public function editCollectionItem($collection_id, $collection_item_id = null) { $this->setCollectionCollection($collection_id); $this->setCollectionCollectionItem($collection_item_id); $this->setTitleEditCollectionItem(); $this->setBreadcrumbEditCollectionItem(); $this->set...
Displays the edit collection item form @param integer $collection_id @param string|int|null $collection_item_id
entailment
protected function submitEditCollectionItem() { if ($this->isPosted('delete')) { $this->deleteCollectionItem(); } else if ($this->isPosted('save') && $this->validateEditCollectionItem()) { if (isset($this->data_collection_item['collection_item_id'])) { $this->...
Saves a submitted collection item
entailment
protected function getHandlerCollectionItem() { $handlers = $this->collection->getHandlers(); if (empty($handlers[$this->data_collection['type']])) { $this->outputHttpStatus(403); } return $handlers[$this->data_collection['type']]; }
Returns an array of handler data for the collection type @return array
entailment
protected function validateEditCollectionItem() { $this->setSubmitted('collection_item'); $this->setSubmittedBool('status'); $this->setSubmitted('update', $this->data_collection_item); $this->setSubmitted('collection_id', $this->data_collection['collection_id']); $this->vali...
Validates a submitted collection item @return bool
entailment
protected function addCollectionItem() { $this->controlAccess('collection_item_add'); if ($this->collection_item->add($this->getSubmitted())) { $this->redirect('', $this->text('Collection item has been added'), 'success'); } $this->redirect('', $this->text('Collection i...
Adds a new collection item
entailment
protected function updateCollectionItem() { $this->controlAccess('collection_item_edit'); if ($this->collection_item->update($this->data_collection_item['collection_item_id'], $this->getSubmitted())) { $url = "admin/content/collection-item/{$this->data_collection['collection_id']}"; ...
Update a submitted collection item
entailment
protected function deleteCollectionItem() { $this->controlAccess('collection_item_delete'); if ($this->collection_item->delete($this->data_collection_item['collection_item_id'])) { $url = "admin/content/collection-item/{$this->data_collection['collection_id']}"; $this->redir...
Delete a collection item
entailment
protected function setTitleEditCollectionItem() { $vars = array('%name' => $this->data_collection['title']); if (empty($this->data_collection_item['collection_item_id'])) { $text = $this->text('Add item to %name', $vars); } else { $text = $this->text('Edit item of %n...
Sets title on the edit collection item page
entailment
protected function setBreadcrumbEditCollectionItem() { $breadcrumbs = array(); $breadcrumbs[] = array( 'url' => $this->url('admin'), 'text' => $this->text('Dashboard') ); $breadcrumbs[] = array( 'url' => $this->url('admin/content/collection'), ...
Sets breadcrumbs on the edit collection item page
entailment
public function createService(ServiceLocatorInterface $serviceLocator) { $router = $serviceLocator->get('MicroRouter'); $requestContext = $serviceLocator->get('RouterRequestContext'); $logger = $serviceLocator->get('Logger'); return new RouterListener($router, $reque...
Create and return the router. @param ServiceLocatorInterface $serviceLocator @return \PPI\Framework\Router\RouterListener
entailment
public function createVerify() { $width = $this->height * $this->len / 1.6; $this->verifyCode = $this->random($this->len, $this->str); $quarterHeight = $this->height / 4; $fontHeight = $this->height - $quarterHeight; $halfHeight = $this->height / 2; for ($num = 0; $n...
创建一个gif验证码,但不输出
entailment
private function findColor() { $code = $this->verifyCode; $this->verifyCode = ''; $color = array_values($this->fontColor); $rand = rand(0, count($color) - 1); foreach ($this->fontColor as $k => $v) { if ($v == $this->fontColor[$rand]) { $this->ver...
如果开启了看颜色识别,这里处理颜色识别
entailment
private function randImageData($imageData) { $rand = rand(0, $this->frames); if ($rand) { foreach ($imageData as $k => $v) { if ($k > $rand) break; array_shift($imageData); $imageData[] = $v; } } $this->imageDat...
偏移gif帧数
entailment
public function outputVerify() { $this->createVerify(); $gif = new gifEncoder($this->imageData, $this->delay); Session::set(static::$sessionKey, $this->autoLower ? strtolower($this->verifyCode) : $this->verifyCode); header('content-type:image/gif'); echo $gif->GetAnimation();...
输出验证码
entailment
public static function getVerify() { $verify = Session::get(self::$sessionKey); Session::set(self::$sessionKey, null); return $verify; }
获取验证码字符串,用于存session
entailment
public function getList(array $options) { $sql = 'SELECT ol.*, u.name AS user_name, u.email AS user_email, u.status AS user_status'; if (!empty($options['count'])) { $sql = 'SELECT COUNT(ol.order_log_id)'; } $sql .= ' FROM order_log ol LEFT JOIN user u...
Returns an array of log records @param array $options @return array|int
entailment
public function getWidgetAdminMenu($route_class, array $options = array()) { $options += array('parent_url' => 'admin'); $items = array(); foreach ($route_class->getList() as $path => $route) { if (strpos($path, "{$options['parent_url']}/") !== 0 || empty($route['menu']['admin']...
Returns rendered admin menu @param \gplcart\core\Route $route_class @param array $options @return string
entailment
public function getWidgetImages($language_model, array $options) { $options += array( 'single' => false, 'languages' => $language_model->getList(array('in_database' => true)) ); return $this->render('common/image', $options); }
Returns rendered image widget @param \gplcart\core\models\Language $language_model @param array $options @return string
entailment
protected function getWidgetCollection(array $items) { if (empty($items)) { return ''; } $item = reset($items); $data = array( 'items' => $items, 'title' => $item['collection_item']['collection_title'], 'collection_id' => $item['colle...
Returns a rendered collection @param array $items @return string
entailment