Пример #1
0
 function podcaster_pageimpl(&$channel)
 {
     if ($channel) {
         $this->format = podcaster_format::create_format($channel->format);
     }
     $this->channel = $channel;
 }
Пример #2
0
 function definition()
 {
     global $CFG;
     $mform =& $this->_form;
     $mform->addElement('header', 'general', get_string('general', 'form'));
     $mform->addElement('date_time_selector', 'scheduledtime', get_string('scheduledtime', 'podcaster'));
     $mform->addElement('text', 'title', get_string('itemtitle', 'podcaster'), array('size' => '48'));
     $mform->setType('title', PARAM_TEXT);
     $mform->addRule('title', null, 'required', null, 'client');
     $mform->addElement('htmleditor', 'description', get_string('itemdescription', 'podcaster'));
     $mform->setType('description', PARAM_RAW);
     $mform->addRule('description', get_string('required'), 'required', null, 'client');
     $mform->setHelpButton('description', array('writing', 'richtext'), false, 'editorhelpbutton');
     $mform->addElement('format', 'introformat', get_string('format'));
     $format = $this->item->channelObj->format;
     $xmlformat =& podcaster_format::create_format($format);
     $xmlformat->define_itemform($mform, $this->item);
     if ($CFG->podcaster_copyright == 'user') {
         $mform->addElement('header', 'license_header', get_string('license', 'podcaster'));
         $mform->addElement('textarea', 'copyright', get_string('copyright', 'podcaster'), array('rows' => '5', 'cols' => '40'));
     } else {
         $license = podcaster_license::create_license($this->item->channelObj->license, $this->item->channelObj->repository);
         if ($license) {
             $mform->addElement('header', 'license_header', get_string('license', 'podcaster'));
             $mform->addElement('static', 'license_name', podcaster_util::get_string('license_' . $license->name . '_title'));
             $mform->addElement('static', 'license_desc', '', podcaster_util::get_string('license_' . $license->name . '_desc'));
             if ($license->confirm) {
                 $mform->addElement('checkbox', 'confirm_license', get_string('confirm_license', 'podcaster'));
                 $mform->addRule('confirm_license', get_string('must_confirm', 'podcaster'), 'required', null, 'client');
             }
         }
     }
     $mform->addElement('hidden', 'cm', $this->coursemodule->id);
     $mform->addElement('hidden', 'channel', $this->item->channelObj->id);
     $mform->addElement('hidden', 'id', $this->item->id);
     $mform->setType('item', PARAM_TEXT);
     $this->add_action_buttons();
 }
Пример #3
0
function podcaster_preprocess_data(&$podcaster)
{
    if (!isset($podcaster->showpreview)) {
        $podcaster->showpreview = 0;
    }
    if (isset($podcaster->format)) {
        require_once 'locallib.php';
        $format =& podcaster_format::create_format($podcaster->format);
        $format->preprocess_channel(&$podcaster);
    }
}
Пример #4
0
 function definition()
 {
     global $CFG;
     $mform =& $this->_form;
     // do some tests to determine if we have to choose a
     // podcast format, repository and / or license first
     if (isset($this->initial_data) && $this->initial_data->ismeta) {
         $formats = explode(',', $CFG->podcaster_metaformats);
     } else {
         $formats = explode(',', $CFG->podcaster_formats);
     }
     $repositories = get_records('podcaster_repository', 'enabled', '1');
     $licenses = get_records('podcaster_license');
     $format = isset($this->initial_data) ? $this->initial_data->format : '';
     $repository = isset($this->initial_data) ? $this->initial_data->repository : 0;
     $license = isset($this->initial_data) ? $this->initial_data->license : 0;
     if ($format == '') {
         $format = optional_param('format', '', PARAM_TEXT);
         if ($format == '') {
             $typeOptions =& $this->parseTypeOptions();
             if (array_key_exists('format', $typeOptions)) {
                 $format = $typeOptions['format'];
             }
         }
         if (count($formats) == 1) {
             $format = $formats[0];
         }
     }
     if ($repository == 0) {
         $repository = optional_param('repository', 0, PARAM_INT);
         if ($repository == 0) {
             $typeOptions =& $this->parseTypeOptions();
             if (array_key_exists('repository', $typeOptions)) {
                 $repository = $typeOptions['repository'];
             }
         }
         // there should be at least one
         if (count($repositories) == 1) {
             list($repository, ) = each($repositories);
         }
     }
     if ($license == 0) {
         $license = optional_param('license', 0, PARAM_INT);
         if ($license == 0) {
             $typeOptions =& $this->parseTypeOptions();
             if (array_key_exists('license', $typeOptions)) {
                 $license = $typeOptions['license'];
             }
         }
         if (count($licenses) == 1) {
             list($license, ) = each($licenses);
         }
     }
     if (!isset($this->initial_data)) {
         $this->initial_data = new object();
         $this->initial_data->format = $format;
         $this->initial_data->repository = $repository;
         $this->initial_data->license = $license;
     } else {
         $updobj = new object();
         $updobj->id = $this->initial_data->id;
         $dofix = false;
         if ($repository != 0 && (!isset($this->initial_data->repository) || $this->initial_data->repository == 0)) {
             $this->initial_data->repository = $repository;
             $updobj->repository = $repository;
             $dofix = true;
         }
         if ($format != '' && $format != '' && (!isset($this->initial_data->format) || $this->initial_data->format == '')) {
             $this->initial_data->format = $format;
             $updobj->format = $format;
             $dofix = true;
         }
         if ($license && (!isset($this->initial_data->license) || $this->initial_data->license == 0)) {
             $this->initial_data->license = $license;
             $updobj->license = $license;
             $dofix = true;
         }
         update_record('podcaster', $updobj);
     }
     // 1st step: repository, format or license cannot be determined automatically
     if (!$repository || !$format || !$license && $CFG->podcaster_copyright == 'menu') {
         $mform->addElement('header', 'firststep', get_string('create_step1', 'podcaster'));
         if (is_array($formats) && count($formats) > 1) {
             $options = array();
             $mform->addElement('static', 'repository_hint', get_string('format_hint', 'podcaster'));
             for ($i = 0, $c = count($formats); $i < $c; ++$i) {
                 $options[$formats[$i]] = podcaster_util::get_string('format_' . $formats[$i] . '_title');
             }
             $mform->addElement('select', 'format', get_string('format', 'podcaster'), $options);
         } elseif ($format) {
             $mform->addElement('hidden', 'format', $format);
         } else {
             error('Module is misconfigured: no formats available. Please check module configuration.');
         }
         if (is_array($repositories) && count($repositories) > 1) {
             $mform->addElement('static', 'repository_hint', get_string('repository_hint', 'podcaster'));
             $options = array();
             foreach ($repositories as $r) {
                 $options[$r->id] = podcaster_util::get_string('repository_' . $r->name . '_title');
             }
             $mform->addElement('select', 'repository', get_string('repository', 'podcaster'), $options);
         } elseif ($repository) {
             $mform->addElement('hidden', 'repository', $repository);
         } else {
             error('Module is misconfigured: no repositories available. Please check module configuration.');
         }
         if (is_array($licenses) && count($licenses) > 1 && $CFG->podcaster_copyright == 'menu') {
             $mform->addElement('static', 'license_hint', get_string('license_hint', 'podcaster'));
             $options = array();
             foreach ($licenses as $l) {
                 $options[$l->id] = podcaster_util::get_string('license_' . $l->name . '_title');
             }
             $mform->addElement('select', 'license', get_string('license', 'podcaster'), $options);
         } elseif ($license && $CFG->podcaster_copyright == 'menu') {
             $mform->addElement('hidden', 'license', $licenses);
         } elseif ($CFG->podcaster_copyright == 'menu') {
             error('Module is misconfigured: no licenses available. Please check module configuration.');
         }
         // add standard elements, common to all modules
         $this->standard_hidden_coursemodule_elements();
         $this->add_action_buttons(true);
         $mform->removeElement('submitbutton2');
         $mform->addElement('hidden', 'reloadform', 'true');
     } else {
         // just submitted 1st step?
         if (optional_param('reloadform', '', PARAM_TEXT) == 'true') {
             $querystr = '';
             $add = optional_param('add', 0, PARAM_TEXT);
             $update = optional_param('update', 0, PARAM_INT);
             if ($update != 0) {
                 $querystr = '?update=' . $update;
             } else {
                 $querystr = '?add=' . $add;
             }
             redirect($CFG->wwwroot . '/course/modedit.php' . $querystr . '&course=' . required_param('course', PARAM_INT) . '&section=' . required_param('section', PARAM_INT) . '&format=' . $format . '&repository=' . $repository . '&license=' . $license . '&sesskey=' . required_param('sesskey', PARAM_TEXT));
         }
         // show standard edit form
         $mform->addElement('header', 'general', get_string('general', 'form'));
         $mform->addElement('text', 'name', get_string('channelname', 'podcaster'), array('size' => '48'));
         $mform->setType('name', PARAM_TEXT);
         $mform->addRule('name', null, 'required', null, 'client');
         $mform->addElement('htmleditor', 'intro', get_string('channeldescription', 'podcaster'));
         $mform->setType('intro', PARAM_RAW);
         $mform->addRule('intro', get_string('required'), 'required', null, 'client');
         $mform->setHelpButton('intro', array('writing', 'richtext'), false, 'editorhelpbutton');
         $mform->addElement('format', 'introformat', get_string('format'));
         // include format specific elements
         $xmlformat =& podcaster_format::create_format($format);
         $xmlformat->define_channelform($mform, $this->initial_data);
         $mform->addElement('hidden', 'format', $format);
         $mform->setType('format', PARAM_TEXT);
         $mform->addElement('hidden', 'repository', $repository);
         $mform->setType('repository', PARAM_INT);
         $mform->addElement('hidden', 'license', $license);
         $mform->setType('license', PARAM_INT);
         // add standard elements, common to all modules
         $this->standard_coursemodule_elements();
         if ($CFG->podcaster_copyright == 'user') {
             $mform->addElement('header', 'license_header', get_string('license', 'podcaster'));
             $mform->addElement('textarea', 'copyright', get_string('copyright', 'podcaster'), array('rows' => '5', 'cols' => '40'));
         } else {
             $license = podcaster_license::create_license($license, $repository);
             if ($license) {
                 $mform->addElement('header', 'license_header', podcaster_util::get_string('license_' . $license->name . '_title'));
                 //
                 if (!isset($this->initial_data->copyright)) {
                     $copyright = podcaster_util::get_string('license_' . $license->name . '_desc');
                 } else {
                     $copyright = $this->initial_data->copyright;
                 }
                 $mform->addElement('static', 'license_desc', '', $copyright);
                 $mform->addElement('hidden', 'copyright', $copyright);
                 if ($license->confirm) {
                     $mform->addElement('checkbox', 'confirm_license', get_string('confirm_license', 'podcaster'));
                     $mform->addRule('confirm_license', get_string('must_confirm', 'podcaster'), 'required', null, 'client');
                 }
             }
         }
         // add standard buttons, common to all modules
         $this->add_action_buttons(false);
     }
 }
Пример #5
0
 function update_rss()
 {
     if ($this->path == '') {
         return;
     }
     // make sure stream is registered
     $r = $this->get_repository(true);
     if (!$r) {
         return false;
     }
     $dirname = dirname($this->path);
     $destpath = $r->prefix . '://' . $dirname;
     $destfile = $r->prefix . '://' . $this->path;
     repository_make_upload_directory($destpath);
     $format = podcaster_format::create_format($this->format);
     $format->set_data($this);
     $format->write_xml($w = new podcaster_filestreamwriter($destfile));
     return true;
 }