print_tabs(array($tabs), 'mnetthemes');
$themes = get_list_of_plugins("theme");
- $sesskey = !empty($USER->id) ? $USER->sesskey : '';
+ $sesskey = sesskey();
echo '<table style="margin-left:auto;margin-right:auto;" cellpadding="7" cellspacing="5">';
return;
}
- $adminroot =& admin_get_root(false, false); //settings not required - only pages
+ $adminroot = admin_get_root(false, false); //settings not required - only pages
// fetch the path parameter
$this->section = $section;
- $current =& $adminroot->locate($section, true);
+ $current = $adminroot->locate($section, true);
$this->visiblepathtosection = array_reverse($current->visiblepath);
// all done
return $this->url;
}
- $adminroot =& admin_get_root(false, false); //settings not required - only pages
+ $adminroot = admin_get_root(false, false); //settings not required - only pages
- $root =& $adminroot->locate($this->section);
- if (is_a($root, 'admin_externalpage')) {
+ $root = $adminroot->locate($this->section);
+ if ($root instanceof admin_externalpage) {
return $root->url;
} else {
return ($CFG->wwwroot . '/' . $CFG->admin . '/settings.php');
$query = trim(optional_param('query', '', PARAM_NOTAGS)); // Search string
-$adminroot =& admin_get_root(); // need all settings here
+$adminroot = admin_get_root(); // need all settings here
$adminroot->search = $query; // So we can reference it in search boxes later in this invocation
$statusmsg = '';
$errormsg = '';
if (admin_write_settings($data)) {
$statusmsg = get_string('changessaved');
}
- $adminroot =& admin_get_root(true); //reload tree
+ $adminroot = admin_get_root(true); //reload tree
if (!empty($adminroot->errors)) {
$errormsg = get_string('errorwithsettings', 'admin');
/// no guest autologin
require_login(0, false);
-$adminroot =& admin_get_root(); // need all settings
-$page =& $adminroot->locate($section);
+$adminroot = admin_get_root(); // need all settings
+$page = $adminroot->locate($section);
-if (empty($page) or !is_a($page, 'admin_settingpage')) {
+if (empty($page) or !($page instanceof admin_settingpage)) {
print_error('sectionerror', 'admin', "$CFG->wwwroot/$CFG->admin/");
die;
}
/// no guest autologin
require_login(0, false);
-$adminroot =& admin_get_root(); // need all settings
+$adminroot = admin_get_root(); // need all settings
admin_externalpage_setup('upgradesettings'); // now hidden page
// now we'll deal with the case that the admin has submitted the form with new settings
if ($data = data_submitted() and confirm_sesskey()) {
$count = admin_write_settings($data);
- $adminroot =& admin_get_root(true); //reload tree
+ $adminroot = admin_get_root(true); //reload tree
}
$newsettings = admin_output_new_settings_by_page($adminroot);
if (get_user_preferences('admin_bookmarks')) {
// this is expensive! Only require when bookmakrs exist..
require_once($CFG->libdir.'/adminlib.php');
- $adminroot =& admin_get_root(false, false); // settings not required - only pages
+ $adminroot = admin_get_root(false, false); // settings not required - only pages
$bookmarks = explode(',', get_user_preferences('admin_bookmarks'));
// hmm... just a liiitle (potentially) processor-intensive
foreach($bookmarks as $bookmark) {
$temp = $adminroot->locate($bookmark);
- if (is_a($temp, 'admin_settingpage')) {
+ if ($temp instanceof admin_settingpage) {
$this->content->text .= '<li><a href="' . $CFG->wwwroot . '/' . $CFG->admin . '/settings.php?section=' . $bookmark . '">' . $temp->visiblename . "</a></li>\n";
- } else if (is_a($temp, 'admin_externalpage')) {
+ } else if ($temp instanceof admin_externalpage) {
$this->content->text .= '<li><a href="' . $temp->url . '">' . $temp->visiblename . "</a></li>\n";
}
}
require_once($CFG->libdir.'/adminlib.php');
require_login();
-$adminroot =& admin_get_root(false, false); // settings not required - only pages
+$adminroot = admin_get_root(false, false); // settings not required - only pages
if ($section = optional_param('section', '', PARAM_SAFEDIR) and confirm_sesskey()) {
$temp = $adminroot->locate($section);
- if (is_a($temp, 'admin_settingpage') || is_a($temp, 'admin_externalpage')) {
+ if ($temp instanceof admin_settingpage || $temp instanceof admin_externalpage) {
$bookmarks[] = $section;
$bookmarks = implode(',', $bookmarks);
set_user_preference('admin_bookmarks', $bookmarks);
die;
}
- if (is_a($temp, 'admin_settingpage')) {
+ if ($temp instanceof admin_settingpage) {
redirect($CFG->wwwroot . '/' . $CFG->admin . '/settings.php?section=' . $section);
- } elseif (is_a($temp, 'admin_externalpage')) {
+ } elseif ($temp instanceof admin_externalpage) {
redirect($temp->url);
}
require_once($CFG->libdir.'/adminlib.php');
require_login();
-$adminroot =& admin_get_root(false, false); // settings not required - only pages
+$adminroot = admin_get_root(false, false); // settings not required - only pages
if ($section = optional_param('section', '', PARAM_SAFEDIR) and confirm_sesskey()) {
$temp = $adminroot->locate($section);
- if (is_a($temp, 'admin_externalpage')) {
+ if ($temp instanceof admin_externalpage) {
redirect($temp->url, get_string('bookmarkdeleted','admin'));
- } elseif (is_a($temp, 'admin_settingpage')) {
+ } elseif ($temp instanceof admin_settingpage) {
redirect($CFG->wwwroot . '/' . $CFG->admin . '/settings.php?section=' . $section);
} else {
redirect($CFG->wwwroot);
function build_tree (&$content) {
global $CFG;
- if (is_a($content, 'admin_settingpage')) {
+ if ($content instanceof admin_settingpage) {
// show hidden pages in tree if hidden page active
if ($content->check_access() and (($content->name == $this->section) or !$content->is_hidden())) {
$class = ($content->name == $this->section) ? 'link current' : 'link';
}
$this->create_item($content->visiblename, $CFG->wwwroot.'/'.$CFG->admin.'/settings.php?section='.$content->name,$CFG->pixpath.'/i/item.gif', $class);
}
- } else if (is_a($content, 'admin_externalpage')) {
+ } else if ($content instanceof admin_externalpage) {
// show hidden pages in tree if hidden page active
if ($content->check_access() and (($content->name == $this->section) or !$content->is_hidden())) {
$class = ($content->name == $this->section) ? 'link current' : 'link';
}
$this->create_item($content->visiblename, $content->url, $CFG->pixpath.'/i/item.gif', $class);
}
- } else if (is_a($content, 'admin_category')) {
+ } else if ($content instanceof admin_category) {
if ($content->check_access() and !$content->is_hidden()) {
// check if the category we're currently printing is a parent category for the current page; if it is, we
}
require_once($CFG->libdir.'/adminlib.php');
- $adminroot =& admin_get_root(false, false); // settings not required - only pages
+ $adminroot = admin_get_root(false, false); // settings not required - only pages
if ($current = $adminroot->locate($this->section, true)) {
$this->pathtosection = $current->path;
} else {
$page = page_create_object($this->instance->pagetype, $this->instance->pageid);
}
- $script = $page->url_get_full(array('instanceid' => $this->instance->id, 'sesskey' => $USER->sesskey));
+ $script = $page->url_get_full(array('instanceid' => $this->instance->id, 'sesskey' => sesskey()));
if (empty($this->instance->pinned)) {
$movebuttons .= '<a class="icon roles" title="'. $this->str->assignroles .'" href="'.$CFG->wwwroot.'/'.$CFG->admin.'/roles/assign.php?contextid='.$context->id.'">' .
// This instance is configured - show Add/Edit feeds link.
$script = $page->url_get_full(
array('instanceid' => $this->instance->id,
- 'sesskey' => $USER->sesskey,
+ 'sesskey' => sesskey(),
'blockaction' => 'config',
'currentaction' => 'managefeeds',
'id' => $this->courseid,
if (has_capability('block/rss_client:manageanyfeeds', $context)) {
$script = $page->url_get_full(
array('instanceid' => $this->instance->id,
- 'sesskey' => $USER->sesskey,
+ 'sesskey' => sesskey(),
'blockaction' => 'config',
'currentaction' => 'configblock',
'id' => $this->courseid,
|| has_capability('block/rss_client:createsharedfeeds', $context)) {
$addrsspage = $page->url_get_full(array('instanceid' => $this->instance->id,
- 'sesskey' => $USER->sesskey,
+ 'sesskey' => sesskey(),
'blockaction' => 'config',
'currentaction' => 'managefeeds',
'id' => $id));
}
if (has_capability('moodle/site:manageblocks', $context)) {
- $script = $page->url_get_full(array('instanceid' => $this->instance->id, 'sesskey' => $USER->sesskey, 'blockaction' => 'config', 'currentaction' => 'configblock', 'id' => $id, 'section' => 'rss'));
+ $script = $page->url_get_full(array('instanceid' => $this->instance->id, 'sesskey' => sesskey(), 'blockaction' => 'config', 'currentaction' => 'configblock', 'id' => $id, 'section' => 'rss'));
$row[] = new tabobject('configblock', $script,
get_string('configblock', 'block_rss_client'));
}
-$script = $page->url_get_full(array('instanceid' => $this->instance->id, 'sesskey' => $USER->sesskey, 'blockaction' => 'config', 'currentaction' => 'managefeeds', 'id' => $id, 'section' => 'rss'));
+$script = $page->url_get_full(array('instanceid' => $this->instance->id, 'sesskey' => sesskey(), 'blockaction' => 'config', 'currentaction' => 'managefeeds', 'id' => $id, 'section' => 'rss'));
$row[] = new tabobject('managefeeds', $script,
get_string('managefeeds', 'block_rss_client'));
unset($options);
$options['id'] = $category->id;
$options['resort'] = 'name';
- $options['sesskey'] = $USER->sesskey;
+ $options['sesskey'] = sesskey();
print_single_button('category.php', $options, get_string('resortcoursesbyname'), 'get');
}
notice_yesno("$strdeletecoursecheck<br /><br />" . format_string($course->fullname) .
" (" . format_string($course->shortname) . ")",
- "delete.php?id=$course->id&delete=".md5($course->timemodified)."&sesskey=$USER->sesskey",
+ "delete.php?id=$course->id&delete=".md5($course->timemodified)."&sesskey=".sesskey(),
"category.php?id=$course->category");
print_footer($course);
if ( !(isset($required[$h]) or
isset($optionalDefaults[$h]) or
isset($optional[$h])) ) {
- print_error('invalidfieldname', 'error', 'index.php?id='.$id.'&sesskey='.$USER->sesskey, $h);
+ print_error('invalidfieldname', 'error', 'index.php?id='.$id.'&sesskey='.sesskey(), $h);
}
if ( isset($required[$h]) ) {
$required[$h] = 2;
// check for required fields
foreach ($required as $key => $value) {
if ($value < 2) {
- print_error('fieldrequired', 'error', 'uploaduser.php?id='.$id.'&sesskey='.$USER->sesskey, $key);
+ print_error('fieldrequired', 'error', 'uploaduser.php?id='.$id.'&sesskey='.sesskey(), $key);
}
}
$linenum = 2; // since header is line 1
foreach ($record as $name => $value) {
// check for required values
if (isset($required[$name]) and !$value) {
- print_error('missingfield', 'error', 'uploaduser.php?sesskey='.$USER->sesskey, $name);
+ print_error('missingfield', 'error', 'uploaduser.php?sesskey='.sesskey(), $name);
}
else if ($name == "groupname") {
$newgroup->name = $value;
function definition (){
$mform =& $this->_form;
+ if (isset($this->_customdata)) { // hardcoding plugin names here is hacky
+ $features = $this->_customdata;
+ } else {
+ $features = array();
+ }
+
// course id needs to be passed for auth purposes
$mform->addElement('hidden', 'id', optional_param('id'));
$mform->setType('id', PARAM_INT);
$encodings = $textlib->get_encodings();
$mform->addElement('select', 'encoding', get_string('encoding', 'grades'), $encodings);
+ if (!empty($features['includeseparator'])) {
+ $radio = array();
+ $radio[] = &MoodleQuickForm::createElement('radio', 'separator', null, get_string('septab', 'grades'), 'tab');
+ $radio[] = &MoodleQuickForm::createElement('radio', 'separator', null, get_string('sepcomma', 'grades'), 'comma');
+ $mform->addGroup($radio, 'separator', get_string('separator', 'grades'), ' ', false);
+ $mform->setDefault('separator', 'comma');
+ }
+
+ if (!empty($features['verbosescales'])) {
+ $options = array(1=>get_string('yes'), 0=>get_string('no'));
+ $mform->addElement('select', 'verbosescales', get_string('verbosescales', 'grades'), $options);
+ }
+
$options = array('10'=>10, '20'=>20, '100'=>100, '1000'=>1000, '100000'=>100000);
$mform->addElement('select', 'previewrows', get_string('rowpreviewnum', 'grades'), $options); // TODO: localize
$mform->setType('previewrows', PARAM_INT);
$mform->setType('id', PARAM_INT);
$mform->addElement('hidden', 'importcode');
$mform->setType('importcode', PARAM_FILE);
+ $mform->addElement('hidden', 'verbosescales', 1);
+ $mform->setType('separator', PARAM_ALPHA);
+ $mform->addElement('hidden', 'separator', 'comma');
+ $mform->setType('verbosescales', PARAM_INT);
$this->add_action_buttons(false, get_string('uploadgrades', 'grades'));
}
<?php
-$string['notenoughsaincategory'] = 'There is/are only $a->nosaquestions short answer questions in the category that you chose \'$a->catname\'. Choose a different category, make some more questions in this category or reduce the amount of questions you\'ve selected.';
+$string['addingrandomsamatch'] = 'Adding a Random short-answer matching question';
+$string['editingrandomsamatch'] = 'Editing a Random short-answer matching question';
$string['nosaincategory'] = 'There are no short answer questions in the category that you chose \'$a->catname\'. Choose a different category, make some questions in this category.';
+$string['notenoughsaincategory'] = 'There is/are only $a->nosaquestions short answer questions in the category that you chose \'$a->catname\'. Choose a different category, make some more questions in this category or reduce the amount of questions you\'ve selected.';
+$string['randomsamatch'] = 'Random short-answer matching';
?>
\ No newline at end of file
<?php
+$string['addingshortanswer'] = 'Adding a short answer question';
$string['addmoreanswerblanks'] = 'Blanks for {no} More Answers';
+$string['answermustbegiven'] = 'You must enter an answer if there is a grade or feedback.';
$string['answerno'] = 'Answer $a';
+$string['editingshortanswer'] = 'Editing a Short answer question';
$string['filloutoneanswer'] = 'You must provide at least one possible answer. Answers left blank will not be used. \'*\' can be used as a wildcard to match any characters. The first matching answer will be used to determine the score and feedback.';
-$string['answermustbegiven'] = 'You must enter an answer if there is a grade or feedback.';
+$string['shortanswer'] = 'Short answer';
?>
\ No newline at end of file
// echo '<div class="feedback_centered_button">';
echo '<div class="form-buttons">';
$export_button_link = 'analysis_to_excel.php';
- $export_button_options = array('sesskey'=>$USER->sesskey, 'id'=>$id);
+ $export_button_options = array('sesskey'=>sesskey(), 'id'=>$id);
$export_button_label = get_string('export_to_excel', 'feedback');
print_single_button($export_button_link, $export_button_options, $export_button_label, 'post');
echo '</div>';
//button "export to excel"
echo '<div class="mdl-align">';
$export_button_link = 'analysis_to_excel.php';
- $export_button_options = array('sesskey'=>$USER->sesskey, 'id'=>$id, 'coursefilter'=>$coursefilter);
+ $export_button_options = array('sesskey'=>sesskey(), 'id'=>$id, 'coursefilter'=>$coursefilter);
$export_button_label = get_string('export_to_excel', 'feedback');
print_single_button($export_button_link, $export_button_options, $export_button_label, 'post');
echo '</div>';
echo get_string('search_course', 'feedback') . ': ';
echo '<input type="text" name="searchcourse" value="'.s($searchcourse).'"/> <input type="submit" value="'.get_string('search').'"/>';
- echo '<input type="hidden" name="sesskey" value="' . $USER->sesskey . '" />';
+ echo '<input type="hidden" name="sesskey" value="'.sesskey().'" />';
echo '<input type="hidden" name="id" value="'.$id.'" />';
echo '<input type="hidden" name="courseitemfilter" value="'.$courseitemfilter.'" />';
echo '<input type="hidden" name="courseitemfiltertyp" value="'.$courseitemfiltertyp.'" />';
// print_simple_box_start('center', '75%');
print_box_start('generalbox boxaligncenter boxwidthwide');
echo '<div class="mdl-align"><form name="frm" action="'.$ME.'" method="post" onsubmit=" ">';
- echo '<input type="hidden" name="sesskey" value="' . $USER->sesskey . '" />';
+ echo '<input type="hidden" name="sesskey" value="'.sesskey().'" />';
echo '<table>';
switch ($feedback->anonymous) {
case FEEDBACK_ANONYMOUS_YES:
echo '<form name="frm" action="'.$CFG->wwwroot.'/course/view.php?id='.$course->id.'" method="post" onsubmit=" ">';
}
}
- echo '<input type="hidden" name="sesskey" value="' . $USER->sesskey . '" />';
+ echo '<input type="hidden" name="sesskey" value="'.sesskey().'" />';
echo '<input type="hidden" name="courseid" value="'. $courseid . '" />';
echo '<button type="submit">'.get_string('cancel').'</button>';
echo '</form>';
}
}
notice_yesno(get_string("confirmdeletionofthispage","lesson"),
- "lesson.php?action=delete&id=$cm->id&pageid=$pageid&sesskey=".$USER->sesskey,
+ "lesson.php?action=delete&id=$cm->id&pageid=$pageid&sesskey=".sesskey(),
"view.php?id=$cm->id");
?>
QUIZ_REVIEW_SCORES => 'scores',
QUIZ_REVIEW_OVERALLFEEDBACK => 'overallfeedback');
- function __construct($name, $visiblename, $description, $defaultsetting) {
+ public function __construct($name, $visiblename, $description, $defaultsetting) {
$this->plugin = 'quiz';
- parent::admin_setting($name, $visiblename, $description, $defaultsetting);
+ parent::__construct($name, $visiblename, $description, $defaultsetting);
}
private function normalise_data($data) {
return $value;
}
- function get_setting() {
+ public function get_setting() {
$value = $this->config_read($this->name);
$fix = $this->config_read('fix_' . $this->name);
if (is_null($value) or is_null($fix)) {
return array('value' => $value, 'fix' => $fix);
}
- function write_setting($data) {
+ public function write_setting($data) {
if (!isset($data['value'])) {
$data['value'] = $this->normalise_data($data);
}
return '';
}
- function output_html($data, $query='') {
+ public function output_html($data, $query='') {
if (!isset($data['value'])) {
$data['value'] = $this->normalise_data($data);
}
function display_question_editing_page(&$mform, $question, $wizardnow){
- print_heading(get_string('warningmissingtype', 'quiz'));
+ print_heading(get_string('warningmissingtype', 'qtype_missingtype'));
$mform->display();
+++ /dev/null
-<?php\r
-/**\r
- * @author Dick Munroe (munroe@csworks.com)\r
- * @copyright copyright @ 2004, Dick Munroe, released under the GPL.\r
- *\r
- * The cURL class is a thin wrapper around the procedural interface\r
- * to cURL provided by PHP. I use it mostly as a base class for\r
- * web services whose low level interface is, literally, web pages.\r
- *\r
- * There are a few differences (value added, I guess) between the interface\r
- * provided by this class and the procedural cURL interface. Most\r
- * noticable are:\r
- *\r
- * 1. The curl::exec function (when returning data to the caller rather\r
- * than simply outputing it) always parses the HTTP header and returns\r
- * only the body portion of the reqeust. The header is available via\r
- * the curl::getHeader method.\r
- * 2. The status of the last curl::exec is always maintained. It is\r
- * available via the curl::getStatus method. In addition to the information\r
- * returned by curl_getinfo, that of curl_error and curl_errno is folded\r
- * in as well.\r
- *\r
- * @example ./example.class.curl.php\r
- */\r
-\r
-//\r
-// Edit History:\r
-//\r
-// Dick Munroe munroe@csworks.com 30-Nov-2004\r
-// Initial Version Created.\r
-//\r
-// Dick Munroe munroe@csworks.com 01-Dec-2004\r
-// Forgot to check for cURL actually being in this instance of PHP.\r
-//\r
-\r
-class curl\r
-{\r
- /**\r
- * The mapping to caseless header names.\r
- *\r
- * @access private\r
- * @var array\r
- */\r
-\r
- var $m_caseless ;\r
-\r
- /**\r
- * The handle for the current curl session.\r
- *\r
- * @access private\r
- * @var resource\r
- */\r
- \r
- var $m_handle ;\r
-\r
- /**\r
- * The parsed contents of the HTTP header if one happened in the\r
- * message. All repeated elements appear as arrays.\r
- *\r
- * The headers are stored as an associative array, the key of which\r
- * is the name of the header, e.g., Set-Cookie, and the values of which\r
- * are the bodies of the header in the order in which they occurred.\r
- * \r
- * Some headers can be repeated in a single header, e.g., Set-Cookie and\r
- * pragma, so each type of header has an array containing one or more\r
- * headers of the same type.\r
- *\r
- * The names of the headers can, potentially, vary in spelling from\r
- * server to server and client to client. No attempt to regulate this\r
- * is made, i.e., the curl class does not force all headers to lower\r
- * or upper class, but it DOES collect all headers of the same type\r
- * under the spelling of the type of header used by the FIRST header\r
- * of that type.\r
- *\r
- * For example, two headers:\r
- *\r
- * 1. Set-Cookie: ...\r
- * 2. set-cookie: ...\r
- *\r
- * Would appear as $this->m_header['Set-Cookie'][0] and ...[1]\r
- *\r
- * @access private\r
- * @var mixed\r
- */\r
-\r
- var $m_header ;\r
-\r
- /**\r
- * Current setting of the curl options.\r
- *\r
- * @access private\r
- * @var mixed\r
- */\r
-\r
- var $m_options ;\r
-\r
- /**\r
- * Status information for the last executed http request. Includes the errno and error\r
- * in addition to the information returned by curl_getinfo.\r
- *\r
- * The keys defined are those returned by curl_getinfo with two additional\r
- * ones specified, 'error' which is the value of curl_error and 'errno' which\r
- * is the value of curl_errno.\r
- *\r
- * @link http://www.php.net/curl_getinfo\r
- * @link http://www.php.net/curl_errno\r
- * @link http://www.php.net/curl_error\r
- * @access private\r
- * @var mixed\r
- */\r
-\r
- var $m_status ;\r
-\r
- /**\r
- * curl class constructor\r
- *\r
- * Initializes the curl class for it's default behavior:\r
- * o no HTTP headers.\r
- * o return the transfer as a string.\r
- * o URL to access.\r
- * By default, the curl class will simply read the URL provided\r
- * in the constructor.\r
- *\r
- * @link http://www.php.net/curl_init\r
- * @param string $theURL [optional] the URL to be accessed by this instance of the class.\r
- */\r
-\r
- function curl($theURL=null)\r
- {\r
- if (!function_exists('curl_init'))\r
- {\r
- trigger_error('PHP was not built with --with-curl, rebuild PHP to use the curl class.', E_USER_ERROR) ;\r
- }\r
-\r
- $this->m_handle = curl_init() ;\r
- \r
- $this->m_caseless = null ;\r
- $this->m_header = null ;\r
- $this->m_options = null ;\r
- $this->m_status = null ;\r
-\r
- if (!empty($theURL))\r
- {\r
- $this->setopt(CURLOPT_URL, $theURL) ; \r
- }\r
- $this->setopt(CURLOPT_HEADER, false) ;\r
- $this->setopt(CURLOPT_RETURNTRANSFER, true) ;\r
- }\r
-\r
- /**\r
- * Free the resources associated with the curl session.\r
- *\r
- * @link http://www.php.net/curl_close\r
- */\r
-\r
- function close()\r
- {\r
- curl_close($this->m_handle) ;\r
- $this->m_handle = null ;\r
- }\r
-\r
- /**\r
- * Execute the curl request and return the result.\r
- *\r
- * @link http://www.php.net/curl_exec\r
- * @link http://www.php.net/curl_getinfo\r
- * @link http://www.php.net/curl_errno\r
- * @link http://www.php.net/curl_error\r
- * @return string The contents of the page (or other interaction as defined by the\r
- * settings of the various curl options).\r
- */\r
-\r
- function exec()\r
- {\r
- $theReturnValue = curl_exec($this->m_handle) ;\r
- \r
- $this->m_status = curl_getinfo($this->m_handle) ;\r
- $this->m_status['errno'] = curl_errno($this->m_handle) ;\r
- $this->m_status['error'] = curl_error($this->m_handle) ;\r
- \r
- //\r
- // Parse out the http header (if any).\r
- //\r
-\r
- $this->m_header = null ;\r
-\r
- if ($this->getOption(CURLOPT_HEADER))\r
- {\r
- $theArray = preg_split("/(\r\n){2,2}/", $theReturnValue, 2) ;\r
-\r
- $this->parseHeader($theArray[0]) ;\r
-\r
- return $theArray[1] ;\r
- }\r
-\r
- return $theReturnValue ;\r
- }\r
-\r
- /**\r
- * Returns the parsed http header.\r
- *\r
- * @param string $theHeader [optional] the name of the header to be returned.\r
- * The name of the header is case insensitive. If\r
- * the header name is omitted the parsed header is\r
- * returned. If the requested header doesn't exist\r
- * false is returned.\r
- * @returns mixed\r
- */\r
-\r
- function getHeader($theHeader=null)\r
- {\r
- if (empty($theHeader))\r
- {\r
- return $this->m_header ;\r
- }\r
- else\r
- {\r
- $theHeader = strtoupper($theHeader) ;\r
- if (isset($this->m_caseless[$theHeader]))\r
- {\r
- return $this->m_header[$this->m_caseless[$theHeader]] ;\r
- }\r
- else\r
- {\r
- return false ;\r
- }\r
- }\r
- }\r
-\r
- /**\r
- * Returns the current setting of the request option. If no \r
- * option has been set, it return null.\r
- *\r
- * @param integer the requested CURLOPT.\r
- * @returns mixed\r
- */\r
-\r
- function getOption($theOption)\r
- {\r
- if (isset($this->m_options[$theOption]))\r
- {\r
- return $this->m_options[$theOption] ;\r
- }\r
-\r
- return null ;\r
- }\r
-\r
- /**\r
- * Did the last curl exec operation have an error?\r
- *\r
- * @return mixed The error message associated with the error if an error \r
- * occurred, false otherwise.\r
- */\r
-\r
- function hasError()\r
- {\r
- if (isset($this->m_status['error']))\r
- {\r
- return (empty($this->m_status['error']) ? false : $this->m_status['error']) ;\r
- }\r
- else\r
- {\r
- return false ;\r
- }\r
- }\r
-\r
- /**\r
- * Parse an HTTP header.\r
- *\r
- * As a side effect it stores the parsed header in the\r
- * m_header instance variable. The header is stored as\r
- * an associative array and the case of the headers \r
- * as provided by the server is preserved and all\r
- * repeated headers (pragma, set-cookie, etc) are grouped\r
- * with the first spelling for that header\r
- * that is seen.\r
- *\r
- * All headers are stored as if they COULD be repeated, so\r
- * the headers are really stored as an array of arrays.\r
- *\r
- * @param string $theHeader The HTTP data header.\r
- */\r
-\r
- function parseHeader($theHeader)\r
- {\r
- $this->m_caseless = array() ;\r
-\r
- $theArray = preg_split("/(\r\n)+/", $theHeader) ;\r
-\r
- //\r
- // Ditch the HTTP status line.\r
- //\r
-\r
- if (preg_match('/^HTTP/', $theArray[0]))\r
- {\r
- $theArray = array_slice($theArray, 1) ;\r
- }\r
-\r
- foreach ($theArray as $theHeaderString)\r
- {\r
- $theHeaderStringArray = preg_split("/\s*:\s*/", $theHeaderString, 2) ;\r
-\r
- $theCaselessTag = strtoupper($theHeaderStringArray[0]) ;\r
-\r
- if (!isset($this->m_caseless[$theCaselessTag]))\r
- {\r
- $this->m_caseless[$theCaselessTag] = $theHeaderStringArray[0] ;\r
- }\r
- \r
- $this->m_header[$this->m_caseless[$theCaselessTag]][] = $theHeaderStringArray[1] ;\r
- }\r
- }\r
-\r
- /**\r
- * Return the status information of the last curl request.\r
- *\r
- * @param string $theField [optional] the particular portion\r
- * of the status information desired.\r
- * If omitted the array of status\r
- * information is returned. If a non-existant\r
- * status field is requested, false is returned.\r
- * @returns mixed\r
- */\r
-\r
- function getStatus($theField=null)\r
- {\r
- if (empty($theField))\r
- {\r
- return $this->m_status ;\r
- }\r
- else\r
- {\r
- if (isset($this->m_status[$theField]))\r
- {\r
- return $this->m_status[$theField] ;\r
- }\r
- else\r
- {\r
- return false ;\r
- }\r
- }\r
- }\r
-\r
- /**\r
- * Set a curl option.\r
- *\r
- * @link http://www.php.net/curl_setopt\r
- * @param mixed $theOption One of the valid CURLOPT defines.\r
- * @param mixed $theValue the value of the curl option.\r
- */\r
-\r
- function setopt($theOption, $theValue)\r
- {\r
- curl_setopt($this->m_handle, $theOption, $theValue) ;\r
- $this->m_options[$theOption] = $theValue ;\r
- }\r
-}\r
-?>
\ No newline at end of file
+++ /dev/null
-<?php
-/**
- * Listener for HTTP_Request and HTTP_Response objects
- *
- * PHP versions 4 and 5
- *
- * LICENSE:
- *
- * Copyright (c) 2002-2007, Richard Heyes
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * o Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * o Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * o The names of the authors may not be used to endorse or promote
- * products derived from this software without specific prior written
- * permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * @category HTTP
- * @package HTTP_Request
- * @author Alexey Borzov <avb@php.net>
- * @copyright 2002-2007 Richard Heyes
- * @license http://opensource.org/licenses/bsd-license.php New BSD License
- * @version CVS: $Id$
- * @link http://pear.php.net/package/HTTP_Request/
- */
-
-/**
- * Listener for HTTP_Request and HTTP_Response objects
- *
- * This class implements the Observer part of a Subject-Observer
- * design pattern.
- *
- * @category HTTP
- * @package HTTP_Request
- * @author Alexey Borzov <avb@php.net>
- * @version Release: 1.4.2
- */
-class HTTP_Request_Listener
-{
- /**
- * A listener's identifier
- * @var string
- */
- var $_id;
-
- /**
- * Constructor, sets the object's identifier
- *
- * @access public
- */
- function HTTP_Request_Listener()
- {
- $this->_id = md5(uniqid('http_request_', 1));
- }
-
-
- /**
- * Returns the listener's identifier
- *
- * @access public
- * @return string
- */
- function getId()
- {
- return $this->_id;
- }
-
-
- /**
- * This method is called when Listener is notified of an event
- *
- * @access public
- * @param object an object the listener is attached to
- * @param string Event name
- * @param mixed Additional data
- * @abstract
- */
- function update(&$subject, $event, $data = null)
- {
- echo "Notified of event: '$event'\n";
- if (null !== $data) {
- echo "Additional data: ";
- var_dump($data);
- }
- }
-}
-?>