本文整理汇总了PHP中uasort函数的典型用法代码示例。如果您正苦于以下问题:PHP uasort函数的具体用法?PHP uasort怎么用?PHP uasort使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了uasort函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getActions
/**
* Get actions
*
* @return array
*/
public function getActions()
{
uasort($this->actions, function ($a, $b) {
return strnatcasecmp($a['label'], $b['label']);
});
return $this->actions;
}
示例2: checkFilters
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;
}
}
}
示例3: qa_sort_by
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');
}
示例4: convertCreditCards
/**
* 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;
}
示例5: getFieldsets
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;
}
示例6: collectBundles
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;
}
示例7: getDerivativeDefinitions
/**
* {@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];
}
示例8: __construct
/**
* 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;
}
}
}
示例9: buildTypeMap
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);
}
示例10: getRestResources
/**
* [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;
}
示例11: _beforeToHtml
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();
}
示例12: process
/**
* {@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)));
}
}
}
示例13: buildJavascriptConfiguration
/**
* 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)) . '";';
}
示例14: getNavigation
/**
* @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;
}
示例15: dump_export_data
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");
}
}