当前位置: 首页>>代码示例>>PHP>>正文


PHP normalize_version函数代码示例

本文整理汇总了PHP中normalize_version函数的典型用法代码示例。如果您正苦于以下问题:PHP normalize_version函数的具体用法?PHP normalize_version怎么用?PHP normalize_version使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了normalize_version函数的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: is_staging_gte

function is_staging_gte($b, $a)
{
    if ($a === $b) {
        return true;
    }
    $a = normalize_version($a);
    $b = normalize_version($b);
    $split_a = explode('.', $a);
    $split_b = explode('.', $b);
    foreach ($split_a as $i => $part_a) {
        $cmp = strcmp($part_a, $split_b[$i]);
        if (0 === $cmp) {
            continue;
        }
        // Weird thing to do to handle numeric (0,1) considered higher version than alpha, beta, rc.
        if (is_numeric($part_a) && !is_numeric($split_b[$i])) {
            return true;
        }
        if (!is_numeric($part_a) && is_numeric($split_b[$i])) {
            return false;
        }
        if (0 < $cmp) {
            return true;
        } else {
            return false;
        }
    }
    return false;
}
开发者ID:TRPmarketingsite,项目名称:marketingsite,代码行数:29,代码来源:common-common.php

示例2: test_environment

 public function test_environment()
 {
     global $CFG;
     require_once $CFG->libdir . '/environmentlib.php';
     list($envstatus, $environment_results) = check_moodle_environment(normalize_version($CFG->release), ENV_SELECT_RELEASE);
     $this->assertNotEmpty($envstatus);
     foreach ($environment_results as $environment_result) {
         $this->assertTrue($environment_result->getStatus(), "Problem detected in environment ({$environment_result->part}:{$environment_result->info}), fix all warnings and errors!");
     }
 }
开发者ID:masaterutakeno,项目名称:MoodleMobile,代码行数:10,代码来源:environment_test.php

示例3: test_environment

 /**
  * Test the environment.
  */
 public function test_environment()
 {
     global $CFG;
     require_once $CFG->libdir . '/environmentlib.php';
     list($envstatus, $environment_results) = check_moodle_environment(normalize_version($CFG->release), ENV_SELECT_RELEASE);
     $this->assertNotEmpty($envstatus);
     foreach ($environment_results as $environment_result) {
         if ($environment_result->part === 'php_setting' and $environment_result->info === 'opcache.enable' and $environment_result->getLevel() === 'optional' and $environment_result->getStatus() === false) {
             $this->markTestSkipped('OPCache extension is not necessary for unit testing.');
             continue;
         }
         $this->assertTrue($environment_result->getStatus(), "Problem detected in environment ({$environment_result->part}:{$environment_result->info}), fix all warnings and errors!");
     }
 }
开发者ID:EmmanuelYupit,项目名称:educursos,代码行数:17,代码来源:environment_test.php

示例4: get_string

 $strinstallation = get_string('installation', 'install');
 // remove current session content completely
 session_get_instance()->terminate_current();
 if (empty($agreelicense)) {
     $strlicense = get_string('license');
     $PAGE->navbar->add($strlicense);
     $PAGE->set_title($strinstallation . ' - Moodle ' . $CFG->target_release);
     $PAGE->set_heading($strinstallation);
     $PAGE->set_cacheable(false);
     $output = $PAGE->get_renderer('core', 'admin');
     echo $output->install_licence_page();
     die;
 }
 if (empty($confirmrelease)) {
     require_once $CFG->libdir . '/environmentlib.php';
     list($envstatus, $environment_results) = check_moodle_environment(normalize_version($release), ENV_SELECT_RELEASE);
     $strcurrentrelease = get_string('currentrelease');
     $PAGE->navbar->add($strcurrentrelease);
     $PAGE->set_title($strinstallation);
     $PAGE->set_heading($strinstallation . ' - Moodle ' . $CFG->target_release);
     $PAGE->set_cacheable(false);
     $output = $PAGE->get_renderer('core', 'admin');
     echo $output->install_environment_page($maturity, $envstatus, $environment_results, $release);
     die;
 }
 //TODO: add a page with list of non-standard plugins here
 $strdatabasesetup = get_string('databasesetup');
 upgrade_init_javascript();
 $PAGE->navbar->add($strdatabasesetup);
 $PAGE->set_title($strinstallation . ' - Moodle ' . $CFG->target_release);
 $PAGE->set_heading($strinstallation);
开发者ID:numbas,项目名称:moodle,代码行数:31,代码来源:index.php

示例5: install_cli_database

/**
 * Install Moodle DB,
 * config.php must exist, there must not be any tables in db yet.
 *
 * @param array $options adminpass is mandatory
 * @param bool $interactive
 * @return void
 */
function install_cli_database(array $options, $interactive)
{
    global $CFG, $DB;
    require_once $CFG->libdir . '/environmentlib.php';
    require_once $CFG->libdir . '/upgradelib.php';
    // show as much debug as possible
    @error_reporting(E_ALL | E_STRICT);
    @ini_set('display_errors', '1');
    $CFG->debug = E_ALL | E_STRICT;
    $CFG->debugdisplay = true;
    $CFG->version = '';
    $CFG->release = '';
    $CFG->branch = '';
    $version = null;
    $release = null;
    $branch = null;
    // read $version and $release
    require $CFG->dirroot . '/version.php';
    if ($DB->get_tables()) {
        cli_error(get_string('clitablesexist', 'install'));
    }
    if (empty($options['adminpass'])) {
        cli_error('Missing required admin password');
    }
    // test environment first
    list($envstatus, $environment_results) = check_moodle_environment(normalize_version($release), ENV_SELECT_RELEASE);
    if (!$envstatus) {
        $errors = environment_get_errors($environment_results);
        cli_heading(get_string('environment', 'admin'));
        foreach ($errors as $error) {
            list($info, $report) = $error;
            echo "!! {$info} !!\n{$report}\n\n";
        }
        exit(1);
    }
    if (!$DB->setup_is_unicodedb()) {
        if (!$DB->change_db_encoding()) {
            // If could not convert successfully, throw error, and prevent installation
            cli_error(get_string('unicoderequired', 'admin'));
        }
    }
    if ($interactive) {
        cli_separator();
        cli_heading(get_string('databasesetup'));
    }
    // install core
    install_core($version, true);
    set_config('release', $release);
    set_config('branch', $branch);
    if (PHPUNIT_TEST) {
        // mark as test database as soon as possible
        set_config('phpunittest', 'na');
    }
    // install all plugins types, local, etc.
    upgrade_noncore(true);
    // set up admin user password
    $DB->set_field('user', 'password', hash_internal_user_password($options['adminpass']), array('username' => 'admin'));
    // rename admin username if needed
    if (isset($options['adminuser']) and $options['adminuser'] !== 'admin' and $options['adminuser'] !== 'guest') {
        $DB->set_field('user', 'username', $options['adminuser'], array('username' => 'admin'));
    }
    // indicate that this site is fully configured
    set_config('rolesactive', 1);
    upgrade_finished();
    // log in as admin - we need do anything when applying defaults
    $admins = get_admins();
    $admin = reset($admins);
    session_set_user($admin);
    // apply all default settings, do it twice to fill all defaults - some settings depend on other setting
    admin_apply_default_settings(NULL, true);
    admin_apply_default_settings(NULL, true);
    set_config('registerauth', '');
    // set the site name
    if (isset($options['shortname']) and $options['shortname'] !== '') {
        $DB->set_field('course', 'shortname', $options['shortname'], array('format' => 'site'));
    }
    if (isset($options['fullname']) and $options['fullname'] !== '') {
        $DB->set_field('course', 'fullname', $options['fullname'], array('format' => 'site'));
    }
}
开发者ID:JP-Git,项目名称:moodle,代码行数:88,代码来源:installlib.php

示例6: environment_check_database

/**
 * This function will check if database requirements are satisfied
 *
 * @global object
 * @uses NO_VERSION_DATA_FOUND
 * @uses NO_DATABASE_SECTION_FOUND
 * @uses NO_DATABASE_VENDORS_FOUND
 * @uses NO_DATABASE_VENDOR_MYSQL_FOUND
 * @uses NO_DATABASE_VENDOR_POSTGRES_FOUND
 * @uses NO_DATABASE_VENDOR_VERSION_FOUND
 * @param string $version xml version we are going to use to test this server
 * @param int $env_select one of ENV_SELECT_NEWER | ENV_SELECT_DATAROOT | ENV_SELECT_RELEASE decide xml to use.
 * @return object results encapsulated in one environment_result object
 */
function environment_check_database($version, $env_select)
{
    global $DB;
    $result = new environment_results('database');
    $vendors = array();
    //Array of vendors in version
    /// Get the enviroment version we need
    if (!($data = get_environment_for_version($version, $env_select))) {
        /// Error. No version data found
        $result->setStatus(false);
        $result->setErrorCode(NO_VERSION_DATA_FOUND);
        return $result;
    }
    /// Extract the database part
    if (!isset($data['#']['DATABASE'])) {
        /// Error. No DATABASE section found
        $result->setStatus(false);
        $result->setErrorCode(NO_DATABASE_SECTION_FOUND);
        return $result;
    } else {
        /// Extract level
        $level = get_level($data['#']['DATABASE']['0']);
    }
    /// Extract DB vendors. At least 2 are mandatory (mysql & postgres)
    if (!isset($data['#']['DATABASE']['0']['#']['VENDOR'])) {
        /// Error. No VENDORS found
        $result->setStatus(false);
        $result->setErrorCode(NO_DATABASE_VENDORS_FOUND);
        return $result;
    } else {
        /// Extract vendors
        foreach ($data['#']['DATABASE']['0']['#']['VENDOR'] as $vendor) {
            if (isset($vendor['@']['name']) && isset($vendor['@']['version'])) {
                $vendors[$vendor['@']['name']] = $vendor['@']['version'];
                $vendorsxml[$vendor['@']['name']] = $vendor;
            }
        }
    }
    /// Check we have the mysql vendor version
    if (empty($vendors['mysql'])) {
        $result->setStatus(false);
        $result->setErrorCode(NO_DATABASE_VENDOR_MYSQL_FOUND);
        return $result;
    }
    /// Check we have the postgres vendor version
    if (empty($vendors['postgres'])) {
        $result->setStatus(false);
        $result->setErrorCode(NO_DATABASE_VENDOR_POSTGRES_FOUND);
        return $result;
    }
    /// Now search the version we are using (depending of vendor)
    $current_vendor = $DB->get_dbfamily();
    $dbinfo = $DB->get_server_info();
    $current_version = normalize_version($dbinfo['version']);
    $needed_version = $vendors[$current_vendor];
    /// Check we have a needed version
    if (!$needed_version) {
        $result->setStatus(false);
        $result->setErrorCode(NO_DATABASE_VENDOR_VERSION_FOUND);
        return $result;
    }
    /// And finally compare them, saving results
    if (version_compare($current_version, $needed_version, '>=')) {
        $result->setStatus(true);
    } else {
        $result->setStatus(false);
    }
    $result->setLevel($level);
    $result->setCurrentVersion($current_version);
    $result->setNeededVersion($needed_version);
    $result->setInfo($current_vendor);
    /// Do any actions defined in the XML file.
    process_environment_result($vendorsxml[$current_vendor], $result);
    return $result;
}
开发者ID:masaterutakeno,项目名称:MoodleMobile,代码行数:89,代码来源:environmentlib.php

示例7: get_string

     $PAGE->set_cacheable(false);
     echo $OUTPUT->header();
     echo $OUTPUT->heading("Moodle {$release}");
     if (isset($maturity)) {
         // main version.php declares moodle code maturity
         if ($maturity < MATURITY_STABLE) {
             $maturitylevel = get_string('maturity' . $maturity, 'admin');
             echo $OUTPUT->box($OUTPUT->container(get_string('maturitycorewarning', 'admin', $maturitylevel)) . $OUTPUT->container($OUTPUT->doc_link('admin/versions', get_string('morehelp'))), 'generalbox maturitywarning');
         }
     }
     $releasenoteslink = get_string('releasenoteslink', 'admin', 'http://docs.moodle.org/en/Release_Notes');
     $releasenoteslink = str_replace('target="_blank"', 'onclick="this.target=\'_blank\'"', $releasenoteslink);
     // extremely ugly validation hack
     echo $OUTPUT->box($releasenoteslink, 'generalbox releasenoteslink');
     require_once $CFG->libdir . '/environmentlib.php';
     if (!check_moodle_environment(normalize_version($release), $environment_results, true, ENV_SELECT_RELEASE)) {
         print_upgrade_reload("index.php?agreelicense=1&amp;lang={$CFG->lang}");
     } else {
         echo $OUTPUT->notification(get_string('environmentok', 'admin'), 'notifysuccess');
         echo $OUTPUT->continue_button(new moodle_url('/admin/index.php', array('agreelicense' => 1, 'confirmrelease' => 1, 'lang' => $CFG->lang)));
     }
     echo $OUTPUT->footer();
     die;
 }
 $strdatabasesetup = get_string('databasesetup');
 upgrade_init_javascript();
 $PAGE->navbar->add($strdatabasesetup);
 $PAGE->set_title($strinstallation . ' - Moodle ' . $CFG->target_release);
 $PAGE->set_heading($strinstallation);
 $PAGE->set_cacheable(false);
 echo $OUTPUT->header();
开发者ID:nfreear,项目名称:moodle,代码行数:31,代码来源:index.php

示例8: array

$current_version = $CFG->release;
/// Calculate list of versions
$versions = array();
if ($contents = load_environment_xml()) {
    if ($env_versions = get_list_of_environment_versions($contents)) {
        /// Set the current version at the beginning
        $env_version = normalize_version($current_version);
        //We need this later (for the upwards)
        $versions[$env_version] = $current_version;
        /// If no version has been previously selected, default to $current_version
        if (empty($version)) {
            $version = $env_version;
        }
        ///Iterate over each version, adding bigged than current
        foreach ($env_versions as $env_version) {
            if (version_compare(normalize_version($current_version), $env_version, '<')) {
                $versions[$env_version] = $env_version;
            }
        }
        /// Add 'upwards' to the last element
        $versions[$env_version] = $env_version . ' ' . $strupwards;
    } else {
        $versions = array('error' => $strerror);
    }
}
/// Print form and popup menu
echo '<div style="text-align:center">' . $strmoodleversion . ' ';
popup_form("{$CFG->wwwroot}/{$CFG->admin}/environment.php?version=", $versions, 'selectversion', $version, '');
echo '</div>';
/// End of main box
print_simple_box_end();
开发者ID:BackupTheBerlios,项目名称:samouk-svn,代码行数:31,代码来源:environment.php

示例9: get_site_info

 /**
  * Gets a text-based site version description.
  *
  * @return string The site info
  */
 public static function get_site_info()
 {
     global $CFG;
     $output = '';
     // All developers have to understand English, do not localise!
     $env = self::get_environment();
     $output .= "Moodle " . $env['moodleversion'];
     if ($hash = self::get_git_hash()) {
         $output .= ", {$hash}";
     }
     $output .= "\n";
     // Add php version.
     require_once $CFG->libdir . '/environmentlib.php';
     $output .= "Php: " . normalize_version($env['phpversion']);
     // Add database type and version.
     $output .= ", " . $env['dbtype'] . ": " . $env['dbversion'];
     // OS details.
     $output .= ", OS: " . $env['os'] . "\n";
     return $output;
 }
开发者ID:evltuma,项目名称:moodle,代码行数:25,代码来源:util.php

示例10: restrict_php_version

/**
 * Check if the current PHP version is greater than or equal to an
 * unsupported version.
 *
 * @param object $result an environment_results instance
 * @param string $version the version of PHP that can't be used
 * @return bool result of version check
 */
function restrict_php_version(&$result, $version)
{
    // Get the current PHP version.
    $currentversion = normalize_version(phpversion());
    // Confirm we're using a supported PHP version.
    if (version_compare($currentversion, $version, '<')) {
        // Everything is ok, the restriction doesn't apply.
        return false;
    } else {
        // We're using an unsupported PHP version, apply restriction.
        return true;
    }
}
开发者ID:anawu2006,项目名称:PeerLearning,代码行数:21,代码来源:environmentlib.php

示例11: file_get_contents

			<legend>Script Repository</legend>
			<table id='fppScripts' cellspacing='5'>
				<tbody>
<?php 
$indexCSV = file_get_contents("https://raw.githubusercontent.com/FalconChristmas/fpp-scripts/master/index.csv");
$lines = explode("\n", $indexCSV);
$count = 0;
foreach ($lines as $line) {
    if (preg_match("/^#/", $line)) {
        continue;
    }
    $parts = explode(',', $line);
    if (count($parts) < 4) {
        continue;
    }
    if (normalize_version($parts[3]) > $rfs_ver) {
        continue;
    }
    if ($count > 0) {
        ?>
				<tr><td colspan='3'><hr></td></tr>
<?php 
    }
    ?>
				<tr><td rowspan='3' valign='top'><input type='button' class='buttons' value='Install' onClick='InstallRemoteScript("<?php 
    echo $parts[0];
    ?>
", "<?php 
    echo $parts[1];
    ?>
");'><br />
开发者ID:randyr505,项目名称:fpp,代码行数:31,代码来源:scriptbrowser.php

示例12: mnetadmin_rpc_upgrade

function mnetadmin_rpc_upgrade($user, $json_response = true)
{
    global $CFG, $USER;
    // Invoke local user and check his rights
    if ($auth_response = invoke_local_user((array) $user)) {
        if ($json_response) {
            return $auth_response;
        } else {
            return json_decode($auth_response);
        }
    }
    // Creating response
    $response = new stdclass();
    $response->status = RPC_SUCCESS;
    require "{$CFG->dirroot}/version.php";
    // defines $version, $release, $branch and $maturity
    $CFG->target_release = $release;
    // used during installation and upgrades
    if ($version < $CFG->version) {
        $response->status = RPC_FAILURE_RUN;
        $response->error = get_string('downgradedcore', 'error');
        $response->errors[] = get_string('downgradedcore', 'error');
        if ($json_response) {
            return json_encode($response);
        } else {
            return $response;
        }
    }
    $oldversion = "{$CFG->release} ({$CFG->version})";
    $newversion = "{$release} ({$version})";
    if (!moodle_needs_upgrading()) {
        $response->message = get_string('cliupgradenoneed', 'core_admin', $newversion);
        if ($json_response) {
            return json_encode($response);
        } else {
            return $response;
        }
    }
    // debug_trace('Remote Upgrade : Environment check');
    list($envstatus, $environment_results) = check_moodle_environment(normalize_version($release), ENV_SELECT_NEWER);
    if (!$envstatus) {
        $response->status = RPC_FAILURE_RUN;
        $response->error = vmoodle_get_string('environmentissues', 'vmoodleadminset_upgrade');
        $response->errors[] = vmoodle_get_string('environmentissues', 'vmoodleadminset_upgrade');
        $response->detail = $environment_results;
        if ($json_response) {
            return json_encode($response);
        } else {
            return $response;
        }
    }
    // Test plugin dependencies.
    // debug_trace('Remote Upgrade : Plugins check');
    $failed = array();
    if (!plugin_manager::instance()->all_plugins_ok($version, $failed)) {
        $response->status = RPC_FAILURE_RUN;
        $response->error = get_string('pluginschecktodo', 'admin');
        $response->errors[] = get_string('pluginschecktodo', 'admin');
        if ($json_response) {
            return json_encode($response);
        } else {
            return $response;
        }
    }
    ob_start();
    // debug_trace('Remote Upgrade : Upgrade core');
    if ($version > $CFG->version) {
        upgrade_core($version, false);
    }
    set_config('release', $release);
    set_config('branch', $branch);
    // unconditionally upgrade
    // debug_trace('Remote Upgrade : Upgrade other');
    upgrade_noncore(false);
    // log in as admin - we need doanything permission when applying defaults
    // debug_trace('Remote Upgrade : Turning ADMIN ');
    session_set_user(get_admin());
    // apply all default settings, just in case do it twice to fill all defaults
    // debug_trace('Remote Upgrade : Applying settings ');
    admin_apply_default_settings(NULL, false);
    admin_apply_default_settings(NULL, false);
    ob_end_clean();
    $response->message = vmoodle_get_string('upgradecomplete', 'vmoodleadminset_upgrade', $newversion);
    if ($json_response) {
        return json_encode($response);
    } else {
        return $response;
    }
}
开发者ID:gabrielrosset,项目名称:moodle-local_vmoodle,代码行数:89,代码来源:rpclib.php

示例13: test_restrict_php_version_less_than_restricted_version

 /**
  * Test the restrict_php_version() function returns false if the current
  * PHP version is less than the restricted version
  */
 public function test_restrict_php_version_less_than_restricted_version()
 {
     global $CFG;
     require_once $CFG->libdir . '/environmentlib.php';
     $result = new environment_results('php');
     $delimiter = '.';
     // Get the current PHP version.
     $currentversion = explode($delimiter, normalize_version(phpversion()));
     // Lets increase the major version to ensure don't trip the restriction.
     $currentversion[0]++;
     $restrictedversion = implode($delimiter, $currentversion);
     // Make sure the status is true before the test to see it flip to false.
     $result->setStatus(true);
     $this->assertFalse(restrict_php_version($result, $restrictedversion), 'restrict_php_version returns false if the current version is less than the restricted version');
 }
开发者ID:janeklb,项目名称:moodle,代码行数:19,代码来源:environment_test.php

示例14: get_environment_info

 /**
  * Returns environment info: php version, db vendor, db version,
  * moodle version and plugin version.
  *
  * @return array
  */
 public static function get_environment_info()
 {
     global $DB, $CFG;
     require_once "{$CFG->libdir}/environmentlib.php";
     require_once "{$CFG->libdir}/adminlib.php";
     $envinfo = array('system' => php_uname('s'), 'server' => php_sapi_name(), 'phpversion' => normalize_version(phpversion()), 'dbvendor' => $DB->get_dbvendor(), 'dbversion' => '', 'moodleversion' => '', 'pluginversion' => '');
     $dbinfo = $DB->get_server_info();
     if (!empty($dbinfo['version'])) {
         $envinfo['dbversion'] = normalize_version($dbinfo['version']);
     }
     if ($version = get_component_version('moodle')) {
         $envinfo['moodleversion'] = normalize_version($version);
     }
     if ($version = get_component_version('block_mhaairs')) {
         $envinfo['pluginversion'] = normalize_version($version);
     }
     return (object) $envinfo;
 }
开发者ID:itamart,项目名称:moodle-block_mhaairs,代码行数:24,代码来源:block_mhaairs_util.php


注:本文中的normalize_version函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。