本文整理汇总了PHP中Page::insert_script方法的典型用法代码示例。如果您正苦于以下问题:PHP Page::insert_script方法的具体用法?PHP Page::insert_script怎么用?PHP Page::insert_script使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Page
的用法示例。
在下文中一共展示了Page::insert_script方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: render_chart
/**
* render a chart
*
* @param string chart data, in JSON format
* @param string chart parameters
* @return string the rendered text
**/
public static function render_chart($data, $variant)
{
global $context;
// split parameters
$attributes = preg_split("/\\s*,\\s*/", $variant, 4);
// set a default size
if (!isset($attributes[0])) {
$attributes[0] = 320;
}
if (!isset($attributes[1])) {
$attributes[1] = 240;
}
// object attributes
$width = $attributes[0];
$height = $attributes[1];
$flashvars = '';
if (isset($attributes[2])) {
$flashvars = $attributes[2];
}
// allow several charts to co-exist in the same page
static $chart_index;
if (!isset($chart_index)) {
$chart_index = 1;
} else {
$chart_index++;
}
$url = $context['url_to_home'] . $context['url_to_root'] . 'included/browser/open-flash-chart.swf';
$text = '<div id="open_flash_chart_' . $chart_index . '" class="no_print">Flash plugin or Javascript are turned off. Activate both and reload to view the object</div>' . "\n";
Page::insert_script('var params = {};' . "\n" . 'params.base = "' . dirname($url) . '/";' . "\n" . 'params.quality = "high";' . "\n" . 'params.wmode = "opaque";' . "\n" . 'params.allowscriptaccess = "always";' . "\n" . 'params.menu = "false";' . "\n" . 'params.flashvars = "' . $flashvars . '";' . "\n" . 'swfobject.embedSWF("' . $url . '", "open_flash_chart_' . $chart_index . '", "' . $width . '", "' . $height . '", "6", "' . $context['url_to_home'] . $context['url_to_root'] . 'included/browser/expressinstall.swf", {"get-data":"get_open_flash_chart_' . $chart_index . '"}, params);' . "\n" . "\n" . 'var chart_data_' . $chart_index . ' = ' . trim(str_replace(array('<br />', "\n"), ' ', $data)) . ';' . "\n" . "\n" . 'function get_open_flash_chart_' . $chart_index . '() {' . "\n" . ' return $.toJSON(chart_data_' . $chart_index . ');' . "\n" . '}' . "\n");
return $text;
}
示例2: get_fields
/**
* get form fields to change the day
*
* @see overlays/overlay.php
*
* @param array hosting attributes
* @return a list of ($label, $input, $hint)
*/
function get_fields($host, $field_pos = NULL)
{
global $context;
$options = '<input type="hidden" name="time_stamp" value="12:00" />' . '<input type="hidden" name="duration" value="1440" />';
// default value is now
if (!isset($this->attributes['date_stamp']) || $this->attributes['date_stamp'] <= NULL_DATE) {
$this->attributes['date_stamp'] = gmstrftime('%Y-%m-%d %H:%M', time() + Surfer::get_gmt_offset() * 3600);
} else {
$this->attributes['date_stamp'] = Surfer::from_GMT($this->attributes['date_stamp']);
}
// split date from time
list($date, $time) = explode(' ', $this->attributes['date_stamp']);
// event time
$label = i18n::s('Date');
$input = Skin::build_input_time('date_stamp', $date, 'date') . $options;
$hint = i18n::s('Use format YYYY-MM-DD');
$fields[] = array($label, $input, $hint);
// ensure that we do have a date
Page::insert_script('func' . 'tion validateOnSubmit(container) {' . "\n" . "\n" . ' if(!Yacs.trim(container.date_stamp.value)) {' . "\n" . ' alert("' . i18n::s('Please provide a date.') . '");' . "\n" . ' container.date_stamp.focus();' . "\n" . ' Yacs.stopWorking();' . "\n" . ' return false;' . "\n" . ' }' . "\n\n" . ' return true;' . "\n" . '}' . "\n");
return $fields;
}
示例3: Make
/**
* build the HTML structure for 1 jssor slider
*
* @param array $slides of images & captions & thumbs
* @param array $options to provide with this instance
* @return string formated HTML
*/
public static function Make($slides, $options = null)
{
$slider = '';
// unique id for the slider
static $slidenum;
$slidenum = isset($slidenum) ? $slidenum + 1 : 1;
// main div
$slider .= '<div id="slider' . $slidenum . '_container" class="sor-container" >' . "\n";
// loading screen, if required
if (isset($option['loading_screen'])) {
$slider .= '<!-- Loading Screen -->' . "\n" . '<div data-u="loading" class="sor-loading">' . "\n" . $option['loading_screen'] . "\n" . '</div>' . "\n";
}
// slider container
$slider .= '<!-- Slides Container -->' . "\n" . '<div data-u="slides" class="sor-slides">' . "\n";
// Parse $slides to make slides
foreach ($slides as $slide) {
// start slide
$slider .= '<div>' . "n";
// main image
if (isset($slide['image_src'])) {
$slider .= '<img data-u="image" src="' . $slide['image_src'] . '" />' . "\n";
}
// caption
if (isset($slide['caption'])) {
$slider .= '<div data-u="caption" data-t="caption-transition-name" class="sor-caption">' . "\n" . $slide['caption'] . "\n" . '</div>' . "\n";
}
// thumb
// close slide
$slider .= '</div>' . "n";
}
// end slider container
$slider .= '</div>' . "\n";
// end main div
$slider .= '</div>' . "\n";
// javascript initalization
$js_options = isset($option['js']) ? $option['js'] : array('$AutoPlay' => 'true');
$rootname = 'slider' . $slidenum . '_';
Page::insert_script('$(document).ready(function ($) {' . "\n" . 'var ' . $rootname . 'options = ' . json_encode($js_options) . ";\n" . 'var ' . $rootname . 'jssor = new $JssorSlider$("' . $rootname . 'container", ' . $rootname . 'options );' . '});');
return $slider;
}
示例4: render_sound
/**
* render a sound object with dewplayer
*
* @global type $context
* @param type $id
* @return string
*/
public static function render_sound($id)
{
global $context;
// maybe an alternate title has been provided
$attributes = preg_split("/\\s*,\\s*/", $id, 2);
$id = $attributes[0];
$flashvars = '';
if (isset($attributes[1])) {
$flashvars = $attributes[1];
}
// get the file
if (!($item = Files::get($id))) {
$output = '[sound=' . $id . ']';
return $output;
}
// where to get the file
if (isset($item['file_href']) && $item['file_href']) {
$url = $item['file_href'];
} else {
$url = $context['url_to_home'] . $context['url_to_root'] . 'files/' . str_replace(':', '/', $item['anchor']) . '/' . rawurlencode($item['file_name']);
}
// several ways to play flash
switch (strtolower(substr(strrchr($url, '.'), 1))) {
// stream a sound file
case 'mp3':
// a flash player to stream a sound
$dewplayer_url = $context['url_to_root'] . 'included/browser/dewplayer.swf';
if ($flashvars) {
$flashvars = 'son=' . $url . '&' . $flashvars;
} else {
$flashvars = 'son=' . $url;
}
$output = '<div id="sound_' . $item['id'] . '" class="no_print">Flash plugin or Javascript are turned off. Activate both and reload to view the object</div>' . "\n";
Page::insert_script('var params = {};' . "\n" . 'params.base = "' . dirname($url) . '/";' . "\n" . 'params.quality = "high";' . "\n" . 'params.wmode = "transparent";' . "\n" . 'params.menu = "false";' . "\n" . 'params.flashvars = "' . $flashvars . '";' . "\n" . 'swfobject.embedSWF("' . $dewplayer_url . '", "sound_' . $item['id'] . '", "200", "20", "6", "' . $context['url_to_home'] . $context['url_to_root'] . 'included/browser/expressinstall.swf", false, params);' . "\n");
return $output;
// link to file page
// link to file page
default:
// link label
$text = Skin::strip($item['title'] ? $item['title'] : str_replace('_', ' ', $item['file_name']));
// make a link to the target page
$url = Files::get_download_url($item);
// return a complete anchor
$output =& Skin::build_link($url, $text, 'basic');
return $output;
}
}
示例5: array
// list available avatars, except on error
if (!count($context['error']) && isset($item['id'])) {
// upload an image
//
if (Images::allow_creation($item, null, 'user')) {
// the form to post an image
$text = '<form method="post" action="' . $context['url_to_root'] . 'images/edit.php" id="main_form" enctype="multipart/form-data"><div>' . '<input type="hidden" name="anchor" value="user:' . $item['id'] . '" />' . '<input type="hidden" name="action" value="set_as_avatar" />';
$fields = array();
// the image
$text .= '<input type="file" name="upload" id="upload" size="30" accesskey="i" title="' . encode_field(i18n::s('Press to select a local file')) . '" />';
$text .= ' ' . Skin::build_submit_button(i18n::s('Submit'), i18n::s('Press [s] to submit data'), 's');
$text .= BR . '<span class="details">' . i18n::s('Select a .png, .gif or .jpeg image.') . ' (< ' . Skin::build_number($image_maximum_size, i18n::s('bytes')) . ')</span>';
// end of the form
$text .= '</div></form>';
// the script used for form handling at the browser
Page::insert_script('$("#upload").focus();');
$context['text'] .= Skin::build_content(NULL, i18n::s('Upload an image'), $text);
}
// use the library
//
// where images are
$path = 'skins/_reference/avatars';
// browse the path to list directories and files
if ($dir = Safe::opendir($context['path_to_root'] . $path)) {
$text = '';
if (Surfer::may_upload()) {
$text .= '<p>' . i18n::s('Click on one image below to make it your new picture.') . '</p>' . "\n";
}
// build the lists
while (($image = Safe::readdir($dir)) !== FALSE) {
// skip some files
示例6: elseif
// ask for something to process, except on error
} elseif (!count($context['error'])) {
// the splash message
$context['text'] .= '<p>' . i18n::s('This script allows you to install or update a theme for your YACS server.') . "</p>\n";
// the form to post an file
$context['text'] .= '<form method="post" action="' . $context['script_url'] . '" id="main_form" enctype="multipart/form-data"><div>';
// upload an archive
$context['text'] .= '<p>' . i18n::s('Select the archive file that you want to install remotely.') . '</p>';
// the file
$context['text'] .= '<input type="file" name="upload" id="focus" size="30" />' . ' (< ' . $context['file_maximum_size'] . i18n::s('bytes') . ')';
// the submit button
$context['text'] .= '<p>' . Skin::build_submit_button(i18n::s('Submit'), i18n::s('Press [s] to submit data'), 's') . '</p>' . "\n";
// end of the form
$context['text'] .= '</div></form>';
// the script used for form handling at the browser
Page::insert_script('$("#focus").focus();');
// use an available archive
$context['text'] .= '<p>' . i18n::s('Alternatively, this script is able to handle archives that have been put in the directory <code>inbox/skins</code>.') . '</p>';
// find available skin archives
$archives = array();
if ($dir = Safe::opendir("../inbox/skins")) {
// scan the file system
while (($file = Safe::readdir($dir)) !== FALSE) {
// skip special files
if ($file[0] == '.' || $file[0] == '~') {
continue;
}
// skip non-archive files
if (!preg_match('/(\\.bz2|\\.tar|\\.tar.gz|\\.tgz|\\.zip)/i', $file)) {
continue;
}
示例7: render_newsfeed
/**
* integrate content of a newsfeed
*
* @param string address of the newsfeed to get
* @return string the rendered text
**/
public static function render_newsfeed($url, $variant = 'ajax')
{
global $context;
// we allow multiple calls
static $count;
if (!isset($count)) {
$count = 1;
} else {
$count++;
}
switch ($variant) {
case 'ajax':
// asynchronous loading
// asynchronous loading
default:
$text = '<div id="newsfeed_' . $count . '" class="no_print"></div>' . "\n";
Page::insert_script('$(function() { Yacs.spin("newsfeed_' . $count . '"); Yacs.call( { method: \'feed.proxy\', params: { url: \'' . $url . '\' }, id: 1 }, function(s) { if(s.text) { $("#newsfeed_' . $count . '").html(s.text.toString()); } else { $("#newsfeed_' . $count . '").html("***error***"); } } ) } );');
return $text;
case 'embed':
// integrate newsfeed into the page
include_once $context['path_to_root'] . 'feeds/proxy_hook.php';
$parameters = array('url' => $url);
if ($output = Proxy_hook::serve($parameters)) {
$text = $output['text'];
}
return $text;
}
}
示例8: list
list($item['latitude'], $item['longitude']) = preg_split('/[\\s,;]+/', $item['geo_position']);
}
// link to anchor page
$description = '';
if ($anchor = Anchors::get($item['anchor'])) {
$description .= Skin::build_link($anchor->get_url(), $anchor->get_title());
}
// item type
if (strpos($item['anchor'], 'user:') == 0) {
$type = 'user';
} else {
$type = 'other';
}
// do the job
Page::defer_script('http://maps.google.com/maps/api/js?v=3&sensor=false');
Page::insert_script('var point = new google.maps.LatLng(parseFloat("' . $item['latitude'] . '"), parseFloat("' . $item['longitude'] . '"));' . "\n" . "\n" . 'var mapOptions = {' . "\n" . ' zoom: 10,' . "\n" . ' center: point,' . "\n" . ' mapTypeId: google.maps.MapTypeId.ROADMAP' . "\n" . '};' . "\n" . 'var map = new google.maps.Map($("#map")[0], mapOptions);' . "\n" . ' var marker = new google.maps.Marker({ position: point, map: map });' . "\n" . ' var infoWindow = new google.maps.InfoWindow();' . "\n" . 'google.maps.event.addDomListener(marker, "click", function() {' . "\n" . ' infoWindow.setContent("' . addcslashes($description, '\'\\"' . "\n\r") . '");' . "\n" . ' infoWindow.open(map, marker);' . "\n" . ' });' . "\n" . '$("body").bind("yacs", function(e) {' . "\n" . ' google.maps.event.trigger(map, "resize");' . "\n" . ' map.setZoom( map.getZoom() );' . "\n" . ' map.setCenter(point);' . "\n" . '});' . "\n");
}
// geo country
if ($item['geo_country']) {
$context['text'] .= '<p>' . sprintf(i18n::s('Regional position: %s'), $item['geo_country']) . "</p>\n";
}
// display the full text
$context['text'] .= Skin::build_block($item['description'], 'description');
// information on uploader
$details = array();
if (Surfer::is_member() && $item['edit_name']) {
$details[] = sprintf(i18n::s('edited by %s %s'), Users::get_link($item['edit_name'], $item['edit_address'], $item['edit_id']), Skin::build_date($item['edit_date']));
}
// page details
if (is_array($details)) {
$context['text'] .= '<p class="details">' . ucfirst(implode(', ', $details)) . "</p>\n";
示例9: array
$label = i18n::s('Message content');
$input = Surfer::get_editor('message', $content);
$fields[] = array($label, $input);
// build the form
$context['text'] .= Skin::build_form($fields);
//
// bottom commands
//
$menu = array();
// the submit button
$menu[] = Skin::build_submit_button(i18n::s('Submit'), i18n::s('Press [s] to submit data'), 's');
// cancel button
if (isset($item['id'])) {
$menu[] = Skin::build_link(Sections::get_permalink($item), i18n::s('Cancel'), 'span');
}
// insert the menu in the page
$context['text'] .= Skin::finalize_list($menu, 'assistant_bar');
// get a copy of the sent message
$context['text'] .= '<p><input type="checkbox" name="self_copy" value="Y" checked="checked" /> ' . i18n::s('Send me a copy of this message.') . '</p>';
// transmit the id as a hidden field
$context['text'] .= '<input type="hidden" name="id" value="' . $item['id'] . '" />';
// end of the form
$context['text'] .= '</div></form>';
// append the script used for data checking on the browser
Page::insert_script('func' . 'tion validateDocumentPost(container) {' . "\n" . ' if(!container.subject.value) {' . "\n" . ' alert("' . i18n::s('Please provide a meaningful title.') . '");' . "\n" . ' Yacs.stopWorking();' . "\n" . ' return false;' . "\n" . ' }' . "\n" . ' if(!container.message.value) {' . "\n" . ' alert("' . i18n::s('Message content can not be empty.') . '");' . "\n" . ' Yacs.stopWorking();' . "\n" . ' return false;' . "\n" . ' }' . "\n" . ' return true;' . "\n" . '}' . "\n" . '$(function() {' . "\n" . ' $("#names").focus();' . "\n" . ' Yacs.autocomplete_names("names");' . "\n" . '}); ' . "\n");
// help message
$help = '<p>' . i18n::s('New e-mail addresses are converted to new user profiles. Because of this, you should not use e-mail addresses that have multiple recipients.') . '</p>';
$context['components']['boxes'] = Skin::build_box(i18n::s('Help'), $help, 'boxes', 'help');
}
// render the skin
render_skin();
示例10: array
// the form to link additional users
$form = '<form method="post" action="' . $context['script_url'] . '" id="main_form">';
// horizontal layout
$cells = array();
// users only have followers
if (!strncmp($anchor->get_reference(), 'user:', 5)) {
} elseif (!strncmp($anchor->get_reference(), 'category:', 9)) {
} elseif (!$anchor->is_hidden()) {
$cells[] = '<span class="small">' . '<input type="radio" name="assignment" value="watcher" checked="checked" /> ' . i18n::s('notify on update (watcher)') . BR . '<input type="radio" name="assignment" value="editor" /> ' . i18n::s('moderate content (editor)') . '</span>';
}
// capture a new name with auto completion
$cells[] = '<input type="text" name="assigned_name" id="assigned_name" size="45" maxlength="255" />' . ' <input type="submit" id="submit_button" value="' . i18n::s('Submit') . '" style="display: none;" />' . '<p class="details">' . i18n::s('To add a person, type some letters to look for a name, then select one profile at a time.') . '</p>';
// finalize the capture form
$form .= Skin::layout_horizontally($cells) . '<input type="hidden" name="member" value="' . encode_field($anchor->get_reference()) . '">' . '<input type="hidden" name="action" value="assign">' . '</form>' . "\n";
// enable autocompletion
Page::insert_script('$(function() {' . "\n" . ' // set the focus on first form field' . "\n" . ' $("#assigned_name").focus();' . "\n" . ' // enable name autocompletion' . "\n" . ' Yacs.autocomplete_names("assigned_name",true, "", function(data) { Yacs.startWorking(); $("#submit_button").show().click(); });' . "\n" . '}); ' . "\n");
// title says it all
if (!strncmp($anchor->get_reference(), 'user:', 5)) {
if (Surfer::is(intval(substr($anchor->get_reference(), 5)))) {
$title = i18n::s('Who do you want to follow?');
} else {
$title = sprintf(i18n::s('Persons followed by %s'), $anchor->get_title());
}
} elseif (!strncmp($anchor->get_reference(), 'category:', 9)) {
$title = sprintf(i18n::s('Add a member to %s'), $anchor->get_title());
} else {
$title = i18n::s('Add a participant');
}
// finalize the box
$context['text'] .= Skin::build_box($title, $form, 'header1');
// looking at category members
示例11: render_dynamic_table
/**
* render a dynamic table
*
* @param string the table content
* @param string the variant, if any
* @return string the rendered text
**/
public static function render_dynamic_table($id, $variant = 'inline')
{
global $context;
// refresh on every page load
Cache::poison();
// get actual content
include_once $context['path_to_root'] . 'tables/tables.php';
// use SIMILE Exhibit
if ($variant == 'filter') {
// load the SIMILE Exhibit javascript library in shared/global.php
$context['javascript']['exhibit'] = TRUE;
// load data
$context['page_header'] .= "\n" . '<link href="' . $context['url_to_root'] . Tables::get_url($id, 'fetch_as_json') . '" type="application/json" rel="exhibit/data" />';
// exhibit data in a table
$text = '<div ex:role="exhibit-view" ex:viewClass="Exhibit.TabularView" ex:columns="' . Tables::build($id, 'json-labels') . '" ex:columnLabels="' . Tables::build($id, 'json-titles') . '" ex:border="0" ex:cellSpacing="0" ex:cellPadding="0" ex:showToolbox="true" ></div>' . "\n";
// allow for filtering
$facets = '<div class="exhibit-facet">' . '<div class="exhibit-facet-header"><span class="exhibit-facet-header-title">' . i18n::s('Filter') . '</span></div>' . '<div class="exhibit-facet-body-frame" style="margin: 0 2px 1em 0;">' . '<div ex:role="facet" ex:facetClass="TextSearch" style="display: block;"></div>' . '</div></div>';
// facets from first columns
$facets .= Tables::build($id, 'json-facets');
// filter and facets aside
$context['components']['boxes'] .= $facets;
// build sparkline
} elseif ($variant == 'bars') {
$text = '<img border="0" align="baseline" hspace="0" src="' . $context['url_to_root'] . Tables::get_url($id, 'fetch_as_png') . '&order=0⪆0.5" alt="" />';
// buid a Flash chart
} elseif ($variant == 'chart') {
// split parameters
$attributes = preg_split("/\\s*,\\s*/", $id, 4);
// set a default size
if (!isset($attributes[1])) {
$attributes[1] = 480;
}
if (!isset($attributes[2])) {
$attributes[2] = 360;
}
// object attributes
$width = $attributes[1];
$height = $attributes[2];
$flashvars = '';
if (isset($attributes[3])) {
$flashvars = $attributes[3];
}
// allow several charts to co-exist in the same page
static $chart_index;
if (!isset($chart_index)) {
$chart_index = 1;
} else {
$chart_index++;
}
// get data in the suitable format
$data = Tables::build($attributes[0], 'chart');
// load it through Javascript
$url = $context['url_to_home'] . $context['url_to_root'] . 'included/browser/open-flash-chart.swf';
$text = '<div id="table_chart_' . $chart_index . '" class="no_print">Flash plugin or Javascript are turned off. Activate both and reload to view the object</div>' . "\n";
Page::insert_script('var params = {};' . "\n" . 'params.base = "' . dirname($url) . '/";' . "\n" . 'params.quality = "high";' . "\n" . 'params.wmode = "opaque";' . "\n" . 'params.allowscriptaccess = "always";' . "\n" . 'params.menu = "false";' . "\n" . 'params.flashvars = "' . $flashvars . '";' . "\n" . 'swfobject.embedSWF("' . $url . '", "table_chart_' . $chart_index . '", "' . $width . '", "' . $height . '", "6", "' . $context['url_to_home'] . $context['url_to_root'] . 'included/browser/expressinstall.swf", {"get-data":"table_chart_' . $chart_index . '"}, params);' . "\n" . "\n" . 'var chart_data_' . $chart_index . ' = ' . trim(str_replace(array('<br />', "\n"), ' ', $data)) . ';' . "\n" . "\n" . 'function table_chart_' . $chart_index . '() {' . "\n" . ' return $.toJSON(chart_data_' . $chart_index . ');' . "\n" . '}' . "\n");
// build sparkline
} elseif ($variant == 'line') {
$text = '<img border="0" align="baseline" hspace="0" src="' . $context['url_to_root'] . Tables::get_url($id, 'fetch_as_png') . '&order=2&gap=0.0" alt="" />';
// we do the rendering ourselves
} else {
$text = Tables::build($id, $variant);
}
// put that into the web page
return $text;
}
示例12: array
$label = i18n::s('E-mail address');
$field = $item['email'];
$fields[] = array($label, $field);
}
// surfer is changing password
if (Surfer::is_logged()) {
// the password
$label = i18n::s('New password');
$input = '<input type="password" name="password" id="password" size="20" value="' . encode_field(isset($_REQUEST['password']) ? $_REQUEST['password'] : '') . '" />';
$fields[] = array($label, $input);
// the password has to be repeated for confirmation
$label = i18n::s('Password confirmation');
$input = '<input type="password" name="confirm" size="20" value="' . encode_field(isset($_REQUEST['confirm']) ? $_REQUEST['confirm'] : '') . '" />';
$fields[] = array($label, $input);
// append the script used for data checking on the browser
Page::insert_script('$("#password").focus();');
}
// stop replay attacks and robots
if ($field = Surfer::get_robot_stopper()) {
$fields[] = $field;
}
// build the form
$context['text'] .= Skin::build_form($fields);
// cancel link
if (!isset($item['id'])) {
$cancel_url = $context['url_to_home'] . $context['url_to_root'];
} else {
$cancel_url = Users::get_permalink($item);
}
// bottom commands
$context['text'] .= Skin::finalize_list(array(Skin::build_submit_button(i18n::s('Submit'), i18n::s('Press [s] to submit data'), 's'), Skin::build_link($cancel_url, i18n::s('Cancel'), 'span')), 'assistant_bar');
示例13: function
$context['text'] .= '<p style="margin-bottom: 1em;"><a href="#" onclick="Yacs.confirm(\'' . i18n::s('AJAX demonstration') . '\', function(choice) { if(choice) { alert(\'' . i18n::s('OK') . '\') } })" class="button"><span>' . i18n::s('Confirmation box') . '</span></a> - ' . i18n::s('Click on the button to make your choice') . '</p>' . "\n";
// notifications
$context['text'] .= '<p style="margin-bottom: 1em;"><a href="#" onclick="Yacs.handleAlertNotification({ title: "' . i18n::s('Alert notification') . '",' . 'nick_name: "Foo Bar",' . 'address: "http://www.google.com/" })" class="button"><span>' . i18n::s('Alert notification') . '</span></a>' . ' <a href="#" onclick="Yacs.handleBrowseNotification({ message: "' . i18n::s('Browse notification') . '",' . 'nick_name: "Foo Bar",' . 'address: "http://www.google.com/" })" class="button"><span>' . i18n::s('Browse notification') . '</span></a>' . ' <a href="#" onclick="Yacs.handleHelloNotification({ message: "' . i18n::s('Hello notification') . '",' . 'nick_name: "Foo Bar" })" class="button"><span>' . i18n::s('Hello notification') . '</span></a> - ' . i18n::s('Click on buttons to process notifications') . '</p>' . "\n";
// a scaled iframe for preview
$context['text'] .= '<p style="margin-bottom: 1em;"><a href="http://www.cisco.com/" class="button tipsy_preview"><span>' . i18n::s('Cisco') . '</span></a> - ' . i18n::s('Hover the button to display a preview') . '</p>' . "\n";
// a popup box
$context['text'] .= '<p style="margin-bottom: 1em;"><a href="http://www.cisco.com/" onclick="Yacs.popup( { url: this.href, width: \'100%\', height: \'100%\' } ); return false;" class="button"><span>' . i18n::s('Cisco') . '</span></a> - ' . i18n::s('Click on the button to trigger the popup window') . '</p>' . "\n";
// a JSON-RPC call -- see services/rpc_echo_hook.php
$context['text'] .= '<p style="margin-bottom: 1em;"><a href="#" onclick="Yacs.call( { method: \'echo\', params: { message: \'' . i18n::s('AJAX demonstration') . '\' }, id: 123 }, function(s) { if(s.message) { alert(s.message); } else { alert(\'failed!\'); } } ); return false;" class="button"><span>JSON-RPC echo</span></a> - ' . i18n::s('Click on the button to call a remote function') . '</p>' . "\n";
// another JSON-RPC call -- see services/rpc_activity_hook.php
$context['text'] .= '<p style="margin-bottom: 1em;"><a href="#" onclick="Yacs.call( { method: \'user.activity\', params: { anchor: \'tools/ajax.php\', action: \'test\' } } ); alert(\'record has been added to table yacs_activities\'); return false;" class="button"><span>JSON-RPC activity</span></a> - ' . i18n::s('Click on the button to remember some on-line activity') . '</p>' . "\n";
// a popup box with content
$context['text'] .= '<p style="margin-bottom: 1em;"><a href="#" onclick="Yacs.popup( { content: \'<html><head><title>Popup</title></head><body><p>' . i18n::s('Hello world') . '</p><p>Lorem ipsum dolor sit amet, consectetur adipisicing elit,<br />sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p><p><a href="javascript:self.close()">' . i18n::s('Close') . '</a></p></body></html>\' } ); return false;" class="button"><span>' . i18n::s('Hello world') . '</span></a> - ' . i18n::s('Click on the button to trigger the popup window') . '</p>' . "\n";
// contextual handling of elements in a list
$context['text'] .= '<div class="onDemandTools mutable" style="position:relative; width: 400px; padding: 0.5em; border: 1px dotted #ccc;"><b>' . i18n::s('Hover me to access tools') . '</b>' . '<p class="properties" style="display: none">Lorem ipsum dolor sit amet, consectetur adipisicing elit,<br />sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>' . '<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit,<br />sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>' . '</div>' . "\n";
// a sortable list
$context['text'] .= '<p style="margin-bottom: 1em;"><b>' . i18n::s('Drag and drop following elements') . '</b></p>' . '<div id="sortables" style="position:relative; width: 510px; padding: 0.5em; border: 1px dotted #ccc;">' . '<div class="sortable">1. Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</div>' . '<div class="sortable">2. Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</div>' . '<div class="sortable">3. Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</div>' . '</div>' . "\n";
// filtering floating numbers
$context['text'] .= '<p style="margin-bottom: 1em;"><b>' . i18n::s('Interactive filters') . '</b></p>' . '<form>' . '<p><input type="text" size="6" onkeypress="return Yacs.filterInteger(this, event)" /> - ' . i18n::s('Enter an integer') . '</p>' . '<p><input type="text" size="6" onkeypress="return Yacs.filterFloat(this, event)" /> - ' . i18n::s('Enter a floating number') . '</p>' . '</form>' . "\n";
// autocompletion field
$context['text'] .= '<p style="margin-bottom: 1em;"><b>' . i18n::s('autocompletion') . '</b></p>' . '<form>' . '<p>' . Skin::build_autocomplete_tag_input('test_auto', 'test_auto', '', 'keywords') . '</p>' . '</form>' . "\n";
// calling raw content of a page
$context['text'] .= '<p>';
$context['text'] .= '<a class="button" id="view_1"><span>Press to open article 1 viewing page</span></a>';
$context['text'] .= '<a class="button" id="edit_1"><span>Press to open article 1 edition form</span></a>';
$context['text'] .= '</p>';
$context['text'] .= '<p><textarea size="3"></textarea>';
// some AJAX to make it work
Page::insert_script('$("#sortables .sortable").each( function() { ' . 'Yacs.addOnDemandTools($(this));}); ' . "\n" . '$("#sortables").sortable({axis: "y", handle: ".drag_handle"});' . "\n" . '$("#view_1").click(function(){Yacs.displayOverlaid(url_to_root+"articles/view.php?id=1")});' . '$("#edit_1").click(function(){Yacs.displayOverlaid(url_to_root+"articles/edit.php?id=1",true,true)});');
// render the page according to the loaded skin
render_skin();
示例14: findFrame
// members can use additional tools
if (Surfer::is_member()) {
// introduce bookmarklets
$box = '<p>' . i18n::s('To install following bookmarklets, right-click over them and add them to your bookmarks or favorites. Then recall them at any time while browsing the Internet, to add content to this site.') . '</p>' . "\n" . '<ul>';
// the blogging bookmarklet uses YACS codes
$bookmarklet = "javascript:function findFrame(f){var i;try{isThere=f.document.selection.createRange().text;}catch(e){isThere='';}if(isThere==''){for(i=0;i<f.frames.length;i++){findFrame(f.frames[i]);}}else{s=isThere}return s}" . "var s='';" . "d=document;" . "s=d.selection?findFrame(window):window.getSelection();" . "window.location='" . $context['url_to_home'] . $context['url_to_root'] . "articles/edit.php?" . "title='+escape(d.title)+'" . "&text='+escape('%22'+s+'%22%5Bnl]-- %5Blink='+d.title+']'+d.location+'%5B/link]')+'" . "&source='+escape(d.location);";
$box .= '<li><a href="' . $bookmarklet . '">' . sprintf(i18n::s('Blog at %s'), $context['site_name']) . '</a></li>' . "\n";
// the bookmarking bookmarklet
$bookmarklet = "javascript:function findFrame(f){var i;try{isThere=f.document.selection.createRange().text;}catch(e){isThere='';}if(isThere==''){for(i=0;i<f.frames.length;i++){findFrame(f.frames[i]);}}else{s=isThere}return s}" . "var s='';" . "d=document;" . "s=d.selection?findFrame(window):window.getSelection();" . "window.location='" . $context['url_to_home'] . $context['url_to_root'] . "links/edit.php?" . "link='+escape(d.location)+'" . "&title='+escape(d.title)+'" . "&text='+escape(s);";
$box .= '<li><a href="' . $bookmarklet . '">' . sprintf(i18n::s('Bookmark at %s'), $context['site_name']) . '</a></li>' . "\n";
// end of bookmarklets
$box .= '</ul>' . "\n";
// the command to add a side panel
$box .= '<p>' . sprintf(i18n::s('If your browser supports side panels and javascript, click on the following link to %s.'), '<a onclick="addSidePanel()">' . i18n::s('add a blogging panel') . '</a>.') . '</p>' . "\n";
// the actual javascript code to add a panel
Page::insert_script('function addSidePanel() {' . "\n" . ' if((typeof window.sidebar == "object") && (typeof window.sidebar.addPanel == "function")) {' . "\n" . ' window.sidebar.addPanel("' . strip_tags($context['site_name']) . '", "' . $context['url_to_home'] . $context['url_to_root'] . 'panel.php", "");' . "\n" . ' alert("' . i18n::s('The panel has been added. You may have to ask your browser to make it visible (Ctrl-B for Firefox).') . '");' . "\n" . ' } else {' . "\n" . ' if(document.all) {' . "\n" . ' window.open("' . $context['url_to_home'] . $context['url_to_root'] . 'panel.php?target=_main" ,"_search");' . "\n" . ' } else {' . "\n" . ' var rv = alert("' . i18n::s('Your browser does not support side panels. Have you considered to upgrade to Mozilla Firefox?') . '");' . "\n" . ' if(rv)' . "\n" . ' document.location.href = "http://www.mozilla.org/products/firefox/";' . "\n" . ' }' . "\n" . ' }' . "\n" . '}' . "\n");
// make a nice box out of it
$text .= Skin::build_box(i18n::s('Blogging tools'), $box);
}
// build another tab
$all_tabs = array_merge($all_tabs, array(array('content', i18n::s('Content'), 'content_panel', $text)));
//
// System Management tab
//
$text = '';
// display a system overview if not a crawler
if (!Surfer::is_crawler()) {
// use a neat table for the layout
$box = Skin::table_prefix('wide');
$lines = 1;
// yacs version
示例15: elseif
// the submit button
$menu[] = Skin::build_submit_button(i18n::s('Submit'), i18n::s('Press [s] to submit data'), 's');
// control panel
if (file_exists('../parameters/control.include.php')) {
$menu[] = Skin::build_link('control/', i18n::s('Control Panel'), 'span');
}
// all skins
if (file_exists('../parameters/control.include.php')) {
$menu[] = Skin::build_link('scripts/', i18n::s('Server software'), 'span');
}
// insert the menu in the page
$context['text'] .= Skin::finalize_list($menu, 'assistant_bar');
// end of the form
$context['text'] .= '</div></form>';
// set the focus
Page::insert_script('$("#reference_server").focus();');
// general help on this form
$help = '<p>' . i18n::s('Indicate only the DNS name or IP address of the reference server.') . '</p>';
// no modifications in demo mode
} elseif (file_exists($context['path_to_root'] . 'parameters/demo.flag')) {
Safe::header('Status: 401 Unauthorized', TRUE, 401);
Logger::error(i18n::s('You are not allowed to perform this operation in demonstration mode.'));
// save updated parameters
} else {
// backup the old version
Safe::unlink($context['path_to_root'] . 'parameters/scripts.include.php.bak');
Safe::rename($context['path_to_root'] . 'parameters/scripts.include.php', $context['path_to_root'] . 'parameters/scripts.include.php.bak');
// build the new configuration file
$content = '<?php' . "\n" . '// This file has been created by the configuration script scripts/configure.php' . "\n" . '// on ' . gmdate("F j, Y, g:i a") . ' GMT, for ' . Surfer::get_name() . '. Please do not modify it manually.' . "\n" . '$context[\'home_at_root\']=\'' . addcslashes($_REQUEST['home_at_root'], "\\'") . "';\n" . '$context[\'reference_server\']=\'' . addcslashes($_REQUEST['reference_server'], "\\'") . "';\n" . '?>' . "\n";
// update the parameters file
if (!Safe::file_put_contents('parameters/scripts.include.php', $content)) {