本文整理汇总了PHP中HTML::h2方法的典型用法代码示例。如果您正苦于以下问题:PHP HTML::h2方法的具体用法?PHP HTML::h2怎么用?PHP HTML::h2使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HTML
的用法示例。
在下文中一共展示了HTML::h2方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: RemovePage
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"));
}
示例2: run
function run($dbi, $argstr, &$request, $basepage)
{
extract($this->getArgs($argstr, $request));
$h = HTML();
$this->_generatePageheader($info, $h);
if (!REQUIRE_ADMIN || $request->_user->isadmin()) {
$h->pushContent(HTML::h2(_("Plugins")));
$table = HTML::table(array('class' => "pagelist"));
$this->_generateColheadings($info, $table);
$this->_generateTableBody($info, $dbi, $request, $table);
$h->pushContent($table);
} else {
$h->pushContent(fmt("You must be an administrator to %s.", _("use this plugin")));
}
return $h;
}
示例3: run
function run($dbi, $argstr, &$request, $basepage)
{
extract($this->getArgs($argstr, $request));
if (!$lang) {
return $this->error(_("This internal action page cannot viewed.") . "\n" . _("You can only use it via the _WikiTranslation plugin."));
}
$this->lang = $lang;
//action=save
if (!empty($translate) and isset($translate['submit']) and $request->isPost()) {
$trans = $translate["content"];
if (empty($trans) or $trans == $pagename) {
$header = HTML(HTML::h2(_("Translation Error!")), HTML::p(_("Your translated text is either empty or equal to the untranslated text. Please try again.")));
} else {
//save translation in a users subpage
$user = $request->getUser();
$homepage = $user->_HomePagehandle;
$transpagename = $homepage->getName() . SUBPAGE_SEPARATOR . _("ContributedTranslations");
$page = $dbi->getPage($transpagename);
$current = $page->getCurrentRevision();
$version = $current->getVersion();
if ($version) {
$text = $current->getPackedContent() . "\n";
$meta = $current->_data;
} else {
$text = '';
$meta = array('markup' => 2.0, 'author' => $user->getId());
}
$text .= $user->getId() . " " . Iso8601DateTime() . "\n" . "* " . sprintf(_("Translate '%s' to '%s' in *%s*"), $pagename, $trans, $lang);
$text .= "\n <verbatim>locale/po/{$lang}.po:\n msgid \"" . $pagename . "\"\n msgstr \"" . $trans . "\"\n </verbatim>";
$meta['summary'] = sprintf(_("Translate %s to %s in %s"), substr($pagename, 0, 15), substr($trans, 0, 15), $lang);
$page->save($text, $version + 1, $meta);
// TODO: admin notification
return HTML(HTML::h2(_("Thanks for adding this translation!")), HTML::p(fmt("Your translated text doesn't yet appear in this %s, but the Administrator will pick it up and add to the installation.", WIKI_NAME)), fmt("Your translation is stored in %s", WikiLink($transpagename)));
}
}
$trans = $this->translate($pagename, $lang, 'en');
//Todo: google lookup or at least a google lookup button.
if (isset($header)) {
$header = HTML($header, fmt("From english to %s: ", HTML::strong($lang)));
} else {
$header = fmt("From english to %s: ", HTML::strong($lang));
}
$button_label = _("Translate");
$buttons = HTML::p(Button('submit:translate[submit]', $button_label, 'wikiadmin'), Button('submit:translate[cancel]', _("Cancel"), 'button'));
return HTML::form(array('action' => $request->getPostURL(), 'method' => 'post'), $header, HTML::textarea(array('class' => 'wikiedit', 'name' => 'translate[content]', 'id' => 'translate[content]', 'rows' => 4, 'cols' => $request->getPref('editWidth')), $trans), HiddenInputs($request->getArgs(), false, array('translate')), HiddenInputs(array('translate[action]' => $pagename, 'require_authority_for_post' => WIKIAUTH_BOGO)), $buttons);
}
示例4: RemovePage
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 {
// 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"));
}
示例5: finish
function finish($errormsg = false)
{
static $in_exit = 0;
if ($in_exit) {
exit;
}
// just in case CloseDataBase calls us
$in_exit = true;
global $ErrorManager;
$ErrorManager->flushPostponedErrors();
if (!empty($errormsg)) {
PrintXML(HTML::br(), HTML::hr(), HTML::h2(_("Fatal PhpWiki Error")), $errormsg);
// HACK:
echo "\n</body></html>";
}
if (is_object($this->_user)) {
$this->_user->page = $this->getArg('pagename');
$this->_user->action = $this->getArg('action');
unset($this->_user->_HomePagehandle);
unset($this->_user->_auth_dbi);
}
Request::finish();
exit;
}
示例6: format
function format($changes)
{
include_once 'lib/InlineParser.php';
$html = HTML(HTML::h2(false, $this->headline()));
$lines = HTML::ol();
$first = true;
$count = 0;
while ($rev = $changes->next()) {
if (mayAccessPage('view', $rev->_pagename)) {
$lines->pushContent($this->format_revision($rev));
if ($first) {
$this->setValidators($rev);
}
$first = false;
}
$count++;
}
$this->_args['limit'] = $count;
if ($desc = $this->description()) {
$html->pushContent($desc);
}
if ($this->_args['daylist']) {
$html->pushContent(new OptionsButtonBars($this->_args));
}
if ($first) {
$html->pushContent(HTML::p(array('class' => 'rc-empty'), $this->empty_message()));
} else {
$html->pushContent($lines);
}
return $html;
}
示例7: format
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;
}
示例8: run
function run($dbi, $argstr, &$request, $basepage)
{
$args = $this->getArgs($argstr, $request);
$user =& $request->_user;
if (isa($request, 'MockRequest')) {
return '';
}
if (!$request->isActionPage($request->getArg('pagename')) and (!isset($user->_prefs->_method) or !in_array($user->_prefs->_method, array('ADODB', 'SQL'))) or in_array($request->getArg('action'), array('zip', 'ziphtml', 'dumphtml')) or isa($user, '_ForbiddenUser')) {
$no_args = $this->getDefaultArguments();
// ?
// foreach ($no_args as $key => $value) {
// $no_args[$value] = false;
// }
$no_args['errmsg'] = HTML(HTML::h2(_("Error: The user HomePage must be a valid WikiWord. Sorry, UserPreferences cannot be saved."), HTML::hr()));
$no_args['isForm'] = false;
return Template('userprefs', $no_args);
}
$userid = $user->UserName();
if ($user->isAuthenticated() and !empty($userid)) {
$pref =& $request->_prefs;
$args['isForm'] = true;
//trigger_error("DEBUG: reading prefs from getPreferences".print_r($pref));
if ($request->isPost()) {
$errmsg = '';
$delete = $request->getArg('delete');
if ($delete and $request->getArg('verify')) {
// deleting prefs, verified
$default_prefs = $pref->defaultPreferences();
$default_prefs['userid'] = $user->UserName();
$user->setPreferences($default_prefs);
$request->_setUser($user);
$request->setArg("verify", false);
$request->setArg("delete", false);
$alert = new Alert(_("Message"), _("Your UserPreferences have been successfully deleted."));
$alert->show();
return;
} elseif ($delete and !$request->getArg('verify')) {
return HTML::form(array('action' => $request->getPostURL(), 'method' => 'post'), HiddenInputs(array('verify' => 1)), HiddenInputs($request->getArgs()), HTML::p(_("Do you really want to delete all your UserPreferences?")), HTML::p(Button('submit:delete', _("Yes"), 'delete'), HTML::Raw(' '), Button('cancel', _("Cancel"))));
} elseif ($rp = $request->getArg('pref')) {
// replace only changed prefs in $pref with those from request
if (!empty($rp['passwd']) and $rp['passwd2'] != $rp['passwd']) {
$errmsg = _("Wrong password. Try again.");
} else {
//trigger_error("DEBUG: reading prefs from request".print_r($rp));
//trigger_error("DEBUG: writing prefs with setPreferences".print_r($pref));
if (empty($rp['passwd'])) {
unset($rp['passwd']);
}
// fix to set system pulldown's. empty values don't get posted
if (empty($rp['theme'])) {
$rp['theme'] = '';
}
if (empty($rp['lang'])) {
$rp['lang'] = '';
}
$num = $user->setPreferences($rp);
if (!empty($rp['passwd'])) {
$passchanged = false;
if ($user->mayChangePass()) {
if (method_exists($user, 'storePass')) {
$passchanged = $user->storePass($rp['passwd']);
}
if (!$passchanged and method_exists($user, 'changePass')) {
$passchanged = $user->changePass($rp['passwd']);
}
if ($passchanged) {
$errmsg = _("Password updated.");
} else {
$errmsg = _("Password was not changed.");
}
} else {
$errmsg = _("Password cannot be changed.");
}
}
if (!$num) {
$errmsg .= " " . _("No changes.");
} else {
$request->_setUser($user);
$pref = $user->_prefs;
$errmsg .= sprintf(_("%d UserPreferences fields successfully updated."), $num);
}
}
$args['errmsg'] = HTML(HTML::h2($errmsg), HTML::hr());
}
}
$args['available_themes'] = listAvailableThemes();
$args['available_languages'] = listAvailableLanguages();
return Template('userprefs', $args);
} else {
// wrong or unauthenticated user
return $request->_notAuthorized(WIKIAUTH_BOGO);
//return $user->PrintLoginForm ($request, $args, false, false);
}
}
示例9: NoSuchRevision
function NoSuchRevision(&$request, $page, $version)
{
$html = HTML(HTML::h2(_("Revision Not Found")), HTML::p(fmt("I'm sorry. Version %d of %s is not in the database.", $version, WikiLink($page, 'auto'))));
include_once 'lib/Template.php';
GeneratePage($html, _("Bad Version"), $page->getCurrentRevision());
$request->finish();
}
示例10: showDiff
//.........这里部分代码省略.........
$page = $request->getPage();
$current = $page->getCurrentRevision(false);
if ($current->getVersion() < 1) {
$html = HTML::div(array('class' => 'wikitext', 'id' => 'difftext'), HTML::p(fmt("I'm sorry, there is no such page as %s.", WikiLink($pagename, 'unknown'))));
require_once 'lib/Template.php';
GeneratePage($html, sprintf(_("Diff: %s"), $pagename), false);
return;
//early return
}
if ($version) {
if (!($new = $page->getRevision($version))) {
NoSuchRevision($request, $page, $version);
}
$new_version = fmt("version %d", $version);
} else {
$new = $current;
$new_version = _("current version");
}
if (preg_match('/^\\d+$/', $previous)) {
if (!($old = $page->getRevision($previous))) {
NoSuchRevision($request, $page, $previous);
}
$old_version = fmt("version %d", $previous);
$others = array('major', 'minor', 'author');
} else {
switch ($previous) {
case 'author':
$old = $new;
while ($old = $page->getRevisionBefore($old)) {
if ($old->get('author') != $new->get('author')) {
break;
}
}
$old_version = _("revision by previous author");
$others = array('major', 'minor');
break;
case 'minor':
$previous = 'minor';
$old = $page->getRevisionBefore($new);
$old_version = _("previous revision");
$others = array('major', 'author');
break;
case 'major':
default:
$old = $new;
while ($old && $old->get('is_minor_edit')) {
$old = $page->getRevisionBefore($old);
}
if ($old) {
$old = $page->getRevisionBefore($old);
}
$old_version = _("predecessor to the previous major change");
$others = array('minor', 'author');
break;
}
}
$new_link = WikiLink($new, '', $new_version);
$old_link = $old ? WikiLink($old, '', $old_version) : $old_version;
$page_link = WikiLink($page);
$html = HTML::div(array('class' => 'wikitext', 'id' => 'difftext'), HTML::p(fmt("Differences between %s and %s of %s.", $new_link, $old_link, $page_link)));
$otherdiffs = HTML::p(_("Other diffs:"));
$label = array('major' => _("Previous Major Revision"), 'minor' => _("Previous Revision"), 'author' => _("Previous Author"));
foreach ($others as $other) {
$args = array('action' => 'diff', 'previous' => $other);
if ($version) {
$args['version'] = $version;
}
if (count($otherdiffs->getContent()) > 1) {
$otherdiffs->pushContent(", ");
} else {
$otherdiffs->pushContent(" ");
}
$otherdiffs->pushContent(Button($args, $label[$other]));
}
$html->pushContent($otherdiffs);
if ($old and $old->getVersion() == 0) {
$old = false;
}
$html->pushContent(HTML::Table(PageInfoRow(_("Newer page:"), $new, $request, empty($version)), PageInfoRow(_("Older page:"), $old, $request, false)));
if ($new && $old) {
$diff = new Diff($old->getContent(), $new->getContent());
if ($diff->isEmpty()) {
$html->pushContent(HTML::hr(), HTML::p(_("Content of versions "), $old->getVersion(), _(" and "), $new->getVersion(), _(" is identical.")));
// If two consecutive versions have the same content, it is because the page was
// renamed, or metadata changed: ACL, owner, markup.
// We give the reason by printing the summary.
if ($new->getVersion() - $old->getVersion() == 1) {
$html->pushContent(HTML::p(_("Version "), $new->getVersion(), _(" was created because: "), $new->get('summary')));
}
} else {
$fmt = new HtmlUnifiedDiffFormatter();
$html->pushContent($fmt->format($diff));
}
$html->pushContent(HTML::hr(), HTML::h2($new_version));
require_once "lib/BlockParser.php";
$html->pushContent(TransformText($new, $new->get('markup'), $pagename));
}
require_once 'lib/Template.php';
GeneratePage($html, sprintf(_("Diff: %s"), $pagename), $new);
}
示例11: handleError
/**
* Handle an error.
*
* The error is passed through any registered error handlers, and
* then either reported or postponed.
*
* @access public
* @param $error object A PhpError object.
*/
function handleError($error)
{
static $in_handler;
if (!empty($in_handler)) {
$msg = $error->_getDetail();
$msg->unshiftContent(HTML::h2(fmt("%s: error while handling error:", "ErrorManager")));
$msg->printXML();
return;
}
// template which flushed the pending errors already handled,
// so display now all errors directly.
if (!empty($GLOBALS['request']->_finishing)) {
$this->_postpone_mask = 0;
}
$in_handler = true;
foreach ($this->_handlers as $handler) {
if (!$handler) {
continue;
}
$result = $handler->call($error);
if (!$result) {
continue;
// Handler did not handle error.
} elseif (is_object($result)) {
// handler filtered the result. Still should pass to
// the rest of the chain.
if ($error->isFatal()) {
// Don't let handlers make fatal errors non-fatal.
$result->errno = $error->errno;
}
$error = $result;
} else {
// Handler handled error.
if (!$error->isFatal()) {
$in_handler = false;
return;
}
break;
}
}
$this->_noCacheHeaders();
// Error was either fatal, or was not handled by a handler.
// Handle it ourself.
if ($error->isFatal()) {
echo "<html><body><div style=\"font-weight:bold; color:red\">Fatal Error:</div>\n";
if (defined('DEBUG') and DEBUG & _DEBUG_TRACE) {
echo "error_reporting=", error_reporting(), "\n<br>";
if (function_exists("debug_backtrace")) {
// >= 4.3.0
$error->printSimpleTrace(debug_backtrace());
}
}
$this->_die($error);
} else {
if (($error->errno & error_reporting()) != 0) {
if (($error->errno & $this->_postpone_mask) != 0) {
//echo "postponed errors: ";
if (defined('DEBUG') and DEBUG & _DEBUG_TRACE) {
echo "error_reporting=", error_reporting(), "\n";
if (function_exists("debug_backtrace")) {
// >= 4.3.0
$error->printSimpleTrace(debug_backtrace());
}
$error->printXML();
}
} else {
if (function_exists('isa') and isa($error, 'PhpErrorOnce') or !function_exists('isa') and (strtolower(get_class($error)) == 'phperroronce' or is_subclass_of($error, 'PhpErrorOnce'))) {
$error->removeDoublettes($this->_postponed_errors);
if ($error->_count < 2) {
$this->_postponed_errors[] = $error;
}
} else {
$this->_postponed_errors[] = $error;
}
}
}
}
$in_handler = false;
}
示例12: getConflictMessage
function getConflictMessage($unresolved = false)
{
/*
xgettext only knows about c/c++ line-continuation strings
it does not know about php's dot operator.
We want to translate this entire paragraph as one string, of course.
*/
//$re_edit_link = Button('edit', _("Edit the new version"), $this->page);
if ($unresolved) {
$message = HTML::p(fmt("Some of the changes could not automatically be combined. Please look for sections beginning with '%s', and ending with '%s'. You will need to edit those sections by hand before you click Save.", "<<<<<<< " . _("Your version"), ">>>>>>> " . _("Other version")));
} else {
$message = HTML::p(_("Please check it through before saving."));
}
/*$steps = HTML::ol(HTML::li(_("Copy your changes to the clipboard or to another temporary place (e.g. text editor).")),
HTML::li(fmt("%s of the page. You should now see the most current version of the page. Your changes are no longer there.",
$re_edit_link)),
HTML::li(_("Make changes to the file again. Paste your additions from the clipboard (or text editor).")),
HTML::li(_("Save your updated changes.")));
*/
return HTML(HTML::h2(_("Conflicting Edits!")), HTML::p(_("In the time since you started editing this page, another user has saved a new version of it.")), HTML::p(_("Your changes can not be saved as they are, since doing so would overwrite the other author's changes. So, your changes and those of the other author have been combined. The result is shown below.")), $message);
}
示例13: run
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();
}
//.........这里部分代码省略.........
示例14: run
function run($dbi, $argstr, &$request, $basepage)
{
extract($this->getArgs($argstr, $request));
// allow plugin-form
if (!empty($s)) {
$page = $s;
}
if (!$page) {
return '';
}
if (!$dbi->isWikiPage($page)) {
return fmt("Page %s not found.", WikiLink($page, 'unknown'));
}
$p = $dbi->getPage($page);
include_once "lib/loadsave.php";
$mailified = MailifyPage($p, $format == 'backup' ? 99 : 1);
// fixup_headers massages the page dump headers depending on
// the 'format' argument, 'normal'(default) or 'forcvs'.
//
// Normal: Don't add X-Rcs-Id, add unique Message-Id, don't
// strip any fields from Content-Type.
//
// ForCVS: Add empty X-Rcs-Id, strip attributes from
// Content-Type field: "author", "version", "lastmodified",
// "author_id", "hits".
$this->pagename = $page;
$this->generateMessageId($mailified);
if ($format == 'forcvs') {
$this->fixup_headers_forcvs($mailified);
} else {
// backup or normal
$this->fixup_headers($mailified);
}
if ($download) {
// TODO: we need a way to hook into the generated headers, to override
// Content-Type, Set-Cookie, Cache-control, ...
$request->discardOutput();
// Hijack the http request from PhpWiki.
ob_end_clean();
// clean up after hijacking $request
//ob_end_flush(); //debugging
Header("Content-disposition: attachment; filename=\"" . FilenameForPage($page) . "\"");
// Read charset from generated page itself.
// Inconsequential at the moment, since loadsave.php
// always generates headers
$charset = $p->get('charset');
if (!$charset) {
$charset = $GLOBALS['charset'];
}
// We generate 3 Content-Type headers! first in loadsave,
// then here and the mimified string $mailified also has it!
Header("Content-Type: text/plain; name=\"" . FilenameForPage($page) . "\"; charset=\"" . $charset . "\"");
$request->checkValidators();
// let $request provide last modifed & etag
Header("Content-Id: <" . $this->MessageId . ">");
// be nice to http keepalive~s
// FIXME: he length is wrong BTW. must strip the header.
Header("Content-Length: " . strlen($mailified));
// Here comes our prepared mime file
echo $mailified;
exit;
// noreturn! php exits.
return;
}
// We are displaing inline preview in a WikiPage, so wrap the
// text if it is too long--unless quoted-printable (TODO).
$mailified = safe_wordwrap($mailified, 70);
$dlcvs = Button(array('action' => $this->getName(), 'format' => 'forcvs', 'download' => true), _("Download for CVS"), $page);
$dl = Button(array('action' => $this->getName(), 'download' => true), _("Download for backup"), $page);
$dlall = Button(array('action' => $this->getName(), 'format' => 'backup', 'download' => true), _("Download all revisions for backup"), $page);
$h2 = HTML::h2(fmt("Preview: Page dump of %s", WikiLink($page, 'auto')));
global $WikiTheme;
if (!($Sep = $WikiTheme->getButtonSeparator())) {
$Sep = " ";
}
if ($format == 'forcvs') {
$desc = _("(formatted for PhpWiki developers as pgsrc template, not for backing up)");
$altpreviewbuttons = HTML(Button(array('action' => $this->getName()), _("Preview as normal format"), $page), $Sep, Button(array('action' => $this->getName(), 'format' => 'backup'), _("Preview as backup format"), $page));
} elseif ($format == 'backup') {
$desc = _("(formatted for backing up: all revisions)");
// all revisions
$altpreviewbuttons = HTML(Button(array('action' => $this->getName(), 'format' => 'forcvs'), _("Preview as developer format"), $page), $Sep, Button(array('action' => $this->getName(), 'format' => ''), _("Preview as normal format"), $page));
} else {
$desc = _("(normal formatting: latest revision only)");
$altpreviewbuttons = HTML(Button(array('action' => $this->getName(), 'format' => 'forcvs'), _("Preview as developer format"), $page), $Sep, Button(array('action' => $this->getName(), 'format' => 'backup'), _("Preview as backup format"), $page));
}
$warning = HTML(_("Please use one of the downloadable versions rather than copying and pasting from the above preview.") . " " . _("The wordwrap of the preview doesn't take nested markup or list indentation into consideration!") . " ", HTML::em(_("PhpWiki developers should manually inspect the downloaded file for nested markup before rewrapping with emacs and checking into CVS.")));
return HTML($h2, HTML::em($desc), HTML::pre($mailified), $altpreviewbuttons, HTML::div(array('class' => 'errors'), HTML::strong(_("Warning:")), " ", $warning), $dl, $Sep, $dlall, $Sep, $dlcvs);
}
示例15: run
function run($dbi, $argstr, &$request, $basepage)
{
$disablemsg = HTML();
$disablemsg->pushContent(HTML::h2("Upload is temporarily disabled."), HTML::br());
return $disablemsg;
$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)));
$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));
if (preg_match("/(\\." . join("|\\.", $this->disallowed_extensions) . ")\$/", $userfile_name)) {
$message->pushContent($err_header);
$message->pushContent(fmt("Files with extension %s are not allowed.", join(", ", $this->disallowed_extensions)), HTML::br(), HTML::br());
} elseif (preg_match("/[^._a-zA-Z0-9-]/", $userfile_name)) {
$message->pushContent($err_header);
$message->pushContent(_("File names may only contain alphanumeric characters and dot, underscore or dash."), HTML::br(), HTML::br());
} elseif (file_exists($file_dir . $userfile_name)) {
$message->pushContent($err_header);
$message->pushContent(fmt("There is already a file with name %s uploaded.", $userfile_name), HTML::br(), HTML::br());
} elseif ($userfile->getSize() > MAX_UPLOAD_SIZE) {
$message->pushContent($err_header);
$message->pushContent(_("Sorry but this file is too big."), HTML::br(), HTML::br());
} 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:{$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());
}
//$result = HTML::div( array( 'class' => 'wikiaction' ) );
$result = HTML();
$result->pushContent($form);
$result->pushContent($message);
return $result;
}