[ Index ]

PHP Cross Reference of Moodle 1.9.3 [Build 15-Oct-2008]

title

Body

[close]

/mod/resource/type/repository/ -> resource.class.php (source)

   1  <?php // $Id: resource.class.php,v 1.21.2.2 2008/03/26 02:46:49 dongsheng Exp $
   2  
   3  /**
   4  * Extend the base resource class for repository resources
   5  *
   6  * Extend the base resource class for respoitory resources
   7  *
   8  */
   9  class resource_repository extends resource_base {
  10  
  11  function resource_repository($cmid=0) {
  12      parent::resource_base($cmid);
  13  }
  14  
  15  var $parameters;
  16  var $maxparameters = 5;
  17  
  18  
  19  /**
  20  * Sets the parameters property of the extended class
  21  *
  22  * Sets the parameters property of the extended repository resource class
  23  *
  24  * @param    USER  global object
  25  * @param    CFG   global object
  26  */
  27  function set_parameters() {
  28      global $USER, $CFG;
  29  
  30      if (empty($USER->id)) {   // No need to set up parameters
  31          $this->parameters = array();
  32          return;
  33      }
  34  
  35      $site = get_site();
  36  
  37      $this->parameters = array(
  38              'label2'          => array('langstr' => "",
  39                                         'value'   =>'/optgroup'),
  40              'label3'          => array('langstr' => get_string('course'),
  41                                         'value'   => 'optgroup'),
  42  
  43              'courseid'        => array('langstr' => 'id',
  44                                         'value'   => $this->course->id),
  45              'coursefullname'  => array('langstr' => get_string('fullname'),
  46                                         'value'   => $this->course->fullname),
  47              'courseshortname' => array('langstr' => get_string('shortname'),
  48                                         'value'   => $this->course->shortname),
  49              'courseidnumber'  => array('langstr' => get_string('idnumbercourse'),
  50                                         'value'   => $this->course->idnumber),
  51              'coursesummary'   => array('langstr' => get_string('summary'),
  52                                         'value'   => $this->course->summary),
  53              'courseformat'    => array('langstr' => get_string('format'),
  54                                         'value'   => $this->course->format),
  55              'courseteacher'   => array('langstr' => get_string('wordforteacher'),
  56                                         'value'   => $this->course->teacher),
  57              'courseteachers'  => array('langstr' => get_string('wordforteachers'),
  58                                         'value'   => $this->course->teachers),
  59              'coursestudent'   => array('langstr' => get_string('wordforstudent'),
  60                                         'value'   => $this->course->student),
  61              'coursestudents'  => array('langstr' => get_string('wordforstudents'),
  62                                         'value'   => $this->course->students),
  63  
  64              'label4'          => array('langstr' => "",
  65                                         'value'   =>'/optgroup'),
  66              'label5'          => array('langstr' => get_string('miscellaneous'),
  67                                         'value'   => 'optgroup'),
  68  
  69              'lang'            => array('langstr' => get_string('preferredlanguage'),
  70                                         'value'   => current_language()),
  71              'sitename'        => array('langstr' => get_string('fullsitename'),
  72                                         'value'   => format_string($site->fullname)),
  73              'serverurl'       => array('langstr' => get_string('serverurl', 'resource', $CFG),
  74                                         'value'   => $CFG->wwwroot),
  75              'currenttime'     => array('langstr' => get_string('time'),
  76                                         'value'   => time()),
  77              'encryptedcode'   => array('langstr' => get_string('encryptedcode'),
  78                                         'value'   => $this->set_encrypted_parameter()),
  79  
  80              'label6'          => array('langstr' => "",
  81                                         'value'   =>'/optgroup')
  82      );
  83  
  84      if (!empty($USER->id)) {
  85  
  86          $userparameters = array(
  87  
  88              'label1'          => array('langstr' => get_string('user'),
  89                                         'value'   => 'optgroup'),
  90  
  91              'userid'          => array('langstr' => 'id',
  92                                         'value'   => $USER->id),
  93              'userusername'    => array('langstr' => get_string('username'),
  94                                         'value'   => $USER->username),
  95              'useridnumber'    => array('langstr' => get_string('idnumber'),
  96                                         'value'   => $USER->idnumber),
  97              'userfirstname'   => array('langstr' => get_string('firstname'),
  98                                         'value'   => $USER->firstname),
  99              'userlastname'    => array('langstr' => get_string('lastname'),
 100                                         'value'   => $USER->lastname),
 101              'userfullname'    => array('langstr' => get_string('fullname'),
 102                                         'value'   => fullname($USER)),
 103              'useremail'       => array('langstr' => get_string('email'),
 104                                         'value'   => $USER->email),
 105              'usericq'         => array('langstr' => get_string('icqnumber'),
 106                                         'value'   => $USER->icq),
 107              'userphone1'      => array('langstr' => get_string('phone').' 1',
 108                                         'value'   => $USER->phone1),
 109              'userphone2'      => array('langstr' => get_string('phone2').' 2',
 110                                         'value'   => $USER->phone2),
 111              'userinstitution' => array('langstr' => get_string('institution'),
 112                                         'value'   => $USER->institution),
 113              'userdepartment'  => array('langstr' => get_string('department'),
 114                                         'value'   => $USER->department),
 115              'useraddress'     => array('langstr' => get_string('address'),
 116                                         'value'   => $USER->address),
 117              'usercity'        => array('langstr' => get_string('city'),
 118                                         'value'   => $USER->city),
 119              'usertimezone'    => array('langstr' => get_string('timezone'),
 120                                         'value'   => get_user_timezone_offset()),
 121              'userurl'         => array('langstr' => get_string('webpage'),
 122                                         'value'   => $USER->url)
 123           );
 124  
 125           $this->parameters = $userparameters + $this->parameters;
 126      }
 127  }
 128  
 129  
 130  function add_instance($resource) {
 131      $this->_postprocess($resource);
 132      return parent::add_instance($resource);
 133  }
 134  
 135  
 136  function update_instance($resource) {
 137      $this->_postprocess($resource);
 138  /*    echo '<xmp>';
 139      var_dump($_POST);
 140      var_dump($resource);die;*/
 141      return parent::update_instance($resource);
 142  }
 143  
 144  function _postprocess(&$resource) {
 145      global $RESOURCE_WINDOW_OPTIONS;
 146      $alloptions = $RESOURCE_WINDOW_OPTIONS;
 147  
 148      if ($resource->windowpopup) {
 149          $optionlist = array();
 150          foreach ($alloptions as $option) {
 151              $optionlist[] = $option."=".$resource->$option;
 152              unset($resource->$option);
 153          }
 154          $resource->popup = implode(',', $optionlist);
 155          unset($resource->windowpopup);
 156          $resource->options = '';
 157  
 158      } else {
 159          if (empty($resource->framepage)) {
 160              $resource->options = '';
 161          } else {
 162              $resource->options = 'frame';
 163          }
 164          unset($resource->framepage);
 165          $resource->popup = '';
 166      }
 167  
 168      $optionlist = array();
 169      for ($i = 0; $i < $this->maxparameters; $i++) {
 170          $parametername = "parameter$i";
 171          $parsename = "parse$i";
 172          if (!empty($resource->$parsename) and $resource->$parametername != "-") {
 173              $optionlist[] = $resource->$parametername."=".$resource->$parsename;
 174          }
 175          unset($resource->$parsename);
 176          unset($resource->$parametername);
 177      }
 178  
 179      $resource->alltext = implode(',', $optionlist);
 180  }
 181  
 182  
 183  /**
 184  * Display the repository resource
 185  *
 186  * Displays a repository resource embedded, in a frame, or in a popup.
 187  * Output depends on type of file resource.
 188  *
 189  * @param    CFG     global object
 190  */
 191  function display() {
 192      global $CFG, $THEME, $SESSION;
 193  
 194  /// Set up generic stuff first, including checking for access
 195      parent::display();
 196  
 197  /// Set up some shorthand variables
 198      $cm = $this->cm;
 199      $course = $this->course;
 200      $resource = $this->resource;
 201  
 202  
 203      $this->set_parameters(); // set the parameters array
 204  
 205  ///////////////////////////////////////////////
 206  
 207      /// Possible display modes are:
 208      /// File displayed in a frame in a normal window
 209      /// File displayed embedded in a normal page
 210      /// File displayed in a popup window
 211      /// File displayed emebedded in a popup window
 212  
 213  
 214      /// First, find out what sort of file we are dealing with.
 215      require_once($CFG->libdir.'/filelib.php');
 216  
 217      $querystring = '';
 218      $resourcetype = '';
 219      $embedded = false;
 220      $mimetype = mimeinfo("type", $resource->reference);
 221      $pagetitle = strip_tags($course->shortname.': '.format_string($resource->name));
 222  
 223      $formatoptions = new object();
 224      $formatoptions->noclean = true;
 225  
 226      if ($resource->options != "frame") {
 227          if (in_array($mimetype, array('image/gif','image/jpeg','image/png'))) {  // It's an image
 228              $resourcetype = "image";
 229              $embedded = true;
 230  
 231          } else if ($mimetype == "audio/mp3") {    // It's an MP3 audio file
 232              $resourcetype = "mp3";
 233              $embedded = true;
 234  
 235          } else if (substr($mimetype, 0, 10) == "video/x-ms") {   // It's a Media Player file
 236              $resourcetype = "mediaplayer";
 237              $embedded = true;
 238  
 239          } else if ($mimetype == "video/quicktime") {   // It's a Quicktime file
 240              $resourcetype = "quicktime";
 241              $embedded = true;
 242  
 243          } else if ($mimetype == "text/html") {    // It's a web page
 244              $resourcetype = "html";
 245          }
 246      }
 247      $navigation = build_navigation($this->navlinks, $cm);
 248  
 249  /// Form the parse string
 250      if (!empty($resource->alltext)) {
 251          $querys = array();
 252          $parray = explode(',', $resource->alltext);
 253          foreach ($parray as $fieldstring) {
 254              $field = explode('=', $fieldstring);
 255              $querys[] = urlencode($field[1]).'='.urlencode($this->parameters[$field[0]]['value']);
 256          }
 257          $querystring = implode('&amp;', $querys);
 258      }
 259  
 260  
 261      /// Set up some variables
 262  
 263      $inpopup = optional_param('inpopup', 0, PARAM_BOOL);
 264  
 265     $fullurl =  $resource->reference. '&amp;HIVE_SESSION='.$SESSION->HIVE_SESSION;
 266      if (!empty($querystring)) {
 267          $urlpieces = parse_url($resource->reference);
 268          if (empty($urlpieces['query'])) {
 269              $fullurl .= '?'.$querystring;
 270          } else {
 271              $fullurl .= '&amp;'.$querystring;
 272          }
 273      }
 274  
 275      /// MW check that the HIVE_SESSION is there
 276      if (empty($SESSION->HIVE_SESSION)) {
 277          if ($inpopup) {
 278              print_header($pagetitle, $course->fullname);
 279          } else {
 280              print_header($pagetitle, $course->fullname, $navigation, "", "", true,
 281                      update_module_button($cm->id, $course->id, $this->strresource), navmenu($course, $cm));
 282          }
 283          notify('You do not have access to HarvestRoad Hive. This resource is unavailable.');
 284          if ($inpopup) {
 285              close_window_button();
 286          }
 287          print_footer('none');
 288          die;
 289      }
 290      /// MW END
 291  
 292  
 293      /// Print a notice and redirect if we are trying to access a file on a local file system
 294      /// and the config setting has been disabled
 295      if (!$CFG->resource_allowlocalfiles and (strpos($resource->reference, RESOURCE_LOCALPATH) === 0)) {
 296          if ($inpopup) {
 297              print_header($pagetitle, $course->fullname);
 298          } else {
 299              print_header($pagetitle, $course->fullname, $navigation, "", "", true,
 300                      update_module_button($cm->id, $course->id, $this->strresource), navmenu($course, $cm));
 301          }
 302          notify(get_string('notallowedlocalfileaccess', 'resource', ''));
 303          if ($inpopup) {
 304              close_window_button();
 305          }
 306          print_footer('none');
 307          die;
 308      }
 309  
 310  
 311      /// Check whether this is supposed to be a popup, but was called directly
 312  
 313      if ($resource->popup and !$inpopup) {    /// Make a page and a pop-up window
 314          print_header($pagetitle, $course->fullname, $navigation, "", "", true,
 315                  update_module_button($cm->id, $course->id, $this->strresource), navmenu($course, $cm));
 316  
 317  
 318          echo "\n<script type=\"text/javascript\">";
 319          echo "\n<!--\n";
 320          echo "openpopup('/mod/resource/view.php?inpopup=true&id={$cm->id}','resource{$resource->id}','{$resource->popup}');\n";
 321          echo "\n-->\n";
 322          echo '</script>';
 323  
 324          if (trim(strip_tags($resource->summary))) {
 325              $formatoptions->noclean = true;
 326              print_simple_box(format_text($resource->summary, FORMAT_MOODLE, $formatoptions), "center");
 327          }
 328  
 329          $link = "<a href=\"$CFG->wwwroot/mod/resource/view.php?inpopup=true&amp;id={$cm->id}\" target=\"resource{$resource->id}\" onclick=\"return openpopup('/mod/resource/view.php?inpopup=true&amp;id={$cm->id}', 'resource{$resource->id}','{$resource->popup}');\">".format_string($resource->name,true)."</a>";
 330  
 331          echo "<p>&nbsp;</p>";
 332          echo '<p align="center">';
 333          print_string('popupresource', 'resource');
 334          echo '<br />';
 335          print_string('popupresourcelink', 'resource', $link);
 336          echo "</p>";
 337  
 338          print_footer($course);
 339          exit;
 340      }
 341  
 342  
 343      /// Now check whether we need to display a frameset
 344  
 345      $frameset = optional_param('frameset', '', PARAM_ALPHA);
 346      if (empty($frameset) and !$embedded and !$inpopup and $resource->options == "frame" and empty($USER->screenreader)) {
 347          echo "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Frameset//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd\">\n";
 348          echo "<html dir=\"ltr\">\n";
 349          echo '<head>';
 350          echo '<meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />';
 351          echo "<title>" . format_string($course->shortname) . ": ".strip_tags(format_string($resource->name,true))."</title></head>\n";
 352          echo "<frameset rows=\"$CFG->resource_framesize,*\">";
 353          echo "<frame src=\"view.php?id={$cm->id}&amp;type={$resource->type}&amp;frameset=top\" title=\"".get_string('modulename','resource')."\"/>";
 354          if (!empty($localpath)) {  // Show it like this so we interpose some HTML
 355              echo "<frame src=\"view.php?id={$cm->id}&amp;type={$resource->type}&amp;inpopup=true\" title=\"".get_string('modulename','resource')."\"/>";
 356          } else {
 357              echo "<frame src=\"$fullurl\" title=\"".get_string('modulename','resource')."\"/>";
 358          }
 359          echo "</frameset>";
 360          echo "</html>";
 361          exit;
 362      }
 363  
 364  
 365      /// We can only get here once per resource, so add an entry to the log
 366  
 367      add_to_log($course->id, "resource", "view", "view.php?id={$cm->id}", $resource->id, $cm->id);
 368  
 369  
 370      /// If we are in a frameset, just print the top of it
 371  
 372      if (!empty($frameset) and $frameset == "top") {
 373          print_header($pagetitle, $course->fullname, $navigation, "", "", true,
 374                  update_module_button($cm->id, $course->id, $this->strresource), navmenu($course, $cm, "parent"));
 375  
 376          echo '<div class="summary">'.format_text($resource->summary, FORMAT_HTML, $formatoptions).'</div>';
 377          if (!empty($localpath)) {  // Show some help
 378              echo '<div align="right" class="helplink">';
 379              link_to_popup_window ('/mod/resource/type/file/localpath.php', get_string('localfile', 'resource'), get_string('localfilehelp','resource'), 400, 500, get_string('localfilehelp', 'resource'));
 380              echo '</div>';
 381          }
 382          echo '</body></html>';
 383          exit;
 384      }
 385  
 386  
 387      /// Display the actual resource
 388  
 389      if ($embedded) {       // Display resource embedded in page
 390          $strdirectlink = get_string("directlink", "resource");
 391  
 392          if ($inpopup) {
 393              print_header($pagetitle);
 394          } else {
 395              print_header($pagetitle, $course->fullname, $navigation, "", "", true,
 396                      update_module_button($cm->id, $course->id, $this->strresource), navmenu($course, $cm, "self"));
 397  
 398          }
 399  
 400          if ($resourcetype == "image") {
 401              echo "<center><p>";
 402              echo "<img title=\"".strip_tags(format_string($resource->name,true))."\" class=\"resourceimage\" src=\"$fullurl\" alt=\"\" />";
 403              echo "</p></center>";
 404  
 405          } else if ($resourcetype == "mp3") {
 406              if (!empty($THEME->resource_mp3player_colors)) {
 407                  $c = $THEME->resource_mp3player_colors;   // You can set this up in your theme/xxx/config.php
 408              } else {
 409                  $c = 'bgColour=000000&btnColour=ffffff&btnBorderColour=cccccc&iconColour=000000&'.
 410                       'iconOverColour=00cc00&trackColour=cccccc&handleColour=ffffff&loaderColour=ffffff&'.
 411                       'font=Arial&fontColour=3333FF&buffer=10&waitForPlay=no&autoPlay=yes';
 412              }
 413              $c .= '&volText='.get_string('vol', 'resource').'&panText='.get_string('pan','resource');
 414              $c = htmlentities($c);
 415              echo '<div class="mp3player" align="center">';
 416              echo '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"';
 417              echo '        codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" ';
 418              echo '        width="600" height="70" id="mp3player" align="">';
 419              echo '<param name="movie" value="'.$CFG->wwwroot.'/lib/mp3player/mp3player.swf?src='.$fullurl.'">';
 420              echo '<param name="quality" value="high">';
 421              echo '<param name="bgcolor" value="#333333">';
 422              echo '<param name="flashvars" value="'.$c.'&amp;" />';
 423              echo '<embed src="'.$CFG->wwwroot.'/lib/mp3player/mp3player.swf?src='.$fullurl.'" ';
 424              echo ' quality="high" bgcolor="#333333" width="600" height="70" name="mp3player" ';
 425              echo ' type="application/x-shockwave-flash" ';
 426              echo ' flashvars="'.$c.'&amp;" ';
 427              echo ' pluginspage="http://www.macromedia.com/go/getflashplayer">';
 428              echo '</embed>';
 429              echo '</object>';
 430              echo '</div>';
 431  
 432  
 433          } else if ($resourcetype == "mediaplayer") {
 434              echo "<center><p>";
 435              echo '<object classid="CLSID:22D6f312-B0F6-11D0-94AB-0080C74C7E95"';
 436              echo '        codebase="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701" ';
 437              echo '        standby="Loading Microsoft� Windows� Media Player components..." ';
 438              echo '        id="msplayer" align="" type="application/x-oleobject">';
 439              echo "<param name=\"Filename\" value=\"$fullurl\">";
 440              echo '<param name="ShowControls" value="true" />';
 441              echo '<param name="AutoRewind" value="true" />';
 442              echo '<param name="AutoStart" value="true" />';
 443              echo '<param name="Autosize" value="true" />';
 444              echo '<param name="EnableContextMenu" value="true" />';
 445              echo '<param name="TransparentAtStart" value="false" />';
 446              echo '<param name="AnimationAtStart" value="false" />';
 447              echo '<param name="ShowGotoBar" value="false" />';
 448              echo '<param name="EnableFullScreenControls" value="true" />';
 449              echo "\n<embed src=\"$fullurl\" name=\"msplayer\" type=\"$mimetype\" ";
 450              echo ' ShowControls="1" AutoRewind="1" AutoStart="1" Autosize="0" EnableContextMenu="1"';
 451              echo ' TransparentAtStart="0" AnimationAtStart="0" ShowGotoBar="0" EnableFullScreenControls="1"';
 452              echo ' pluginspage="http://www.microsoft.com/Windows/Downloads/Contents/Products/MediaPlayer/">';
 453              echo '</embed>';
 454              echo '</object>';
 455              echo "</p></center>";
 456  
 457          } else if ($resourcetype == "quicktime") {
 458  
 459              echo "<center><p>";
 460              echo '<object classid="CLSID:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B"';
 461              echo '        codebase="http://www.apple.com/qtactivex/qtplugin.cab" ';
 462              echo '        height="450" width="600"';
 463              echo '        id="quicktime" align="" type="application/x-oleobject">';
 464              echo "<param name=\"src\" value=\"$fullurl\" />";
 465              echo '<param name="autoplay" value="true" />';
 466              echo '<param name="loop" value="true" />';
 467              echo '<param name="controller" value="true" />';
 468              echo '<param name="scale" value="aspect" />';
 469              echo "\n<embed src=\"$fullurl\" name=\"quicktime\" type=\"$mimetype\" ";
 470              echo ' height="450" width="600" scale="aspect"';
 471              echo ' autoplay="true" controller="true" loop="true" ';
 472              echo ' pluginspage="http://quicktime.apple.com/">';
 473              echo '</embed>';
 474              echo '</object>';
 475              echo "</p></center>";
 476          }
 477  
 478          if (trim($resource->summary)) {
 479              $formatoptions->noclean = true;
 480              print_simple_box(format_text($resource->summary, FORMAT_MOODLE, $formatoptions, $course->id), "center");
 481          }
 482  
 483          if ($inpopup) {
 484              echo "<center><p>(<a href=\"$fullurl\">$strdirectlink</a>)</p></center>";
 485          } else {
 486              print_spacer(20,20);
 487              print_footer($course);
 488          }
 489  
 490      } else {              // Display the resource on it's own
 491          if (!empty($localpath)) {   // Show a link to help work around browser security
 492              echo '<div align="right" class="helplink">';
 493              link_to_popup_window ('/mod/resource/type/file/localpath.php', get_string('localfile', 'resource'), get_string('localfilehelp','resource'), 400, 500, get_string('localfilehelp', 'resource'));
 494              echo '</div>';
 495              echo "<center><p>(<a href=\"$fullurl\">$fullurl</a>)</p></center>";
 496          }
 497          redirect($fullurl);
 498      }
 499  
 500  }
 501  
 502  
 503  //backwards compatible with existing resources
 504  function set_encrypted_parameter() {
 505      global $CFG;
 506  
 507      if (!empty($this->resource->reference) && file_exists($CFG->dirroot ."/mod/resource/type/file/externserverfile.php")) {
 508          include $CFG->dirroot ."/mod/resource/type/file/externserverfile.php";
 509          if (function_exists(extern_server_file)) {
 510              return extern_server_file($this->resource->reference);
 511          }
 512      }
 513      return md5($_SERVER['REMOTE_ADDR'].$CFG->resource_secretphrase);
 514  }
 515  
 516  
 517  function setup_preprocessing(&$defaults){
 518  
 519      if (!isset($defaults['popup'])) {
 520          // use form defaults
 521  
 522      } else if (!empty($defaults['popup'])) {
 523          $defaults['windowpopup'] = 1;
 524          if (array_key_exists('popup', $defaults)) {
 525              $rawoptions = explode(',', $defaults['popup']);
 526              foreach ($rawoptions as $rawoption) {
 527                  $option = explode('=', trim($rawoption));
 528                  $defaults[$option[0]] = $option[1];
 529              }
 530          }
 531      } else {
 532          $defaults['windowpopup'] = 0;
 533          if (array_key_exists('options', $defaults)) {
 534              $defaults['framepage'] = ($defaults['options']=='frame');
 535          }
 536      }
 537      /// load up any stored parameters
 538      if (!empty($defaults['alltext'])) {
 539          $parray = explode(',', $defaults['alltext']);
 540          $i=0;
 541          foreach ($parray as $rawpar) {
 542              list($param, $varname) = explode('=', $rawpar);
 543              $defaults["parse$i"] = $varname;
 544              $defaults["parameter$i"] = $param;
 545              $i++;
 546          }
 547      }
 548  }
 549  
 550  function setup_elements(&$mform) {
 551      global $CFG, $RESOURCE_WINDOW_OPTIONS;
 552  
 553      $this->set_parameters(); // set the parameter array for the form
 554  
 555      $mform->addElement('text', 'reference', get_string('location'), array('size'=>'48'));
 556  
 557      $options = 'menubar,location,toolbar,scrollbars,resizable,width=750,height=500';
 558  
 559      $button = $mform->addElement('button', 'browsebutton', 'Browse for content in hive...');
 560      $url = '/mod/resource/type/repository/hive/openlitebrowse.php';
 561      $buttonattributes = array('title'=>'Browse for content in hive', 'onclick'=>"return openpopup('$url', '".$button->getName()."', '$options', 0);");
 562      $button->updateAttributes($buttonattributes);
 563  
 564      $button = $mform->addElement('button', 'browsebutton', 'Search for content in Hive...');
 565      $url = '/mod/resource/type/repository/hive/openlitesearch.php';
 566      $buttonattributes = array('title'=>'Search for content in Hive', 'onclick'=>"return openpopup('$url', '".$button->getName()."', '$options', 0);");
 567      $button->updateAttributes($buttonattributes);
 568  
 569      $button = $mform->addElement('button', 'browsebutton', 'Add new item to Hive...');
 570      $url = '/mod/resource/type/repository/hive/openlitepublish.php';
 571      $buttonattributes = array('title'=>'Add new item to Hive', 'onclick'=>"return openpopup('$url', '".$button->getName()."', '$options', 0);");
 572      $button->updateAttributes($buttonattributes);
 573  
 574      $mform->addElement('header', 'displaysettings', get_string('display', 'resource'));
 575  
 576      $woptions = array(0 => get_string('pagewindow', 'resource'), 1 => get_string('newwindow', 'resource'));
 577      $mform->addElement('select', 'windowpopup', get_string('display', 'resource'), $woptions);
 578      $mform->setDefault('windowpopup', !empty($CFG->resource_popup));
 579  
 580      $mform->addElement('checkbox', 'framepage', get_string('frameifpossible', 'resource'));
 581      $mform->setDefault('framepage', 0);
 582      $mform->disabledIf('framepage', 'windowpopup', 'eq', 1);
 583      $mform->setAdvanced('framepage');
 584  
 585      foreach ($RESOURCE_WINDOW_OPTIONS as $option) {
 586          if ($option == 'height' or $option == 'width') {
 587              $mform->addElement('text', $option, get_string('new'.$option, 'resource'), array('size'=>'4'));
 588              $mform->setDefault($option, $CFG->{'resource_popup'.$option});
 589              $mform->disabledIf($option, 'windowpopup', 'eq', 0);
 590          } else {
 591              $mform->addElement('checkbox', $option, get_string('new'.$option, 'resource'));
 592              $mform->setDefault($option, $CFG->{'resource_popup'.$option});
 593              $mform->disabledIf($option, 'windowpopup', 'eq', 0);
 594          }
 595          $mform->setAdvanced($option);
 596      }
 597  
 598      $mform->addElement('header', 'parameters', get_string('parameters', 'resource'));
 599  
 600      $options = array();
 601      $options['-'] = get_string('chooseparameter', 'resource').'...';
 602      $optgroup = '';
 603      foreach ($this->parameters as $pname=>$param) {
 604          if ($param['value']=='/optgroup') {
 605              $optgroup = '';
 606              continue;
 607          }
 608          if ($param['value']=='optgroup') {
 609              $optgroup = $param['langstr'];
 610              continue;
 611          }
 612          $options[$pname] = $optgroup.' - '.$param['langstr'];
 613      }
 614  
 615      for ($i = 0; $i < $this->maxparameters; $i++) {
 616          $parametername = "parameter$i";
 617          $parsename = "parse$i";
 618          $group = array();
 619          $group[] =& $mform->createElement('text', $parsename, '', array('size'=>'12'));//TODO: accessiblity
 620          $group[] =& $mform->createElement('select', $parametername, '', $options);//TODO: accessiblity
 621          $mform->addGroup($group, 'pargroup'.$i, get_string('variablename', 'resource').'='.get_string('parameter', 'resource'), ' ', false);
 622          $mform->setAdvanced('pargroup'.$i);
 623  
 624          $mform->setDefault($parametername, '-');
 625      }
 626  }
 627  
 628  }
 629  
 630  ?>


Generated: Wed Jan 14 11:33:29 2009 Cross-referenced by PHPXref 0.7