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); } } $this->prepareImageStyle($this->data_imagestyle); }
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(); } else { $this->addImageStyle(); } } }
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 style has been deleted'), 'success'); } $this->redirect('', $this->text('Image style has not been deleted'), 'warning'); }
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->hasErrors(); }
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/settings/imagestyle', $this->text('Image style has been updated'), 'success'); } $this->redirect('', $this->text('Image style has not been updated'), 'warning'); }
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('Image style has not been added'), 'warning'); }
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)) { $modified[] = $info; continue; } $action = $action_id; if (!empty($info['value'])) { $action .= ' ' . implode(',', $info['value']); } $modified[] = $action; } $this->setData('imagestyle.actions', implode(PHP_EOL, $modified)); }
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($title); }
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'), 'text' => $this->text('Image styles') ); $this->setBreadcrumbs($breadcrumbs); }
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 and each record, there may be one or more fields, separated by commas. // Spaces are considered part of a field and should not be ignored. // The last field in the record must not be followed by a comma. // - Each field may or may not be enclosed in double quotes // (however some programs, such as Microsoft Excel, do not use double quotes at all). // If fields are not enclosed with double quotes, then double quotes may not appear inside the fields. // - Fields containing line breaks (CRLF), double quotes, and commas // should be enclosed in double-quotes. // - If double-quotes are used to enclose fields, // then a double-quote appearing inside a field must be escaped by preceding it with another double quote. $enclosed = null; $fields = []; $field = -1; $lastCharPos = mb_strlen($line) - 1; if ($continueLine) { if (!is_a($continueLine[count($continueLine) - 1], 'frictionlessdata\\tableschema\\ContinueEnclosedField')) { throw new \Exception('invalid continueLine'); } unset($continueLine[count($continueLine) - 1]); $fields = $continueLine; $field = count($fields) - 1; $enclosed = true; } for ($charPos = 0; $charPos < mb_strlen($line); ++$charPos) { $char = mb_substr($line, $charPos, 1); if ($enclosed === null) { // start of a new field if ($char == $this->dialect['delimiter']) { if ( // delimiter at end of line ($charPos == $lastCharPos) // double delimiters || ($charPos != $lastCharPos && mb_substr($line, $charPos + 1, 1) == $this->dialect['delimiter']) ) { ++$field; $fields[$field] = ''; } } else { ++$field; $fields[$field] = ''; if ($char == $this->dialect['quoteChar']) { $enclosed = true; } else { $enclosed = false; $fields[$field] .= $char; } } } elseif ($enclosed) { // processing an enclosed field if ( $this->dialect['doubleQuote'] !== null && $char == $this->dialect['quoteChar'] && $charPos != $lastCharPos && mb_substr($line, $charPos + 1, 1) == $this->dialect['quoteChar'] ) { // doubleQuote mode is active, current char is a quote and next char is a quote $fields[$field] .= $this->dialect['quoteChar']; // skip a char ++$charPos; continue; } elseif ( $this->dialect['escapeChar'] && $char === $this->dialect['escapeChar'] ) { // encountered escape char, add the escaped char to the string if ($charPos === $lastCharPos) { throw new DataSourceException('Encountered escape char at end of line'); } else { $fields[$field] .= mb_substr($line, $charPos + 1, 1); } // skip a char ++$charPos; continue; } elseif ($char == $this->dialect['quoteChar']) { // encountered a quote signifying the end of the enclosed field $enclosed = null; continue; } else { // character in enclosed field $fields[$field] .= $char; continue; } } else { // processing a non-enclosed field if ($char == $this->dialect['quoteChar']) { // non enclosed field - cannot have a quotes throw new \Exception('Invalid csv file - if field is not enclosed with double quotes - then double quotes may not appear inside the field'); } elseif ($char == $this->dialect['delimiter']) { // end of non-enclosed field + start of new field if ( // delimiter at end of line ($charPos == $lastCharPos) // double delimiters || ($charPos != $lastCharPos && mb_substr($line, $charPos + 1, 1) == $this->dialect['delimiter']) ) { ++$field; $fields[$field] = ''; } $enclosed = null; continue; } else { // character in non-enclosed field $fields[$field] .= $char; continue; } } } if ($this->dialect['skipInitialSpace']) { $fields = array_map(function ($field) { return ltrim($field); }, $fields); } if ($enclosed === true && !is_a($fields[count($fields) - 1], 'frictionlessdata\\tableschema\\ContinueEnclosedField')) { $fields[$field + 1] = new ContinueEnclosedField(); } return $fields; }
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 return null; }
获取默认值 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->redirect($result['redirect'], $result['message'], $result['severity']); } }
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->setDataPanelSummaryIndexOrder(); $this->setDataPanelCommentIndexOrder(); $this->setDataPanelCustomerIndexOrder(); $this->setDataPanelComponentsIndexOrder(); $this->setDataPanelPaymentAddressIndexOrder(); $this->setDataPanelShippingAddressIndexOrder(); $this->outputIndexOrder(); }
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()) { $this->cloneOrder(); } }
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 been deleted'), 'warning'); }
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->data_order['order_id']); $this->logUpdateStatusOrder($submitted); $messages = $this->getMassagesUpdateOrder(); list($severity, $text) = $messages[$submitted['notify']]; $this->redirect('', $this->text($text), $severity); } $this->redirect('', $this->text('Order has not been updated'), 'warning'); }
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 to @status', array('@status' => $submitted['status'])) ); $this->order_history->add($log); } }
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) { return static::NOTIFICATION_SENT; } return static::NOTIFICATION_ERROR; }
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)) { $this->logUpdateStatusOrder($update); $this->redirect("checkout/clone/{$this->data_order['order_id']}"); } $this->redirect('', $this->text('Order has not been cloned'), 'warning'); }
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['cart'] as $item) { $count++; unset($item['cart_id']); $item['user_id'] = $this->uid; $item['order_id'] = 0; if ($this->cart->add($item)) { $added++; } } return $count && $count == $added; }
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->url('admin/sale/order') ); $this->setBreadcrumbs($breadcrumbs); }
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_history->setViewed($this->data_order); $this->prepareOrder($this->data_order); } }
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->setItemOrderPaymentName($order, $this->payment); $this->setItemOrderShippingName($order, $this->shipping); $order['user'] = array(); if (is_numeric($order['user_id'])) { $order['user'] = $this->user->get($order['user_id']); } $options = array( 'count' => true, 'user_id' => $order['user_id'] ); $order['user']['total_orders'] = (int) $this->order->getList($options); $order['customer'] = $this->text('Anonymous'); $order['creator_formatted'] = $this->text('Customer'); if (!empty($order['creator'])) { $order['creator_formatted'] = $this->text('Unknown'); $user = $this->user->get($order['creator']); if (isset($user['user_id'])) { $order['creator_formatted'] = "{$user['name']} ({$user['email']})"; } } }
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_order, 'pager' => $pager['rendered'], 'items' => $this->getListLogOrder($pager['limit']) ); $this->setData('pane_log', $this->render('sale/order/panes/log', $data)); }
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); $this->setItemOrderPaymentComponent($this->data_order, $this->price, $this->payment, $this->order); $this->setItemOrderShippingComponent($this->data_order, $this->price, $this->shipping, $this->order); ksort($this->data_order['data']['components']); } $this->setData('pane_components', $this->render('sale/order/panes/components', array('order' => $this->data_order))); }
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', $this->getListOrder()); $this->outputListOrder(); }
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($pager); }
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')) { $updated = (bool) $this->order->update($id, array('status' => $value)); if ($updated && $this->setNotificationUpdateOrder($id) == static::NOTIFICATION_ERROR) { $failed_notifications[] = $this->text('<a href="@url">@text</a>', array( '@url' => $this->url("admin/sale/order/$id"), '@text' => $id)); } $updated++; } if ($action === 'delete' && $this->access('order_delete')) { $deleted += (int) $this->order->delete($id); } } if ($updated > 0) { $message = $this->text('Updated %num item(s)', array('%num' => $updated)); $this->setMessage($message, 'success'); } if (!empty($failed_notifications)) { $vars = array('!list' => implode(', ', $failed_notifications)); $message = $this->text('Failed to notify customers in orders: !list', $vars); $this->setMessage($message, 'warning'); } if ($deleted > 0) { $message = $this->text('Deleted %num item(s)', array('%num' => $deleted)); $this->setMessage($message, 'success'); } }
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_FILENAME) . '.' . pathinfo($path, PATHINFO_EXTENSION)); $this->routes = $routesCollection; } return $this->routes; }
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)) { throw new \InvalidArgumentException('Invalid fast route routes path found: ' . $path); } // The included file must return the laravel router $getRouteCollector = function () use ($routeCollector, $path) { $r = $routeCollector; include $path; return $r; }; $routeCollector = $getRouteCollector(); if (!($routeCollector instanceof \FastRoute\RouteCollector)) { throw new \Exception('Invalid return value from ' . pathinfo($path, PATHINFO_FILENAME) . ' expected instance of RouteCollector' ); } $dispatcher = new \FastRoute\Dispatcher\GroupCountBased($routeCollector->getData()); $router = new \PPI\FastRoute\Wrapper\FastRouteWrapper( $dispatcher ); $router->setModuleName($this->getName()); return $router; }
@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 = include $path; if (!($router instanceof AuraRouter)) { throw new \Exception('Invalid return value from ' . pathinfo($path, PATHINFO_FILENAME) . ' expected instance of AuraRouter' ); } foreach ($router->getRoutes() as $route) { $route->addValues(array('_module' => $this->getName())); } return $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 ($finder as $file) { $ns = $prefix; if ($relativePath = $file->getRelativePath()) { $ns .= '\\' . strtr($relativePath, '/', '\\'); } $r = new \ReflectionClass($ns . '\\' . $file->getBasename('.php')); if ($r->isSubclassOf('PPI\Framework\\Console\\Command\\AbstractCommand') && !$r->isAbstract()) { $application->add($r->newInstance()); } } }
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 (!empty($condition_value[1])) { $condition_currency = $condition_value[1]; } $condition_value[0] = $this->price->amount($condition_value[0], $condition_currency); $value = $this->currency->convert($condition_value[0], $condition_currency, $data['cart']['currency']); return $this->compare($data['cart']['total'], $value, $condition['operator']); }
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']; } return $this->compare($ids, $condition['value'], $condition['operator']); }
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->get('currency', 'USD')); $this->setPrice($data); $result = $data['product_id'] = $this->db->insert('product', $data); $this->setTranslations($data, $this->translation_entity, 'product', false); $this->setImages($data, $this->file, 'product'); $this->setSku($data, false); $this->setSkuCombinations($data, false); $this->setOptions($data, false); $this->setAttributes($data, false); $this->setAlias($data, $this->alias, 'product', false); $this->setRelated($data, false); $this->search->index('product', $data); $this->hook->attach('product.add.after', $data, $result, $this); return (int) $result; }
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'] = $product_id; $this->setPrice($data); $updated = $this->db->update('product', $data, array('product_id' => $product_id)); $updated += (int) $this->setSku($data); $updated += (int) $this->setTranslations($data, $this->translation_entity, 'product'); $updated += (int) $this->setImages($data, $this->file, 'product'); $updated += (int) $this->setAlias($data, $this->alias, 'product'); $updated += (int) $this->setSkuCombinations($data); $updated += (int) $this->setOptions($data); $updated += (int) $this->setAttributes($data); $updated += (int) $this->setRelated($data); $result = $updated > 0; if ($result) { $this->search->index('product', $product_id); } $this->hook->attach('product.update.after', $product_id, $data, $result, $this); return (bool) $result; }
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'])) { foreach ((array) $data['related'] as $related_product_id) { $this->product_relation->add($related_product_id, $data['product_id']); } return true; } return false; }
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)) { return false; } $result = (bool) $this->db->delete('product', array('product_id' => $product_id)); if ($result) { $this->deleteLinked($product_id); } $this->hook->attach('product.delete.after', $product_id, $check, $result, $this); return (bool) $result; }
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, $options) as $price_rule) { $this->price_rule->calculate($total, $product, $components, $price_rule); } return $total; }
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('rating', $conditions); $this->db->delete('wishlist', $conditions); $this->db->delete('rating_user', $conditions); $this->db->delete('product_sku', $conditions); $this->db->delete('product_field', $conditions); $this->db->delete('product_translation', $conditions); $this->db->delete('product_view', $conditions); $this->db->delete('product_related', $conditions); $this->db->delete('product_related', array('item_product_id' => $product_id)); $this->db->delete('product_bundle', $conditions); $this->db->delete('file', $conditions2); $this->db->delete('alias', $conditions2); $this->db->delete('search_index', $conditions2); $sql = 'DELETE ci FROM collection_item ci INNER JOIN collection c ON(ci.collection_id = c.collection_id) WHERE c.type = ? AND ci.entity_id = ?'; $this->db->run($sql, array('product', $product_id)); }
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 ($product['field']['option'] as &$field_values) { $field_values = array_unique($field_values); } return $product; }
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 ($code['combination_id'] === '') { $product['sku'] = $code['sku']; $product['price'] = $code['price']; $product['stock'] = $code['stock']; continue; } $product['combination'][$code['combination_id']] = $code; if (!empty($code['is_default'])) { $product['default_field_values'] = $code['fields']; } } return $product; }
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); } if (empty($data['sku'])) { $data['sku'] = $this->generateSku($data); } 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 $this->addSkuCombinations($data); }
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['price'])) { $combination['price'] = $this->price->amount($combination['price'], $data['currency']); } $this->setCombinationFileId($combination, $data); $combination['store_id'] = $data['store_id']; $combination['product_id'] = $data['product_id']; $combination['combination_id'] = $this->sku->getCombinationId($combination['fields'], $data['product_id']); if (empty($combination['sku'])) { $combination['sku'] = $this->sku->generate($data['sku'], array('store_id' => $data['store_id'])); } $this->sku->add($combination); } return true; }
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'])); } return $this->addOptions($data); }
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'])); } return $this->addAttributes($data); }
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'] as $field_id => $field_value_id) { $options = array( 'type' => 'option', 'field_id' => $field_id, 'product_id' => $data['product_id'], 'field_value_id' => $field_value_id ); $this->product_field->add($options); } } return true; }
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 = array( 'type' => 'attribute', 'field_id' => $field_id, 'product_id' => $data['product_id'], 'field_value_id' => $field_value_id ); $this->product_field->add($options); } } return true; }
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 \InvalidArgumentException('Int value for '.$name.' is too low'); } } } return false; }
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'); } else { foreach ($value as $line) { if (false === is_string($line)) { throw new \InvalidArgumentException('Array for '.$name.' contains a non-string item'); } } return true; } } } return false; }
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 'action' key always exists and defaults to the Route Name, so we check accordingly if (!isset($routeParams['controller']) && $routeParams['action'] === $matchedRoute->name) { throw new \Exception('Matched the route: ' . $matchedRoute->name . ' but unable to locate any controller/action params to dispatch'); } // We need _controller, to that symfony ControllerResolver can pick this up if (!isset($routeParams['_controller'])) { if (isset($routeParams['controller'])) { $routeParams['_controller'] = $routeParams['controller']; } elseif (isset($routeParams['action'])) { $routeParams['_controller'] = $routeParams['action']; } else { throw new \Exception('Unable to determine the controller from route: ' . $matchedRoute->name); } } $routeParams['_route'] = $matchedRoute->name; // If the controller is an Object, and 'action' is defaulted to the route name - we default to __invoke if ($routeParams['action'] === $matchedRoute->name) { $routeParams['action'] = '__invoke'; } if (false === strpos($routeParams['_controller'], '::') && isset($routeParams['action'])) { $routeParams['_controller'] = sprintf('%s::%s', $routeParams['_controller'], $routeParams['action'] ); } return $routeParams; }
@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->setPagerListCollectionItem(); $this->setData('collection', $this->data_collection); $this->setData('items', $this->getListCollectionItem()); $this->outputListCollectionItem(); }
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_item->getList($options) ); return $this->data_limit = $this->setPager($pager); }
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)) { $this->outputHttpStatus(404); } $this->prepareCollectionItem($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'), 'url' => $this->url('admin/content/collection') ); $this->setBreadcrumbs($breadcrumbs); }
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->setData('collection', $this->data_collection); $this->setData('collection_item', $this->data_collection_item); $this->setData('handler', $this->getHandlerCollectionItem()); $this->setData('weight', $this->collection_item->getNextWeight($collection_id)); $this->submitEditCollectionItem(); $this->setJsEditCollectionItem(); $this->outputEditCollectionItem(); }
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->updateCollectionItem(); } else { $this->addCollectionItem(); } } }
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->validateComponent('collection_item'); return !$this->hasErrors(); }
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 item has not been added'), 'warning'); }
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']}"; $this->redirect($url, $this->text('Collection item has been updated'), 'success'); } $this->redirect('', $this->text('Collection item has not been updated'), 'warning'); }
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->redirect($url, $this->text('Collection item has been deleted'), 'success'); } $this->redirect('', $this->text('Collection item has not been deleted'), 'warning'); }
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 %name', $vars); } $this->setTitle($text); }
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'), 'text' => $this->text('Collections') ); $breadcrumbs[] = array( 'url' => $this->url("admin/content/collection-item/{$this->data_collection['collection_id']}"), 'text' => $this->text('Items of collection %name', array('%name' => $this->data_collection['title'])) ); $this->setBreadcrumbs($breadcrumbs); }
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, $requestContext, $logger); }
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; $num < $this->len; $num++) { $c_angel[$num] = $i_rand = rand(0, 30); // 每个字母的初始化角度 $this->fontColor[$num] = rand(0, 4); // 每个字母的初始化颜色 $c_y[$num] = $fontHeight + $this->fontColor[$num]; // 每个字母的初始化高度 $r_1_2[$num] = rand(3, 20); // 该值决定每个字母的旋转方向和速度及最大角度 $r_size[$num] = rand($halfHeight, $fontHeight); // 每个字母的初始化大小 } $fra_2 = $this->frames / 2; $fra_4 = $this->frames / 4; $fra_8 = $this->frames - $fra_4; for ($i = 0; $i < $this->frames; $i++) { ob_start(); $image = imagecreate($width, $this->height); $red = imagecolorallocate($image, $this->baseColor['0']['rbg']['0'], $this->baseColor['0']['rbg']['1'], $this->baseColor['0']['rbg']['2']); $blue = imagecolorallocate($image, $this->baseColor['1']['rbg']['0'], $this->baseColor['1']['rbg']['1'], $this->baseColor['1']['rbg']['2']); $green = imagecolorallocate($image, $this->baseColor['2']['rbg']['0'], $this->baseColor['2']['rbg']['1'], $this->baseColor['2']['rbg']['2']); $orange = imagecolorallocate($image, $this->baseColor['3']['rbg']['0'], $this->baseColor['3']['rbg']['1'], $this->baseColor['3']['rbg']['2']); $purple = imagecolorallocate($image, $this->baseColor['4']['rbg']['0'], $this->baseColor['4']['rbg']['1'], $this->baseColor['4']['rbg']['2']); $colors = array($red, $blue, $green, $orange, $purple); $gray = imagecolorallocate($image, $this->background['0'], $this->background['1'], $this->background['2']); imagefill($image, 0, 0, $gray); $j = $i < $fra_4 ? $i : $fra_2 - $i; // 实现gif旋转对称 if ($i > $fra_8) { $j += $fra_2; $j = -$j; } for ($num = 0; $num < $this->len; $num++) { $angel = $r_1_2[$num] % 2 == 0 ? $c_angel[$num] + $j * $r_1_2[$num] : $c_angel[$num] - $j * $r_1_2[$num]; imagettftext($image, $r_size[$num], $angel, $quarterHeight + $halfHeight * $num + 2, $c_y[$num], $colors[$this->fontColor[$num]], $this->font, $this->verifyCode[$num]); } Imagegif($image); ImageDestroy($image); $delay[] = 8; // 每一帧的延迟 $imageData[] = ob_get_contents(); ob_clean(); } $this->findColor && $this->findColor(); $this->randImageData($imageData); $this->delay = $delay; }
创建一个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->verifyCode .= $code[$k]; } } $this->tips = $this->baseColor[$color[$rand]]['tips']; }
如果开启了看颜色识别,这里处理颜色识别
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->imageData = $imageData; }
偏移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 ON(ol.user_id=u.user_id) WHERE ol.order_id=?'; if (!empty($options['count'])) { return (int) $this->db->fetchColumn($sql, array($options['order_id'])); } $sql .= ' ORDER BY ol.created DESC'; if (!empty($options['limit'])) { $sql .= ' LIMIT ' . implode(',', array_map('intval', $options['limit'])); } $fetch_options = array('unserialize' => 'data', 'index' => 'order_log_id'); $list = $this->db->fetchAll($sql, array($options['order_id']), $fetch_options); $this->hook->attach('order.log.list', $list, $this); return (array) $list; }
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'])) { continue; } if (isset($route['access']) && !$this->access($route['access'])) { continue; } $items[$path] = array( 'url' => $this->url($path), 'text' => $this->text($route['menu']['admin']), 'depth' => substr_count(substr($path, strlen("{$options['parent_url']}/")), '/'), ); } ksort($items); $options += array('items' => $items); return $this->getWidgetMenu($options); }
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['collection_item']['collection_id'] ); return $this->render($item['collection_handler']['template']['list'], $data, true); }
Returns a rendered collection @param array $items @return string
entailment