/** * Method to get critical path length for a node * * @param string $module Module actual name * * @return integer */ public function getCriticalPath($module) { if (!isset($this->criticalPaths)) { $this->criticalPaths = $this->calculateCriticalPathLengths(); } return \Includes\Utils\ArrayManager::getIndex($this->criticalPaths, $module); }
/** * Translate label * * @param string $name Label name * @param string $code Language code * * @return string|void */ public function translate($name, $code) { if (!isset($this->translations[$code])) { $this->translations[$code] = $this->getRepo()->findLabelsByCode($code); } return \Includes\Utils\ArrayManager::getIndex($this->translations[$code], $name); }
/** * Return all classes metadata * * @param string $class Class name OPTIONAL * * @return array */ public static function getAllMetadata($class = null) { if (!isset(static::$metadata)) { static::$metadata = array(); // Create hash array to quick access its elements foreach (static::getHandler()->getMetadataFactory()->getAllMetadata() as $data) { static::$metadata[$data->name] = $data; } } return \Includes\Utils\ArrayManager::getIndex(static::$metadata, $class); }
/** * Get some data for depenendecy in list * * @param \XLite\Model\Module $module Current module * * @return string */ protected function getDependencyCSSClass(\XLite\Model\Module $module) { return \Includes\Utils\ArrayManager::getIndex($this->getDependencyData($module), 'class', true); }
/** * Parse template and add tags to the list * * @param array $data Tags data * @param string $path Template file path * * @return array */ protected function addTags(array $data, $path) { $base = \Includes\Utils\FileManager::getRelativePath($path, LC_DIR_SKINS); foreach ($data as $tags) { $skin = \Includes\Utils\ArrayManager::getIndex(explode(LC_DS, $base), 0, true); $zone = array_search($skin, static::$zones) ?: \XLite\Model\ViewList::INTERFACE_CUSTOMER; $template = substr($base, strpos($base, LC_DS) + ('common' == $skin ? 1 : 4)); static::$annotatedTemplates[] = array('tpl' => $template, 'zone' => $zone, 'path' => $path) + $tags; } }
/** * Get row heading * * @param string $row Row identificator * * @return array|string */ public function getRowTitle($row) { return \Includes\Utils\ArrayManager::getIndex($this->getRowTitles(), $row); }
/** * Alias * * @param array $data Data to get field value from * @param string $field Name of field to get * * @return mixed */ protected function getField(array $data, $field) { return \Includes\Utils\ArrayManager::getIndex($data, $field, true); }
/** * Translate array of data received from Paypal to the array for updating cart * * @param array $paypalData Array of customer data received from Paypal * * @return array */ public function prepareBuyerData($paypalData) { $countryCode = \Includes\Utils\ArrayManager::getIndex($paypalData, 'SHIPTOCOUNTRYCODE'); $country = \XLite\Core\Database::getRepo('XLite\\Model\\Country')->findOneByCode($countryCode); $stateCode = \Includes\Utils\ArrayManager::getIndex($paypalData, 'SHIPTOSTATE'); $state = $country && $stateCode ? \XLite\Core\Database::getRepo('XLite\\Model\\State')->findOneByCountryAndCode($country->getCode(), $stateCode) : null; $street = trim(\Includes\Utils\ArrayManager::getIndex($paypalData, 'SHIPTOSTREET') . ' ' . \Includes\Utils\ArrayManager::getIndex($paypalData, 'SHIPTOSTREET2')); $data = array('shippingAddress' => array('name' => (string) \Includes\Utils\ArrayManager::getIndex($paypalData, 'SHIPTONAME'), 'street' => $street, 'country' => $country ?: '', 'state' => $state ? $state : (string) \Includes\Utils\ArrayManager::getIndex($paypalData, 'SHIPTOSTATE'), 'city' => (string) \Includes\Utils\ArrayManager::getIndex($paypalData, 'SHIPTOCITY'), 'zipcode' => (string) \Includes\Utils\ArrayManager::getIndex($paypalData, 'SHIPTOZIP'), 'phone' => (string) \Includes\Utils\ArrayManager::getIndex($paypalData, 'PHONENUM'))); return $data; }
/** * Check if redirect to clean URL is needed * * @return boolean */ protected function isRedirectToCleanURLNeeded() { return preg_match('/\\/cart\\.php/Si', \Includes\Utils\ArrayManager::getIndex(\XLite\Core\Request::getInstance()->getServerData(), 'REQUEST_URI')); }
/** * Return code for the parsed "<list ... />" tag * * @param array $attrs All tag attributes * * @return string */ protected function getListDisplayCode(array $attrs) { $type = ucfirst(\Includes\Utils\ArrayManager::getIndex($attrs, 'type')); $name = \Includes\Utils\ArrayManager::getIndex($attrs, 'name'); $this->unsetAttributes($attrs, array('type', 'name')); $args = ''; if (!empty($attrs)) { $args .= ', ' . $this->getAttributesList($attrs); } return '$this->display' . $type . 'ViewListContent(' . $this->flexyAttribute($name) . $args . ');'; }
/** * Check if module is active * * @param string|null $moduleName Module name * * @return boolean */ public static function isActiveModule($moduleName) { return (bool) \Includes\Utils\ArrayManager::getIndex(static::getActiveModules(), $moduleName, true); }
/** * Get tag info * * @param string $name Tag name * @param boolean $forceTokenizer Flag to force tokenizer use (since LC_Dependencies classes could be non-working) * * @return array */ public function getTag($name, $forceTokenizer = false) { return \Includes\Utils\ArrayManager::getIndex($this->getTags($forceTokenizer), strtolower($name), true); }
/** * Parse template and add tags to the list * * @param array $data Tags data * @param string $path Template file path * * @return array */ protected function addTags(array $data, $path) { $base = \Includes\Utils\FileManager::getRelativePath($path, LC_DIR_SKINS); $skin = \Includes\Utils\ArrayManager::getIndex(explode(LC_DS, $base), 0, true); static::$annotatedTemplates[] = array('tpl' => $base, 'zone' => array_search($skin, static::$zones) ?: \XLite\Model\ViewList::INTERFACE_CUSTOMER, 'path' => $path, 'tags' => $data); }
/** * Get fixtures loading procedure option * * @param string $name Option name * * @return mixed */ public function getFixturesLoadingOption($name) { return \Includes\Utils\ArrayManager::getIndex($this->fixturesLoadingOptions, $name, true); }
/** * Return extension for the archive file * * @return string */ public static function getExtension() { return \Includes\Utils\ArrayManager::getIndex(static::$extensions, self::COMPRESSION_TYPE, true); }
/** * Get session cell by name * * @param string $name Cell name * * @return \XLite\Model\SessionCell|void */ protected function getCellByName($name) { return \Includes\Utils\ArrayManager::getIndex($this->getCellsCache(), $name, true); }
/** * Get session cell by name * * @param string $name Cell name * * @return \XLite\Model\SessionCell|void */ protected function getCellByName($name) { if (!isset($this->cache)) { $this->cache = array(); foreach ((array) static::getSessionCellRepo()->findById($this->getId()) as $cell) { $this->cache[$cell->getName()] = $cell; } } return \Includes\Utils\ArrayManager::getIndex($this->cache, $name, true); }
/** * Find node by key * * @param string $key Key to search * * @return array */ public function find($key) { $searchResult = null; $this->walkFirst(function (\Includes\DataStructure\Graph $node) use($key, &$searchResult) { if ($node->getKey() == $key) { $searchResult = $node; } return (bool) $searchResult; }); return $searchResult; return \Includes\Utils\ArrayManager::getIndex($this->findAll($key), 0, true); }
/** * processData * * @param array $data Collected data * * @return array */ protected function processData($data) { $stats = $this->stats; foreach ($this->stats as $rownum => $periods) { foreach ($periods as $period => $val) { $stats[$rownum][$period] = is_array($data[$period]) && \Includes\Utils\ArrayManager::getIndex($data[$period], $rownum) ? $data[$period][$rownum][0] : null; } } return $stats; }
/** * getRequestDataByPrefix * * @param string $prefix Index in the request array * @param string $field Name of the field to retrieve OPTIONAL * * @return array|mixed */ protected function getRequestDataByPrefix($prefix, $field = null) { return \Includes\Utils\ArrayManager::getIndex($this->getRequestDataByPrefixArray($prefix), $field); }
/** * Check and add (if needed) core upgrade entry * * @return \XLite\Upgrade\Entry\Core */ protected function checkForCoreUpgrade() { $majorVersion = $this->coreVersion ?: \XLite::getInstance()->getMajorVersion(); $data = \Includes\Utils\ArrayManager::getIndex($this->getCoreVersions(), $majorVersion, true); $result = null; if (is_array($data) && $this->isCoreUpgradeSelected()) { $result = $this->addEntry(self::CORE_IDENTIFIER, 'Core', array_merge(array($majorVersion), $data)); $this->setCoreVersion($majorVersion); } return $result; }
/** * Get module metadata (or only the certain field from it) * * @param string $name Array index * * @return mixed */ protected function getMetadata($name) { return \Includes\Utils\ArrayManager::getIndex($this->metadata, $name, true); }
/** * Getter method for $this->dbOptions * * @return array */ protected static function getDbOptions($name = null) { return \Includes\Utils\ArrayManager::getIndex(static::$dbOptions ?: \Includes\Utils\ConfigParser::getOptions(array('database_details')), $name); }
/** * Return list of registered plugins * * @param string $hook Hook name OPTIONAL * * @return array */ protected static function getPlugins($hook = null) { if (!isset(static::$plugins)) { // Check config file if (\Includes\Utils\FileManager::isFileReadable(static::getConfigFile())) { // Iterate over all sections foreach (parse_ini_file(static::getConfigFile(), true) as $section => $plugins) { // Set plugins order asort($plugins, SORT_NUMERIC); // Save plugins list static::$plugins[$section] = array_fill_keys(array_keys($plugins), null); } } else { \Includes\ErrorHandler::fireError('Unable to read config file for the Decorator plugins'); } } return \Includes\Utils\ArrayManager::getIndex(static::$plugins, $hook); }
/** * Return info about model field * * @param string $field Field name * @param string $param Data param OPTIONAL * * @return array|mixed */ public function getFieldInfo($field, $param = null) { try { $result = $this->getClassMetadata()->getFieldMapping($field); } catch (\Doctrine\ORM\Mapping\MappingException $exception) { $result = $this->getClassMetadata()->getAssociationMapping($field); } return \Includes\Utils\ArrayManager::getIndex($result, $param, null !== $param); }
/** * Returns a description of the selected tab. If no tab is selected, returns NULL. * * @return array */ protected function getSelectedTab() { return \Includes\Utils\ArrayManager::getIndex($this->getTabs(), $this->getCurrentTarget()); }
/** * getPageTemplate * * @return string */ public function getPageTemplate() { return \Includes\Utils\ArrayManager::getIndex($this->getPageTemplates(), $this->getPage()); }
/** * Find node by key * * @param string $key Key to search * * @return array */ public function find($key) { return \Includes\Utils\ArrayManager::getIndex($this->findAll($key), 0, true); }