本文整理汇总了PHP中head_add_js函数的典型用法代码示例。如果您正苦于以下问题:PHP head_add_js函数的具体用法?PHP head_add_js怎么用?PHP head_add_js使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了head_add_js函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: b2tbtn_active
function b2tbtn_active(&$a, &$b)
{
head_add_css('/addon/b2tbtn/view/css/b2tbtn.css');
head_add_js('/addon/b2tbtn/view/js/b2tbtn.js');
$b .= "\n<script>\n\$(document).ready(function(){\n\n\t// hide #back-top first\n\t\$(\"#back-top\").hide();\n\t\n\t// fade in #back-top\n\t\$(function () {\n\t\t\$(window).scroll(function () {\n\t\t\tif (\$(this).scrollTop() > 100) {\n\t\t\t\t\$('#back-top').fadeIn();\n\t\t\t} else {\n\t\t\t\t\$('#back-top').fadeOut();\n\t\t\t}\n\t\t});\n\n\t\t// scroll body to 0px on click\n\t\t\$('#back-top a').click(function () {\n\t\t\t\$('body,html').animate({\n\t\t\t\tscrollTop: 0\n\t\t\t}, 150);\n\t\t\treturn false;\n\t\t});\n\t});\n\n});\n</script>";
$b .= '
<p id="back-top">
<a href="#top"><span></span></a>
</p>';
}
示例2: get
function get()
{
if (!local_channel()) {
return;
}
if (get_pconfig(local_channel(), 'cdav', 'enabled') != 1) {
return t('You have to enable this plugin in Feature/Addon Settings > CalDAV/CardDAV Settings before you can use it.');
}
//TODO: add a possibility to enable this plugin here.
$channel = \App::get_channel();
$principalUri = 'principals/' . $channel['channel_address'];
if (!cdav_principal($principalUri)) {
return;
}
if (\DBA::$dba && \DBA::$dba->connected) {
$pdovars = \DBA::$dba->pdo_get();
} else {
killme();
}
$pdo = new \PDO($pdovars[0], $pdovars[1], $pdovars[2]);
$pdo->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION);
require_once 'vendor/autoload.php';
head_add_css('addon/cdav/view/css/cdav.css');
if (argv(1) === 'calendar') {
$caldavBackend = new \Sabre\CalDAV\Backend\PDO($pdo);
$calendars = $caldavBackend->getCalendarsForUser($principalUri);
}
//Display calendar(s) here
if (argc() == 2 && argv(1) === 'calendar') {
head_add_css('library/fullcalendar/fullcalendar.css');
head_add_css('addon/cdav/view/css/cdav_calendar.css');
head_add_js('library/moment/moment.min.js', 1);
head_add_js('library/fullcalendar/fullcalendar.min.js', 1);
head_add_js('library/fullcalendar/locale-all.js', 1);
foreach ($calendars as $calendar) {
$editable = $calendar['share-access'] == 2 ? 'false' : 'true';
// false/true must be string since we're passing it to javascript
$color = $calendar['{http://apple.com/ns/ical/}calendar-color'] ? $calendar['{http://apple.com/ns/ical/}calendar-color'] : '#3a87ad';
$sharer = $calendar['share-access'] == 3 ? $calendar['{urn:ietf:params:xml:ns:caldav}calendar-description'] : '';
$switch = get_pconfig(local_channel(), 'cdav_calendar', $calendar['id'][0]);
if ($switch) {
$sources .= '{
url: \'/cdav/calendar/json/' . $calendar['id'][0] . '/' . $calendar['id'][1] . '\',
color: \'' . $color . '\'
}, ';
}
if ($calendar['share-access'] != 2) {
$writable_calendars[] = ['displayname' => $calendar['{DAV:}displayname'], 'sharer' => $sharer, 'id' => $calendar['id']];
}
}
$sources = rtrim($sources, ', ');
$first_day = get_pconfig(local_channel(), 'system', 'cal_first_day');
$first_day = $first_day ? $first_day : 0;
$title = ['title', t('Event title')];
$dtstart = ['dtstart', t('Start date and time'), '', t('Example: YYYY-MM-DD HH:mm')];
$dtend = ['dtend', t('End date and time'), '', t('Example: YYYY-MM-DD HH:mm')];
$description = ['description', t('Description')];
$location = ['location', t('Location')];
$o .= replace_macros(get_markup_template('cdav_calendar.tpl', 'addon/cdav'), ['$sources' => $sources, '$color' => $color, '$lang' => \App::$language, '$first_day' => $first_day, '$prev' => t('Previous'), '$next' => t('Next'), '$today' => t('Today'), '$month' => t('Month'), '$week' => t('Week'), '$day' => t('Day'), '$list_month' => t('List month'), '$list_week' => t('List week'), '$list_day' => t('List day'), '$title' => $title, '$writable_calendars' => $writable_calendars, '$dtstart' => $dtstart, '$dtend' => $dtend, '$description' => $description, '$location' => $location, '$more' => t('More'), '$less' => t('Less'), '$calendar_select_label' => t('Select calendar'), '$delete' => t('Delete'), '$delete_all' => t('Delete all'), '$cancel' => t('Cancel'), '$recurrence_warning' => t('Sorry! Editing of recurrent events is not yet implemented.')]);
return $o;
}
//Provide json data for calendar
if (argc() == 5 && argv(1) === 'calendar' && argv(2) === 'json' && intval(argv(3)) && intval(argv(4))) {
$id = [argv(3), argv(4)];
if (!cdav_perms($id[0], $calendars)) {
killme();
}
if (x($_GET, 'start')) {
$start = new \DateTime($_GET['start']);
}
if (x($_GET, 'end')) {
$end = new \DateTime($_GET['end']);
}
$filters['name'] = 'VCALENDAR';
$filters['prop-filters'][0]['name'] = 'VEVENT';
$filters['comp-filters'][0]['name'] = 'VEVENT';
$filters['comp-filters'][0]['time-range']['start'] = $start;
$filters['comp-filters'][0]['time-range']['end'] = $end;
$uris = $caldavBackend->calendarQuery($id, $filters);
if ($uris) {
$objects = $caldavBackend->getMultipleCalendarObjects($id, $uris);
foreach ($objects as $object) {
$vcalendar = \Sabre\VObject\Reader::read($object['calendardata']);
if (isset($vcalendar->VEVENT->RRULE)) {
$vcalendar = $vcalendar->expand($start, $end);
}
foreach ($vcalendar->VEVENT as $vevent) {
$title = (string) $vevent->SUMMARY;
$dtstart = (string) $vevent->DTSTART;
$dtend = (string) $vevent->DTEND;
$description = (string) $vevent->DESCRIPTION;
$location = (string) $vevent->LOCATION;
$rw = cdav_perms($id[0], $calendars, true) ? true : false;
$recurrent = isset($vevent->{'RECURRENCE-ID'}) ? true : false;
$editable = $rw ? true : false;
if ($recurrent) {
$editable = false;
}
$allDay = false;
// allDay event rules
//.........这里部分代码省略.........
示例3: construct_page
/**
* @brief build the page.
*
* Build the page - now that we have all the components
*
* @param App &$a global application object
*/
function construct_page(&$a)
{
exec_pdl($a);
$comanche = count($a->layout) ? true : false;
require_once theme_include('theme_init.php');
$installing = false;
if ($a->module == 'setup') {
$installing = true;
} else {
nav($a);
}
if ($comanche) {
if ($a->layout['nav']) {
$a->page['nav'] = get_custom_nav($a, $a->layout['nav']);
}
}
if (($p = theme_include(current_theme() . '.js')) != '') {
head_add_js($p);
}
if (($p = theme_include('mod_' . $a->module . '.php')) != '') {
require_once $p;
}
require_once 'include/js_strings.php';
if (x($a->page, 'template_style')) {
head_add_css($a->page['template_style'] . '.css');
} else {
head_add_css((x($a->page, 'template') ? $a->page['template'] : 'default') . '.css');
}
head_add_css('mod_' . $a->module . '.css');
head_add_css(current_theme_url($installing));
head_add_js('mod_' . $a->module . '.js');
$a->build_pagehead();
$arr = $a->get_widgets();
ksort($arr, SORT_NUMERIC);
if (count($arr)) {
foreach ($arr as $x) {
if (!array_key_exists($x['location'], $a->page)) {
$a->page[$x['location']] = '';
}
$a->page[$x['location']] .= $x['html'];
}
}
// Let's say we have a comanche declaration '[region=nav][/region][region=content]$nav $content[/region]'.
// The text 'region=' identifies a section of the layout by that name. So what we want to do here is leave
// $a->page['nav'] empty and put the default content from $a->page['nav'] and $a->page['section']
// into a new region called $a->data['content']. It is presumed that the chosen layout file for this comanche page
// has a '<content>' element instead of a '<section>'.
// This way the Comanche layout can include any existing content, alter the layout by adding stuff around it or changing the
// layout completely with a new layout definition, or replace/remove existing content.
if ($comanche) {
$arr = array('module' => $a->module, 'layout' => $a->layout);
call_hooks('construct_page', $arr);
$a->layout = $arr['layout'];
foreach ($a->layout as $k => $v) {
if (strpos($k, 'region_') === 0 && strlen($v)) {
if (strpos($v, '$region_') !== false) {
$v = preg_replace_callback('/\\$region_([a-zA-Z0-9]+)/ism', 'comanche_replace_region', $v);
}
// And a couple of convenience macros
if (strpos($v, '$htmlhead') !== false) {
$v = str_replace('$htmlhead', $a->page['htmlhead'], $v);
}
if (strpos($v, '$nav') !== false) {
$v = str_replace('$nav', $a->page['nav'], $v);
}
if (strpos($v, '$content') !== false) {
$v = str_replace('$content', $a->page['content'], $v);
}
$a->page[substr($k, 7)] = $v;
}
}
}
if ($a->is_mobile || $a->is_tablet) {
if (isset($_SESSION['show_mobile']) && !$_SESSION['show_mobile']) {
$link = $a->get_baseurl() . '/toggle_mobile?f=&address=' . curPageURL();
} else {
$link = $a->get_baseurl() . '/toggle_mobile?f=&off=1&address=' . curPageURL();
}
if (isset($_SESSION) && $_SESSION['mobile_theme'] != '' && $_SESSION['mobile_theme'] != '---' || isset($a->config['system']['mobile_theme']) && !isset($_SESSION['mobile_theme'])) {
$a->page['footer'] .= replace_macros(get_markup_template("toggle_mobile_footer.tpl"), array('$toggle_link' => $link, '$toggle_text' => t('toggle mobile')));
}
}
$page = $a->page;
$profile = $a->profile;
header("Content-type: text/html; charset=utf-8");
require_once theme_include((x($a->page, 'template') ? $a->page['template'] : 'default') . '.php');
}
示例4: head_add_js
head_add_js('library/readmore.js/readmore.js');
//head_add_js('library/jquery_ac/friendica.complete.js');
//head_add_js('library/tiptip/jquery.tipTip.minified.js');
head_add_js('library/jgrowl/jquery.jgrowl_minimized.js');
//head_add_js('library/tinymce/jscripts/tiny_mce/tiny_mce.js');
head_add_js('library/cryptojs/components/core-min.js');
head_add_js('library/cryptojs/rollups/aes.js');
head_add_js('library/cryptojs/rollups/rabbit.js');
head_add_js('library/cryptojs/rollups/tripledes.js');
//head_add_js('library/stylish_select/jquery.stylish-select.js');
head_add_js('acl.js');
head_add_js('webtoolkit.base64.js');
head_add_js('main.js');
head_add_js('crypto.js');
head_add_js('library/jRange/jquery.range.js');
//head_add_js('docready.js');
head_add_js('library/colorbox/jquery.colorbox-min.js');
head_add_js('library/jquery.AreYouSure/jquery.are-you-sure.js');
head_add_js('library/tableofcontents/jquery.toc.js');
head_add_js('library/imagesloaded/imagesloaded.pkgd.min.js');
/**
* Those who require this feature will know what to do with it.
* Those who don't, won't.
* Eventually this functionality needs to be provided by a module
* such that permissions can be enforced. At the moment it's
* more of a proof of concept; but sufficient for our immediate needs.
*/
$channel = App::get_channel();
if ($channel && file_exists($channel['channel_address'] . '.js')) {
head_add_js('/' . $channel['channel_address'] . '.js');
}
示例5: construct_page
/**
* @brief build the page.
*
* Build the page - now that we have all the components
*
* @param App &$a global application object
*/
function construct_page(&$a)
{
exec_pdl($a);
$comanche = count(App::$layout) ? true : false;
require_once theme_include('theme_init.php');
$installing = false;
if (App::$module == 'setup') {
$installing = true;
} else {
nav($a);
}
if ($comanche) {
if (App::$layout['nav']) {
App::$page['nav'] = get_custom_nav($a, App::$layout['nav']);
}
}
$current_theme = Zotlabs\Render\Theme::current();
if (($p = theme_include($current_theme[0] . '.js')) != '') {
head_add_js($p);
}
if (($p = theme_include('mod_' . App::$module . '.php')) != '') {
require_once $p;
}
require_once 'include/js_strings.php';
if (x(App::$page, 'template_style')) {
head_add_css(App::$page['template_style'] . '.css');
} else {
head_add_css((x(App::$page, 'template') ? App::$page['template'] : 'default') . '.css');
}
head_add_css('mod_' . App::$module . '.css');
head_add_css(Zotlabs\Render\Theme::url($installing));
head_add_js('mod_' . App::$module . '.js');
App::build_pagehead();
if (App::$page['pdl_content']) {
App::$page['content'] = App::$comanche->region(App::$page['content']);
}
// Let's say we have a comanche declaration '[region=nav][/region][region=content]$nav $content[/region]'.
// The text 'region=' identifies a section of the layout by that name. So what we want to do here is leave
// App::$page['nav'] empty and put the default content from App::$page['nav'] and App::$page['section']
// into a new region called App::$data['content']. It is presumed that the chosen layout file for this comanche page
// has a '<content>' element instead of a '<section>'.
// This way the Comanche layout can include any existing content, alter the layout by adding stuff around it or changing the
// layout completely with a new layout definition, or replace/remove existing content.
if ($comanche) {
$arr = array('module' => App::$module, 'layout' => App::$layout);
call_hooks('construct_page', $arr);
App::$layout = $arr['layout'];
foreach (App::$layout as $k => $v) {
if (strpos($k, 'region_') === 0 && strlen($v)) {
if (strpos($v, '$region_') !== false) {
$v = preg_replace_callback('/\\$region_([a-zA-Z0-9]+)/ism', array(App::$comanche, 'replace_region'), $v);
}
// And a couple of convenience macros
if (strpos($v, '$htmlhead') !== false) {
$v = str_replace('$htmlhead', App::$page['htmlhead'], $v);
}
if (strpos($v, '$nav') !== false) {
$v = str_replace('$nav', App::$page['nav'], $v);
}
if (strpos($v, '$content') !== false) {
$v = str_replace('$content', App::$page['content'], $v);
}
App::$page[substr($k, 7)] = $v;
}
}
}
if (App::$is_mobile || App::$is_tablet) {
if (isset($_SESSION['show_mobile']) && !$_SESSION['show_mobile']) {
$link = z_root() . '/toggle_mobile?f=&address=' . curPageURL();
} else {
$link = z_root() . '/toggle_mobile?f=&off=1&address=' . curPageURL();
}
if (isset($_SESSION) && $_SESSION['mobile_theme'] != '' && $_SESSION['mobile_theme'] != '---' || isset(App::$config['system']['mobile_theme']) && !isset($_SESSION['mobile_theme'])) {
App::$page['footer'] .= replace_macros(get_markup_template("toggle_mobile_footer.tpl"), array('$toggle_link' => $link, '$toggle_text' => t('toggle mobile')));
}
}
$page = App::$page;
$profile = App::$profile;
// There's some experimental support for right-to-left text in the view/php/default.php page template.
// In v1.9 we started providing direction preference in the per language hstrings.php file
// This requires somebody with fluency in a RTL language to make happen
$page['direction'] = 0;
// ((App::$rtl) ? 1 : 0);
header("Content-type: text/html; charset=utf-8");
// security headers - see https://securityheaders.io
if (App::get_scheme() === 'https' && App::$config['system']['transport_security_header']) {
header("Strict-Transport-Security: max-age=31536000");
}
if (App::$config['system']['content_security_policy']) {
header("Content-Security-Policy: script-src 'self' 'unsafe-inline' 'unsafe-eval'; style-src 'self' 'unsafe-inline'");
}
if (App::$config['system']['x_security_headers']) {
header("X-Frame-Options: SAMEORIGIN");
//.........这里部分代码省略.........
示例6: widget_rating
function widget_rating($arr)
{
$a = get_app();
$poco_rating = get_config('system', 'poco_rating_enable');
if (!$poco_rating && $poco_rating !== false) {
return;
}
if ($arr['target']) {
$hash = $arr['target'];
} else {
$hash = $a->poi['xchan_hash'];
}
if (!$hash) {
return;
}
$url = '';
$remote = false;
if (remote_channel() && !local_channel()) {
$ob = $a->get_observer();
if ($ob && $ob['xchan_url']) {
$p = parse_url($ob['xchan_url']);
if ($p) {
$url = $p['scheme'] . '://' . $p['host'] . ($p['port'] ? ':' . $p['port'] : '');
$url .= '/rate?f=&target=' . urlencode($hash);
}
$remote = true;
}
}
$self = false;
if (local_channel()) {
$channel = $a->get_channel();
if ($hash == $channel['channel_hash']) {
$self = true;
}
head_add_js('ratings.js');
}
$o = '<div class="widget">';
$o .= '<h3>' . t('Rating Tools') . '</h3>';
if (($remote || local_channel()) && !$self) {
if ($remote) {
$o .= '<a class="btn btn-block btn-primary btn-sm" href="' . $url . '"><i class="icon-pencil"></i> ' . t('Rate Me') . '</a>';
} else {
$o .= '<div class="btn btn-block btn-primary btn-sm" onclick="doRatings(\'' . $hash . '\'); return false;"><i class="icon-pencil"></i> ' . t('Rate Me') . '</div>';
}
}
$o .= '<a class="btn btn-block btn-default btn-sm" href="ratings/' . $hash . '"><i class="icon-eye-open"></i> ' . t('View Ratings') . '</a>';
$o .= '</div>';
return $o;
}
示例7: chess_content
/**
* @brief Outputs the main content of the page, depending on the URL
*
* @return string HTML content
*/
function chess_content($a)
{
// Include the custom CSS and JavaScript necessary for the chess board
head_add_css('/addon/chess/view/css/chessboard.css');
head_add_js('/addon/chess/view/js/chessboard.js');
// If the user is not a local channel, then they must use a URL like /chess/localchannel
// to specify which local channel "chess host" they are visiting
$which = null;
if (argc() > 1) {
$which = argv(1);
$user = q("select channel_id from channel where channel_address = '%s' and channel_removed = 0 limit 1", dbesc($which));
if (!$user) {
notice(t('Requested channel is not available.') . EOL);
App::$error = 404;
return;
}
}
if (!$which) {
if (local_channel()) {
$channel = App::get_channel();
if ($channel && $channel['channel_address']) {
$which = $channel['channel_address'];
}
}
}
if (!$which) {
notice(t('You must select a local channel /chess/channelname') . EOL);
return;
}
if (argc() > 2) {
switch (argv(2)) {
case 'new':
if (!local_channel()) {
notice(t('You must be logged in to see this page.') . EOL);
return;
}
$acl = new Zotlabs\Access\AccessList(App::get_channel());
$channel_acl = $acl->get();
require_once 'include/acl_selectors.php';
$channel = App::get_channel();
$o = replace_macros(get_markup_template('chess_new.tpl', 'addon/chess'), array('$acl' => populate_acl($channel_acl, false), '$allow_cid' => acl2json($channel_acl['allow_cid']), '$allow_gid' => acl2json($channel_acl['allow_gid']), '$deny_cid' => acl2json($channel_acl['deny_cid']), '$deny_gid' => acl2json($channel_acl['deny_gid']), '$channel' => $channel['channel_address']));
return $o;
default:
// argv(2) is the resource_id for an existing game
// argv(1) should be the owner channel of the game
$owner = argv(1);
$hash = q("select channel_hash from channel where channel_address = '%s' and channel_removed = 0 limit 1", dbesc($owner));
$owner_hash = $hash[0]['channel_hash'];
$game_id = argv(2);
$observer = App::get_observer();
$g = chess_get_game($game_id);
if (!$g['status'] || $g['game']['owner_xchan'] !== $owner_hash) {
notice(t('Invalid game.') . EOL);
return;
}
// Verify that observer is a valid player
$game = json_decode($g['game']['obj'], true);
if (!in_array($observer['xchan_hash'], $game['players'])) {
notice(t('You are not a player in this game.') . EOL);
goaway('/chess');
}
$player = array_search($observer['xchan_hash'], $game['players']);
$color = $game['colors'][$player];
$active = $game['active'] === $game['players'][$player] ? true : false;
$game_ended = !x($game, 'ended') || $game['ended'] === 0 ? 0 : 1;
$notify = intval(get_xconfig($observer['xchan_hash'], 'chess', 'notifications'));
logger('xconfig notifications: ' . $notify);
$o = replace_macros(get_markup_template('chess_game.tpl', 'addon/chess'), array('$myturn' => $active ? 'true' : 'false', '$active' => $active, '$color' => $color, '$game_id' => $game_id, '$position' => $game['position'], '$ended' => $game_ended, '$notifications' => $notify));
// TODO: Create settings panel to set the board size and eventually the board theme
// and other customizations
return $o;
}
}
// If the URL was simply /chess, then if the script reaches this point the
// user is a local channel, so load any games they may have as well as a board
// they can move pieces around on without storing the moves anywhere
$o .= replace_macros(get_markup_template('chess.tpl', 'addon/chess'), array('$color' => 'white'));
return $o;
}
示例8: head_add_css
<?php
head_add_css('library/font_awesome/css/font-awesome.min.css');
head_add_css('library/bootstrap/css/bootstrap-theme.min.css');
head_add_css('library/bootstrap/css/bootstrap.min.css');
head_add_css('view/css/bootstrap-red.css');
head_add_css('library/bootstrap-datetimepicker/css/bootstrap-datetimepicker.min.css');
//head_add_css('library/colorpicker/css/colorpicker.css');
head_add_css('library/bootstrap-colorpicker/dist/css/bootstrap-colorpicker.min.css');
require_once 'view/php/theme_init.php';
head_add_js('library/bootstrap/js/bootstrap.min.js');
head_add_js('library/bootstrap/js/bootbox.min.js');
head_add_js('library/bootstrap-datetimepicker/js/moment.js');
head_add_js('library/bootstrap-datetimepicker/js/bootstrap-datetimepicker.min.js');
//head_add_js('library/colorpicker/js/colorpicker.js');
head_add_js('library/bootstrap-colorpicker/dist/js/bootstrap-colorpicker.js');
//head_add_js('library/bootstrap-colorpicker/src/js/docs.js');
示例9: get
//.........这里部分代码省略.........
$resource_id = '';
// init() should have forced the URL to redirect to /wiki/channel so assume argc() > 1
$nick = argv(1);
$channel = get_channel_by_nick($nick);
// The channel who owns the wikis being viewed
if (!$channel) {
notice('Invalid channel' . EOL);
goaway('/' . argv(0));
}
// Determine if the observer is the channel owner so the ACL dialog can be populated
if (local_channel() === intval($channel['channel_id'])) {
$local_observer = \App::get_channel();
$wiki_owner = true;
// Obtain the default permission settings of the channel
$channel_acl = array('allow_cid' => $local_observer['channel_allow_cid'], 'allow_gid' => $local_observer['channel_allow_gid'], 'deny_cid' => $local_observer['channel_deny_cid'], 'deny_gid' => $local_observer['channel_deny_gid']);
// Initialize the ACL to the channel default permissions
$x = array('lockstate' => $local_observer['channel_allow_cid'] || $local_observer['channel_allow_gid'] || $local_observer['channel_deny_cid'] || $local_observer['channel_deny_gid'] ? 'lock' : 'unlock', 'acl' => populate_acl($channel_acl), 'bang' => '');
} else {
// Not the channel owner
$channel_acl = $x = array();
}
switch (argc()) {
case 2:
// Configure page template
$wikiheaderName = t('Wiki');
$wikiheaderPage = t('Sandbox');
require_once 'library/markdown.php';
$content = t('"# Wiki Sandbox\\n\\nContent you **edit** and **preview** here *will not be saved*."');
$renderedContent = Markdown(json_decode($content));
$hide_editor = false;
$showPageControls = false;
$showNewWikiButton = $wiki_owner;
$showNewPageButton = false;
$hidePageHistory = true;
$showCommitMsg = false;
break;
case 3:
// /wiki/channel/wiki -> No page was specified, so redirect to Home.md
$wikiUrlName = urlencode(argv(2));
goaway('/' . argv(0) . '/' . argv(1) . '/' . $wikiUrlName . '/Home');
case 4:
// GET /wiki/channel/wiki/page
// Fetch the wiki info and determine observer permissions
$wikiUrlName = urlencode(argv(2));
$pageUrlName = urlencode(argv(3));
$w = wiki_exists_by_name($channel['channel_id'], $wikiUrlName);
if (!$w['resource_id']) {
notice('Wiki not found' . EOL);
goaway('/' . argv(0) . '/' . argv(1));
}
$resource_id = $w['resource_id'];
if (!$wiki_owner) {
// Check for observer permissions
$observer_hash = get_observer_hash();
$perms = wiki_get_permissions($resource_id, intval($channel['channel_id']), $observer_hash);
if (!$perms['read']) {
notice('Permission denied.' . EOL);
goaway('/' . argv(0) . '/' . argv(1));
}
if ($perms['write']) {
$wiki_editor = true;
} else {
$wiki_editor = false;
}
} else {
$wiki_editor = true;
}
$wikiheaderName = urldecode($wikiUrlName);
$wikiheaderPage = urldecode($pageUrlName);
$p = wiki_get_page_content(array('resource_id' => $resource_id, 'pageUrlName' => $pageUrlName));
if (!$p['success']) {
notice('Error retrieving page content' . EOL);
goaway('/' . argv(0) . '/' . argv(1) . '/' . $wikiUrlName);
}
$content = $p['content'] !== '' ? htmlspecialchars_decode($p['content'], ENT_COMPAT) : '"# New page\\n"';
// Render the Markdown-formatted page content in HTML
require_once 'library/markdown.php';
$html = wiki_generate_toc(purify_html(Markdown(json_decode($content))));
$renderedContent = wiki_convert_links($html, argv(0) . '/' . argv(1) . '/' . $wikiUrlName);
$hide_editor = false;
$showPageControls = $wiki_editor;
$showNewWikiButton = $wiki_owner;
$showNewPageButton = $wiki_editor;
$hidePageHistory = false;
$showCommitMsg = true;
$pageHistory = wiki_page_history(array('resource_id' => $resource_id, 'pageUrlName' => $pageUrlName));
break;
default:
// Strip the extraneous URL components
goaway('/' . argv(0) . '/' . argv(1) . '/' . $wikiUrlName . '/' . $pageUrlName);
}
$wikiModalID = random_string(3);
$wikiModal = replace_macros(get_markup_template('generic_modal.tpl'), array('$id' => $wikiModalID, '$title' => t('Revision Comparison'), '$ok' => t('Revert'), '$cancel' => t('Cancel')));
$is_owner = local_channel() && local_channel() == \App::$profile['profile_uid'] ? true : false;
$o .= profile_tabs($a, $is_owner, \App::$profile['channel_address']);
$o .= replace_macros(get_markup_template('wiki.tpl'), array('$wikiheaderName' => $wikiheaderName, '$wikiheaderPage' => $wikiheaderPage, '$hideEditor' => $hide_editor, '$showPageControls' => $showPageControls, '$showNewWikiButton' => $showNewWikiButton, '$showNewPageButton' => $showNewPageButton, '$hidePageHistory' => $hidePageHistory, '$showCommitMsg' => $showCommitMsg, '$channel' => $channel['channel_address'], '$resource_id' => $resource_id, '$page' => $pageUrlName, '$lockstate' => $x['lockstate'], '$acl' => $x['acl'], '$bang' => $x['bang'], '$content' => $content, '$renderedContent' => $renderedContent, '$wikiName' => array('wikiName', t('Enter the name of your new wiki:'), '', ''), '$pageName' => array('pageName', t('Enter the name of the new page:'), '', ''), '$pageRename' => array('pageRename', t('Enter the new name:'), '', ''), '$commitMsg' => array('commitMsg', '', '', '', '', 'placeholder="(optional) Enter a custom message when saving the page..."'), '$pageHistory' => $pageHistory['history'], '$wikiModal' => $wikiModal, '$wikiModalID' => $wikiModalID, '$commit' => 'HEAD', '$embedPhotos' => t('Embed image from photo albums'), '$embedPhotosModalTitle' => t('Embed an image from your albums'), '$embedPhotosModalCancel' => t('Cancel'), '$embedPhotosModalOK' => t('OK'), '$modalchooseimages' => t('Choose images to embed'), '$modalchoosealbum' => t('Choose an album'), '$modaldiffalbum' => t('Choose a different album...'), '$modalerrorlist' => t('Error getting album list'), '$modalerrorlink' => t('Error getting photo link'), '$modalerroralbum' => t('Error getting album')));
head_add_js('library/ace/ace.js');
// Ace Code Editor
return $o;
}
示例10: get
function get()
{
require_once 'include/wiki.php';
require_once 'include/acl_selectors.php';
// TODO: Combine the interface configuration into a unified object
// Something like $interface = array('new_page_button' => false, 'new_wiki_button' => false, ...)
$wiki_owner = false;
$showNewWikiButton = false;
$showCommitMsg = false;
$hidePageHistory = false;
$pageHistory = array();
$local_observer = null;
$resource_id = '';
// init() should have forced the URL to redirect to /wiki/channel so assume argc() > 1
$nick = argv(1);
$channel = get_channel_by_nick($nick);
// The channel who owns the wikis being viewed
if (!$channel) {
notice('Invalid channel' . EOL);
goaway('/' . argv(0));
}
// Determine if the observer is the channel owner so the ACL dialog can be populated
if (local_channel() === intval($channel['channel_id'])) {
$local_observer = \App::get_channel();
$wiki_owner = true;
// Obtain the default permission settings of the channel
$channel_acl = array('allow_cid' => $local_observer['channel_allow_cid'], 'allow_gid' => $local_observer['channel_allow_gid'], 'deny_cid' => $local_observer['channel_deny_cid'], 'deny_gid' => $local_observer['channel_deny_gid']);
// Initialize the ACL to the channel default permissions
$x = array('lockstate' => $local_observer['channel_allow_cid'] || $local_observer['channel_allow_gid'] || $local_observer['channel_deny_cid'] || $local_observer['channel_deny_gid'] ? 'lock' : 'unlock', 'acl' => populate_acl($channel_acl), 'bang' => '');
} else {
// Not the channel owner
$channel_acl = $x = array();
}
switch (argc()) {
case 2:
// Configure page template
$wikiheader = t('Wiki Sandbox');
$content = '"# Wiki Sandbox\\n\\nContent you **edit** and **preview** here *will not be saved*."';
$hide_editor = false;
$showPageControls = false;
$showNewWikiButton = $wiki_owner;
$showNewPageButton = false;
$hidePageHistory = true;
$showCommitMsg = false;
break;
case 3:
// /wiki/channel/wiki -> No page was specified, so redirect to Home.md
$wikiUrlName = urlencode(argv(2));
goaway('/' . argv(0) . '/' . argv(1) . '/' . $wikiUrlName . '/Home');
case 4:
// GET /wiki/channel/wiki/page
// Fetch the wiki info and determine observer permissions
$wikiUrlName = urlencode(argv(2));
$pageUrlName = urlencode(argv(3));
$w = wiki_exists_by_name($channel['channel_id'], $wikiUrlName);
if (!$w['resource_id']) {
notice('Wiki not found' . EOL);
goaway('/' . argv(0) . '/' . argv(1));
}
$resource_id = $w['resource_id'];
if (!$wiki_owner) {
// Check for observer permissions
$observer_hash = get_observer_hash();
$perms = wiki_get_permissions($resource_id, intval($channel['channel_id']), $observer_hash);
if (!$perms['read']) {
notice('Permission denied.' . EOL);
goaway('/' . argv(0) . '/' . argv(1));
}
if ($perms['write']) {
$wiki_editor = true;
} else {
$wiki_editor = false;
}
} else {
$wiki_editor = true;
}
$wikiheader = urldecode($wikiUrlName) . ': ' . urldecode($pageUrlName);
// show wiki name and page
$p = wiki_get_page_content(array('resource_id' => $resource_id, 'pageUrlName' => $pageUrlName));
if (!$p['success']) {
notice('Error retrieving page content' . EOL);
goaway('/' . argv(0) . '/' . argv(1) . '/' . $wikiUrlName);
}
$content = $p['content'] !== '' ? $p['content'] : '"# New page\\n"';
$hide_editor = false;
$showPageControls = $wiki_editor;
$showNewWikiButton = $wiki_owner;
$showNewPageButton = $wiki_editor;
$hidePageHistory = false;
$showCommitMsg = true;
$pageHistory = wiki_page_history(array('resource_id' => $resource_id, 'pageUrlName' => $pageUrlName));
break;
default:
// Strip the extraneous URL components
goaway('/' . argv(0) . '/' . argv(1) . '/' . $wikiUrlName . '/' . $pageUrlName);
}
// Render the Markdown-formatted page content in HTML
require_once 'library/markdown.php';
$o .= replace_macros(get_markup_template('wiki.tpl'), array('$wikiheader' => $wikiheader, '$hideEditor' => $hide_editor, '$showPageControls' => $showPageControls, '$showNewWikiButton' => $showNewWikiButton, '$showNewPageButton' => $showNewPageButton, '$hidePageHistory' => $hidePageHistory, '$showCommitMsg' => $showCommitMsg, '$channel' => $channel['channel_address'], '$resource_id' => $resource_id, '$page' => $pageUrlName, '$lockstate' => $x['lockstate'], '$acl' => $x['acl'], '$bang' => $x['bang'], '$content' => $content, '$renderedContent' => Markdown(json_decode($content)), '$wikiName' => array('wikiName', t('Enter the name of your new wiki:'), '', ''), '$pageName' => array('pageName', t('Enter the name of the new page:'), '', ''), '$commitMsg' => array('commitMsg', '', '', '', '', 'placeholder="(optional) Enter a custom message when saving the page..."'), '$pageHistory' => $pageHistory['history']));
head_add_js('library/ace/ace.js');
//.........这里部分代码省略.........