Пример #1
0
 function run($dbi, $argstr, &$request, $basepage)
 {
     extract($this->getArgs($argstr, $request));
     if ($numberlinks > 10 || $numberlinks < 0) {
         $numberlinks = $this->def_numberlinks;
     }
     // Get name of the current page we are on
     $thispage = $request->getArg('pagename');
     $Pages = $request->session->get("PageTrail");
     if (!is_array($Pages)) {
         $Pages = array();
     }
     if ($duplicates || $thispage != $Pages[0]) {
         array_unshift($Pages, $thispage);
         $request->session->set("PageTrail", $Pages);
     }
     $numberlinks = min(count($Pages), $numberlinks);
     if (!$invisible and $numberlinks) {
         $html = HTML::tt(WikiLink($Pages[$numberlinks - 1], 'auto'));
         for ($i = $numberlinks - 2; $i >= 0; $i--) {
             if (!empty($Pages[$i])) {
                 $html->pushContent(PAGETRAIL_ARROW, WikiLink($Pages[$i], 'auto'));
             }
         }
         return $html;
     } else {
         return HTML();
     }
 }
Пример #2
0
 function run($dbi, $argstr, &$request, $basepage)
 {
     extract($this->getArgs($argstr, $request));
     // Any text that is returned will not be further transformed,
     // so use html where necessary.
     $html = HTML::tt(fmt('%s: %s', $salutation, WikiLink($name, 'auto')), THE_END);
     return $html;
 }
Пример #3
0
 function showForm(&$dbi, &$request, $args)
 {
     $action = $request->getPostURL();
     $hiddenfield = HiddenInputs($request->getArgs(), '', array('action', 'page', 's', 'direction'));
     $pagefilter = HTML::input(array('name' => 'page', 'value' => $args['page'], 'title' => _("Search only in these pages. With autocompletion."), 'class' => 'dropdown', 'acdropdown' => 'true', 'autocomplete_complete' => 'true', 'autocomplete_matchsubstring' => 'false', 'autocomplete_list' => 'xmlrpc:wiki.titleSearch ^[S] 4'), '');
     $query = HTML::input(array('name' => 's', 'value' => $args['s'], 'title' => _("Filter by this link. These are pagenames. With autocompletion."), 'class' => 'dropdown', 'acdropdown' => 'true', 'autocomplete_complete' => 'true', 'autocomplete_matchsubstring' => 'true', 'autocomplete_list' => 'xmlrpc:wiki.titleSearch ^[S] 4'), '');
     $dirsign_switch = JavaScript("\nfunction dirsign_switch() {\n  var d = document.getElementById('dirsign')\n  d.innerHTML = (d.innerHTML == ' =&gt; ') ? ' &lt;= ' : ' =&gt; '\n}\n");
     $dirsign = " => ";
     $in = $out = array('name' => 'direction', 'type' => 'radio', 'onChange' => 'dirsign_switch()');
     $out['value'] = 'out';
     $out['id'] = 'dir_out';
     if ($args['direction'] == 'out') {
         $out['checked'] = 'checked';
     }
     $in['value'] = 'in';
     $in['id'] = 'dir_in';
     if ($args['direction'] == 'in') {
         $in['checked'] = 'checked';
         $dirsign = " <= ";
     }
     $direction = HTML(HTML::input($out), HTML::label(array('for' => 'dir_out'), _("outgoing")), HTML::input($in), HTML::label(array('for' => 'dir_in'), _("incoming")));
     /*
     $direction = HTML::select(array('name'=>'direction',
                                     'onChange' => 'dirsign_switch()'));
     $out = array('value' => 'out');
     if ($args['direction']=='out') $out['selected'] = 'selected';
     $in = array('value' => 'in');
     if ($args['direction']=='in') {
         $in['selected'] = 'selected';
         $dirsign = " <= ";
     }
     $direction->pushContent(HTML::option($out, _("outgoing")));
     $direction->pushContent(HTML::option($in, _("incoming")));
     */
     $submit = Button('submit:search', _("LinkSearch"), false);
     $instructions = _("Search in pages for links with the matching name.");
     $form = HTML::form(array('action' => $action, 'method' => 'GET', 'accept-charset' => $GLOBALS['charset']), $dirsign_switch, $hiddenfield, $instructions, HTML::br(), $pagefilter, HTML::strong(HTML::tt(array('id' => 'dirsign'), $dirsign)), $query, HTML::raw('&nbsp;'), $direction, HTML::raw('&nbsp;'), $submit);
     return $form;
 }
Пример #4
0
 function _start_block($header)
 {
     $this->_block = HTML::table(array('width' => '100%', 'class' => 'block', 'cellspacing' => 0, 'cellpadding' => 1, 'border' => 0), HTML::tr(HTML::td(array('colspan' => 2), HTML::tt($header))));
 }
Пример #5
0
 function _debug($tab, $msg)
 {
     //return ;
     $where = $this->where();
     $tab = str_repeat('____', $this->getDepth()) . $tab;
     printXML(HTML::div("{$tab} {$msg}: at: '", HTML::tt($where), "'"));
     flush();
 }
Пример #6
0
 function _formatMap($pagetext)
 {
     $map = $this->_getMap($pagetext);
     if (!$map) {
         return HTML::p("<No interwiki map found>");
     }
     // Shouldn't happen.
     $mon_attr = array('class' => 'interwiki-moniker');
     $url_attr = array('class' => 'interwiki-url');
     $thead = HTML::thead(HTML::tr(HTML::th($mon_attr, _("Moniker")), HTML::th($url_attr, _("InterWiki Address"))));
     foreach ($map as $moniker => $interurl) {
         $rows[] = HTML::tr(HTML::td($mon_attr, new Cached_WikiLinkIfKnown($moniker)), HTML::td($url_attr, HTML::tt($interurl)));
     }
     return HTML::table(array('class' => 'interwiki-map'), $thead, HTML::tbody(false, $rows));
 }
Пример #7
0
 function setaclForm(&$header, $post_args, $pagehash)
 {
     $acl = $post_args['acl'];
     //FIXME: find intersection of all pages perms, not just from the last pagename
     $pages = array();
     foreach ($pagehash as $name => $checked) {
         if ($checked) {
             $pages[] = $name;
         }
     }
     $perm_tree = pagePermissions($name);
     $table = pagePermissionsAclFormat($perm_tree, !empty($pages));
     $header->pushContent(HTML::strong(_("Selected Pages: ")), HTML::tt(join(', ', $pages)), HTML::br());
     $first_page = $GLOBALS['request']->_dbi->getPage($name);
     $owner = $first_page->getOwner();
     list($type, $perm) = pagePermissionsAcl($perm_tree[0], $perm_tree);
     //if (DEBUG) $header->pushContent(HTML::pre("Permission tree for $name:\n",print_r($perm_tree,true)));
     if ($type == 'inherited') {
         $type = sprintf(_("page permission inherited from %s"), $perm_tree[1][0]);
     } elseif ($type == 'page') {
         $type = _("individual page permission");
     } elseif ($type == 'default') {
         $type = _("default page permission");
     }
     $header->pushContent(HTML::strong(_("Type") . ': '), HTML::tt($type), HTML::br());
     $header->pushContent(HTML::strong(_("ACL") . ': '), HTML::tt($perm->asAclLines()), HTML::br());
     $header->pushContent(HTML::p(HTML::strong(_("Description") . ': '), _("Selected Grant checkboxes allow access, unselected checkboxes deny access."), _("To ignore delete the line."), _("To add check 'Add' near the dropdown list.")));
     $header->pushContent($table);
     //
     // display array of checkboxes for existing perms
     // and a dropdown for user/group to add perms.
     // disabled if inherited,
     // checkbox to disable inheritance,
     // another checkbox to progate new permissions to all childs (if there exist some)
     //Todo:
     // warn if more pages are selected and they have different perms
     //$header->pushContent(HTML::input(array('name' => 'admin_setacl[acl]',
     //                                       'value' => $post_args['acl'])));
     $header->pushContent(HTML::br());
     if (!empty($pages) and defined('EXPERIMENTAL') and EXPERIMENTAL) {
         $checkbox = HTML::input(array('type' => 'checkbox', 'name' => 'admin_setacl[updatechildren]', 'value' => 1));
         if (!empty($post_args['updatechildren'])) {
             $checkbox->setAttr('checked', 'checked');
         }
         $header->pushContent($checkbox, _("Propagate new permissions to all subpages?"), HTML::raw("&nbsp;&nbsp;"), HTML::em(_("(disable individual page permissions, enable inheritance)?")), HTML::br(), HTML::em(_("(Currently not working)")));
     }
     $header->pushContent(HTML::hr());
     return $header;
 }
Пример #8
0
 function run($dbi, $argstr, &$request, $basepage)
 {
     global $WikiTheme;
     $this->_supported_operators = array(':=', '<', '<=', '>', '>=', '!=', '==', '=~');
     $this->_text_operators = array(':=', '==', '=~', '!=');
     $args = $this->getArgs($argstr, $request);
     if (empty($args['page'])) {
         $args['page'] = "*";
     }
     if (!isset($args['s'])) {
         // it might be (integer) 0
         $args['s'] = "*";
     }
     $posted = $request->getArg("semsearch");
     $form = $this->showForm($dbi, $request, $args);
     if (isset($this->_norelations_warning)) {
         $form->pushContent(HTML::div(array('class' => 'warning'), _("Warning:"), HTML::br(), _("No relations nor attributes in the whole wikidb defined!"), "\n", fmt("See %s", WikiLink(_("Help:SemanticRelations")))));
     }
     extract($args);
     // for convenience and harmony we allow GET requests also.
     if (!$request->isPost()) {
         if ($relation or $attribute) {
             // check for good GET request
         } else {
             return $form;
         }
         // nobody called us, so just display our supadupa form
     }
     $pagequery = $this->regex_query($page, $args['case_exact'], $args['regex']);
     // we might want to check for semsearch['relations'] and semsearch['attributes'] also
     if (empty($relation) and empty($attribute)) {
         // so we just clicked without selecting any relation.
         // hmm. check which button we clicked, before we do the massive alltogether search.
         if (isset($posted['relations']) and $posted['relations']) {
             $relation = '*';
         } elseif (isset($posted['attributes']) and $posted['attributes']) {
             $attribute = '*';
             // here we have to check for invalid text operators. ignore it then
             if (!in_array($attr_op, $this->_text_operators)) {
                 $attribute = '';
             }
         }
     }
     $searchtype = "Text";
     if (!empty($relation)) {
         $querydesc = $relation . "::" . $s;
         $linkquery = $this->regex_query($s, $args['case_exact'], $args['regex']);
         $relquery = $this->regex_query($relation, $args['case_exact'], $args['regex']);
         $links = $dbi->linkSearch($pagequery, $linkquery, 'relation', $relquery);
         $pagelist = new PageList($info, $exclude, $args);
         $pagelist->_links = array();
         while ($link = $links->next()) {
             $pagelist->addPage($link['pagename']);
             $pagelist->_links[] = $link;
         }
         // default (=empty info) wants all three. but we want to be able to override this.
         // $pagelist->_columns_seen is the exploded info
         if (!$info or $info and isset($pagelist->_columns_seen['relation'])) {
             $pagelist->addColumnObject(new _PageList_Column_SemanticSearch_relation('relation', _("Relation"), $pagelist));
         }
         if (!$args['info'] or $args['info'] and isset($pagelist->_columns_seen['linkto'])) {
             $pagelist->addColumnObject(new _PageList_Column_SemanticSearch_link('linkto', _("Link"), $pagelist));
         }
     }
     // can we merge two different pagelist?
     if (!empty($attribute)) {
         $relquery = $this->regex_query($attribute, $args['case_exact'], $args['regex']);
         if (!in_array($attr_op, $this->_supported_operators)) {
             return HTML($form, $this->error(fmt("Illegal operator: %s", HTML::tt($attr_op))));
         }
         $s_base = preg_replace("/,/", "", $s);
         $units = new Units();
         if (!is_numeric($s_base)) {
             $s_base = $units->basevalue($s_base);
             $is_numeric = is_numeric($s_base);
         } else {
             $is_numeric = true;
         }
         // check which type to search with:
         // at first check if forced text matcher
         if ($attr_op == '=~') {
             if ($s == '*') {
                 $s = '.*';
             }
             // help the poor user. we need pcre syntax.
             $linkquery = new TextSearchQuery("{$s}", $args['case_exact'], 'pcre');
             $querydesc = "{$attribute} {$attr_op} {$s}";
         } elseif ($is_numeric) {
             // do comparison with numbers
             /* We want to search for multiple attributes also. linkSearch can do this.
              * But we have to construct the query somehow. (that's why we try the AND OR dhtml)
              *     population < 1 million AND area > 50 km2
              * Here we check only for one attribute per page.
              * See SemanticSearchAdvanced for the full expression.
              */
             // it might not be the best idea to use '*' as variable to expand. hmm.
             if ($attribute == '*') {
                 $attribute = '_star_';
             }
             $searchtype = "Numeric";
             $query = $attribute . " " . $attr_op . " " . $s_base;
             $linkquery = new SemanticAttributeSearchQuery($query, $attribute, $units->baseunit($s));
             if ($attribute == '_star_') {
                 $attribute = '*';
             }
             $querydesc = $attribute . " " . $attr_op . " " . $s;
             // no number or unit: check other text matchers or '*' MATCH_ALL
         } elseif (in_array($attr_op, $this->_text_operators)) {
             if ($attr_op == '=~') {
                 if ($s == '*') {
                     $s = '.*';
                 }
                 // help the poor user. we need pcre syntax.
                 $linkquery = new TextSearchQuery("{$s}", $args['case_exact'], 'pcre');
             } else {
                 $linkquery = $this->regex_query($s, $args['case_exact'], $args['regex']);
             }
             $querydesc = "{$attribute} {$attr_op} {$s}";
             // should we fail or skip when the user clicks on Relations?
         } elseif (isset($posted['relations']) and $posted['relations']) {
             $linkquery = false;
             // skip
         } else {
             $querydesc = $attribute . " " . $attr_op . " " . $s;
             return HTML($form, $this->error(fmt("Only text operators can be used with strings: %s", HTML::tt($querydesc))));
         }
         if ($linkquery) {
             $links = $dbi->linkSearch($pagequery, $linkquery, 'attribute', $relquery);
             if (empty($relation)) {
                 $pagelist = new PageList($args['info'], $args['exclude'], $args);
                 $pagelist->_links = array();
             }
             while ($link = $links->next()) {
                 $pagelist->addPage($link['pagename']);
                 $pagelist->_links[] = $link;
             }
             // default (=empty info) wants all three. but we want to override this.
             if (!$args['info'] or $args['info'] and isset($pagelist->_columns_seen['attribute'])) {
                 $pagelist->addColumnObject(new _PageList_Column_SemanticSearch_relation('attribute', _("Attribute"), $pagelist));
             }
             if (!$args['info'] or $args['info'] and isset($pagelist->_columns_seen['value'])) {
                 $pagelist->addColumnObject(new _PageList_Column_SemanticSearch_link('value', _("Value"), $pagelist));
             }
         }
     }
     if (!isset($pagelist)) {
         $querydesc = _("<empty>");
         $pagelist = new PageList();
     }
     if (!$noheader) {
         // We put the form into the caption just to be able to return one pagelist object,
         // and to still have the convenience form at the top. we could workaround this by
         // putting the form as WikiFormRich into the actionpage. but thid doesnt look as
         // nice as this here.
         $pagelist->setCaption(HTML($noform ? '' : HTML($form, HTML::hr()), fmt("Semantic %s Search Result for \"%s\" in pages \"%s\"", $searchtype, $querydesc, $page)));
     }
     return $pagelist;
 }
Пример #9
0
 function _lines($lines, $class, $prefix = false, $elem = false)
 {
     if (!$prefix) {
         $prefix = HTML::raw('&nbsp;');
     }
     $div = HTML::div(array('class' => 'difftext'));
     foreach ($lines as $line) {
         if ($elem) {
             $line = new HtmlElement($elem, $line);
         }
         $div->pushContent(HTML::div(array('class' => $class), HTML::tt(array('class' => 'prefix'), $prefix), $line, HTML::raw('&nbsp;')));
     }
     $this->_block->pushContent($div);
 }
Пример #10
0
 function showWatchList($pagelist)
 {
     return HTML::strong(HTML::tt(empty($pagelist) ? _("<empty>") : $pagelist));
 }
Пример #11
0
 function setaclForm(&$header, $pagehash)
 {
     $pages = array();
     foreach ($pagehash as $name => $checked) {
         if ($checked) {
             $pages[] = $name;
         }
     }
     $header->pushContent(HTML::strong(_("Selected Pages: ")), HTML::tt(join(', ', $pages)), HTML::br());
     return $header;
 }
Пример #12
0
function pagePermissionsSimpleFormat($perm_tree, $owner, $group = false)
{
    list($type, $perm) = pagePermissionsAcl($perm_tree[0], $perm_tree);
    /*
    $type = $perm_tree[0];
    $perm = pagePermissionsAcl($perm_tree);
    if (is_object($perm_tree[1]))
        $perm = $perm_tree[1];
    elseif (is_array($perm_tree[1])) {
        $perm_tree = pagePermissionsSimpleFormat($perm_tree[1],$owner,$group);
    	if (isa($perm_tree[1],'pagepermission'))
    	    $perm = $perm_tree[1];
    	elseif (isa($perm_tree,'htmlelement'))
            return $perm_tree;
    }
    */
    if ($type == 'page') {
        return HTML::tt(HTML::strong($perm->asRwxString($owner, $group)));
    } elseif ($type == 'default') {
        return HTML::tt($perm->asRwxString($owner, $group));
    } elseif ($type == 'inherited') {
        return HTML::tt(array('class' => 'inherited', 'style' => 'color:#aaa;'), $perm->asRwxString($owner, $group));
    }
}
Пример #13
0
 function tex2png($text)
 {
     // the name of the png cached file
     $imagename = md5($text) . ".png";
     $url = $this->imagepath . "/{$imagename}";
     if (!file_exists($url)) {
         if (is_writable($this->imagepath)) {
             $texfile = $this->imagepath . "/temp.tex";
             $this->createTexFile($texfile, $text);
             $this->createPngFile($this->imagepath, $imagename);
         } else {
             $error_html = _("TeX directory not writable.");
             trigger_error($error_html, E_USER_NOTICE);
         }
     }
     // there is always something in the html page
     // even if the tex directory doesn't exist
     // or mathematical expression is wrong
     switch ($this->isMathExp($text)) {
         case 0:
             // not a mathematical expression
             $html = HTML::tt(array('class' => 'tex', 'style' => 'color:red;'), $text);
             break;
         case 1:
             // an inlined mathematical expression
             $html = HTML::img(array('class' => 'tex', 'src' => $url, 'alt' => $text));
             break;
         case 2:
             // mathematical expression on separate line
             $html = HTML::img(array('class' => 'tex', 'src' => $url, 'alt' => $text));
             $html = HTML::div(array('align' => 'center'), $html);
             break;
         default:
             break;
     }
     return $html;
 }