Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Changing local combo cache key from query string to full url. Adding …

…a more complex test of the local combo handler.
  • Loading branch information...
commit 88602e401a9a63acaded9945b528a813b3ba2fcf 1 parent 21ee6ff
@cauld cauld authored
View
4 phploader/combo.php
@@ -42,7 +42,7 @@
$cache = false;
if (APC_AVAIL === true) {
- $cache = apc_fetch('combo:'.$queryString);
+ $cache = apc_fetch(server(true));
}
if ($cache) {
@@ -99,7 +99,7 @@
if ($contentType == "application/x-javascript") {
$rawScript = $loader->script_raw();
if (APC_AVAIL === true) {
- apc_store('combo:'.$queryString, $rawScript, APC_TTL);
+ apc_store(server(true), $rawScript, APC_TTL);
}
echo $rawScript;
} else {
View
19 phploader/combo_functions.inc.php
@@ -8,14 +8,29 @@
//server(): Computes the base URL of the current page (protocol, server, path)
//credit: http://code.google.com/p/simple-php-framework/ (modified version of full_url), license: MIT
-function server()
+function server($includeRequestURI=false)
{
$s = getenv('HTTPS') ? '' : (getenv('HTTPS') == 'on') ? 's' : '';
$protocol = substr(strtolower(getenv('SERVER_PROTOCOL')), 0, strpos(strtolower(getenv('SERVER_PROTOCOL')), '/')) . $s;
$port = (getenv('SERVER_PORT') == '80') ? '' : (":".getenv('SERVER_PORT'));
- return $protocol . "://" . getenv('HTTP_HOST') . $port;
+ $server = $protocol . "://" . getenv('HTTP_HOST') . $port;
+
+ if ($includeRequestURI === true) {
+ $server .= getenv('REQUEST_URI');
+ }
+
+ return $server;
}
+// Computes the *full* URL of the current page (protocol, server, path, query parameters, etc)
+ function full_url()
+ {
+ $s = empty($_SERVER['HTTPS']) ? '' : ($_SERVER['HTTPS'] == 'on') ? 's' : '';
+ $protocol = substr(strtolower($_SERVER['SERVER_PROTOCOL']), 0, strpos(strtolower($_SERVER['SERVER_PROTOCOL']), '/')) . $s;
+ $port = ($_SERVER['SERVER_PORT'] == '80') ? '' : (":".$_SERVER['SERVER_PORT']);
+ return $protocol . "://" . $_SERVER['HTTP_HOST'] . $port . $_SERVER['REQUEST_URI'];
+ }
+
function alphaImageLoaderPathCorrection($matches) {
global $crtResourceBase;
View
2  phploader/test/2.0.php
@@ -6,7 +6,7 @@
* version: 1.0.0b2
*/
-include("/home/y/share/pear/Yahoo/YUI/loader.php");
+include("../loader.php");
function encoded_out($str) {
echo (htmlentities($str));
View
178 phploader/test/local-combo-loader.php
@@ -6,26 +6,176 @@
* version: 1.0.0b2
*/
-include("../loader.php");
-
-$loader = new YAHOO_util_Loader("2.7.0");
-$loader->combine = true;
-//$loader->comboBase = "http://localhost/phploader/phploader/combo.php?";
-$loader->load("colorpicker");
+ include("../loader.php");
+ $loader = new YAHOO_util_Loader("2.8.0r4");
+ //Specify YUI components to load
+ $loader->combine = true;
+ $loader->comboBase = "http://localhost/phploader/phploader/combo.php?"; //modify as needed
+ $loader->load("editor", "calendar", "container", "animation", "fonts");
?>
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
+<html>
<head>
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
- <title>test-local-combo-loader</title>
- <?PHP echo $loader->css(); ?>
+ <meta http-equiv="content-type" content="text/html; charset=utf-8">
+ <title>Calendar Plugin</title>
+
+ <style type="text/css">
+ /*margin and padding on body element
+ can introduce errors in determining
+ element position and are not recommended;
+ we turn them off as a foundation for YUI
+ CSS treatments. */
+ body {
+ margin:0;
+ padding:0;
+ }
+ </style>
+
+ <?PHP echo $loader->css(); ?>
</head>
-<body>
+<body class="yui-skin-sam">
+
+
+<h1>Calendar Plugin</h1>
+
+<div class="exampleIntro">
+ <p>This example adds a button to the Rich Text Editor's Toolbar that displays a <a href="http://developer.yahoo.com/yui/calendar/">Calendar Control</a> for choosing dates. It also demonstrates how to manage the state of a custom button.</p>
+
+<p>Click the Date button (<img src="http://developer.yahoo.com/yui/examples/editor/assets/calendar_default.gif">) in the Toolbar to display the Calendar Control, then select a date and it will be placed inside the Editor.</p>
+
+<p>You can also click on a date that has been inserted in the Editor and the Date button will enable. When the Date button is enabled and you click it the corresponding date will be selected in the Calendar Control when it is displayed.</p>
+
+</div>
+
+<style>
+ .yui-skin-sam .yui-toolbar-container .yui-toolbar-insertdate span.yui-toolbar-icon {
+ background-image: url( http://developer.yahoo.com/yui/examples/editor/assets/calendar_default.gif );
+ background-position: 1px 0px;
+ left: 5px;
+ }
+ .yui-skin-sam .yui-toolbar-container .yui-button-insertdate-selected span.yui-toolbar-icon {
+ background-image: url( http://developer.yahoo.com/yui/examples/editor/assets/calendar_active.gif );
+ background-position: 1px 0px;
+ left: 5px;
+ }
+
+ #insertdate {
+ background-color: transparent;
+ }
+</style>
+<style>
+.yui-toolbar-group-insertitem {
+ *width: auto;
+}
+</style>
+
+<form method="post" action="#" id="form1">
+<textarea id="editor" name="editor" rows="20" cols="75">
+This is some more test text. <font face="Times New Roman">This is some more test text. This is some more <b>test <i>text</i></b></font>. This is some more test text. This is some more test text. This is some more test text. This is some more test text. This is some more test text. This is some more test text. This is some more test text.
+</textarea>
+</form>
<?PHP echo $loader->script(); ?>
+<script type="text/javascript">
+(function() {
+ var Dom = YAHOO.util.Dom,
+ Event = YAHOO.util.Event,
+ cal = null,
+ selectedDate = null;
+
+ var myConfig = {
+ height: '300px',
+ width: '600px',
+ animate: true,
+ dompath: true,
+ focusAtStart: true
+ };
+
+ YAHOO.log('Creating Editor', 'info', 'example');
+ var myEditor = new YAHOO.widget.Editor('editor', myConfig);
+
+ myEditor.on('toolbarLoaded', function() {
+ YAHOO.log('Editor Toolbar loaded', 'info', 'example');
+
+ var dateConfig = {
+ type: 'push', label: 'Insert Date', value: 'insertdate',
+ menu: function() {
+ var menu = new YAHOO.widget.Overlay('insertdate', {
+ width: '210px',
+ height: '220px',
+ xy: [-9000,-9000],
+ visible: false
+ });
+ menu.setBody('<div id="cal1Container"></div>');
+ menu.beforeShowEvent.subscribe(function() {
+ menu.cfg.setProperty('context', [
+ myEditor.toolbar.getButtonByValue('insertdate').get('element'),
+ 'tl', 'bl'
+ ]);
+ });
+ menu.showEvent.subscribe(function() {
+ cal.deselectAll();
+ Dom.removeClass(cal.cells, 'selected');
+ if (selectedDate != null) {
+ cal.cfg.setProperty('selected', selectedDate);
+ cal.cfg.setProperty('pagedate', new Date(selectedDate), true);
+ selectedDate = null;
+ }
+ cal.render();
+ });
+ menu.render(document.body);
+ menu.element.style.visibility = 'hidden';
+ return menu;
+ }()
+ };
+
+ YAHOO.log('Adding new button (insertdate) to toolbar', 'info', 'example');
+ myEditor.toolbar.addButtonToGroup(dateConfig, 'insertitem');
+
+ myEditor.on('afterNodeChange', function() {
+ var el = this._getSelectedElement();
+ if (Dom.hasClass(el, 'date') || Dom.hasClass(el.parentNode, 'date')) {
+ YAHOO.log('We found an element with the class of (date) select button', 'info', 'example');
+ this.toolbar.selectButton(this.toolbar.getButtonByValue('insertdate'));
+ if (Dom.hasClass(el.parentNode, 'date')) {
+ selectedDate = el.parentNode.innerHTML;
+ } else {
+ selectedDate = el.innerHTML;
+ }
+ }
+ var _button = this.toolbar.getButtonByValue('insertdate');
+ _button._menu.hide();
+ }, myEditor, true);
+
+ myEditor.toolbar.on('insertdateClick', function(ev) {
+ YAHOO.log('insertdateClick: ' + YAHOO.lang.dump(ev), 'info', 'example');
+ var calDate = ' <span class="date">' + (ev.calDate.getMonth() + 1)
+ + '/' + ev.calDate.getDate()
+ + '/' + ev.calDate.getFullYear() + '</span>&nbsp;';
+ this.execCommand('inserthtml', calDate);
+ var _button = this.toolbar.getButtonByValue('insertdate');
+ _button._menu.hide();
+ }, myEditor, true);
+ });
+ myEditor.render();
+
+ Event.onAvailable('cal1Container', function() {
+ YAHOO.log('Found (#cal1Container) - render the calendar', 'info', 'example');
+ cal = new YAHOO.widget.Calendar('cal1', 'cal1Container');
+ cal.selectEvent.subscribe(function() {
+ var calDate = cal.getSelectedDates()[0];
+ YAHOO.log('Calendar selectEvent: (' + calDate + ')', 'info', 'example');
+ this.toolbar.fireEvent('insertdateClick', { type: 'insertdateClick', calDate: calDate });
+ }, myEditor, true);
+ cal.render();
+ });
+
+})();
+
+</script>
+
</body>
-</html>
+</html>
Please sign in to comment.
Something went wrong with that request. Please try again.