Пример #1
0
 function _generateColheadings(&$info, &$table)
 {
     // table headings
     $tr = HTML::tr();
     $headings = array(_("Plugin"), _("Description"));
     if ($info == 'args') {
         $headings[] = _("Arguments");
     }
     foreach ($headings as $title) {
         $tr->pushContent(HTML::th($title));
     }
     $table->pushContent(HTML::thead($tr));
 }
Пример #2
0
 function run($dbi, $argstr, &$request, $basepage)
 {
     if (!ACCESS_LOG) {
         return;
     }
     $args = $this->getArgs($argstr, $request);
     $table = HTML::table(array('cellpadding' => 1, 'cellspacing' => 2, 'border' => 0, 'class' => 'pagelist'));
     if (!$args['noheader'] and !empty($args['caption'])) {
         $table->pushContent(HTML::caption(array('align' => 'top'), $args['caption']));
     }
     $logs = array();
     $limit = $args['limit'];
     $accesslog =& $request->_accesslog;
     if ($logiter = $accesslog->get_referer($limit, "external_only") and $logiter->count()) {
         $table->pushContent(HTML::tr(HTML::th("Target"), HTML::th("Referrer"), HTML::th("Host"), HTML::th("Date")));
         while ($logentry = $logiter->next()) {
             $table->pushContent(HTML::tr(HTML::td($logentry['request']), HTML::td($logentry['referer']), HTML::td($logentry['host']), HTML::td($logentry['time'])));
         }
         return $table;
     }
 }
Пример #3
0
 function _arrayToTable($array, &$request)
 {
     $thead = HTML::thead();
     $label[0] = _("Wiki Name");
     $label[1] = _("Search");
     $thead->pushContent(HTML::tr(HTML::th($label[0]), HTML::th($label[1])));
     $tbody = HTML::tbody();
     $dbi = $request->getDbh();
     if ($array) {
         foreach ($array as $moniker => $interurl) {
             $monikertd = HTML::td(array('class' => 'interwiki-moniker'), $dbi->isWikiPage($moniker) ? WikiLink($moniker) : $moniker);
             $w = new WikiPluginLoader();
             $p = $w->getPlugin('ExternalSearch');
             $argstr = sprintf('url="%s"', addslashes($interurl));
             $searchtd = HTML::td($p->run($dbi, $argstr, $request, $basepage));
             $tbody->pushContent(HTML::tr($monikertd, $searchtd));
         }
     }
     $table = HTML::table();
     $table->setAttr('class', 'interwiki-map');
     $table->pushContent($thead);
     $table->pushContent($tbody);
     return $table;
 }
Пример #4
0
 function doPoll($page, $request, $answers, $readonly = false)
 {
     $question = $this->_args['question'];
     $answer = $this->_args['answer'];
     $html = HTML::table(array('cellspacing' => 2));
     $init = isset($question[0]) ? 0 : 1;
     for ($i = $init; $i <= count($question); $i++) {
         if (!isset($question[$i])) {
             break;
         }
         $poll = $page->get('poll');
         @$poll['data']['all'][$i]++;
         $q = $question[$i];
         if (!isset($answer[$i])) {
             trigger_error(fmt("Missing %s for %s", "answer" . "[{$i}]", "question" . "[{$i}]"), E_USER_ERROR);
         }
         if (!$readonly) {
             $page->set('poll', $poll);
         }
         $a = $answer[$i];
         $result = isset($answers[$i]) ? $answers[$i] : -1;
         if (!is_array($a)) {
             $checkbox = HTML::input(array('type' => 'checkbox', 'name' => "answer[{$i}]", 'value' => $a));
             if ($result >= 0) {
                 $checkbox->setAttr('checked', "checked");
             }
             if (!$readonly) {
                 list($percent, $count, $all) = $this->storeResult($page, $i, $result ? 1 : 0);
             } else {
                 list($percent, $count, $all) = $this->getResult($page, $i, 1);
             }
             $print = sprintf(_("  %d%% (%d/%d)"), $percent, $count, $all);
             $html->pushContent(HTML::tr(HTML::th(array('colspan' => 4, 'align' => 'left'), $q)));
             $html->pushContent(HTML::tr(HTML::td($checkbox), HTML::td($a), HTML::td($this->bar($percent)), HTML::td($print)));
         } else {
             $html->pushContent(HTML::tr(HTML::th(array('colspan' => 4, 'align' => 'left'), $q)));
             $row = HTML();
             if (!$readonly) {
                 $this->storeResult($page, $i, $answers[$i]);
             }
             for ($j = 0; $j <= count($a); $j++) {
                 if (isset($a[$j])) {
                     list($percent, $count, $all) = $this->getResult($page, $i, $j);
                     $print = sprintf(_("  %d%% (%d/%d)"), $percent, $count, $all);
                     $radio = HTML::input(array('type' => 'radio', 'name' => "answer[{$i}]", 'value' => $j));
                     if ($result == $j) {
                         $radio->setAttr('checked', "checked");
                     }
                     $row->pushContent(HTML::tr(HTML::td($radio), HTML::td($a[$j]), HTML::td($this->bar($percent)), HTML::td($print)));
                 }
             }
             $html->pushContent($row);
         }
     }
     if (!$readonly) {
         return HTML(HTML::h3(_("The result of this poll so far:")), $html, HTML::p(_("Thanks for participating!")));
     } else {
         return HTML(HTML::h3(_("The result of this poll so far:")), $html);
     }
 }
Пример #5
0
 function run($dbi, $argstr, &$request, $basepage)
 {
     global $WikiTheme;
     include_once 'lib/InlineParser.php';
     $table = array();
     $lines = preg_split('/\\s*?\\n\\s*/', $argstr);
     foreach ($lines as $line) {
         if (!$line) {
             continue;
         }
         $line = trim($line);
         // If line ends with a '|', remove it
         if ($line[strlen($line) - 1] == '|') {
             $line = substr($line, 0, -1);
         }
         if ($line[0] != '|') {
             // trigger_error(sprintf(_("Line %s does not begin with a '|'."), $line), E_USER_WARNING);
         } else {
             $table[] = $this->_parse_row($line, $basepage);
         }
     }
     $nbrows = sizeof($table);
     // If table is empty, do not generate table markup
     if ($nbrows == 0) {
         return HTML::raw('');
     }
     $nbcols = sizeof($table[0]);
     for ($i = 0; $i < $nbrows; $i++) {
         for ($j = 0; $j < $nbcols; $j++) {
             if (preg_match('/@@/', $table[$i][$j])) {
                 $table[$i][$j] = compute_tablecell($table, $i, $j, $nbrows, $nbcols);
             }
         }
     }
     $htmltable = HTML::table(array('class' => "bordered"));
     foreach ($table as $row) {
         $htmlrow = HTML::tr();
         foreach ($row as $cell) {
             if ($cell && $cell[0] == '=') {
                 $cell = trim(substr($cell, 1));
                 $htmlrow->pushContent(HTML::th(TransformInline($cell, 2.0, $basepage)));
             } else {
                 if (is_numeric($cell)) {
                     $htmlrow->pushContent(HTML::td(array('style' => "text-align:right"), $cell));
                 } else {
                     $htmlrow->pushContent(HTML::td(TransformInline($cell, 2.0, $basepage)));
                 }
             }
         }
         $htmltable->pushContent($htmlrow);
     }
     return $htmltable;
 }
Пример #6
0
 function run($dbi, $argstr, $request)
 {
     extract($this->getArgs($argstr, $request));
     $html = HTML::table(array('cellpadding' => 1, 'cellspacing' => 1, 'border' => 1));
     $connect = ldap_connect($host, $port);
     if (!ldap_set_option($connect, LDAP_OPT_PROTOCOL_VERSION, 3)) {
         $this->error(_("Failed to set LDAP protocol version to 3"));
     }
     $bind = ldap_bind($connect);
     $attr_array = array("");
     // for now -
     if (!$attributes) {
         $res = ldap_search($connect, $basedn, $filter);
     } else {
         $attr_array = split(" ", $attributes);
         $res = ldap_search($connect, $basedn, $filter, $attr_array);
     }
     $entries = ldap_get_entries($connect, $res);
     // If we were given attributes then we return them in the order given
     if ($attributes) {
         for ($i = 0; $i < count($attr_array); $i++) {
             $attrcols[$i] = 0;
         }
         // Work out how many columns we need for each attribute.
         for ($i = 0; $i < $entries["count"]; $i++) {
             for ($ii = 0; $ii < $entries[$i]["count"]; $ii++) {
                 $data = $entries[$i][$ii];
                 $datalen = $entries[$i][$data]["count"];
                 if ($attrcols[$ii] < $datalen) {
                     $attrcols[$ii] = $datalen;
                 }
             }
         }
         // Now print the headers
         $row = HTML::tr();
         for ($i = 0; $i < count($attr_array); $i++) {
             $row->pushContent(HTML::th(array('colspan' => $attrcols[$i]), $attr_array[$i]));
         }
         $html->pushContent($row);
         for ($i = 0; $i < $entries["count"]; $i++) {
             // start a new row for every data value.
             $row = HTML::tr();
             $nc = 0;
             for ($ii = 0; $ii < $entries[$i]["count"]; $ii++) {
                 $data = $entries[$i][$ii];
                 // 3 possible cases for the values of each attribute.
                 switch ($entries[$i][$data]["count"]) {
                     case 0:
                         $row->pushContent(HTML::td(""));
                         $nc++;
                         break;
                     default:
                         for ($iii = 0; $iii < $entries[$i][$data]["count"]; $iii++) {
                             $row->pushContent(HTML::td($entries[$i][$data][$iii]));
                             $nc++;
                         }
                 }
                 // Make up some blank cells if required to pad this row
                 for ($j = 0; $j < $attrcols[$ii] - $nc; $j++) {
                     $row->pushContent(HTML::td(""));
                 }
             }
             $html->pushContent($row);
         }
     } else {
         // $i = entries
         // $ii = attributes for entry
         // $iii = values per attribute
         for ($i = 0; $i < $entries["count"]; $i++) {
             $row = HTML::tr();
             for ($ii = 0; $ii < $entries[$i]["count"]; $ii++) {
                 $data = $entries[$i][$ii];
                 for ($iii = 0; $iii < $entries[$i][$data]["count"]; $iii++) {
                     //echo $data.":&nbsp;&nbsp;".$entries[$i][$data][$iii]."<br>";
                     if (!$attributes) {
                         $row->pushContent(HTML::td($data));
                     }
                     $row->pushContent(HTML::td($entries[$i][$data][$iii]));
                 }
             }
             $html->pushContent($row);
         }
     }
     // THE_END); // ??
     return $html;
 }
Пример #7
0
 function showForm(&$dbi, &$request, $args)
 {
     global $WikiTheme;
     $action = $request->getPostURL();
     $hiddenfield = HiddenInputs($request->getArgs(), '', array('action', 'page', 's', 'semsearch', 'relation', 'attribute'));
     $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'), '');
     $allrelations = $dbi->listRelations(false, false, true);
     $svalues = empty($allrelations) ? "" : join("','", $allrelations);
     $reldef = JavaScript("var semsearch_relations = new Array('" . $svalues . "')");
     $relation = HTML::input(array('name' => 'relation', 'value' => $args['relation'], 'title' => _("Filter by this relation. With autocompletion."), 'class' => 'dropdown', 'style' => 'width:10em', 'acdropdown' => 'true', 'autocomplete_assoc' => 'false', 'autocomplete_complete' => 'true', 'autocomplete_matchsubstring' => 'true', 'autocomplete_list' => 'array:semsearch_relations'), '');
     $queryrel = 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'), '');
     $relsubmit = Button('submit:semsearch[relations]', _("Relations"), false);
     // just testing some dhtml... not yet done
     $enhancements = HTML();
     $nbsp = HTML::raw('&nbsp;');
     $this_uri = $_SERVER['REQUEST_URI'] . '#';
     $andbutton = new Button(_("AND"), $this_uri, 'wikiaction', array('onclick' => "addquery('rel', 'and')", 'title' => _("Add an AND query")));
     $orbutton = new Button(_("OR"), $this_uri, 'wikiaction', array('onclick' => "addquery('rel', 'or')", 'title' => _("Add an OR query")));
     if (DEBUG) {
         $enhancements = HTML::span($andbutton, $nbsp, $orbutton);
     }
     $instructions = _("Search in pages for a relation with that value (a pagename).");
     $form1 = HTML::form(array('action' => $action, 'method' => 'post', 'accept-charset' => $GLOBALS['charset']), $reldef, $hiddenfield, HiddenInputs(array('attribute' => '')), $instructions, HTML::br(), HTML::table(array('border' => 0, 'cellspacing' => 2), HTML::colgroup(array('span' => 6)), HTML::thead(HTML::tr(HTML::th('Pagefilter'), HTML::th('Relation'), HTML::th(), HTML::th('Links'), HTML::th())), HTML::tbody(HTML::tr(HTML::td($pagefilter, ": "), HTML::td($relation), HTML::td(HTML::strong(HTML::tt('  ::  '))), HTML::td($queryrel), HTML::td($nbsp, $relsubmit, $nbsp, $enhancements)))));
     $allattrs = $dbi->listRelations(false, true, true);
     if (empty($allrelations) and empty($allattrs)) {
         // be nice to the dummy.
         $this->_norelations_warning = 1;
     }
     $svalues = empty($allattrs) ? "" : join("','", $allattrs);
     $attdef = JavaScript("var semsearch_attributes = new Array('" . $svalues . "')\n" . "var semsearch_op = new Array('" . join("','", $this->_supported_operators) . "')");
     // TODO: We want some more tricks: Autofill the base unit of the selected
     // attribute into the s area.
     $attribute = HTML::input(array('name' => 'attribute', 'value' => $args['attribute'], 'title' => _("Filter by this attribute name. With autocompletion."), 'class' => 'dropdown', 'style' => 'width:10em', 'acdropdown' => 'true', 'autocomplete_complete' => 'true', 'autocomplete_matchsubstring' => 'true', 'autocomplete_assoc' => 'false', 'autocomplete_list' => 'array:semsearch_attributes'), '');
     $attr_op = HTML::input(array('name' => 'attr_op', 'value' => $args['attr_op'], 'title' => _("Comparison operator. With autocompletion."), 'class' => 'dropdown', 'style' => 'width:2em', 'acdropdown' => 'true', 'autocomplete_complete' => 'true', 'autocomplete_matchsubstring' => 'true', 'autocomplete_assoc' => 'false', 'autocomplete_list' => 'array:semsearch_op'), '');
     $queryatt = HTML::input(array('name' => 's', 'value' => $args['s'], 'title' => _("Filter by this numeric attribute value. With autocompletion."), 'class' => 'dropdown', 'acdropdown' => 'false', 'autocomplete_complete' => 'true', 'autocomplete_matchsubstring' => 'false', 'autocomplete_assoc' => 'false', 'autocomplete_list' => 'plugin:SemanticSearch page=' . $args['page'] . ' attribute=^[S] attr_op==~'), '');
     $andbutton = new Button(_("AND"), $this_uri, 'wikiaction', array('onclick' => "addquery('attr', 'and')", 'title' => _("Add an AND query")));
     $orbutton = new Button(_("OR"), $this_uri, 'wikiaction', array('onclick' => "addquery('attr', 'or')", 'title' => _("Add an OR query")));
     if (DEBUG) {
         $enhancements = HTML::span($andbutton, $nbsp, $orbutton);
     }
     $attsubmit = Button('submit:semsearch[attributes]', _("Attributes"), false);
     $instructions = HTML::span(_("Search in pages for an attribute with that numeric value."), "\n");
     if (DEBUG) {
         $instructions->pushContent(HTML(" ", new Button(_("Advanced..."), _("SemanticSearchAdvanced"))));
     }
     $form2 = HTML::form(array('action' => $action, 'method' => 'post', 'accept-charset' => $GLOBALS['charset']), $attdef, $hiddenfield, HiddenInputs(array('relation' => '')), $instructions, HTML::br(), HTML::table(array('border' => 0, 'cellspacing' => 2), HTML::colgroup(array('span' => 6)), HTML::thead(HTML::tr(HTML::th('Pagefilter'), HTML::th('Attribute'), HTML::th('Op'), HTML::th('Value'), HTML::th())), HTML::tbody(HTML::tr(HTML::td($pagefilter, ": "), HTML::td($attribute), HTML::td($attr_op), HTML::td($queryatt), HTML::td($nbsp, $attsubmit, $nbsp, $enhancements)))));
     return HTML($form1, $form2);
 }
Пример #8
0
 function addTableHead(&$table)
 {
     $row = HTML::tr(HTML::th(_("Name")), HTML::th(array('align' => 'right'), _("Score")));
     if ($this->debug) {
         $this->_pushDebugHeadingTDinto($row);
     }
     $table->pushContent(HTML::thead($row));
 }
Пример #9
0
 function Block_table_dl_defn($term, $defn)
 {
     $this->XmlContent();
     if (!is_array($defn)) {
         $defn = $defn->getContent();
     }
     $this->_next_tight_top = false;
     // value irrelevant - gets fixed later
     $this->_ncols = $this->_ComputeNcols($defn);
     $this->_nrows = 0;
     foreach ($defn as $item) {
         if ($this->_IsASubtable($item)) {
             $this->_addSubtable($item);
         } else {
             $this->_addToRow($item);
         }
     }
     $this->_flushRow();
     $th = HTML::th($term);
     if ($this->_nrows > 1) {
         $th->setAttr('rowspan', $this->_nrows);
     }
     $this->_setTerm($th);
 }
Пример #10
0
 function asEditableTable($type)
 {
     global $WikiTheme;
     if (!isset($this->_group)) {
         $this->_group =& $GLOBALS['request']->getGroup();
     }
     $table = HTML::table();
     $table->pushContent(HTML::tr(HTML::th(array('align' => 'left'), _("Access")), HTML::th(array('align' => 'right'), _("Group/User")), HTML::th(_("Grant")), HTML::th(_("Del/+")), HTML::th(_("Description"))));
     $allGroups = $this->_group->_specialGroups();
     foreach ($this->_group->getAllGroupsIn() as $group) {
         if (!in_array($group, $this->_group->specialGroups())) {
             $allGroups[] = $group;
         }
     }
     //array_unique(array_merge($this->_group->getAllGroupsIn(),
     $deletesrc = $WikiTheme->_findData('images/delete.png');
     $addsrc = $WikiTheme->_findData('images/add.png');
     $nbsp = HTML::raw('&nbsp;');
     foreach ($this->perm as $access => $groups) {
         //$permlist = HTML::table(array('class' => 'cal','valign' => 'top'));
         $first_only = true;
         $newperm = HTML::input(array('type' => 'checkbox', 'name' => "acl[_new_perm][{$access}]", 'value' => 1));
         $addbutton = HTML::input(array('type' => 'checkbox', 'name' => "acl[_add_group][{$access}]", 'title' => _("Add this ACL"), 'value' => 1));
         $newgroup = HTML::select(array('name' => "acl[_new_group][{$access}]", 'style' => 'text-align: right;', 'size' => 1));
         foreach ($allGroups as $groupname) {
             if (!isset($groups[$groupname])) {
                 $newgroup->pushContent(HTML::option(array('value' => $groupname), $this->groupName($groupname)));
             }
         }
         if (empty($groups)) {
             $addbutton->setAttr('checked', 'checked');
             $newperm->setAttr('checked', 'checked');
             $table->pushContent(HTML::tr(array('valign' => 'top'), HTML::td(HTML::strong($access . ":")), HTML::td($newgroup), HTML::td($nbsp, $newperm), HTML::td($nbsp, $addbutton), HTML::td(HTML::em(getAccessDescription($access)))));
         }
         foreach ($groups as $group => $bool) {
             $checkbox = HTML::input(array('type' => 'checkbox', 'name' => "acl[{$access}][{$group}]", 'title' => _("Allow / Deny"), 'value' => 1));
             if ($bool) {
                 $checkbox->setAttr('checked', 'checked');
             }
             $checkbox = HTML(HTML::input(array('type' => 'hidden', 'name' => "acl[{$access}][{$group}]", 'value' => 0)), $checkbox);
             $deletebutton = HTML::input(array('type' => 'checkbox', 'name' => "acl[_del_group][{$access}][{$group}]", 'style' => 'background: #aaa url(' . $deletesrc . ')', 'title' => _("Delete this ACL"), 'value' => 1));
             if ($first_only) {
                 $table->pushContent(HTML::tr(HTML::td(HTML::strong($access . ":")), HTML::td(array('class' => 'cal-today', 'align' => 'right'), HTML::strong($this->groupName($group))), HTML::td(array('align' => 'center'), $nbsp, $checkbox), HTML::td(array('align' => 'right', 'style' => 'background: #aaa url(' . $deletesrc . ') no-repeat'), $deletebutton), HTML::td(HTML::em(getAccessDescription($access)))));
                 $first_only = false;
             } else {
                 $table->pushContent(HTML::tr(HTML::td(), HTML::td(array('class' => 'cal-today', 'align' => 'right'), HTML::strong($this->groupName($group))), HTML::td(array('align' => 'center'), $nbsp, $checkbox), HTML::td(array('align' => 'right', 'style' => 'background: #aaa url(' . $deletesrc . ') no-repeat'), $deletebutton), HTML::td()));
             }
         }
         if (!empty($groups)) {
             $table->pushContent(HTML::tr(array('valign' => 'top'), HTML::td(array('align' => 'right'), _("add ")), HTML::td($newgroup), HTML::td(array('align' => 'center'), $nbsp, $newperm), HTML::td(array('align' => 'right', 'style' => 'background: #ccc url(' . $addsrc . ') no-repeat'), $addbutton), HTML::td(HTML::small(_("Check to add this ACL")))));
         }
     }
     if ($type == 'default') {
         $table->setAttr('style', 'border: dotted thin black; background-color:#eee;');
     } elseif ($type == 'inherited') {
         $table->setAttr('style', 'border: dotted thin black; background-color:#ddd;');
     } elseif ($type == 'page') {
         $table->setAttr('style', 'border: solid thin black; font-weight: bold;');
     }
     return $table;
 }
Пример #11
0
 function button_heading($pagelist, $colNum)
 {
     $s = HTML(HTML::raw('&nbsp;'), $this->_heading, HTML::raw('&nbsp;'));
     return HTML::th(array('align' => 'center', 'valign' => 'middle', 'class' => 'gridbutton'), $s);
 }
Пример #12
0
 function _setHeaders($row)
 {
     if (!$this->_headerSet) {
         foreach ($row as $key => $value) {
             $this->_theadrow->pushContent(HTML::th(_($key)));
         }
         $this->_headerSet = true;
     }
 }
Пример #13
0
 function run($dbi, $argstr, $request)
 {
     if (!function_exists('ldap_connect')) {
         if (!loadPhpExtension('ldap')) {
             return $this->error(_("Missing ldap extension"));
         }
     }
     $args = $this->getArgs($argstr, $request);
     extract($args);
     //include_once("lib/WikiUser/LDAP.php");
     if (!$host) {
         if (defined('LDAP_AUTH_HOST')) {
             $host = LDAP_AUTH_HOST;
             if (strstr(LDAP_AUTH_HOST, '://')) {
                 $port = null;
             }
         } else {
             $host = 'localhost';
         }
     } else {
         if (strstr($host, '://')) {
             $port = null;
         }
     }
     $html = HTML();
     if (is_null($port)) {
         $connect = ldap_connect($host);
     } else {
         $connect = ldap_connect($host, $port);
     }
     if (!$connect) {
         return $this->error(_("Failed to connect to LDAP host"));
     }
     if (!$options and defined('LDAP_AUTH_HOST') and $args['host'] == LDAP_AUTH_HOST) {
         if (!empty($GLOBALS['LDAP_SET_OPTION'])) {
             $options = $GLOBALS['LDAP_SET_OPTION'];
         }
     }
     if ($options) {
         foreach ($options as $key => $value) {
             if (!ldap_set_option($connect, $key, $value)) {
                 $this->error(_("Failed to set LDAP {$key} {$value}"));
             }
         }
     }
     // special convenience: if host = LDAP_AUTH_HOST
     // then take user and password from config.ini also
     if ($user) {
         if ($password) {
             // required for Windows Active Directory Server
             $bind = ldap_bind($connect, $user, $password);
         } else {
             $bind = ldap_bind($connect, $user);
         }
     } elseif (defined('LDAP_AUTH_HOST') and $args['host'] == LDAP_AUTH_HOST) {
         if (LDAP_AUTH_USER) {
             if (LDAP_AUTH_PASSWORD) {
                 // Windows Active Directory Server is strict
                 $r = ldap_bind($connect, LDAP_AUTH_USER, LDAP_AUTH_PASSWORD);
             } else {
                 $r = ldap_bind($connect, LDAP_AUTH_USER);
             }
         } else {
             // anonymous bind
             $bind = ldap_bind($connect);
         }
     } else {
         // other anonymous bind
         $bind = ldap_bind($connect);
     }
     if (!$bind) {
         return $this->error(_("Failed to bind LDAP host"));
     }
     if (!$basedn) {
         $basedn = LDAP_BASE_DN;
     }
     $attr_array = array("");
     if (!$attributes) {
         $res = ldap_search($connect, $basedn, $filter);
     } else {
         $attr_array = explode(" ", $attributes);
         $res = ldap_search($connect, $basedn, $filter, $attr_array);
     }
     $entries = ldap_get_entries($connect, $res);
     // If we were given attributes then we return them in the order given
     // else take all
     if (!$attributes) {
         $attr_array = array();
         for ($ii = 0; $ii < $entries[0]["count"]; $ii++) {
             $data = $entries[0][$ii];
             $attr_array[] = $data;
         }
     }
     for ($i = 0; $i < count($attr_array); $i++) {
         $attrcols[$i] = 0;
     }
     // Work out how many columns we need for each attribute. objectclass has more
     for ($i = 0; $i < $entries[0]["count"]; $i++) {
         $data = $entries[0][$i];
         $datalen = $entries[0][$data]["count"];
         if ($attrcols[$i] < $datalen) {
             $attrcols[$i] = $datalen;
         }
     }
     // Print the headers
     $row = HTML::tr();
     for ($i = 0; $i < count($attr_array); $i++) {
         // span subcolumns, like objectclass
         if ($attrcols[$i] > 1) {
             $row->pushContent(HTML::th(array('colspan' => $attrcols[$i]), $attr_array[$i]));
         } else {
             $row->pushContent(HTML::th(array(), $attr_array[$i]));
         }
     }
     $html->pushContent($row);
     // Print the data rows
     for ($currow = 0; $currow < $entries["count"]; $currow++) {
         $row = HTML::tr();
         $nc = 0;
         // columns
         for ($i = 0; $i < count($attr_array); $i++) {
             $colname = $attr_array[$i];
             $data = @$entries[$currow][$colname];
             if ($data and $data["count"] > 0) {
                 // subcolumns, e.g. for objectclass
                 for ($iii = 0; $iii < $data["count"]; $iii++) {
                     $row->pushContent(HTML::td($data[$iii]));
                     $nc++;
                 }
             } else {
                 $row->pushContent(HTML::td(""));
                 $nc++;
             }
             // Make up some blank cells if required to pad this row
             /*for ( $j=0 ; $j < ($attrcols[$ii] - $nc); $j++ ) {
                   $row->pushContent(HTML::td(""));
               }*/
         }
         $html->pushContent($row);
     }
     return HTML::table(array('cellpadding' => 1, 'cellspacing' => 1, 'border' => 1), $html);
 }
Пример #14
0
 function showTopics($request, $args)
 {
     global $WikiTheme;
     $dbi = $request->getDbh();
     $topics = $this->findBlogs($dbi, $args['pagename'], 'wikiforum');
     $html = HTML::table(array('border' => 0));
     $row = HTML::tr(HTML::th('title'), HTML::th('last post'), HTML::th('author'));
     $html->pushContent($row);
     foreach ($topics as $rev) {
         //TODO: get numposts, number of replies
         $meta = $rev->get('wikiforum');
         // format as list, not as wikiforum content
         $page = new WikiPageName($rev, $args['pagename']);
         $row = HTML::tr(HTML::td(WikiLink($page, 'if_known', $rev->get('summary'))), HTML::td($WikiTheme->formatDateTime($meta['ctime'])), HTML::td(WikiLink($meta['creator'], 'if_known')));
         $html->pushContent($row);
     }
     return $html;
 }
Пример #15
0
 function run($dbi, $argstr, &$request, $basepage)
 {
     $this->disallowed_extensions = explode("\n", "ad[ep]\nasd\nba[st]\nchm\ncmd\ncom\ncgi\ncpl\ncrt\ndll\neml\nexe\nhlp\nhta\nin[fs]\nisp\njse?\nlnk\nmd[betw]\nms[cipt]\nnws\nocx\nops\npcd\np[ir]f\nphp\npl\npy\nreg\nsc[frt]\nsh[bsm]?\nswf\nurl\nvb[esx]?\nvxd\nws[cfh]");
     //removed "\{[[:xdigit:]]{8}(?:-[[:xdigit:]]{4}){3}-[[:xdigit:]]{12}\}"
     $args = $this->getArgs($argstr, $request);
     extract($args);
     $file_dir = getUploadFilePath();
     //$url_prefix = SERVER_NAME . DATA_PATH;
     $form = HTML::form(array('action' => $request->getPostURL(), 'enctype' => 'multipart/form-data', 'method' => 'post'));
     $contents = HTML::div(array('class' => 'wikiaction'));
     $contents->pushContent(HTML::input(array('type' => 'hidden', 'name' => 'MAX_FILE_SIZE', 'value' => MAX_UPLOAD_SIZE)));
     /// MV add pv
     /// @todo: have a generic method to transmit pv
     if (!empty($_REQUEST['pv'])) {
         $contents->pushContent(HTML::input(array('type' => 'hidden', 'name' => 'pv', 'value' => $_REQUEST['pv'])));
     }
     $contents->pushContent(HTML::input(array('name' => 'userfile', 'type' => 'file', 'size' => '50')));
     $contents->pushContent(HTML::raw(" "));
     $contents->pushContent(HTML::input(array('value' => _("Upload"), 'type' => 'submit')));
     $form->pushContent($contents);
     $message = HTML();
     if ($request->isPost() and $this->only_authenticated) {
         // Make sure that the user is logged in.
         $user = $request->getUser();
         if (!$user->isAuthenticated()) {
             $message->pushContent(HTML::h2(_("ACCESS DENIED: You must log in to upload files.")), HTML::br(), HTML::br());
             $result = HTML();
             $result->pushContent($form);
             $result->pushContent($message);
             return $result;
         }
     }
     $userfile = $request->getUploadedFile('userfile');
     if ($userfile) {
         $userfile_name = $userfile->getName();
         $userfile_name = trim(basename($userfile_name));
         $userfile_tmpname = $userfile->getTmpName();
         $err_header = HTML::h2(fmt("ERROR uploading '%s': ", $userfile_name));
         /// MV add
         /// Wiki attachments
         $wa = new WikiAttachment(GROUP_ID);
         $rev = $wa->createRevision($userfile_name, $userfile->getSize(), $userfile->getType(), $userfile->getTmpName());
         if ($rev >= 0) {
             $prev = $rev + 1;
             $interwiki = new PageType_interwikimap();
             $link = $interwiki->link("Upload:{$prev}/{$userfile_name}");
             $message->pushContent(HTML::h2(_("File successfully uploaded.")));
             $message->pushContent(HTML::ul(HTML::li($link)));
             // the upload was a success and we need to mark this event in the "upload log"
             if ($logfile) {
                 $upload_log = $file_dir . basename($logfile);
                 $this->log($userfile, $upload_log, $message);
             }
             if ($autolink) {
                 require_once "lib/loadsave.php";
                 $pagehandle = $dbi->getPage($page);
                 if ($pagehandle->exists()) {
                     // don't replace default contents
                     $current = $pagehandle->getCurrentRevision();
                     $version = $current->getVersion();
                     $text = $current->getPackedContent();
                     $newtext = $text . "\n* [Upload:{$userfile_name}]";
                     $meta = $current->_data;
                     $meta['summary'] = sprintf(_("uploaded %s"), $userfile_name);
                     $pagehandle->save($newtext, $version + 1, $meta);
                 }
             }
         } else {
             $message->pushContent($err_header);
             $message->pushContent(HTML::br(), _("Uploading failed."), HTML::br());
         }
     } else {
         $message->pushContent(HTML::br(), HTML::br());
     }
     /// {{{ Codendi Specific
     // URL arguments
     if (array_key_exists('offset', $_REQUEST)) {
         $offset = $_REQUEST['offset'];
     } else {
         $offset = 0;
     }
     if (array_key_exists('limit', $_REQUEST)) {
         $limit = $_REQUEST['limit'];
     } else {
         $limit = 10;
     }
     $attchTab = HTML::table(array('border' => '1', 'width' => '100%'));
     $attchTab->pushContent(HTML::tr(HTML::th(_("Attachment")), HTML::th(_("Number of revision"))));
     $wai =& WikiAttachment::getListWithCounter(GROUP_ID, user_getid(), array('offset' => $offset, 'nb' => $limit));
     $wai->rewind();
     while ($wai->valid()) {
         $wa =& $wai->current();
         $filename = basename($wa->getFilename());
         $url = getUploadDataPath() . urlencode($filename);
         $line = HTML::tr();
         $line->pushContent(HTML::td(HTML::a(array('href' => $url), "Attach:" . $filename)));
         $line->pushContent(HTML::td($wa->count()));
         $attchTab->pushContent($line);
         $wai->next();
     }
     $attchList = HTML();
     $attchList->pushContent(HTML::hr(), HTML::h2(_("Attached files")));
     $attchList->pushContent($attchTab);
     $url = WikiURL("UpLoad");
     if (!empty($_REQUEST['pv'])) {
         $url .= '&pv=' . $_REQUEST['pv'];
     }
     $attchList->pushContent(HTML::a(array('href' => $url . '&offset=' . ($offset - $limit)), "<- Previous"));
     $attchList->pushContent(" - ");
     $attchList->pushContent(HTML::a(array('href' => $url . '&offset=' . ($offset + $limit)), "Next ->"));
     /// }}}
     //$result = HTML::div( array( 'class' => 'wikiaction' ) );
     $result = HTML();
     $result->pushContent($form);
     $result->pushContent($message);
     $result->pushContent($attchList);
     return $result;
 }
Пример #16
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));
 }
Пример #17
0
 function run($dbi, $argstr, &$request, $basepage)
 {
     $this->_args = $this->getArgs($argstr, $request);
     extract($this->_args);
     //trigger_error("1 p= $page a= $author");
     if ($page && $page == 'username') {
         //FIXME: use [username]!!!!!
         $page = $author;
     }
     //trigger_error("2 p= $page a= $author");
     if (!$page || !$author) {
         //user not signed in or no author specified
         return '';
     }
     //$pagelist = new PageList($info, $exclude);
     ///////////////////////////
     $nbsp = HTML::raw('&nbsp;');
     global $WikiTheme;
     // date & time formatting
     $table = HTML::table(array('class' => 'pagelist'));
     $thead = HTML::thead();
     $tbody = HTML::tbody();
     if (!($page == 'all')) {
         $p = $dbi->getPage($page);
         $thead->pushContent(HTML::tr(HTML::th(array('align' => 'right'), _("Version")), $includeminor ? HTML::th(_("Minor")) : "", HTML::th(_("Author")), HTML::th(_("Summary")), HTML::th(_("Modified"))));
         $allrevisions_iter = $p->getAllRevisions();
         while ($rev = $allrevisions_iter->next()) {
             $isminor = $rev->get('is_minor_edit');
             $authordoesmatch = $author == $rev->get('author');
             if ($authordoesmatch && (!$isminor || $includeminor && $isminor)) {
                 $difflink = Button(array('action' => 'diff', 'previous' => 'minor'), $rev->getversion(), $rev);
                 $tr = HTML::tr(HTML::td(array('align' => 'right'), $difflink, $nbsp), $includeminor ? HTML::td($nbsp, $isminor ? "minor" : "major", $nbsp) : "", HTML::td($nbsp, WikiLink($rev->get('author'), 'if_known'), $nbsp), HTML::td($nbsp, $rev->get('summary')), HTML::td(array('align' => 'right'), $WikiTheme->formatdatetime($rev->get('mtime'))));
                 $class = $isminor ? 'evenrow' : 'oddrow';
                 $tr->setAttr('class', $class);
                 $tbody->pushContent($tr);
                 //$pagelist->addPage($rev->getPage());
             }
         }
         $captext = fmt($includeminor ? "History of all major and minor edits by %s to page %s." : "History of all major edits by %s to page %s.", WikiLink($author, 'auto'), WikiLink($page, 'auto'));
     } else {
         //search all pages for all edits by this author
         $thead->pushContent(HTML::tr(HTML::th(_("Page Name")), HTML::th(array('align' => 'right'), _("Version")), $includeminor ? HTML::th(_("Minor")) : "", HTML::th(_("Summary")), HTML::th(_("Modified"))));
         $allpages_iter = $dbi->getAllPages($includedeleted);
         while ($p = $allpages_iter->next()) {
             $allrevisions_iter = $p->getAllRevisions();
             while ($rev = $allrevisions_iter->next()) {
                 $isminor = $rev->get('is_minor_edit');
                 $authordoesmatch = $author == $rev->get('author');
                 if ($authordoesmatch && (!$isminor || $includeminor && $isminor)) {
                     $difflink = Button(array('action' => 'diff', 'previous' => 'minor'), $rev->getversion(), $rev);
                     $tr = HTML::tr(HTML::td($nbsp, $isminor ? $rev->_pagename : WikiLink($rev->_pagename, 'auto')), HTML::td(array('align' => 'right'), $difflink, $nbsp), $includeminor ? HTML::td($nbsp, $isminor ? "minor" : "major", $nbsp) : "", HTML::td($nbsp, $rev->get('summary')), HTML::td(array('align' => 'right'), $WikiTheme->formatdatetime($rev->get('mtime')), $nbsp));
                     $class = $isminor ? 'evenrow' : 'oddrow';
                     $tr->setAttr('class', $class);
                     $tbody->pushContent($tr);
                     //$pagelist->addPage($rev->getPage());
                 }
             }
         }
         $captext = fmt($includeminor ? "History of all major and minor modifications for any page edited by %s." : "History of major modifications for any page edited by %s.", WikiLink($author, 'auto'));
     }
     $table->pushContent(HTML::caption($captext));
     $table->pushContent($thead, $tbody);
     //        if (!$noheader) {
     // total minor, major edits. if include minoredits was specified
     //        }
     return $table;
     //        if (!$noheader) {
     //            $pagelink = WikiLink($page, 'auto');
     //
     //            if ($pagelist->isEmpty())
     //                return HTML::p(fmt("No pages link to %s.", $pagelink));
     //
     //            if ($pagelist->getTotal() == 1)
     //                $pagelist->setCaption(fmt("One page links to %s:",
     //                                          $pagelink));
     //            else
     //                $pagelist->setCaption(fmt("%s pages link to %s:",
     //                                          $pagelist->getTotal(), $pagelink));
     //        }
     //
     //        return $pagelist;
 }
Пример #18
0
 function run($dbi, $argstr, &$request, $basepage)
 {
     include_once "lib/BlockParser.php";
     // MediawikiTablePlugin markup is new.
     $markup = 2.0;
     // We allow the compact Mediawiki syntax with:
     // - multiple cells on the same line (separated by "||"),
     // - multiple header cells on the same line (separated by "!!").
     $argstr = str_replace("||", "\n| ", $argstr);
     $argstr = str_replace("!!", "\n! ", $argstr);
     $lines = preg_split('/\\n/', $argstr);
     $table = HTML::table();
     // We always generate an Id for the table.
     // This is convenient for tables of class "sortable".
     // If user provides an Id, the generated Id will be overwritten below.
     $table->setAttr("id", GenerateId("MediawikiTable"));
     if (substr($lines[0], 0, 2) == "{|") {
         // Start of table
         $lines[0] = substr($lines[0], 2);
     }
     if ($lines[0][0] != '|' and $lines[0][0] != '!') {
         $line = array_shift($lines);
         $attrs = parse_attributes($line);
         foreach ($attrs as $key => $value) {
             if (in_array($key, array("id", "class", "title", "style", "bgcolor", "frame", "rules", "border", "cellspacing", "cellpadding", "summary", "align", "width"))) {
                 $table->setAttr($key, $value);
             }
         }
     }
     if (count($lines) == 1) {
         // empty table, we only have closing "|}" line
         return HTML::raw('');
     }
     foreach ($lines as $line) {
         if (substr($line, 0, 2) == "|}") {
             // End of table
             continue;
         }
         if (substr($line, 0, 2) == "|-") {
             if (isset($row)) {
                 if (isset($cell)) {
                     if (isset($content)) {
                         if (is_numeric(trim($content))) {
                             $cell->pushContent(HTML::p(array('style' => "text-align:right"), trim($content)));
                         } else {
                             $cell->pushContent(TransformText(trim($content), $markup, $basepage));
                         }
                         unset($content);
                     }
                     $row->pushContent($cell);
                     unset($cell);
                 }
                 if (isset($thead)) {
                     $thead->pushContent($row);
                     $table->pushContent($thead);
                     unset($thead);
                     $tbody = HTML::tbody();
                 } else {
                     $tbody->pushContent($row);
                 }
             }
             $row = HTML::tr();
             $attrs = parse_attributes(substr($line, 2));
             foreach ($attrs as $key => $value) {
                 if (in_array($key, array("id", "class", "title", "style", "bgcolor", "align", "valign"))) {
                     $row->setAttr($key, $value);
                 }
             }
             continue;
         }
         // Table summary
         if (substr($line, 0, 2) == "|=") {
             $line = substr($line, 2);
             $table->setAttr("summary", trim($line));
         }
         // Table caption
         if (substr($line, 0, 2) == "|+") {
             $caption = HTML::caption();
             $line = substr($line, 2);
             $pospipe = strpos($line, "|");
             $posbracket = strpos($line, "[");
             if ($pospipe !== false && ($posbracket === false || $posbracket > $pospipe)) {
                 $attrs = parse_attributes(substr($line, 0, $pospipe));
                 foreach ($attrs as $key => $value) {
                     if (in_array($key, array("id", "class", "title", "style", "align", "lang"))) {
                         $caption->setAttr($key, $value);
                     }
                 }
                 $line = substr($line, $pospipe + 1);
             }
             $caption->pushContent(trim($line));
             $table->pushContent($caption);
         }
         if ((substr($line, 0, 1) == "|" or substr($line, 0, 1) == "!") and isset($row)) {
             if (isset($cell)) {
                 if (isset($content)) {
                     if (is_numeric(trim($content))) {
                         $cell->pushContent(HTML::p(array('style' => "text-align:right"), trim($content)));
                     } else {
                         $cell->pushContent(TransformText(trim($content), $markup, $basepage));
                     }
                     unset($content);
                 }
                 $row->pushContent($cell);
             }
             if (substr($line, 0, 1) == "!") {
                 $cell = HTML::th();
                 // Header
                 $thead = HTML::thead();
             } else {
                 $cell = HTML::td();
                 if (!isset($tbody)) {
                     $tbody = HTML::tbody();
                 }
             }
             $line = substr($line, 1);
             // If there is a "|" in the line, the start of line
             // (before the "|") is made of attributes.
             // The end of the line (after the "|") is the cell content
             // This is not true if the pipe is inside [], {{}} or {{{}}}
             // | [foo|bar]
             // The following cases must work:
             // | foo
             // | [foo|bar]
             // | class="xxx" | foo
             // | class="xxx" | [foo|bar]
             // | {{tmpl|arg=val}}
             // | {{image.png|alt}}
             // | {{{ xxx | yyy }}}
             $pospipe = strpos($line, "|");
             $posbracket = strpos($line, "[");
             $poscurly = strpos($line, "{");
             if ($pospipe !== false && ($posbracket === false || $posbracket > $pospipe) && ($poscurly === false || $poscurly > $pospipe)) {
                 $attrs = parse_attributes(substr($line, 0, $pospipe));
                 foreach ($attrs as $key => $value) {
                     if (in_array($key, array("id", "class", "title", "style", "colspan", "rowspan", "width", "height", "bgcolor", "align", "valign"))) {
                         $cell->setAttr($key, $value);
                     }
                 }
                 $line = substr($line, $pospipe + 1);
                 if (is_numeric(trim($line))) {
                     $cell->pushContent(HTML::p(array('style' => "text-align:right"), trim($line)));
                 } else {
                     $cell->pushContent(TransformText(trim($line), $markup, $basepage));
                 }
                 continue;
             }
         }
         if (isset($row) and isset($cell)) {
             $line = str_replace("?\\>", "?>", $line);
             $line = str_replace("\\~", "~", $line);
             if (empty($content)) {
                 $content = '';
             }
             $content .= $line . "\n";
         }
     }
     if (isset($row)) {
         if (isset($cell)) {
             if (isset($content)) {
                 if (is_numeric(trim($content))) {
                     $cell->pushContent(HTML::p(array('style' => "text-align:right"), trim($content)));
                 } else {
                     $cell->pushContent(TransformText(trim($content), $markup, $basepage));
                 }
             }
             $row->pushContent($cell);
         }
         $tbody->pushContent($row);
         $table->pushContent($tbody);
     }
     return $table;
 }
Пример #19
0
 function run($dbi, $argstr, &$request, $basepage)
 {
     // don't parse argstr for name=value pairs. instead we use just 'name'
     //$args = $this->getArgs($argstr, $request);
     $this->_dbi =& $dbi;
     $args['seperator'] = ' ';
     $availableargs = array('appname' => create_function('', "return 'PhpWiki';"), 'version' => create_function('', "return sprintf('%s', PHPWIKI_VERSION);"), 'LANG' => create_function('', 'return $GLOBALS["LANG"];'), 'LC_ALL' => create_function('', 'return setlocale(LC_ALL, 0);'), 'current_language' => create_function('', 'return $GLOBALS["LANG"];'), 'system_language' => create_function('', 'return DEFAULT_LANGUAGE;'), 'current_theme' => create_function('', 'return $GLOBALS["WikiTheme"]->_name;'), 'system_theme' => create_function('', 'return THEME;'), '' => create_function('', "return 'dummy';"));
     // split the argument string by any number of commas or space
     // characters, which include " ", \r, \t, \n and \f
     $allargs = preg_split("/[\\s,]+/", $argstr, -1, PREG_SPLIT_NO_EMPTY);
     if (in_array('all', $allargs) || in_array('table', $allargs)) {
         $allargs = array('appname' => _("Application name"), 'version' => _("PhpWiki engine version"), 'database' => _("Database"), 'cachestats' => _("Cache statistics"), 'pagestats' => _("Page statistics"), 'userstats' => _("User statistics"), 'hitstats' => _("Hit statistics"), 'discspace' => _("Harddisc usage"), 'expireparams' => _("Expiry parameters"), 'wikinameregexp' => _("Wikiname regexp"), 'allowedprotocols' => _("Allowed protocols"), 'inlineimages' => _("Inline images"), 'available_plugins' => _("Available plugins"), 'supported_languages' => _("Supported languages"), 'supported_themes' => _("Supported themes"), '' => "");
         $table = HTML::table(array('class' => 'bordered'));
         foreach ($allargs as $arg => $desc) {
             if (!$arg) {
                 continue;
             }
             if (!$desc) {
                 $desc = _($arg);
             }
             $table->pushContent(HTML::tr(HTML::th(array('style' => "white-space:nowrap"), $desc), HTML::td(HTML($this->call($arg, $availableargs)))));
         }
         return $table;
     } else {
         $output = '';
         foreach ($allargs as $arg) {
             $o = $this->call($arg, $availableargs);
             if (is_object($o)) {
                 return $o;
             } else {
                 $output .= $o . $args['seperator'];
             }
         }
         // if more than one arg, remove the trailing seperator
         if ($output) {
             $output = substr($output, 0, -strlen($args['seperator']));
         }
         return HTML($output);
     }
 }