本文整理汇总了PHP中fmt函数的典型用法代码示例。如果您正苦于以下问题:PHP fmt函数的具体用法?PHP fmt怎么用?PHP fmt使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了fmt函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: chownPages
function chownPages(&$dbi, &$request, $pages, $newowner)
{
$ul = HTML::ul();
$count = 0;
foreach ($pages as $name) {
$page = $dbi->getPage($name);
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 {
$page->set('owner', $newowner);
if ($page->get('owner') === $newowner) {
$ul->pushContent(HTML::li(fmt("Chown page '%s' to '%s'.", WikiLink($name), WikiLink($newowner))));
$count++;
} else {
$ul->pushContent(HTML::li(fmt("Couldn't chown page '%s' to '%s'.", WikiLink($name), $newowner)));
}
}
}
}
if ($count) {
$dbi->touch();
return HTML($ul, HTML::p(fmt("%s pages have been permanently changed.", $count)));
} else {
return HTML($ul, HTML::p(fmt("No pages changed.")));
}
}
示例2: WikiDB_backend_dba
function WikiDB_backend_dba($dbparams)
{
$directory = '/tmp';
$prefix = 'wiki_';
$dba_handler = 'gdbm';
$timeout = 20;
extract($dbparams);
if ($directory) {
$directory .= "/";
}
$dbfile = $directory . $prefix . 'pagedb' . '.' . $dba_handler;
// FIXME: error checking.
$db = new DbaDatabase($dbfile, false, $dba_handler);
$db->set_timeout($timeout);
// Workaround for BDB 4.1 bugs
if (file_exists($dbfile)) {
$mode = 'w';
} else {
$mode = 'c';
}
if (!$db->open($mode)) {
trigger_error(sprintf(_("%s: Can't open dba database"), $dbfile), E_USER_ERROR);
global $request;
$request->finish(fmt("%s: Can't open dba database", $dbfile));
}
$this->WikiDB_backend_dbaBase($db);
}
示例3: run
function run($dbi, $argstr, &$request, $basepage)
{
if (!defined('ENABLE_RAW_HTML') || !ENABLE_RAW_HTML) {
return $this->disabled(_("Raw HTML is disabled in this wiki."));
}
if (!$basepage) {
return $this->error("{$basepage} unset?");
}
$page = $request->getPage($basepage);
if (ENABLE_RAW_HTML_LOCKEDONLY) {
if (!$page->get('locked')) {
return $this->disabled(fmt("%s is only allowed in locked pages.", _("Raw HTML")));
}
}
if (ENABLE_RAW_HTML_SAFE) {
// check for javascript handlers (on*) and style tags with external urls. no javascript urls.
// See also http://simon.incutio.com/archive/2003/02/23/safeHtmlChecker
// But we should allow not only code semantic meaning, presentational markup also.
// http://chxo.com/scripts/safe_html-test.php looks better
$argstr = $this->safe_html($argstr);
/*return $this->disabled(HTML(fmt("This %s plugin on %s is disabled because of unsafe HTML code. ",$this->getName(), $basepage),
fmt("See PhpWiki:allowing%20safe%20HTML")
));
*/
}
return HTML::raw($argstr);
}
示例4: run
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;
}
示例5: purgePages
function purgePages(&$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('purge', $name)) {
$dbi->purgePage($name);
$ul->pushContent(HTML::li(fmt("Purged page '%s' successfully.", $name)));
$count++;
} else {
$ul->pushContent(HTML::li(fmt("Didn't purge 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 purged:"));
} else {
$result->pushContent(HTML::p(fmt("%s pages have been permanently purged:", $count)));
}
$result->pushContent($ul);
return $result;
} else {
$result->setAttr('class', 'error');
$result->pushContent(HTML::p("No pages purged."));
return $result;
}
}
示例6: PurgePage
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"));
}
示例7: box
function box($args = false, $request = false, $basepage = false)
{
if (!$request) {
$request =& $GLOBALS['request'];
}
$stats = $this->getStats($request->_dbi, $request, 'summary');
return $this->makeBox(_("Who is online"), HTML(HTML::Raw('· '), WikiLink(_("WhoIsOnline"), 'auto', fmt("%d online users", $stats['NUM_USERS']))));
}
示例8: run
function run($dbi, $argstr, &$request, $basepage)
{
extract($this->getArgs($argstr, $request));
// Any text that is returned will not be further transformed,
// so use html where necessary.
$html = HTML::tt(fmt('%s: %s', $salutation, WikiLink($name, 'auto')), THE_END);
return $html;
}
示例9: 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"));
}
示例10: getHtmlFields
public function getHtmlFields()
{
$this->notifyUrl .= "&processor=jcc";
$this->returnUrl .= "&processor=jcc";
//Version
$version = "1.0.0";
//Merchant ID
$merchantID = $this->merchantId;
//Acquirer ID
$acquirerID = $this->acquirerId;
//The SSL secured URL of the merchant to which JCC will send the transaction result
//This should be SSL enabled – note https:// NOT http://
//Purchase Amount
$purchaseAmt = fmt($this->amount);
//Pad the purchase amount with 0's so that the total length is 13 characters, i.e. 20.50 will become 0000000020.50
$purchaseAmt = str_pad($purchaseAmt, 13, "0", STR_PAD_LEFT);
//Remove the dot (.) from the padded purchase amount(JCC will know from currency how many digits to consider as decimal)
//0000000020.50 will become 000000002050 (notice there is no dot)
$formattedPurchaseAmt = substr($purchaseAmt, 0, 10) . substr($purchaseAmt, 11);
//Euro currency ISO Code; see relevant appendix for ISO codes of other currencies
$currency = 978;
//The number of decimal points for transaction currency, i.e. in this example we indicate that Euro has 2 decimal points
$currencyExp = 2;
//Order number
$orderID = $this->itemNumber;
//Specify we want not only to authorize the amount but also capture at the same time. Alternative value could be M (for capturing later)
$captureFlag = "A";
//Password
$password = $this->password;
//Form the plaintext string to encrypt by concatenating Password, Merchant ID, Acquirer ID, Order ID,Formatter Purchase Amount and Currency
//This will give 1234abcd | 0011223344 | 402971 | TestOrder12345 | 000000002050 | 978 (spaces and | introduced here for clarity)
$toEncrypt = $password . $merchantID . $acquirerID . $orderID . $formattedPurchaseAmt . $currency;
//Produce the hash using SHA1
//This will give b14dcc7842a53f1ec7a621e77c106dfbe8283779
$sha1Signature = sha1($toEncrypt);
//Encode the signature using Base64 before transmitting to JCC
//This will give sU3MeEKlPx7HpiHnfBBt++goN3k=
$base64Sha1Signature = base64_encode(pack("H*", $sha1Signature));
//The name of the hash algorithm use to create the signature; can be MD5 or SHA1; the latter is preffered and is what we used in this example
$signatureMethod = "SHA1";
$html = '';
$html .= sprintf('<input type="hidden" name="Version" value="%s"/>', $version);
$html .= sprintf('<input type="hidden" name="MerID" value="%s"/>', $merchantID);
$html .= sprintf('<input type="hidden" name="AcqID" value="%s"/>', $acquirerID);
$html .= sprintf('<input type="hidden" name="MerRespURL" value="%s"/>', $this->notifyUrl);
$html .= sprintf('<input type="hidden" name="PurchaseAmt" value="%s"/>', $formattedPurchaseAmt);
$html .= sprintf('<input type="hidden" name="PurchaseCurrency" value="%s"/>', $currency);
$html .= sprintf('<input type="hidden" name="PurchaseCurrencyExponent" value="%s"/>', $currencyExp);
$html .= sprintf('<input type="hidden" name="OrderID" value="%s"/>', $orderID);
$html .= sprintf('<input type="hidden" name="CaptureFlag" value="%s"/>', $captureFlag);
$html .= sprintf('<input type="hidden" name="Signature" value="%s"/>', $base64Sha1Signature);
$html .= sprintf('<input type="hidden" name="SignatureMethod" value="%s"/>', $signatureMethod);
//echo $html; exit;
return $html;
}
示例11: checkname
function checkname()
{
$name = isset($_POST['name']) ? $_POST['name'] : "";
$name = fmt($name);
$data = $this->find("user_name=" . $name, "users");
if (!empty($data)) {
echo "用户名已存在";
} else {
echo "OK";
}
}
示例12: run
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;
}
示例13: showNotify
function showNotify(&$request, $messages, $page, $pagelist, $verified)
{
$isNecessary = !$this->contains($pagelist, $page);
$form = HTML::form(array('action' => $request->getPostURL(), 'method' => 'post'), HiddenInputs(array('verify' => 1)), HiddenInputs($request->getArgs(), false, array('verify')), $messages, HTML::p(_("Your current watchlist: "), $this->showWatchList($pagelist)));
if ($isNecessary) {
$form->pushContent(HTML::p(_("New watchlist: "), $this->showWatchList($this->addpagelist($page, $pagelist))), HTML::p(sprintf(_("Do you %s want to add this page \"%s\" to your WatchList?"), $verified ? _("really") : "", $page)), HTML::p(Button('submit:add', _("Yes")), HTML::Raw(' '), Button('submit:cancel', _("Cancel"))));
} else {
$form->pushContent(HTML::p(fmt("The page %s is already watched!", $page)), HTML::p(Button('submit:edit', _("Edit")), HTML::Raw(' '), Button('submit:cancel', _("Cancel"))));
}
$fieldset = HTML::fieldset(HTML::legend("Watch Page"), $form);
return $fieldset;
}
示例14: run
function run($dbi, $argstr, &$request, $basepage)
{
$args = $this->getArgs($argstr, $request);
extract($args);
if (empty($page) && empty($prefix) && empty($suffix)) {
return '';
}
if ($prefix) {
$suffix = false;
$descrip = fmt("Page names with prefix '%s'", $prefix);
} elseif ($suffix) {
$descrip = fmt("Page names with suffix '%s'", $suffix);
} elseif ($page) {
$words = preg_split('/[\\s:-;.,]+/', SplitPagename($page));
$words = preg_grep('/\\S/', $words);
$prefix = reset($words);
$suffix = end($words);
$descrip = fmt("These pages share an initial or final title word with '%s'", WikiLink($page, 'auto'));
}
// Search for pages containing either the suffix or the prefix.
$search = $match = array();
if (!empty($prefix)) {
$search[] = $this->_quote($prefix);
$match[] = '^' . preg_quote($prefix, '/');
}
if (!empty($suffix)) {
$search[] = $this->_quote($suffix);
$match[] = preg_quote($suffix, '/') . '$';
}
if ($search) {
$query = new TextSearchQuery(join(' OR ', $search));
} else {
$query = new NullTextSearchQuery();
}
// matches nothing
$match_re = '/' . join('|', $match) . '/';
$pagelist = new PageList($info, $exclude, $args);
if (!$noheader) {
$pagelist->setCaption($descrip);
}
$pages = $dbi->titleSearch($query);
while ($page = $pages->next()) {
$name = $page->getName();
if (!preg_match($match_re, $name)) {
continue;
}
$pagelist->addPage($page);
}
return $pagelist;
}
示例15: run
function run($dbi, $argstr, &$request, $basepage)
{
$args = $this->getArgs($argstr, $request);
if ($args['basepage']) {
$pagename = $args['basepage'];
} else {
$pagename = $request->getArg('pagename');
}
// FIXME: explodePageList from stdlib doesn't seem to work as
// expected when there are no subpages. (see also
// UnfoldSubPages plugin)
$subpages = explodePageList($pagename . SUBPAGE_SEPARATOR . '*');
if (!$subpages) {
return $this->error(_("The current page has no subpages defined."));
}
extract($args);
$content = HTML();
$subpages = array_reverse($subpages);
if ($maxpages) {
$subpages = array_slice($subpages, 0, $maxpages);
}
$descrip = fmt("SubPages of %s:", WikiLink($pagename, 'auto'));
if ($info) {
$info = explode(",", $info);
if (in_array('count', $info)) {
$args['types']['count'] = new _PageList_Column_ListSubpages_count('count', _("#"), 'center');
}
}
$pagelist = new PageList($info, $exclude, $args);
if (!$noheader) {
$pagelist->setCaption($descrip);
}
foreach ($subpages as $page) {
// A page cannot include itself. Avoid doublettes.
static $included_pages = array();
if (in_array($page, $included_pages)) {
$content->pushContent(HTML::p(sprintf(_("recursive inclusion of page %s ignored"), $page)));
continue;
}
array_push($included_pages, $page);
//if ($relative) {
// TODO: add relative subpage name display to PageList class
//}
$pagelist->addPage($page);
array_pop($included_pages);
}
$content->pushContent($pagelist);
return $content;
}