Permalink
Browse files

Initial commit

  • Loading branch information...
0 parents commit a0fb02cb011184b6a00be2224c5945bfccd601db Alistair Kearney committed May 11, 2009
@@ -0,0 +1,27 @@
+All source code included in the "Session Monster" Symphony Extension
+archive is, unless otherwise specified, released under the MIT licence as
+follows:
+
+----- begin license block -----
+
+Copyright 2008 Alistair Kearney, Allen Chang, Scott Hughes
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
+
+----- end license block -----
@@ -0,0 +1,27 @@
+Session Monster
+------------------------------------
+
+Version: 1.0
+Author: Symphony Team (http://symphony21.com)
+Build Date: 12th May 2008
+Requirements: Symphony Beta revision 5 or greater.
+
+
+[INSTALLATION]
+
+1. upload this folder, 'sessionmonster', to your /extensions folder
+
+2. navigate to 'System' > 'Extensions' and enable it
+
+3. Add the "Session Monster: Add GET variable to Session" Event
+ and/or "Session Monster: Show Session Parameters" Data Source to
+ your page. Documentation on the Event can be viewed via the
+ Components area of the Symphony Admin.
+
+
+[USAGE]
+
+- The Event allows for adding GET variables to the XML. Setting a
+ GET variable to an empty string will remove it from the session.
+
+
@@ -0,0 +1,36 @@
+<?php
+
+ Final Class datasourceSessionmonster_showsessionparam Extends DataSource{
+
+ function about(){
+ return array(
+ 'name' => 'Session Monster: Show Session Parameters',
+ 'author' => array(
+ 'name' => 'Symphony Team',
+ 'website' => 'http://symphony21.com',
+ 'email' => 'team@symphony21.com'),
+ 'version' => '1.0',
+ 'release-date' => '2008-05-12');
+ }
+
+
+ public function grab(){
+
+ session_start();
+
+ $xml = new XMLElement('session-monster');
+
+ if(!is_array($_SESSION[__SYM_COOKIE_PREFIX__ . '-sessionmonster']) || empty($_SESSION[__SYM_COOKIE_PREFIX__ . '-sessionmonster'])) return NULL;
+
+ $count = 0;
+
+ foreach($_SESSION[__SYM_COOKIE_PREFIX__ . '-sessionmonster'] as $key => $val){
+ if(strlen($val) <= 0) continue;
+ $xml->appendChild(new XMLElement('item', $val, array('name' => $key)));
+ $count++;
+ }
+
+ return ($count == 0 ? NULL : $xml);
+
+ }
+ }
@@ -0,0 +1,63 @@
+<?php
+
+ if(!defined('__IN_SYMPHONY__')) die('<h2>Error</h2><p>You cannot directly access this file</p>');
+
+ Final Class eventSessionmonster_addgettosession extends Event{
+
+ public static function about(){
+
+ return array(
+ 'name' => 'Session Monster: Add GET variable to session',
+ 'author' => array('name' => 'Alistair Kearney',
+ 'website' => 'http://www.pointybeard.com',
+ 'email' => 'alistair@pointybeard.com'),
+ 'version' => '1.0',
+ 'release-date' => '2008-05-12',
+ );
+ }
+
+ public function load(){
+ if(is_array($_GET) && !empty($_GET)) return $this->__trigger();
+ return NULL;
+ }
+
+ public static function documentation(){
+
+ return '
+
+ <h3>Usage</h3>
+
+ <p>Any GET parameters, i.e key & value pairs in the URL such as <code>?var1=hello</code>, will be added to the session, which is then available via the "Show Session Parameter" Data Source. XML after adding or removing variables look like so:</p>
+
+ <pre class="XML"><code>&lt;session-monster>
+ &lt;item name="var1" action="added">one&lt;/item>
+ &lt;item name="var2" action="removed"/>
+&lt;/session-monster></code></pre>
+
+ <p>The corresponding URL for the above XML looks like <code>?var1=one&amp;var2=</code>. Notice that to remove an item, you set it as empty.</p>
+
+ ';
+
+ }
+
+ protected function __trigger(){
+
+ session_start();
+
+ $xml = new XMLElement('session-monster');
+
+ $count = 0;
+
+ foreach($_GET as $key => $val){
+ if(!in_array($key, array('page', 'debug', 'profile'))){
+ $_SESSION[__SYM_COOKIE_PREFIX__ . '-sessionmonster'][$key] = $val;
+ $xml->appendChild(new XMLElement('item', $val, array('name' => $key, 'action' => (strlen($val) > 0 ? 'added' : 'removed'))));
+ $count++;
+ }
+ }
+
+ return ($count == 0 ? NULL : $xml);
+
+ }
+ }
+
@@ -0,0 +1,17 @@
+<?php
+
+ Class extension_sessionmonster extends Extension{
+
+ public function about(){
+ return array('name' => 'Session Monster',
+ 'version' => '1.0',
+ 'release-date' => '2008-05-12',
+ 'author' => array('name' => 'Symphony Team',
+ 'website' => 'http://www.symphony21.com',
+ 'email' => 'team@symphony21.com')
+ );
+ }
+
+ }
+
+?>

0 comments on commit a0fb02c

Please sign in to comment.