function run($dbi, $argstr, &$request, $basepage) { $args = $this->getArgs($argstr, $request); extract($args); include_once "lib/imdb.php"; $imdb = new imdb(); if (method_exists($imdb, $query)) { $SqlResult = $imdb->{$query}($title ? $title : $name); } else { $SqlResult = array(); } // if ($limit) ; // TODO: fill paging vars (see PageList) if ($ordered) { $html = HTML::ol(array('class' => 'sqlresult')); foreach ($SqlResult as $row) { $html->pushContent(HTML::li(array('class' => $i++ % 2 ? 'evenrow' : 'oddrow'), $row[0])); } } else { $html = HTML::table(array('class' => 'sqlresult')); $i = 0; foreach ($SqlResult as $row) { $tr = HTML::tr(array('class' => $i++ % 2 ? 'evenrow' : 'oddrow')); foreach ($row as $col) { $tr->pushContent(HTML::td($col)); } $html->pushContent($tr); } } // if ($limit) ; // do paging via pagelink template return $html; }
function showForm(&$dbi, &$request, $args, $allrelations) { global $WikiTheme; $action = $request->getPostURL(); $hiddenfield = HiddenInputs($request->getArgs(), '', array('action', 'page', 's')); $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'), ''); $help = Button('submit:semsearch[help]', "?", false); $svalues = empty($allrelations) ? "" : join("','", $allrelations); $reldef = JavaScript("var semsearch_relations = new Array('" . $svalues . "')"); $querybox = HTML::textarea(array('name' => 's', 'title' => _("Enter a valid query expression"), 'rows' => 4, 'acdropdown' => 'true', 'autocomplete_complete' => 'true', 'autocomplete_assoc' => 'false', 'autocomplete_matchsubstring' => 'true', 'autocomplete_list' => 'array:semsearch_relations'), $args['s']); $submit = Button('submit:semsearch[relations]', _("Search"), false, array('title' => 'Move to help page. No seperate window')); $instructions = _("Search in all specified pages for the expression."); $form = HTML::form(array('action' => $action, 'method' => 'post', 'accept-charset' => $GLOBALS['charset']), $reldef, $hiddenfield, HiddenInputs(array('attribute' => '')), $instructions, HTML::br(), HTML::table(array('border' => '0', 'width' => '100%'), HTML::tr(HTML::td(_("Pagename(s): "), $pagefilter), HTML::td(array('align' => 'right'), $help)), HTML::tr(HTML::td(array('colspan' => 2), $querybox))), HTML::br(), HTML::div(array('align' => 'center'), $submit)); return $form; }
function PageInfoRow($label, $rev, &$request) { global $WikiTheme, $WikiNameRegexp; $row = HTML::tr(HTML::td(array('align' => 'right'), $label)); if ($rev) { $author = $rev->get('author'); $dbi = $request->getDbh(); $iswikipage = isWikiWord($author) && $dbi->isWikiPage($author); $authorlink = $iswikipage ? WikiLink($author) : $author; $linked_version = WikiLink($rev, 'existing', $rev->getVersion()); $row->pushContent(HTML::td(fmt("version %s", $linked_version)), HTML::td($WikiTheme->getLastModifiedMessage($rev, false)), HTML::td(fmt("by %s", $authorlink))); } else { $row->pushContent(HTML::td(array('colspan' => '3'), _("None"))); } return $row; }
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; } }
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(' '); 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; }
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; }
function _lines($lines, $class, $prefix = false, $elem = false) { if (!$prefix) { $prefix = HTML::raw(' '); } $prefix = HTML::td(array('class' => 'prefix', 'width' => "1%"), $prefix); foreach ($lines as $line) { if (!trim($line)) { $line = HTML::raw(' '); } elseif ($elem) { $line = new HtmlElement($elem, $line); } $this->_block->pushContent(HTML::tr(array('valign' => 'top'), $prefix, HTML::td(array('class' => $class), $line))); } }
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; }
function _upgrade_db_init(&$dbh) { global $request, $DBParams, $DBAuthParams; if (!in_array($DBParams['dbtype'], array('SQL', 'ADODB', 'PDO'))) { return; } if (DBADMIN_USER) { // if need to connect as the root user, for CREATE and ALTER privileges $AdminParams = $DBParams; if ($DBParams['dbtype'] == 'SQL') { $dsn = DB::parseDSN($AdminParams['dsn']); } else { // ADODB or PDO $dsn = parseDSN($AdminParams['dsn']); } $AdminParams['dsn'] = sprintf("%s://%s:%s@%s/%s", $dsn['phptype'], DBADMIN_USER, DBADMIN_PASSWD, $dsn['hostspec'], $dsn['database']); if (DEBUG & _DEBUG_SQL and $DBParams['dbtype'] == 'PDO') { echo "<br>\nDBParams['dsn']: '", $DBParams['dsn'], "'"; echo "<br>\ndsn: '", print_r($dsn), "'"; echo "<br>\nAdminParams['dsn']: '", $AdminParams['dsn'], "'"; } $dbh = WikiDB::open($AdminParams); } elseif ($dbadmin = $request->getArg('dbadmin')) { if (empty($dbadmin['user']) or isset($dbadmin['cancel'])) { $dbh =& $request->_dbi; } else { $AdminParams = $DBParams; if ($DBParams['dbtype'] == 'SQL') { $dsn = DB::parseDSN($AdminParams['dsn']); } else { $dsn = parseDSN($AdminParams['dsn']); } $AdminParams['dsn'] = sprintf("%s://%s:%s@%s/%s", $dsn['phptype'], $dbadmin['user'], $dbadmin['passwd'], $dsn['hostspec'], $dsn['database']); $dbh = WikiDB::open($AdminParams); } } else { // Check if the privileges are enough. Need CREATE and ALTER perms. // And on windows: SELECT FROM mysql, possibly: UPDATE mysql. $form = HTML::form(array("method" => "post", "action" => $request->getPostURL(), "accept-charset" => $GLOBALS['charset']), HTML::p(_("Upgrade requires database privileges to CREATE and ALTER the phpwiki database."), HTML::br(), _("And on windows at least the privilege to SELECT FROM mysql, and possibly UPDATE mysql")), HiddenInputs(array('action' => 'upgrade')), HTML::table(array("cellspacing" => 4), HTML::tr(HTML::td(array('align' => 'right'), _("DB admin user:"******"dbadmin[user]", 'size' => 12, 'maxlength' => 256, 'value' => 'root')))), HTML::tr(HTML::td(array('align' => 'right'), _("DB admin password:"******"dbadmin[passwd]", 'type' => 'password', 'size' => 12, 'maxlength' => 256)))), HTML::tr(HTML::td(array('align' => 'center', 'colspan' => 2), Button("submit:", _("Submit"), 'wikiaction'), HTML::raw(' '), Button("submit:dbadmin[cancel]", _("Cancel"), 'button'))))); $form->printXml(); echo "</div><!-- content -->\n"; echo asXML(Template("bottom")); echo "</body></html>\n"; $request->finish(); exit; } }
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; }
function _generateTableBody(&$info, &$dbi, &$request, &$table) { $plugin_dir = 'lib/plugin'; if (defined('PHPWIKI_DIR')) { $plugin_dir = PHPWIKI_DIR . "/{$plugin_dir}"; } $pd = new fileSet($plugin_dir, '*.php'); $plugins = $pd->getFiles(); unset($pd); sort($plugins); // table body $tbody = HTML::tbody(); $row_no = 0; $w = new WikiPluginLoader(); foreach ($plugins as $pluginName) { // instantiate a plugin $pluginName = str_replace(".php", "", $pluginName); $temppluginclass = "<? plugin {$pluginName} ?>"; // hackish $p = $w->getPlugin($pluginName, false); // second arg? // trap php files which aren't WikiPlugin~s if (!strtolower(substr(get_parent_class($p), 0, 10)) == 'wikiplugin') { // Security: Hide names of extraneous files within // plugin dir from non-admins. if ($request->_user->isAdmin()) { trigger_error(sprintf(_("%s does not appear to be a WikiPlugin."), $pluginName . ".php")); } continue; // skip this non WikiPlugin file } $desc = $p->getDescription(); $ver = $p->getVersion(); $arguments = $p->getArgumentsDescription(); unset($p); //done querying plugin object, release from memory // This section was largely improved by Pierrick Meignen: // make a link if an actionpage exists $pluginNamelink = $pluginName; $pluginDocPageName = $pluginName . "Plugin"; $pluginDocPageNamelink = false; $localizedPluginName = ''; $localizedPluginDocPageName = ''; if ($GLOBALS['LANG'] != "en") { if (_($pluginName) != $pluginName) { $localizedPluginName = _($pluginName); } if ($localizedPluginName && $dbi->isWikiPage($localizedPluginName)) { $pluginDocPageNamelink = WikiLink($localizedPluginName, 'if_known'); } if (_($pluginDocPageName) != $pluginDocPageName) { $localizedPluginDocPageName = _($pluginDocPageName); } if ($localizedPluginDocPageName && $dbi->isWikiPage($localizedPluginDocPageName)) { $pluginDocPageNamelink = WikiLink($localizedPluginDocPageName, 'if_known'); } } else { $pluginNamelink = WikiLink($pluginName, 'if_known'); if ($dbi->isWikiPage($pluginDocPageName)) { $pluginDocPageNamelink = WikiLink($pluginDocPageName, 'if_known'); } } // highlight alternate rows $row_no++; $group = (int) ($row_no / 1); //_group_rows $class = $group % 2 ? 'evenrow' : 'oddrow'; // generate table row $tr = HTML::tr(array('class' => $class)); if ($pluginDocPageNamelink) { // plugin has a description page 'PluginName' . 'Plugin' $tr->pushContent(HTML::td($pluginNamelink, HTML::br(), $pluginDocPageNamelink)); $pluginDocPageNamelink = false; } else { // plugin just has an actionpage $tr->pushContent(HTML::td($pluginNamelink)); } $tr->pushContent(HTML::td($ver), HTML::td($desc)); if ($info == 'args') { // add Arguments column $style = array('style' => 'font-family:monospace;font-size:smaller'); $tr->pushContent(HTML::td($style, $arguments)); } $tbody->pushContent($tr); } $table->pushContent($tbody); }
function run($dbi, $argstr, &$request, $basepage) { $this->args = $this->getArgs($argstr, $request); $args =& $this->args; $this->_links = array(); $now = localtime(time() + 3600 * $request->getPref('timeOffset'), 1); foreach (array('month' => $now['tm_mon'] + 1, 'year' => $now['tm_year'] + 1900) as $param => $dflt) { if (!($args[$param] = intval($args[$param]))) { $args[$param] = $dflt; } } $time = mktime(12, 0, 0, $args['month'] + $args['month_offset'], 1, $args['year']); $colnum = $args['display_weeknum'] ? 8 : 7; $cal = HTML::table(array('cellspacing' => 0, 'cellpadding' => 2, 'class' => 'cal'), HTML::thead($this->__header($request->getArg('pagename'), $time), $this->__daynames($args['start_wday']))); $t = localtime($time, 1); if ($now['tm_year'] == $t['tm_year'] && $now['tm_mon'] == $t['tm_mon']) { $this->_today = $now['tm_mday']; } else { $this->_today = false; } $tbody = HTML::tbody(); $row = HTML::tr(); if ($args['display_weeknum']) { $row->pushContent(HTML::td(array('class' => 'cal-weeknum'), (int) strftime("%U", $time) + 1)); } // %U problem. starts with 0 $col = (7 + $t['tm_wday'] - $args['start_wday']) % 7; if ($col > 0) { $row->pushContent(HTML::td(array('colspan' => $col))); } $done = false; while (!$done) { $row->pushContent($this->__date($dbi, $time)); if (++$col % 7 == 0) { $tbody->pushContent($row); $col = 0; $row = HTML::tr(); } $time += SECONDS_PER_DAY; $t = localtime($time, 1); $done = $t['tm_mday'] == 1; if (!$col and !$done and $args['display_weeknum']) { $row->pushContent(HTML::td(array('class' => 'cal-weeknum'), (int) strftime("%U", $time) + 1)); } // starts with 0 } if ($row->getContent()) { $row->pushContent(HTML::td(array('colspan' => (42 - $col) % 7))); $tbody->pushContent($row); } $cal->pushContent($tbody); return $cal; }
function run($dbi, $argstr, &$request, $basepage) { /* ignore fatal on loading */ /* global $ErrorManager; $ErrorManager->pushErrorHandler(new WikiMethodCb($this,'_error_handler')); */ // Require the XML_FOAF_Parser class. This is a pear library not included with phpwiki. // see doc/README.foaf if (findFile('XML/FOAF/Parser.php', 'missing_ok')) { require_once 'XML/FOAF/Parser.php'; } //$ErrorManager->popErrorHandler(); if (!class_exists('XML_FOAF_Parser')) { return $this->error(_("required pear library XML/FOAF/Parser.php not found in include_path")); } extract($this->getArgs($argstr, $request)); // Get our FOAF File from the foaf plugin argument or $_GET['foaf'] if (empty($foaf)) { $foaf = $request->getArg('foaf'); } $chooser = HTML::form(array('method' => 'get', 'action' => $request->getURLtoSelf()), HTML::h4(_("FOAF File URI")), HTML::input(array('id' => 'foaf', 'name' => 'foaf', 'type' => 'text', 'size' => '80', 'value' => $foaf)), HTML::br(), HTML::input(array('id' => 'pretty', 'name' => 'pretty', 'type' => 'radio', 'checked' => 'checked'), _("Pretty HTML")), HTML::input(array('id' => 'original', 'name' => 'original', 'type' => 'radio'), _("Original URL (Redirect)")), HTML::br(), HTML::input(array('type' => 'submit', 'value' => _("Parse FOAF")))); if (empty($foaf)) { return $chooser; } else { //Error Checking if (substr($foaf, 0, 7) != "http://") { return $this->error(_("foaf must be a URI starting with http://")); } // Start of output if (!empty($original)) { $request->redirect($foaf); } else { $foaffile = url_get_contents($foaf); if (!$foaffile) { //TODO: get errormsg return HTML(HTML::p("Resource isn't available: Something went wrong, probably a 404!")); } // Create new Parser object $parser = new XML_FOAF_Parser(); // Parser FOAF into $foaffile $parser->parseFromMem($foaffile); $a = $parser->toArray(); $html = HTML(HTML::h1(@$a[0]["name"]), HTML::table(HTML::thead(), HTML::tbody(@$a[0]["title"] ? HTML::tr(HTML::td(_("Title")), HTML::td($a[0]["title"])) : null, @$a[0]["homepage"][0] ? $this->iterateHTML($a[0], "homepage", $a["dc"]) : null, @$a[0]["weblog"][0] ? $this->iterateHTML($a[0], "weblog", $a["dc"]) : null, HTML::tr(HTML::td("Full Name"), @$a[0]["name"][0] ? HTML::td(@$a[0]["name"]) : null), @$a[0]["nick"][0] ? $this->iterateHTML($a[0], "nick", $a["dc"]) : null, @$a[0]["mboxsha1sum"][0] ? $this->iterateHTML($a[0], "mboxsha1sum", $a["dc"]) : null, @$a[0]["depiction"][0] ? $this->iterateHTML($a[0], "depiction", $a["dc"]) : null, @$a[0]["seealso"][0] ? $this->iterateHTML($a[0], "seealso", $a["dc"]) : null, HTML::tr(HTML::td("Source"), HTML::td(HTML::a(array('href' => @$foaf), "RDF")))))); if (DEBUG) { $html->pushContent(HTML::hr(), $chooser); } return $html; } } }
function _do_email_verification(&$request, &$args) { $dbi = $request->getDbh(); $pagelist = new PageList('pagename', 0, $args); //$args['return_url'] = 'action=email-verification-verified'; $email = new _PageList_Column_email('email', _("E-Mail"), 'left'); $emailVerified = new _PageList_Column_emailVerified('emailVerified', _("Verification Status"), 'center'); $pagelist->_columns[] = $email; $pagelist->_columns[] = $emailVerified; //This is the best method to find all users (Db and PersonalPage) $current_user = $request->_user; if (empty($args['verify'])) { $group = $request->getGroup(); $allusers = $group->_allUsers(); } else { $allusers = array_keys($args['user']); } foreach ($allusers as $username) { if (ENABLE_USER_NEW) { $user = WikiUser($username); } else { $user = new WikiUser($request, $username); } $prefs = $user->getPreferences(); if ($prefs->get('email')) { if (!$prefs->get('userid')) { $prefs->set('userid', $username); } if (!empty($pagelist->_rows)) { $group = (int) (count($pagelist->_rows) / $pagelist->_group_rows); } else { $group = 0; } $class = $group % 2 ? 'oddrow' : 'evenrow'; $row = HTML::tr(array('class' => $class)); $page_handle = $dbi->getPage($username); $row->pushContent($pagelist->_columns[0]->format($pagelist, $page_handle, $page_handle)); $row->pushContent($email->format($pagelist, $prefs, $page_handle)); if (!empty($args['verify'])) { $prefs->_prefs['email']->set('emailVerified', empty($args['verified'][$username]) ? 0 : 2); $user->setPreferences($prefs); } $row->pushContent($emailVerified->format($pagelist, $prefs, $args['verify'])); $pagelist->_rows[] = $row; } } $request->_user = $current_user; if (!empty($args['verify'])) { return HTML($pagelist->_generateTable(false)); } else { $args['verify'] = 1; $args['return_url'] = $request->getURLtoSelf(); return HTML::form(array('action' => $request->getPostURL(), 'method' => 'post'), HiddenInputs($args, 'wikiadminutils'), HiddenInputs(array('require_authority_for_post' => WIKIAUTH_ADMIN)), HiddenInputs($request->getArgs()), $pagelist->_generateTable(false), HTML::p(Button('submit:', _("Change Verification Status"), 'wikiadmin'), HTML::Raw(' '), Button('cancel', _("Cancel")))); } }
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; }
function run($dbi, $argstr, &$request, $basepage) { global $DBParams; //$request->setArg('nocache','1'); extract($this->getArgs($argstr, $request)); if (!$alias) { return $this->error(_("No DSN alias for SqlResult.ini specified")); } $sql = $this->_sql; // apply custom filters if ($where and strstr($sql, "%%where%%")) { $sql = str_replace("%%where%%", $where, $sql); } // TODO: use a SQL construction library? if ($limit) { $pagelist = new PageList(); $limit = $pagelist->limit($limit); if (strstr($sql, "%%limit%%")) { $sql = str_replace("%%limit%%", $limit, $sql); } else { if (strstr($sql, "LIMIT")) { $sql = preg_replace("/LIMIT\\s+[\\d,]+\\s+/m", "LIMIT " . $limit . " ", $sql); } } } if (strstr($sql, "%%sortby%%")) { if (!$sortby) { $sql = preg_replace("/ORDER BY .*%%sortby%%\\s/m", "", $sql); } else { $sql = str_replace("%%sortby%%", $sortby, $sql); } } elseif (PageList::sortby($sortby, 'db')) { // add sorting: support paging sortby links if (preg_match("/\\sORDER\\s/", $sql)) { $sql = preg_replace("/ORDER BY\\s\\S+\\s/m", "ORDER BY " . PageList::sortby($sortby, 'db'), $sql); } else { $sql .= " ORDER BY " . PageList::sortby($sortby, 'db'); } } $inidsn = $this->getDsn($alias); if (!$inidsn) { return $this->error(sprintf(_("No DSN for alias %s in SqlResult.ini found"), $alias)); } // adodb or pear? adodb as default, since we distribute per default it. // for pear there may be overrides. // TODO: native PDO support (for now we use ADODB) if ($DBParams['dbtype'] == 'SQL') { $dbh = DB::connect($inidsn); $all = $dbh->getAll($sql); if (DB::isError($all)) { return $this->error($all->getMessage() . ' ' . $all->userinfo); } } else { // unless PearDB use the included ADODB, regardless if dba, file or PDO, ... if ($DBParams['dbtype'] != 'ADODB') { // require_once('lib/WikiDB/adodb/adodb-errorhandler.inc.php'); require_once 'lib/WikiDB/adodb/adodb.inc.php'; } $parsed = parseDSN($inidsn); $dbh =& ADONewConnection($parsed['phptype']); $conn = $dbh->Connect($parsed['hostspec'], $parsed['username'], $parsed['password'], $parsed['database']); if (!$conn) { return $this->error($dbh->errorMsg()); } $GLOBALS['ADODB_FETCH_MODE'] = ADODB_FETCH_ASSOC; $dbh->SetFetchMode(ADODB_FETCH_ASSOC); $all = $dbh->getAll($sql); $GLOBALS['ADODB_FETCH_MODE'] = ADODB_FETCH_NUM; $dbh->SetFetchMode(ADODB_FETCH_NUM); if (!$all) { return $this->error($dbh->errorMsg()); } } $args = array(); if ($limit) { // fill paging vars (see PageList) $args = $pagelist->pagingTokens(count($all), count($all[0]), $limit); if (!$args) { $args = array(); } } if ($template) { $args = array_merge(array('SqlResult' => $all, 'ordered' => $ordered, 'where' => $where, 'sortby' => $sortby, 'limit' => $limit), $args); // paging params override given params return Template($template, $args); } else { if ($ordered) { $html = HTML::ol(array('class' => 'sqlresult')); if ($all) { foreach ($all as $row) { $html->pushContent(HTML::li(array('class' => $i++ % 2 ? 'evenrow' : 'oddrow'), $row[0])); } } } else { $html = HTML::table(array('class' => 'sqlresult')); $i = 0; if ($all) { foreach ($all as $row) { $tr = HTML::tr(array('class' => $i++ % 2 ? 'evenrow' : 'oddrow')); if ($row) { foreach ($row as $col) { $tr->pushContent(HTML::td($col)); } } $html->pushContent($tr); } } } } // do paging via pagelink template if (!empty($args['NUMPAGES'])) { $paging = Template("pagelink", $args); $html = $table->pushContent(HTML::thead($paging), HTML::tbody($html), HTML::tfoot($paging)); } if (0 and DEBUG) { // test deferred error/warning/notice collapsing trigger_error("test notice", E_USER_NOTICE); trigger_error("test warning", E_USER_WARNING); } return $html; }
function run($dbi, $argstr, &$request, $basepage) { global $WikiTheme; $args = $this->getArgs($argstr, $request); extract($args); if ($since) { $since = strtotime($since); } if ($month) { $since = strtotime($month); $since = mktime(0, 0, 0, date("m", $since), 1, date("Y", $since)); $until = mktime(23, 59, 59, date("m", $since) + 1, 0, date("Y", $since)); } else { $until = 0; } $iter = $dbi->getAllPages(false, '-mtime'); $pages = array(); while ($page = $iter->next()) { $pagename = $page->getName(); if (!$page->exists()) { continue; } $rev = $page->getRevision(1, false); $date = $rev->get('mtime'); //$author = $rev->get('author_id'); $author = $page->getOwner(); if (defined('DEBUG') && DEBUG && $debug) { echo "<i>{$pagename}, ", strftime("%Y-%m-%d %h:%m:%s", $date), ", {$author}</i><br />\n"; } if ($userid and !preg_match("/" . $userid . "/", $author)) { continue; } if ($since and $date < $since) { continue; } if ($until and $date > $until) { continue; } if (!$comments and preg_match("/\\/Comment/", $pagename)) { continue; } $monthnum = strftime("%Y%m", $date); if (!isset($pages[$monthnum])) { $pages[$monthnum] = array('author' => array(), 'month' => strftime("%B, %Y", $date)); } if (!isset($pages[$monthnum]['author'][$author])) { $pages[$monthnum]['author'][$author] = array('count' => 0, 'pages' => array()); } $pages[$monthnum]['author'][$author]['count']++; $pages[$monthnum]['author'][$author]['pages'][] = $pagename; } $iter->free(); $html = HTML::table(HTML::col(array('span' => 2, 'align' => 'left'))); $nbsp = HTML::raw(' '); krsort($pages); foreach ($pages as $monthname => $parr) { $html->pushContent(HTML::tr(HTML::td(array('colspan' => 2), HTML::strong($parr['month'])))); uasort($parr['author'], 'cmp_by_count'); foreach ($parr['author'] as $user => $authorarr) { $count = $authorarr['count']; $id = preg_replace("/ /", "_", 'pages-' . $monthname . '-' . $user); $html->pushContent(HTML::tr(HTML::td($nbsp, $nbsp, HTML::img(array('id' => "{$id}-img", 'src' => $WikiTheme->_findData("images/folderArrowClosed.png"), 'onclick' => "showHideFolder('{$id}')", 'alt' => _("Click to hide/show"), 'title' => _("Click to hide/show"))), $nbsp, $user), HTML::td($count))); if ($links) { $pagelist = HTML(); foreach ($authorarr['pages'] as $p) { $pagelist->pushContent(WikiLink($p), ', '); } } else { $pagelist = join(', ', $authorarr['pages']); } $html->pushContent(HTML::tr(array('id' => $id . '-body', 'style' => 'display:none; background-color: #eee;'), HTML::td(array('colspan' => 2, 'style' => 'font-size:smaller'), $pagelist))); } } return $html; }
function run($dbi, $argstr, &$request, $basepage) { // When 'phpweather/phpweather.php' is not installed then // PHPWEATHER_BASE_DIR will be undefined. if (!defined('PHPWEATHER_BASE_DIR')) { return $this->error(_("You have to define PHPWEATHER_BASE_DIR before use. (config/config.ini)")); } //early return require_once PHPWEATHER_BASE_DIR . '/output/pw_images.php'; require_once PHPWEATHER_BASE_DIR . '/pw_utilities.php'; extract($this->getArgs($argstr, $request)); $html = HTML(); $w = new phpweather(); // Our weather object if (!empty($icao)) { /* We assign the ICAO to the weather object: */ $w->set_icao($icao); if (!$w->get_country_code()) { /* The country code couldn't be resolved, so we * shouldn't use the ICAO: */ trigger_error(sprintf(_("The ICAO '%s' wasn't recognized."), $icao), E_USER_NOTICE); $icao = ''; } } if (!empty($icao)) { /* We check and correct the language if necessary: */ //if (!in_array($language, array_keys($w->get_languages('text')))) { if (!in_array($language, array_keys(get_languages('text')))) { trigger_error(sprintf(_("%s does not know about the language '%s', using 'en' instead."), $this->getName(), $language), E_USER_NOTICE); $language = 'en'; } $class = "pw_text_{$language}"; require_once PHPWEATHER_BASE_DIR . "/output/{$class}.php"; $t = new $class($w); $t->set_pref_units($units); $i = new pw_images($w); $i_temp = HTML::img(array('src' => $i->get_temp_image())); $i_wind = HTML::img(array('src' => $i->get_winddir_image())); $i_sky = HTML::img(array('src' => $i->get_sky_image())); $m = $t->print_pretty(); $m_td = HTML::td(HTML::p(new RawXml($m))); $i_tr = HTML::tr(); $i_tr->pushContent(HTML::td($i_temp)); $i_tr->pushContent(HTML::td($i_wind)); $i_table = HTML::table($i_tr); $i_table->pushContent(HTML::tr(HTML::td(array('colspan' => '2'), $i_sky))); $tr = HTML::tr(); $tr->pushContent($m_td); $tr->pushContent(HTML::td($i_table)); $html->pushContent(HTML::table($tr)); } /* We make a menu if asked to, or if $icao is empty: */ if ($menu || empty($icao)) { $form_arg = array('action' => $request->getURLtoSelf(), 'method' => 'get'); /* The country box is always part of the menu: */ $p1 = HTML::p(new RawXml(get_countries_select($w, $cc))); /* We want to save the language: */ $p1->pushContent(HTML::input(array('type' => 'hidden', 'name' => 'language', 'value' => $language))); /* And also the ICAO: */ $p1->pushContent(HTML::input(array('type' => 'hidden', 'name' => 'icao', 'value' => $icao))); $caption = empty($cc) ? _("Submit country") : _("Change country"); $p1->pushContent(HTML::input(array('type' => 'submit', 'value' => $caption))); $html->pushContent(HTML::form($form_arg, $p1)); if (!empty($cc)) { /* We have selected a country, now display a list with * the available stations in that country: */ $p2 = HTML::p(); /* We need the country code after the form is submitted: */ $p2->pushContent(HTML::input(array('type' => 'hidden', 'name' => 'cc', 'value' => $cc))); $p2->pushContent(new RawXml(get_stations_select($w, $cc, $icao))); $p2->pushContent(new RawXml(get_languages_select($language))); $p2->pushContent(HTML::input(array('type' => 'submit', 'value' => _("Submit location")))); $html->pushContent(HTML::form($form_arg, $p2)); } } return $html; }
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(' '); global $WikiTheme; // date & time formatting if (!($page == 'all')) { $p = $dbi->getPage($page); $t = HTML::table(array('class' => 'pagelist', 'style' => 'font-size:smaller')); $th = HTML::thead(); $tb = HTML::tbody(); $th->pushContent(HTML::tr(HTML::td(array('align' => 'right'), _("Version")), $includeminor ? HTML::td(_("Minor")) : "", HTML::td(_("Author")), HTML::td(_("Summary")), HTML::td(_("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); $tb->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')); $t->pushContent(HTML::caption($captext)); $t->pushContent($th, $tb); } else { //search all pages for all edits by this author ///////////////////////////////////////////////////////////// $t = HTML::table(array('class' => 'pagelist', 'style' => 'font-size:smaller')); $th = HTML::thead(); $tb = HTML::tbody(); $th->pushContent(HTML::tr(HTML::td(_("Page Name")), HTML::td(array('align' => 'right'), _("Version")), $includeminor ? HTML::td(_("Minor")) : "", HTML::td(_("Summary")), HTML::td(_("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); $tb->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')); $t->pushContent(HTML::caption($captext)); $t->pushContent($th, $tb); } // if (!$noheader) { // total minor, major edits. if include minoredits was specified // } return $t; // 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; }
function _showhash($heading, $hash, $prefix = '') { $rows = array(); if ($heading) { $rows[] = HTML::tr(array('bgcolor' => '#ffcccc', 'style' => 'color:#000000'), HTML::td(array('colspan' => 2, 'style' => 'color:#000000'), $heading)); } if (!is_array($hash)) { return array(); } ksort($hash); foreach ($hash as $key => $val) { if ($this->chunk_split and is_string($val)) { $val = chunk_split($val); } $rows[] = HTML::tr(HTML::td(array('align' => 'right', 'bgcolor' => '#cccccc', 'style' => 'color:#000000'), HTML(HTML::raw(' '), $key, HTML::raw(' '))), HTML::td(array('bgcolor' => '#ffffff', 'style' => 'color:#000000'), $this->_showvalue($key, $val, $prefix))); } return $rows; }
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); } }
function run($dbi, $argstr, &$request, $basepage) { extract($this->getArgs($argstr, $request)); $attributes = $attrib ? explode(",", $attrib) : array(); $photos = array(); $html = HTML(); $count = 0; // check all parameters // what type do we have? if (!$src) { $showdesc = 'none'; $src = $request->getArg('pagename'); $error = $this->fromLocation($src, $photos); } else { $error = $this->fromFile($src, $photos, $url); } if ($error) { return $this->error($error); } if ($numcols < 1) { $numcols = 1; } if ($align != 'left' && $align != 'center' && $align != 'right') { $align = 'center'; } if (count($photos) == 0) { return; } if (in_array("sort", $attributes)) { sort($photos); } if ($p) { $mode = "normal"; } if ($mode == "column") { $mode = "normal"; $numcols = "1"; } // set some fixed properties for each $mode if ($mode == 'thumbs' || $mode == 'tiles') { $attributes = array_merge($attributes, "alt"); $attributes = array_merge($attributes, "nowrap"); $cellwidth = 'auto'; // else cell won't nowrap $width = 50; } elseif ($mode == 'list') { $numcols = 1; $cellwidth = "auto"; $width = 50; } elseif ($mode == 'slide') { $tableheight = 0; $cell_width = 0; $numcols = count($photos); $keep = $photos; while (list($key, $value) = each($photos)) { list($x, $y, $s, $t) = @getimagesize($value['src']); if ($height != 'auto') { $y = $this->newSize($y, $height); } if ($width != 'auto') { $y = round($y * $this->newSize($x, $width) / $x); } if ($x > $cell_width) { $cell_width = $x; } if ($y > $tableheight) { $tableheight = $y; } } $tableheight += 50; $photos = $keep; unset($x, $y, $s, $t, $key, $value, $keep); } $row = HTML(); $duration = 1000 * $duration; if ($mode == 'slide') { $row->pushContent(JavaScript("\ni = 0;\nfunction display_slides() {\n j = i - 1;\n cell0 = document.getElementsByName('wikislide' + j);\n cell = document.getElementsByName('wikislide' + i);\n if (cell0.item(0) != null)\n cell0.item(0).style.display='none';\n if (cell.item(0) != null)\n cell.item(0).style.display='block';\n i += 1;\n if (cell.item(0) == null) i = 0;\n setTimeout('display_slides()',{$duration});\n}\ndisplay_slides();")); } while (list($key, $value) = each($photos)) { if ($p && basename($value["name"]) != "{$p}") { continue; } if ($h && basename($value["name"]) == "{$h}") { $color = $hlcolor ? $hlcolor : $bgcolor; } else { $color = $bgcolor; } // $params will be used for each <img > tag $params = array('src' => $value["name"], 'src_tile' => $value["name_tile"], 'border' => "0", 'alt' => ($value["desc"] != "" and in_array("alt", $attributes)) ? $value["desc"] : basename($value["name"])); if (!@empty($value['location'])) { $params = array_merge($params, array("location" => $value['location'])); } // check description switch ($showdesc) { case 'none': $value["desc"] = ''; break; case 'name': $value["desc"] = basename($value["name"]); break; case 'desc': break; default: // 'both' if (!$value["desc"]) { $value["desc"] = basename($value["name"]); } break; } // FIXME: get getimagesize to work with names with spaces in it. // convert $value["name"] from webpath to local path $size = @getimagesize($value["name"]); // try " " => "\\ " if (!$size and !empty($value["src"])) { $size = @getimagesize($value["src"]); if (!$size) { trigger_error("Unable to getimagesize(" . $value["name"] . ")", E_USER_NOTICE); } } $newwidth = $this->newSize($size[0], $width); if ($mode == 'thumbs' || $mode == 'tiles' || $mode == 'list') { if (!empty($size[0])) { $newheight = round(50 * $size[1] / $size[0]); } else { $newheight = ''; } if ($height == 'auto') { $height = 150; } } else { $newheight = $this->newSize($size[1], $height); } if ($width != 'auto' && $newwidth > 0) { $params = array_merge($params, array("width" => $newwidth)); } if ($height != 'auto' && $newheight > 0) { $params = array_merge($params, array("height" => $newheight)); } // cell operations $cell = array('align' => "center", 'valign' => "top", 'bgcolor' => "{$color}"); if ($cellwidth != 'auto') { if ($cellwidth == 'equal') { $newcellwidth = round(100 / $numcols) . "%"; } else { if ($cellwidth == 'image') { $newcellwidth = $newwidth; } else { $newcellwidth = $cellwidth; } } $cell = array_merge($cell, array("width" => $newcellwidth)); } if (in_array("nowrap", $attributes)) { $cell = array_merge($cell, array("nowrap" => "nowrap")); } //create url to display single larger version of image on page $url = WikiURL($request->getPage(), array("p" => basename($value["name"]))) . "#" . basename($value["name"]); $b_url = WikiURL($request->getPage(), array("h" => basename($value["name"]))) . "#" . basename($value["name"]); $url_text = $link ? HTML::a(array("href" => "{$url}"), basename($value["desc"])) : basename($value["name"]); if (!$p) { if ($mode == 'normal' || $mode == 'slide') { if (!@empty($params['location'])) { $params['src'] = $params['location']; } unset($params['location'], $params['src_tile']); $url_image = $link ? HTML::a(array("id" => basename($value["name"])), HTML::a(array("href" => "{$url}"), HTML::img($params))) : HTML::img($params); } else { $keep = $params; if (!@empty($params['src_tile'])) { $params['src'] = $params['src_tile']; } unset($params['location'], $params['src_tile']); $url_image = $link ? HTML::a(array("id" => basename($value["name"])), HTML::a(array("href" => "{$url}"), ImageTile::image_tile($params))) : HTML::img($params); $params = $keep; unset($keep); } } else { if (!@empty($params['location'])) { $params['src'] = $params['location']; } unset($params['location'], $params['src_tile']); $url_image = $link ? HTML::a(array("id" => basename($value["name"])), HTML::a(array("href" => "{$b_url}"), HTML::img($params))) : HTML::img($params); } if ($mode == 'list') { $url_text = HTML::a(array("id" => basename($value["name"])), $url_text); } // here we use different modes if ($mode == 'tiles') { $row->pushContent(HTML::td($cell, HTML::table(array("cellpadding" => 1, "border" => 0), HTML::tr(HTML::td(array("valign" => "top", "rowspan" => 2), $url_image), HTML::td(array("valign" => "top", "nowrap" => 0), HTML::span(array('class' => 'boldsmall'), $url_text), HTML::br(), HTML::span(array('class' => 'gensmall'), $size[0] . " x " . $size[1] . " pixels")))))); } elseif ($mode == 'list') { $desc = $showdesc != 'none' ? $value["desc"] : ''; $row->pushContent(HTML::td(array("valign" => "top", "nowrap" => 0, "bgcolor" => $color), HTML::span(array('class' => 'boldsmall'), $url_text))); $row->pushContent(HTML::td(array("valign" => "top", "nowrap" => 0, "bgcolor" => $color), HTML::span(array('class' => 'gensmall'), $size[0] . " x " . $size[1] . " pixels"))); if ($desc != '') { $row->pushContent(HTML::td(array("valign" => "top", "nowrap" => 0, "bgcolor" => $color), HTML::span(array('class' => 'gensmall'), $desc))); } } elseif ($mode == 'thumbs') { $desc = $showdesc != 'none' ? HTML::p(HTML::a(array("href" => "{$url}"), $url_text)) : ''; $row->pushContent(HTML::td($cell, $url_image, HTML::span(array('class' => 'gensmall'), $desc))); } elseif ($mode == 'normal') { $desc = $showdesc != 'none' ? HTML::p($value["desc"]) : ''; $row->pushContent(HTML::td($cell, $url_image, HTML::span(array('class' => 'gensmall'), $desc))); } elseif ($mode == 'slide') { if ($newwidth == 'auto' || !$newwidth) { $newwidth = $this->newSize($size[0], $width); } if ($newwidth == 'auto' || !$newwidth) { $newwidth = $size[0]; } if ($newheight != 'auto') { $newwidth = round($size[0] * $newheight / $size[1]); } $desc = $showdesc != 'none' ? HTML::p($value["desc"]) : ''; if ($count == 0) { $cell = array('style' => 'display: block; ' . 'position: absolute; ' . 'left: 50% ; ' . 'margin-left: -' . round($newwidth / 2) . 'px;' . 'text-align: center; ' . 'vertical-align: top', 'name' => "wikislide" . $count); } else { $cell = array('style' => 'display: none; ' . 'position: absolute ;' . 'left: 50% ;' . 'margin-left: -' . round($newwidth / 2) . 'px;' . 'text-align: center; ' . 'vertical-align: top', 'name' => "wikislide" . $count); } if ($align == 'left' || $align == 'right') { if ($count == 0) { $cell = array('style' => 'display: block; ' . 'position: absolute; ' . $align . ': 50px; ' . 'vertical-align: top', 'name' => "wikislide" . $count); } else { $cell = array('style' => 'display: none; ' . 'position: absolute; ' . $align . ': 50px; ' . 'vertical-align: top', 'name' => "wikislide" . $count); } } $row->pushContent(HTML::td($cell, $url_image, HTML::span(array('class' => 'gensmall'), $desc))); $count++; } elseif ($mode == 'row') { $desc = $showdesc != 'none' ? HTML::p($value["desc"]) : ''; $row->pushContent(HTML::table(array("style" => "display: inline"), HTML::tr(HTML::td($url_image)), HTML::tr(HTML::td(array("class" => "gensmall", "style" => "text-align: center; " . "background-color: {$color}"), $desc)))); } else { return $this->error(fmt("Invalid argument: %s=%s", 'mode', $mode)); } // no more images in one row as defined by $numcols if (($key + 1) % $numcols == 0 || $key + 1 == count($photos) || $p) { if ($mode == 'row') { $html->pushcontent(HTML::span($row)); } else { $html->pushcontent(HTML::tr($row)); } $row->setContent(''); } } //create main table $table_attributes = array("border" => 0, "cellpadding" => 5, "cellspacing" => 2, "width" => $tablewidth); if (!@empty($tableheight)) { $table_attributes = array_merge($table_attributes, array("height" => $tableheight)); } if ($mode != 'row') { $html = HTML::table($table_attributes, $html); } // align all return HTML::div(array("align" => $align), $html); }
function _generateTable($caption) { if (count($this->pagelist) > 0) { $table = HTML::table(array('cellpadding' => 0, 'cellspacing' => 1, 'border' => 0, 'class' => 'pagelist')); if ($caption) { $table->pushContent(HTML::caption(array('align' => 'top'), $caption)); } $row = HTML::tr(); $spacer = new RawXml(" "); foreach ($this->_columns as $col_heading) { $row->pushContent(HTML::td(HTML($spacer, HTML::u($col_heading)))); $table_summary[] = $col_heading; } // Table summary for non-visual browsers. $table->setAttr('summary', sprintf(_("Columns: %s."), implode(", ", $table_summary))); $table->pushContent(HTML::thead($row), HTML::tbody(false, $this->_rows)); } else { $table = HTML(); if ($caption) { $table->pushContent(HTML::p($caption)); } $table->pushContent(HTML::p($this->_messageIfEmpty)); } return $table; }
function PageInfoRow($label, $rev, &$request, $is_current = false) { global $WikiTheme; $row = HTML::tr(HTML::td(array('align' => 'right'), $label)); if ($rev) { $author = $rev->get('author'); $dbi = $request->getDbh(); $iswikipage = isWikiWord($author) && $dbi->isWikiPage($author); $authorlink = $iswikipage ? WikiLink($author) : $author; $version = $rev->getVersion(); $linked_version = WikiLink($rev, 'existing', $version); if ($is_current) { $revertbutton = HTML(); } else { $revertbutton = $WikiTheme->makeActionButton(array('action' => 'revert', 'version' => $version), false, $rev); } $row->pushContent(HTML::td(fmt("version %s", $linked_version)), HTML::td($WikiTheme->getLastModifiedMessage($rev, false)), HTML::td(fmt("by %s", $authorlink)), HTML::td($revertbutton)); } else { $row->pushContent(HTML::td(array('colspan' => '4'), _("None"))); } return $row; }
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)); }
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(' '); $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); }
function OptionsButtonBars($plugin_args) { $this->__construct('fieldset', array('class' => 'wiki-rc-action')); // Add ShowHideFolder button $icon = $GLOBALS['WikiTheme']->_findData('images/folderArrowOpen.png'); $img = HTML::img(array('id' => 'rc-action-img', 'src' => $icon, 'onclick' => "showHideFolder('rc-action')", 'alt' => _("Click to hide/show"), 'title' => _("Click to hide/show"))); // Display selection buttons extract($plugin_args); // Custom caption if (!$caption) { $caption = _("Show changes for:"); } $this->pushContent(HTML::legend($caption, ' ', $img)); $table = HTML::table(array('id' => 'rc-action-body', 'style' => 'display:block')); $tr = HTML::tr(); foreach (explode(",", $daylist) as $days_button) { $tr->pushContent($this->_makeDayButton($days_button, $days)); } $table->pushContent($tr); $tr = HTML::tr(); $tr->pushContent($this->_makeUsersButton(0)); $tr->pushContent($this->_makeUsersButton(1)); $table->pushContent($tr); $tr = HTML::tr(); $tr->pushContent($this->_makePagesButton(0)); $tr->pushContent($this->_makePagesButton(1)); $table->pushContent($tr); $tr = HTML::tr(); $tr->pushContent($this->_makeMinorButton(1, $show_minor)); $tr->pushContent($this->_makeMinorButton(0, $show_minor)); $table->pushContent($tr); $tr = HTML::tr(); $tr->pushContent($this->_makeShowAllButton(1, $show_all)); $tr->pushContent($this->_makeShowAllButton(0, $show_all)); $table->pushContent($tr); $tr = HTML::tr(); $tr->pushContent($this->_makeNewPagesButton(0, $only_new)); $tr->pushContent($this->_makeNewPagesButton(1, $only_new)); $table->pushContent($tr); $this->pushContent($table); }
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.": ".$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; }
function run($dbi, $argstr, &$request, $basepage) { global $WikiTheme; include_once "lib/BlockParser.php"; // RichTablePlugin markup is new. $markup = 2.0; $lines = preg_split('/\\n/', $argstr); $table = HTML::table(); if ($lines[0][0] == '*') { $line = substr(array_shift($lines), 1); $attrs = $this->_parse_attr($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); } } } foreach ($lines as $line) { if (substr($line, 0, 1) == "-") { if (isset($row)) { if (isset($cell)) { if (isset($content)) { $cell->pushContent(TransformText($content, $markup, $basepage)); unset($content); } $row->pushContent($cell); unset($cell); } $table->pushContent($row); } $row = HTML::tr(); $attrs = $this->_parse_attr(substr($line, 1)); foreach ($attrs as $key => $value) { if (in_array($key, array("id", "class", "title", "style", "bgcolor", "align", "valign"))) { $row->setAttr($key, $value); } } continue; } if (substr($line, 0, 1) == "|" and isset($row)) { if (isset($cell)) { if (isset($content)) { $cell->pushContent(TransformText($content, $markup, $basepage)); unset($content); } $row->pushContent($cell); } $cell = HTML::td(); $line = substr($line, 1); if ($line[0] == "*") { $attrs = $this->_parse_attr(substr($line, 1)); 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); } } 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)) { $cell->pushContent(TransformText($content)); } $row->pushContent($cell); } $table->pushContent($row); } return $table; }
function _generateList($caption = '') { if (empty($this->_pages)) { return; } // stop recursion $out = HTML(); if ($caption) { $out->pushContent(HTML::p($caption)); } // need a recursive switch here for the azhead and cols grouping. if (!empty($this->_options['cols']) and $this->_options['cols'] > 1) { $count = count($this->_pages); $length = $count / $this->_options['cols']; $width = sprintf("%d", 100 / $this->_options['cols']) . '%'; $cols = HTML::tr(array('valign' => 'top')); for ($i = 0; $i < $count; $i += $length) { $this->_saveOptions(array('cols' => 0)); $this->_pages = array_slice($this->_pages, $i, $length); $cols->pushContent(HTML::td($this->_generateList())); $this->_restoreOptions(); } // speed up table rendering by defining colgroups $out->pushContent(HTML::table(HTML::colgroup(array('span' => $this->_options['cols'], 'width' => $width)), $cols)); return $out; } // Ignore azhead if not sorted by pagename if (!empty($this->_options['azhead']) and strstr($this->sortby($this->_options['sortby'], 'init'), "pagename")) { $cur_h = substr($this->_pages[0]->getName(), 0, 1); $out->pushContent(HTML::h3($cur_h)); // group those pages together with same $h $j = 0; for ($i = 0; $i < count($this->_pages); $i++) { $page =& $this->_pages[$i]; $h = substr($page->getName(), 0, 1); if ($h != $cur_h and $i > $j) { $this->_saveOptions(array('cols' => 0, 'azhead' => 0)); $this->_pages = array_slice($this->_pages, $j, $i - $j); $out->pushContent($this->_generateList()); $this->_restoreOptions(); $j = $i; $out->pushContent(HTML::h3($h)); $cur_h = $h; } } if ($i > $j) { // flush the rest $this->_saveOptions(array('cols' => 0, 'azhead' => 0)); $this->_pages = array_slice($this->_pages, $j, $i - $j); $out->pushContent($this->_generateList()); $this->_restoreOptions(); } return $out; } if (!empty($this->_options['comma'])) { if ($this->_options['comma'] == 1) { $out->pushContent($this->_generateCommaListAsString()); } else { $out->pushContent($this->_generateCommaList($this->_options['comma'])); } return $out; } $do_paging = (isset($this->_options['paging']) and !empty($this->_options['limit']) and $this->getTotal() and $this->_options['paging'] != 'none'); if ($do_paging) { $tokens = $this->pagingTokens($this->getTotal(), count($this->_columns), $this->_options['limit']); if ($tokens) { $paging = Template("pagelink", $tokens); $out->pushContent(HTML::table($paging)); } } if (!empty($this->_options['ordered'])) { $list = HTML::ol(array('class' => 'pagelist')); } else { $list = HTML::ul(array('class' => 'pagelist')); } $i = 0; //TODO: currently we ignore limit here and hope tha the backend didn't ignore it. (BackLinks) if (!empty($this->_options['limit'])) { list($offset, $pagesize) = $this->limit($this->_options['limit']); } else { $pagesize = 0; } foreach ($this->_pages as $pagenum => $page) { $pagehtml = $this->_renderPageRow($page); $group = $i++ / $this->_group_rows; //TODO: here we switch every row, in tables every third. // unification or parametrized? $class = $group % 2 ? 'oddrow' : 'evenrow'; $list->pushContent(HTML::li(array('class' => $class), $pagehtml)); if ($pagesize and $i > $pagesize) { break; } } $out->pushContent($list); if ($do_paging and $tokens) { $out->pushContent(HTML::table($paging)); } return $out; }