コード例 #1
0
ファイル: TwitterController.php プロジェクト: brainexe/php.ug
 /**
  * Get a list of twitter-nicks ordered by groups
  *
  * @return mixed|void
  */
 public function getList()
 {
     $twitter = $this->getEntityManager()->getRepository('Phpug\\Entity\\Service')->findBy(array('name' => 'Twitter'));
     $twitters = $this->getEntityManager()->getRepository('Phpug\\Entity\\Groupcontact')->findBy(array('service' => $twitter[0]->id));
     $twitterService = $this->getServiceLocator()->get('TwitterInfoService');
     $result = array();
     foreach ($twitters as $twitter) {
         $group = $twitter->getGroup();
         if (!$group) {
             continue;
         }
         if (!$group instanceof Usergroup) {
             continue;
         }
         if ($group->getState() != Usergroup::ACTIVE) {
             continue;
         }
         if (!isset($result[$twitter->getName()])) {
             $result[$twitter->getName()] = array('screen_name' => $twitter->getName(), 'name' => $twitterService->getInfoForUser('name', $twitter->getName()), 'url' => $twitter->getUrl(), 'icon_url' => $twitterService->getInfoForUser('profile_image_url_https', $twitter->getName()), 'groups' => array());
         }
         $groupMapUrl = $this->url()->fromRoute('home', array(), array('force_canonical' => true)) . '?center=' . $group->getShortName();
         $groupApiUrl = $this->url()->fromRoute('api/rest', array('controller' => 'Usergroup', 'id' => $group->getId()), array('force_canonical' => true));
         $result[$twitter->getName()]['groups'][] = array('usergroup' => $group->getName(), 'usergroup_url' => $group->getUrl(), 'phpug_group_map_url' => $groupMapUrl, 'phpug_group_api_url' => $groupApiUrl);
     }
     usort($result, function ($a, $b) {
         return strnatcasecmp($a['name'], $b['name']);
     });
     $adapter = $this->getAdapter();
     $response = $this->getResponse();
     $response->setContent($adapter->serialize(array_values($result)));
     return $response;
 }
コード例 #2
0
function Global_Init()
{
    //session_start();
    Load_Configs();
    if (!strnatcasecmp(trim($GLOBALS['db']['type']), "LB")) {
        require_once 'inc/dbmodule_LB.php';
    }
    if (!strnatcasecmp(trim($GLOBALS['db']['type']), "GD")) {
        require_once 'inc/dbmodule_GD.php';
    }
    //echo "GLOBALS: <BR>"; print_r($GLOBALS['db']); echo "<BR>";
    $source_db_ok = SQL_DB_OK("source");
    if ($source_db_ok['error'] === false) {
        $GLOBALS['db']['s_resource'] = @mysql_connect($GLOBALS['db']['s_host'], $GLOBALS['db']['s_user'], $GLOBALS['db']['s_pass']) or die($_SERVER["SCRIPT_FILENAME"] . "Could not connect to Source MySQL Server. : " . mysql_error());
        @mysql_selectdb($GLOBALS['db']['s_base']) or die("Could not connect to Source database [" . $GLOBALS['db']['s_base'] . "] : " . mysql_error());
        $GLOBALS['db']['x_resource'] = @mysql_connect($GLOBALS['db']['x_host'], $GLOBALS['db']['x_user'], $GLOBALS['db']['x_pass']) or die($_SERVER["SCRIPT_FILENAME"] . "Could not connect to X-Ray  MySQL Server. : " . mysql_error());
        @mysql_selectdb($GLOBALS['db']['x_base']) or die("Could not connect to X-Ray database [" . $GLOBALS['db']['x_base'] . "] : " . mysql_error());
        $GLOBALS['db']['s_link'] = mysqli_connect($GLOBALS['db']['s_host'], $GLOBALS['db']['s_user'], $GLOBALS['db']['s_pass'], $GLOBALS['db']['s_base']) or die($_SERVER["SCRIPT_FILENAME"] . "Could not connect to Source MySQL Server (multilink). : " . mysqli_error($GLOBALS['db']['s_link']));
        mysqli_select_db($GLOBALS['db']['s_link'], $GLOBALS['db']['s_base']) or die("Could not connect to Source database (multilink) [" . $GLOBALS['db']['s_base'] . "] : " . mysqli_error($GLOBALS['db']['s_link']));
        $GLOBALS['db']['x_link'] = mysqli_connect($GLOBALS['db']['x_host'], $GLOBALS['db']['x_user'], $GLOBALS['db']['x_pass'], $GLOBALS['db']['x_base']) or die($_SERVER["SCRIPT_FILENAME"] . "Could not connect to X-Ray MySQL Server (multilink). : " . mysqli_error($GLOBALS['db']['x_link']));
        mysqli_select_db($GLOBALS['db']['x_link'], $GLOBALS['db']['x_base']) or die("Could not connect to X-Ray database (multilink) [" . $GLOBALS['db']['x_base'] . "] : " . mysqli_error($GLOBALS['db']['x_link']));
    } else {
        $config_error .= $source_db_ok['message'] . "<BR>";
    }
    //	array_key_exists('form', $_POST) && $_POST['form']!="" ? $_GET = $_POST : NULL;
    //	array_key_exists('force', $_GET) && $_GET['force']!="" ? $_POST = $_GET : NULL;
    if (count($_GET) > 0) {
        $_POST = $_GET;
    }
    //	if($_POST['form']!=""){$_GET = $_POST;}
    //	if($_GET['force']!=""){$_POST = $_GET;}
    if (!FixOutput_Bool($GLOBALS['config_settings']['settings']['first_setup'], true, false, true)) {
        $GLOBALS['worlds'] = Get_Worlds_Enabled();
    }
}
コード例 #3
0
 /**
  * This is a helper method that can be used with u?sort methods to sort a list of (relative) file paths, e.g.
  * array("someDir/fileA", "fileA", "fileB", "anotherDir/fileA").
  *
  * Directories are sorted first in the lists, with the deepest structures first (while every level is sorted
  * alphabetically)
  *
  * @param string $elementA
  * @param string $elementB
  * @return int
  */
 public static function recursiveFileListSortingHelper($elementA, $elementB)
 {
     if (strpos($elementA, '/') === FALSE) {
         // first element is a file
         if (strpos($elementB, '/') === FALSE) {
             $result = strnatcasecmp($elementA, $elementB);
         } else {
             // second element is a directory => always sort it first
             $result = 1;
         }
     } else {
         // first element is a directory
         if (strpos($elementB, '/') === FALSE) {
             // second element is a file => always sort it last
             $result = -1;
         } else {
             // both elements are directories => we have to recursively sort here
             list($pathPartA, $elementA) = explode('/', $elementA, 2);
             list($pathPartB, $elementB) = explode('/', $elementB, 2);
             if ($pathPartA === $pathPartB) {
                 // same directory => sort by subpaths
                 $result = self::recursiveFileListSortingHelper($elementA, $elementB);
             } else {
                 // different directories => sort by current directories
                 $result = strnatcasecmp($pathPartA, $pathPartB);
             }
         }
     }
     return $result;
 }
コード例 #4
0
ファイル: arraysort.class.php プロジェクト: vsalx/rattieinfo
 function compare_rows($a, $b)
 {
     if (-1 == $this->column) {
         return 0;
     }
     return strnatcasecmp($a[$this->column], $b[$this->column]);
 }
コード例 #5
0
ファイル: DataSorter.php プロジェクト: Lucas8x/graph
 public static function sort(&$entries, $sortType)
 {
     switch ($sortType) {
         case self::Title:
             $cb = function ($a, $b) {
                 return strnatcasecmp($a->title, $b->title);
             };
             break;
         case self::Score:
             $cb = function ($a, $b) {
                 return $a->score < $b->score ? 1 : -1;
             };
             break;
         case self::MeanScore:
             $cb = function ($a, $b) {
                 return $a->meanScore < $b->meanScore ? 1 : -1;
             };
             break;
         case self::MediaMalId:
             $cb = function ($a, $b) {
                 return strcmp(sprintf('%s%05d', $a->media, $a->mal_id), sprintf('%s%05d', $b->media, $b->mal_id));
             };
             break;
         default:
             throw new RuntimeException('Bad sort type');
     }
     usort($entries, $cb);
 }
コード例 #6
0
function CableIDTabHandler()
{
    echo '<div class=portlet><h2>Cable ID Helper</h2></div>';
    $rack = spotEntity('rack', $_REQUEST['rack_id']);
    $result = usePreparedSelectBlade('SELECT DISTINCT object_id FROM RackSpace WHERE rack_id = ? ', array($rack['id']));
    $objects = $result->fetchAll(PDO::FETCH_ASSOC);
    $cableIDs = array();
    foreach ($objects as $object) {
        $pals = getObjectPortsAndLinks($object['object_id']);
        foreach ($pals as $portLink) {
            if ($portLink['cableid']) {
                $new = true;
                $dublicate = false;
                foreach ($cableIDs as $key => $cableID) {
                    if ($portLink['object_id'] == $cableID['object1_id'] && $portLink['name'] == $cableID['object1_port'] || $portLink['object_id'] == $cableID['object2_id'] && $portLink['name'] == $cableID['object2_port']) {
                        $new = false;
                        // Link already in List
                    }
                    // Check for duplicate cable ids
                    if ($new && $portLink['cableid'] == $cableID['cableID']) {
                        $dublicate = true;
                        $cableIDs[$key]['dublicate'] = true;
                    }
                }
                if ($new) {
                    $cableID = array();
                    $cableID['cableID'] = $portLink['cableid'];
                    $cableID['object1_id'] = $portLink['object_id'];
                    $cableID['object1_name'] = $portLink['object_name'];
                    $cableID['object1_port'] = $portLink['name'];
                    $cableID['object2_id'] = $portLink['remote_object_id'];
                    $cableID['object2_name'] = $portLink['remote_object_name'];
                    $cableID['object2_port'] = $portLink['remote_name'];
                    $cableID['dublicate'] = $dublicate;
                    array_push($cableIDs, $cableID);
                }
            }
        }
    }
    // Sort by cableIDs
    usort($cableIDs, function ($elem1, $elem2) {
        return strnatcasecmp($elem1['cableID'], $elem2['cableID']);
    });
    // Print table
    echo '<table class="cooltable" align="center" border="0" cellpadding="5" cellspacing="0">' . '<tbody>' . '  <tr>' . '  <th>CableID</th>' . '  <th>Object 1</th>' . '  <th>Object 2</th>' . '  </tr>';
    $i = 0;
    foreach ($cableIDs as $cableID) {
        if ($i % 2) {
            $class = 'row_even tdleft';
        } else {
            $class = 'row_odd tdleft';
        }
        if ($cableID['dublicate']) {
            $class .= ' trerror';
        }
        echo '<tr class="' . $class . '">' . '<td>' . $cableID['cableID'] . '</td>' . '<td><a href="' . makeHref(array('page' => 'object', 'object_id' => $cableID['object1_id'])) . '">' . $cableID['object1_name'] . ': ' . $cableID['object1_port'] . '</a></td>' . '<td><a href="' . makeHref(array('page' => 'object', 'object_id' => $cableID['object2_id'])) . '">' . $cableID['object2_name'] . ': ' . $cableID['object2_port'] . '</a></td>' . '</tr>';
        $i++;
    }
    echo '  </tbody>' . '</table>';
}
コード例 #7
0
 function display($tpl = null)
 {
     JToolBarHelper::title(JText::_('JoomSEF'), 'artio.png');
     // Get number of URLs for purge warning
     $model =& JModel::getInstance('URLs', 'SEFModel');
     $this->assign('purgeCount', $model->getCount(0));
     // Get newest version available
     $sefConfig =& SEFConfig::getConfig();
     if ($sefConfig->versionChecker) {
         $model2 =& JModel::getInstance('Upgrade', 'SEFModel');
         $newVer = $model2->getNewSEFVersion();
         $sefinfo = SEFTools::getSEFInfo();
         if (strnatcasecmp($newVer, $sefinfo['version']) > 0 || strnatcasecmp($newVer, substr($sefinfo['version'], 0, strpos($sefinfo['version'], '-'))) == 0) {
             $newVer = '<span style="font-weight: bold; color: red;">' . $newVer . '</span>&nbsp;&nbsp;<input type="button" onclick="showUpgrade();" value="' . JText::_('Go to Upgrade page') . '" />';
         }
         $newVer .= ' <input type="button" onclick="disableStatus(\'versioncheck\');" value="' . JText::_('Disable version checker') . '" />';
         $this->assign('newestVersion', $newVer);
     } else {
         $newestVersion = JText::_('Version checker disabled') . '&nbsp;&nbsp;<input type="button" onclick="enableStatus(\'versioncheck\');" value="' . JText::_('Enable') . '" />';
         $this->assign('newestVersion', $newestVersion);
     }
     // Get statistics
     $stats = $model->getStatistics();
     $this->assignRef('stats', $stats);
     // Get feed
     $feed = $this->get('Feed');
     $this->assignRef('feed', $feed);
     JHTML::_('behavior.tooltip');
     parent::display($tpl);
 }
コード例 #8
0
ファイル: Router.php プロジェクト: fructify/theme
 /**
  * Finds all theme route files and adds the routes to the RouteCollection.
  *
  * @return void
  */
 private function discoverRoutes()
 {
     // Where are our routes located?
     $parentRoutes = $this->config->paths->theme->parent->routes;
     $childRoutes = $this->config->paths->theme->child->routes;
     $files = $this->finder->createFinder()->files()->name('*.php')->in($parentRoutes);
     if ($parentRoutes != $childRoutes && is_dir($childRoutes)) {
         $files = $files->in($childRoutes);
     }
     // Collect all the files
     $splFiles = [];
     foreach ($files as $file) {
         $splFiles[] = $file;
     }
     // Now we need to sort them ourselves because it seems Finder's
     // sortByName(), only sorts per in('dir') and not across the
     // entire list.
     $orderedFiles = Linq::from($splFiles)->orderBy('$v', function ($a, $b) {
         return strnatcasecmp($a->getBasename('.php'), $b->getBasename('.php'));
     });
     // Finally lets add some routes.
     foreach ($orderedFiles as $file) {
         $route = import($file->getRealPath(), ['route' => $this->routes]);
         if (is_callable($route)) {
             $this->container->call($route, ['config' => $this->config]);
         }
     }
 }
コード例 #9
0
ファイル: navigation.php プロジェクト: DECAF/redaxo
 /**
  * @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 strnatcasecmp($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;
 }
コード例 #10
0
/**
 * https://gist.github.com/amnuts/8633684
 */
function osort(&$array, $properties)
{
    if (is_string($properties)) {
        $properties = array($properties => SORT_ASC);
    }
    uasort($array, function ($a, $b) use($properties) {
        foreach ($properties as $k => $v) {
            if (is_int($k)) {
                $k = $v;
                $v = SORT_ASC;
            }
            $collapse = function ($node, $props) {
                if (is_array($props)) {
                    foreach ($props as $prop) {
                        $node = !isset($node->{$prop}) ? null : $node->{$prop};
                    }
                    return $node;
                } else {
                    return !isset($node->{$props}) ? null : $node->{$props};
                }
            };
            $aProp = $collapse($a, $k);
            $bProp = $collapse($b, $k);
            if ($aProp != $bProp) {
                return $v == SORT_ASC ? strnatcasecmp($aProp, $bProp) : strnatcasecmp($bProp, $aProp);
            }
        }
        return 0;
    });
}
コード例 #11
0
ファイル: TrieCollection.php プロジェクト: jaytaph/Tries
 public function sortKeys()
 {
     usort($this->entries, function ($a, $b) {
         return strnatcasecmp($a->key, $b->key);
     });
     return $this;
 }
コード例 #12
0
 public function run()
 {
     $rules = [];
     $query = Rule::find()->innerJoinWith('mode')->andWhere(['{{game_mode}}.[[key]]' => 'gachi']);
     foreach ($query->all() as $rule) {
         $rules[$rule->id] = Yii::t('app-rule', $rule->name);
     }
     asort($rules);
     $maps = [];
     foreach (Map::find()->all() as $map) {
         $maps[$map->id] = [$map->key, Yii::t('app-map', $map->name)];
     }
     uasort($maps, function ($a, $b) {
         return strnatcasecmp($a[1], $b[1]);
     });
     // init data
     $data = [];
     foreach (array_keys($maps) as $mapId) {
         $data[$mapId] = [];
         foreach (array_keys($rules) as $ruleId) {
             $data[$mapId][$ruleId] = (object) ['battle_count' => 0, 'ko_count' => 0];
         }
     }
     // set data
     foreach ($this->query() as $row) {
         $ruleId = $row['rule_id'];
         $mapId = $row['map_id'];
         $data[$mapId][$ruleId]->battle_count = (int) $row['battle_count'];
         $data[$mapId][$ruleId]->ko_count = (int) $row['ko_count'];
     }
     return $this->controller->render('knockout.tpl', ['rules' => $rules, 'maps' => $maps, 'data' => $data]);
 }
コード例 #13
0
 /**
  * Get events.
  *
  * @return array
  */
 public function getEvents()
 {
     uasort($this->events, function ($a, $b) {
         return strnatcasecmp($a['label'], $b['label']);
     });
     return $this->events;
 }
コード例 #14
0
 /**
  * Get actions
  *
  * @return array
  */
 public function getActions()
 {
     uasort($this->actions, function ($a, $b) {
         return strnatcasecmp($a['label'], $b['label']);
     });
     return $this->actions;
 }
コード例 #15
0
 /**
  * {@inheritdoc}
  */
 public function getIterator()
 {
     $array = iterator_to_array($this->iterator);
     $sort = is_callable($this->sort) ? 'callback' : $this->sort;
     $normalize = function ($string) {
         $string = preg_replace("/(?<=[aou])̈/i", '', $string);
         $string = mb_strtolower($string);
         $string = str_replace(array('ä', 'ö', 'ü', 'ß'), array('a', 'o', 'u', 's'), $string);
         return $string;
     };
     $sortCallback = function ($a, $b) use($normalize) {
         $a = $normalize($a);
         $b = $normalize($b);
         return strnatcasecmp($a, $b);
     };
     switch ($sort) {
         case self::VALUES:
             uasort($array, $sortCallback);
             break;
         case self::KEYS:
             uksort($array, $sortCallback);
             break;
         case 'callback':
             uasort($array, $this->sort);
             break;
         default:
             throw new Exception('Unknown sort mode!');
     }
     return new ArrayIterator($array);
 }
コード例 #16
0
ファイル: view.html.php プロジェクト: 01J/bealtine
 function display($tpl = null)
 {
     JToolBarHelper::title(JText::_('COM_SEF_JOOMSEF'), 'artio.png');
     $user = JFactory::getUser();
     if ($user->authorise('core.admin', 'com_sef')) {
         JToolBarHelper::preferences('com_sef');
     }
     // Get number of URLs for purge warning
     $model = SEFModel::getInstance('URLs', 'SEFModel');
     $this->assign('purgeCount', $model->getCount(0));
     // Get newest version available
     $sefConfig = SEFConfig::getConfig();
     if ($sefConfig->versionChecker) {
         $model2 = SEFModel::getInstance('Upgrade', 'SEFModel');
         $newVer = $model2->getNewSEFVersion();
         $sefinfo = SEFTools::getSEFInfo();
         if (strnatcasecmp($newVer, $sefinfo['version']) > 0 || strnatcasecmp($newVer, substr($sefinfo['version'], 0, strpos($sefinfo['version'], '-'))) == 0) {
             $newVer = '<span style="font-weight: bold; color: red;">' . $newVer . '</span>&nbsp;&nbsp;<input type="button" class="btn btn-small" onclick="showUpgrade();" value="' . JText::_('COM_SEF_GO_TO_UPGRADE_PAGE') . '" />';
         }
         $newVer .= ' <input type="button" class="btn btn-danger btn-small" onclick="disableStatus(\'versioncheck\');" value="' . JText::_('COM_SEF_DISABLE_VERSION_CHECKER') . '" />';
         $this->assign('newestVersion', $newVer);
     } else {
         $newestVersion = JText::_('COM_SEF_VERSION_CHECKER_DISABLED') . '&nbsp;&nbsp;<input type="button" class="btn btn-success btn-small" onclick="enableStatus(\'versioncheck\');" value="' . JText::_('COM_SEF_ENABLE') . '" />';
         $this->assign('newestVersion', $newestVersion);
     }
     // Get statistics
     $stats = $model->getStatistics();
     $this->assignRef('stats', $stats);
     // Get feed
     $feed = $this->get('Feed');
     $this->assignRef('feed', $feed);
     // Check language filter plugin
     $this->getModel('sef')->checkLanguagePlugins();
     parent::display($tpl);
 }
コード例 #17
0
ファイル: Sorter.php プロジェクト: darya/framework
 /**
  * Sort data using the given order.
  * 
  * Uses indexes to retain order of equal elements - stable sorting.
  * 
  * @param array        $data
  * @param array|string $order [optional]
  * @return array
  */
 public function sort(array $data, $order = array())
 {
     $order = $this->prepareOrder($order);
     if (empty($order)) {
         return $data;
     }
     $index = 0;
     foreach ($data as &$item) {
         $item = array($index++, $item);
     }
     usort($data, function ($a, $b) use($order) {
         foreach ($order as $field => $direction) {
             if (!isset($a[1][$field]) || !isset($b[1][$field])) {
                 continue;
             }
             $result = strnatcasecmp($a[1][$field], $b[1][$field]);
             if ($result === 0) {
                 continue;
             }
             if ($direction === 'desc') {
                 return $result - $result * 2;
             }
             return $result;
         }
         return $a[0] - $b[0];
     });
     foreach ($data as &$item) {
         $item = $item[1];
     }
     return $data;
 }
コード例 #18
0
 /**
  * Create a list of the files in the torrent and their sizes as well as the total torrent size
  *
  * @return array with a list of files and file sizes
  */
 public function file_list()
 {
     if (empty($this->Dec)) {
         return false;
     }
     $InfoDict =& $this->Dec['info'];
     if (!isset($InfoDict['files'])) {
         // Single-file torrent
         $this->Size = Int64::is_int($InfoDict['length']) ? Int64::get($InfoDict['length']) : $InfoDict['length'];
         $Name = isset($InfoDict['name.utf-8']) ? $InfoDict['name.utf-8'] : $InfoDict['name'];
         $this->Files[] = array($this->Size, $Name);
     } else {
         if (isset($InfoDict['path.utf-8']['files'][0])) {
             $this->PathKey = 'path.utf-8';
         }
         foreach ($InfoDict['files'] as $File) {
             $TmpPath = array();
             foreach ($File[$this->PathKey] as $SubPath) {
                 $TmpPath[] = $SubPath;
             }
             $CurSize = Int64::is_int($File['length']) ? Int64::get($File['length']) : $File['length'];
             $this->Files[] = array($CurSize, implode('/', $TmpPath));
             $this->Size += $CurSize;
         }
         uasort($this->Files, function ($a, $b) {
             return strnatcasecmp($a[1], $b[1]);
         });
     }
     return array($this->Size, $this->Files);
 }
コード例 #19
0
 /**
  * Compare to css property names by name, browser-prefix and level.
  *
  * @param string $propertyNameOne
  * @param string $propertyNameTwo
  * @return integer
  */
 public function compare($propertyNameOne, $propertyNameTwo)
 {
     $propertyOne = $this->_decodeName($propertyNameOne);
     $propertyTwo = $this->_decodeName($propertyNameTwo);
     $propertyOneLevels = count($propertyOne);
     $propertyTwoLevels = count($propertyTwo);
     $maxLevels = $propertyOneLevels > $propertyTwoLevels ? $propertyOneLevels : $propertyTwoLevels;
     for ($i = 0; $i < $maxLevels; ++$i) {
         if (isset($propertyOne[$i]) && isset($propertyTwo[$i])) {
             $compare = strnatcasecmp($propertyOne[$i], $propertyTwo[$i]);
             if ($compare != 0) {
                 return $compare;
             }
         } else {
             break;
         }
     }
     if ($propertyOneLevels > $propertyTwoLevels) {
         return 1;
     } elseif ($propertyOneLevels < $propertyTwoLevels) {
         return -1;
     } else {
         return 0;
     }
 }
コード例 #20
0
ファイル: Index.php プロジェクト: hoborglabs/widgets
 public function getData()
 {
     $index = array('list' => array(), 'tags' => array());
     $configPaths = $this->kernel->getConfigPath();
     foreach ($configPaths as $path) {
         $configs = $this->getConfigs($path);
         foreach ($configs as $config) {
             $index['list'][] = $config;
             if (!empty($config['tags'])) {
                 foreach ($config['tags'] as $tagName) {
                     // check if tag array exists, and create if needed
                     if (empty($index['tags'][$tagName])) {
                         $index['tags'][$tagName] = array('name' => $tagName, 'list' => array());
                     }
                     $index['tags'][$tagName]['list'][] = $config;
                 }
             }
         }
     }
     // sort by name
     usort($index['list'], function ($a, $b) {
         return strnatcasecmp($a['name'], $b['name']);
     });
     $index['tags'] = array_values($index['tags']);
     return $index;
 }
コード例 #21
0
function getStudents($orderBy = "surname")
{
    global $students;
    $order = strtolower($orderBy);
    switch ($order) {
        case "surname":
            usort($students, function ($a, $b) {
                return strcasecmp($a['surname'], $b['surname']);
            });
            break;
        case "id":
            usort($students, function ($a, $b) {
                return strnatcasecmp($a['id'], $b['id']);
            });
            break;
        case "mark":
            usort($students, function ($a, $b) {
                return $b['mark'] - $a['mark'];
            });
            break;
        default:
            throw new Exception("Invalid orderby parameter supplied");
            break;
    }
    foreach ($students as $student) {
        echo "<p>" . $student['id'] . ": " . $student['name'] . " " . $student['surname'] . " Mark: " . $student['mark'] . "</p>";
    }
}
コード例 #22
0
ファイル: Fn.php プロジェクト: niujie123/myself
 /**
  * 判断当前环境php版本是否大于大于等于指定的一个版本
  * @param sreing $version default=5.0.0
  * @return boolean
  * @author weiwenchao <*****@*****.**>
  */
 public static function is_php($version = '5.5.0')
 {
     $php_version = explode('-', phpversion());
     // =0表示版本为5.0.0  =1表示大于5.0.0  =-1表示小于5.0.0
     $is_pass = strnatcasecmp($php_version[0], $version) >= 0 ? true : false;
     return $is_pass;
 }
コード例 #23
0
 private function getDocumentations($sPreferredLanguageId)
 {
     $aMetaData = DocumentationProviderTypeModule::completeMetaData();
     $aPreferredDocumentationLanguages = array_unique(array($sPreferredLanguageId, 'de', 'en'));
     $cFormat = function ($aLanguageData) use($aPreferredDocumentationLanguages) {
         $oResult = new stdClass();
         foreach ($aPreferredDocumentationLanguages as $sLanguageId) {
             if (isset($aLanguageData[$sLanguageId])) {
                 $oResult->title = $aLanguageData[$sLanguageId]['title'];
                 $oResult->url = $aLanguageData[$sLanguageId]['url'];
             }
         }
         return $oResult;
     };
     // A list of all documentation heads, by key. Documentation heads are all the documentations whose keys do not contain a slash
     $aDocumentations = array();
     // Try to figure out how many documentations (and which ones) there are
     foreach ($aMetaData as $sKey => $aLanguageData) {
         if (strpos($sKey, '/') !== false) {
             continue;
         }
         $aDocumentations[$sKey] = $cFormat($aLanguageData);
         $aDocumentations[$sKey]->parts = array();
     }
     // Add keys to documentations
     foreach ($aMetaData as $sKey => $aLanguageData) {
         if (strpos($sKey, '/') === false) {
             continue;
         }
         $sDocumentationKey = explode('/', $sKey);
         $sPartKey = implode('/', array_slice($sDocumentationKey, 1));
         $sDocumentationKey = $sDocumentationKey[0];
         if (isset($aDocumentations[$sDocumentationKey])) {
             $aDocumentations[$sDocumentationKey]->parts[$sPartKey] = $cFormat($aLanguageData);
         } else {
             // If there are no documentations with this key, just pretend it’s a documentation in itself
             $aDocumentations[$sKey] = $cFormat($aLanguageData);
             $aDocumentations[$sKey]->parts = array();
         }
     }
     $aEmptyDocumentations = array();
     foreach ($aDocumentations as $sKey => $oDocumentation) {
         if (count($oDocumentation->parts) === 0) {
             $aEmptyDocumentations[$sKey] = $oDocumentation;
             unset($aDocumentations[$sKey]);
         }
     }
     usort($aDocumentations, function ($a, $b) {
         return strnatcasecmp($a->title, $b->title);
     });
     if (count($aEmptyDocumentations) > 0) {
         $oOthers = new stdClass();
         $oOthers->title = TranslationPeer::getString('wns.others', $sPreferredLanguageId, 'Weiteres');
         $oOthers->url = null;
         $oOthers->parts = $aEmptyDocumentations;
         $aDocumentations[] = $oOthers;
     }
     return $aDocumentations;
 }
コード例 #24
0
ファイル: Newsletter.php プロジェクト: nchervyakov/evolve2
 public function getSubscribers()
 {
     $list = $this->pixie->orm->get('NewsletterSignup')->order_by('email', 'asc')->find_all()->as_array();
     uasort($list, function ($item1, $item2) {
         return strnatcasecmp($item1->email, $item2->email);
     });
     return $list;
 }
コード例 #25
0
 public static function sort_items_by_title_descending($a, $b)
 {
     $a_title = self::$bKeepRawTitle ? $a->get_title() : preg_replace('/#\\d+?:\\s?/i', '', $a->get_title());
     $b_title = self::$bKeepRawTitle ? $b->get_title() : preg_replace('/#\\d+?:\\s?/i', '', $b->get_title());
     $a_title = html_entity_decode(trim(strip_tags($a_title)), ENT_COMPAT, self::$sCharEncoding);
     $b_title = html_entity_decode(trim(strip_tags($b_title)), ENT_COMPAT, self::$sCharEncoding);
     return strnatcasecmp($b_title, $a_title);
 }
コード例 #26
0
 function champCompare($a, $b)
 {
     if ($GLOBALS['ordre'] == 'desc') {
         return strnatcasecmp($b[$GLOBALS['champ']], $a[$GLOBALS['champ']]);
     } else {
         return strnatcasecmp($a[$GLOBALS['champ']], $b[$GLOBALS['champ']]);
     }
 }
コード例 #27
0
ファイル: Debug.php プロジェクト: radnan/rdn-router
 protected function getAllRoutes()
 {
     $routes = $this->parseRoutes($this->routes);
     uksort($routes, function ($a, $b) {
         return strnatcasecmp($a, $b);
     });
     return $routes;
 }
コード例 #28
0
ファイル: Modules.php プロジェクト: GruppoMeta/Movio
 /**
  * @return null|org_glizy_ModuleVO
  */
 function &getModulesSorted()
 {
     $modules =& org_glizy_ObjectValues::get('org.glizy', 'modules', array());
     uasort($modules, function ($a, $b) {
         return strnatcasecmp($a->name, $b->name);
     });
     return $modules;
 }
コード例 #29
0
ファイル: ConceptProperty.php プロジェクト: jneubert/Skosmos
 private function sortValues()
 {
     if (!empty($this->values)) {
         uksort($this->values, function ($a, $b) {
             return strnatcasecmp($a, $b);
         });
     }
     $this->is_sorted = true;
 }
コード例 #30
0
ファイル: DateFormat.php プロジェクト: Nikola-xiii/d8intranet
 /**
  * {@inheritdoc}
  */
 public static function sort(ConfigEntityInterface $a, ConfigEntityInterface $b)
 {
     if ($a->isLocked() == $b->isLocked()) {
         $a_label = $a->label();
         $b_label = $b->label();
         return strnatcasecmp($a_label, $b_label);
     }
     return $a->isLocked() ? 1 : -1;
 }