Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 3.11.x will end 14 Nov 2022 (12 months plus 6 months extension).
  • Bug fixes for security issues in 3.11.x will end 13 Nov 2023 (18 months plus 12 months extension).
  • PHP version: minimum PHP 7.3.0 Note: minimum PHP version has increased since Moodle 3.10. PHP 7.4.x is supported too.
   1  <?php
   2  // This file is part of Moodle - http://moodle.org/
   3  //
   4  // Moodle is free software: you can redistribute it and/or modify
   5  // it under the terms of the GNU General Public License as published by
   6  // the Free Software Foundation, either version 3 of the License, or
   7  // (at your option) any later version.
   8  //
   9  // Moodle is distributed in the hope that it will be useful,
  10  // but WITHOUT ANY WARRANTY; without even the implied warranty of
  11  // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  12  // GNU General Public License for more details.
  13  //
  14  // You should have received a copy of the GNU General Public License
  15  // along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
  16  
  17  /**
  18  * @package    backup-convert
  19  * @subpackage cc-library
  20  * @copyright  2011 Darko Miletic <dmiletic@moodlerooms.com>
  21  * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
  22  */
  23  
  24  require_once  'cc_general.php';
  25  
  26  class url1_resurce_file extends general_cc_file {
  27      const deafultname = 'weblink.xml';
  28  
  29      protected $rootns = 'wl';
  30      protected $rootname = 'wl:webLink';
  31      protected $ccnamespaces = array('wl'  => 'http://www.imsglobal.org/xsd/imswl_v1p0',
  32                                      'xsi' => 'http://www.w3.org/2001/XMLSchema-instance');
  33      protected $ccnsnames = array('wl'   => 'http://www.imsglobal.org/profile/cc/ccv1p0/derived_schema/domainProfile_5/imswl_v1p0_localised.xsd');
  34  
  35      protected $url = null;
  36      protected $title = null;
  37      protected $href = null;
  38      protected $target = '_self';
  39      protected $window_features = null;
  40  
  41      /**
  42       *
  43       * Set the url title
  44       * @param string $title
  45       */
  46      public function set_title($title) {
  47          $this->title = self::safexml($title);
  48      }
  49  
  50      /**
  51       *
  52       * Set the url specifics
  53       * @param string $url
  54       * @param string $target
  55       * @param string $window_features
  56       */
  57      public function set_url($url, $target='_self', $window_features=null) {
  58          $this->url = $url;
  59          $this->target = $target;
  60          $this->window_features = $window_features;
  61      }
  62  
  63      protected function on_save() {
  64          $this->append_new_element($this->root, 'title', $this->title);
  65          $url = $this->append_new_element($this->root, 'url');
  66          $this->append_new_attribute($url, 'href', $this->url);
  67          if (!empty($this->target)) {
  68              $this->append_new_attribute($url, 'target', $this->target);
  69          }
  70          if (!empty($this->window_features)) {
  71              $this->append_new_attribute($url, 'windowFeatures', $this->window_features);
  72          }
  73          return true;
  74      }
  75  
  76  }
  77  
  78  class url11_resurce_file extends url1_resurce_file {
  79      protected $rootname = 'webLink';
  80  
  81      protected $ccnamespaces = array('wl'  => 'http://www.imsglobal.org/xsd/imsccv1p1/imswl_v1p1',
  82                                      'xsi' => 'http://www.w3.org/2001/XMLSchema-instance');
  83      protected $ccnsnames = array('wl' => 'http://www.imsglobal.org/profile/cc/ccv1p1/ccv1p1_imswl_v1p1.xsd');
  84  
  85      protected function on_save() {
  86          $rns = $this->ccnamespaces[$this->rootns];
  87          $this->append_new_element_ns($this->root, $rns, 'title', $this->title);
  88          $url = $this->append_new_element_ns($this->root, $rns, 'url');
  89          $this->append_new_attribute_ns($url, $rns, 'href', $this->url);
  90          if (!empty($this->target)) {
  91              $this->append_new_attribute_ns($url, $rns, 'target', $this->target);
  92          }
  93          if (!empty($this->window_features)) {
  94              $this->append_new_attribute_ns($url, $rns, 'windowFeatures', $this->window_features);
  95          }
  96          return true;
  97      }
  98  }
  99