コード例 #1
0
ファイル: _BackendInfo.php プロジェクト: pombredanne/tuleap
 function run($dbi, $argstr, &$request, $basepage)
 {
     $args = $this->getArgs($argstr, $request);
     extract($args);
     if (empty($page)) {
         return '';
     }
     $backend =& $dbi->_backend;
     $html = HTML(HTML::h3(fmt("Querying backend directly for '%s'", $page)));
     $table = HTML::table(array('border' => 1, 'cellpadding' => 2, 'cellspacing' => 0));
     $pagedata = $backend->get_pagedata($page);
     if (!$pagedata) {
         // FIXME: invalid HTML
         $html->pushContent(HTML::p(fmt("No pagedata for %s", $page)));
     } else {
         $this->_fixupData($pagedata);
         $table->pushContent($this->_showhash("get_pagedata('{$page}')", $pagedata));
     }
     for ($version = $backend->get_latest_version($page); $version; $version = $backend->get_previous_version($page, $version)) {
         $vdata = $backend->get_versiondata($page, $version, true);
         $this->_fixupData($vdata);
         $table->pushContent(HTML::tr(HTML::td(array('colspan' => 2))));
         $table->pushContent($this->_showhash("get_versiondata('{$page}',{$version})", $vdata));
     }
     $html->pushContent($table);
     return $html;
 }
コード例 #2
0
ファイル: AtomFeed.php プロジェクト: hugcoday/wiki
 function run($dbi, $argstr, &$request, $basepage)
 {
     extract($this->getArgs($argstr, $request));
     $parser = new AtomParser();
     assert(!empty($url));
     $parser->parse_url($url);
     $html = '';
     $items = HTML::dl();
     foreach ($parser->feed as $feed) {
         $title = HTML::h3(HTML::a(array('href' => $feed["links"]["0"]["href"]), $feed["title"]));
         $counter = 1;
         foreach ($parser->entries as $entry) {
             $item = HTML::dt(HTML::a(array('href' => $entry["links"]["0"]["href"]), $entry["title"]));
             $items->pushContent($item);
             if (!$titleonly) {
                 $description = HTML::dd(HTML::raw(html_entity_decode($entry["content"])));
             } else {
                 $description = HTML::dd();
             }
             $items->pushContent($description);
             if ($maxitem > 0 && $counter >= $maxitem) {
                 break;
             }
             $counter++;
         }
         $html = HTML::div(array('class' => 'rss'), $title);
         $html->pushContent($items);
     }
     return $html;
 }
コード例 #3
0
ファイル: _BackendInfo.php プロジェクト: hugcoday/wiki
 function run($dbi, $argstr, &$request, $basepage)
 {
     $args = $this->getArgs($argstr, $request);
     extract($args);
     if (empty($page)) {
         return $this->error("page missing");
     }
     $backend =& $dbi->_backend;
     $this->chunk_split = true;
     $this->readonly_pagemeta = array();
     $this->hidden_pagemeta = array('_cached_html');
     $html = HTML(HTML::h3(fmt("Querying backend directly for '%s'", $page)));
     $table = HTML::table(array('border' => 1, 'cellpadding' => 2, 'cellspacing' => 0));
     $pagedata = $backend->get_pagedata($page);
     if (!$pagedata) {
         // FIXME: invalid HTML
         $html->pushContent(HTML::p(fmt("No pagedata for %s", $page)));
     } else {
         $this->_fixupData($pagedata);
         $table->pushContent($this->_showhash("get_pagedata('{$page}')", $pagedata));
     }
     if (!$notallversions) {
         $version = $backend->get_latest_version($page);
         $vdata = $backend->get_versiondata($page, $version, true);
         $this->_fixupData($vdata);
         $table->pushContent(HTML::tr(HTML::td(array('colspan' => 2))));
         $table->pushContent($this->_showhash("get_versiondata('{$page}',{$version})", $vdata));
     } else {
         for ($version = $backend->get_latest_version($page); $version; $version = $backend->get_previous_version($page, $version)) {
             $vdata = $backend->get_versiondata($page, $version, true);
             $this->_fixupData($vdata);
             $table->pushContent(HTML::tr(HTML::td(array('colspan' => 2))));
             $table->pushContent($this->_showhash("get_versiondata('{$page}',{$version})", $vdata));
         }
     }
     $linkdata = $backend->get_links($page, false);
     if ($linkdata->count()) {
         $table->pushContent($this->_showhash("get_links('{$page}')", $linkdata->asArray()));
     }
     $relations = $backend->get_links($page, false, false, false, false, false, true);
     if ($relations->count()) {
         $table->pushContent($this->_showhash("get_relations('{$page}')", array()));
         while ($rel = $relations->next()) {
             $table->pushContent($this->_showhash(false, $rel));
         }
     }
     $linkdata = $backend->get_links($page, true);
     if ($linkdata->count()) {
         $table->pushContent($this->_showhash("get_backlinks('{$page}')", $linkdata->asArray()));
     }
     $html->pushContent($table);
     return $html;
 }
コード例 #4
0
ファイル: _GroupInfo.php プロジェクト: hugcoday/wiki
 function run($dbi, $argstr, &$request, $basepage)
 {
     $args = $this->getArgs($argstr, $request);
     extract($args);
     $output = HTML(HTML::h1("Group Info"));
     $group = WikiGroup::getGroup();
     $allGroups = $group->getAllGroupsIn();
     foreach ($allGroups as $g) {
         $members = $group->getMembersOf($g);
         $output->pushContent(HTML::h3($g . " - members: " . sizeof($members) . " - isMember: " . ($group->isMember($g) ? "yes" : "no")));
         foreach ($members as $m) {
             $output->pushContent($m);
             $output->pushContent(HTML::br());
         }
     }
     $output->pushContent(HTML::p("--- the end ---"));
     return $output;
 }
コード例 #5
0
ファイル: _Retransform.php プロジェクト: hugcoday/wiki
 function run($dbi, $argstr, &$request, $basepage)
 {
     $args = $this->getArgs($argstr, $request);
     extract($args);
     if (empty($page)) {
         return '';
     }
     $html = HTML(HTML::h3(fmt("Retransform page '%s'", $page)));
     // bypass WikiDB and cache, go directly through the backend.
     $backend =& $dbi->_backend;
     //$pagedata = $backend->get_pagedata($page);
     $version = $backend->get_latest_version($page);
     $vdata = $backend->get_versiondata($page, $version, true);
     include_once 'lib/PageType.php';
     $formatted = new TransformedText($dbi->getPage($page), $vdata['%content'], $vdata);
     $content =& $formatted->_content;
     $html->pushContent($this->_DebugPrintArray($content));
     $links = $formatted->getWikiPageLinks();
     if (count($links) > 0) {
         $html->pushContent(HTML::h3("Links"));
         $html->pushContent($this->_DebugPrintArray($links));
     }
     return $html;
 }
コード例 #6
0
ファイル: WikiPoll.php プロジェクト: hugcoday/wiki
 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);
     }
 }
コード例 #7
0
ファイル: BlogJournal.php プロジェクト: hugcoday/wiki
 function run($dbi, $argstr, &$request, $basepage)
 {
     if (is_array($argstr)) {
         // can do with array also.
         $args =& $argstr;
         if (!isset($args['order'])) {
             $args['order'] = 'reverse';
         }
     } else {
         $args = $this->getArgs($argstr, $request);
     }
     $user = $request->getUser();
     if (empty($args['user'])) {
         if ($user->isAuthenticated()) {
             $args['user'] = $user->UserName();
         } else {
             $args['user'] = '';
         }
     }
     if (!$args['user'] or $args['user'] == ADMIN_USER) {
         if (BLOG_DEFAULT_EMPTY_PREFIX) {
             $args['user'] = '';
             // "Blogs/day" pages
         } else {
             $args['user'] = ADMIN_USER;
             // "Admin/Blogs/day" pages
         }
     }
     $parent = empty($args['user']) ? '' : $args['user'] . SUBPAGE_SEPARATOR;
     $sp = HTML::Raw('&middot; ');
     $prefix = $base = $parent . $this->_blogPrefix('wikiblog');
     if ($args['month']) {
         $prefix .= SUBPAGE_SEPARATOR . $args['month'];
     }
     $pages = $dbi->titleSearch(new TextSearchQuery("^" . $prefix . SUBPAGE_SEPARATOR, true, 'posix'));
     $html = HTML();
     $i = 0;
     while ($page = $pages->next() and $i < $args['count']) {
         $rev = $page->getCurrentRevision(false);
         if ($rev->get('pagetype') != 'wikiblog') {
             continue;
         }
         $i++;
         $blog = $this->_blog($rev);
         //$html->pushContent(HTML::h3(WikiLink($page, 'known', $rev->get('summary'))));
         $html->pushContent($rev->getTransformedContent('wikiblog'));
     }
     if ($args['user'] == $user->UserName() or $args['user'] == '') {
         $html->pushContent(Button(array('action' => 'WikiBlog', 'mode' => 'add'), _("New entry"), $base));
     }
     if (!$i) {
         return HTML(HTML::h3(_("No Blog Entries")), $html);
     }
     if (!$args['noheader']) {
         return HTML(HTML::h3(sprintf(_("Blog Entries for %s:"), $this->_monthTitle($args['month']))), $html);
     } else {
         return $html;
     }
 }
コード例 #8
0
ファイル: BlogArchives.php プロジェクト: pombredanne/tuleap
 function run($dbi, $argstr, &$request, $basepage)
 {
     if (is_array($argstr)) {
         // can do with array also.
         $args =& $argstr;
         if (!isset($args['order'])) {
             $args['order'] = 'reverse';
         }
     } else {
         $args = $this->getArgs($argstr, $request);
     }
     if (empty($args['user'])) {
         $user = $request->getUser();
         if ($user->isAuthenticated()) {
             $args['user'] = $user->UserName();
         } else {
             $args['user'] = '';
         }
     }
     if (!$args['user'] or $args['user'] == ADMIN_USER) {
         if (BLOG_EMPTY_DEFAULT_PREFIX) {
             $args['user'] = '';
         } else {
             $args['user'] = ADMIN_USER;
         }
         // "Admin/Blogs/day" pages
     }
     $parent = empty($args['user']) ? '' : $args['user'] . SUBPAGE_SEPARATOR;
     //$info = explode(',', $args['info']);
     //$pagelist = new PageList($args['info'], $args['exclude'], $args);
     //if (!is_array('pagename'), explode(',', $info))
     //    unset($pagelist->_columns['pagename']);
     $sp = HTML::Raw('&middot; ');
     if (!empty($args['month'])) {
         $prefix = $parent . $this->_blogPrefix('wikiblog') . SUBPAGE_SEPARATOR . $args['month'];
         $pages = $dbi->titleSearch(new TextSearchQuery("^" . $prefix, true, 'posix'));
         $html = HTML::ul();
         while ($page = $pages->next()) {
             $rev = $page->getCurrentRevision(false);
             if ($rev->get('pagetype') != 'wikiblog') {
                 continue;
             }
             $blog = $this->_blog($rev);
             $html->pushContent(HTML::li(WikiLink($page, 'known', $rev->get('summary'))));
         }
         if (!$args['noheader']) {
             return HTML(HTML::h3(sprintf(_("Blog Entries for %s:"), $this->_monthTitle($args['month']))), $html);
         } else {
             return $html;
         }
     }
     $blogs = $this->findBlogs($dbi, $args['user'], 'wikiblog');
     if ($blogs) {
         if (!$basepage) {
             $basepage = _("BlogArchives");
         }
         $html = HTML::ul();
         usort($blogs, array("WikiPlugin_WikiBlog", "cmp"));
         if ($args['order'] == 'reverse') {
             $blogs = array_reverse($blogs);
         }
         // collapse pagenames by month
         $months = array();
         foreach ($blogs as $rev) {
             $blog = $this->_blog($rev);
             $mon = $blog['month'];
             if (empty($months[$mon])) {
                 $months[$mon] = array('title' => $this->_monthTitle($mon), 'num' => 1, 'month' => $mon, 'link' => WikiURL($basepage, $this->_nonDefaultArgs(array('month' => $mon))));
             } else {
                 $months[$mon]['num']++;
             }
         }
         foreach ($months as $m) {
             $html->pushContent(HTML::li(HTML::a(array('href' => $m['link'], 'class' => 'named-wiki'), $m['title'] . " (" . $m['num'] . ")")));
         }
         if (!$args['noheader']) {
             return HTML(HTML::h3(_("Blog Archives:")), $html);
         } else {
             return $html;
         }
     } else {
         return '';
     }
 }
コード例 #9
0
ファイル: PageList.php プロジェクト: hugcoday/wiki
 function _generateList($caption = '')
 {
     if (empty($this->_pages)) {
         return;
     }
     // stop recursion
     if (!isset($this->_options['listtype'])) {
         $this->_options['listtype'] = '';
     }
     foreach ($this->_pages as $pagenum => $page) {
         $one_row = $this->_renderPageRow($page);
         $rows[] = array('header' => WikiLink($page), 'render' => $one_row);
     }
     $out = HTML();
     if ($caption) {
         $out->pushContent(HTML::p($caption));
     }
     // Semantic Search et al: only unique list entries, esp. with nopage
     if (!is_array($this->_pages[0]) and is_string($this->_pages[0])) {
         $this->_pages = array_unique($this->_pages);
     }
     if (count($this->_sortby) > 0) {
         $this->_sortPages();
     }
     $count = $this->getTotal();
     $do_paging = (isset($this->_options['paging']) and !empty($this->_options['limit']) and $count and $this->_options['paging'] != 'none');
     if ($do_paging) {
         $tokens = $this->pagingTokens($count, count($this->_columns), $this->_options['limit']);
         if ($tokens) {
             $paging = Template("pagelink", $tokens);
             $out->pushContent(HTML::table(array('width' => '50%'), $paging));
         }
     }
     if (!empty($this->_options['limit']) and !empty($this->_options['slice'])) {
         list($offset, $count) = $this->limit($this->_options['limit']);
     } else {
         $offset = 0;
         $count = count($this->_pages);
     }
     // need a recursive switch here for the azhead and cols grouping.
     if (!empty($this->_options['cols']) and $this->_options['cols'] > 1) {
         $length = intval($count / $this->_options['cols']);
         // If division does not give an integer, we need one more line
         // E.g. 13 pages to display in 3 columns.
         if ($length * $this->_options['cols'] != $count) {
             $length += 1;
         }
         $width = sprintf("%d", 100 / $this->_options['cols']) . '%';
         $cols = HTML::tr(array('valign' => 'top'));
         for ($i = $offset; $i < $offset + $count; $i += $length) {
             $this->_saveOptions(array('cols' => 0, 'paging' => 'none'));
             $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, 'ordered' => $j + 1));
                 $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, 'ordered' => $j + 1));
             $this->_pages = array_slice($this->_pages, $j, $i - $j);
             $out->pushContent($this->_generateList());
             $this->_restoreOptions();
         }
         return $out;
     }
     if ($this->_options['listtype'] == 'comma') {
         $this->_options['comma'] = 2;
     }
     if (!empty($this->_options['comma'])) {
         if ($this->_options['comma'] == 1) {
             $out->pushContent($this->_generateCommaListAsString());
         } else {
             $out->pushContent($this->_generateCommaList($this->_options['comma']));
         }
         return $out;
     }
     if ($this->_options['listtype'] == 'ol') {
         if (empty($this->_options['ordered'])) {
             $this->_options['ordered'] = $offset + 1;
         }
     } elseif ($this->_options['listtype'] == 'ul') {
         $this->_options['ordered'] = 0;
     }
     if ($this->_options['listtype'] == 'ol' and !empty($this->_options['ordered'])) {
         $list = HTML::ol(array('class' => 'pagelist', 'start' => $this->_options['ordered']));
     } elseif ($this->_options['listtype'] == 'dl') {
         $list = HTML::dl(array('class' => 'pagelist'));
     } else {
         $list = HTML::ul(array('class' => 'pagelist'));
     }
     $i = 0;
     //TODO: currently we ignore limit here and hope that the backend didn't ignore it. (BackLinks)
     if (!empty($this->_options['limit'])) {
         list($offset, $pagesize) = $this->limit($this->_options['limit']);
     } else {
         $pagesize = 0;
     }
     foreach (array_reverse($rows) as $one_row) {
         $pagehtml = $one_row['render'];
         if (!$pagehtml) {
             continue;
         }
         $group = $i++ / $this->_group_rows;
         //TODO: here we switch every row, in tables every third.
         //      unification or parametrized?
         $class = $group % 2 ? 'oddrow' : 'evenrow';
         if ($this->_options['listtype'] == 'dl') {
             $header = $one_row['header'];
             $list->pushContent(HTML::dt(array('class' => $class), $header), HTML::dd(array('class' => $class), $pagehtml));
         } else {
             $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;
 }
コード例 #10
0
ファイル: PageList.php プロジェクト: pombredanne/tuleap
 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;
 }
コード例 #11
0
ファイル: ModeratedPage.php プロジェクト: hugcoday/wiki
 function _approval_form(&$request, $args, $moderation, $pass = '******')
 {
     $header = HTML::h3(_("Please approve or reject this request:"));
     $loader = new WikiPluginLoader();
     $BackendInfo = $loader->getPlugin("_BackendInfo");
     $table = HTML::table(array('border' => 1, 'cellpadding' => 2, 'cellspacing' => 0));
     $content = $table;
     $diff = '';
     if ($moderation['args']['action'] == 'edit') {
         $pagename = $moderation['args']['pagename'];
         $p = $request->_dbi->getPage($pagename);
         $rev = $p->getCurrentRevision(true);
         $curr_content = $rev->getPackedContent();
         $new_content = $moderation['args']['edit']['content'];
         include_once "lib/difflib.php";
         $diff2 = new Diff($curr_content, $new_content);
         $fmt = new UnifiedDiffFormatter();
         $diff = $pagename . " Current Version " . Iso8601DateTime($p->get('mtime')) . "\n";
         $diff .= $pagename . " Edited Version " . Iso8601DateTime($moderation['timestamp']) . "\n";
         $diff .= $fmt->format($diff2);
     }
     $content->pushContent($BackendInfo->_showhash("Request", array('User' => $moderation['userid'], 'When' => CTime($moderation['timestamp']), 'Pagename' => $pagename, 'Action' => $moderation['args']['action'], 'Diff' => HTML::pre($diff))));
     $content_dbg = $table;
     $myargs = $args;
     $BackendInfo->_fixupData($myargs);
     $content_dbg->pushContent($BackendInfo->_showhash("raw request args", $myargs));
     $BackendInfo->_fixupData($moderation);
     $content_dbg->pushContent($BackendInfo->_showhash("raw moderation data", $moderation));
     $reason = HTML::div(_("Reason: "), HTML::textarea(array('name' => 'reason')));
     $approve = Button('submit:ModeratedPage[approve]', _("Approve"), $pass == 'approve' ? 'wikiadmin' : 'button');
     $reject = Button('submit:ModeratedPage[reject]', _("Reject"), $pass == 'reject' ? 'wikiadmin' : 'button');
     $args['action'] = _("ModeratedPage");
     return HTML::form(array('action' => $request->getPostURL(), 'method' => 'post'), $header, $content, HTML::p(""), $content_dbg, $reason, ENABLE_PAGEPERM ? '' : HiddenInputs(array('require_authority_for_post' => WIKIAUTH_ADMIN)), HiddenInputs($args), $pass == 'approve' ? HTML::p($approve, $reject) : HTML::p($reject, $approve));
 }
コード例 #12
0
ファイル: _AuthInfo.php プロジェクト: pombredanne/tuleap
 function run($dbi, $argstr, &$request, $basepage)
 {
     $args = $this->getArgs($argstr, $request);
     extract($args);
     if (empty($userid) or $userid == $request->_user->UserName()) {
         $user =& $request->_user;
         $userid = $user->UserName();
     } else {
         $user = WikiUser($userid);
     }
     if (!$user->isAdmin() and !(DEBUG && _DEBUG_LOGIN)) {
         $request->_notAuthorized(WIKIAUTH_ADMIN);
         $this->disabled("! user->isAdmin");
     }
     $html = HTML(HTML::h3(fmt("General Auth Settings")));
     $table = HTML::table(array('border' => 1, 'cellpadding' => 2, 'cellspacing' => 0));
     $table->pushContent($this->_showhash("AUTH DEFINES", $this->_buildConstHash(array("ENABLE_USER_NEW", "ALLOW_ANON_USER", "ALLOW_ANON_EDIT", "ALLOW_BOGO_LOGIN", "REQUIRE_SIGNIN_BEFORE_EDIT", "ALLOW_USER_PASSWORDS", "PASSWORD_LENGTH_MINIMUM", "USE_DB_SESSION"))));
     if (defined('ALLOW_LDAP_LOGIN') && ALLOW_LDAP_LOGIN or in_array("LDAP", $GLOBALS['USER_AUTH_ORDER'])) {
         $table->pushContent($this->_showhash("LDAP DEFINES", $this->_buildConstHash(array("LDAP_AUTH_HOST", "LDAP_BASE_DN"))));
     }
     if (defined('ALLOW_IMAP_LOGIN') && ALLOW_IMAP_LOGIN or in_array("IMAP", $GLOBALS['USER_AUTH_ORDER'])) {
         $table->pushContent($this->_showhash("IMAP DEFINES", array("IMAP_AUTH_HOST" => IMAP_AUTH_HOST)));
     }
     if (defined('AUTH_USER_FILE') or in_array("File", $GLOBALS['USER_AUTH_ORDER'])) {
         $table->pushContent($this->_showhash("AUTH_USER_FILE", $this->_buildConstHash(array("AUTH_USER_FILE", "AUTH_USER_FILE_STORABLE"))));
     }
     if (defined('GROUP_METHOD')) {
         $table->pushContent($this->_showhash("GROUP_METHOD", $this->_buildConstHash(array("GROUP_METHOD", "AUTH_GROUP_FILE", "GROUP_LDAP_QUERY"))));
     }
     $table->pushContent($this->_showhash("\$USER_AUTH_ORDER[]", $GLOBALS['USER_AUTH_ORDER']));
     $table->pushContent($this->_showhash("USER_AUTH_POLICY", array("USER_AUTH_POLICY" => USER_AUTH_POLICY)));
     $DBParams = $GLOBALS['DBParams'];
     $DBParams['dsn'] = class_exists('WikiDB_SQL') ? WikiDB_SQL::view_dsn($DBParams['dsn']) : '';
     $table->pushContent($this->_showhash("\$DBParams[]", $DBParams));
     $DBAuthParams = $GLOBALS['DBAuthParams'];
     if (isset($DBAuthParams['auth_dsn']) and class_exists('WikiDB_SQL')) {
         $DBAuthParams['auth_dsn'] = WikiDB_SQL::view_dsn($DBAuthParams['auth_dsn']);
     } else {
         $DBAuthParams['auth_dsn'] = '';
     }
     unset($DBAuthParams['dummy']);
     $table->pushContent($this->_showhash("\$DBAuthParams[]", $DBAuthParams));
     $html->pushContent($table);
     $html->pushContent(HTML(HTML::h3(fmt("Personal Auth Settings for '%s'", $userid))));
     if (!$user) {
         $html->pushContent(HTML::p(fmt("No userid")));
     } else {
         $table = HTML::table(array('border' => 1, 'cellpadding' => 2, 'cellspacing' => 0));
         //$table->pushContent(HTML::tr(HTML::td(array('colspan' => 2))));
         $userdata = obj2hash($user, array('_dbi', '_request', 'password', 'passwd'));
         $table->pushContent($this->_showhash("User: Object of " . get_class($user), $userdata));
         if (ENABLE_USER_NEW) {
             $group =& $request->getGroup();
             $groups = $group->getAllGroupsIn();
             $groupdata = obj2hash($group, array('_dbi', '_request', 'password', 'passwd'));
             unset($groupdata['request']);
             $table->pushContent($this->_showhash("Group: Object of " . get_class($group), $groupdata));
             $groups = $group->getAllGroupsIn();
             $groupdata = array('getAllGroupsIn' => $groups);
             foreach ($groups as $g) {
                 $groupdata["getMembersOf({$g})"] = $group->getMembersOf($g);
                 $groupdata["isMember({$g})"] = $group->isMember($g);
             }
             $table->pushContent($this->_showhash("Group Methods: ", $groupdata));
         }
         $html->pushContent($table);
     }
     return $html;
 }
コード例 #13
0
ファイル: editpage.php プロジェクト: hugcoday/wiki
 function output($template, $title_fs)
 {
     $selected =& $this->selected;
     $current =& $this->current;
     if ($selected && $selected->getVersion() != $current->getVersion()) {
         $rev = $selected;
         $pagelink = WikiLink($selected);
     } else {
         $rev = $current;
         $pagelink = WikiLink($this->page);
     }
     $title = new FormattedText($title_fs, $pagelink);
     $this->tokens['HEADER'] = $title;
     //hack! there's no TITLE in editpage, but in the previous top template
     if (empty($this->tokens['PAGE_LOCKED_MESSAGE'])) {
         $this->tokens['PAGE_LOCKED_MESSAGE'] = HTML::h3($title);
     } else {
         $this->tokens['PAGE_LOCKED_MESSAGE'] = HTML(HTML::h3($title), $this->tokens['PAGE_LOCKED_MESSAGE']);
     }
     $template = Template($template, $this->tokens);
     //GeneratePage($template, $title, $rev);
     PrintXML($template);
     return true;
 }
コード例 #14
0
 function format($changes)
 {
     include_once 'lib/InlineParser.php';
     $html = HTML(HTML::h2(false, $this->title()));
     if ($desc = $this->description()) {
         $html->pushContent($desc);
     }
     if ($this->_args['daylist']) {
         $html->pushContent(new DayButtonBar($this->_args));
     }
     $last_date = '';
     $lines = false;
     $first = true;
     while ($rev = $changes->next()) {
         if (($date = $this->date($rev)) != $last_date) {
             if ($lines) {
                 $html->pushContent($lines);
             }
             $html->pushContent(HTML::h3($date));
             $lines = HTML::ul();
             $last_date = $date;
         }
         // enforce view permission
         if (mayAccessPage('view', $rev->_pagename)) {
             $lines->pushContent($this->format_revision($rev));
             if ($first) {
                 $this->setValidators($rev);
             }
             $first = false;
         }
     }
     if ($lines) {
         $html->pushContent($lines);
     }
     if ($first) {
         $html->pushContent(HTML::p(array('class' => 'rc-empty'), $this->empty_message()));
     }
     return $html;
 }
コード例 #15
0
 function _approval_form(&$request, $args, $moderation, $pass = '******')
 {
     $header = HTML::h3(_("Please approve or reject this request:"));
     $loader = new WikiPluginLoader();
     $BackendInfo = $loader->getPlugin("_BackendInfo");
     $content = HTML::table(array('border' => 1, 'cellpadding' => 2, 'cellspacing' => 0));
     $myargs = $args;
     $BackendInfo->_fixupData($myargs);
     $content->pushContent($BackendInfo->_showhash("request args", $myargs));
     $BackendInfo->_fixupData($moderation);
     $content->pushContent($BackendInfo->_showhash("moderation data", $moderation));
     $approve = Button('submit:ModeratedPage[approve]', _("Approve"), $pass == 'approve' ? 'wikiadmin' : 'button');
     $reject = Button('submit:ModeratedPage[reject]', _("Reject"), $pass == 'reject' ? 'wikiadmin' : 'button');
     return HTML::form(array('action' => $request->getPostURL(), 'method' => 'post'), $header, $content, ENABLE_PAGEPERM ? '' : HiddenInputs(array('require_authority_for_post' => WIKIAUTH_ADMIN)), HiddenInputs($args), $pass == 'approve' ? HTML::p($approve, $reject) : HTML::p($reject, $approve));
 }
コード例 #16
0
ファイル: RecentChanges.php プロジェクト: hugcoday/wiki
 function format($changes)
 {
     include_once 'lib/InlineParser.php';
     $html = HTML(HTML::h2(false, $this->headline()));
     if ($desc = $this->description()) {
         $html->pushContent($desc);
     }
     if ($this->_args['daylist']) {
         $html->pushContent(new OptionsButtonBars($this->_args));
     }
     $last_date = '';
     $lines = false;
     $first = true;
     while ($rev = $changes->next()) {
         if (($date = $this->date($rev)) != $last_date) {
             if ($lines) {
                 $html->pushContent($lines);
             }
             // for user contributions no extra date line
             $html->pushContent(HTML::h3($date));
             $lines = HTML::ul();
             $last_date = $date;
         }
         // enforce view permission
         if (mayAccessPage('view', $rev->_pagename)) {
             $lines->pushContent($this->format_revision($rev));
             if ($first) {
                 $this->setValidators($rev);
             }
             $first = false;
         }
     }
     if ($lines) {
         $html->pushContent($lines);
     }
     if ($first) {
         if ($this->_args['daylist']) {
             $html->pushContent(JavaScript("document.getElementById('rc-action-body').style.display='block';"));
         }
         $html->pushContent(HTML::p(array('class' => 'rc-empty'), $this->empty_message()));
     }
     return $html;
 }
コード例 #17
0
ファイル: SemanticRelations.php プロジェクト: hugcoday/wiki
 function run($dbi, $argstr, &$request, $basepage)
 {
     global $WikiTheme;
     $args = $this->getArgs($argstr, $request);
     extract($args);
     if (empty($page)) {
         $page = $request->getArg('pagename');
     }
     $relhtml = HTML();
     if ($args['relations'] != '') {
         $relfilter = explode(",", $args['relations']);
     } else {
         $relfilter = array();
     }
     if ($args['attributes'] != '') {
         $attfilter = explode(",", $args['attributes']);
     } else {
         $attfilter = array();
     }
     foreach (explodePageList($page) as $pagename) {
         $p = $dbi->getPage($pagename);
         if ($args['relations'] != '0') {
             $links = $p->getRelations();
             // iter of pagelinks
             // TODO: merge same relations together located_in::here, located_in::there
             while ($object = $links->next()) {
                 if ($related = $object->get('linkrelation')) {
                     // a page name
                     if ($relfilter and !in_array($related, $relfilter)) {
                         continue;
                     }
                     $rellink = WikiLink($related, false, $related);
                     $rellink->setAttr('class', $rellink->getAttr('class') . ' relation');
                     $relhtml->pushContent($pagename . " ", $rellink, HTML::span(array('class' => 'relation-symbol'), "::"), WikiLink($object->_pagename), " ", $WikiTheme->makeActionButton(array('relation' => $related, 's' => $object->_pagename), '+', _("SemanticSearch")), count($relfilter) > 3 ? HTML::br() : " ");
                 }
             }
             if (!empty($relhtml->_content) and !$noheader) {
                 $relhtml = HTML(HTML::hr(), HTML::h3(fmt("Semantic relations for %s", $pagename)), $relhtml);
             }
         }
         $atthtml = HTML();
         if ($args['attributes'] != '0') {
             if ($attributes = $p->get('attributes')) {
                 // a hash of unique pairs
                 foreach ($attributes as $att => $val) {
                     if ($attfilter and !in_array($att, $attfilter)) {
                         continue;
                     }
                     $rellink = WikiLink($att, false, $att);
                     $rellink->setAttr('class', $rellink->getAttr('class') . ' relation');
                     $searchlink = $WikiTheme->makeActionButton(array('attribute' => $att, 's' => $val), $val, _("SemanticSearch"));
                     $searchlink->setAttr('class', $searchlink->getAttr('class') . ' attribute');
                     if (!$noheader) {
                         $atthtml->pushContent("{$pagename}  ");
                     }
                     $atthtml->pushContent(HTML::span(array('class' => 'attribute ' . $att), $rellink, HTML::span(array('class' => 'relation-symbol'), ":="), $searchlink), count($attfilter) > 3 ? HTML::br() : " ");
                 }
                 if (!$noheader) {
                     $relhtml = HTML($relhtml, HTML::hr(), HTML::h3(fmt("Attributes of %s", $pagename)), $atthtml);
                 } else {
                     $relhtml = HTML($relhtml, $atthtml);
                 }
             }
         }
     }
     if ($nohelp) {
         return $relhtml;
     }
     return HTML($relhtml, HTML::hr(), WikiLink(_("Help/SemanticRelations"), false, HTML::em(_("Help/SemanticRelations"))), " - ", HTML::em(_("Find out how to add relations and attributes to pages.")));
 }