[ Index ]

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

title

Body

[close]

/lib/editor/htmlarea/popups/ -> link_std.php (source)

   1  <?php // $Id: link_std.php,v 1.6 2007/01/27 23:23:44 skodak Exp $
   2      require("../../../../config.php");
   3  
   4      $id = optional_param('id', SITEID, PARAM_INT);
   5  
   6      require_course_login($id);
   7      @header('Content-Type: text/html; charset=utf-8');
   8  ?>
   9  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  10      "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  11  <html>
  12  <head>
  13  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  14    <title><?php print_string("insertlink","editor");?></title>
  15    <script type="text/javascript" src="popup.js"></script>
  16    <script type="text/javascript">
  17  //<![CDATA[
  18  function onTargetChanged() {
  19    var f = document.getElementById("f_other_target");
  20    if (this.value == "_other") {
  21      f.style.visibility = "visible";
  22      f.select();
  23      f.focus();
  24    } else f.style.visibility = "hidden";
  25  };
  26  function Init() {
  27    //__dlg_translate(I18N);
  28    __dlg_init();
  29  
  30    var param = window.dialogArguments;
  31    if(param.f_anchors) {
  32        //anchors = param.f_anchors;
  33        var anchor = document.getElementById('f_anchors');
  34        for(var a in param.f_anchors) {
  35          var opti = document.createElement('option');
  36          opti.value = '#' + param.f_anchors[a];
  37          opti.innerHTML = opti.value;
  38          anchor.appendChild(opti);
  39      }
  40    }
  41    var target_select = document.getElementById("f_target");
  42    if (param.f_href) {
  43        document.getElementById("f_href").value = param["f_href"];
  44        document.getElementById("f_title").value = param["f_title"];
  45        //comboSelectValue(target_select, param["f_target"]);
  46        if (target_select.value != param.f_target) {
  47          var opt = document.createElement("option");
  48          opt.value = param.f_target;
  49          opt.innerHTML = opt.value;
  50          target_select.appendChild(opt);
  51          opt.selected = true;
  52        }
  53    } else {
  54        document.getElementById("f_href").value = "http://";
  55    }
  56    var opt = document.createElement("option");
  57    opt.value = "_other";
  58    opt.innerHTML = "<?php print_string("linktargetother","editor");?>";
  59    target_select.appendChild(opt);
  60    target_select.onchange = onTargetChanged;
  61    document.getElementById("f_href").focus();
  62    document.getElementById("f_href").select();
  63  };
  64  
  65  function onOK() {
  66    var required = {
  67      "f_href": "You must enter the URL where this link points to"
  68    };
  69    for (var i in required) {
  70      var el = document.getElementById(i);
  71      if (!el.value) {
  72        alert(required[i]);
  73        el.focus();
  74        return false;
  75      }
  76    }
  77    // pass data back to the calling window
  78    var fields = ["f_href", "f_title", "f_target" ];
  79    var param = new Object();
  80    for (var i in fields) {
  81      var id = fields[i];
  82      var el = document.getElementById(id);
  83      param[id] = el.value;
  84    }
  85    if (param.f_target == "_other") {
  86      param.f_target = document.getElementById("f_other_target").value;
  87    }
  88    __dlg_close(param);
  89    return false;
  90  };
  91  
  92  function onCancel() {
  93    __dlg_close(null);
  94    return false;
  95  };
  96  
  97  function onBrowse() {
  98      var lx = (screen.width - 470) / 2;
  99      var tx = (screen.height - 400) / 2;
 100  
 101      var settings = "toolbar=no,";
 102      settings += " location=no,";
 103      settings += " directories=no,";
 104      settings += " status=no,";
 105      settings += " menubar=no,";
 106      settings += " scrollbars=no,";
 107      settings += " resizable=no,";
 108      settings += " width=470,";
 109      settings += " height=400,";
 110  
 111      var newwin = window.open("link.php?id=<?php echo $id; ?>","",""+ settings +" left="+ lx +", top="+ tx +"");
 112      return false;
 113  }
 114  function seturl() {
 115      var sel = document.getElementById('f_anchors');
 116      var txt = sel.options[sel.selectedIndex].text;
 117      if(txt != '----') {
 118          var f_url = document.getElementById('f_href');
 119          f_url.value = txt;
 120      }
 121  }
 122  //]]>
 123  </script>
 124  <style type="text/css">
 125  html, body {
 126    background: ButtonFace;
 127    color: ButtonText;
 128    font: 11px Tahoma,Verdana,sans-serif;
 129    margin: 0px;
 130    padding: 0px;
 131  }
 132  body { padding: 5px; }
 133  table { font: 11px Tahoma,Verdana,sans-serif; }
 134  select, input, button { font: 11px Tahoma,Verdana,sans-serif; }
 135  button { width: 70px; }
 136  table .label { text-align: right; width: 8em; }
 137  
 138  .title { background: #ddf; color: #000; font-weight: bold; font-size: 120%; padding: 3px 10px; margin-bottom: 3px;
 139  border-bottom: 1px solid black; letter-spacing: 2px;
 140  }
 141  
 142  #buttons {
 143        margin-top: 1em; border-top: 1px solid #999;
 144        padding: 2px; text-align: right;
 145  }
 146  </style>
 147  </head>
 148  <body onload="Init()">
 149  <div class="title"><?php print_string("insertlink","editor");?></div>
 150  <table border="0" style="width: 100%;">
 151    <tr>
 152      <td class="label"><?php print_string("linkurl","editor");?>:</td>
 153      <td><input type="text" id="f_href" style="width: 100%" /></td>
 154    </tr>
 155    <tr>
 156      <td class="label"><?php print_string("linktitle","editor");?>:</td>
 157      <td><input type="text" id="f_title" style="width: 100%" /></td>
 158    </tr>
 159    <tr>
 160      <td class="label"><?php print_string("linktarget","editor");?>:</td>
 161      <td><select id="f_target">
 162        <option value=""><?php print_string("linktargetnone","editor");?></option>
 163        <option value="_blank"><?php print_string("linktargetblank","editor");?></option>
 164        <option value="_self"><?php print_string("linktargetself","editor");?></option>
 165        <option value="_top"><?php print_string("linktargettop","editor");?></option>
 166      </select>
 167    <tr>
 168      <td class="label"><?php print_string("anchors","editor");?>:</td>
 169      <td><select id="f_anchors" onchange="seturl()">
 170      <option value="">----</option></select></td>
 171    </tr>
 172      <input type="text" name="f_other_target" id="f_other_target" size="10" style="visibility: hidden" />
 173      </td>
 174    </tr>
 175  </table>
 176  
 177  <div id="buttons">
 178    <?php if (has_capability('moodle/course:managefiles', get_context_instance(CONTEXT_COURSE, $id))) {
 179              echo "<button type=\"button\" name=\"browse\" onclick=\"return onBrowse();\">".get_string("browse","editor")."...</button>";
 180          }
 181    ?>
 182    <button type="button" name="ok" onclick="return onOK();"><?php print_string("ok","editor");?></button>
 183    <button type="button" name="cancel" onclick="return onCancel();"><?php print_string("cancel","editor");?></button>
 184  </div>
 185  
 186  </body>
 187  </html>


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