public function renderContent() { $content = ''; $list = ''; $records = $this->splitRecords($this->controller->getRecords()); $totalLength = 0; foreach ($records as $day => $dayRecords) { $filtered = []; $totalDayLength = 0; foreach ($dayRecords as $dayRecord) { foreach ($dayRecord->getTags() as $tag) { if ($tag->getName() == $this->getPath(1)) { $filtered[] = $dayRecord; $length = $dayRecord->getLength(); if (is_null($length)) { $length = abs(time() - $dayRecord->getStart()->getTimestamp()); } $totalDayLength += $length; } } } if (!empty($filtered)) { $totalLength += $totalDayLength; $lengthString = round($totalDayLength / 3600, 2); $list .= HTML::div(['.title'], HTML::div(['.date'], $day) . HTML::div(['.length'], $lengthString)); $list .= new RecordList($filtered, 'record', false, false); } } $content .= HTML::div(['.title', '.total'], HTML::div('total') . HTML::div(['.length'], round($totalLength / 3600, 2))); $content .= $list; return HTML::div($content); }
public function __construct(array $objects, $edit = null, $add = true, $delete = true) { $this->list = ''; foreach ($objects as $object) { $properties = $this->getProperties($object); $propertyList = ''; foreach ($properties as $class => $property) { $propertyList .= HTML::span(['class' => $class], $property); } $id = $object->getId(); if ($edit) { $properties = HTML::span(['class' => 'properties'], HTML::a(['href' => "/edit/{$edit}/{$id}"], $propertyList)); } else { $properties = HTML::span(['class' => 'properties'], $propertyList); } if ($delete) { $deleteLink = HTML::span(['class' => 'delete'], HTML::a(['href' => "/delete/{$edit}/{$id}"], 'x')); } else { $deleteLink = ''; } $this->list .= HTML::div(['class' => 'objectRow'], $properties . $deleteLink); } if ($add && $edit) { $this->list .= HTML::div(HTML::span(HTML::a(['href' => "/edit/{$edit}/"], 'add ' . $edit))); } $this->list = HTML::div(['class' => 'objectList'], $this->list); }
function PurgePage(&$request) { global $WikiTheme; $page = $request->getPage(); $pagelink = WikiLink($page); if ($request->getArg('cancel')) { $request->redirect(WikiURL($page)); // noreturn } $current = $page->getCurrentRevision(); if (!$current or !($version = $current->getVersion())) { $html = HTML::p(array('class' => 'error'), _("Sorry, this page does not exist.")); } elseif (!$request->isPost() || !$request->getArg('verify')) { $purgeB = Button('submit:verify', _("Purge Page"), 'wikiadmin'); $cancelB = Button('submit:cancel', _("Cancel"), 'button'); // use generic wiki button look $fieldset = HTML::fieldset(HTML::p(fmt("You are about to purge '%s'!", $pagelink)), HTML::form(array('method' => 'post', 'action' => $request->getPostURL()), HiddenInputs(array('currentversion' => $version, 'pagename' => $page->getName(), 'action' => 'purge')), HTML::div(array('class' => 'toolbar'), $purgeB, $WikiTheme->getButtonSeparator(), $cancelB))); $sample = HTML::div(array('class' => 'transclusion')); // simple and fast preview expanding only newlines foreach (explode("\n", firstNWordsOfContent(100, $current->getPackedContent())) as $s) { $sample->pushContent($s, HTML::br()); } $html = HTML($fieldset, HTML::div(array('class' => 'wikitext'), $sample)); } elseif ($request->getArg('currentversion') != $version) { $html = HTML(HTML::p(array('class' => 'error'), _("Someone has edited the page!")), HTML::p(fmt("Since you started the purge process, someone has saved a new version of %s. Please check to make sure you still want to permanently purge the page from the database.", $pagelink))); } else { // Real purge. $pagename = $page->getName(); $dbi = $request->getDbh(); $dbi->purgePage($pagename); $dbi->touch(); $html = HTML::div(array('class' => 'feedback'), fmt("Purged page '%s' successfully.", $pagename)); } GeneratePage($html, _("Purge Page")); }
function removePages(&$request, $pages) { $result = HTML::div(); $ul = HTML::ul(); $dbi = $request->getDbh(); $count = 0; foreach ($pages as $name) { $name = str_replace(array('%5B', '%5D'), array('[', ']'), $name); if (mayAccessPage('remove', $name)) { $dbi->deletePage($name); $ul->pushContent(HTML::li(fmt("Removed page '%s' successfully.", $name))); $count++; } else { $ul->pushContent(HTML::li(fmt("Didn't remove page '%s'. Access denied.", $name))); } } if ($count) { $dbi->touch(); $result->setAttr('class', 'feedback'); if ($count == 1) { $result->pushContent(HTML::p("One page has been permanently removed:")); } else { $result->pushContent(HTML::p(fmt("%s pages have been permanently removed:", $count))); } $result->pushContent($ul); return $result; } else { $result->setAttr('class', 'error'); $result->pushContent(HTML::p("No pages removed.")); return $result; } }
function run($dbi, $argstr, &$request, $basepage) { extract($this->getArgs($argstr, $request)); if ($numberlinks > 10 || $numberlinks < 0) { $numberlinks = $this->def_numberlinks; } // Get name of the current page we are on $thispage = $request->getArg('pagename'); $Pages = $request->session->get("PageTrail"); if (!is_array($Pages)) { $Pages = array(); } if (!isset($Pages[0]) or $duplicates || $thispage != $Pages[0]) { array_unshift($Pages, $thispage); $request->session->set("PageTrail", $Pages); } $numberlinks = min(count($Pages), $numberlinks); if (!$invisible and $numberlinks) { $html = HTML::div(array('class' => 'pagetrail')); $html->pushContent(WikiLink($Pages[$numberlinks - 1], 'auto')); for ($i = $numberlinks - 2; $i >= 0; $i--) { if (!empty($Pages[$i])) { $html->pushContent(PAGETRAIL_ARROW, WikiLink($Pages[$i], 'auto')); } } return $html; } else { return HTML(); } }
function run($dbi, $argstr, &$request, $basepage) { global $WikiTheme; $args = $this->getArgs($argstr, $request); extract($args); if (!$src) { return $this->error(fmt("%s parameter missing", "'src'")); } // FIXME: Better recursion detection. // FIXME: Currently this doesnt work at all. if ($src == $request->getURLtoSelf()) { return $this->error(fmt("recursive inclusion of url %s", $src)); } if (!IsSafeURL($src)) { return $this->error(_("Bad url in src: remove all of <, >, \"")); } $params = array('title' => _("Transcluded page"), 'src' => $src, 'width' => "100%", 'height' => $height, 'marginwidth' => 0, 'marginheight' => 0, 'class' => 'transclude', "onload" => "adjust_iframe_height(this);"); $noframe_msg[] = fmt("See: %s", HTML::a(array('href' => $src), $src)); $noframe_msg = HTML::div(array('class' => 'transclusion'), HTML::p(array(), $noframe_msg)); $iframe = HTML::div(HTML::iframe($params, $noframe_msg)); /* This doesn't work very well... maybe because CSS screws up NS4 anyway... $iframe = new HtmlElement('ilayer', array('src' => $src), $iframe); */ return HTML(HTML::p(array('class' => 'transclusion-title'), fmt("Transcluded from %s", LinkURL($src))), $this->_js(), $iframe); }
function run($dbi, $argstr, &$request, $basepage) { /* plugin not yet has arguments - save for later (copied from UpLoad) $args = $this->getArgs($argstr, $request); extract($args); */ $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))); $contents->pushContent(HTML::input(array('name' => 'userfile', 'type' => 'file', 'size' => '50'))); $contents->pushContent(HTML::raw(" ")); $contents->pushContent(HTML::input(array('value' => _("Convert"), 'type' => 'submit'))); $form->pushContent($contents); $message = HTML(); $userfile = $request->getUploadedFile('userfile'); if ($userfile) { $userfile_name = $userfile->getName(); $userfile_name = basename($userfile_name); $userfile_tmpname = $userfile->getTmpName(); if (!preg_match("/(\\.html|\\.htm)\$/i", $userfile_name)) { $message->pushContent(_("Only files with extension HTML are allowed"), HTML::br(), HTML::br()); } else { $message->pushContent(_("Processed {$userfile_name}"), HTML::br(), HTML::br()); $message->pushContent(_("Copy the output below and paste it into your Wiki page."), HTML::br()); $message->pushContent($this->_process($userfile_tmpname)); } } else { $message->pushContent(HTML::br(), HTML::br()); } $result = HTML(); $result->pushContent($form); $result->pushContent($message); return $result; }
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; }
function run($dbi, $argstr, &$request, $basepage) { if (!$basepage) { return $this->error("{$basepage} unset?"); } include_once "lib/BlockParser.php"; $page = $request->getPage($basepage); return HTML::div(array('class' => 'boxright'), TransformText($argstr)); }
function RemovePage(&$request) { global $WikiTheme; $page = $request->getPage(); $pagelink = WikiLink($page); if ($request->getArg('cancel')) { $request->redirect(WikiURL($page)); // noreturn } $current = $page->getCurrentRevision(); if (!$current or !($version = $current->getVersion())) { $html = HTML(HTML::h2(_("Already deleted")), HTML::p(_("Sorry, this page is not in the database."))); } elseif (!$request->isPost() || !$request->getArg('verify')) { $removeB = Button('submit:verify', _("Remove Page"), 'wikiadmin'); $cancelB = Button('submit:cancel', _("Cancel"), 'button'); // use generic wiki button look $html = HTML(HTML::h2(fmt("You are about to remove '%s'!", $pagelink)), HTML::form(array('method' => 'post', 'action' => $request->getPostURL()), HiddenInputs(array('currentversion' => $version, 'pagename' => $page->getName(), 'action' => 'remove')), HTML::div(array('class' => 'toolbar'), $removeB, $WikiTheme->getButtonSeparator(), $cancelB)), HTML::hr()); $sample = HTML::div(array('class' => 'transclusion')); // simple and fast preview expanding only newlines foreach (explode("\n", firstNWordsOfContent(100, $current->getPackedContent())) as $s) { $sample->pushContent($s, HTML::br()); } $html->pushContent(HTML::div(array('class' => 'wikitext'), $sample)); } elseif ($request->getArg('currentversion') != $version) { $html = HTML(HTML::h2(_("Someone has edited the page!")), HTML::p(fmt("Since you started the deletion process, someone has saved a new version of %s. Please check to make sure you still want to permanently remove the page from the database.", $pagelink))); } else { // Codendi specific: remove the deleted wiki page from ProjectWantedPages $projectPageName = 'ProjectWantedPages'; $pagename = $page->getName(); $dbi = $request->getDbh(); require_once PHPWIKI_DIR . "/lib/loadsave.php"; $pagehandle = $dbi->getPage($projectPageName); if ($pagehandle->exists()) { // don't replace default contents $current = $pagehandle->getCurrentRevision(); $version = $current->getVersion(); $text = $current->getPackedContent(); $meta = $current->_data; } $text = str_replace("* [{$pagename}]", "", $text); $meta['summary'] = $GLOBALS['Language']->getText('wiki_lib_wikipagewrap', 'page_added', array($pagename)); $meta['author'] = user_getname(); $pagehandle->save($text, $version + 1, $meta); //Codendi specific: remove permissions for this page @codenditodo: may be transferable otherwhere. require_once 'common/wiki/lib/WikiPage.class.php'; $wiki_page = new WikiPage(GROUP_ID, $_REQUEST['pagename']); $wiki_page->resetPermissions(); // Real delete. //$pagename = $page->getName(); $dbi = $request->getDbh(); $dbi->deletePage($pagename); $dbi->touch(); $link = HTML::a(array('href' => 'javascript:history.go(-2)'), _("Back to the previous page.")); $html = HTML(HTML::h2(fmt("Removed page '%s' successfully.", $pagename)), HTML::div($link), HTML::hr()); } GeneratePage($html, _("Remove Page")); }
public function __construct($user = null) { if ($user) { $linksLeft = ['home' => '/', 'records' => '/records', 'totals' => '/totals', 'todos' => '/todos']; $linksRight = ['logout' => '/login', $user->__toString() => '/user']; } else { $linksLeft = ['home' => '/']; $linksRight = ['login' => '/login', 'register' => '/user']; } $this->menu = HTML::div(['.menuBar'], HTML::div(['.menuLeft'], HTML::menu($linksLeft)) . HTML::div(['.menuRight'], HTML::menu($linksRight))); }
function Textarea($textarea, $wikitext, $name = 'edit[content]') { global $request; $htmltextid = $this->_htmltextid; $textarea->SetAttr('id', $htmltextid); $iframe0 = new RawXml('<iframe id="iframe0" src="blank.htm" height="0" width="0" frameborder="0"></iframe>'); if ($request->getArg('mode') and $request->getArg('mode') == 'wysiwyg') { $out = HTML(HTML::div(array('class' => 'hint'), _("Warning: This Wikiwyg editor has only Beta quality!")), $textarea, $iframe0, "\n"); } else { $out = HTML($textarea, $iframe0, "\n"); } return $out; }
function chmarkupPages(&$dbi, &$request, $pages, $newmarkup) { $result = HTML::div(); $ul = HTML::ul(); $count = 0; foreach ($pages as $name) { $page = $dbi->getPage($name); $current = $page->getCurrentRevision(); $markup = $current->get('markup'); if (!$markup or $newmarkup != $markup) { if (!mayAccessPage('change', $name)) { $result->setAttr('class', 'error'); $result->pushContent(HTML::p(fmt("Access denied to change page '%s'.", WikiLink($name)))); } else { $version = $current->getVersion(); $meta = $current->_data; $meta['markup'] = $newmarkup; // convert text? $text = $current->getPackedContent(); $meta['summary'] = sprintf(_("Change markup type from %s to %s"), $markup, $newmarkup); $meta['is_minor_edit'] = 1; $meta['author'] = $request->_user->UserName(); unset($meta['mtime']); // force new date $page->save($text, $version + 1, $meta); $current = $page->getCurrentRevision(); if ($current->get('markup') === $newmarkup) { $ul->pushContent(HTML::li(fmt("change page '%s' to markup type '%s'.", WikiLink($name), $newmarkup))); $count++; } else { $ul->pushContent(HTML::li(fmt("Couldn't change page '%s' to markup type '%s'.", WikiLink($name), $newmarkup))); } } } } if ($count) { $dbi->touch(); $result->setAttr('class', 'feedback'); if ($count == 1) { $result->pushContent(HTML::p("One page has been permanently changed:")); } else { $result->pushContent(HTML::p(fmt("%s pages have been permanently changed:", $count))); } $result->pushContent($ul); return $result; } else { $result->setAttr('class', 'error'); $result->pushContent(HTML::p("No pages changed.")); return $result; } }
function Textarea_PHP($textarea, $wikitext, $name = 'edit[content]') { global $LANG; $this->FilePath = realpath(PHPWIKI_DIR . '/themes/default/FCKeditor') . "/"; $htmltextid = "edit-content"; include_once $this->FilePath . 'fckeditor.php'; $this->oFCKeditor = new FCKeditor($htmltextid); $this->oFCKeditor->BasePath = $this->BasePath; $this->oFCKeditor->Value = $textarea->_content[0]->asXML(); $this->oFCKeditor->Config['AutoDetectLanguage'] = true; $this->oFCKeditor->Config['DefaultLanguage'] = $LANG; $this->oFCKeditor->Create(); return HTML::div(array("id" => $this->_wikitextid, 'style' => 'display:none'), $wikitext); }
function run($dbi, $argstr, &$request, $basepage) { $args = $this->getArgs($argstr, $request); if (empty($this->source)) { return HTML::div(array('class' => "error"), "Please provide a formula to AsciiMath plugin"); } if (phpversion() >= '5') { include "lib/ASCIIMathPHP/ASCIIMathPHP-2.0.cfg.php"; } else { include "lib/ASCIIMathPHP/ASCIIMathPHP.cfg.php"; } $ascii_math = new ASCIIMathPHP($symbol_arr, $this->source); $ascii_math->genMathML(); return HTML::raw($ascii_math->getMathML()); }
function chownPages(&$dbi, &$request, $pages, $newowner) { $result = HTML::div(); $ul = HTML::ul(); $count = 0; foreach ($pages as $name) { $page = $dbi->getPage($name); $current = $page->getCurrentRevision(); if ($owner = $page->getOwner() and $newowner != $owner) { if (!mayAccessPage('change', $name)) { $ul->pushContent(HTML::li(fmt("Access denied to change page '%s'.", WikiLink($name)))); } else { $version = $current->getVersion(); $meta = $current->_data; $text = $current->getPackedContent(); $meta['summary'] = "Change page owner from '" . $owner . "' to '" . $newowner . "'"; $meta['is_minor_edit'] = 1; $meta['author'] = $request->_user->UserName(); unset($meta['mtime']); // force new date $page->set('owner', $newowner); $page->save($text, $version + 1, $meta); if ($page->get('owner') === $newowner) { $ul->pushContent(HTML::li(fmt("Change owner of page '%s' to '%s'.", WikiLink($name), WikiLink($newowner)))); $count++; } else { $ul->pushContent(HTML::li(fmt("Could not change owner of page '%s' to '%s'.", WikiLink($name), $newowner))); } } } } if ($count) { $dbi->touch(); $result->setAttr('class', 'feedback'); if ($count == 1) { $result->pushContent(HTML::p("One page has been permanently changed:")); } else { $result->pushContent(HTML::p(fmt("%s pages have been permanently changed:", $count))); } $result->pushContent($ul); return $result; } else { $result->setAttr('class', 'error'); $result->pushContent(HTML::p("No pages changed.")); return $result; } }
function setExternalPages(&$dbi, &$request, $pages) { $result = HTML::div(); $ul = HTML::ul(); $count = 0; foreach ($pages as $name) { $page = $dbi->getPage($name); $current = $page->getCurrentRevision(); $external = $current->get('external'); if (!$external) { $external = 0; } $external = (bool) $external; if (!$external) { if (!mayAccessPage('change', $name)) { $result->setAttr('class', 'error'); $result->pushContent(HTML::p(fmt("Access denied to change page '%s'.", WikiLink($name)))); } else { $version = $current->getVersion(); $page->set('external', (bool) 1); $ul->pushContent(HTML::li(fmt("change page '%s' to external.", WikiLink($name)))); $count++; } } } if ($count) { $dbi->touch(); $result->setAttr('class', 'feedback'); if ($count == 1) { $result->pushContent(HTML::p("One page has been permanently changed:")); } else { $result->pushContent(HTML::p(fmt("%s pages have been permanently changed:", $count))); } $result->pushContent($ul); return $result; } else { $result->setAttr('class', 'error'); $result->pushContent(HTML::p("No pages changed.")); return $result; } }
function run($dbi, $argstr, &$request, $basepage) { if (!ACCESS_LOG) { return HTML::div(array('class' => "error"), "Error: no ACCESS_LOG"); } $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 Textarea($textarea, $wikitext, $name = 'edit[content]') { // global $LANG, $WikiTheme; $id = "spaw_editor"; /*SPAW_Wysiwyg( $control_name='spaweditor', // control's name $value='', // initial value $lang='', // language $mode = '', // toolbar mode $theme='', // theme (skin) $width='100%', // width $height='300px', // height $css_stylesheet='', // css stylesheet file for content $dropdown_data='' // data for dropdowns (style, font, etc.) */ $this->SPAW = new SPAW_Wysiwyg($id, $textarea->_content); $textarea->SetAttr('id', $name); $this->SPAW->show(); $out = HTML::div(array("id" => $id, 'style' => 'display:none'), $wikitext); return $out; }
function run($dbi, $argstr, &$request, $basepage) { global $WikiTheme; $args = $this->getArgs($argstr, $request, false); $page =& $args['page']; if (ENABLE_AJAX) { if ($args['state']) { $html = WikiPlugin_IncludePage::run($dbi, $argstr, $request, $basepage); } else { $html = HTML(HTML::p(array('class' => 'transclusion-title'), fmt(" %s :", WikiLink($page))), HTML::div(array('class' => 'transclusion'), '')); } $ajaxuri = WikiURL($page, array('format' => 'xml')); } else { $html = WikiPlugin_IncludePage::run($dbi, $argstr, $request, $basepage); } $header = $html->_content[0]; $body = $html->_content[1]; $id = 'DynInc-' . MangleXmlIdentifier($page); $body->setAttr('id', $id . '-body'); $png = $WikiTheme->_findData('images/folderArrow' . ($args['state'] ? 'Open' : 'Closed') . '.png'); $icon = HTML::img(array('id' => $id . '-img', 'src' => $png, 'onclick' => ENABLE_AJAX ? "showHideAsync('" . $ajaxuri . "','{$id}')" : "showHideFolder('{$id}')", 'alt' => _("Click to hide/show"), 'title' => _("Click to hide/show"))); $header = HTML::p(array('class' => 'transclusion-title', 'style' => "text-decoration: none;"), $icon, fmt(" %s :", WikiLink($page))); if ($args['state']) { // show base $body->setAttr('style', 'display:block'); return HTML($header, $body); } else { // do not show base $body->setAttr('style', 'display:none'); if (ENABLE_AJAX) { return HTML($header, $body); } else { return HTML($header, $body); } // sync (load but display:none) } }
function run($dbi, $argstr, &$request, $basepage) { $args = $this->getArgs($argstr, $request); if (empty($args['s']) and isset($request->_searchhighlight)) { $args['s'] = $request->_searchhighlight['query']; } if (empty($args['s'])) { return ''; } extract($args); $html = HTML(); if (!$noheader and isset($request->_searchhighlight)) { $engine = $request->_searchhighlight['engine']; $html->pushContent(HTML::div(array('class' => 'search-context'), fmt("%s: Found %s through %s", $basepage, $request->_searchhighlight['query'], $engine))); } if ($hits) { $query = new TextSearchQuery($s, $case_exact, $regex); $lines = array(); $hilight_re = $query->getHighlightRegexp(); $page = $request->getPage(); $html->pushContent($this->showhits($page, $hilight_re)); } return $html; }
function run($dbi, $argstr, &$request, $basepage) { extract($this->getArgs($argstr, $request)); if (defined('CHARSET')) { $rss_parser = new RSSParser(CHARSET); } else { $rss_parser = new RSSParser(); } if (!empty($url)) { $rss_parser->parse_url($url, $debug); } if (!empty($rss_parser->channel['title'])) { $feed = $rss_parser->channel['title']; } if (!empty($rss_parser->channel['link'])) { $url = $rss_parser->channel['link']; } if (!empty($rss_parser->channel['description'])) { $description = $rss_parser->channel['description']; } if (!empty($feed)) { if (!empty($url)) { $titre = HTML::span(HTML::a(array('href' => $rss_parser->channel['link']), $rss_parser->channel['title'])); } else { $titre = HTML::span($rss_parser->channel['title']); } $th = HTML::div(array('class' => 'feed'), $titre); if (!empty($description)) { $th->pushContent(HTML::p(array('class' => 'chandesc'), HTML::raw($description))); } } else { $th = HTML(); } if (!empty($rss_parser->channel['date'])) { $th->pushContent(HTML::raw("<!--" . $rss_parser->channel['date'] . "-->")); } $html = HTML::div(array('class' => 'rss'), $th); if ($rss_parser->items) { // only maxitem's if ($maxitem > 0) { $rss_parser->items = array_slice($rss_parser->items, 0, $maxitem); } foreach ($rss_parser->items as $item) { $cell = HTML::div(array('class' => 'rssitem')); if ($item['link'] and empty($item['title'])) { $item['title'] = $item['link']; } $cell_title = HTML::div(array('class' => 'itemname'), HTML::a(array('href' => $item['link']), HTML::raw($item['title']))); $cell->pushContent($cell_title); $cell_author = HTML::raw($item['author']); $cell_pubDate = HTML::raw($item['pubDate']); $cell_authordate = HTML::div(array('class' => 'authordate'), $cell_author, HTML::raw(" - "), $cell_pubDate); $cell->pushContent($cell_authordate); if (!$titleonly && !empty($item['description'])) { $cell->pushContent(HTML::div(array('class' => 'itemdesc'), HTML::raw($item['description']))); } $html->pushContent($cell); } } else { $html = HTML::div(array('class' => 'rss'), HTML::em(_("no RSS items"))); } if (!check_php_version(5)) { $rss_parser->__destruct(); } return $html; }
function handleAction() { $action = $this->getArg('action'); if ($this->isPost() and !$this->_user->isAdmin() and $action != 'browse') { $page = $this->getPage(); if ($page->get('moderation')) { require_once "lib/WikiPlugin.php"; $loader = new WikiPluginLoader(); $plugin = $loader->getPlugin("ModeratedPage"); if ($plugin->handler($this, $page)) { $CONTENT = HTML::div(array('class' => 'wiki-edithelp'), fmt("%s: action forwarded to a moderator.", $action), HTML::br(), _("This action requires moderator approval. Please be patient.")); if (!empty($plugin->_tokens['CONTENT'])) { $plugin->_tokens['CONTENT']->pushContent(HTML::br(), _("You must wait for moderator approval.")); } else { $plugin->_tokens['CONTENT'] = $CONTENT; } require_once "lib/Template.php"; $title = WikiLink($page->getName()); $title->pushContent(' : ', WikiLink(_("ModeratedPage"))); GeneratePage(Template('browse', $plugin->_tokens), $title, $page->getCurrentRevision()); $this->finish(); } } } $method = "action_{$action}"; if (method_exists($this, $method)) { $this->{$method}(); } elseif ($page = $this->findActionPage($action)) { $this->actionpage($page); } else { $this->finish(fmt("%s: Bad action", $action)); } }
function run($dbi, $argstr, &$request, $basepage) { $this->allowed_extensions = explode("\n", "7z\navi\nbmp\nbz2\nc\ncfg\ndiff\ndoc\ndocx\nflv\ngif\nh\nics\nini\njpeg\njpg\nkmz\nmp3\nodg\nodp\nods\nodt\nogg\npatch\npdf\npng\nppt\npptx\nrar\nsvg\ntar\ntar.gz\ntxt\nxls\nxlsx\nxml\nxsd\nzip"); $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\\d?\nphtml\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(); $file_dir .= "/"; $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))); $contents->pushContent(HTML::input(array('name' => 'userfile', 'type' => 'file', 'size' => $size))); if ($mode == 'edit') { $contents->pushContent(HTML::input(array('name' => 'action', 'type' => 'hidden', 'value' => 'edit'))); $contents->pushContent(HTML::raw(" ")); $contents->pushContent(HTML::input(array('value' => _("Upload"), 'name' => 'edit[upload]', 'type' => 'submit'))); } else { $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()) { if (defined('FUSIONFORGE') and FUSIONFORGE) { $message->pushContent(HTML::div(array('class' => 'error'), HTML::p(_("You cannot upload files.")), HTML::ul(HTML::li(_("Check you are logged in.")), HTML::li(_("Check you are in the right project.")), HTML::li(_("Check you are a member of the current project."))))); } else { $message->pushContent(HTML::div(array('class' => 'error'), HTML::p(_("ACCESS DENIED: You must log in to upload files.")))); } $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)); if (UPLOAD_USERDIR) { $file_dir .= $request->_user->_userid; if (!file_exists($file_dir)) { mkdir($file_dir, 0775); } $file_dir .= "/"; $u_userfile = $request->_user->_userid . "/" . $userfile_name; } else { $u_userfile = $userfile_name; } $u_userfile = preg_replace("/ /", "%20", $u_userfile); $userfile_tmpname = $userfile->getTmpName(); $err_header = HTML::div(array('class' => 'error'), HTML::p(fmt("ERROR uploading '%s'", $userfile_name))); if (preg_match("/(\\." . join("|\\.", $this->disallowed_extensions) . ")(\\.|\$)/i", $userfile_name)) { $message->pushContent($err_header); $message->pushContent(HTML::p(fmt("Files with extension %s are not allowed.", join(", ", $this->disallowed_extensions)))); } elseif (!DISABLE_UPLOAD_ONLY_ALLOWED_EXTENSIONS and !preg_match("/(\\." . join("|\\.", $this->allowed_extensions) . ")\$/i", $userfile_name)) { $message->pushContent($err_header); $message->pushContent(HTML::p(fmt("Only files with the extension %s are allowed.", join(", ", $this->allowed_extensions)))); } elseif (preg_match("/[^._a-zA-Z0-9- ]/", strip_accents($userfile_name))) { $message->pushContent($err_header); $message->pushContent(HTML::p(_("Invalid filename. File names may only contain alphanumeric characters and dot, underscore, space or dash."))); } elseif (file_exists($file_dir . $userfile_name)) { $message->pushContent($err_header); $message->pushContent(HTML::p(fmt("There is already a file with name %s uploaded.", $u_userfile))); } elseif ($userfile->getSize() > MAX_UPLOAD_SIZE) { $message->pushContent($err_header); $message->pushContent(HTML::p(_("Sorry but this file is too big."))); } elseif (move_uploaded_file($userfile_tmpname, $file_dir . $userfile_name) or IsWindows() and rename($userfile_tmpname, $file_dir . $userfile_name)) { $interwiki = new PageType_interwikimap(); $link = $interwiki->link("Upload:{$u_userfile}"); $message->pushContent(HTML::div(array('class' => 'feedback'), HTML::p(_("File successfully uploaded.")), HTML::p($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:{$u_userfile}"; // don't inline images $meta = $current->_data; $meta['summary'] = sprintf(_("uploaded %s"), $u_userfile); $pagehandle->save($newtext, $version + 1, $meta); } } } else { $message->pushContent($err_header); $message->pushContent(HTML::br(), _("Uploading failed."), HTML::br()); } } else { $message->pushContent(HTML::br(), _("No file selected. Please select one."), HTML::br()); } //$result = HTML::div( array( 'class' => 'wikiaction' ) ); $result = HTML(); $result->pushContent($form); $result->pushContent($message); return $result; }
function format($changes) { $this->_args['daylist'] = false; //don't show day buttons in Mozilla sidebar $html = _RecentChanges_HtmlFormatter::format($changes); $html = HTML::div(array('class' => 'wikitext'), $html); global $request; $request->discardOutput(); printf("<?xml version=\"1.0\" encoding=\"%s\"?>\n", $GLOBALS['charset']); printf('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"'); printf(' "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">'); printf('<html xmlns="http://www.w3.org/1999/xhtml">'); printf("<head>\n"); extract($this->_args); if (!empty($category)) { $title = $category; } elseif (!empty($pagematch)) { $title = $pagematch; } else { $title = WIKI_NAME . $show_minor ? _("RecentEdits") : _("RecentChanges"); } printf("<title>" . $title . "</title>\n"); global $WikiTheme; $css = $WikiTheme->getCSS(); $css->PrintXML(); printf("</head>\n"); printf("<body class=\"sidebar\">\n"); $html->PrintXML(); echo '<a href="http://www.feedvalidator.org/check.cgi?url=http://phpwiki.org/RecentChanges?format=rss"><img src="themes/default/buttons/valid-rss.png" alt="[Valid RSS]" title="Validate the RSS feed" width="44" height="15" /></a>'; printf("\n</body>\n"); printf("</html>\n"); $request->finish(); // cut rest of page processing short }
function displayPage(&$request, $template = false) { global $WikiTheme, $pv; $pagename = $request->getArg('pagename'); $version = $request->getArg('version'); $page = $request->getPage(); if ($version) { $revision = $page->getRevision($version); if (!$revision) { NoSuchRevision($request, $page, $version); } } else { $revision = $page->getCurrentRevision(); } if (isSubPage($pagename)) { $pages = explode(SUBPAGE_SEPARATOR, $pagename); $last_page = array_pop($pages); // deletes last element from array as side-effect $pageheader = HTML::span(HTML::a(array('href' => WikiURL($pages[0]), 'class' => 'pagetitle'), $WikiTheme->maybeSplitWikiWord($pages[0] . SUBPAGE_SEPARATOR))); $first_pages = $pages[0] . SUBPAGE_SEPARATOR; array_shift($pages); foreach ($pages as $p) { if ($pv != 2) { //Add the Backlink in page title $pageheader->pushContent(HTML::a(array('href' => WikiURL($first_pages . $p), 'class' => 'backlinks'), $WikiTheme->maybeSplitWikiWord($p . SUBPAGE_SEPARATOR))); } else { // Remove Backlinks $pageheader->pushContent(HTML::h1($pagename)); } $first_pages .= $p . SUBPAGE_SEPARATOR; } if ($pv != 2) { $backlink = HTML::a(array('href' => WikiURL($pagename, array('action' => _("BackLinks"))), 'class' => 'backlinks'), $WikiTheme->maybeSplitWikiWord($last_page)); $backlink->addTooltip(sprintf(_("BackLinks for %s"), $pagename)); } else { $backlink = HTML::h1($pagename); } $pageheader->pushContent($backlink); } else { if ($pv != 2) { $pageheader = HTML::a(array('href' => WikiURL($pagename, array('action' => _("BackLinks"))), 'class' => 'backlinks'), $WikiTheme->maybeSplitWikiWord($pagename)); $pageheader->addTooltip(sprintf(_("BackLinks for %s"), $pagename)); } else { $pageheader = HTML::h1($pagename); //Remove Backlinks } if ($request->getArg('frame')) { $pageheader->setAttr('target', '_top'); } } // {{{ Codendi hook to insert stuff between navbar and header $eM =& EventManager::instance(); $ref_html = ''; $crossref_fact = new CrossReferenceFactory($pagename, ReferenceManager::REFERENCE_NATURE_WIKIPAGE, GROUP_ID); $crossref_fact->fetchDatas(); if ($crossref_fact->getNbReferences() > 0) { $ref_html .= '<h3>' . $GLOBALS['Language']->getText('cross_ref_fact_include', 'references') . '</h3>'; $ref_html .= $crossref_fact->getHTMLDisplayCrossRefs(); } $additional_html = false; $eM->processEvent('wiki_before_content', array('html' => &$additional_html, 'group_id' => GROUP_ID, 'wiki_page' => $pagename)); if ($additional_html) { $beforeHeader = HTML(); $beforeHeader->pushContent($additional_html); $beforeHeader->pushContent(HTML::raw($ref_html)); $toks['BEFORE_HEADER'] = $beforeHeader; } else { $beforeHeader = HTML(); $beforeHeader->pushContent(HTML::raw($ref_html)); $toks['BEFORE_HEADER'] = $beforeHeader; } // }}} /Codendi hook $pagetitle = SplitPagename($pagename); if ($redirect_from = $request->getArg('redirectfrom')) { $redirect_message = HTML::span(array('class' => 'redirectfrom'), fmt("(Redirected from %s)", RedirectorLink($redirect_from))); // abuse the $redirected template var for some status update notice } elseif ($request->getArg('errormsg')) { $redirect_message = $request->getArg('errormsg'); $request->setArg('errormsg', false); } $request->appendValidators(array('pagerev' => $revision->getVersion(), '%mtime' => $revision->get('mtime'))); /* // FIXME: This is also in the template... if ($request->getArg('action') != 'pdf' and !headers_sent()) { // FIXME: enable MathML/SVG/... support if (ENABLE_XHTML_XML and (!isBrowserIE() and strstr($request->get('HTTP_ACCEPT'),'application/xhtml+xml'))) header("Content-Type: application/xhtml+xml; charset=" . $GLOBALS['charset']); else header("Content-Type: text/html; charset=" . $GLOBALS['charset']); } */ $page_content = $revision->getTransformedContent(); // if external searchengine (google) referrer, highlight the searchterm // FIXME: move that to the transformer? // OR: add the searchhightplugin line to the content? if ($result = isExternalReferrer($request)) { if (DEBUG and !empty($result['query'])) { //$GLOBALS['SearchHighlightQuery'] = $result['query']; /* simply add the SearchHighlight plugin to the top of the page. This just parses the wikitext, and doesn't highlight the markup */ include_once 'lib/WikiPlugin.php'; $loader = new WikiPluginLoader(); $xml = $loader->expandPI('<' . '?plugin SearchHighlight s="' . $result['query'] . '"?' . '>', $request, $markup); if ($xml and is_array($xml)) { foreach (array_reverse($xml) as $line) { array_unshift($page_content->_content, $line); } array_unshift($page_content->_content, HTML::div(_("You searched for: "), HTML::strong($result['query']))); } if (0) { /* Parse the transformed (mixed HTML links + strings) lines? This looks like overkill. */ require_once "lib/TextSearchQuery.php"; $query = new TextSearchQuery($result['query']); $hilight_re = $query->getHighlightRegexp(); //$matches = preg_grep("/$hilight_re/i", $revision->getContent()); // FIXME! for ($i = 0; $i < count($page_content->_content); $i++) { $found = false; $line = $page_content->_content[$i]; if (is_string($line)) { while (preg_match("/^(.*?)({$hilight_re})/i", $line, $m)) { $found = true; $line = substr($line, strlen($m[0])); $html[] = $m[1]; // prematch $html[] = HTML::strong(array('class' => 'search-term'), $m[2]); // match } } if ($found) { $html[] = $line; // postmatch $page_content->_content[$i] = HTML::span(array('class' => 'search-context'), $html); } } } } } $toks['CONTENT'] = new Template('browse', $request, $page_content); $toks['TITLE'] = $pagetitle; // <title> tag $toks['HEADER'] = $pageheader; // h1 with backlink $toks['revision'] = $revision; if (!empty($redirect_message)) { $toks['redirected'] = $redirect_message; } $toks['ROBOTS_META'] = 'index,follow'; $toks['PAGE_DESCRIPTION'] = $page_content->getDescription(); $toks['PAGE_KEYWORDS'] = GleanKeywords($page); if (!$template) { $template = new Template('html', $request); } $template->printExpansion($toks); $page->increaseHitCount(); if ($request->getArg('action') != 'pdf') { $request->checkValidators(); } flush(); }
function _lines($lines, $class, $prefix = false, $elem = false) { if (!$prefix) { $prefix = HTML::raw(' '); } $div = HTML::div(array('class' => 'difftext')); foreach ($lines as $line) { if ($elem) { $line = new HtmlElement($elem, $line); } $div->pushContent(HTML::div(array('class' => $class), HTML::tt(array('class' => 'prefix'), $prefix), $line, HTML::raw(' '))); } $this->_block->pushContent($div); }
function wiki_before_content() { $wiki_page = $this->request->get('wiki_page'); $group_id = $this->request->get('group_id'); $item_dao =& $this->_getItemDao(); $docman_references = HTML(); // Add js part for toogling referencers section. $js_code = ' function toggle_documents(id) { Element.toggle(id); toggle_image(id); } function toggle_image(id) { var img_element = $(\'img_\' + id); if (img_element.src.indexOf(\'' . util_get_image_theme("ic/toggle_plus.png") . '\') != -1) { img_element.src = \'' . util_get_image_theme("ic/toggle_minus.png") . '\'; img_element.title = \'' . $GLOBALS['Language']->getText('plugin_docman', 'docman_wiki_hide_referencers') . '\'; } else { img_element.src = \'' . util_get_image_theme("ic/toggle_plus.png") . '\'; img_element.title = \'' . $GLOBALS['Language']->getText('plugin_docman', 'docman_wiki_open_referencers') . '\'; } } '; $docman_references->pushContent(HTML::script(array('type' => 'text/javascript'), $js_code)); if ($item_dao->isWikiPageReferenced($wiki_page, $group_id)) { $docman_item_id = $item_dao->getItemIdByWikiPageAndGroupId($wiki_page, $group_id); if ($this->referrerIsDocument()) { $referrer_id = $this->getReferrerId($this->getReferrer()); } if (isset($docman_item_id) && $docman_item_id) { $content = HTML(); $script = HTML::script(array('type' => 'text/javascript'), "toggle_documents('documents');"); $user =& $this->getUser(); $dpm =& Docman_PermissionsManager::instance($group_id); // Wiki page could have many references in docman. if (is_array($docman_item_id)) { $icon = HTML::img(array('id' => 'img_documents', 'src' => util_get_image_theme("ic/toggle_minus.png"), 'title' => $GLOBALS['Language']->getText('plugin_docman', 'docman_wiki_open_referencers'))); $linked_icon = HTML::a(array('href' => "#", 'onclick' => "javascript:toggle_documents('documents'); return false;"), $icon); // creating the title of the section regarding number of referencing documents and from where we arrived to this wiki page. if (count($docman_item_id) > 1) { $title = ""; if (isset($referrer_id) && $referrer_id) { $title = HTML::strong($GLOBALS['Language']->getText('plugin_docman', 'breadcrumbs_location') . " "); } else { $title = HTML::strong($GLOBALS['Language']->getText('plugin_docman', 'docman_wiki_breadcrumbs_locations') . " "); } } else { if (count($docman_item_id) == 1) { $title = HTML::strong($GLOBALS['Language']->getText('plugin_docman', 'breadcrumbs_location') . " "); } else { $title = ""; } } //create Full legend of the section $legend = HTML::legend(array('class' => 'docman_md_frame'), count($docman_item_id) > 1 ? $linked_icon : "", $title, isset($referrer_id) && $referrer_id ? HTML($this->showReferrerPath($referrer_id, $group_id)) : ""); $details = HTML(); // create section body. if (isset($referrer_id) && $referrer_id) { if (count($docman_item_id) > 2) { $details->pushContent(HTML::H3($GLOBALS['Language']->getText('plugin_docman', 'docman_wiki_other_locations') . " ")); } else { if (count($docman_item_id) == 2) { $details->pushContent(HTML::H3($GLOBALS['Language']->getText('plugin_docman', 'docman_wiki_other_location') . " ")); } } } // create Referencing documents linked paths. foreach ($docman_item_id as $index => $value) { $details->pushContent($this->getDocumentPath($value, $group_id, isset($referrer_id) && $referrer_id ? $referrer_id : null)); } $content->pushContent(HTML::div(array('id' => 'documents'), $details)); if (count($docman_item_id) == 1) { $id = array_pop($docman_item_id); $docman_references->pushContent(HTML::strong($GLOBALS['Language']->getText('plugin_docman', 'breadcrumbs_location') . " ")); $docman_references->pushContent(HTML($this->getDocumentPath($id, $group_id))); $docman_references->pushContent(HTML::br()); } else { $docman_references->pushContent(HTML::br()); $docman_references->pushContent(HTML::fieldset(array('class' => 'docman_md_frame'), $legend, $content, $script)); } } else { if ($dpm->userCanAccess($user, $docman_item_id)) { $docman_references->pushContent(HTML::strong($GLOBALS['Language']->getText('plugin_docman', 'breadcrumbs_location') . " ")); $docman_references->pushContent(HTML($this->getDocumentPath($docman_item_id, $group_id))); //$docman_references->pushContent(HTML::br()); } } } } // Write documents paths on wiki view. // TODO: find another way to return a value. // Codendi_Request->params should not be public $this->request->params['html'] = $docman_references; }
function run($dbi, $argstr, &$request, $basepage) { extract($this->getArgs($argstr, $request)); if (empty($action)) { return $this->error(fmt("A required argument '%s' is missing.", "action")); } $form = HTML::form(array('action' => $request->getPostURL(), 'method' => strtolower($method), 'class' => 'wikiaction', 'accept-charset' => $GLOBALS['charset']), HiddenInputs(array('action' => $action, 'group_id' => GROUP_ID))); $nbsp = HTML::Raw(' '); $already_submit = 0; foreach ($this->inputbox as $inputbox) { foreach ($inputbox as $inputtype => $input) { if ($inputtype == 'radiobutton') { $inputtype = 'radio'; } // convert from older versions $input['type'] = $inputtype; $text = ''; if ($inputtype != 'submit') { if (empty($input['name'])) { return $this->error(fmt("A required argument '%s' is missing.", $inputtype . "[][name]")); } if (!isset($input['text'])) { $input['text'] = gettext($input['name']); } $text = $input['text']; unset($input['text']); } switch ($inputtype) { case 'checkbox': case 'radio': if (empty($input['value'])) { $input['value'] = 1; } if (is_array($input['value'])) { $div = HTML::div(array('class' => $class)); $values = $input['value']; $name = $input['name']; $input['name'] = $inputtype == 'checkbox' ? $name . "[]" : $name; foreach ($values as $val) { $input['value'] = $val; if ($request->getArg($name)) { if ($request->getArg($name) == $val) { $input['checked'] = 'checked'; } else { unset($input['checked']); } } $div->pushContent(HTML::input($input), $nbsp, $val, $nbsp, "\n"); if (!$nobr) { $div->pushContent(HTML::br()); } } $form->pushContent($div); } else { if (empty($input['checked'])) { if ($request->getArg($input['name'])) { $input['checked'] = 'checked'; } } else { $input['checked'] = 'checked'; } if ($nobr) { $form->pushContent(HTML::input($input), $nbsp, $text, $nbsp); } else { $form->pushContent(HTML::div(array('class' => $class), HTML::input($input), $text)); } } break; case 'editbox': $input['type'] = 'text'; if (empty($input['value']) and $s = $request->getArg($input['name'])) { $input['value'] = $s; } if ($nobr) { $form->pushContent(HTML::input($input), $nbsp, $text, $nbsp); } else { $form->pushContent(HTML::div(array('class' => $class), HTML::input($input), $text)); } break; case 'combobox': // TODO: moACDROPDOWN $values = $input['value']; unset($input['value']); $input['type'] = 'text'; if (is_string($values)) { $values = explode(",", $values); } if (empty($values)) { if ($input['method']) { $input['value'] = xmlrequest($input['method']); } elseif ($s = $request->getArg($input['name'])) { $input['value'] = $s; } } elseif (is_array($values)) { $name = $input['name']; unset($input['name']); foreach ($values as $val) { $input = array('value' => $val); if ($request->getArg($name)) { if ($request->getArg($name) == $val) { $input['selected'] = 'selected'; } else { unset($input['selected']); } } //$select->pushContent(HTML::option($input, $val)); } } if ($nobr) { $form->pushContent(HTML::input($input), $nbsp, $text, $nbsp); } else { $form->pushContent(HTML::div(array('class' => $class), HTML::input($input), $text)); } break; case 'pulldown': $values = $input['value']; unset($input['value']); unset($input['type']); $select = HTML::select($input); if (is_string($values)) { $values = explode(",", $values); } if (empty($values) and $s = $request->getArg($input['name'])) { $select->pushContent(HTML::option(array('value' => $s), $s)); } elseif (is_array($values)) { $name = $input['name']; unset($input['name']); foreach ($values as $val) { $input = array('value' => $val); if ($request->getArg($name)) { if ($request->getArg($name) == $val) { $input['selected'] = 'selected'; } else { unset($input['selected']); } } $select->pushContent(HTML::option($input, $val)); } } $form->pushContent($text, $nbsp, $select); break; case 'reset': case 'hidden': $form->pushContent(HTML::input($input)); break; // change the order of inputs, by explicitly placing a submit button here. // change the order of inputs, by explicitly placing a submit button here. case 'submit': //$input['type'] = 'submit'; if (empty($input['value'])) { $input['value'] = $buttontext ? $buttontext : $action; } unset($input['text']); if (empty($input['class'])) { $input['class'] = $class; } if ($nobr) { $form->pushContent(HTML::input($input), $nbsp, $text, $nbsp); } else { $form->pushContent(HTML::div(array('class' => $class), HTML::input($input), $text)); } // unset the default submit button $already_submit = 1; break; } } } if ($request->getArg('start_debug')) { $form->pushContent(HTML::input(array('name' => 'start_debug', 'value' => $request->getArg('start_debug'), 'type' => 'hidden'))); } if (!USE_PATH_INFO) { $form->pushContent(HiddenInputs(array('pagename' => $basepage))); } if (!$already_submit) { if (empty($buttontext)) { $buttontext = $action; } $submit = Button('submit:', $buttontext, $class); if ($cancel) { $form->pushContent(HTML::span(array('class' => $class), $submit, Button('submit:cancel', _("Cancel"), $class))); } else { $form->pushContent(HTML::span(array('class' => $class), $submit)); } } return $form; }
function _debug($tab, $msg) { //return ; $where = $this->where(); $tab = str_repeat('____', $this->getDepth()) . $tab; printXML(HTML::div("{$tab} {$msg}: at: '", HTML::tt($where), "'")); flush(); }