public function liste_matchs_semaine($groupe) { // On liste les équipes du groupe $query = "SELECT * FROM projet.equipe WHERE id_groupe=? ORDER BY nom"; $equipes = $this->db->query($query, array($groupe)); $equipes = $equipes->result_array(); // $date_day_moins_semaine = new DateTime('last monday'); // $date_day = new DateTime('next monday'); $date_day_moins_semaine = new DateTime('2015-11-30 last monday'); $date_day = new DateTime('2015-11-30 next monday'); // Array qui contiendra tout les matchs du jour $matchs_semaine = array(); // On liste tout les matchs du jour foreach ($equipes as $key => $equipe) { $matchs = $this->liste_matchs($equipe['id_equipe']); // on récupère tout les matchs de l'équipe $nb_match = sizeof($matchs); // On vois le nombre de match sortie foreach ($matchs as $match) { if ($match['date'] >= $date_day_moins_semaine->format('Y-m-d') and $match['date'] <= $date_day->format('Y-m-d')) { // On vérifie que les matchs dates de moins de 1 semaine $matchs_semaine[$match['id_match']] = $match; } } } // Trie du tableau en fonction de la date des matchs foreach ($matchs_semaine as $key => $value) { $lm[$key] = $value['date']; } if (!empty($matchs_semaine)) { array_multisort($lm, SORT_DESC, $matchs_semaine); } return $matchs_semaine; }
/** * Default HTML formatting implementation for error messages * @param $config Configuration array, vital for HTML output nature */ function getHTMLFormatted($config) { $ret = array(); $errors = $this->errors; // sort error array by line // line numbers are enabled if they aren't explicitly disabled if ($config->get('Core', 'MaintainLineNumbers') !== false) { $has_line = array(); $lines = array(); $original_order = array(); foreach ($errors as $i => $error) { $has_line[] = (int) (bool) $error[0]; $lines[] = $error[0]; $original_order[] = $i; } array_multisort($has_line, SORT_DESC, $lines, SORT_ASC, $original_order, SORT_ASC, $errors); } foreach ($errors as $error) { list($line, $severity, $msg) = $error; $string = ''; $string .= '<strong>' . $this->locale->getErrorName($severity) . '</strong>: '; $string .= $this->generator->escape($msg); if ($line) { // have javascript link generation that causes // textarea to skip to the specified line $string .= $this->locale->formatMessage('ErrorCollector: At line', array('line' => $line)); } $ret[] = $string; } if (empty($errors)) { return '<p>' . $this->locale->getMessage('ErrorCollector: No errors') . '</p>'; } else { return '<ul><li>' . implode('</li><li>', $ret) . '</li></ul>'; } }
function sortBySubkey(&$array, $subkey, $sortType = SORT_DESC) { foreach ($array as $subarray) { $keys[] = $subarray[$subkey]; } array_multisort($keys, $sortType, $array); }
public function getMethod($country_id = '', $zone_id = '', $postcode = '') { $this->load->language('payment/free_checkout'); $method_data = array(); $status = FALSE; if ($this->config->get('free_checkout_status')) { $method_data = array(); // Get All taxes, shipping fees, and order totals to be sure the price is still 0.00 $total = 0; $taxes = $this->cart->getTaxes(); $this->load->model('checkout/extension'); $sort_order = array(); $results = $this->model_checkout_extension->getExtensions('total'); foreach ($results as $key => $value) { $sort_order[$key] = $this->config->get($value['key'] . '_sort_order'); } array_multisort($sort_order, SORT_ASC, $results); foreach ($results as $result) { $this->load->model('total/' . $result['key']); $this->{'model_total_' . $result['key']}->getTotal($total_data, $total, $taxes); } if ($total <= 0) { $status = TRUE; } if ($status) { $method_data = array('id' => 'free_checkout', 'title' => $this->language->get('text_title'), 'sort_order' => $this->config->get('free_checkout_sort_order')); } } return $method_data; }
public function form_membership_level($id) { ob_start(); $id = $_POST['id']; $wpm_levels = $this->wlm->GetOption('wpm_levels'); $level = $wpm_levels[$id]; $pages = get_pages('exclude=' . implode(',', $this->wlm->ExcludePages(array(), true))); $pages_options = ''; foreach ((array) $pages as $page) { $pages_options .= '<option value="' . $page->ID . '">' . $page->post_title . '</option>'; } $roles = $GLOBALS['wp_roles']->roles; $caps = array(); foreach ((array) $roles as $key => $role) { if ($role['capabilities']['level_10'] || $role['capabilities']['level_9'] || $role['capabilities']['level_8']) { unset($roles[$key]); } else { list($roles[$key]) = explode('|', $role['name']); $caps[$key] = count($role['capabilities']); } } array_multisort($caps, SORT_ASC, $roles); include $this->wlm->pluginDir . '/resources/forms/edit_membership_level.php'; $str = ob_get_clean(); echo $str; //return $str; die; }
public static function getList($siteId, $arFilter = array(), $arOrder = array()) { if (empty($siteId)) { throw new ArgumentNullException("siteId"); } $arUrlRewrite = static::loadRules($siteId); $arResult = array(); $arResultKeys = self::filterRules($arUrlRewrite, $arFilter); foreach ($arResultKeys as $key) { $arResult[] = $arUrlRewrite[$key]; } if (!empty($arOrder) && !empty($arResult)) { $arOrderKeys = array_keys($arOrder); $orderBy = array_shift($arOrderKeys); $orderDir = $arOrder[$orderBy]; $orderBy = strtoupper($orderBy); $orderDir = strtoupper($orderDir); $orderDir = $orderDir == "DESC" ? SORT_DESC : SORT_ASC; $ar = array(); foreach ($arResult as $key => $row) { $ar[$key] = $row[$orderBy]; } array_multisort($ar, $orderDir, $arResult); } return $arResult; }
/** * Shows the general settings form. * * @param array $variables */ public function actionGeneralSettings(array $variables = array()) { if (empty($variables['info'])) { $variables['info'] = Craft::getInfo(); } // Assemble the timezone options array // (Technique adapted from http://stackoverflow.com/a/7022536/1688568) $variables['timezoneOptions'] = array(); $utc = new DateTime(); $offsets = array(); $timezoneIds = array(); $includedAbbrs = array(); foreach (\DateTimeZone::listIdentifiers() as $timezoneId) { $timezone = new \DateTimeZone($timezoneId); $transition = $timezone->getTransitions($utc->getTimestamp(), $utc->getTimestamp()); $abbr = $transition[0]['abbr']; $offset = round($timezone->getOffset($utc) / 60); if ($offset) { $hour = floor($offset / 60); $minutes = floor(abs($offset) % 60); $format = sprintf('%+d', $hour); if ($minutes) { $format .= ':' . sprintf('%02u', $minutes); } } else { $format = ''; } $offsets[] = $offset; $timezoneIds[] = $timezoneId; $includedAbbrs[] = $abbr; $variables['timezoneOptions'][$timezoneId] = 'UTC' . $format . ($abbr != 'UTC' ? " ({$abbr})" : '') . ($timezoneId != 'UTC' ? ' - ' . $timezoneId : ''); } array_multisort($offsets, $timezoneIds, $variables['timezoneOptions']); $this->renderTemplate('settings/general/index', $variables); }
public static function searchNGram($cuv) { $leng = mb_strlen($cuv); $hash = NGram::searchLexemIds($cuv); if (empty($hash)) { return array(); } arsort($hash); $max = current($hash); $lexIds = array_keys($hash, $max); $results = array(); foreach ($lexIds as $id) { $lexem = Model::factory('Lexem')->where('id', $id)->where_gte('charLength', $leng - self::$LENGTH_DIF)->where_lte('charLength', $leng + self::$LENGTH_DIF)->find_one(); if ($lexem) { $results[] = $lexem; if (count($results) == self::$MAX_RESULTS) { break; } } } // Sort the lexems by their Levenshtein distance from $cuv $distances = array(); foreach ($results as $lexem) { $distances[] = Levenshtein::dist($cuv, $lexem->formNoAccent); } array_multisort($distances, $results); return $results; }
/** * Parses an HTTP header into a weight map, that is an associative array * mapping values to their respective weights. Any header name preceding * weight spec is ignored for convenience. * * This implementation is partially based on the code at * http://www.thefutureoftheweb.com/blog/use-accept-language-header * * Note that type parameters and accept extension like the "level" parameter * are not supported, weights are derived from "q" values only. * * @todo: If additional type parameters are present, ignore them cleanly. * At present, they often confuse the result. * * See HTTP/1.1 section 14 for details. * * @param string $rawHeader * * @return array */ public function parseWeights($rawHeader) { //FIXME: The code below was copied and adapted from WebRequest::getAcceptLang. // Move this utility class into core for reuse! // first, strip header name $rawHeader = preg_replace('/^[-\\w]+:\\s*/', '', $rawHeader); // Return values in lower case $rawHeader = strtolower($rawHeader); // Break up string into pieces (values and q factors) $value_parse = null; preg_match_all('@([a-z\\d*]+([-+/.][a-z\\d*]+)*)\\s*(;\\s*q\\s*=\\s*(1(\\.0{0,3})?|0(\\.\\d{0,3})?)?)?@', $rawHeader, $value_parse); if (!count($value_parse[1])) { return array(); } $values = $value_parse[1]; $qvalues = $value_parse[4]; $indices = range(0, count($value_parse[1]) - 1); // Set default q factor to 1 foreach ($indices as $index) { if ($qvalues[$index] === '') { $qvalues[$index] = 1; } elseif ($qvalues[$index] == 0) { unset($values[$index], $qvalues[$index], $indices[$index]); } else { $qvalues[$index] = (double) $qvalues[$index]; } } // Sort list. First by $qvalues, then by order. Reorder $values the same way array_multisort($qvalues, SORT_DESC, SORT_NUMERIC, $indices, $values); // Create a list like "en" => 0.8 $weights = array_combine($values, $qvalues); return $weights; }
/** * {@inheritdoc} */ protected function getFields(DatagridConfiguration $config) { $entityClassName = $this->entityClassResolver->getEntityClass($this->getEntityName($config)); if (!$this->configManager->hasConfig($entityClassName)) { return []; } $entityConfigProvider = $this->configManager->getProvider('entity'); $extendConfigProvider = $this->configManager->getProvider('extend'); $viewConfigProvider = $this->configManager->getProvider('view'); $datagridConfigProvider = $this->configManager->getProvider('datagrid'); $fields = []; $priorities = []; $fieldIds = $entityConfigProvider->getIds($entityClassName); /** @var FieldConfigId $fieldId */ foreach ($fieldIds as $fieldId) { $extendConfig = $extendConfigProvider->getConfigById($fieldId); if ($extendConfig->is('owner', ExtendScope::OWNER_CUSTOM) && $datagridConfigProvider->getConfigById($fieldId)->is('is_visible') && !$extendConfig->is('state', ExtendScope::STATE_NEW) && !$extendConfig->is('is_deleted')) { $fields[] = $fieldId; $viewConfig = $viewConfigProvider->getConfig($entityClassName, $fieldId->getFieldName()); $priorities[] = $viewConfig->get('priority', false, 0); } } array_multisort($priorities, SORT_DESC, $fields); return $fields; }
public function indexAction() { function deepStrlen($data) { if (is_scalar($data)) { return strlen($data); } else { if (is_array($data)) { $sum = 0; foreach ($data as $k => $v) { $sum += deepStrlen($v); } return $sum; } else { if (is_object($data)) { return 0; } } } } $profile = array(); $sets = array(); $names = array(); foreach ($this->cache_keys as $k => $key) { $profile[$key] = array('set' => $isset = $value = apc_fetch($this->hash . '-' . $key) !== false ? true : false, 'value' => $value, 'size' => $isset ? deepStrlen($value) : 'N/A'); $sets[$k] = $isset; $names[$k] = $key; } array_multisort($sets, SORT_DESC, $names, SORT_ASC, $profile); $this->view->profile = $profile; }
function buildCategories($categories, $parentId) { $childCategories = array(); $ids = array(); foreach ($categories as $category) { if ($category['Category']['cat_parent_id'] == $parentId) { $childCategories[] = $category['Category']; } $ids[$category['Category']['id']] = $category['Category']; } $holdParentId = $parentId; while ($holdParentId != 0) { $parent = array($ids[$holdParentId]); $currentId = $parent[0]['id']; $holdParentId = $ids[$holdParentId]['cat_parent_id']; foreach ($categories as $category) { if ($category['Category']['cat_parent_id'] == $holdParentId && !in_array($category['Category'], $parent)) { $parent[] = $category['Category']; } } array_multisort($parent); $n = count($parent); $childCategories2 = array(); for ($i = 0; $i < $n; $i++) { $childCategories2[] = $parent[$i]; if ($parent[$i]['id'] == $currentId) { $childCategories2 = array_merge($childCategories2, $childCategories); } } $childCategories = $childCategories2; } return $childCategories; }
/** * Returns books in a particular order * @param type $sort_type * @param type $order * @return type */ public function sortBooks($sort_type, $order) { // Obtain a list of columns foreach ($this->books as $key => $row) { $title[$key] = $row['title']; $author[$key] = $row['author']; $date_added[$key] = $row['date_added']; } // Sort the data with volume descending, edition ascending // Add $data as the last parameter, to sort by the common key switch ($sort_type) { case Collections::SORT_TYPE_TITLE: array_multisort($title, $order == SORT_DESC ? SORT_DESC : SORT_ASC, $author, SORT_ASC, $date_added, SORT_DESC, $this->books); break; case Collections::SORT_TYPE_AUTHOR: array_multisort($author, $order == SORT_DESC ? SORT_DESC : SORT_ASC, $title, SORT_ASC, $date_added, SORT_DESC, $this->books); break; case Collections::SORT_TYPE_DATE_ADDED: array_multisort($date_added, $order == SORT_DESC ? SORT_DESC : SORT_ASC, $title, SORT_ASC, $author, SORT_ASC, $this->books); break; default: throw new Exception("Invalid sort type"); } return $this->books; }
public function loadFromCart($c) { $ids = array(); $product_data = array(); if (($cart = Session::get('cart')) != false) { foreach ($cart as $v => $qty) { array_push($ids, $v); } $v = Model::load('ProductVariant'); $id_string = $v->buildUnionString($ids); $product_data = $v->getCartData($id_string); foreach ($product_data as $index => $value) { $id = $value['id']; $price = $value['price']; $qty = $cart[$id]['qty']; $product_data[$index]['qty'] = $qty; $product_data[$index]['line'] = $qty * $price; $product_data[$index]['stamp'] = $cart[$id]['stamp']; } // sort foreach ($product_data as $key => $row) { $stamp[$key] = $row['stamp']; unset($row['stamp']); } array_multisort($stamp, SORT_ASC, $product_data); } return $product_data; }
public function getConnectionsModel($id) { $connid = ""; $connection = ""; $inc = ""; $this->db->select('tbl_messages.id as messageid, tbl_messages.created_on as message_logtime, tbl_messages.message, tbl_ceos.first_name, tbl_ceos.last_name, tbl_ceos.id as msg_ceos_id, tbl_ceos.ceo_profile_pic, tbl_businesses.id as business_id, tbl_businesses.business_name'); $this->db->from('tbl_messages'); $this->db->join('tbl_ceos', 'tbl_ceos.id = tbl_messages.ceo2_id AND tbl_messages.ceo2_id != "' . $id . '" OR tbl_ceos.id = tbl_messages.ceo1_id AND tbl_messages.ceo1_id != "' . $id . '" ', 'left'); $this->db->join('tbl_ceo_business_details', 'tbl_ceo_business_details.ceo_id = tbl_ceos.id', 'left'); $this->db->join('tbl_businesses', 'tbl_businesses.id = tbl_ceo_business_details.business_id', 'left'); $this->db->where("(tbl_messages.ceo1_id = '" . $id . "' OR tbl_messages.ceo2_id = '" . $id . "' )"); $this->db->order_by('tbl_messages.id', 'asc'); $resultss = $this->db->get(); if ($resultss->num_rows() > 0) { foreach ($resultss->result() as $key => $val) { $connection[$val->msg_ceos_id] = $val; } $sortArray = array(); foreach ($connection as $person) { foreach ($person as $key => $value) { if (!isset($sortArray[$key])) { $sortArray[$key] = array(); } $sortArray[$key][] = $value; } } $orderby = "messageid"; //change this to whatever key you want from the array array_multisort($sortArray[$orderby], SORT_DESC, $connection); } return $connection; }
/** * Search configuration files. * @param mixed * @param mixed */ public function addFindConfig($dirs, $exclude = NULL) { $cache = new Caching\Cache(new Caching\Storages\FileStorage($this->getCacheDirectory()), self::Caching); // Search will be started only when the cache does not exist. if (!$cache->load(self::Caching)) { // Search configuration files. foreach (Utils\Finder::findFiles('*.neon')->from($dirs)->exclude($exclude) as $row) { $data[] = $row->getPathname(); } foreach ($data as $row) { $name[] = basename($row); } // Sort found files by number and put into the cache. array_multisort($name, SORT_NUMERIC, $data); if (isset($data)) { $cache->save(self::Caching, $data); } } // Loads the data from the cache. if ($cache->load(self::Caching)) { foreach ($cache->load(self::Caching) as $files) { $this->addConfig($files); } } }
/** * @return array */ function getRows() { array_multisort($this->sortEnabled, $this->sections['enabled']); list($grid, $n_grid_columns) = $this->gridOfDescriptions(); $n = 4 + $n_grid_columns; $rows = array(); foreach ($this->sections as $section_key => $section_rows) { foreach ($section_rows as $row_key => &$row) { $cells =& $row['data']; if (4 === count($cells)) { // Regular row if (isset($grid[$row_key])) { $cells = array_merge($cells, $grid[$row_key]); } else { $cells[] = array('data' => '', 'colspan' => $n_grid_columns); } } elseif (1 === count($cells)) { // Section header row $cells[0]['colspan'] = $n; } } $rows = array_merge($rows, array_values($section_rows)); } return $rows; }
function tags_summary($user_tags) { $result = new stdclass(); $result->tags = array(); $tag_count = array(); $result->tag_list = array(); foreach ($user_tags as $tag) { array_push($result->tags, $tag); if (in_array($tag, $tag_count)) { $tag_count[$tag]++; } else { $tag_count[$tag]++; } } $result->tags = array_unique($result->tags); sort($result->tags); $result->max_frequency = 0; $result->min_frequency = count($user_tags); foreach ($result->tags as $tag) { array_push($result->tag_list, array('term' => $tag, 'freq' => $tag_count[$tag])); $result->max_frequency = max($result->max_frequency, $tag_count[$tag]); $result->min_frequency = min($result->min_frequency, $tag_count[$tag]); } // From PHP manual, we create an array of the serach terms sorted alphabetically // to use to sort the search terms foreach ($result->tag_list as $key => $row) { $terms[$key] = strtolower($row['term']); } array_multisort($terms, SORT_ASC, SORT_STRING, $result->tag_list); return $result; }
public function prepareAWTabs($observer) { $tabsBlock = $observer->getBlock(); if ($tabsBlock instanceof Mage_Adminhtml_Block_System_Config_Tabs) { foreach ($tabsBlock->getTabs() as $tab) { if ($tab->getId() != 'awall' || null === $tab->getSections()) { continue; } $_sections = $tab->getSections()->getItems(); $tab->getSections()->clear(); $_sectionLabelList = array(); $_sectionList = array(); foreach ($_sections as $key => $_section) { if (!in_array($key, array('awstore', 'awall'))) { $_sectionLabelList[] = strtolower(str_replace(' ', '_', $_section->getLabel())); $_sectionList[] = $_section; } } array_multisort($_sectionLabelList, SORT_ASC, SORT_STRING, $_sectionList); foreach ($_sectionList as $_section) { $tab->getSections()->addItem($_section); } if (array_key_exists('awstore', $_sections)) { $tab->getSections()->addItem($_sections['awstore']); } if (array_key_exists('awall', $_sections)) { $tab->getSections()->addItem($_sections['awall']); } } } return $this; }
/** * Returns those of the given domains which match the specified host. * The domains are sorted by their match exactness. * If none really matches an empty array is returned. * * @param string $host The host to match against (eg. "localhost" or "www.neos.io") * @param array<\TYPO3\Neos\Domain\Model\Domain> $domains The domains to check * @return array The matching domains */ public function getSortedMatches($host, array $domains) { $matchingDomains = array(); $matchQualities = array(); $hostPartsReverse = array_reverse(explode('.', $host)); foreach ($domains as $domain) { $hostPattern = $domain->getHostPattern(); if ($host === $hostPattern) { $matchQuality = self::EXACTMATCH; } else { $matchQuality = 0; $hostPatternPartsReverse = array_reverse(explode('.', $hostPattern)); foreach ($hostPatternPartsReverse as $index => $hostPatternPart) { if ($hostPatternPart === '*' || isset($hostPartsReverse[$index]) && $hostPatternPart === $hostPartsReverse[$index]) { $matchQuality++; } else { $matchQuality = self::NOMATCH; break; } } } if ($matchQuality > 0) { $matchingDomains[] = $domain; $matchQualities[] = $matchQuality; } } array_multisort($matchQualities, SORT_DESC, $matchingDomains); return $matchingDomains; }
private function gets() { // Scanning the thumbnail folder for JPG images: $aG = glob(PH7_PATH_PUBLIC_DATA_SYS_MOD . 'webcam/picture/img/thumb/*.jpg'); if (!$aG) { $aG = array(); } // We loop though the file names returned by glob, // and we populate a second file with modifed timestamps. for ($i = 0, $iCount = count($aG); $i < $iCount; $i++) { $this->aPath = explode('/', $aG[$i]); $this->aNames[$i] = array_pop($this->aPath); $this->aModified[$i] = filemtime($aG[$i]); } // Multisort will sort the array with the filenames // according to their timestamps, given in $modified: array_multisort($this->aModified, SORT_DESC, $this->aNames); // browse.php can also paginate results with an optional // GET parameter with the filename of the image to start from: if ($this->oHttpRequest->getExists('start') && strlen($this->oHttpRequest->get('start') > 1)) { $this->mStart = array_search($this->oHttpRequest->get('start'), $this->aNames); if ($this->mStart === false) { // Such a picture was not found $this->mStart = 0; } } if (@$this->aNames[$this->mStart + $this->iPerPage]) { $this->iNextStart = $this->aNames[$this->mStart + $this->iPerPage]; } $this->aNames = array_slice($this->aNames, $this->mStart, $this->iPerPage); }
public function process() { $results = array(); foreach ($this->rows as $row_val) { $search_show_unlinked_results = api_get_setting('search_show_unlinked_results') == 'true'; $course_visible_for_user = api_is_course_visible_for_user(NULL, $row_val['courseid']); // can view course? if ($course_visible_for_user || $search_show_unlinked_results) { // is visible? $visibility = api_get_item_visibility(api_get_course_info($row_val['courseid']), TOOL_DOCUMENT, $row_val['xapian_data'][SE_DATA]['doc_id']); if ($visibility) { list($thumbnail, $image, $name, $author, $url) = $this->get_information($row_val['courseid'], $row_val['xapian_data'][SE_DATA]['doc_id']); $result = array('toolid' => TOOL_DOCUMENT, 'score' => $row_val['score'], 'url' => $url, 'thumbnail' => $thumbnail, 'image' => $image, 'title' => $name, 'author' => $author); if ($course_visible_for_user) { $results[] = $result; } else { // course not visible for user if ($search_show_unlinked_results) { $result['url'] = ''; $results[] = $result; } } } } } // get information to sort foreach ($results as $key => $row) { $score[$key] = $row['score']; } // Sort results with score descending array_multisort($score, SORT_DESC, $results); return $results; }
public function index() { $this->language->load('checkout/checkout'); $this->load->model('account/address'); if ($this->customer->isLogged() && isset($this->session->data['shipping_address_id'])) { $shipping_address = $this->model_account_address->getAddress($this->session->data['shipping_address_id']); } elseif (isset($this->session->data['guest'])) { $shipping_address = $this->session->data['guest']['shipping']; } if (!empty($shipping_address)) { // Shipping Methods $quote_data = array(); $this->load->model('setting/extension'); $results = $this->model_setting_extension->getExtensions('shipping'); foreach ($results as $result) { if ($this->config->get($result['code'] . '_status')) { $this->load->model('shipping/' . $result['code']); $quote = $this->{'model_shipping_' . $result['code']}->getQuote($shipping_address); if ($quote) { $quote_data[$result['code']] = array('title' => $quote['title'], 'quote' => $quote['quote'], 'sort_order' => $quote['sort_order'], 'error' => $quote['error']); } } } $sort_order = array(); foreach ($quote_data as $key => $value) { $sort_order[$key] = $value['sort_order']; } array_multisort($sort_order, SORT_ASC, $quote_data); $this->session->data['shipping_methods'] = $quote_data; } $this->data['text_shipping_method'] = $this->language->get('text_shipping_method'); $this->data['text_comments'] = $this->language->get('text_comments'); $this->data['button_continue'] = $this->language->get('button_continue'); if (empty($this->session->data['shipping_methods'])) { $this->data['error_warning'] = sprintf($this->language->get('error_no_shipping'), $this->url->link('information/contact')); } else { $this->data['error_warning'] = ''; } if (isset($this->session->data['shipping_methods'])) { $this->data['shipping_methods'] = $this->session->data['shipping_methods']; } else { $this->data['shipping_methods'] = array(); } if (isset($this->session->data['shipping_method']['code'])) { $this->data['code'] = $this->session->data['shipping_method']['code']; } else { $this->data['code'] = ''; } if (isset($this->session->data['comment'])) { $this->data['comment'] = $this->session->data['comment']; } else { $this->data['comment'] = ''; } if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/checkout/shipping_method.tpl')) { $this->template = $this->config->get('config_template') . '/template/checkout/shipping_method.tpl'; } else { $this->template = 'default/template/checkout/shipping_method.tpl'; } $this->response->setOutput($this->render()); }
/** * Get dummy callbacks. * @param boolean $shuffled * @return array */ protected function getDummyCallbacks($shuffled = false) { if (empty($this->dummyCallbacks)) { $priority = self::NUM_DUMMY_PRIORITIES; for ($i = 0; $i < self::NUM_DUMMY_CALLBACKS; $i++) { $order = $i % ceil(self::NUM_DUMMY_CALLBACKS / self::NUM_DUMMY_PRIORITIES); if (0 == $order) { $priority--; } $this->dummyCallbacks[] = ['callback' => create_function('', "return '{$priority}.{$order}';"), 'priority' => $priority, 'addIndex' => $order]; } } if ($shuffled) { if (empty($this->shuffledDummyCallbacks)) { $this->shuffledDummyCallbacks = $this->dummyCallbacks; // Shuffle items by shuffling keys. $shufflingKeys = self::getShufflingKeys(); array_multisort($shufflingKeys, $this->shuffledDummyCallbacks); // Correct adding order of items. usort($this->shuffledDummyCallbacks, function ($a, $b) { if ($a['addIndex'] == $b['addIndex']) { return 0; } return $a['addIndex'] < $b['addIndex'] ? -1 : 1; }); } return $this->shuffledDummyCallbacks; } return $this->dummyCallbacks; }
function d3diary_new_base($mydirname, $limit = 0, $offset = 0) { if (preg_match('/[^0-9a-zA-Z_-]/', $mydirname)) { die('Invalid mydirname'); } $constpref = '_MB_' . strtoupper($mydirname); $_enc = _CHARSET; $URL_MOD = XOOPS_URL . "/modules/" . $mydirname; $mytrustdirpath = dirname(dirname(__FILE__)); //include_once "$mytrustdirpath/include.php"; require_once $mytrustdirpath . "/class/d3diaryConf.class.php"; require_once $mytrustdirpath . "/class/photo.class.php"; $d3dConf = D3diaryConf::getInstance($mydirname, 0, "whatsnew"); $func =& $d3dConf->func; $myts =& $d3dConf->myts; $photo =& D3diaryPhoto::getInstance(); $uid = $d3dConf->uid; //$req_uid = $d3dConf->req_uid; // overrided by d3dConf $req_uid = 0; // overrided by d3dConf $entry = $func->get_blist_tstamp($req_uid, $uid, $limit, false, $mytstamp); // dosort = false, byref $mytstamp // random photos $d3dConf->get_new_bids($got_bids); $photo->bids = $got_bids; $photo->readrand_mul($mydirname); foreach ($photo->photos as $i => $_photo) { $entry[$i]['photo'] = $_photo['pid'] . $_photo['ptype']; } unset($photo->photos); // comment counts, newest comments list($yd_comment, $yd_com_key) = $func->get_commentlist(0, $uid, 100, true, true); if (!empty($yd_comment)) { foreach ($yd_comment as $_com) { $i = (int) $_com['bid']; $entry[$i]['com_num'] = (int) $_com['com_num']; } } $ret = array(); if (!empty($entry)) { array_multisort($mytstamp, SORT_DESC, $entry); $i = 0; foreach ($entry as $b => $e) { $entry_temp[$i] = $e; $ret[$i]['description'] = trim($func->substrTarea($e['diary'], $e['dohtml'], 500, true)); $ret[$i]['link'] = $e['url']; $ret[$i]['cname'] = $myts->makeTboxData4Show($e['cname']); $ret[$i]['cat_link'] = $URL_MOD . "/index.php?page=category&cid=" . $e['cid']; $ret[$i]['title'] = $e['title']; $ret[$i]['time'] = $e['tstamp']; $ret[$i]['uid'] = $e['uid']; $ret[$i]['hits'] = $e['view']; $ret[$i]['replies'] = !empty($e['com_num']) ? $e['com_num'] : 0; $ret[$i]['image'] = !empty($e['photo']) ? $URL_MOD . "/upimg/" . $e['photo'] : ""; $ret[$i]['id'] = $e['bid']; $i++; } } return $ret; }
private function alphaID($in, $to_num = false, $pad_up = 3, $passKey = "prephe.ro") { $index = "abcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"; $i = []; $p = []; if ($passKey !== null) { // Although this function's purpose is to just make the // ID short - and not so much secure, // with this patch by Simon Franz (http://blog.snaky.org/) // you can optionally supply a password to make it harder // to calculate the corresponding numeric ID for ($n = 0; $n < strlen($index); $n++) { $i[] = substr($index, $n, 1); } $passhash = hash('sha256', $passKey); $passhash = strlen($passhash) < strlen($index) ? hash('sha512', $passKey) : $passhash; for ($n = 0; $n < strlen($index); $n++) { $p[] = substr($passhash, $n, 1); } array_multisort($p, SORT_DESC, $i); $index = implode($i); } $base = strlen($index); if ($to_num) { // Digital number <<-- alphabet letter code $in = strrev($in); $out = 0; $len = strlen($in) - 1; for ($t = 0; $t <= $len; $t++) { $bcpow = bcpow($base, $len - $t); $out = $out + strpos($index, substr($in, $t, 1)) * $bcpow; } if (is_numeric($pad_up)) { $pad_up--; if ($pad_up > 0) { $out -= pow($base, $pad_up); } } $out = sprintf('%F', $out); $out = substr($out, 0, strpos($out, '.')); } else { // Digital number -->> alphabet letter code if (is_numeric($pad_up)) { $pad_up--; if ($pad_up > 0) { $in += pow($base, $pad_up); } } $out = ""; for ($t = floor(log($in, $base)); $t >= 0; $t--) { $bcp = bcpow($base, $t); $a = floor($in / $bcp) % $base; $out = $out . substr($index, $a, 1); $in = $in - $a * $bcp; } $out = strrev($out); // reverse } return $out; }
private function _splitToTokens() { $content = $this->_doc_content; $tmp = array(); $tmp2 = array(); $slength = array(); $content = str_replace(".", " ", $content); $tmp = explode(" ", $content); foreach ($tmp as $word) { // let's count only words with more then 4 chars if (mb_strlen($word, $this->_charset) > 3) { $tmp2[$word] = $word; $slength[$word] = strlen($word); } } array_multisort($slength, SORT_DESC, $tmp2, SORT_ASC); $count = count($slength); // Save only top15 (by length) sentences/words for ($i = 0; $i < $count && $i < 15; $i++) { $this->_tokens[] = current($tmp2); next($tmp2); } $this->length = count($this->_tokens); return $this; }
public function consultarNotificacionJSONAction() { $notificacionDao = new NotificacionSistemaDao($this->getDoctrine()); $notificacion = $notificacionDao->getNotiSistema(); $numfilas = count($notificacion); $aux = new NotificacionSistema(); $i = 0; foreach ($notificacion as $aux) { $rows[$i]['id'] = $aux->getCodNoti(); $rows[$i]['cell'] = array($aux->getCodNoti(), $aux->getNombreNoti(), $aux->getMensajeNoti(), $aux->getTipoMensajeNoti()); $i++; } if ($numfilas != 0) { array_multisort($rows, SORT_ASC); } else { $rows[0]['id'] = 0; $rows[0]['cell'] = array(' ', ' ', ' ', ' '); } $datos = json_encode($rows); $pages = floor($numfilas / 10) + 1; $jsonresponse = '{ "page":"1", "total":"' . $pages . '", "records":"' . $numfilas . '", "rows":' . $datos . '}'; $response = new Response($jsonresponse); return $response; }
public function index() { $this->load->model('design/layout'); $this->load->model('catalog/category'); $this->load->model('catalog/product'); $this->load->model('catalog/information'); if (isset($this->request->get['route'])) { $route = (string) $this->request->get['route']; } else { $route = 'common/home'; } $layout_id = 0; if ($route == 'product/category' && isset($this->request->get['path'])) { $path = explode('_', (string) $this->request->get['path']); $layout_id = $this->model_catalog_category->getCategoryLayoutId(end($path)); } if ($route == 'product/product' && isset($this->request->get['product_id'])) { $layout_id = $this->model_catalog_product->getProductLayoutId($this->request->get['product_id']); } if ($route == 'information/information' && isset($this->request->get['information_id'])) { $layout_id = $this->model_catalog_information->getInformationLayoutId($this->request->get['information_id']); } if (!$layout_id) { $layout_id = $this->model_design_layout->getLayout($route); } if (!$layout_id) { $layout_id = $this->config->get('config_layout_id'); } $module_data = array(); $this->load->model('setting/extension'); $extensions = $this->model_setting_extension->getExtensions('module'); foreach ($extensions as $extension) { $modules = $this->config->get($extension['code'] . '_module'); if ($modules) { foreach ($modules as $module) { if ($module['layout_id'] == $layout_id && $module['position'] == 'header_top' && $module['status']) { $module_data[] = array('code' => $extension['code'], 'setting' => $module, 'sort_order' => $module['sort_order']); } } } } $sort_order = array(); foreach ($module_data as $key => $value) { $sort_order[$key] = $value['sort_order']; } array_multisort($sort_order, SORT_ASC, $module_data); $this->data['modules'] = array(); foreach ($module_data as $module) { $module = $this->getChild('module/' . $module['code'], $module['setting']); if ($module) { $this->data['modules'][] = $module; } } if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/common/header_top.tpl')) { $this->template = $this->config->get('config_template') . '/template/common/header_top.tpl'; } else { $this->template = 'default/template/common/header_top.tpl'; } $this->render(); }
function getPropertiesSortedByPriority() { $properties = $this->_properties; $priorities = $this->_priorities; array_multisort($priorities, $properties); return $properties; }