本文整理汇总了PHP中cmsFramework::addScript方法的典型用法代码示例。如果您正苦于以下问题:PHP cmsFramework::addScript方法的具体用法?PHP cmsFramework::addScript怎么用?PHP cmsFramework::addScript使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cmsFramework
的用法示例。
在下文中一共展示了cmsFramework::addScript方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: js
function js($files, $inline = false, $duress = false)
{
// Register in header to prevent duplicates
$registry = ClassRegistry::getObject('javascript');
if (is_array($files)) {
$out = '';
foreach ($files as $i) {
if ($duress || !isset($registry[$i])) {
$out .= "\n\t" . $this->js($i, $inline, $duress);
}
}
if ($out != '' && $inline) {
echo $out . "\n";
}
return;
}
ClassRegistry::setObject($files, 1, 'javascript');
if (substr($files, -3) != '.js') {
$files = $files . '.js';
}
if (false !== strpos($files, MVC_ADMIN)) {
// Automatic routing to admin path
$files = str_replace(MVC_ADMIN . '/', '', $files);
$jsUrl = $this->locateScript($files, true);
} else {
$jsUrl = $this->locateScript($files);
}
if ($jsUrl) {
$out = sprintf($this->tags['javascriptlink'], $jsUrl);
cmsFramework::addScript($out, $inline, $duress);
}
}
示例2: startup
function startup(&$controller)
{
$this->c =& $controller;
if (!$this->runPlugin($controller)) {
return false;
}
// Initialize vars
$center = array();
$address = '';
$lat = 0;
$lon = 0;
if (!isset($controller->Config)) {
$controller->Config = Configure::read('JreviewsSystem.Config');
}
if (!isset($controller->Access)) {
$controller->Config = Configure::read('JreviewsSystem.Access');
}
$this->max_radius = Sanitize::getInt($controller->Config, 'geomaps.max_radius', $this->max_radius);
$this->jr_lat = Sanitize::getString($controller->Config, 'geomaps.latitude');
$this->jr_lon = Sanitize::getString($controller->Config, 'geomaps.longitude');
if ($this->jr_lat == '' || $this->jr_lon == '') {
return false;
}
// Setup vars used in startup and other plugin methods
$this->google_url = Sanitize::getString($this->c->Config, 'geomaps.google_url', 'http://maps.google.com');
$this->google_api_key = trim(Sanitize::getString($controller->Config, 'geomaps.google_key'));
$this->google_api_url = $this->google_url . "/maps?file=api&v=2&async=2&key={$this->google_api_key}&sensor=false";
$search_method = Sanitize::getString($controller->Config, 'geomaps.search_method', 'address');
// address/disabled
$search_address_field = Sanitize::getString($controller->Config, 'geomaps.advsearch_input');
$default_radius = Sanitize::getString($controller->Config, 'geomaps.radius');
$this->distance_metric = array('mi' => __t("Miles", true), 'km' => __t("Km", true));
$this->distance_in = Sanitize::getString($controller->Config, 'geomaps.radius_metric', 'mi');
$this->jr_address1 = Sanitize::getString($controller->Config, 'geomaps.address1');
$this->jr_address2 = Sanitize::getString($controller->Config, 'geomaps.address2');
$this->jr_city = Sanitize::getString($controller->Config, 'geomaps.city');
$this->jr_state = Sanitize::getString($controller->Config, 'geomaps.state');
$this->jr_postal_code = Sanitize::getString($controller->Config, 'geomaps.postal_code');
$this->jr_country = Sanitize::getString($controller->Config, 'geomaps.country');
$this->country_def = Sanitize::getString($controller->Config, 'geomaps.default_country');
$this->gid = $controller->Access->gid;
$this->address_fields = array_filter(array('address1' => $this->jr_address1, 'address2' => $this->jr_address2, 'city' => $this->jr_city, 'state' => $this->jr_state, 'postal_code' => $this->jr_postal_code, 'country' => $this->jr_country));
$this->geo_fields = array('lat' => $this->jr_lat, 'lon' => $this->jr_lon);
$this->c->set(array('address_fields' => $this->address_fields, 'geo_fields' => $this->geo_fields));
/**
* Address search checks
*/
if (isset($controller->data['Field']['Listing'])) {
$address = Sanitize::getString($controller->data['Field']['Listing'], $search_address_field);
} else {
$address = Sanitize::getString($controller->params, $search_address_field);
$lat = Sanitize::getFloat($controller->params, $this->jr_lat);
$lon = Sanitize::getFloat($controller->params, $this->jr_lon);
}
/**
* Plugin does different things for different controller methods
*/
switch ($controller->name) {
case 'com_content':
$this->published = true;
$controller->Listing->cacheCallbacks[] = 'plgAfterAfterFind';
$controller->Listing->fields[] = "`Field`.{$this->jr_lat} AS `Geomaps.lat`";
$controller->Listing->fields[] = "`Field`.{$this->jr_lon} AS `Geomaps.lon`";
$controller->Listing->fields[] = "JreviewsCategory.marker_icon AS `Geomaps.icon`";
break;
case 'listings':
switch ($controller->action) {
// Load the geomaps js library
case 'create':
// Submit a new listing
// Submit a new listing
case 'edit':
// Edit a listing
$this->published = true;
$Html = new HtmlHelper();
$Html->app = 'jreviews';
$jsGlobals = 'var GeomapsGoogleApi = "' . $this->google_api_url . '";';
$jsGlobals .= 'var jr_lat = "' . $this->jr_lat . '";';
$jsGlobals .= 'var jr_lon = "' . $this->jr_lon . '";';
$jsGlobals .= 'var jr_country_def = "' . $this->country_def . '";';
$jsGlobals .= 'var geoAddressObj = {};';
foreach ($this->address_fields as $key => $field) {
$jsGlobals .= "geoAddressObj.{$key} = '{$field}';";
}
cmsFramework::addScript($controller->makeJS($jsGlobals), true);
$Html->js('geomaps', true);
if ($controller->action == 'edit') {
$mapit_field = Sanitize::getString($controller->Config, 'geomaps.mapit_field');
if ($mapit_field) {
$response = "jQuery(document).ready(function() { \r\n jQuery('#{$mapit_field}','#jr_listingForm').after('<span id=\"gm_geocode\">\r\n <input class=\"jrButton\" type=\"button\" onclick=\"geomaps.mapPopupSimple();\" value=\"" . __t("Map it", true) . "\" /> \r\n <input class=\"jrButton\" type=\"button\" onclick=\"geomaps.clearLatLng();\" value=\"" . __t("Clear LatLng", true) . "\" />\r\n </span>');\r\n });";
cmsFramework::addScript($controller->makeJS($response), true);
}
}
break;
// Add geomaps buttons after form is loaded
// Add geomaps buttons after form is loaded
case '_loadForm':
// New listing - Loads submit listing form after category selection
$this->published = true;
$mapit_field = Sanitize::getString($controller->Config, 'geomaps.mapit_field');
//.........这里部分代码省略.........
示例3: ModuleDirectories
function ModuleDirectories()
{
$module_id = Sanitize::getInt($this->params, 'module_id', rand());
$inline = in_array(getCmsVersion(), array(CMS_JOOMLA10, CMS_MAMBO46));
$assets = array('js' => array('jquery', 'jq.treeview'), 'css' => array('theme', 'jq.treeview'));
$this->send($assets, $inline);
// Render tree view
cmsFramework::addScript("\n <script type=\"text/javascript\">\n jQuery(document).ready(function() {\n jQuery('#jr_treeView{$module_id}').treeview({\n animated: 'fast',\n unique: true,\n collaped: false,\n persist: 'location'\n });\n }); \n </script> \n ");
}
示例4: send
function send($assets, $inline = false)
{
# Load javascript libraries
$findjQuery = false;
$this->Html->app = $this->app;
unset($this->viewVars);
/**
* Send cachable scripts to the head tag from controllers and components by adding it to the head array
*/
if (!empty($this->assets['head-top'])) {
foreach ($this->assets['head-top'] as $head) {
cmsFramework::addScript($head);
}
}
// Incorporate controller set assets before sending
if (!empty($this->assets['js'])) {
$assets['js'] = array_merge($assets['js'], $this->assets['js']);
}
if (!empty($this->assets['css'])) {
$assets['css'] = array_merge($assets['css'], $this->assets['css']);
}
$assets['css'][] = 'custom_styles';
cmsFramework::isRTL() and $assets['css'][] = 'rtl';
# Load CSS stylesheets
if (isset($assets['css']) && !empty($assets['css'])) {
$findjQueryUI = array_search('jq.ui.core', $assets['css']);
if ($findjQueryUI !== false) {
if (defined('J_JQUERYUI_LOADED')) {
unset($assets['css'][array_search('jq.ui.core', $assets['css'])]);
} else {
define('J_JQUERYUI_LOADED', 1);
}
}
$this->Html->css(arrayFilter($assets['css'], $this->Libraries->css()), $inline);
}
// For CB
// Check is done against constants defined in those applications
if (isset($assets['js']) && !empty($assets['js'])) {
$findjQuery = array_search('jquery', $assets['js']);
$findjQueryUI = array_search('jq.ui.core', $assets['js']);
if ($findjQuery !== false) {
if (defined('J_JQUERY_LOADED') || JFactory::getApplication()->get('jquery')) {
unset($assets['js'][$findjQuery]);
} else {
define('J_JQUERY_LOADED', 1);
// JFactory::getApplication()->set('jquery', true); This was for Warp, but it loads too late. jQuery must be manually disabled in the configuration
// define( 'C_ASSET_JQUERY', 1 );
}
}
if ($findjQueryUI != false) {
$locale = cmsFramework::locale();
$assets['js'][] = 'jquery/i18n/jquery.ui.datepicker-' . $locale;
}
}
if (isset($assets['js']) && !empty($assets['js'])) {
$this->Html->js(arrayFilter($assets['js'], $this->Libraries->js()), $inline);
}
# Set jQuery defaults
if ($findjQuery && isset($assets['js']['jreviews'])) {
?>
<script type="text/javascript">
/* <![CDATA[ */
jreviews.ajax_init();
/* ]]> */
</script>
<?php
}
if (isset($this->Config) && Sanitize::getBool($this->Config, 'ie6pngfix')) {
$App =& App::getInstance($this->app);
$AppPaths = $App->{$this->app . 'Paths'};
$jsUrl = isset($AppPaths['Javascript']['jquery/jquery.pngfix.pack.js']) ? $AppPaths['Javascript']['jquery/jquery.pngfix.pack.js'] : false;
if ($jsUrl) {
cmsFramework::addScript('<!--[if lte IE 6]><script type="text/javascript" src="' . $jsUrl . '"></script><script type="text/javascript">jQuery(document).ready(function(){jQuery(document).pngFix();});</script><![endif]-->');
}
unset($App, $AppPaths);
}
/**
* Send cachable scripts to the head tag from controllers and components by adding it to the head array
*/
if (!empty($this->assets['head'])) {
foreach ($this->assets['head'] as $head) {
cmsFramework::addScript($head);
}
}
}
示例5: loadAssets
/**
* Adds js and css assets to the assets array to be processed later on by the assets helper
* Need to be set here instead of theme files for pages that can be cached
*
*/
function loadAssets()
{
switch ($this->c->name) {
case 'com_content':
cmsFramework::addScript('<script src="' . $this->google_url . '/maps?file=api&v=2&sensor=false&key=' . Sanitize::getString($this->c->Config, 'geomaps.google_key') . '" type="text/javascript"></script>');
$this->c->assets['css'][] = 'geomaps';
if ($this->c->action == 'com_content_view') {
$this->c->assets['js'] = array('geomaps');
}
break;
case 'categories':
$this->c->assets['css'][] = 'geomaps';
$this->c->assets['js'] = array('jquery', 'jquery/jquery.scroll-follow', 'geomaps');
break;
}
}
示例6: transform
function transform($return = false)
{
switch ($this->editor) {
case 'tinyMCE':
case 'JCE':
if ($return == true) {
return "jQuery('.wysiwyg_editor').tinyMCE();";
} else {
cmsFramework::addScript("<script type='text/javascript'>jQuery(document).ready(function() {jQuery('.wysiwyg_editor').tinyMCE();});</script>");
}
break;
}
}
示例7: facebookOpenGraph
/**
* Facebook Open Graph implementation
*
* @param mixed $listing
* @param mixed $meta
*/
function facebookOpenGraph(&$listing, $meta)
{
// http://developers.facebook.com/docs/opengraph/
$option = Sanitize::getString($_REQUEST, 'option', '');
$view = Sanitize::getString($_REQUEST, 'view', '');
$id = Sanitize::getInt($_REQUEST, 'id');
// Make sure this is a Joomla article page
if (!($option == 'com_content' && $view == 'article' && $id)) {
return;
}
$Config = Configure::read('JreviewsSystem.Config');
if (empty($Config)) {
$cache_file = 'jreviews_config_' . md5(cmsFramework::getConfig('secret'));
$Config = S2Cache::read($cache_file);
}
$facebook_xfbml = Sanitize::getBool($Config, 'facebook_opengraph') && Sanitize::getBool($Config, 'facebook_appid');
// Make sure FB is enabled and we have an FB App Id
if (!$facebook_xfbml) {
return;
}
extract($meta);
$title == '' and $title = $listing['Listing']['title'];
$description == '' and $description = Sanitize::htmlClean(Sanitize::stripAll($listing['Listing'], 'summary'));
$image = isset($listing['Listing']['images'][0]) ? cmsFramework::makeAbsUrl(_DS . _JR_WWW_IMAGES . $listing['Listing']['images'][0]['path']) : null;
if (!$image) {
$img_src = '/<img[^>]+src[\\s=\'"]+([^"\'>\\s]+(jpg)+)/is';
preg_match($img_src, $listing['Listing']['summary'], $matches);
if (isset($matches[1])) {
$image = $matches[1];
}
}
$url = cmsFramework::makeAbsUrl($listing['Listing']['url'], array('sef' => true, 'ampreplace' => true));
$fields = $listing['Field']['pairs'];
// You can add other Open Graph meta tags by adding the attribute, custom field pair to the array below
$tags = array('title' => $title, 'url' => $url, 'image' => $image, 'site_name' => cmsFramework::getConfig('sitename'), 'description' => $description, 'type' => Sanitize::getString($listing['ListingType']['config'], 'facebook_opengraph_type'), 'latitude' => Sanitize::getString($Config, 'geomaps.latitude'), 'longitude' => Sanitize::getString($Config, 'geomaps.longitude'), 'street-address' => Sanitize::getString($Config, 'geomaps.address1'), 'locality' => Sanitize::getString($Config, 'geomaps.city'), 'region' => Sanitize::getString($Config, 'geomaps.state'), 'postal-code' => Sanitize::getString($Config, 'geomaps.postal_code'), 'country-name' => Sanitize::getString($Config, 'geomaps.country', Sanitize::getString($Config, 'geomaps.default_country')));
cmsFramework::addScript('<meta property="fb:app_id" content="' . Sanitize::getString($Config, 'facebook_appid') . '"/>');
Sanitize::getString($Config, 'facebook_admins') != '' and cmsFramework::addScript('<meta property="fb:admins" content="' . str_replace(' ', '', $Config->facebook_admins) . '"/>');
// cmsFramework::addScript('<meta property="fb:admins" content="YOUR-ADMIN-ID"/>'); // It's app_id or this, not both
# Loop through the tags array to add the additional FB meta tags
foreach ($tags as $attr => $fname) {
$content = '';
if (substr($fname, 0, 3) == 'jr_') {
// It's a custom field
$content = isset($fields[$fname]) ? htmlspecialchars($fields[$fname]['text'][0], ENT_QUOTES, 'utf-8') : '';
} elseif ($fname != '') {
// It's a static text, not a custom field
$content = htmlspecialchars($fname);
}
$content != '' and cmsFramework::addScript('<meta property="og:' . $attr . '" content="' . $content . '"/>');
}
}
示例8: beforeFilter
function beforeFilter()
{
# Init Access
if (isset($this->Access)) {
$this->Access->init($this->Config);
}
# Dynamic Community integration loading
$community_extension = Configure::read('Community.extension');
$community_extension = $community_extension != '' ? $community_extension : 'community_builder';
App::import('Model', $community_extension, 'jreviews');
$this->Community = new CommunityModel();
# Set Theme
$this->viewTheme = $this->Config->template;
$this->viewImages = S2Paths::get('jreviews', 'S2_THEMES_URL') . 'default' . _DS . 'theme_images' . _DS;
# Set template type for lists and template suffix
$this->__initTemplating();
# Set pagination vars
// First check url, then menu parameter. Otherwise the limit list in pagination doesn't respond b/c menu params always wins
$this->limit = Sanitize::getInt($this->params, 'limit', Sanitize::getInt($this->data, 'limit_special', Sanitize::getInt($this->data, 'limit')));
// $this->passedArgs['limit'] = $this->limit;
$this->page = Sanitize::getInt($this->data, 'page', Sanitize::getInt($this->params, 'page', 1));
if (!$this->limit) {
if (Sanitize::getVar($this->params, 'action') == 'myreviews') {
$this->limit = Sanitize::getInt($this->params, 'limit', $this->Config->user_limit);
} else {
$this->limit = Sanitize::getInt($this->params, 'limit', $this->Config->list_limit);
}
}
// Set a hard code limit to prevent abuse
$this->limit = max(min($this->limit, 50), 1);
// Need to normalize the limit var for modules
if (isset($this->params['module'])) {
$module_limit = Sanitize::getInt($this->params['module'], 'module_limit', 5);
} else {
$module_limit = 5;
}
$this->module_limit = Sanitize::getInt($this->data, 'module_limit', $module_limit);
$this->module_page = Sanitize::getInt($this->data, 'module_page', 1);
$this->module_page = $this->module_page === 0 ? 1 : $this->module_page;
$this->module_offset = (int) ($this->module_page - 1) * $this->module_limit;
if ($this->module_offset < 0) {
$this->module_offset = 0;
}
$this->page = $this->page === 0 ? 1 : $this->page;
$this->offset = (int) ($this->page - 1) * $this->limit;
if ($this->offset < 0) {
$this->offset = 0;
}
# Add global javascript variables
if (!defined('MVC_GLOBAL_JS_VARS') && !$this->ajaxRequest && $this->action != '_save') {
cmsFramework::addScript('<script type="text/javascript">
//<![CDATA[
var xajaxUri = "' . getXajaxUri() . '";
//]]>
</script>');
cmsFramework::addScript('<script type="text/javascript">
//<![CDATA[
var s2AjaxUri = "' . getAjaxUri() . '";
//]]>
</script>');
cmsFramework::addScript('<script type="text/javascript">
var jr_translate= new Array();
jr_translate["cancel"] = "' . __t("Cancel", true) . '";
jr_translate["submit"] = "' . __t("Submit", true) . '";
</script>');
$javascriptcode = '<script type="text/javascript">%s</script>';
# Set calendar image
cmsFramework::addScript(sprintf($javascriptcode, 'var datePickerImage = "' . $this->viewImages . 'calendar.gif";'));
# Find and set one public Itemid to use for Ajax requests
$menu_id = '';
if (!defined('MVC_FRAMEWORK_ADMIN')) {
App::import('Model', 'menu', 'jreviews');
$MenuModel = RegisterClass::getInstance('MenuModel');
$menu_id = $MenuModel->get('jreviews_public');
$menu_id = $menu_id != '' ? $menu_id : 99999;
$this->set('public_menu_id', $menu_id);
}
# Set JReviews public menu
cmsFramework::addScript(sprintf($javascriptcode, 'var jr_publicMenu = ' . $menu_id . ';'));
define('MVC_GLOBAL_JS_VARS', 1);
}
# Init plugin system
$this->_initPlugins();
}
示例9: loadXajax
function loadXajax()
{
// Prevents xajax from loading twice if already loaded by jReviews or BlueFlame Platform
if (!class_exists('xajax') && !defined('XAJAX_LOADED') && !defined('XAJAX_VER')) {
define('XAJAX_LOADED', 1);
App::import('Vendor', 'xajax_05final' . DS . 'xajax_core' . DS . 'xajax.inc');
if (defined('MVC_FRAMEWORK_ADMIN')) {
$xajax = new xajax('index2.php?option=' . S2Paths::get('jreviews', 'S2_CMSCOMP') . '&task=xajax&no_html=1');
} else {
$xajax = new xajax();
}
$xajax->setCharEncoding(strtoupper(cmsFramework::getCharset()));
if (strtolower(cmsFramework::getCharset()) == 'utf-8') {
$decodeUTF8 = false;
} else {
$decodeUTF8 = true;
}
/* Set defaults from params */
$this->xajax_statusMessage ? $xajax->setFlag('statusMessages', true) : $xajax->setFlag('statusMessages', false);
$this->xajax_waitCursor ? $xajax->setFlag('waitCursor', true) : $xajax->setFlag('waitCursor', false);
$this->xajax_debug ? $xajax->setFlag('debug', true) : $xajax->setFlag('debug', false);
$decodeUTF8 ? $xajax->setFlag('decodeUTF8Input', true) : $xajax->setFlag('decodeUTF8Input', false);
$xajax->registerFunction('xajaxDispatch');
// ob_start('ob_gzhandler'); // Results in wrong encoding error ni certain servers
$xajax->processRequest();
$js = $xajax->getJavascript(S2_VENDORS_URL . 'xajax_05final' . _DS);
cmsFramework::addScript($js);
}
}
示例10: js
function js($files, $inline = false, $duress = false, $nocache = false)
{
/**
* BYPASSES THE JS METHOD IN FAVOR OF CJS (cached)
*/
if (Configure::read('Cache.assets_js') && !defined('MVC_FRAMEWORK_ADMIN') && !$inline && $nocache === false) {
$this->cjs($files, $duress);
return;
}
// Register in header to prevent duplicates
$headCheck = RegisterClass::getInstance('HeadTracking');
if (is_array($files)) {
$out = '';
foreach ($files as $i) {
// Check if already in header
if ($duress || !$headCheck->check($i, 'js')) {
$out .= "\n\t" . $this->js($i, $inline, $duress, $nocache);
}
}
if ($out != '' && $inline) {
echo $out . "\n";
}
return;
}
$headCheck->register($files, 'js');
if (empty($this->AppPaths)) {
$App =& App::getInstance($this->app);
$this->AppPaths = $App->{$this->app . 'Paths'};
}
if (!strstr($files, '.js')) {
$files = $files . '.js';
}
if (false !== strpos($files, MVC_ADMIN)) {
// Automatic routing to admin path
$files = str_replace(MVC_ADMIN . '/', '', $files);
$jsUrl = $this->locateScript($files, true);
} else {
$jsUrl = $this->locateScript($files);
}
if ($jsUrl) {
$out = sprintf($this->tags['javascriptlink'], $jsUrl);
cmsFramework::addScript($out, $inline, $duress);
}
}