本文整理汇总了PHP中get_list_of_environment_versions函数的典型用法代码示例。如果您正苦于以下问题:PHP get_list_of_environment_versions函数的具体用法?PHP get_list_of_environment_versions怎么用?PHP get_list_of_environment_versions使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_list_of_environment_versions函数的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: test_get_list_of_environment_versions
/**
* Test the get_list_of_environment_versions() function.
*/
public function test_get_list_of_environment_versions()
{
global $CFG;
require_once $CFG->libdir . '/environmentlib.php';
// Build a sample xmlised environment.xml.
$xml = <<<END
<COMPATIBILITY_MATRIX>
<MOODLE version="1.9">
<PHP_EXTENSIONS>
<PHP_EXTENSION name="xsl" level="required" />
</PHP_EXTENSIONS>
</MOODLE>
<MOODLE version="2.5">
<PHP_EXTENSIONS>
<PHP_EXTENSION name="xsl" level="required" />
</PHP_EXTENSIONS>
</MOODLE>
<MOODLE version="2.6">
<PHP_EXTENSIONS>
<PHP_EXTENSION name="xsl" level="required" />
</PHP_EXTENSIONS>
</MOODLE>
<MOODLE version="2.7">
<PHP_EXTENSIONS>
<PHP_EXTENSION name="xsl" level="required" />
</PHP_EXTENSIONS>
</MOODLE>
<PLUGIN name="block_test">
<PHP_EXTENSIONS>
<PHP_EXTENSION name="xsl" level="required" />
</PHP_EXTENSIONS>
</PLUGIN>
</COMPATIBILITY_MATRIX>
END;
$environemt = xmlize($xml);
$versions = get_list_of_environment_versions($environemt);
$this->assertCount(5, $versions);
$this->assertContains('1.9', $versions);
$this->assertContains('2.5', $versions);
$this->assertContains('2.6', $versions);
$this->assertContains('2.7', $versions);
$this->assertContains('all', $versions);
}
示例2: get_environment_for_version
/**
* This function will return the xmlized data belonging to one Moodle version
*
* @param string $version top version from which we start to look backwards
* @param int $env_select one of ENV_SELECT_NEWER | ENV_SELECT_DATAROOT | ENV_SELECT_RELEASE decide xml to use.
* @return mixed the xmlized structure or false on error
*/
function get_environment_for_version($version, $env_select)
{
/// Normalize the version requested
$version = normalize_version($version);
/// Load xml file
if (!($contents = load_environment_xml($env_select))) {
return false;
}
/// Detect available versions
if (!($versions = get_list_of_environment_versions($contents))) {
return false;
}
/// If the version requested is available
if (!in_array($version, $versions)) {
return false;
}
/// We now we have it. Extract from full contents.
$fl_arr = array_flip($versions);
return $contents['COMPATIBILITY_MATRIX']['#']['MOODLE'][$fl_arr[$version]];
}
示例3: print_simple_box
break;
case INSTALLED:
print_simple_box(get_string('componentinstalled', 'admin'), 'center');
break;
}
}
}
/// Start of main box
print_simple_box_start('center');
echo "<div style=\"text-align:center\">" . $stradminhelpenvironment . "</div><br />";
/// Get current Moodle version
$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
示例4: get_environment_for_version
/**
* This function will return the xmlized data belonging to one Moodle version
*
* @param string $version top version from which we start to look backwards
* @param int|string $env_select one of ENV_SELECT_NEWER | ENV_SELECT_DATAROOT | ENV_SELECT_RELEASE decide xml to use. String means plugin name.
* @return mixed the xmlized structure or false on error
*/
function get_environment_for_version($version, $env_select)
{
/// Normalize the version requested
$version = normalize_version($version);
/// Load xml file
if (!($contents = load_environment_xml($env_select))) {
return false;
}
/// Detect available versions
if (!($versions = get_list_of_environment_versions($contents))) {
return false;
}
// If $env_select is not numeric then this is being called on a plugin, and not the core environment.xml
// If a version of 'all' is in the arry is also means that the new <PLUGIN> tag was found, this should
// be matched against any version of Moodle.
if (!is_numeric($env_select) && in_array('all', $versions) && environment_verify_plugin($env_select, $contents['COMPATIBILITY_MATRIX']['#']['PLUGIN'][0])) {
return $contents['COMPATIBILITY_MATRIX']['#']['PLUGIN'][0];
}
/// If the version requested is available
if (!in_array($version, $versions)) {
return false;
}
/// We now we have it. Extract from full contents.
$fl_arr = array_flip($versions);
return $contents['COMPATIBILITY_MATRIX']['#']['MOODLE'][$fl_arr[$version]];
}