本文整理汇总了PHP中JavaScript函数的典型用法代码示例。如果您正苦于以下问题:PHP JavaScript函数的具体用法?PHP JavaScript怎么用?PHP JavaScript使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了JavaScript函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: Head
function Head($name = 'edit[content]')
{
global $WikiTheme;
foreach (array("Wikiwyg.js", "Wikiwyg/Toolbar.js", "Wikiwyg/Preview.js", "Wikiwyg/Wikitext.js", "Wikiwyg/Wysiwyg.js", "Wikiwyg/Phpwiki.js", "Wikiwyg/HTML.js", "Wikiwyg/Toolbar.js") as $js) {
$WikiTheme->addMoreHeaders(Javascript('', array('src' => $this->BasePath . '/' . $js, 'language' => 'JavaScript')));
}
$doubleClickToEdit = ($GLOBALS['request']->getPref('doubleClickEdit') or ENABLE_DOUBLECLICKEDIT) ? 'true' : 'false';
if ($GLOBALS['request']->getArg('mode') && $GLOBALS['request']->getArg('mode') == 'wysiwyg') {
return JavaScript($this->_jsdefault . "\n window.onload = function() {\n var wikiwyg = new Wikiwyg.Phpwiki();\n var config = {\n doubleClickToEdit: {$doubleClickToEdit},\n javascriptLocation: data_path+'/themes/default/Wikiwyg/',\n toolbar: {\n\t imagesLocation: data_path+'/themes/default/Wikiwyg/images/',\n\t\tcontrolLayout: [\n\t\t 'save','preview','save_button','|',\n\t\t 'p','|',\n\t\t 'h2', 'h3', 'h4','|',\n\t\t 'bold', 'italic', '|',\n 'sup', 'sub', '|',\n 'toc',\n 'wikitext','|',\n\t\t 'pre','|',\n\t\t 'ordered', 'unordered','hr','|',\n\t\t 'link','|',\n 'table'\n\t\t ],\n\t\tstyleSelector: [\n\t\t 'label', 'p', 'h2', 'h3', 'h4', 'pre'\n\t\t\t\t], \n\t\tcontrolLabels: {\n\t save: '" . _("Apply changes") . "',\n\t\t cancel: '" . _("Exit toolbar") . "',\n\t\t h2: '" . _("Title 1") . "',\n\t\t h3: '" . _("Title 2") . "',\n\t\t h4: '" . _("Title 3") . "',\n\t\t verbatim: '" . _("Verbatim") . "',\n toc: '" . _("Table of content") . "', \n wikitext: '" . _("Insert Wikitext section") . "', \n sup: '" . _("Sup") . "', \n sub: '" . _("Sub") . "',\n preview: '" . _("Preview") . "', \n save_button:'" . _("Save") . "' \n\t }\n },\n wysiwyg: {\n iframeId: 'iframe0'\n },\n\t wikitext: {\n\t supportCamelCaseLinks: true\n\t }\n };\n var div = document.getElementById(\"" . $this->_htmltextid . "\");\n wikiwyg.createWikiwygArea(div, config);\n wikiwyg_divs.push(wikiwyg);\n wikiwyg.editMode();}");
}
}
示例2: EditToolbar
function EditToolbar()
{
global $WikiTheme;
$this->tokens = array();
//FIXME: enable Undo button for all other buttons also, not only the search/replace button
if (JS_SEARCHREPLACE) {
$this->tokens['JS_SEARCHREPLACE'] = 1;
$undo_btn = $WikiTheme->getImageURL("ed_undo.png");
$undo_d_btn = $WikiTheme->getImageURL("ed_undo_d.png");
// JS_SEARCHREPLACE from walterzorn.de
$js = Javascript("\nuri_undo_btn = '" . $undo_btn . "'\nmsg_undo_alt = '" . _("Undo") . "'\nuri_undo_d_btn = '" . $undo_d_btn . "'\nmsg_undo_d_alt = '" . _("Undo disabled") . "'\nmsg_do_undo = '" . _("Operation undone") . "'\nmsg_replfound = '" . _("Substring \"\\1\" found \\2 times. Replace with \"\\3\"?") . "'\nmsg_replnot = '" . _("String \"%s\" not found.") . "'\nmsg_repl_title = '" . _("Search & Replace") . "'\nmsg_repl_search = '" . _("Search for") . "'\nmsg_repl_replace_with = '" . _("Replace with") . "'\nmsg_repl_ok = '" . _("OK") . "'\nmsg_repl_close = '" . _("Close") . "'\n");
if (empty($WikiTheme->_headers_printed)) {
$WikiTheme->addMoreHeaders($js);
$WikiTheme->addMoreAttr('body', "SearchReplace", " onload='define_f()'");
} else {
// from an actionpage: WikiBlog, AddComment, WikiForum
printXML($js);
}
} else {
$WikiTheme->addMoreAttr('body', "editfocus", "document.getElementById('edit-content]').editarea.focus()");
}
if (ENABLE_EDIT_TOOLBAR) {
$js = JavaScript('', array('src' => $WikiTheme->_findData("toolbar.js")));
if (empty($WikiTheme->_headers_printed)) {
$WikiTheme->addMoreHeaders($js);
} else {
// from an actionpage: WikiBlog, AddComment, WikiForum
printXML($js);
printXML(JavaScript('define_f()'));
}
}
require_once "lib/WikiPluginCached.php";
$cache = WikiPluginCached::newCache();
$dbi = $GLOBALS['request']->getDbh();
// regenerate if number of pages changes (categories, pages, templates)
$key = $dbi->numPages();
$key .= '+categories+plugin' . (isBrowserSafari() ? '+safari' : '');
if (TOOLBAR_PAGELINK_PULLDOWN) {
$key .= "+pages";
}
if (TOOLBAR_TEMPLATE_PULLDOWN) {
$key .= "+templates_" . $dbi->getTimestamp();
}
$id = $cache->generateId($key);
$content = $cache->get($id, 'toolbarcache');
if (!empty($content)) {
$this->tokens['EDIT_TOOLBAR'] =& $content;
} else {
$content = $this->_generate();
// regenerate buttons every 1 hr/6 hrs
$cache->save($id, $content, DEBUG ? '+3600' : '+21600', 'toolbarcache');
$this->tokens['EDIT_TOOLBAR'] =& $content;
}
}
示例3: showForm
function showForm(&$dbi, &$request, $args, $allrelations)
{
global $WikiTheme;
$action = $request->getPostURL();
$hiddenfield = HiddenInputs($request->getArgs(), '', array('action', 'page', 's'));
$pagefilter = HTML::input(array('name' => 'page', 'value' => $args['page'], 'title' => _("Search only in these pages. With autocompletion."), 'class' => 'dropdown', 'acdropdown' => 'true', 'autocomplete_complete' => 'true', 'autocomplete_matchsubstring' => 'false', 'autocomplete_list' => 'xmlrpc:wiki.titleSearch ^[S] 4'), '');
$help = Button('submit:semsearch[help]', "?", false);
$svalues = empty($allrelations) ? "" : join("','", $allrelations);
$reldef = JavaScript("var semsearch_relations = new Array('" . $svalues . "')");
$querybox = HTML::textarea(array('name' => 's', 'title' => _("Enter a valid query expression"), 'rows' => 4, 'acdropdown' => 'true', 'autocomplete_complete' => 'true', 'autocomplete_assoc' => 'false', 'autocomplete_matchsubstring' => 'true', 'autocomplete_list' => 'array:semsearch_relations'), $args['s']);
$submit = Button('submit:semsearch[relations]', _("Search"), false, array('title' => 'Move to help page. No seperate window'));
$instructions = _("Search in all specified pages for the expression.");
$form = HTML::form(array('action' => $action, 'method' => 'post', 'accept-charset' => $GLOBALS['charset']), $reldef, $hiddenfield, HiddenInputs(array('attribute' => '')), $instructions, HTML::br(), HTML::table(array('border' => '0', 'width' => '100%'), HTML::tr(HTML::td(_("Pagename(s): "), $pagefilter), HTML::td(array('align' => 'right'), $help)), HTML::tr(HTML::td(array('colspan' => 2), $querybox))), HTML::br(), HTML::div(array('align' => 'center'), $submit));
return $form;
}
示例4: initGlobals
function initGlobals()
{
global $request;
static $already = 0;
if (!$already) {
$script_url = deduce_script_name();
$script_url .= '/' . $GLOBALS['group_name'];
if (DEBUG & _DEBUG_REMOTE and isset($_GET['start_debug'])) {
$script_url .= "?start_debug=" . $_GET['start_debug'];
}
$folderArrowPath = dirname($this->_findData('images/folderArrowLoading.gif'));
$pagename = $request->getArg('pagename');
$this->addMoreHeaders(JavaScript('', array('src' => $this->_findData("wikilens.js"))));
$js = "var data_path = '" . javascript_quote_string(DATA_PATH) . "';\n" . "var script_url= '" . javascript_quote_string($script_url) . "';\n" . "var stylepath = data_path+'/" . javascript_quote_string($this->_theme) . "/';\n" . "var folderArrowPath = '" . javascript_quote_string($folderArrowPath) . "';\n" . "var use_path_info = " . (USE_PATH_INFO ? "true" : "false") . ";\n";
$this->addMoreHeaders(JavaScript($js));
$already = 1;
}
}
示例5: EditToolbar
function EditToolbar()
{
global $WikiTheme;
$this->tokens = array();
//FIXME: enable Undo button for all other buttons also, not only the search/replace button
if (JS_SEARCHREPLACE) {
$this->tokens['JS_SEARCHREPLACE'] = 1;
$undo_btn = $WikiTheme->getImageURL("ed_undo.png");
$undo_d_btn = $WikiTheme->getImageURL("ed_undo_d.png");
// JS_SEARCHREPLACE from walterzorn.de
$WikiTheme->addMoreHeaders(Javascript("\nvar f, sr_undo, replacewin, undo_buffer=new Array(), undo_buffer_index=0;\n\nfunction define_f() {\n f=document.getElementById('editpage');\n f.editarea=document.getElementById('edit[content]');\n sr_undo=document.getElementById('sr_undo');\n undo_enable(false);\n f.editarea.focus();\n}\nfunction undo_enable(bool) {\n if (bool) {\n sr_undo.src='" . $undo_btn . "';\n sr_undo.alt='" . _("Undo") . "';\n sr_undo.disabled = false;\n } else {\n sr_undo.src='" . $undo_d_btn . "';\n sr_undo.alt='" . _("Undo disabled") . "';\n sr_undo.disabled = true;\n if(sr_undo.blur) sr_undo.blur();\n }\n}\nfunction replace() {\n replacewin = window.open('','','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes,copyhistory=no,height=90,width=450');\n replacewin.window.document.write('<html><head><title>" . _("Search & Replace") . "</title><style type=\"text/css\"><'+'!'+'-- body, input {font-family:Tahoma,Arial,Helvetica,sans-serif;font-size:10pt;font-weight:bold;} td {font-size:9pt} --'+'></style></head><body bgcolor=\"#dddddd\" onload=\"if(document.forms[0].ein.focus) document.forms[0].ein.focus(); return false;\"><form><center><table><tr><td align=\"right\">'+'" . _("Search") . ":</td><td align=\"left\"><input type=\"text\" name=\"ein\" size=\"45\" maxlength=\"500\"></td></tr><tr><td align=\"right\">'+' " . _("Replace with") . ":</td><td align=\"left\"><input type=\"text\" name=\"aus\" size=\"45\" maxlength=\"500\"></td></tr><tr><td colspan=\"2\" align=\"center\"><input type=\"button\" value=\" " . _("OK") . " \" onclick=\"if(self.opener)self.opener.do_replace(); return false;\"> <input type=\"button\" value=\"" . _("Close") . "\" onclick=\"self.close(); return false;\"></td></tr></table></center></form></body></html>');\n replacewin.window.document.close();\n return false;\n}\nfunction do_replace() {\n var txt=undo_buffer[undo_buffer_index]=f.editarea.value, ein=new RegExp(replacewin.document.forms[0].ein.value,'g'), aus=replacewin.document.forms[0].aus.value;\n if (ein==''||ein==null) {\n if (replacewin) replacewin.window.document.forms[0].ein.focus();\n return;\n }\n var z_repl=txt.match(ein)? txt.match(ein).length : 0;\n txt=txt.replace(ein,aus);\n ein=ein.toString().substring(1,ein.toString().length-2);\n result(z_repl, '" . sprintf(_("Substring \"%s\" found %s times. Replace with \"%s\"?"), "'+ein+'", "'+z_repl+'", "'+aus+'") . "', txt, '" . sprintf(_("String \"%s\" not found."), "'+ein+'") . "');\n replacewin.window.focus();\n replacewin.window.document.forms[0].ein.focus();\n return false;\n}\nfunction result(zahl,frage,txt,alert_txt) {\n if (zahl>0) {\n if(window.confirm(frage)==true) {\n f.editarea.value=txt;\n undo_save();\n undo_enable(true);\n }\n } else alert(alert_txt);\n}\nfunction do_undo() {\n if(undo_buffer_index==0) return;\n else if(undo_buffer_index>0) {\n f.editarea.value=undo_buffer[undo_buffer_index-1];\n undo_buffer[undo_buffer_index]=null;\n undo_buffer_index--;\n if(undo_buffer_index==0) {\n alert('" . _("Operation undone") . "');\n undo_enable(false);\n }\n }\n}\n//save a snapshot in the undo buffer\nfunction undo_save() {\n undo_buffer[undo_buffer_index]=f.editarea.value;\n undo_buffer_index++;\n undo_enable(true);\n}\n"));
$WikiTheme->addMoreAttr('body', "SearchReplace", " onload='define_f()'");
} else {
$WikiTheme->addMoreAttr('body', "editfocus", "document.getElementById('edit[content]').editarea.focus()");
}
if (ENABLE_EDIT_TOOLBAR) {
$WikiTheme->addMoreHeaders(JavaScript('', array('src' => $WikiTheme->_findData("toolbar.js"))));
}
include_once "lib/WikiPluginCached.php";
$cache = WikiPluginCached::newCache();
$dbi = $GLOBALS['request']->getDbh();
// regenerate if number of pages changes (categories, pages, templates)
$key = $dbi->numPages();
$key .= '+categories+plugin';
if (TOOLBAR_PAGELINK_PULLDOWN) {
$key .= "+pages";
}
if (TOOLBAR_TEMPLATE_PULLDOWN) {
$key .= "+templates_" . $dbi->getTimestamp();
}
$id = $cache->generateId($key);
$content = $cache->get($id, 'toolbarcache');
if (!empty($content)) {
$this->tokens['EDIT_TOOLBAR'] =& $content;
} else {
$content = $this->_generate();
// regenerate buttons every 3600 seconds
$cache->save($id, $content, '+3600', 'toolbarcache');
$this->tokens['EDIT_TOOLBAR'] =& $content;
}
}
示例6: showForm
function showForm(&$dbi, &$request, $args)
{
$action = $request->getPostURL();
$hiddenfield = HiddenInputs($request->getArgs(), '', array('action', 'page', 's', 'direction'));
$pagefilter = HTML::input(array('name' => 'page', 'value' => $args['page'], 'title' => _("Search only in these pages. With autocompletion."), 'class' => 'dropdown', 'acdropdown' => 'true', 'autocomplete_complete' => 'true', 'autocomplete_matchsubstring' => 'false', 'autocomplete_list' => 'xmlrpc:wiki.titleSearch ^[S] 4'), '');
$query = HTML::input(array('name' => 's', 'value' => $args['s'], 'title' => _("Filter by this link. These are pagenames. With autocompletion."), 'class' => 'dropdown', 'acdropdown' => 'true', 'autocomplete_complete' => 'true', 'autocomplete_matchsubstring' => 'true', 'autocomplete_list' => 'xmlrpc:wiki.titleSearch ^[S] 4'), '');
$dirsign_switch = JavaScript("\nfunction dirsign_switch() {\n var d = document.getElementById('dirsign')\n d.innerHTML = (d.innerHTML == ' => ') ? ' <= ' : ' => '\n}\n");
$dirsign = " => ";
$in = $out = array('name' => 'direction', 'type' => 'radio', 'onChange' => 'dirsign_switch()');
$out['value'] = 'out';
$out['id'] = 'dir_out';
if ($args['direction'] == 'out') {
$out['checked'] = 'checked';
}
$in['value'] = 'in';
$in['id'] = 'dir_in';
if ($args['direction'] == 'in') {
$in['checked'] = 'checked';
$dirsign = " <= ";
}
$direction = HTML(HTML::input($out), HTML::label(array('for' => 'dir_out'), _("outgoing")), HTML::input($in), HTML::label(array('for' => 'dir_in'), _("incoming")));
/*
$direction = HTML::select(array('name'=>'direction',
'onChange' => 'dirsign_switch()'));
$out = array('value' => 'out');
if ($args['direction']=='out') $out['selected'] = 'selected';
$in = array('value' => 'in');
if ($args['direction']=='in') {
$in['selected'] = 'selected';
$dirsign = " <= ";
}
$direction->pushContent(HTML::option($out, _("outgoing")));
$direction->pushContent(HTML::option($in, _("incoming")));
*/
$submit = Button('submit:search', _("LinkSearch"), false);
$instructions = _("Search in pages for links with the matching name.");
$form = HTML::form(array('action' => $action, 'method' => 'GET', 'accept-charset' => $GLOBALS['charset']), $dirsign_switch, $hiddenfield, $instructions, HTML::br(), $pagefilter, HTML::strong(HTML::tt(array('id' => 'dirsign'), $dirsign)), $query, HTML::raw(' '), $direction, HTML::raw(' '), $submit);
return $form;
}
示例7: run
function run($dbi, $argstr, &$request, $basepage)
{
global $WikiTheme;
$args = $this->getArgs($argstr, $request);
if (empty($this->source)) {
return '';
}
$html = HTML();
if (empty($WikiTheme->_asciiSVG)) {
$js = JavaScript('', array('src' => $WikiTheme->_findData('ASCIIsvg.js')));
if (empty($WikiTheme->_headers_printed)) {
$WikiTheme->addMoreHeaders($js);
} else {
$html->pushContent($js);
}
$WikiTheme->_asciiSVG = 1;
// prevent duplicates
}
// extract <script>
if (preg_match("/^(.*)<script>(.*)<\\/script>/ism", $this->source, $m)) {
$this->source = $m[1];
$args['script'] = $m[2];
}
$embedargs = array('width' => $args['width'], 'height' => $args['height'], 'script' => $this->source);
// additional onmousemove argument
if ($args['onmousemove']) {
$embedargs['onmousemove'] = $args['onmousemove'];
}
// we need script='data' and not script="data"
$embed = new AsciiSVG_HTML("embed", $embedargs);
$html->pushContent($embed);
if ($args['script']) {
$html->pushContent(JavaScript($args['script']));
}
return $html;
}
示例8: redirect
function redirect($url, $noreturn = true)
{
$bogus = defined('DISABLE_HTTP_REDIRECT') && DISABLE_HTTP_REDIRECT;
if (!$bogus) {
header("Location: {$url}");
/*
* "302 Found" is not really meant to be sent in response
* to a POST. Worse still, according to (both HTTP 1.0
* and 1.1) spec, the user, if it is sent, the user agent
* is supposed to use the same method to fetch the
* redirected URI as the original.
*
* That means if we redirect from a POST, the user-agent
* supposed to generate another POST. Not what we want.
* (We do this after a page save after all.)
*
* Fortunately, most/all browsers don't do that.
*
* "303 See Other" is what we really want. But it only
* exists in HTTP/1.1
*
* FIXME: this is still not spec compliant for HTTP
* version < 1.1.
*/
$status = $this->httpVersion() >= 1.1 ? 303 : 302;
$this->setStatus($status);
}
if ($noreturn) {
$this->discardOutput();
// This might print the gzip headers. Not good.
$this->buffer_output(false);
include_once 'lib/Template.php';
$tmpl = new Template('redirect', $this, array('REDIRECT_URL' => $url));
$tmpl->printXML();
$this->finish();
} elseif ($bogus) {
// Safari needs window.location.href = targeturl
return JavaScript("\n function redirect(url) {\n if (typeof location.replace == 'function')\n location.replace(url);\n else if (typeof location.assign == 'function')\n location.assign(url);\n else if (self.location.href)\n self.location.href = url;\n else\n window.location = url;\n }\n redirect('" . addslashes($url) . "')");
}
}
示例9: calendarInit
function calendarInit($force = false)
{
$dbi = $GLOBALS['request']->getDbh();
// display flat calender dhtml in the sidebar
if ($force or $dbi->isWikiPage($this->calendarBase())) {
$jslang = @$GLOBALS['LANG'];
$this->addMoreHeaders($this->_CSSlink(0, $this->_findFile('jscalendar/calendar-phpwiki.css'), 'all'));
$this->addMoreHeaders(JavaScript('', array('src' => $this->_findData('jscalendar/calendar' . (DEBUG ? '' : '_stripped') . '.js'))));
if (!($langfile = $this->_findData("jscalendar/lang/calendar-{$jslang}.js"))) {
$langfile = $this->_findData("jscalendar/lang/calendar-en.js");
}
$this->addMoreHeaders(JavaScript('', array('src' => $langfile)));
$this->addMoreHeaders(JavaScript('', array('src' => $this->_findData('jscalendar/calendar-setup' . (DEBUG ? '' : '_stripped') . '.js'))));
// Get existing date entries for the current user
require_once "lib/TextSearchQuery.php";
$iter = $dbi->titleSearch(new TextSearchQuery("^" . $this->calendarBase() . SUBPAGE_SEPARATOR, true, "auto"));
$existing = array();
while ($page = $iter->next()) {
if ($page->exists()) {
$existing[] = basename($page->_pagename);
}
}
if (!empty($existing)) {
$js_exist = '{"' . join('":1,"', $existing) . '":1}';
//var SPECIAL_DAYS = {"2004-05-11":1,"2004-05-12":1,"2004-06-01":1}
$this->addMoreHeaders(JavaScript('
/* This table holds the existing calender entries for the current user
* calculated from the database
*/
var SPECIAL_DAYS = ' . javascript_quote_string($js_exist) . ';
/* This function returns true if the date exists in SPECIAL_DAYS */
function dateExists(date, y, m, d) {
var year = date.getFullYear();
m = m + 1;
m = m < 10 ? "0" + m : m; // integer, 0..11
d = d < 10 ? "0" + d : d; // integer, 1..31
var date = year+"-"+m+"-"+d;
var exists = SPECIAL_DAYS[date];
if (!exists) return false;
else return true;
}
// This is the actual date status handler.
// Note that it receives the date object as well as separate
// values of year, month and date.
function dateStatusFunc(date, y, m, d) {
if (dateExists(date, y, m, d)) return "existing";
else return false;
}
'));
} else {
$this->addMoreHeaders(JavaScript('
function dateStatusFunc(date, y, m, d) { return false;}'));
}
}
}
示例10: Textarea
function Textarea($textarea, $wikitext, $name = 'edit[content]')
{
$out = HTML($textarea);
$out->pushContent(JavaScript("editor_generate('" . $name . "');", array('version' => 'JavaScript1.2', 'defer' => 1)));
return $out;
}
示例11: initLiveSearch
function initLiveSearch()
{
if (!$this->HTML_DUMP_SUFFIX) {
$this->addMoreAttr('body', 'LiveSearch', HTML::Raw(" onload=\"liveSearchInit()"));
$this->addMoreHeaders(JavaScript('var liveSearchURI="' . WikiURL(_("TitleSearch"), false, true) . '";'));
$this->addMoreHeaders(JavaScript('', array('src' => $this->_findData('livesearch.js'))));
}
}
示例12: showForm
function showForm(&$dbi, &$request, $args)
{
global $WikiTheme;
$action = $request->getPostURL();
$hiddenfield = HiddenInputs($request->getArgs(), '', array('action', 'page', 's', 'semsearch', 'relation', 'attribute'));
$pagefilter = HTML::input(array('name' => 'page', 'value' => $args['page'], 'title' => _("Search only in these pages. With autocompletion."), 'class' => 'dropdown', 'acdropdown' => 'true', 'autocomplete_complete' => 'true', 'autocomplete_matchsubstring' => 'false', 'autocomplete_list' => 'xmlrpc:wiki.titleSearch ^[S] 4'), '');
$allrelations = $dbi->listRelations(false, false, true);
$svalues = empty($allrelations) ? "" : join("','", $allrelations);
$reldef = JavaScript("var semsearch_relations = new Array('" . $svalues . "')");
$relation = HTML::input(array('name' => 'relation', 'value' => $args['relation'], 'title' => _("Filter by this relation. With autocompletion."), 'class' => 'dropdown', 'style' => 'width:10em', 'acdropdown' => 'true', 'autocomplete_assoc' => 'false', 'autocomplete_complete' => 'true', 'autocomplete_matchsubstring' => 'true', 'autocomplete_list' => 'array:semsearch_relations'), '');
$queryrel = HTML::input(array('name' => 's', 'value' => $args['s'], 'title' => _("Filter by this link. These are pagenames. With autocompletion."), 'class' => 'dropdown', 'acdropdown' => 'true', 'autocomplete_complete' => 'true', 'autocomplete_matchsubstring' => 'true', 'autocomplete_list' => 'xmlrpc:wiki.titleSearch ^[S] 4'), '');
$relsubmit = Button('submit:semsearch[relations]', _("Relations"), false);
// just testing some dhtml... not yet done
$enhancements = HTML();
$nbsp = HTML::raw(' ');
$this_uri = $_SERVER['REQUEST_URI'] . '#';
$andbutton = new Button(_("AND"), $this_uri, 'wikiaction', array('onclick' => "addquery('rel', 'and')", 'title' => _("Add an AND query")));
$orbutton = new Button(_("OR"), $this_uri, 'wikiaction', array('onclick' => "addquery('rel', 'or')", 'title' => _("Add an OR query")));
if (DEBUG) {
$enhancements = HTML::span($andbutton, $nbsp, $orbutton);
}
$instructions = _("Search in pages for a relation with that value (a pagename).");
$form1 = HTML::form(array('action' => $action, 'method' => 'post', 'accept-charset' => $GLOBALS['charset']), $reldef, $hiddenfield, HiddenInputs(array('attribute' => '')), $instructions, HTML::br(), HTML::table(array('border' => 0, 'cellspacing' => 2), HTML::colgroup(array('span' => 6)), HTML::thead(HTML::tr(HTML::th('Pagefilter'), HTML::th('Relation'), HTML::th(), HTML::th('Links'), HTML::th())), HTML::tbody(HTML::tr(HTML::td($pagefilter, ": "), HTML::td($relation), HTML::td(HTML::strong(HTML::tt(' :: '))), HTML::td($queryrel), HTML::td($nbsp, $relsubmit, $nbsp, $enhancements)))));
$allattrs = $dbi->listRelations(false, true, true);
if (empty($allrelations) and empty($allattrs)) {
// be nice to the dummy.
$this->_norelations_warning = 1;
}
$svalues = empty($allattrs) ? "" : join("','", $allattrs);
$attdef = JavaScript("var semsearch_attributes = new Array('" . $svalues . "')\n" . "var semsearch_op = new Array('" . join("','", $this->_supported_operators) . "')");
// TODO: We want some more tricks: Autofill the base unit of the selected
// attribute into the s area.
$attribute = HTML::input(array('name' => 'attribute', 'value' => $args['attribute'], 'title' => _("Filter by this attribute name. With autocompletion."), 'class' => 'dropdown', 'style' => 'width:10em', 'acdropdown' => 'true', 'autocomplete_complete' => 'true', 'autocomplete_matchsubstring' => 'true', 'autocomplete_assoc' => 'false', 'autocomplete_list' => 'array:semsearch_attributes'), '');
$attr_op = HTML::input(array('name' => 'attr_op', 'value' => $args['attr_op'], 'title' => _("Comparison operator. With autocompletion."), 'class' => 'dropdown', 'style' => 'width:2em', 'acdropdown' => 'true', 'autocomplete_complete' => 'true', 'autocomplete_matchsubstring' => 'true', 'autocomplete_assoc' => 'false', 'autocomplete_list' => 'array:semsearch_op'), '');
$queryatt = HTML::input(array('name' => 's', 'value' => $args['s'], 'title' => _("Filter by this numeric attribute value. With autocompletion."), 'class' => 'dropdown', 'acdropdown' => 'false', 'autocomplete_complete' => 'true', 'autocomplete_matchsubstring' => 'false', 'autocomplete_assoc' => 'false', 'autocomplete_list' => 'plugin:SemanticSearch page=' . $args['page'] . ' attribute=^[S] attr_op==~'), '');
$andbutton = new Button(_("AND"), $this_uri, 'wikiaction', array('onclick' => "addquery('attr', 'and')", 'title' => _("Add an AND query")));
$orbutton = new Button(_("OR"), $this_uri, 'wikiaction', array('onclick' => "addquery('attr', 'or')", 'title' => _("Add an OR query")));
if (DEBUG) {
$enhancements = HTML::span($andbutton, $nbsp, $orbutton);
}
$attsubmit = Button('submit:semsearch[attributes]', _("Attributes"), false);
$instructions = HTML::span(_("Search in pages for an attribute with that numeric value."), "\n");
if (DEBUG) {
$instructions->pushContent(HTML(" ", new Button(_("Advanced..."), _("SemanticSearchAdvanced"))));
}
$form2 = HTML::form(array('action' => $action, 'method' => 'post', 'accept-charset' => $GLOBALS['charset']), $attdef, $hiddenfield, HiddenInputs(array('relation' => '')), $instructions, HTML::br(), HTML::table(array('border' => 0, 'cellspacing' => 2), HTML::colgroup(array('span' => 6)), HTML::thead(HTML::tr(HTML::th('Pagefilter'), HTML::th('Attribute'), HTML::th('Op'), HTML::th('Value'), HTML::th())), HTML::tbody(HTML::tr(HTML::td($pagefilter, ": "), HTML::td($attribute), HTML::td($attr_op), HTML::td($queryatt), HTML::td($nbsp, $attsubmit, $nbsp, $enhancements)))));
return HTML($form1, $form2);
}
示例13: IfJavaScript
/** Conditionally display content based of whether javascript is supported.
*
* This conditionally (on the client side) displays one of two alternate
* contents depending on whether the client supports javascript.
*
* NOTE:
* The content you pass as arguments to this function must be block-level.
* (This is because the <noscript> tag is block-level.)
*
* @param mixed $if_content Content to display if the browser supports
* javascript.
*
* @param mixed $else_content Content to display if the browser does
* not support javascript.
*
* @return XmlContent
*/
function IfJavaScript($if_content = false, $else_content = false)
{
$html = array();
if ($if_content) {
$xml = AsXML($if_content);
$js = sprintf('document.write("%s");', addcslashes($xml, "..!@\\..ÿ"));
$html[] = JavaScript($js);
}
if ($else_content) {
$html[] = HTML::noscript(false, $else_content);
}
return HTML($html);
}
示例14: run
function run($dbi, $argstr, &$request, $basepage)
{
extract($this->getArgs($argstr, $request));
$attributes = $attrib ? explode(",", $attrib) : array();
$photos = array();
$html = HTML();
$count = 0;
// check all parameters
// what type do we have?
if (!$src) {
$showdesc = 'none';
$src = $request->getArg('pagename');
$error = $this->fromLocation($src, $photos);
} else {
$error = $this->fromFile($src, $photos, $url);
}
if ($error) {
return $this->error($error);
}
if ($numcols < 1) {
$numcols = 1;
}
if ($align != 'left' && $align != 'center' && $align != 'right') {
$align = 'center';
}
if (count($photos) == 0) {
return;
}
if (in_array("sort", $attributes)) {
sort($photos);
}
if ($p) {
$mode = "normal";
}
if ($mode == "column") {
$mode = "normal";
$numcols = "1";
}
// set some fixed properties for each $mode
if ($mode == 'thumbs' || $mode == 'tiles') {
$attributes = array_merge($attributes, "alt");
$attributes = array_merge($attributes, "nowrap");
$cellwidth = 'auto';
// else cell won't nowrap
$width = 50;
} elseif ($mode == 'list') {
$numcols = 1;
$cellwidth = "auto";
$width = 50;
} elseif ($mode == 'slide') {
$tableheight = 0;
$cell_width = 0;
$numcols = count($photos);
$keep = $photos;
while (list($key, $value) = each($photos)) {
list($x, $y, $s, $t) = @getimagesize($value['src']);
if ($height != 'auto') {
$y = $this->newSize($y, $height);
}
if ($width != 'auto') {
$y = round($y * $this->newSize($x, $width) / $x);
}
if ($x > $cell_width) {
$cell_width = $x;
}
if ($y > $tableheight) {
$tableheight = $y;
}
}
$tableheight += 50;
$photos = $keep;
unset($x, $y, $s, $t, $key, $value, $keep);
}
$row = HTML();
$duration = 1000 * $duration;
if ($mode == 'slide') {
$row->pushContent(JavaScript("\ni = 0;\nfunction display_slides() {\n j = i - 1;\n cell0 = document.getElementsByName('wikislide' + j);\n cell = document.getElementsByName('wikislide' + i);\n if (cell0.item(0) != null)\n cell0.item(0).style.display='none';\n if (cell.item(0) != null)\n cell.item(0).style.display='block';\n i += 1;\n if (cell.item(0) == null) i = 0;\n setTimeout('display_slides()',{$duration});\n}\ndisplay_slides();"));
}
while (list($key, $value) = each($photos)) {
if ($p && basename($value["name"]) != "{$p}") {
continue;
}
if ($h && basename($value["name"]) == "{$h}") {
$color = $hlcolor ? $hlcolor : $bgcolor;
} else {
$color = $bgcolor;
}
// $params will be used for each <img > tag
$params = array('src' => $value["name"], 'src_tile' => $value["name_tile"], 'border' => "0", 'alt' => ($value["desc"] != "" and in_array("alt", $attributes)) ? $value["desc"] : basename($value["name"]));
if (!@empty($value['location'])) {
$params = array_merge($params, array("location" => $value['location']));
}
// check description
switch ($showdesc) {
case 'none':
$value["desc"] = '';
break;
case 'name':
$value["desc"] = basename($value["name"]);
break;
//.........这里部分代码省略.........
示例15: sidebar_link
function sidebar_link()
{
extract($this->_args);
$pagetitle = $show_minor ? _("RecentEdits") : _("RecentChanges");
global $request;
$sidebarurl = WikiURL($pagetitle, array('format' => 'sidebar'), 'absurl');
$addsidebarjsfunc = "function addPanel() {\n" . " window.sidebar.addPanel (\"" . sprintf("%s - %s", WIKI_NAME, $pagetitle) . "\",\n" . " \"{$sidebarurl}\",\"\");\n" . "}\n";
$jsf = JavaScript($addsidebarjsfunc);
global $WikiTheme;
$sidebar_button = $WikiTheme->makeButton("sidebar", 'javascript:addPanel();', 'sidebaricon');
$addsidebarjsclick = asXML(HTML::small(array('style' => 'font-weight:normal;vertical-align:middle;'), $sidebar_button));
$jsc = JavaScript("if ((typeof window.sidebar == 'object') &&\n" . " (typeof window.sidebar.addPanel == 'function'))\n" . " {\n" . " document.write('{$addsidebarjsclick}');\n" . " }\n");
return HTML(new RawXML("\n"), $jsf, new RawXML("\n"), $jsc);
}