/** * Get actions * * @return array */ public function getActions() { uasort($this->actions, function ($a, $b) { return strnatcasecmp($a['label'], $b['label']); }); return $this->actions; }
public function checkFilters($filters) { // Get the admin filter $adminFilter['admin'] = $filters['admin']; unset($filters['admin']); // Sort filters by length uasort($filters, array($this, 'sortByLength')); // Push the admin filter first $filters = $adminFilter + $filters; $this->filters = $filters; foreach ($filters as $filterName => $filterURI) { // $slug will be FALSE if the filter is not included in the URI. $slug = $this->getSlugAfterFilter($filterURI); if ($slug !== false) { $this->slug = $slug; $this->whereAmI = $filterName; // If the slug is empty if (Text::isEmpty($slug)) { if ($filterURI === '/') { $this->whereAmI = 'home'; break; } if ($filterURI === $adminFilter['admin']) { $this->whereAmI = 'admin'; $this->slug = 'dashboard'; break; } $this->setNotFound(true); } break; } } }
function qa_sort_by(&$array, $by1, $by2 = null) { global $qa_sort_by_1, $qa_sort_by_2; $qa_sort_by_1 = $by1; $qa_sort_by_2 = $by2; uasort($array, 'qa_sort_by_fn'); }
/** * Convert credit cards xml tree to array * * @param \DOMXPath $xpath * @return array */ protected function convertCreditCards(\DOMXPath $xpath) { $creditCards = []; /** @var \DOMNode $type */ foreach ($xpath->query('/payment/adyen_credit_cards/type') as $type) { $typeArray = []; /** @var $typeSubNode \DOMNode */ foreach ($type->childNodes as $typeSubNode) { switch ($typeSubNode->nodeName) { case 'label': $typeArray['name'] = $typeSubNode->nodeValue; break; case 'code_alt': $typeArray['code_alt'] = $typeSubNode->nodeValue; default: break; } } $typeAttributes = $type->attributes; $typeArray['order'] = $typeAttributes->getNamedItem('order')->nodeValue; $ccId = $typeAttributes->getNamedItem('id')->nodeValue; $creditCards[$ccId] = $typeArray; } uasort($creditCards, [$this, '_compareCcTypes']); $config = []; foreach ($creditCards as $code => $data) { $config[$code] = $data; } return $config; }
public function getFieldsets() { $hlp = Mage::helper('udropship'); $visible = Mage::getStoreConfig('udropship/vendor/visible_preferences'); $visible = $visible ? explode(',', $visible) : false; $fieldsets = array(); $fieldsets['account'] = array('position' => 0, 'legend' => 'Account Information', 'fields' => array('vendor_name' => array('position' => 1, 'name' => 'vendor_name', 'type' => 'text', 'label' => 'Vendor Name'), 'vendor_attn' => array('position' => 2, 'name' => 'vendor_attn', 'type' => 'text', 'label' => 'Attention To'), 'subdomain' => array('position' => 2, 'name' => 'subdomain', 'type' => 'text', 'label' => 'Subdomain'), 'email' => array('position' => 3, 'name' => 'email', 'type' => 'text', 'label' => 'Email Address / Login'), 'password' => array('position' => 4, 'name' => 'password', 'type' => 'text', 'label' => 'Login Password'), 'telephone' => array('position' => 5, 'name' => 'telephone', 'type' => 'text', 'label' => 'Telephone'))); $countries = Mage::getModel('adminhtml/system_config_source_country')->toOptionArray(); $countryId = Mage::registry('vendor_data') ? Mage::registry('vendor_data')->getCountryId() : null; if (!$countryId) { $countryId = Mage::getStoreConfig('general/country/default'); } $regionCollection = Mage::getModel('directory/region')->getCollection()->addCountryFilter($countryId); $regions = $regionCollection->toOptionArray(); if ($regions) { $regions[0]['label'] = $hlp->__('Please select state...'); } else { $regions = array(array('value' => '', 'label' => '')); } $fieldsets['shipping_origin'] = array('position' => 1, 'legend' => 'Shipping Origin Address', 'fields' => array('street' => array('position' => 1, 'name' => 'street', 'type' => 'textarea', 'label' => 'Street'), 'limit_zipcode' => array('position' => 1, 'name' => 'limit_zipcode', 'type' => 'textarea', 'label' => 'Zipcodes'), 'city' => array('position' => 2, 'name' => 'city', 'type' => 'text', 'label' => 'City'), 'zip' => array('position' => 3, 'name' => 'zip', 'type' => 'text', 'label' => 'Zip / Postal code'), 'country_id' => array('position' => 4, 'name' => 'country_id', 'type' => 'select', 'label' => 'Country', 'options' => $countries), 'region_id' => array('position' => 5, 'name' => 'region_id', 'type' => 'select', 'label' => 'State', 'options' => $regions))); $_v = Mage::getSingleton('udropship/session')->getVendor(); $hlp = Mage::helper('udropship'); $fieldsets['delivery_time'] = array('position' => 2, 'legend' => 'Delivery Time', 'fields' => array('cut_off_time' => array('position' => 1, 'name' => 'cut_off_time', 'type' => 'text', 'label' => 'Cut Off Time', 'note' => 'It must be in (24 hour format). <br/>'), 'non_working_days' => array('position' => 2, 'name' => 'non_working_days', 'type' => 'multiselect', 'label' => 'Non Delivery Days', 'options' => array(array('label' => 'Monday', 'value' => 'Monday'), array('label' => 'Tuesday', 'value' => 'Tuesday'), array('label' => 'Wednesday', 'value' => 'Wednesday'), array('label' => 'Thursday', 'value' => 'Thursday'), array('label' => 'Friday', 'value' => 'Friday'), array('label' => 'Saturday', 'value' => 'Saturday'), array('label' => 'Sunday', 'value' => 'Sunday'))))); $fieldsets['delivery_charge'] = array('position' => 3, 'legend' => 'Delivery Charge', 'fields' => array('delivery_charge' => array('position' => 1, 'name' => 'delivery_charge', 'type' => 'text', 'label' => 'Delivery Charge'))); $fieldsets['social_accounts'] = array('position' => 4, 'legend' => 'Google Reference', 'fields' => array('google_reference' => array('position' => 1, 'name' => 'google_reference', 'type' => 'text', 'label' => 'Google Reference ID'))); Mage::dispatchEvent('udropship_vendor_front_preferences', array('fieldsets' => &$fieldsets)); uasort($fieldsets, array($hlp, 'usortByPosition')); foreach ($fieldsets as $k => $v) { if (empty($v['fields'])) { continue; } uasort($v['fields'], array($hlp, 'usortByPosition')); } return $fieldsets; }
protected function collectBundles() { $finder = new Finder(); $bundles = array(); $finder->files()->followLinks()->in(array($this->getRootDir() . '/../src', $this->getRootDir() . '/../vendor'))->name('bundles.yml'); foreach ($finder as $file) { $import = Yaml::parse($file->getRealpath()); foreach ($import['bundles'] as $bundle) { $kernel = false; $priority = 0; if (is_array($bundle)) { $class = $bundle['name']; $kernel = isset($bundle['kernel']) && true == $bundle['kernel']; $priority = isset($bundle['priority']) ? (int) $bundle['priority'] : 0; } else { $class = $bundle; } if (!isset($bundles[$class])) { $bundles[$class] = array('name' => $class, 'kernel' => $kernel, 'priority' => $priority); } } } uasort($bundles, array($this, 'compareBundles')); return $bundles; }
/** * {@inheritdoc} */ public function getDerivativeDefinitions($base_plugin_definition) { $base_plugin_id = $base_plugin_definition['id']; try { /** @var \Drupal\Core\Entity\EntityStorageInterface $views_storage */ $views_storage = $this->entityTypeManager->getStorage('view'); $all_views = $views_storage->loadMultiple(); } catch (PluginNotFoundException $e) { return []; } if (!isset($this->derivatives[$base_plugin_id])) { $plugin_derivatives = array(); /** @var \Drupal\views\Entity\View $view */ foreach ($all_views as $view) { // Hardcoded usage of Search API views, for now. if (strpos($view->get('base_table'), 'search_api_index') !== FALSE) { $displays = $view->get('display'); foreach ($displays as $display_id => $display_info) { // We only support pages and blocks because those are the ones that // we've tested. They are also the only ones that support for // ::isRenderedInCurrentRequest() and ::getPath(). if (in_array($display_info['display_plugin'], ['page', 'block'])) { $machine_name = $view->id() . PluginBase::DERIVATIVE_SEPARATOR . $display_id; $label_arguments = ['%view_name' => $view->label(), '%display_title' => $display_info['display_title'], '%display_type' => $display_info['display_plugin']]; $plugin_derivatives[$machine_name] = ['id' => $base_plugin_id . PluginBase::DERIVATIVE_SEPARATOR . $machine_name, 'label' => $this->t('Search API view: %view_name, display: %display_title (%display_type)', $label_arguments), 'description' => $this->t('Provides a facet source.'), 'view_id' => $view->id(), 'view_display' => $display_id] + $base_plugin_definition; $sources[] = $this->t('Search API view: %view, display: %display', ['%view' => $view->label(), '%display' => $display_info['display_title']]); } } } } uasort($plugin_derivatives, array($this, 'compareDerivatives')); $this->derivatives[$base_plugin_id] = $plugin_derivatives; } return $this->derivatives[$base_plugin_id]; }
/** * Constructor. */ public function __construct() { add_action('wp', array($this, 'process')); $this->steps = (array) apply_filters('submit_job_steps', array('submit' => array('name' => __('Submit Details', 'wp-job-manager'), 'view' => array($this, 'submit'), 'handler' => array($this, 'submit_handler'), 'priority' => 10), 'preview' => array('name' => __('Preview', 'wp-job-manager'), 'view' => array($this, 'preview'), 'handler' => array($this, 'preview_handler'), 'priority' => 20), 'done' => array('name' => __('Done', 'wp-job-manager'), 'view' => array($this, 'done'), 'priority' => 30))); uasort($this->steps, array($this, 'sort_by_priority')); // Get step/job if (isset($_POST['step'])) { $this->step = is_numeric($_POST['step']) ? max(absint($_POST['step']), 0) : array_search($_POST['step'], array_keys($this->steps)); } elseif (!empty($_GET['step'])) { $this->step = is_numeric($_GET['step']) ? max(absint($_GET['step']), 0) : array_search($_GET['step'], array_keys($this->steps)); } $this->job_id = !empty($_REQUEST['job_id']) ? absint($_REQUEST['job_id']) : 0; // Allow resuming from cookie. if (!$this->job_id && !empty($_COOKIE['wp-job-manager-submitting-job-id']) && !empty($_COOKIE['wp-job-manager-submitting-job-key'])) { $job_id = absint($_COOKIE['wp-job-manager-submitting-job-id']); $job_status = get_post_status($job_id); if ('preview' === $job_status && get_post_meta($job_id, '_submitting_key', true) === $_COOKIE['wp-job-manager-submitting-job-key']) { $this->job_id = $job_id; } } // Load job details if ($this->job_id) { $job_status = get_post_status($this->job_id); if ('expired' === $job_status) { if (!job_manager_user_can_edit_job($this->job_id)) { $this->job_id = 0; $this->step = 0; } } elseif (!in_array($job_status, apply_filters('job_manager_valid_submit_job_statuses', array('preview')))) { $this->job_id = 0; $this->step = 0; } } }
private function buildTypeMap($paths) { global $prefs; $cacheKey = 'fieldtypes.' . $prefs['language']; if ($this->getPreCacheTypeMap()) { return; } $cachelib = TikiLib::lib('cache'); if ($data = $cachelib->getSerialized($cacheKey)) { $this->typeMap = $data['typeMap']; $this->infoMap = $data['infoMap']; $this->setPreCacheTypeMap($data); return; } foreach ($paths as $path => $prefix) { foreach (glob("{$path}/*.php") as $file) { if ($file === "{$path}/index.php") { continue; } $class = $prefix . substr($file, strlen($path) + 1, -4); $reflected = new ReflectionClass($class); if ($reflected->isInstantiable() && $reflected->implementsInterface('Tracker_Field_Interface')) { $providedFields = call_user_func(array($class, 'getTypes')); foreach ($providedFields as $key => $info) { $this->typeMap[$key] = $class; $this->infoMap[$key] = $info; } } } } uasort($this->infoMap, array($this, 'compareName')); $data = array('typeMap' => $this->typeMap, 'infoMap' => $this->infoMap); $cachelib->cacheItem($cacheKey, serialize($data)); $this->setPreCacheTypeMap($data); }
/** * [geRest get a list of Rest Resouces]. * * @param bool $rest_status return Rest Resources by status * * @return array list of rest resources */ public function getRestResources($rest_status = false) { $config = $this->getRestDrupalConfig(); $resourcePluginManager = $this->getPluginManagerRest(); $resources = $resourcePluginManager->getDefinitions(); $enabled_resources = array_combine(array_keys($config), array_keys($config)); $available_resources = array('enabled' => array(), 'disabled' => array()); foreach ($resources as $id => $resource) { $status = in_array($id, $enabled_resources) ? 'enabled' : 'disabled'; $available_resources[$status][$id] = $resource; } // Sort the list of resources by label. $sort_resources = function ($resource_a, $resource_b) { return strcmp($resource_a['label'], $resource_b['label']); }; if (!empty($available_resources['enabled'])) { uasort($available_resources['enabled'], $sort_resources); } if (!empty($available_resources['disabled'])) { uasort($available_resources['disabled'], $sort_resources); } if (isset($available_resources[$rest_status])) { return array($rest_status => $available_resources[$rest_status]); } return $available_resources; }
protected function _beforeToHtml() { $categoryData = Mage::helper('M2ePro/Data_Global')->getValue('chooser_data'); $specificBlocks = array(); $templates = array(); $uniqueIdCounter = 0; if (!empty($categoryData['templates'])) { foreach ($categoryData['templates'] as $template) { $uniqueId = 'sb' . $uniqueIdCounter; $specificBlocks[] = array('create_date' => $template['date'], 'template_id' => $template['id'], 'unique_id' => $uniqueId, 'block' => $this->createSpecificsBlock(array(), $uniqueId)); $uniqueIdCounter++; } } else { $specificsSets = $this->getSpecificsSets(); uasort($specificsSets, array($this, 'specificsSetsSortCallback')); foreach ($specificsSets as $templateId => $specificsSet) { $uniqueId = 'sb' . $uniqueIdCounter; $date = $specificsSet['create_date']->format('Y-m-d h:i'); $templates[] = array('id' => $templateId, 'date' => $date); $specificBlocks[] = array('create_date' => $date, 'template_id' => $templateId, 'unique_id' => $uniqueId, 'block' => $this->createSpecificsBlock($specificsSet['specifics'], $uniqueId)); $uniqueIdCounter++; } } $this->templates = $templates; $this->specificsBlocks = $specificBlocks; return parent::_beforeToHtml(); }
/** * {@inheritDoc} */ public function process(ContainerBuilder $container) { if (!$container->hasParameter($this->connections)) { return; } $this->container = $container; $this->connections = $container->getParameter($this->connections); $sortFunc = function ($a, $b) { $a = isset($a['priority']) ? $a['priority'] : 0; $b = isset($b['priority']) ? $b['priority'] : 0; return $a > $b ? -1 : 1; }; $subscribersPerCon = $this->groupByConnection($container->findTaggedServiceIds($this->tagPrefix . '.event_subscriber')); foreach ($subscribersPerCon as $con => $subscribers) { $em = $this->getEventManager($con); uasort($subscribers, $sortFunc); foreach ($subscribers as $id => $instance) { $em->addMethodCall('addEventSubscriber', array(new Reference($id))); } } $listenersPerCon = $this->groupByConnection($container->findTaggedServiceIds($this->tagPrefix . '.event_listener'), true); foreach ($listenersPerCon as $con => $listeners) { $em = $this->getEventManager($con); uasort($listeners, $sortFunc); foreach ($listeners as $id => $instance) { $em->addMethodCall('addEventListener', array(array_unique($instance['event']), isset($instance['lazy']) && $instance['lazy'] ? $id : new Reference($id))); } } }
/** * Return JS configuration of the htmlArea plugins registered by the extension * * @return string JS configuration for registered plugins */ public function buildJavascriptConfiguration() { $schema = array('types' => array(), 'properties' => array()); // Parse configured schemas if (is_array($this->configuration['thisConfig']['schema.']) && is_array($this->configuration['thisConfig']['schema.']['sources.'])) { foreach ($this->configuration['thisConfig']['schema.']['sources.'] as $source) { $fileName = trim($source); $absolutePath = GeneralUtility::getFileAbsFileName($fileName); // Fallback to default schema file if configured file does not exists or is of zero size if (!$fileName || !file_exists($absolutePath) || !filesize($absolutePath)) { $fileName = 'EXT:' . $this->extensionKey . '/Resources/Public/Rdf/MicrodataSchema/SchemaOrgAll.rdf'; } $fileName = $this->getFullFileName($fileName); $rdf = file_get_contents($fileName); if ($rdf) { $this->parseSchema($rdf, $schema); } } } uasort($schema['types'], array($this, 'compareLabels')); uasort($schema['properties'], array($this, 'compareLabels')); // Insert no type and no property entries $languageService = $this->getLanguageService(); $noSchema = $languageService->sL('LLL:EXT:rtehtmlarea/Resources/Private/Language/Plugins/MicrodataSchema/locallang.xlf:No type'); $noProperty = $languageService->sL('LLL:EXT:rtehtmlarea/Resources/Private/Language/Plugins/MicrodataSchema/locallang.xlf:No property'); array_unshift($schema['types'], array('name' => 'none', 'label' => $noSchema)); array_unshift($schema['properties'], array('name' => 'none', 'label' => $noProperty)); // Store json encoded array in temporary file return 'RTEarea[editornumber].schemaUrl = "' . $this->writeTemporaryFile('schema_' . $this->configuration['language'], 'js', json_encode($schema)) . '";'; }
/** * @return array */ public function getNavigation() { //$this->setActiveElements(); $return = []; foreach ($this->pages as $block => $blockPages) { if (is_array($blockPages) && count($blockPages) > 0 && $blockPages[0] instanceof rex_be_page_main) { uasort($blockPages, function (rex_be_page_main $a, rex_be_page_main $b) { $a_prio = (int) $a->getPrio(); $b_prio = (int) $b->getPrio(); if ($a_prio == $b_prio || $a_prio <= 0 && $b_prio <= 0) { return strcmp($a->getTitle(), $b->getTitle()); } if ($a_prio <= 0) { return 1; } if ($b_prio <= 0) { return -1; } return $a_prio > $b_prio ? 1 : -1; }); } $n = $this->_getNavigation($blockPages); if (count($n) > 0) { $fragment = new rex_fragment(); $fragment->setVar('navigation', $n, false); $return[] = ['navigation' => $n, 'headline' => ['title' => $this->getHeadline($block)]]; } } return $return; }
public function dump_export_data() { if ($this->exporter->get('viewexportmode') == PluginExport::EXPORT_LIST_OF_VIEWS && $this->exporter->get('artefactexportmode') == PluginExport::EXPORT_ARTEFACTS_FOR_VIEWS) { // Dont' care about profile information in this case return; } $smarty = $this->exporter->get_smarty('../../', 'internal'); $smarty->assign('page_heading', get_string('profilepage', 'artefact.internal')); // Profile page $profileviewid = $this->exporter->get('user')->get_profile_view()->get('id'); foreach ($this->exporter->get('views') as $viewid => $view) { if ($profileviewid == $viewid) { $smarty->assign('breadcrumbs', array(array('text' => 'Profile page', 'path' => 'profilepage.html'))); $view = $this->exporter->get('user')->get_profile_view(); $outputfilter = new HtmlExportOutputFilter('../../'); $smarty->assign('view', $outputfilter->filter($view->build_columns())); $content = $smarty->fetch('export:html/internal:profilepage.tpl'); if (!file_put_contents($this->fileroot . 'profilepage.html', $content)) { throw new SystemException("Unable to write profile page"); } $this->profileviewexported = true; break; } } // Generic profile information $smarty->assign('page_heading', get_string('profileinformation', 'artefact.internal')); $smarty->assign('breadcrumbs', array(array('text' => 'Profile information', 'path' => 'index.html'))); // Organise profile information by sections, ordered how it's ordered // on the 'edit profile' page $sections = array('aboutme' => array(), 'contact' => array(), 'messaging' => array(), 'general' => array()); $elementlist = call_static_method('ArtefactTypeProfile', 'get_all_fields'); $elementlistlookup = array_flip(array_keys($elementlist)); $profilefields = get_column_sql('SELECT id FROM {artefact} WHERE owner=? AND artefacttype IN (' . join(",", array_map(create_function('$a', 'return db_quote($a);'), array_keys($elementlist))) . ")", array($this->exporter->get('user')->get('id'))); foreach ($profilefields as $id) { $artefact = artefact_instance_from_id($id); $rendered = $artefact->render_self(array('link' => true)); if ($artefact->get('artefacttype') == 'introduction') { $outputfilter = new HtmlExportOutputFilter('../../'); $rendered['html'] = $outputfilter->filter($rendered['html']); } $sections[$this->get_category_for_artefacttype($artefact->get('artefacttype'))][$artefact->get('artefacttype')] = array('html' => $rendered['html'], 'weight' => $elementlistlookup[$artefact->get('artefacttype')]); } // Sort the data and then drop the weighting information foreach ($sections as &$section) { uasort($section, create_function('$a, $b', 'return $a["weight"] > $b["weight"];')); foreach ($section as &$data) { $data = $data['html']; } } $smarty->assign('sections', $sections); $iconid = $this->exporter->get('user')->get('profileicon'); if ($iconid) { $icon = artefact_instance_from_id($iconid); $smarty->assign('icon', '<img src="../../static/profileicons/200px-' . PluginExportHtml::sanitise_path($icon->get('title')) . '" alt="Profile Icon">'); } $content = $smarty->fetch('export:html/internal:index.tpl'); if (!file_put_contents($this->fileroot . 'index.html', $content)) { throw new SystemException("Unable to write profile information page"); } }
public function checkFilters($filters) { // Get the admin filter $adminFilter['admin'] = $filters['admin']; unset($filters['admin']); // Sort by filter length uasort($filters, array($this, 'sortByLength')); // Push the admin filter first $filters = $adminFilter + $filters; $this->filters = $filters; foreach ($filters as $filterKey => $filter) { // getSlugAfterFilter() set the variable $this->slug $slug = $this->getSlugAfterFilter($filter); // If the filter is included in the URI. if ($slug !== false) { // Where Am I is the filter now, because is in the URI. $this->whereAmI = $filterKey; // If the slug empty if (empty($slug)) { if ($filter === '/') { $this->whereAmI = 'home'; break; } if ($filter === $adminFilter['admin']) { $this->whereAmI = 'admin'; $this->slug = 'dashboard'; break; } $this->setNotFound(true); } break; } } }
/** * Return the terms for the given type. * * @param int $site_id Blog ID. * * @return array */ public function get_terms_for_site($site_id) { $out = []; switch_to_blog($site_id); $taxonomy_object = get_taxonomy($this->taxonomy_name); if (!current_user_can($taxonomy_object->cap->edit_terms)) { $terms = []; } else { $terms = get_terms($this->taxonomy_name, ['hide_empty' => FALSE]); } foreach ($terms as $term) { if (is_taxonomy_hierarchical($this->taxonomy_name)) { $ancestors = get_ancestors($term->term_id, $this->taxonomy_name); if (!empty($ancestors)) { foreach ($ancestors as $ancestor) { $parent_term = get_term($ancestor, $this->taxonomy_name); $term->name = $parent_term->name . '/' . $term->name; } } } $out[$term->term_taxonomy_id] = esc_html($term->name); } restore_current_blog(); uasort($out, 'strcasecmp'); return $out; }
/** * Registers node routes */ public function onRequest() { $site = App::module('system/site'); $frontpage = $site->config('frontpage'); $nodes = Node::findAll(true); uasort($nodes, function ($a, $b) { return strcmp(substr_count($a->path, '/'), substr_count($b->path, '/')) * -1; }); foreach ($nodes as $node) { if ($node->status !== 1 || !($type = $site->getType($node->type))) { continue; } $type = array_replace(['alias' => '', 'redirect' => '', 'controller' => ''], $type); $type['defaults'] = array_merge(isset($type['defaults']) ? $type['defaults'] : [], $node->get('defaults', []), ['_node' => $node->id]); $type['path'] = $node->path; $route = null; if ($node->get('alias')) { App::routes()->alias($node->path, $node->link, $type['defaults']); } elseif ($node->get('redirect')) { App::routes()->redirect($node->path, $node->get('redirect'), $type['defaults']); } elseif ($type['controller']) { App::routes()->add($type); } if (!$frontpage && isset($type['frontpage']) && $type['frontpage']) { $frontpage = $node->id; } } if ($frontpage && isset($nodes[$frontpage])) { App::routes()->alias('/', $nodes[$frontpage]->link); } else { App::routes()->get('/', function () { return __('No Frontpage assigned.'); }); } }
/** * @see CacheBuilder::getData() */ public function getData($cacheResource) { list($cache, $packageID, $languageIDs) = explode('-', $cacheResource['cache']); $data = array(); // get all taggable types $sql = "SELECT\t\ttaggable.taggableID, taggable.name\n\t\t\tFROM\t\twcf" . WCF_N . "_package_dependency package_dependency,\n\t\t\t\t\twcf" . WCF_N . "_tag_taggable taggable\n\t\t\tWHERE \t\ttaggable.packageID = package_dependency.dependency\n\t\t\t\t\tAND package_dependency.packageID = " . $packageID . "\n\t\t\tORDER BY\tpackage_dependency.priority"; $result = WCF::getDB()->sendQuery($sql); $itemIDs = array(); while ($row = WCF::getDB()->fetchArray($result)) { $itemIDs[$row['name']] = $row['taggableID']; } if (count($itemIDs) > 0) { // get tag ids $tagIDs = array(); $sql = "SELECT\t\tCOUNT(*) AS counter, object.tagID\n\t\t\t\tFROM \t\twcf" . WCF_N . "_tag_to_object object\n\t\t\t\tWHERE \t\tobject.taggableID IN (" . implode(',', $itemIDs) . ")\n\t\t\t\t\t\tAND object.languageID IN (" . $languageIDs . ")\n\t\t\t\tGROUP BY \tobject.tagID\n\t\t\t\tORDER BY \tcounter DESC"; $result = WCF::getDB()->sendQuery($sql, 500); while ($row = WCF::getDB()->fetchArray($result)) { $tagIDs[$row['tagID']] = $row['counter']; } // get tags if (count($tagIDs)) { $sql = "SELECT\t\tname, tagID\n\t\t\t\t\tFROM\t\twcf" . WCF_N . "_tag\n\t\t\t\t\tWHERE\t\ttagID IN (" . implode(',', array_keys($tagIDs)) . ")"; $result = WCF::getDB()->sendQuery($sql); while ($row = WCF::getDB()->fetchArray($result)) { $row['counter'] = $tagIDs[$row['tagID']]; $this->tags[StringUtil::toLowerCase($row['name'])] = new Tag(null, $row); } // sort by counter uasort($this->tags, array('self', 'compareTags')); $data = $this->tags; } } return $data; }
/** * Render sql select orders * * @return Mana_Db_Resource_Entity_JsonCollection */ protected function _renderOrders() { if (count($this->_orders)) { uasort($this->_data, array($this, '_compareItems')); } return $this; }
/** * Get events. * * @return array */ public function getEvents() { uasort($this->events, function ($a, $b) { return strnatcasecmp($a['label'], $b['label']); }); return $this->events; }
public function delayedPrepareLayout() { $this->_headerText = $this->getTitle(); /* @var $pageHelper Mana_Admin_Helper_Page */ $pageHelper = Mage::helper('mana_admin/page'); /* @var $left Mage_Adminhtml_Block_Text_List */ $left = $this->getLayout()->getBlock('left'); $tabs = $this->getChildGroup('tabs'); uasort($tabs, array($pageHelper, 'compareBySortOrder')); if (count($tabs)) { /* @var $tabsBlock Mana_Admin_Block_Tabs */ $tabsBlock = $this->getLayout()->createBlock('mana_admin/tabs', 'tabs'); $activeTabId = null; foreach ($tabs as $tabId => $tab) { $tab->setTabId($tabId); $tabsBlock->addTabBlock($tabId, $tab); if (!$activeTabId) { $activeTabId = $tabId; } } $tabsBlock->setActiveTab($activeTabId)->setDestElementId('tab-content'); $left->insert($tabsBlock); } // create client-side block $this->_prepareClientSideBlock(); return $this; }
public static function load() { global $Settings; if (is_array(self::$Modules) && count(self::$Modules)) { return; } // Load the various modules (search for the "tv" subdirectory in case it might // find some other "modules" directory, too. if (modules_path && modules_path != 'modules_path') { foreach (get_sorted_files(modules_path) as $module) { if (preg_match('/^_/', $module)) { continue; } if (!is_dir(modules_path . "/{$module}")) { continue; } if (!file_exists(modules_path . "/{$module}/init.php")) { continue; } require_once modules_path . "/{$module}/init.php"; } } if (empty($Modules)) { tailored_error('no_modules'); } // Sort the modules uasort($Modules, 'Modules::by_module_sort'); self::$Modules = $Modules; unset($Modules); }
protected function _getItemValuesList($baseValues, $amountsKeys, $event = null) { $itemValues = array(); $salesHelper = Mage::helper('sales'); $position = 0; foreach ($baseValues as $key => $value) { $itemValues[$key] = array('code' => $key, 'name' => $salesHelper->__($value), 'description' => '', 'default' => true, 'position' => $position += 100, 'renderers' => array(999999 => 'customgrid/widget_grid_column_renderer_sales_items_sub_value_default')); if (in_array($key, $amountsKeys)) { $itemValues[$key]['value_align'] = 'right'; } // Also usable: "header_align" for header label alignment } if (!empty($event)) { $response = new Varien_Object(array('item_values' => $itemValues)); Mage::dispatchEvent($event, array('response' => $response)); $itemValues = $response->getItemValues(); } uasort($itemValues, array($this, '_sortItemValues')); foreach ($itemValues as $key => $value) { $itemValues[$key]['last'] = false; sort($itemValues[$key]['renderers'], SORT_NUMERIC); } if (!is_null($key)) { $itemValues[$key]['last'] = true; } return $itemValues; }
public function showSummary() { if (isset($_GET['order'])) { $this->sortBy = $_GET['order']; } if (!isset($this->result['data'])) { die("Impropper coverage report. Please regenerate"); } $coveredArray = $this->result["data"]; //lets sort it. uasort($coveredArray, array($this, "sortArray")); //and flip if it perhaps? if (isset($_GET["flip"]) && $_GET["flip"] == "true") { $coveredArray = array_reverse($coveredArray, true); } $totals = $this->result["totals"]; echo '<tr><td>TOTAL</td><td>', $totals['percentage'], '%</td><td>', $totals['lines'], '</td><td>', $totals['covered'], '</td><td>', $totals['maybe'], '</td><td>', $totals['notcovered'], '</td><td></tr>'; foreach ($coveredArray as $class => $info) { echo '<tr><td>'; if ($info['type'] == "covered") { echo '<a href="', $class, '.html">', $class, '</a>'; } else { echo $class; } echo '<td>' . $info['percentage'] . ' % </td><td>' . $info['total'] . '</td><td>' . $info['covered'] . '</td><td>' . $info['maybe'] . '</td><td>' . $info['notcovered'] . '</td></tr>'; } }
/** * Get and sort available payment methods for specified or current store * * array structure: * $index => Varien_Simplexml_Element * * @param mixed $store * @param Mage_Sales_Model_Quote $quote * @return array */ public function getStoreMethods($store = null, $quote = null) { $res = array(); $methods = $this->getPaymentMethods($store); uasort($methods, array($this, '_sortMethods')); foreach ($methods as $code => $methodConfig) { $prefix = self::XML_PATH_PAYMENT_METHODS . '/' . $code . '/'; if (!($model = Mage::getStoreConfig($prefix . 'model', $store))) { continue; } $methodInstance = Mage::getModel($model); if (!$methodInstance) { continue; } $methodInstance->setStore($store); if (!$methodInstance->isAvailable($quote)) { /* if the payment method cannot be used at this time */ continue; } $sortOrder = (int) $methodInstance->getConfigData('sort_order', $store); $methodInstance->setSortOrder($sortOrder); $res[] = $methodInstance; } return $res; }
/** * Finalizes the in-page tab property array. * * This finalizes the added in-page tabs and sets the default in-page tab for each page. * Also this sorts the in-page tab property array. * This must be done before registering settings sections because the default tab needs to be determined in the process. * * @since 2.0.0 * @since 3.3.0 Changed the name from `_replyToFinalizeInPageTabs()` and been no longer a callback. * @since 3.3.1 Moved from `AdminPageFramework_Page`. * @return void * @internal */ protected function _finalizeInPageTabs() { if (!$this->oProp->isPageAdded()) { return; } foreach ($this->oProp->aPages as $sPageSlug => $aPage) { if (!isset($this->oProp->aInPageTabs[$sPageSlug])) { continue; } // Apply filters to let modify the in-page tab array. $this->oProp->aInPageTabs[$sPageSlug] = $this->oUtil->addAndApplyFilter($this, "tabs_{$this->oProp->sClassName}_{$sPageSlug}", $this->oProp->aInPageTabs[$sPageSlug]); // Added in-page arrays may be missing necessary keys so merge them with the default array structure. foreach ($this->oProp->aInPageTabs[$sPageSlug] as &$aInPageTab) { $aInPageTab = $aInPageTab + self::$_aStructure_InPageTabElements; $aInPageTab['order'] = is_null($aInPageTab['order']) ? 10 : $aInPageTab['order']; } // Sort the in-page tab array. uasort($this->oProp->aInPageTabs[$sPageSlug], array($this, '_sortByOrder')); // Set the default tab for the page. // Read the value as reference; otherwise, a strange bug occurs. It may be due to the variable name, $aInPageTab, is also used as reference in the above foreach. foreach ($this->oProp->aInPageTabs[$sPageSlug] as $sTabSlug => &$aInPageTab) { if (!isset($aInPageTab['tab_slug'])) { continue; } // Regardless of whether it's a hidden tab, it is stored as the default in-page tab. $this->oProp->aDefaultInPageTabs[$sPageSlug] = $aInPageTab['tab_slug']; break; // The first iteration item is the default one. } } }
/** * Method to get the list * * @access public * @return array */ function getData(&$params) { if (!class_exists('JoomleagueModelResults')) { require_once JLG_PATH_SITE . DS . 'models' . DS . 'results.php'; } $model =& JLGModel::getInstance('Results', 'JoomleagueModel'); $model->setProjectId($params->get('p')); $project =& $model->getProject(); switch ($params->get('round_selection', 0)) { case 0: // latest $roundid = modJLGResultsHelper::getLatestRoundId($project->id); break; case 1: // next $roundid = modJLGResultsHelper::getNextRoundId($project->id); break; case 2: //manual $roundid = (int) $params->get('id') ? (int) $params->get('id') : $model->getCurrentRound(); break; } if (!$roundid) { $roundid = $model->getCurrentRound(); } $model->set('divisionid', (int) $params->get('division_id')); $model->set('roundid', $roundid); $round = modJLGResultsHelper::getRound($project->id, $roundid); $matches = $model->getMatches(); uasort($matches, array('modJLGResultsHelper', '_cmpDate')); $matches = array_slice($matches, 0, $params->get('limit', 10)); $teams = $model->getTeamsIndexedByPtid(); return array('project' => $project, 'round' => $round, 'matches' => $matches, 'teams' => $teams); }
/** * Add a table with the specified columns to the lookup. * * The data should be an associative array with the following data: * 'display_name' => The translation key to display in the select list * 'columns' => An array containing the table's columns * * @param string $context Context for data * @param array $data Data array for the table * * @return ReportBuilderEvent */ public function addTable($context, array $data, $group = null) { $data['group'] = null == $group ? $context : $group; foreach ($data['columns'] as $column => &$d) { $d['label'] = $this->translator->trans($d['label']); if (!isset($d['alias'])) { $d['alias'] = substr($column, ($pos = strpos($column, '.')) !== false ? $pos + 1 : 0); } } uasort($data['columns'], function ($a, $b) { return strnatcmp($a['label'], $b['label']); }); if (isset($data['filters'])) { foreach ($data['filters'] as $column => &$d) { $d['label'] = $this->translator->trans($d['label']); if (!isset($d['alias'])) { $d['alias'] = substr($column, ($pos = strpos($column, '.')) !== false ? $pos + 1 : 0); } } uasort($data['filters'], function ($a, $b) { return strnatcmp($a['label'], $b['label']); }); } $this->tableArray[$context] = $data; if ($this->context == $context) { $this->stopPropagation(); } return $this; }
/** * Builds the Toolbar as a structured array ready for drupal_render(). * * Since building the toolbar takes some time, it is done just prior to * rendering to ensure that it is built only if it will be displayed. * * @param array $element * A renderable array. * * @return array * A renderable array. * * @see toolbar_page_top(). */ public static function preRenderToolbar($element) { // Get the configured breakpoints to switch from vertical to horizontal // toolbar presentation. $breakpoints = static::breakpointManager()->getBreakpointsByGroup('toolbar'); if (!empty($breakpoints)) { $media_queries = array(); foreach ($breakpoints as $id => $breakpoint) { $media_queries[$id] = $breakpoint->getMediaQuery(); } $element['#attached']['drupalSettings']['toolbar']['breakpoints'] = $media_queries; } $module_handler = static::moduleHandler(); // Get toolbar items from all modules that implement hook_toolbar(). $items = $module_handler->invokeAll('toolbar'); // Allow for altering of hook_toolbar(). $module_handler->alter('toolbar', $items); // Sort the children. uasort($items, array('\\Drupal\\Component\\Utility\\SortArray', 'sortByWeightProperty')); // Merge in the original toolbar values. $element = array_merge($element, $items); // Assign each item a unique ID, based on its key. foreach (Element::children($element) as $key) { $element[$key]['#id'] = Html::getId('toolbar-item-' . $key); } return $element; }