本文整理汇总了PHP中loadJavascriptFile函数的典型用法代码示例。如果您正苦于以下问题:PHP loadJavascriptFile函数的具体用法?PHP loadJavascriptFile怎么用?PHP loadJavascriptFile使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了loadJavascriptFile函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: pmxc_InitContent
/**
* InitContent.
*/
function pmxc_InitContent()
{
global $user_info, $modSettings, $txt;
if ($this->visible) {
// show current time as realtime?
if (!empty($this->cfg['config']['settings']['show_time']) && !empty($this->cfg['config']['settings']['show_realtime'])) {
$cdate = date('Y,n-1,j,G,', Forum_Time()) . intval(date('i', Forum_Time())) . ',' . intval(date('s', Forum_Time()));
if (empty($modSettings['pmxUserLoginLoaded'])) {
addInlineJavascript('
var pmx_rtcFormat = {};');
}
if (empty($this->cfg['config']['settings']['rtc_format'])) {
addInlineJavascript('
pmx_rtcFormat[' . $this->cfg['id'] . '] = "' . (empty($user_info['time_format']) ? $modSettings['time_format'] : $user_info['time_format']) . '";');
} else {
addInlineJavascript('
pmx_rtcFormat[' . $this->cfg['id'] . '] = "' . $this->cfg['config']['settings']['rtc_format'] . '";');
}
if (empty($modSettings['pmxUserLoginLoaded'])) {
addInlineJavascript('
var pmx_rctMonths = new Array("' . implode('","', $txt['months']) . '");
var pmx_rctShortMonths = new Array("' . implode('","', $txt['months_short']) . '");
var pmx_rctDays = new Array("' . implode('","', $txt['days']) . '");
var pmx_rctShortDays = new Array("' . implode('","', $txt['days_short']) . '");
var pmx_rtcFormatTypes = new Array("%a", "%A", "%d", "%b", "%B", "%m", "%Y", "%y", "%H", "%I", "%M", "%S", "%p", "%%", "%D", "%e", "%R", "%T");
var pmx_rtcOffset = new Date(' . $cdate . ') - new Date();');
loadJavascriptFile(PortaMx_loadCompressed('PortaMxUser.js'), array('external' => true));
$modSettings['pmxUserLoginLoaded'] = true;
}
}
}
// return the visibility flag (true/false)
return $this->visible;
}
示例2: ModerationHome
/**
* This function basically is the home page of the moderation center.
*/
function ModerationHome()
{
global $txt, $context, $scripturl, $modSettings, $user_info, $user_settings;
loadTemplate('ModerationCenter');
loadJavascriptFile('admin.js', array('default_theme' => true), 'admin.js');
$context['page_title'] = $txt['moderation_center'];
$context['sub_template'] = 'moderation_center';
// Load what blocks the user actually can see...
$valid_blocks = array('n' => 'LatestNews', 'p' => 'Notes');
if ($context['can_moderate_groups']) {
$valid_blocks['g'] = 'GroupRequests';
}
if ($context['can_moderate_boards']) {
$valid_blocks['r'] = 'ReportedPosts';
$valid_blocks['w'] = 'WatchedUsers';
}
if (empty($user_settings['mod_prefs'])) {
$user_blocks = 'n' . ($context['can_moderate_boards'] ? 'wr' : '') . ($context['can_moderate_groups'] ? 'g' : '');
} else {
list(, $user_blocks) = explode('|', $user_settings['mod_prefs']);
}
$user_blocks = str_split($user_blocks);
$context['mod_blocks'] = array();
foreach ($valid_blocks as $k => $block) {
if (in_array($k, $user_blocks)) {
$block = 'ModBlock' . $block;
if (function_exists($block)) {
$context['mod_blocks'][] = $block();
}
}
}
}
示例3: showVerification
public function showVerification($isNew, $force_refresh = true)
{
loadTemplate('reCaptcha');
loadTemplate('VerificationControls');
loadJavascriptFile('https://www.google.com/recaptcha/api.js');
return true;
}
示例4: load_theme
public static function load_theme()
{
global $context, $modSettings, $txt, $settings, $user_info;
if (($themes = cache_get_data('TS_themes_list', 3600)) === null) {
loadLanguage('ManageThemes');
require_once SUBSDIR . '/Themes.subs.php';
$themes = availableThemes($user_info['theme'], $user_info['id']);
cache_put_data('TS_themes_list', $themes, 3600);
}
foreach ($themes[0] as $theme_id => $theme) {
$name = $theme['name'];
$selected = !empty($user_info['theme']) && $user_info['theme'] == $theme_id;
$context['ThemeSelector'][$theme_id] = array('name' => $name, 'selected' => $selected, 'variants' => array());
if (isset($theme['variants'])) {
foreach ($theme['variants'] as $key => $variant) {
$context['ThemeSelector'][$theme_id]['variants'][$key] = array('name' => $variant['label'], 'selected' => $context['theme_variant'] == '_' . $key);
}
}
}
if (!isset($context['theme_header_callbacks'])) {
$context['theme_header_callbacks'] = array();
}
$context['theme_header_callbacks'][] = 'themeselector';
loadTemplate('ThemeSelector');
loadJavascriptFile('ThemeSelector.js');
loadCSSFile('ThemeSelector.css');
}
示例5: ibb_fa_button
/**
* ibb_fa_button
*
* - Editor hook, integrate_bbc_buttons hook, Called from Editor.subs.php
* - Used to add buttons to the editor menu bar
*
* @param mixed[] $bbc_tags
*/
function ibb_fa_button(&$bbc_tags)
{
// This is the group we intend to modify
$where = $bbc_tags['row1'][2];
// And here we insert the new value after font
$bbc_tags['row1'][2] = elk_array_insert($where, 'font', array('fontawesome'), 'after', false);
// Add the javascript, this tells the editor what to do with the new button
loadJavascriptFile('faButton.plugin.js', array(), 'faButton');
// CSS specific to this button presentation in the editor toolbar
loadCSSFile('faButton.css', array(), 'fa44');
}
示例6: ibb_gist_button
/**
* ibb_gist_button
*
* - Editor hook, integrate_bbc_buttons hook, Called from Editor.subs.php
* - Used to add buttons to the editor menu bar
*
* @param mixed[] $bbc_tags
*/
function ibb_gist_button(&$bbc_tags)
{
global $context;
// This is the group we intend to modify
$where = $bbc_tags['row2'][0];
// And here we insert the new value after code
$bbc_tags['row2'][0] = elk_array_insert($where, 'code', array('gist'), 'after', false);
// Add the javascript, this tells the editor what to do with the new button
loadJavascriptFile('GistButton.js', array(), 'GistButton');
// We need to supply the css for the button image, here we use a data-url to save an image call
$context['html_headers'] .= '<style>.sceditor-button-gist div {background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAVpJREFUeNqM0s0rRGEUx/F7x0RKxob4A6bZKBYWFkLZqIkkC7FUsrCwoCxsZcN/IFmIP4E9ZWnyurBR3krZeH8b1/dMv5vTpDue+szzzL33nJ5znieIoihIGCGmMIt0+ctSbIUETbhHEbm/EqSD5PGOC2TwgHo04xaPv9tIHhbUoPUMXjAcx4aln9BKDcYxgRR20IJNDKEO69hCFie2JnYx3sGYJcQ5jrU2PTjEDbpwpeeXWPZN3NOLnLb8hm1UoaBAG3P6btR26pt4rblDDarRs6KOMh7fmr/idZxgAW3Y0H/r/IqCfYKU5o/yB1b7kY5tGp04Uwmh++5Vcx59PoGNWtV3pznQXK2SbLf76s8kVv09yLpGRro0SwoawIgrt1fNzPtT2FVd/WjVCdiL9qQb5k8ho3Ia8eTKea50TeMd2LZOXQmfmP9PrL/K3RjURTrAmk4lMcGPAAMAEvmJGW+ZZPAAAAAASUVORK5CYII=)}</style>';
}
示例7: buildTemplate
protected static function buildTemplate($notices)
{
global $context, $user_info;
loadTemplate('DismissibleNotices');
loadLanguage('DismissibleNotices');
Template_Layers::getInstance()->addAfter('notices', 'body');
loadJavascriptFile('notify.js', array('defer' => true));
loadCSSFile('notify.css');
foreach ($notices as $key => $notice) {
$notice['body'] = str_replace('{username}', $user_info['name'], $notice['body']);
$context['notices'][$key] = $notice;
}
$context['notices'] = $notices;
}
示例8: pmx_eclnonemodal
/**
* System none modal ECL init
*/
function pmx_eclnonemodal()
{
global $context, $settings, $modSettings, $maintenance, $scripturl, $options, $txt;
if (!empty($modSettings['pmx_eclmodal']) && !pmx_checkECL_Cookie()) {
if (!empty($modSettings['pmxportal_disabled'])) {
loadJavascriptFile(PortaMx_loadCompressed('PortaMx.js', array('dir' => $settings['default_theme_dir'] . '/PortaMx/Scripts/', 'url' => $settings['default_theme_url'] . '/PortaMx/Scripts/')), array('external' => true));
addInlineJavascript('
var pmxIsInit = true;');
loadLanguage('PortaMx/PortaMx');
}
addInlineJavascript('
var eclOverlay = true;
function Setlang(elm){window.location.href = elm.options[elm.selectedIndex].value;}');
loadCSSFile(PortaMx_loadCompressed('pmx_ecl.css', array('dir' => $settings['default_theme_dir'] . '/PortaMx/SysCss/', 'url' => $settings['default_theme_url'] . '/PortaMx/SysCss/')), array('external' => true));
loadtemplate('PortaMx/EclMain');
$context['template_layers'][] = 'eclmain';
}
}
示例9: pmxc_InitContent
/**
* InitContent.
*/
function pmxc_InitContent()
{
global $context, $user_info, $modSettings, $pmxCacheFunc;
// if visible init the content
if ($this->visible) {
$cbtopic = isset($_GET['topic']) ? $_GET['topic'] : 0;
if ($this->cfg['cache'] > 0) {
// check the block cache
if (($cachedata = $pmxCacheFunc['get']($this->cache_key, $this->cache_mode)) !== null) {
list($this->topics, $isRead, $this->boards, $this->cat_board) = $cachedata;
if (isset($isRead[$user_info['id']]) && array_key_exists($cbtopic, $isRead[$user_info['id']]) && empty($isRead[$user_info['id']][$cbtopic])) {
$isRead[$user_info['id']][$cbtopic] = 1;
$cachedata = array($this->topics, $isRead, $this->boards, $this->cat_board);
$pmxCacheFunc['put']($this->cache_key, $cachedata, $this->cache_time, $this->cache_mode);
}
} else {
$cachedata = $this->cbt_fetchdata();
$pmxCacheFunc['put']($this->cache_key, $cachedata, $this->cache_time, $this->cache_mode);
list($this->topics, $isRead, $this->boards, $this->cat_board) = $cachedata;
}
} else {
$cachedata = $this->cbt_fetchdata();
list($this->topics, $isRead, $this->boards, $this->cat_board) = $cachedata;
}
unset($cachedata);
$this->isRead = isset($isRead[$user_info['id']]) ? $isRead[$user_info['id']] : null;
// no boards .. disable the block
if (!empty($this->boards)) {
if (empty($modSettings['pmxCBTNavLoaded'])) {
addInlineJavascript('
var pmxCBTimages = new Array("' . $context['pmx_imageurl'] . 'minus.png", "' . $context['pmx_imageurl'] . 'plus.png");
var pmxCBTallBoards = {};');
loadJavascriptFile(PortaMx_loadCompressed('PortaMxCBTNav.js'), array('external' => true));
$modSettings['pmxCBTNavLoaded'] = true;
}
addInlineJavascript('
pmxCBTallBoards[' . $this->cfg['id'] . '] = new Array("' . implode('", "', $this->boards) . '");');
} else {
$this->visible = false;
}
}
// return the visibility flag (true/false)
return $this->visible;
}
示例10: action_index
/**
* Entrance point for the registration center, it checks permisions and forwards
* to the right method based on the subaction.
*
* - Accessed by ?action=admin;area=regcenter.
* - Requires either the moderate_forum or the admin_forum permission.
*
* @uses Login language file
* @uses Register template.
* @see Action_Controller::action_index()
*/
public function action_index()
{
global $context, $txt;
// Loading, always loading.
loadLanguage('Login');
loadTemplate('Register');
loadJavascriptFile('register.js');
$subActions = array('register' => array('controller' => $this, 'function' => 'action_register', 'permission' => 'moderate_forum'), 'agreement' => array('controller' => $this, 'function' => 'action_agreement', 'permission' => 'admin_forum'), 'reservednames' => array('controller' => $this, 'function' => 'action_reservednames', 'permission' => 'admin_forum'), 'settings' => array('controller' => $this, 'function' => 'action_registerSettings_display', 'permission' => 'admin_forum'));
// Action controller
$action = new Action('manage_registrations');
// Next create the tabs for the template.
$context[$context['admin_menu_name']]['tab_data'] = array('title' => $txt['registration_center'], 'help' => 'registrations', 'description' => $txt['admin_settings_desc'], 'tabs' => array('register' => array('description' => $txt['admin_register_desc']), 'agreement' => array('description' => $txt['registration_agreement_desc']), 'reservednames' => array('description' => $txt['admin_reserved_desc']), 'settings' => array('description' => $txt['admin_settings_desc'])));
// Work out which to call... call integrate_sa_manage_registrations
$subAction = $action->initialize($subActions, 'register');
// Final bits
$context['page_title'] = $txt['maintain_title'];
$context['sub_action'] = $subAction;
// Call the right function for this sub-action.
$action->dispatch($subAction);
}
示例11: imageNeedsCache
/**
* Images cache
*
* @name Images cache
* @copyright Images cache contributors
* @license BSD http://opensource.org/licenses/BSD-3-Clause
*
* @version 0.1
*
*/
function imageNeedsCache($img)
{
global $boardurl, $txt;
static $js_loaded = false;
$parseboard = parse_url($boardurl);
$parseimg = parse_url($img);
if (!($parseboard['scheme'] === 'https') || $parseboard['scheme'] === $parseimg['scheme']) {
return false;
}
if ($js_loaded === false) {
$js_loaded = true;
loadJavascriptFile('imgcache.js', array('defer' => true));
loadLanguage('imgcache');
}
require_once SUBSDIR . '/Graphics.subs.php';
$destination = CACHEDIR . '/img_cache_' . md5($img);
if (!file_exists($destination)) {
resizeImageFile($img, $destination, 200, 200, 3);
}
return $boardurl . '/imgcache.php?id=' . md5($img) . '" rel="cached" data-warn="' . Util::htmlspecialchars($txt['httpimgcache_warn_ext']) . '" data-url="' . Util::htmlspecialchars($img);
}
示例12: pmxc_InitContent
/**
* InitContent.
* Checks the cache status and create the content.
*/
function pmxc_InitContent()
{
global $pmxCacheFunc, $modSettings;
// if visible init the content
if ($this->visible) {
if ($this->cfg['cache'] > 0) {
// check the block cache
if (($this->faderdata = $pmxCacheFunc['get']($this->cache_key, $this->cache_mode)) === null) {
$this->getFaderData();
$pmxCacheFunc['put']($this->cache_key, $this->faderdata, $this->cache_time, $this->cache_mode);
}
} else {
$this->getFaderData();
}
if (empty($modSettings['pmxFaderLoaded'])) {
loadJavascriptFile(PortaMx_loadCompressed('PortaMxFader.js'), array('external' => true));
$modSettings['pmxFaderLoaded'] = true;
}
}
// return the visibility flag (true/false)
return $this->visible;
}
示例13: action_list
public function action_list()
{
global $txt, $context, $scripturl, $modSettings, $settings;
loadJavascriptFile('notify.js', array('defer' => true));
loadJavascriptFile('jquery.knob.js', array('defer' => true));
loadCSSFile('notify.css');
addInlineJavascript('dismissnotice_editable();', true);
$modSettings['jquery_include_ui'] = true;
loadCSSFile('dism/jquery.ui.theme.css');
loadCSSFile('dism/jquery.ui.datepicker.css');
loadCSSFile('dism/jquery.ui.d.theme.css');
loadCSSFile('dism/jquery.ui.core.css');
$possible_locals = array($txt['lang_locale']);
$b = explode('_', $txt['lang_locale']);
foreach ($b as $a) {
$possible_locals[] = $a;
}
foreach ($possible_locals as $local) {
if (file_exists($settings['default_theme_dir'] . '/scripts/datepicker-i18n/datepicker-' . $local . '.js')) {
loadJavascriptFile('datepicker-i18n/datepicker-' . $local . '.js', array('defer' => true));
break;
$context['datepicker_local'] = $local;
}
}
$list_options = array('id' => 'list_dismissible_notices', 'title' => $txt['dismissnotices_title_list'], 'items_per_page' => 20, 'base_href' => $scripturl . '?action=admin;area=dismissnotice;sa=list' . $context['session_var'] . '=' . $context['session_id'], 'default_sort_col' => 'timeadded', 'get_items' => array('function' => array($this, 'getItems')), 'get_count' => array('function' => array($this, 'countItems')), 'data_check' => array('class' => function ($rowData) {
return 'editable_' . $rowData['id_notice'];
}), 'no_items_label' => $txt['hooks_no_hooks'], 'columns' => array('timeadded' => array('header' => array('value' => $txt['dismissnotices_time_added']), 'data' => array('function' => function ($rowData) {
return standardTime($rowData['added']);
}), 'sort' => array('default' => 'added', 'reverse' => 'added DESC')), 'body' => array('header' => array('value' => $txt['dismissnotices_body']), 'data' => array('db' => 'body')), 'class' => array('header' => array('value' => $txt['dismissnotices_class']), 'data' => array('db_htmlsafe' => 'class'), 'sort' => array('default' => 'class', 'reverse' => 'class DESC')), 'expire' => array('header' => array('value' => $txt['dismissnotices_expire']), 'data' => array('function' => function ($rowData) {
return Dismissible_Notices_Integrate::formatExpireCol($rowData['expire']);
}), 'sort' => array('default' => 'expire', 'reverse' => 'expire DESC')), 'edit' => array('header' => array('value' => ''), 'data' => array('function' => function ($rowData) {
global $txt;
return '<a data-idnotice="' . $rowData['id_notice'] . '" class="dismissnotice_editable" href="#">' . $txt['modify'] . '</a>';
}))), 'additional_rows' => array(array('position' => 'bottom_of_list', 'value' => '<a id="dismissnotice_new" class="floatright linkbutton" href="#">' . $txt['new'] . '</a>')));
require_once SUBSDIR . '/GenericList.class.php';
createList($list_options);
}
示例14: PortaMx_AdminArticles
//.........这里部分代码省略.........
$where = 'WHERE a.owner = {int:owner}';
} else {
$where = '';
}
if (!isset($_SESSION['PortaMx']['filter'])) {
$_SESSION['PortaMx']['filter'] = array('category' => '', 'approved' => 0, 'active' => 0, 'myown' => 0, 'member' => '');
}
if ($_SESSION['PortaMx']['filter']['category'] != '') {
$where .= (empty($where) ? 'WHERE ' : ' AND ') . 'a.catid IN ({array_int:catfilter})';
}
if ($_SESSION['PortaMx']['filter']['approved'] != 0) {
$where .= empty($where) ? 'WHERE ' : ' AND ';
if ($_SESSION['PortaMx']['filter']['active'] != 0) {
$where .= '(a.approved = 0 OR a.active = 0)';
} else {
$where .= 'a.approved = 0';
}
}
if ($_SESSION['PortaMx']['filter']['active'] != 0) {
$where .= empty($where) ? 'WHERE ' : ' AND ';
if ($_SESSION['PortaMx']['filter']['approved'] != 0) {
$where .= '(a.active = 0 OR a.approved = 0)';
} else {
$where .= 'a.active = 0';
}
}
if ($_SESSION['PortaMx']['filter']['myown'] != 0) {
$where .= (empty($where) ? 'WHERE ' : ' AND ') . 'a.owner = {int:owner}';
}
if ($_SESSION['PortaMx']['filter']['member'] != '') {
$where .= (empty($where) ? 'WHERE ' : ' AND ') . 'm.member_name LIKE {string:memname}';
}
if (isset($_GET['pg']) && !is_array($_GET['pg'])) {
$context['pmx']['articlestart'] = PortaMx_makeSafe($_GET['pg']);
unset($_GET['pg']);
} elseif (!isset($context['pmx']['articlestart'])) {
$context['pmx']['articlestart'] = 0;
}
$cansee = allowPmx('pmx_articles, pmx_create', true);
$isadmin = allowPmx('pmx_admin');
$memerIDs = array();
$context['pmx']['articles'] = array();
$context['pmx']['article_rows'] = array();
$context['pmx']['totalarticles'] = 0;
$result = null;
$request = $smcFunc['db_query']('', '
SELECT a.id, a.name, a.catid, a.acsgrp, a.ctype, a.config, a.active, a.owner, a.created, a.approved, a.approvedby, a.updated, a.updatedby, a.content, c.artsort, c.level, c.name AS catname
FROM {db_prefix}portamx_articles AS a' . ($_SESSION['PortaMx']['filter']['member'] != '' ? '
LEFT JOIN {db_prefix}members AS m ON (a.owner = m.id_member)' : '') . '
LEFT JOIN {db_prefix}portamx_categories AS c ON (a.catid = c.id)
' . $where . '
ORDER BY a.id', array('catfilter' => Pmx_StrToArray($_SESSION['PortaMx']['filter']['category']), 'memname' => str_replace('*', '%', $_SESSION['PortaMx']['filter']['member']), 'owner' => $user_info['id']));
if ($smcFunc['db_num_rows']($request) > 0) {
while ($row = $smcFunc['db_fetch_assoc']($request)) {
$cfg = unserialize($row['config']);
if (!empty($isadmin) || $cansee && !empty($cfg['can_moderate'])) {
$memerIDs[] = $row['owner'];
$memerIDs[] = $row['approvedby'];
$memerIDs[] = $row['updatedby'];
$context['pmx']['article_rows'][$row['id']] = array('name' => $row['name'], 'cat' => str_repeat('•', $row['level']) . $row['catname']);
$result[] = array('id' => $row['id'], 'name' => $row['name'], 'catid' => $row['catid'], 'cat' => str_repeat('•', $row['level']) . $row['catname'], 'acsgrp' => $row['acsgrp'], 'ctype' => $row['ctype'], 'config' => $cfg, 'active' => $row['active'], 'owner' => $row['owner'], 'created' => $row['created'], 'approved' => $row['approved'], 'approvedby' => $row['approvedby'], 'updated' => $row['updated'], 'updatedby' => $row['updatedby'], 'content' => $row['content']);
}
}
$smcFunc['db_free_result']($request);
if (!empty($result)) {
foreach ($result as $st => $data) {
$context['pmx']['articles'][$st] = $data;
}
$context['pmx']['totalarticles'] = count($result);
if ($context['pmx']['totalarticles'] <= $context['pmx']['articlestart']) {
$context['pmx']['articlestart'] = 0;
}
// get all members names
$request = $smcFunc['db_query']('', '
SELECT id_member, member_name
FROM {db_prefix}members
WHERE id_member IN ({array_int:members})', array('members' => array_unique($memerIDs)));
if ($smcFunc['db_num_rows']($request) > 0) {
while ($row = $smcFunc['db_fetch_assoc']($request)) {
$context['pmx']['articles_member'][$row['id_member']] = $row['member_name'];
}
$smcFunc['db_free_result']($request);
}
}
}
// load popup js for overview
loadJavascriptFile(PortaMx_loadCompressed('PortaMxPopup.js'), array('external' => true));
} elseif (empty($_POST['save_edit'])) {
// prepare the editor
PortaMx_EditArticle($article['ctype'], 'content', $article['content']);
// load the class file and create the object
require_once $context['pmx_sysclassdir'] . 'PortaMx_AdminArticlesClass.php';
$context['pmx']['editarticle'] = new PortaMxC_SystemAdminArticle($article);
$context['pmx']['editarticle']->pmxc_AdmArticle_loadinit();
}
} else {
fatal_error($txt['pmx_acces_error']);
}
}
}
示例15: create_control_richedit
/**
* Creates a box that can be used for richedit stuff like BBC, Smileys etc.
* @param mixed[] $editorOptions associative array of options => value
* must contain:
* - id => unique id for the css
* - value => text for the editor or blank
* Optionaly
* - height => height of the intial box
* - width => width of the box (100%)
* - force_rich => force wysiwyg to be enabled
* - disable_smiley_box => boolean to turn off the smiley box
* - labels => array(
* - 'post_button' => $txt['for post button'],
* ),
* - preview_type => 2 how to act on preview click, see template_control_richedit_buttons
*/
function create_control_richedit($editorOptions)
{
global $txt, $modSettings, $options, $context, $settings, $user_info, $scripturl;
static $bbc_tags;
$db = database();
// Load the Post language file... for the moment at least.
loadLanguage('Post');
if (!empty($context['drafts_save']) || !empty($context['drafts_pm_save'])) {
loadLanguage('Drafts');
}
// Every control must have a ID!
assert(isset($editorOptions['id']));
assert(isset($editorOptions['value']));
// Is this the first richedit - if so we need to ensure things are initialised and that we load all of the needed files
if (empty($context['controls']['richedit'])) {
// Store the name / ID we are creating for template compatibility.
$context['post_box_name'] = $editorOptions['id'];
// Some general stuff.
$settings['smileys_url'] = $modSettings['smileys_url'] . '/' . $user_info['smiley_set'];
if (!empty($context['drafts_autosave']) && !empty($options['drafts_autosave_enabled'])) {
$context['drafts_autosave_frequency'] = empty($modSettings['drafts_autosave_frequency']) ? 30000 : $modSettings['drafts_autosave_frequency'] * 1000;
}
// This really has some WYSIWYG stuff.
loadTemplate('GenericControls', 'jquery.sceditor');
if (!empty($context['theme_variant']) && file_exists($settings['theme_dir'] . '/css/' . $context['theme_variant'] . '/jquery.sceditor.elk' . $context['theme_variant'] . '.css')) {
loadCSSFile($context['theme_variant'] . '/jquery.sceditor.elk' . $context['theme_variant'] . '.css');
}
// JS makes the editor go round
loadJavascriptFile(array('jquery.sceditor.min.js', 'jquery.sceditor.bbcode.min.js', 'jquery.sceditor.elkarte.js', 'post.js', 'splittag.plugin.js', 'dropAttachments.js'));
addJavascriptVar(array('post_box_name' => $editorOptions['id'], 'elk_smileys_url' => $settings['smileys_url'], 'bbc_quote_from' => $txt['quote_from'], 'bbc_quote' => $txt['quote'], 'bbc_search_on' => $txt['search_on']), true);
// Editor language file
if (!empty($txt['lang_locale'])) {
loadJavascriptFile($scripturl . '?action=jslocale;sa=sceditor', array('defer' => true), 'sceditor_language');
}
// Drafts?
if ((!empty($context['drafts_save']) || !empty($context['drafts_pm_save'])) && !empty($context['drafts_autosave']) && !empty($options['drafts_autosave_enabled'])) {
loadJavascriptFile('drafts.plugin.js');
}
// Mentions?
if (!empty($context['mentions_enabled'])) {
loadJavascriptFile(array('jquery.atwho.js', 'jquery.caret.min.js', 'mentioning.plugin.js'));
}
// Our not so concise shortcut line
$context['shortcuts_text'] = $txt['shortcuts' . (!empty($context['drafts_save']) || !empty($context['drafts_pm_save']) ? '_drafts' : '') . (isBrowser('is_firefox') ? '_firefox' : '')];
// Spellcheck?
$context['show_spellchecking'] = !empty($modSettings['enableSpellChecking']) && function_exists('pspell_new');
if ($context['show_spellchecking']) {
// Some hidden information is needed in order to make spell check work.
if (!isset($_REQUEST['xml'])) {
$context['insert_after_template'] .= '
<form name="spell_form" id="spell_form" method="post" accept-charset="UTF-8" target="spellWindow" action="' . $scripturl . '?action=spellcheck">
<input type="hidden" name="spellstring" value="" />
<input type="hidden" name="fulleditor" value="" />
</form>';
}
loadJavascriptFile('spellcheck.js', array('defer' => true));
}
}
// Start off the editor...
$context['controls']['richedit'][$editorOptions['id']] = array('id' => $editorOptions['id'], 'value' => $editorOptions['value'], 'rich_active' => !empty($options['wysiwyg_default']) || !empty($editorOptions['force_rich']) || !empty($_REQUEST[$editorOptions['id'] . '_mode']), 'disable_smiley_box' => !empty($editorOptions['disable_smiley_box']), 'columns' => isset($editorOptions['columns']) ? $editorOptions['columns'] : 60, 'rows' => isset($editorOptions['rows']) ? $editorOptions['rows'] : 18, 'width' => isset($editorOptions['width']) ? $editorOptions['width'] : '100%', 'height' => isset($editorOptions['height']) ? $editorOptions['height'] : '250px', 'form' => isset($editorOptions['form']) ? $editorOptions['form'] : 'postmodify', 'bbc_level' => !empty($editorOptions['bbc_level']) ? $editorOptions['bbc_level'] : 'full', 'preview_type' => isset($editorOptions['preview_type']) ? (int) $editorOptions['preview_type'] : 1, 'labels' => !empty($editorOptions['labels']) ? $editorOptions['labels'] : array(), 'locale' => !empty($txt['lang_locale']) ? $txt['lang_locale'] : 'en_US');
// Switch between default images and back... mostly in case you don't have an PersonalMessage template, but do have a Post template.
if (isset($settings['use_default_images']) && $settings['use_default_images'] == 'defaults' && isset($settings['default_template'])) {
$temp1 = $settings['theme_url'];
$settings['theme_url'] = $settings['default_theme_url'];
$temp2 = $settings['images_url'];
$settings['images_url'] = $settings['default_images_url'];
$temp3 = $settings['theme_dir'];
$settings['theme_dir'] = $settings['default_theme_dir'];
}
if (empty($bbc_tags)) {
// The below array is used to show a command button in the editor, the execution
// and display details of any added buttons must be defined in the javascript files
// see jquery.sceditor.elkarte.js under the $.sceditor.plugins.bbcode.bbcode area
// for examples of how to use the .set command to add codes. Include your new
// JS with addInlineJavascript() or loadJavascriptFile()
$bbc_tags['row1'] = array(array('bold', 'italic', 'underline', 'strike', 'superscript', 'subscript'), array('left', 'center', 'right', 'pre', 'tt'), array('font', 'size', 'color'));
$bbc_tags['row2'] = array(array('quote', 'code', 'table'), array('bulletlist', 'orderedlist', 'horizontalrule'), array('spoiler', 'footnote'), array('image', 'link', 'email'));
// Allow mods to add BBC buttons to the toolbar, actions are defined in the JS
call_integration_hook('integrate_bbc_buttons', array(&$bbc_tags));
// Show the wysiwyg format and toggle buttons?
$bbc_tags['row2'][] = array('removeformat', 'source');
// Generate a list of buttons that shouldn't be shown
$disabled_tags = array();
if (!empty($modSettings['disabledBBC'])) {
//.........这里部分代码省略.........