/** * Returns an array of all possible upgrade files as an array with * the upgrade's key and version * * This first looks for all .php files in the versions directory. * The files should have the format of VERSION_NUMBER (e.g. 1.0.0__1). * The project is then checked to see if */ public function getUpgrades() { if (!$this->_upgrades) { $this->_upgrades = array(); $versions = array(); $dir = dirname(__FILE__) . '/versions'; $files = sfFinder::type('file')->name('*.php')->in($dir); foreach ($files as $file) { $info = pathinfo($file); if (strpos($info['filename'], '__') === false) { throw new sfException(sprintf('Invalid upgrade filename format for file "%s" - must contain a double underscore - VERSION__NUMBER (e.g. 1.0.0__1) ', $info['filename'])); } $e = explode('__', $info['filename']); $version = $e[0]; $number = $e[1]; if ($this->_isVersionNew($info['filename'])) { $versions[] = array('version' => $version, 'number' => $number); $this->_upgrades[] = $version . '__' . $number; } } natcasesort($this->_upgrades); foreach ($this->_upgrades as $key => $version) { $this->_upgrades[$key] = $versions[$key]; } } return $this->_upgrades; }
/** * * @return string */ public static function fileTree() { $root = JchPlatformPaths::rootPath(); $dir = urldecode(JchPlatformUtility::get('dir', '', 'string', 'post')); $dir = JchPlatformUtility::decrypt($dir); $response = ''; if (file_exists($root . $dir)) { $files = scandir($root . $dir); natcasesort($files); if (count($files) > 2) { /* The 2 accounts for . and .. */ $response .= '<ul class="jqueryFileTree" style="display: none; ">'; // All dirs foreach ($files as $file) { if (file_exists($root . $dir . $file) && $file != '.' && $file != '..' && is_dir($root . $dir . $file)) { $response .= '<li class="directory collapsed"><a href="#" rel="' . JchPlatformUtility::encrypt($dir . $file . '/') . '">' . htmlentities($file) . '</a></li>'; } } // All files foreach ($files as $file) { if (file_exists($root . $dir . $file) && $file != '.' && $file != '..' && !is_dir($root . $dir . $file)) { $ext = preg_replace('/^.*\\./', '', $file); $response .= '<li class="file ext_' . $ext . '"><a href="#" rel="' . JchPlatformUtility::encrypt($dir . $file) . '">' . htmlentities($file) . '</a></li>'; } } $response .= '</ul>'; } } return $response; }
/** * Do the parsing of the yaml files and return the final parsed array * * @return array $array */ public function doParsing() { $recursiveMerge = Doctrine_Manager::getInstance()->getAttribute(Doctrine_Core::ATTR_RECURSIVE_MERGE_FIXTURES); $mergeFunction = $recursiveMerge === true ? 'array_merge_recursive' : 'array_merge'; $directory = $this->getDirectory(); $array = array(); if ($directory !== null) { foreach ((array) $directory as $dir) { $e = explode('.', $dir); // If they specified a specific yml file if (end($e) == 'yml') { $array = $mergeFunction($array, Doctrine_Parser::load($dir, $this->getFormat())); // If they specified a directory } else { if (is_dir($dir)) { $it = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($dir), RecursiveIteratorIterator::LEAVES_ONLY); $filesOrdered = array(); foreach ($it as $file) { $filesOrdered[] = $file; } // force correct order natcasesort($filesOrdered); foreach ($filesOrdered as $file) { $e = explode('.', $file->getFileName()); if (in_array(end($e), $this->getFormats())) { $array = $mergeFunction($array, Doctrine_Parser::load($file->getPathName(), $this->getFormat())); } } } } } } return $array; }
public function getTaxaFilterList() { $returnArr = array(); $sql = "SELECT DISTINCT nt.UnitName1, ts.Family "; if ($this->clid && $this->clType == "static") { $sql .= "FROM (taxstatus ts INNER JOIN taxa nt ON ts.tid = nt.tid) INNER JOIN fmchklsttaxalink cltl ON nt.TID = cltl.TID " . "WHERE (cltl.CLID = " . $this->clid . ") "; } else { if ($this->dynClid) { $sql .= "FROM (taxstatus ts INNER JOIN taxa nt ON ts.tid = nt.tid) INNER JOIN fmdyncltaxalink dcltl ON nt.TID = dcltl.TID " . "WHERE (dcltl.dynclid = " . $this->dynClid . ") "; } else { $sql .= "FROM (((taxstatus ts INNER JOIN taxa nt ON ts.tid = nt.tid) " . "INNER JOIN fmchklsttaxalink cltl ON nt.TID = cltl.TID) " . "INNER JOIN fmchecklists cl ON cltl.CLID = cl.CLID) " . "INNER JOIN fmchklstprojlink clpl ON cl.CLID = clpl.clid " . "WHERE (clpl.pid = " . $this->pid . ") "; } } $sql .= 'AND (ts.taxauthid = 1)'; //echo $sql.'<br/>'; exit; $result = $this->keyCon->query($sql); while ($row = $result->fetch_object()) { $genus = $row->UnitName1; $family = $row->Family; if ($genus) { $returnArr[] = $genus; } if ($family) { $returnArr[] = $family; } } $result->free(); $returnArr = array_unique($returnArr); natcasesort($returnArr); array_unshift($returnArr, "--------------------------"); array_unshift($returnArr, "All Species"); return $returnArr; }
public function getRootDirContent() { $path = PHPFOX_DIR; if (file_exists($path)) { if (is_dir($path)) { $this->files = scandir($path); //folders natcasesort($this->files); //All dirs foreach ($this->files as $file) { if (file_exists($path . $file) && $file != '.' && $file != '..' && is_dir($path . $file)) { $full_path = htmlentities($path . $file) . "/"; $this->filesforzip[] = str_replace('\\', '/', realpath($full_path) . "/"); $file = htmlentities($file); } } foreach ($this->files as $file) { if (file_exists($path . $file) && $file != '.' && $file != '..' && !is_dir($path . $file)) { $full_path = htmlentities($path . $file); $this->filesforzip[] = str_replace('\\', '/', realpath($full_path)); $file = htmlentities($file); } } } else { $this->filesforzip[] = $path; //files } } //convert to string $comma_separated = implode(",", $this->filesforzip); //add taken content to db Phpfox::getService('backuprestore.backuprestore')->addBTDBSetting('included_paths', serialize($comma_separated)); }
function compo_cloud() { global $wpdb; $topurl = get_bloginfo("url"); $start = 10; $total = 24; $query = "SELECT {$wpdb->terms}.term_id, {$wpdb->terms}.name, {$wpdb->term_taxonomy}.count, {$wpdb->terms}.slug FROM (({$wpdb->term_relationships} INNER JOIN {$wpdb->posts} ON {$wpdb->term_relationships}.object_id = {$wpdb->posts}.ID) INNER JOIN {$wpdb->term_taxonomy} ON {$wpdb->term_relationships}.term_taxonomy_id = {$wpdb->term_taxonomy}.term_taxonomy_id) INNER JOIN {$wpdb->terms} ON {$wpdb->term_taxonomy}.term_id = {$wpdb->terms}.term_id WHERE ((({$wpdb->term_taxonomy}.taxonomy)='post_tag') AND (({$wpdb->posts}.post_status)='publish')) GROUP BY {$wpdb->terms}.name ORDER BY count DESC, {$wpdb->terms}.name"; # LIMIT $start,$total"; $terms = $wpdb->get_results($query); shuffle($terms); $data = array(); foreach ($terms as $e) { if ($e->count < 2) { continue; } $data[] = "{$e->count}|{$e->name}|{$e->slug}"; if (count($data) >= $total) { break; } } natcasesort($data); $out = array(); $n = 0; foreach ($data as $v) { $z = intval(8 + $n * 0.5); list($x, $name, $slug) = explode("|", $v); // $name = htmlentities($name); $out[] = "<a href='{$topurl}/tag/{$slug}' style='font-size:{$z}px'>{$name}</a>"; $n += 1; } shuffle($out); echo implode(" ", $out); }
function listFiles($dir) { global $cfg; $list = array(); $full = $cfg['root'] . trim($dir, '/\\') . DIR_SEP; $thumb = $cfg['root'] . $cfg['thumb']['dir'] . DIR_SEP . trim($dir, '/\\') . DIR_SEP; $files = scandir($full); natcasesort($files); for ($i = -1, $iCount = count($files); ++$i < $iCount;) { $ext = substr($files[$i], strrpos($files[$i], '.') + 1); if (!in_array($files[$i], $cfg['hide']['file']) && !in_array($ext, $cfg['deny'][$cfg['type']]) && in_array($ext, $cfg['allow'][$cfg['type']]) && is_file($full . $files[$i])) { $imgSize = array(0, 0); if (in_array($ext, $cfg['allow']['image'])) { if ($cfg['thumb']['auto'] && !file_exists($thumb . $files[$i])) { create_thumbnail($full . $files[$i], $thumb . $files[$i]); } $imgSize = getimagesize($full . $files[$i]); } $stats = getSize($full . $files[$i]); $list[] = array('name' => $files[$i], 'ext' => $ext, 'width' => $imgSize[0], 'height' => $imgSize[1], 'size' => $stats['_size'], 'date' => date($cfg['thumb']['date'], $stats['mtime']), 'r_size' => $stats['size'], 'mtime' => $stats['mtime'], 'thumb' => '/' . $cfg['url'] . '/' . $cfg['thumb']['dir'] . '/' . $dir . $files[$i]); } } switch ($cfg['sort']) { case 'size': usort($list, 'sortSize'); break; case 'date': usort($list, 'sortDate'); break; default: //name break; } return $list; }
static function getImagesFromFolder(&$params) { if (!is_numeric($max = $params->get('max_images'))) { $max = 20; } $folder = $params->get('image_folder'); if (!($dir = @opendir($folder))) { return null; } while (false !== ($file = readdir($dir))) { if (preg_match('/.+\\.(jpg|jpeg|gif|png)$/i', $file)) { // check with getimagesize() which attempts to return the image mime-type if (getimagesize(JPATH_ROOT . DS . $folder . DS . $file) !== FALSE) { $files[] = $file; } } } closedir($dir); if ($params->get('sort_by')) { natcasesort($files); } else { shuffle($files); } $images = array_slice($files, 0, $max); $target = modDJImageSliderHelper::getSlideTarget($params->get('link')); foreach ($images as $image) { $slides[] = (object) array('title' => '', 'description' => '', 'image' => $folder . '/' . $image, 'link' => $params->get('link'), 'alt' => $image, 'target' => $target); } return $slides; }
function wikiplugin_sort($data, $params) { global $tikilib; extract($params, EXTR_SKIP); $sort = isset($sort) ? $sort : "asc"; $lines = preg_split("/\n+/", $data, -1, PREG_SPLIT_NO_EMPTY); // separate lines into array // $lines = array_filter( $lines, "chop" ); // remove \n srand((double) microtime() * 1000000); // needed for shuffle; if ($sort == "asc") { natcasesort($lines); } else { if ($sort == "desc") { natcasesort($lines); $lines = array_reverse($lines); } else { if ($sort == "reverse") { $lines = array_reverse($lines); } else { if ($sort == "shuffle") { shuffle($lines); } } } } reset($lines); if (is_array($lines)) { $data = implode("\n", $lines); } $data = trim($data); return $data; }
public function render() { $conpherence = $this->getConpherence(); $widget_data = $conpherence->getWidgetData(); $viewer = $this->getUser(); $participants = $conpherence->getParticipants(); $handles = $conpherence->getHandles(); $head_handles = array_select_keys($handles, array($viewer->getPHID())); $handle_list = mpull($handles, 'getName'); natcasesort($handle_list); $handles = mpull($handles, null, 'getName'); $handles = array_select_keys($handles, $handle_list); $head_handles = mpull($head_handles, null, 'getName'); $handles = $head_handles + $handles; $can_edit = PhabricatorPolicyFilter::hasCapability($viewer, $conpherence, PhabricatorPolicyCapability::CAN_EDIT); $body = array(); foreach ($handles as $handle) { $user_phid = $handle->getPHID(); if ($user_phid == $viewer->getPHID() || $can_edit) { $icon = id(new PHUIIconView())->setIcon('fa-times lightbluetext'); $remove_html = javelin_tag('a', array('class' => 'remove', 'sigil' => 'remove-person', 'meta' => array('remove_person' => $user_phid, 'action' => 'remove_person')), $icon); } else { $remove_html = null; } $body[] = phutil_tag('div', array('class' => 'person-entry grouped'), array(phutil_tag('a', array('class' => 'pic', 'href' => $handle->getURI()), phutil_tag('img', array('src' => $handle->getImageURI()), '')), $handle->renderLink(), $remove_html)); } return $body; }
public static function generatePage(&$tpl, &$session, &$account, &$mj) { if (!isset($_POST['db_id']) && isset($_GET['id'])) { $_POST['db_id'] = $_GET['id']; } if (!isset($_POST['db_id'])) { return fctErrorMSG('Vous devez sélectionner un objet.'); } $dbMgr = DbManager::getInstance(); //Instancier le gestionnaire $db = $dbMgr->getConn('game'); //Demander la connexion existante if (isset($_POST['save'])) { self::save(); die("<script>location.href='?mj=Item_Livre';</script>"); } $tpl->set('ACTIONTYPETXT', "Modifier"); $tpl->set('SUBMITNAME', 'Mod'); $tpl->set('SHOWID', true); $query = 'SELECT `db_id`,' . ' `db_nom`,' . ' `db_desc`,' . ' `db_pass`,' . ' `db_img`,' . ' `db_pr`,' . ' `db_param`,' . ' `db_valeur`,' . ' `db_resistance`,' . ' `db_notemj`' . ' FROM `' . DB_PREFIX . 'item_db`' . ' WHERE `db_id` = :db_id;'; $prep = $db->prepare($query); $prep->bindValue(':db_id', $_POST['db_id'], PDO::PARAM_INT); $prep->execute($db, __FILE__, __LINE__); $arr = $prep->fetch(); $prep->closeCursor(); $prep = NULL; $tpl->set('ITEM', $arr); //lister le dossier d'image $dir2 = dir($account->getSkinRemotePhysicalPath() . "../_common/items/"); $counter = 0; $arrurl = array(); $arr = array(); while ($url = $dir2->read()) { $arrurl[$counter++] = $url; } natcasesort($arrurl); $arrurl = array_values($arrurl); for ($i = 0; $i < count($arrurl); $i++) { if ($arrurl[$i] != '' && substr($arrurl[$i], 0, 1) != '.') { $arr[$i] = $arrurl[$i]; } } $tpl->set('IMGS', $arr); //Générer la liste des actions associable à un lieu $query = 'SELECT `id`, `url`, `caption`' . ' FROM `' . DB_PREFIX . 'item_menu`' . ' WHERE `item_dbid` = :db_id;'; $prep = $db->prepare($query); $prep->bindValue(':db_id', $_POST['db_id'], PDO::PARAM_INT); $prep->execute($db, __FILE__, __LINE__); $result = $prep->fetchAll(); $prep->closeCursor(); $prep = NULL; if (count($result) > 0) { $ACTIONS = array(); foreach ($result as $arr) { $ACTIONS[] = $arr; } $tpl->set('ACTIONS', $ACTIONS); } return $tpl->fetch($account->getSkinRemotePhysicalPath() . 'html/Mj/Item/Livre_Addmod.htm'); }
/** * Load terms and try to sort it by names * * @return $this */ protected function _loadTerms() { if (empty($this->_terms)) { $this->_terms = []; $terms = $this->_queryCollectionFactory->create()->setPopularQueryFilter($this->_storeManager->getStore()->getId())->setPageSize(100)->load()->getItems(); if (count($terms) == 0) { return $this; } $this->_maxPopularity = reset($terms)->getPopularity(); $this->_minPopularity = end($terms)->getPopularity(); $range = $this->_maxPopularity - $this->_minPopularity; $range = $range == 0 ? 1 : $range; foreach ($terms as $term) { if (!$term->getPopularity()) { continue; } $term->setRatio(($term->getPopularity() - $this->_minPopularity) / $range); $temp[$term->getName()] = $term; $termKeys[] = $term->getName(); } natcasesort($termKeys); foreach ($termKeys as $termKey) { $this->_terms[$termKey] = $temp[$termKey]; } } return $this; }
public function filelist() { $mp3s = $directories = $current = array(); if (!empty($_GET['dir'])) { $currentDir = urldecode($_GET['dir']); } else { $currentDir = ''; } $contents = mpc::ls($currentDir); natcasesort($contents); foreach ($contents as $value) { if (strpos($value, '/') > 0) { $value = substr($value, strrpos($value, '/') + 1); } if (strtolower(substr($value, -4)) == ".mp3") { $mp3s[] = $value; } else { $directories[$value] = $currentDir . '/' . $value; } } if (!empty($currentDir)) { $directories = array('up' => substr($currentDir, 0, strrpos($currentDir, '/'))) + $directories; } return array('files' => $mp3s, 'directories' => $directories, 'currentDir' => $currentDir); }
/** * Get an array of all two-letter country code => country name pairs. * * @return array * An array of country code => country name pairs. */ public static function getStandardList() { $countries = array('AC' => t('Ascension Island'), 'AD' => t('Andorra'), 'AE' => t('United Arab Emirates'), 'AF' => t('Afghanistan'), 'AG' => t('Antigua and Barbuda'), 'AI' => t('Anguilla'), 'AL' => t('Albania'), 'AM' => t('Armenia'), 'AN' => t('Netherlands Antilles'), 'AO' => t('Angola'), 'AQ' => t('Antarctica'), 'AR' => t('Argentina'), 'AS' => t('American Samoa'), 'AT' => t('Austria'), 'AU' => t('Australia'), 'AW' => t('Aruba'), 'AX' => t('Åland Islands'), 'AZ' => t('Azerbaijan'), 'BA' => t('Bosnia and Herzegovina'), 'BB' => t('Barbados'), 'BD' => t('Bangladesh'), 'BE' => t('Belgium'), 'BF' => t('Burkina Faso'), 'BG' => t('Bulgaria'), 'BH' => t('Bahrain'), 'BI' => t('Burundi'), 'BJ' => t('Benin'), 'BL' => t('Saint Barthélemy'), 'BM' => t('Bermuda'), 'BN' => t('Brunei'), 'BO' => t('Bolivia'), 'BQ' => t('Caribbean Netherlands'), 'BR' => t('Brazil'), 'BS' => t('Bahamas'), 'BT' => t('Bhutan'), 'BV' => t('Bouvet Island'), 'BW' => t('Botswana'), 'BY' => t('Belarus'), 'BZ' => t('Belize'), 'CA' => t('Canada'), 'CC' => t('Cocos [Keeling] Islands'), 'CD' => t('Congo - Kinshasa'), 'CF' => t('Central African Republic'), 'CG' => t('Congo - Brazzaville'), 'CH' => t('Switzerland'), 'CI' => t('Côte d’Ivoire'), 'CK' => t('Cook Islands'), 'CL' => t('Chile'), 'CM' => t('Cameroon'), 'CN' => t('China'), 'CO' => t('Colombia'), 'CP' => t('Clipperton Island'), 'CR' => t('Costa Rica'), 'CU' => t('Cuba'), 'CV' => t('Cape Verde'), 'CW' => t('Curaçao'), 'CX' => t('Christmas Island'), 'CY' => t('Cyprus'), 'CZ' => t('Czech Republic'), 'DE' => t('Germany'), 'DG' => t('Diego Garcia'), 'DJ' => t('Djibouti'), 'DK' => t('Denmark'), 'DM' => t('Dominica'), 'DO' => t('Dominican Republic'), 'DZ' => t('Algeria'), 'EA' => t('Ceuta and Melilla'), 'EC' => t('Ecuador'), 'EE' => t('Estonia'), 'EG' => t('Egypt'), 'EH' => t('Western Sahara'), 'ER' => t('Eritrea'), 'ES' => t('Spain'), 'ET' => t('Ethiopia'), 'FI' => t('Finland'), 'FJ' => t('Fiji'), 'FK' => t('Falkland Islands'), 'FM' => t('Micronesia'), 'FO' => t('Faroe Islands'), 'FR' => t('France'), 'GA' => t('Gabon'), 'GB' => t('United Kingdom'), 'GD' => t('Grenada'), 'GE' => t('Georgia'), 'GF' => t('French Guiana'), 'GG' => t('Guernsey'), 'GH' => t('Ghana'), 'GI' => t('Gibraltar'), 'GL' => t('Greenland'), 'GM' => t('Gambia'), 'GN' => t('Guinea'), 'GP' => t('Guadeloupe'), 'GQ' => t('Equatorial Guinea'), 'GR' => t('Greece'), 'GS' => t('South Georgia and the South Sandwich Islands'), 'GT' => t('Guatemala'), 'GU' => t('Guam'), 'GW' => t('Guinea-Bissau'), 'GY' => t('Guyana'), 'HK' => t('Hong Kong SAR China'), 'HM' => t('Heard Island and McDonald Islands'), 'HN' => t('Honduras'), 'HR' => t('Croatia'), 'HT' => t('Haiti'), 'HU' => t('Hungary'), 'IC' => t('Canary Islands'), 'ID' => t('Indonesia'), 'IE' => t('Ireland'), 'IL' => t('Israel'), 'IM' => t('Isle of Man'), 'IN' => t('India'), 'IO' => t('British Indian Ocean Territory'), 'IQ' => t('Iraq'), 'IR' => t('Iran'), 'IS' => t('Iceland'), 'IT' => t('Italy'), 'JE' => t('Jersey'), 'JM' => t('Jamaica'), 'JO' => t('Jordan'), 'JP' => t('Japan'), 'KE' => t('Kenya'), 'KG' => t('Kyrgyzstan'), 'KH' => t('Cambodia'), 'KI' => t('Kiribati'), 'KM' => t('Comoros'), 'KN' => t('Saint Kitts and Nevis'), 'KP' => t('North Korea'), 'KR' => t('South Korea'), 'KW' => t('Kuwait'), 'KY' => t('Cayman Islands'), 'KZ' => t('Kazakhstan'), 'LA' => t('Laos'), 'LB' => t('Lebanon'), 'LC' => t('Saint Lucia'), 'LI' => t('Liechtenstein'), 'LK' => t('Sri Lanka'), 'LR' => t('Liberia'), 'LS' => t('Lesotho'), 'LT' => t('Lithuania'), 'LU' => t('Luxembourg'), 'LV' => t('Latvia'), 'LY' => t('Libya'), 'MA' => t('Morocco'), 'MC' => t('Monaco'), 'MD' => t('Moldova'), 'ME' => t('Montenegro'), 'MF' => t('Saint Martin'), 'MG' => t('Madagascar'), 'MH' => t('Marshall Islands'), 'MK' => t('Macedonia'), 'ML' => t('Mali'), 'MM' => t('Myanmar [Burma]'), 'MN' => t('Mongolia'), 'MO' => t('Macau SAR China'), 'MP' => t('Northern Mariana Islands'), 'MQ' => t('Martinique'), 'MR' => t('Mauritania'), 'MS' => t('Montserrat'), 'MT' => t('Malta'), 'MU' => t('Mauritius'), 'MV' => t('Maldives'), 'MW' => t('Malawi'), 'MX' => t('Mexico'), 'MY' => t('Malaysia'), 'MZ' => t('Mozambique'), 'NA' => t('Namibia'), 'NC' => t('New Caledonia'), 'NE' => t('Niger'), 'NF' => t('Norfolk Island'), 'NG' => t('Nigeria'), 'NI' => t('Nicaragua'), 'NL' => t('Netherlands'), 'NO' => t('Norway'), 'NP' => t('Nepal'), 'NR' => t('Nauru'), 'NU' => t('Niue'), 'NZ' => t('New Zealand'), 'OM' => t('Oman'), 'PA' => t('Panama'), 'PE' => t('Peru'), 'PF' => t('French Polynesia'), 'PG' => t('Papua New Guinea'), 'PH' => t('Philippines'), 'PK' => t('Pakistan'), 'PL' => t('Poland'), 'PM' => t('Saint Pierre and Miquelon'), 'PN' => t('Pitcairn Islands'), 'PR' => t('Puerto Rico'), 'PS' => t('Palestinian Territories'), 'PT' => t('Portugal'), 'PW' => t('Palau'), 'PY' => t('Paraguay'), 'QA' => t('Qatar'), 'QO' => t('Outlying Oceania'), 'RE' => t('Réunion'), 'RO' => t('Romania'), 'RS' => t('Serbia'), 'RU' => t('Russia'), 'RW' => t('Rwanda'), 'SA' => t('Saudi Arabia'), 'SB' => t('Solomon Islands'), 'SC' => t('Seychelles'), 'SD' => t('Sudan'), 'SE' => t('Sweden'), 'SG' => t('Singapore'), 'SH' => t('Saint Helena'), 'SI' => t('Slovenia'), 'SJ' => t('Svalbard and Jan Mayen'), 'SK' => t('Slovakia'), 'SL' => t('Sierra Leone'), 'SM' => t('San Marino'), 'SN' => t('Senegal'), 'SO' => t('Somalia'), 'SR' => t('Suriname'), 'SS' => t('South Sudan'), 'ST' => t('São Tomé and Príncipe'), 'SV' => t('El Salvador'), 'SX' => t('Sint Maarten'), 'SY' => t('Syria'), 'SZ' => t('Swaziland'), 'TA' => t('Tristan da Cunha'), 'TC' => t('Turks and Caicos Islands'), 'TD' => t('Chad'), 'TF' => t('French Southern Territories'), 'TG' => t('Togo'), 'TH' => t('Thailand'), 'TJ' => t('Tajikistan'), 'TK' => t('Tokelau'), 'TL' => t('Timor-Leste'), 'TM' => t('Turkmenistan'), 'TN' => t('Tunisia'), 'TO' => t('Tonga'), 'TR' => t('Turkey'), 'TT' => t('Trinidad and Tobago'), 'TV' => t('Tuvalu'), 'TW' => t('Taiwan'), 'TZ' => t('Tanzania'), 'UA' => t('Ukraine'), 'UG' => t('Uganda'), 'UM' => t('U.S. Outlying Islands'), 'US' => t('United States'), 'UY' => t('Uruguay'), 'UZ' => t('Uzbekistan'), 'VA' => t('Vatican City'), 'VC' => t('Saint Vincent and the Grenadines'), 'VE' => t('Venezuela'), 'VG' => t('British Virgin Islands'), 'VI' => t('U.S. Virgin Islands'), 'VN' => t('Vietnam'), 'VU' => t('Vanuatu'), 'WF' => t('Wallis and Futuna'), 'WS' => t('Samoa'), 'XK' => t('Kosovo'), 'YE' => t('Yemen'), 'YT' => t('Mayotte'), 'ZA' => t('South Africa'), 'ZM' => t('Zambia'), 'ZW' => t('Zimbabwe')); // Sort the list. natcasesort($countries); return $countries; }
function wpdm_odir_tree() { if (!isset($_GET['task']) || $_GET['task'] != 'wpdm_odir_tree') { return; } if (!current_user_can('access_server_browser')) { echo "<ul><li>" . __('Not Allowed!', 'wpdmpro') . "</li></ul>"; die; } $_POST['dir'] = isset($_POST['dir']) ? urldecode($_POST['dir']) : ''; $root = ''; if (file_exists($root . $_POST['dir'])) { $files = scandir($root . $_POST['dir']); natcasesort($files); if (count($files) > 2) { /* The 2 accounts for . and .. */ echo "<ul class=\"jqueryFileTree\" style=\"display: none;\">"; // All dirs foreach ($files as $file) { if (file_exists($root . $_POST['dir'] . $file) && $file != '.' && $file != '..' && is_dir($root . $_POST['dir'] . $file)) { echo "<li class=\"directory collapsed\"><a onclick=\"odirpath(this)\" class=\"odir\" href=\"#\" rel=\"" . htmlentities($_POST['dir'] . $file) . "/\">" . htmlentities($file) . "</a></li>"; } } echo "</ul>"; } } die; }
public function execute() { $path = rtrim(waRequest::post('path'), ' /'); $path = wa()->getDataPath($path, true); if (!file_exists($path)) { throw new waException("File not found", 404); } $files = array(); $dh = opendir($path); $names = array(); while (($f = readdir($dh)) !== false) { if ($f !== '.' && $f !== '..' && is_file($path . '/' . $f)) { $t = filemtime($path . '/' . $f); $name = htmlspecialchars($f); $files[$name] = array('file' => $name, 'type' => $this->getType($f), 'size' => filesize($path . '/' . $f), 'timestamp' => $t, 'datetime' => waDateTime::format('humandatetime', $t)); $names[] = $name; } } natcasesort($names); $sorted_files = array(); foreach ($names as $name) { $sorted_files[] =& $files[$name]; } closedir($dh); $this->response = $sorted_files; }
/** * returns an aray of customers * The unselect option shows an extra line, basically allowing you to deselect the * current option. * * @param Boolean $showUnselectedOption * @return Array ( ID => Email (member.title) ) */ public static function list_of_customers($showUnselectedOption = false) { //start array $array = array(); if ($showUnselectedOption) { $array[0] = _t("Member.SELECTCUSTOMER", " --- SELECT CUSTOMER ---"); } //get customer group $customerCode = EcommerceConfig::get("EcommerceRole", "customer_group_code"); $group = Group::get()->Filter(array("Code" => $customerCode))->First(); //fill array if ($group) { $members = $group->Members(); $membersCount = $members->count(); if ($membersCount > 0 && $membersCount < Config::inst()->get("EcommerceRole", "max_count_of_members_in_array")) { foreach ($members as $member) { if ($member->Email) { $array[$member->ID] = $member->Email . " (" . $member->getTitle() . ")"; } } } else { return $array; } } //sort in a natural order natcasesort($array); return $array; }
/** * Returns a valid html tag for the choosen $fieldType for pathes * * @param string path The path to start searching in * @param integer uid The uid which must match the found directories * @param integer gid The gid which must match the found direcotries * @param string fieldType Either "Manual" or "Dropdown" * @return string The html tag for the choosen $fieldType * * @author Martin Burchert <*****@*****.**> * @author Manuel Bernhardt <*****@*****.**> */ function makePathfield($path, $uid, $gid, $fieldType, $value = '') { global $lng; $value = str_replace($path, '', $value); $field = ''; if ($fieldType == 'Manual') { $field = '<input type="text" name="path" value="' . htmlspecialchars($value) . '" size="30" />'; } elseif ($fieldType == 'Dropdown') { $dirList = findDirs($path, $uid, $gid); natcasesort($dirList); if (sizeof($dirList) > 0) { $field = '<select name="path">'; foreach ($dirList as $key => $dir) { if (strpos($dir, $path) === 0) { $dir = makeCorrectDir(substr($dir, strlen($path))); } $field .= makeoption($dir, $dir, $value); } $field .= '</select>'; } else { $field = $lng['panel']['dirsmissing']; $field .= '<input type="hidden" name="path" value="/" />'; } } return $field; }
/** * 对查询结果集进行排序 * @param array $array 查询结果 * @param string $field 排序的字段名 * @param string $sortby 排序类型 asc正向排序 desc逆向排序 nat自然排序 * @return array */ public function table_sort($array, $field, $sortby = 'asc') { if (!is_array($array)) { return $array; } $sort = $r = []; foreach ($array as $i => $data) { $sort[$i] =& $data[$field]; } switch ($sortby) { case 'asc': // 正向排序 asort($sort); break; case 'desc': // 逆向排序 arsort($sort); break; case 'nat': // 自然排序 natcasesort($sort); break; } foreach ($sort as $key => $val) { $r[] =& $array[$key]; } return $r; }
public function __construct($from, $name, array $config) { $this->name = $name; $this->model_from = $from; $this->model_to = array_key_exists('model_to', $config) ? $config['model_to'] : \Inflector::get_namespace($from) . 'Model_' . \Inflector::classify($name); $this->key_from = array_key_exists('key_from', $config) ? (array) $config['key_from'] : $this->key_from; $this->key_to = array_key_exists('key_to', $config) ? (array) $config['key_to'] : $this->key_to; $this->conditions = array_key_exists('conditions', $config) ? (array) $config['conditions'] : array(); if (!empty($config['table_through'])) { $this->table_through = $config['table_through']; } else { $table_name = array($this->model_from, $this->model_to); natcasesort($table_name); $table_name = array_merge($table_name); $this->table_through = \Inflector::tableize($table_name[0]) . '_' . \Inflector::tableize($table_name[1]); } $this->key_through_from = !empty($config['key_through_from']) ? (array) $config['key_through_from'] : (array) \Inflector::foreign_key($this->model_from); $this->key_through_to = !empty($config['key_through_to']) ? (array) $config['key_through_to'] : (array) \Inflector::foreign_key($this->model_to); $this->cascade_save = array_key_exists('cascade_save', $config) ? $config['cascade_save'] : $this->cascade_save; $this->cascade_delete = array_key_exists('cascade_delete', $config) ? $config['cascade_delete'] : $this->cascade_delete; if (!class_exists($this->model_to)) { throw new \FuelException('Related model not found by Many_Many relation "' . $this->name . '": ' . $this->model_to); } $this->model_to = get_real_class($this->model_to); }
function treatPost() { $members = isset($_POST["lmembers"]) ? unserialize(base64_decode($_POST["lmembers"])) : null; $nonmemb = isset($_POST["lnonmemb"]) ? unserialize(base64_decode($_POST["lnonmemb"])) : null; $this->list = isset($_POST["list"]) ? unserialize(base64_decode($_POST["list"])) : null; if (!is_array($this->list)) { $this->loadList(); } if (isset($_POST["bdeluser_x"])) { if (isset($_POST["members"])) { foreach ($_POST["members"] as $member) { unset($members[$member]); } } } elseif (isset($_POST["badduser_x"])) { if (isset($_POST["nonmemb"])) { foreach ($_POST["nonmemb"] as $nm) { $members[$nm] = $this->list[$nm]; } } } elseif (isset($_POST["bconfirm"])) { header("Location: " . urlStrRedirect($this->set_order_uri, array('list' => base64_encode(serialize($this->list))))); exit; } else { $members = array(); $nonmemb = $this->list; } ksort($members); reset($members); ksort($nonmemb); $this->diff = array_diff_assoc($nonmemb, $members); natcasesort($this->diff); $this->members = $members; $this->nonmemb = $nonmemb; }
public function __construct($rejectedProp, $acceptedProps) { natcasesort($acceptedProps); $message = $rejectedProp . ' is not a valid UI property.'; $message .= ' Must be one of [ ' . implode(' | ', $acceptedProps) . ' ]'; parent::__construct($message); }
/** * Tests adding, editing, and deleting languages. */ function testLanguageLocaleList() { // User to add and remove language. $admin_user = $this->drupalCreateUser(array('administer languages', 'access administration pages')); $this->drupalLogin($admin_user); // Add predefined language. $edit = array('predefined_langcode' => 'fr'); $this->drupalPostForm('admin/config/regional/language/add', $edit, t('Add language')); $this->assertText('The language French has been created and can now be used'); $this->assertUrl(\Drupal::url('entity.configurable_language.collection', [], ['absolute' => TRUE])); $this->rebuildContainer(); // Translate Spanish language to French (Espagnol). $source = $this->storage->createString(array('source' => 'Spanish', 'context' => ''))->save(); $this->storage->createTranslation(array('lid' => $source->lid, 'language' => 'fr', 'translation' => 'Espagnol'))->save(); // Get language list displayed in select list. $this->drupalGet('fr/admin/config/regional/language/add'); $select = $this->xpath('//select[@id="edit-predefined-langcode"]'); $select_element = (array) end($select); $options = $select_element['option']; // Remove the 'Custom language...' option form the end. array_pop($options); // Order language list. $options_ordered = $options; natcasesort($options_ordered); // Check the language list displayed is ordered. $this->assertTrue($options === $options_ordered, 'Language list is ordered.'); }
/** * Return array of filenames to convert * @param string $dirName * @return mixed */ function getFileList($dirName = null) { if (!is_string($dirName)) { return false; } if (!is_dir($dirName)) { return false; } if (!is_readable($dirName)) { return false; } clearstatcache(); $ret_ar = array(); if (!($dh = opendir($dirName))) { return false; } while (false !== ($file = readdir($dh))) { if ($file == '..' or $file == '.') { continue; } $cur_file = $dirName . '/' . $file; if (is_dir($cur_file)) { $tmp_ar = getFileList($cur_file); if (is_array($tmp_ar)) { $ret_ar = array_merge($ret_ar, $tmp_ar); } } $ret_ar[] = $cur_file; } closedir($dh); natcasesort($ret_ar); return $ret_ar; }
/** * handle request and build XML * @access protected * */ function buildXml() { $_config =& CKEditor_Connector_Core_Factory::getInstance("Core_Config"); // Map the virtual path to the local server path. $_sServerDir = $this->_currentFolder->getServerPath(); if (!is_dir($_sServerDir)) { $this->_errorHandler->throwError(CKEDITOR_CONNECTOR_ERROR_FOLDER_NOT_FOUND); } // Create the "Folders" node. $oFoldersNode = new CKEditor_Connector_Utils_XmlNode("Folders"); $this->_connectorNode->addChild($oFoldersNode); $files = array(); if ($dh = @opendir($_sServerDir)) { while (($file = readdir($dh)) !== false) { if ($file != "." && $file != ".." && is_dir($_sServerDir . $file)) { $files[] = $file; } } closedir($dh); } else { $this->_errorHandler->throwError(CKEDITOR_CONNECTOR_ERROR_ACCESS_DENIED); } $resourceTypeInfo = $this->_currentFolder->getResourceTypeConfig(); if (sizeof($files) > 0) { natcasesort($files); $i = 0; foreach ($files as $file) { // Create the "Folder" node. $oFolderNode[$i] = new CKEditor_Connector_Utils_XmlNode("Folder"); $oFoldersNode->addChild($oFolderNode[$i]); $oFolderNode[$i]->addAttribute("name", CKEditor_Connector_Utils_FileSystem::convertToConnectorEncoding($file)); $i++; } } }
/** * Load terms and try to sort it by names * * @return Mage_CatalogSearch_Block_Term */ protected function _loadTerms() { if (empty($this->_terms)) { $this->_terms = array(); $terms = Mage::getResourceModel('catalogsearch/query_collection')->setPopularQueryFilter(Mage::app()->getStore()->getId())->setPageSize(100)->load()->getItems(); if (count($terms) == 0) { return $this; } $this->_maxPopularity = reset($terms)->getPopularity(); $this->_minPopularity = end($terms)->getPopularity(); $range = $this->_maxPopularity - $this->_minPopularity; $range = $range == 0 ? 1 : $range; foreach ($terms as $term) { if (!$term->getPopularity()) { continue; } $term->setRatio(($term->getPopularity() - $this->_minPopularity) / $range); $temp[$term->getName()] = $term; $termKeys[] = $term->getName(); } natcasesort($termKeys); foreach ($termKeys as $termKey) { $this->_terms[$termKey] = $temp[$termKey]; } } return $this; }
function export_template_list($path, $d = 0) { if (substr($path, strlen($path) - 1) != '/') { $path .= '/'; } $dirlist = array(); if ($handle = opendir($path)) { while (false !== ($file = readdir($handle))) { if ($file != '.' && $file != '..') { $file = $path . $file; if (!is_dir($file)) { $extension = get_extension($path); if (stripos($extension, 'bak') === false) { $dirlist[] = $file; } } elseif ($d >= 0) { $result = export_template_list($file . '/', $d + 1); $dirlist = array_merge($dirlist, $result); } } } closedir($handle); } if ($d == 0) { natcasesort($dirlist); } return $dirlist; }
/** * Get a list of editor font families * * @return string font family list * @param string $add Font family to add * @param string $remove Font family to remove */ protected static function getFonts() { $wf = WFEditor::getInstance(); $fonts = $wf->getParam('fontselect.fonts'); // get fonts using legacy parameters if (empty($fonts)) { $fonts = self::$fonts; $add = $wf->getParam('editor.theme_advanced_fonts_add'); $remove = $wf->getParam('editor.theme_advanced_fonts_remove'); if (empty($remove) && empty($add)) { return implode(';', $fonts); } $remove = preg_split('/[;,]+/', $remove); if (count($remove)) { foreach ($fonts as $key => $value) { foreach ($remove as $gone) { if ($gone && preg_match('/^' . $gone . '=/i', $value)) { // Remove family unset($fonts[$key]); } } } } foreach (explode(";", $add) as $new) { // Add new font family if (preg_match('/([^\\=]+)(\\=)([^\\=]+)/', trim($new)) && !in_array($new, $fonts)) { $fonts[] = $new; } } natcasesort($fonts); $fonts = implode(';', $fonts); } return $fonts; }
/** * Gets all objects * * @param CMS_poly_object_field $field, the reference field which will be used by those objects * @param boolean $sort, sort objects list (alphabetically by name). Use global $cms_language. Default false (unsorted). * @return array(string "CMS_object_{type}" => object CMS_object_{type}) * @access public * @static */ function getObjects(&$field, $sort = false) { $objectsNames = CMS_object_catalog::getObjectsNames(); $return = array(); foreach ($objectsNames as $anObjectName) { $return[$anObjectName] = new $anObjectName(array(), $field); } if ($sort) { global $cms_language; if (is_object($cms_language)) { $labels = array(); foreach ($return as $key => $object) { $labels[$key] = $object->getObjectLabel($cms_language); } //natural sort of objects natcasesort($labels); $returnSorted = array(); foreach ($labels as $key => $label) { $returnSorted[$key] = $return[$key]; } $return = $returnSorted; } } return $return; }
function wpdm_dir_tree() { $root = ''; if (!isset($_GET['task']) || $_GET['task'] != 'wpdm_dir_tree') { return; } $_POST['dir'] = urldecode($_POST['dir']); if (file_exists($_POST['dir'])) { $files = scandir($_POST['dir']); natcasesort($files); if (count($files) > 2) { /* The 2 accounts for . and .. */ echo "<ul class=\"jqueryFileTree\" style=\"display: none;\">"; // All dirs foreach ($files as $file) { if ($file != '.' && $file != '..' && file_exists($root . $_POST['dir'] . $file) && is_dir($root . $_POST['dir'] . $file)) { echo "<li class=\"directory collapsed\"><a id=\"" . uniqid() . "\" href=\"#\" rel=\"" . htmlentities($_POST['dir'] . $file) . "/\">" . htmlentities($file) . "</a></li>"; } } // All files foreach ($files as $file) { if ($file != '.' && $file != '..' && file_exists($root . $_POST['dir'] . $file) && !is_dir($root . $_POST['dir'] . $file)) { $ext = preg_replace('/^.*\\./', '', $file); echo "<li class=\"file ext_{$ext}\"><a id=\"" . uniqid() . "\" href=\"#\" rel=\"" . htmlentities($_POST['dir'] . $file) . "\">" . htmlentities($file) . "</a></li>"; } } echo "</ul>"; } } }