-<?php //$Id$
+<?php
+// This file is part of Moodle - http://moodle.org/
+//
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
+
/**
* CLI support functions
- * @author Dilan
+ *
+ * @package moodlecore
+ * @copyright Dilan
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
-//include PEAR Console libraries
+/**
+ * include PEAR Console libraries
+ */
set_include_path($CFG->libdir . PATH_SEPARATOR . $CFG->libdir . '/pear/');
require_once('Console/Getopt.php');
* Check the validity of the language
* return true or false
*
+ * @global array
* @param string $lang (short code for language)
- * @return true/false
+ * @return bool true/false
*/
function valid_language($lang) {
global $DEFAULT;
* Return true or false
*
* @param string $value
- * @return true/false
+ * @return bool true/false
*/
function valid_yes_no($value){
$valid=array('yes','y','n','no');
* Can value have a valid integer in the given range
* Return true or false
* @link valid_param()
- *
*
- * @param mixedtype $value
+ * @uses PARAM_INT
+ * @param mixed $value
* @param int $start
* @param int $end
- * @return true/false
+ * @return bool true/false
*/
function valid_int_range($value,$start,$end) {
if (valid_param($value,PARAM_INT)) {
* Take a value and and check it with the given set of values
* If value if found in the set return true. False otherwise
*
- * @param mixed type $value
- * @param array $set of valid elements
+ * @param mixed $value
+ * @param array $set of valid elements
* @return boolean
*/
* Take a value and Type of the value
* If value match the type return true, false otherwise
* uses {@link clean_param()} in moodlelib.php
- * @param mixedtype $value
+ *
+ * @param mixed $value
* @param int $type
* @return boolean
*/
/**
* Creat long arument list for PEAR method invocation using LONGOPTOIN array
*
- * @param long option array $long_opt
+ * @uses CLI_VAL_REQ
+ * @uses CLI_VAL_OPT
+ * @param array $long_opt long option array $long_opt
* @return PEAR method compatible long option array
*/
function create_long_options($long_opt) {
* This funtion return an array of options with option as key containing the value of
* respective option
*
+ * @global array
* @param array of option arguments as defined by PEAR GetOpt calss $opt
* @return return a options arguments with options as keys and values as respective value for key
*/
/**
* Validate options values
*
+ * @uses CLI_FULL
+ * @uses CLI_NO
* @param array $options
*/
function validate_option_values($options){
/**
* Read an integer
*
+ * @uses PARAM_INT
* @return integer
*/
function read_int() {
/**
* Read yes/no argument
*
- * @return string yes/no
+ * @return string|void yes/no or void
*/
function read_yes_no() {
$input=strtolower(read());
/**
* Read a boolean parameter from the input
*
+ * @uses PARAM_BOOL
* @return boolean
*/
function read_boolean(){
/**
* Reading an element from a given set
*
- * @param mixed type array $set
- * @return mixed type
+ * @param mixed array $set
+ * @return mixed
*/
function read_element($set=array()) {
$input=read();
}
}
//=========================================================================//
+/**
+ * Read URL
+ *
+ * @uses PARAM_URL
+ * @return mixed
+ */
function read_url() {
$input = read();
$localhost = false;
//=========================================================================//
/**
* Enter description here...
- *
+ * @todo Document this function
* @return string
*/
function read_dir() {
/**
* Print environment status to standard out
*
- * @param array $env, of type object
+ * @param array $env of type object
*/
function print_environment_status($env = array()) {
console_write( get_string('name') . "\t\t\t" . get_string('info') . "\t" . get_string('status') . "\n\r", '', false);
/**
* Print environment status to standard out
*
- * @param array $env, of type object
+ * @param array $env of type object
*/
function print_environment_status_detailed($env = array()) {
console_write("Status\t\tLevel\t\tCurrent ver\tRequired ver\t\tPart\t\tInfo\n\r",'',false);