summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCraig Andrews <candrews@integralblue.com>2009-12-04 19:41:51 -0500
committerCraig Andrews <candrews@integralblue.com>2009-12-04 19:41:51 -0500
commit4c8bed8ba0558c5834621331f253e05029fa4e43 (patch)
tree796607aa0a8b6a7ce4ef73090a8b255a6b2bacdd
parentaab7344002fd390e5b62a3eb82f3a418fd294617 (diff)
Use inlineScript() everywhere inline scripts are written
-rw-r--r--lib/messageform.php3
-rw-r--r--lib/noticeform.php3
-rw-r--r--plugins/Facebook/FacebookPlugin.php4
-rw-r--r--plugins/GoogleAnalyticsPlugin.php8
-rw-r--r--plugins/PiwikAnalyticsPlugin.php15
-rw-r--r--plugins/Realtime/RealtimePlugin.php6
-rw-r--r--plugins/UserFlag/UserFlagPlugin.php4
7 files changed, 12 insertions, 31 deletions
diff --git a/lib/messageform.php b/lib/messageform.php
index b034be312..4df193c6d 100644
--- a/lib/messageform.php
+++ b/lib/messageform.php
@@ -154,8 +154,7 @@ class MessageForm extends Form
$contentLimit = Message::maxContent();
- $this->out->element('script', array('type' => 'text/javascript'),
- 'maxLength = ' . $contentLimit . ';');
+ $this->out->inlineScript('maxLength = ' . $contentLimit . ';');
if ($contentLimit > 0) {
$this->out->elementStart('dl', 'form_note');
diff --git a/lib/noticeform.php b/lib/noticeform.php
index ec8624597..0dd3f2d77 100644
--- a/lib/noticeform.php
+++ b/lib/noticeform.php
@@ -178,8 +178,7 @@ class NoticeForm extends Form
$contentLimit = Notice::maxContent();
- $this->out->element('script', array('type' => 'text/javascript'),
- 'maxLength = ' . $contentLimit . ';');
+ $this->out->inlineScript('maxLength = ' . $contentLimit . ';');
if ($contentLimit > 0) {
$this->out->elementStart('dl', 'form_note');
diff --git a/plugins/Facebook/FacebookPlugin.php b/plugins/Facebook/FacebookPlugin.php
index 047477d9c..40c911cce 100644
--- a/plugins/Facebook/FacebookPlugin.php
+++ b/plugins/Facebook/FacebookPlugin.php
@@ -185,7 +185,6 @@ class FacebookPlugin extends Plugin
// XXX: Facebook says we don't need this FB_RequireFeatures(),
// but we actually do, for IE and Safari. Gar.
- $js = '<script type="text/javascript">';
$js .= ' $(document).ready(function () {';
$js .= ' FB_RequireFeatures(';
$js .= ' ["XFBML"], function() {';
@@ -219,7 +218,6 @@ class FacebookPlugin extends Plugin
$js .= ' }';
$js .= ' );';
$js .= ' });';
- $js .= '</script>';
$js = sprintf($js, $apikey, $login_url, $logout_url);
@@ -227,7 +225,7 @@ class FacebookPlugin extends Plugin
$js = str_replace(' ', '', $js);
- $action->raw(" $js"); // leading two spaces to make it line up
+ $action->inlineScript($js);
}
}
diff --git a/plugins/GoogleAnalyticsPlugin.php b/plugins/GoogleAnalyticsPlugin.php
index 7f3d209ee..6891ee6a7 100644
--- a/plugins/GoogleAnalyticsPlugin.php
+++ b/plugins/GoogleAnalyticsPlugin.php
@@ -67,11 +67,7 @@ class GoogleAnalyticsPlugin extends Plugin
'pageTracker._trackPageview();'.
'} catch(err) {}',
$this->code);
- $action->elementStart('script', array('type' => 'text/javascript'));
- $action->raw($js1);
- $action->elementEnd('script');
- $action->elementStart('script', array('type' => 'text/javascript'));
- $action->raw($js2);
- $action->elementEnd('script');
+ $action->inlineScript($js1);
+ $action->inlineScript($js2);
}
}
diff --git a/plugins/PiwikAnalyticsPlugin.php b/plugins/PiwikAnalyticsPlugin.php
index 54faa0bdb..fefd09867 100644
--- a/plugins/PiwikAnalyticsPlugin.php
+++ b/plugins/PiwikAnalyticsPlugin.php
@@ -81,25 +81,20 @@ class PiwikAnalyticsPlugin extends Plugin
function onEndShowScripts($action)
{
- $piwikCode = <<<ENDOFPIWIK
-
-<!-- Piwik -->
-<script type="text/javascript">
+ $piwikCode1 = <<<ENDOFPIWIK
var pkBaseURL = (("https:" == document.location.protocol) ? "https://{$this->piwikroot}" : "http://{$this->piwikroot}");
document.write(unescape("%3Cscript src='" + pkBaseURL + "piwik.js' type='text/javascript'%3E%3C/script%3E"));
-</script>
-<script type="text/javascript">
+ENDOFPIWIK;
+ $piwikCode2 = <<<ENDOFPIWIK
try {
var piwikTracker = Piwik.getTracker(pkBaseURL + "piwik.php", {$this->piwikId});
piwikTracker.trackPageView();
piwikTracker.enableLinkTracking();
} catch( err ) {}
-</script>
-<!-- End Piwik Tag -->
-
ENDOFPIWIK;
- $action->raw($piwikCode);
+ $action->inlineScript($piwikCode1);
+ $action->inlineScript($piwikCode2);
return true;
}
}
diff --git a/plugins/Realtime/RealtimePlugin.php b/plugins/Realtime/RealtimePlugin.php
index 030df405b..3e33fdaf1 100644
--- a/plugins/Realtime/RealtimePlugin.php
+++ b/plugins/Realtime/RealtimePlugin.php
@@ -105,15 +105,11 @@ class RealtimePlugin extends Plugin
$realtimeUI = ' RealtimeUpdate.initActions("'.$url.'", "'.$timeline.'", "'. $pluginPath .'");';
}
- $action->elementStart('script', array('type' => 'text/javascript'));
-
$script = ' $(document).ready(function() { '.
$realtimeUI.
$this->_updateInitialize($timeline, $user_id).
'}); ';
- $action->raw($script);
-
- $action->elementEnd('script');
+ $action->inlineScript($script);
return true;
}
diff --git a/plugins/UserFlag/UserFlagPlugin.php b/plugins/UserFlag/UserFlagPlugin.php
index e13c2555a..75dcca4fc 100644
--- a/plugins/UserFlag/UserFlagPlugin.php
+++ b/plugins/UserFlag/UserFlagPlugin.php
@@ -145,9 +145,7 @@ class UserFlagPlugin extends Plugin
function onEndShowScripts($action)
{
- $action->elementStart('script', array('type' => 'text/javascript'));
- $action->raw('/*<![CDATA[*/ if ($(".form_entity_flag").length > 0) { SN.U.FormXHR($(".form_entity_flag")); } /*]]>*/');
- $action->elementEnd('script');
+ $action->inlineScript('if ($(".form_entity_flag").length > 0) { SN.U.FormXHR($(".form_entity_flag")); }');
return true;
}
}