Example #1
0
 function run($dbi, $argstr, &$request, $basepage)
 {
     global $WikiTheme;
     $args = $this->getArgs($argstr, $request);
     extract($args);
     if (!$src) {
         return $this->error(fmt("%s parameter missing", "'src'"));
     }
     // Expand possible interwiki link for src
     if (strstr($src, ':') and !strstr($src, '://') and $intermap = getInterwikiMap() and preg_match("/^" . $intermap->getRegexp() . ":/", $src)) {
         $link = $intermap->link($src);
         $src = $link->getAttr('href');
     }
     // FIXME: Better recursion detection.
     // FIXME: Currently this doesnt work at all.
     if ($src == $request->getURLtoSelf()) {
         return $this->error(fmt("recursive inclusion of url %s", $src));
     }
     if (!IsSafeURL($src)) {
         return $this->error(_("Bad url in src: remove all of <, >, \""));
     }
     $params = array('title' => $title, 'src' => $src, 'width' => "100%", 'height' => $height, 'marginwidth' => 0, 'marginheight' => 0, 'class' => 'transclude', "onload" => "adjust_iframe_height(this);");
     $noframe_msg[] = fmt("See: %s", HTML::a(array('href' => $src), $src));
     $noframe_msg = HTML::div(array('class' => 'transclusion'), HTML::p(array(), $noframe_msg));
     $iframe = HTML::iframe($params, $noframe_msg);
     /* This doesn't work very well...  maybe because CSS screws up NS4 anyway...
        $iframe = new HtmlElement('ilayer', array('src' => $src), $iframe);
        */
     if ($quiet) {
         return HTML($this->_js(), $iframe);
     } else {
         return HTML(HTML::p(array('class' => 'transclusion-title'), fmt("Transcluded from %s", LinkURL($src))), $this->_js(), $iframe);
     }
 }
Example #2
0
 function _getInterWikiUrl(&$request)
 {
     $intermap = getInterwikiMap();
     $map = $intermap->_map;
     if (in_array($this->_url, array_keys($map))) {
         if (empty($this->_name)) {
             $this->_name = $this->_url;
         }
         $this->_url = sprintf($map[$this->_url], '%s');
     }
     if (empty($this->_name)) {
         $this->_name = $this->getName();
     }
 }
Example #3
0
 function _getMap($pagetext)
 {
     $map = getInterwikiMap($pagetext);
     return $map->_map;
 }
Example #4
0
 function getMatchRegexp()
 {
     $map = getInterwikiMap();
     return "(?<! [[:alnum:]])" . $map->getRegexp() . ": [^:=]\\S+ (?<![ ,.?;! \\] \\) \" \\' ])";
 }
Example #5
0
 function getMatchRegexp()
 {
     global $request;
     $map = getInterwikiMap();
     return "(?<! [[:alnum:]])" . $map->getRegexp() . ": \\S+ (?<![ ,.?;! \\] \\) \" \\' ])";
 }
Example #6
0
 /** Constructor
  *
  * @param mixed $name Page name.
  * WikiDB_Page, WikiDB_PageRevision, or string.
  * This can be a relative subpage name (like '/SubPage'),
  * or can be the empty string to refer to the $basename.
  *
  * @param string $anchor For links to anchors in page.
  *
  * @param mixed $basename Page name from which to interpret
  * relative or other non-fully-specified page names.
  */
 function WikiPageName($name, $basename = false, $anchor = false)
 {
     if (is_string($name)) {
         $this->shortName = $name;
         if (strstr($name, ':')) {
             list($moniker, $shortName) = explode(":", $name, 2);
             $map = getInterwikiMap();
             // allow overrides to custom maps
             if (isset($map->_map[$moniker])) {
                 $url = $map->_map[$moniker];
                 if (strstr($url, '%s')) {
                     $url = sprintf($url, $shortName);
                 } else {
                     $url .= $shortName;
                 }
                 $this->url = $url;
                 // expand Talk or User, but not to absolute urls!
                 if (strstr($url, '//')) {
                     if ($moniker == 'Talk') {
                         $name = $name . SUBPAGE_SEPARATOR . _("Discussion");
                     } elseif ($moniker == 'User') {
                         $name = $name;
                     }
                 } else {
                     $name = $url;
                 }
                 if (strstr($shortName, '?')) {
                     list($shortName, $dummy) = explode("\\?", $shortName, 2);
                 }
                 $this->shortName = $shortName;
             }
         }
         // FIXME: We should really fix the cause for "/PageName" in the WikiDB
         if ($name == '' or $name[0] == SUBPAGE_SEPARATOR) {
             if ($basename) {
                 $name = $this->_pagename($basename) . $name;
             } else {
                 $name = $this->_normalize_bad_pagename($name);
                 $this->shortName = $name;
             }
         }
     } else {
         $name = $this->_pagename($name);
         $this->shortName = $name;
     }
     $this->name = $this->_check($name);
     $this->anchor = (string) $anchor;
 }
Example #7
0
 function expand($basepage, &$markup)
 {
     global $WikiTheme;
     $intermap = getInterwikiMap();
     $label = isset($this->_label) ? $this->_label : false;
     //FIXME: check Upload: inlined images
     if ($WikiTheme->DUMP_MODE and !empty($WikiTheme->VALID_LINKS)) {
         if (!in_array($this->_link, $WikiTheme->VALID_LINKS)) {
             return HTML($label ? $label : $this->_link);
         }
     }
     return $intermap->link($this->_link, $label);
 }
Example #8
0
 function expand($basepage, &$markup)
 {
     $intermap = getInterwikiMap();
     $label = isset($this->_label) ? $this->_label : false;
     return $intermap->link($this->_link, $label);
 }