Author: spikebrehm
Date: 2010-04-28 01:13:56 +0200 (Wed, 28 Apr 2010)
New Revision: 29277

Added:
   plugins/srPageChooserPlugin/branches/
   plugins/srPageChooserPlugin/tags/
   plugins/srPageChooserPlugin/trunk/
   plugins/srPageChooserPlugin/trunk/LICENSE
   plugins/srPageChooserPlugin/trunk/README
   plugins/srPageChooserPlugin/trunk/config/
   
plugins/srPageChooserPlugin/trunk/config/srPageChooserPluginConfiguration.class.php
   plugins/srPageChooserPlugin/trunk/lib/
   plugins/srPageChooserPlugin/trunk/lib/BasesrPageChooserActions.class.php
   plugins/srPageChooserPlugin/trunk/lib/srPageChooserRouting.class.php
   plugins/srPageChooserPlugin/trunk/lib/srValidatorSlug.class.php
   plugins/srPageChooserPlugin/trunk/lib/srWidgetFormPageChooser.class.php
   plugins/srPageChooserPlugin/trunk/modules/
   plugins/srPageChooserPlugin/trunk/modules/srPageChooser/
   plugins/srPageChooserPlugin/trunk/modules/srPageChooser/actions/
   
plugins/srPageChooserPlugin/trunk/modules/srPageChooser/actions/actions.class.php
   plugins/srPageChooserPlugin/trunk/modules/srPageChooser/config/
   plugins/srPageChooserPlugin/trunk/modules/srPageChooser/config/view.yml
   plugins/srPageChooserPlugin/trunk/modules/srPageChooser/templates/
   
plugins/srPageChooserPlugin/trunk/modules/srPageChooser/templates/_includeFormAssets.php
   
plugins/srPageChooserPlugin/trunk/modules/srPageChooser/templates/chooseInvalidCredentials.php
   
plugins/srPageChooserPlugin/trunk/modules/srPageChooser/templates/chooseSuccess.php
   plugins/srPageChooserPlugin/trunk/package.xml.tmpl
   plugins/srPageChooserPlugin/trunk/web/
   plugins/srPageChooserPlugin/trunk/web/css/
   plugins/srPageChooserPlugin/trunk/web/css/srPageChooserPlugin.css
   plugins/srPageChooserPlugin/trunk/web/images/
   plugins/srPageChooserPlugin/trunk/web/images/loading.gif
   plugins/srPageChooserPlugin/trunk/web/js/
   plugins/srPageChooserPlugin/trunk/web/js/srPageChooserPlugin.js
Log:
Initial import of srPageChooserPlugin

Added: plugins/srPageChooserPlugin/trunk/LICENSE
===================================================================
--- plugins/srPageChooserPlugin/trunk/LICENSE                           (rev 0)
+++ plugins/srPageChooserPlugin/trunk/LICENSE   2010-04-27 23:13:56 UTC (rev 
29277)
@@ -0,0 +1,22 @@
+--------------------------------------------------------------------------------
+                              srPageChooserPlugin
+--------------------------------------------------------------------------------
+
+Copyright (c) 2010 SunRun Inc.
+
+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.

Added: plugins/srPageChooserPlugin/trunk/README
===================================================================
--- plugins/srPageChooserPlugin/trunk/README                            (rev 0)
+++ plugins/srPageChooserPlugin/trunk/README    2010-04-27 23:13:56 UTC (rev 
29277)
@@ -0,0 +1,9 @@
+# srPageChooserPlugin
+
+This plugin is designed to work with the Apostrophe CMS by P'unk Ave. It allows
+developers to add an srPageChooserWidget to forms, for use with choosing links
+in slots, and also in the rich text slot.
+
+Contact the developer at ocelot [a] gmail.
+
+Copyright (c) 2010 SunRun Inc.

Added: 
plugins/srPageChooserPlugin/trunk/config/srPageChooserPluginConfiguration.class.php
===================================================================
--- 
plugins/srPageChooserPlugin/trunk/config/srPageChooserPluginConfiguration.class.php
                         (rev 0)
+++ 
plugins/srPageChooserPlugin/trunk/config/srPageChooserPluginConfiguration.class.php
 2010-04-27 23:13:56 UTC (rev 29277)
@@ -0,0 +1,22 @@
+<?php
+
+/**
+ * srPageChooserPlugin configuration.
+ * 
+ * @package     srPageChooserPlugin
+ * @subpackage  config
+ * @author      Alexander "Spike" Brehm <[email protected]>
+ * @version     SVN: $Id: PluginConfiguration.class.php 17207 2009-04-10 
15:36:26Z Kris.Wallsmith $
+ */
+class srPageChooserPluginConfiguration extends sfPluginConfiguration
+{
+  const VERSION = '1.0.0-DEV';
+
+  /**
+   * @see sfPluginConfiguration
+   */
+  public function initialize()
+  {
+    $this->dispatcher->connect('routing.load_configuration', 
array('srPageChooserRouting', 'listenToRoutingLoadConfigurationEvent'));
+  }
+}

Added: plugins/srPageChooserPlugin/trunk/lib/BasesrPageChooserActions.class.php
===================================================================
--- plugins/srPageChooserPlugin/trunk/lib/BasesrPageChooserActions.class.php    
                        (rev 0)
+++ plugins/srPageChooserPlugin/trunk/lib/BasesrPageChooserActions.class.php    
2010-04-27 23:13:56 UTC (rev 29277)
@@ -0,0 +1,32 @@
+<?php
+
+/**
+ * Base actions for the srPageChooserPlugin srPageChooser module.
+ * 
+ * @package     srPageChooserPlugin
+ * @subpackage  srPageChooser
+ * @author      Alexander "Spike" Brehm <[email protected]>
+ * @version     SVN: $Id: BaseActions.class.php 12534 2008-11-01 13:38:27Z 
Kris.Wallsmith $
+ */
+abstract class BasesrPageChooserActions extends sfActions
+{
+  /**
+   * Executes index action
+   *
+   * @param sfRequest $request A request object
+   */
+   public function executeChoose(sfWebRequest $request)
+   {
+     // manually disable the web debug toolbar cause it screws up the small 
screen real estate
+     sfConfig::set('sf_web_debug', false);
+
+     if ( ! $this->getUser()->hasCredential('cms_admin'))
+     {
+       return 'InvalidCredentials';
+     }
+
+     $root = aPageTable::retrieveBySlug('/');
+
+     $this->treeData = $root->getTreeJSONReadySR(false);
+   }
+}

Added: plugins/srPageChooserPlugin/trunk/lib/srPageChooserRouting.class.php
===================================================================
--- plugins/srPageChooserPlugin/trunk/lib/srPageChooserRouting.class.php        
                        (rev 0)
+++ plugins/srPageChooserPlugin/trunk/lib/srPageChooserRouting.class.php        
2010-04-27 23:13:56 UTC (rev 29277)
@@ -0,0 +1,21 @@
+<?php
+
+/**
+ * Routing rules for the srPageChooserPlugin.
+ * 
+ * @package     srPageChooserPlugin
+ * @subpackage  routing
+ * @author      Alexander "Spike" Brehm <[email protected]>
+ */
+class srPageChooserRouting extends sfPatternRouting
+{
+  static public function listenToRoutingLoadConfigurationEvent(sfEvent $event)
+  {
+    $r = $event->getSubject();
+
+    $r->prependRoute('sr_page_chooser', 
+      new sfRoute('/admin/srPageChooser', 
+        array('module' => 'srPageChooser', 'action' => 'choose')
+      ));
+  }
+}

Added: plugins/srPageChooserPlugin/trunk/lib/srValidatorSlug.class.php
===================================================================
--- plugins/srPageChooserPlugin/trunk/lib/srValidatorSlug.class.php             
                (rev 0)
+++ plugins/srPageChooserPlugin/trunk/lib/srValidatorSlug.class.php     
2010-04-27 23:13:56 UTC (rev 29277)
@@ -0,0 +1,66 @@
+<?php
+
+/**
+ * sfValidatorRegex validates a value with a regular expression.
+ *
+ * @package    srPageChooserPlugin
+ * @subpackage validator
+ * @author     Alexander "Spike" Brehm <[email protected]>
+ * @version    SVN: $$
+ */
+class srValidatorSlug extends sfValidatorRegex
+{
+   /**
+   * Configures the current validator.
+   *
+   * Available options:
+   *
+   *  * strip_slash:    Whether to strip the leading slash off the slug
+   *  * add_slash:     Whether to add a leading slash to the slug
+   *  * pattern:               A regex pattern compatible with PCRE or 
{...@link sfCallable} that returns one (required)
+   *
+   * @param array $options   An array of options
+   * @param array $messages  An array of error messages
+   *
+   * @see sfValidatorString
+   */
+  protected function configure($options = array(), $messages = array())
+  {
+    parent::configure($options, $messages);
+
+    $this->addRequiredOption('pattern');
+    $this->addOption('strip_slash', false);
+    $this->addOption('add_slash', true);
+               $this->addOption('pattern', $this->getPattern());
+  }
+
+  /**
+   * @see sfValidatorString
+   */
+  protected function doClean($value)
+  {
+    $clean = parent::doClean($value);
+
+    if ($this->getOption('strip_slash'))
+    {
+      $clean = trim($value, '/');
+    }
+    elseif ($this->getOption('add_slash'))
+    {
+      $clean = trim($value, '/');
+                       $clean = '/'.$clean;
+    }
+
+    return $clean;
+  }
+
+  /**
+   * Returns the current validator's regular expression.
+   *
+   * @return string
+   */
+  public function getPattern()
+  {
+    return '/^[\w\/\-\+]+$/';
+  }
+}
\ No newline at end of file

Added: plugins/srPageChooserPlugin/trunk/lib/srWidgetFormPageChooser.class.php
===================================================================
--- plugins/srPageChooserPlugin/trunk/lib/srWidgetFormPageChooser.class.php     
                        (rev 0)
+++ plugins/srPageChooserPlugin/trunk/lib/srWidgetFormPageChooser.class.php     
2010-04-27 23:13:56 UTC (rev 29277)
@@ -0,0 +1,94 @@
+<?php
+
+/**
+ * srWidgetFormPageChooser pops up an iframe with CMS page tree for use with 
links
+ *
+ * @package    srPageChooserPlugin
+ * @subpackage widget
+ * @author     Alexander "Spike" Brehm <[email protected]>
+ * @version    SVN: $$
+ */
+class srWidgetFormPageChooser extends sfWidgetForm
+{
+  
+  /**
+   * Constructor.
+   *
+   * Available options:
+   *
+   *  * type: The widget type
+   *
+   * @param array $options     An array of options
+   * @param array $attributes  An array of default HTML attributes
+   *
+   * @see sfWidgetForm
+   */
+  protected function configure($options = array(), $attributes = array())
+  {
+    parent::configure($options, $attributes);
+        
+    $this->addOption('type', 'hidden');
+    $this->addOption('buttonText', 'Select a Link');
+  }
+
+  /**
+   * @param  string $name        The element name
+   * @param  string $value       The value displayed in this widget
+   * @param  array  $attributes  An array of HTML attributes to be merged with 
the default HTML attributes
+   * @param  array  $errors      An array of errors for the field
+   *
+   * @return string An HTML tag string
+   *
+   * @see sfWidgetForm
+   */
+  public function render($name, $value = null, $attributes = array(), $errors 
= array())
+  {
+    $attributes = array_merge(array('span' => array(), 'input' => array(), 
'button' => array()), $attributes);
+    
+    $spanTag = $this->renderContentTag('span', $value, 
array_merge(array('class' => 'srwidgetformpagechooser'), $attributes['span']));
+    
+    $inputTag = $this->renderTag('input', array_merge(array('type' => 
$this->getOption('type'), 'name' => $name, 'value' => $value, 'class' => 
'srwidgetformpagechooser'), $attributes['input']));
+    
+    $buttonTag = $this->renderContentTag('button', 
$this->getOption('buttonText'), array_merge(array('class' => 
'srwidgetformpagechooser', 'type' => 'button'), $attributes['button']));
+    
+    $iframe = self::renderIframe();
+    
+    return '<div class="srwidgetformpagechooser-container">' . $spanTag . 
$inputTag . $buttonTag . $iframe . '</div>';
+  }
+  
+  static public function renderIframe()
+  {
+    $url = url_for('@sr_page_chooser');
+    
+    return <<<EOT
+<script type="text/javascript">
+var sPageChooserWidgetUrl = '$url';
+</script>
+EOT;
+    //return '<div class="srwidgetformpagechooser-iframe-container" 
style="display:none"><iframe frameborder="0" scrolling="no" src="'.$url.'" 
class="srwidgetformpagechooser"></iframe><p 
class="srwidgetformpagechooser-url"></p><button 
class="srwidgetformpagechooser-done" type="button">Ok</button></div>';
+  }
+  
+  /**
+   * Gets the stylesheet paths associated with the widget.
+   *
+   * The array keys are files and values are the media names (separated by a 
,):
+   *
+   *   array('/path/to/file.css' => 'all', '/another/file.css' => 
'screen,print')
+   *
+   * @return array An array of stylesheet paths
+   */
+  public function getStylesheets()
+  {
+    return array('/srPageChooserPlugin/css/srPageChooserPlugin.css');
+  }
+
+  /**
+   * Gets the JavaScript paths associated with the widget.
+   *
+   * @return array An array of JavaScript paths
+   */
+  public function getJavaScripts()
+  {
+    return array('/srPageChooserPlugin/js/srPageChooserPlugin.js');
+  }
+}

Added: 
plugins/srPageChooserPlugin/trunk/modules/srPageChooser/actions/actions.class.php
===================================================================
--- 
plugins/srPageChooserPlugin/trunk/modules/srPageChooser/actions/actions.class.php
                           (rev 0)
+++ 
plugins/srPageChooserPlugin/trunk/modules/srPageChooser/actions/actions.class.php
   2010-04-27 23:13:56 UTC (rev 29277)
@@ -0,0 +1,15 @@
+<?php
+
+require_once 
dirname(__FILE__).'/../../../lib/action/BasesrPageChooserActions.class.php';
+
+/**
+ * srPageChooser actions.
+ * 
+ * @package    srPageChooserPlugin
+ * @subpackage srPageChooser
+ * @author     Alexander "Spike" Brehm <[email protected]>
+ * @version    SVN: $Id: actions.class.php 12534 2008-11-01 13:38:27Z 
Kris.Wallsmith $
+ */
+class srPageChooserActions extends BasesrPageChooserActions
+{
+}

Added: plugins/srPageChooserPlugin/trunk/modules/srPageChooser/config/view.yml
===================================================================
--- plugins/srPageChooserPlugin/trunk/modules/srPageChooser/config/view.yml     
                        (rev 0)
+++ plugins/srPageChooserPlugin/trunk/modules/srPageChooser/config/view.yml     
2010-04-27 23:13:56 UTC (rev 29277)
@@ -0,0 +1,5 @@
+default:
+  layout: bare
+  
+  javascripts: [-tmpHover.js]
+  stylesheets: [-website.css, -templates.css]
\ No newline at end of file

Added: 
plugins/srPageChooserPlugin/trunk/modules/srPageChooser/templates/_includeFormAssets.php
===================================================================
--- 
plugins/srPageChooserPlugin/trunk/modules/srPageChooser/templates/_includeFormAssets.php
                            (rev 0)
+++ 
plugins/srPageChooserPlugin/trunk/modules/srPageChooser/templates/_includeFormAssets.php
    2010-04-27 23:13:56 UTC (rev 29277)
@@ -0,0 +1,50 @@
+<?php if ($form): ?>
+<script type="text/javascript" charset="utf-8">
+  (function($){
+    $(document).ready(function(){
+      <?php // To prevent a set of assets from being loaded once for each 
widget on the page. ?>
+      <?php // Tt would be even better to explicitly check if the script is 
loaded, in case it ?>
+      <?php // was first loaded by something else than this partial ?>
+      if (typeof _includedFormAssets == 'undefined') {
+        _includedFormAssets = {
+          js: [],
+          css: []
+        }
+      }
+      
+  <?php // load javascripts ?>
+  <?php $javascripts = $form->getJavaScripts() ?>
+  <?php if (count($javascripts)): ?>
+    <?php foreach ($javascripts as &$js): ?>
+      <?php $js = javascript_path($js) ?>
+    <?php endforeach ?>
+      var scripts = ['<?php echo join($javascripts, "','") ?>'];
+        $.each(scripts, function(i,e){
+          if ($.inArray(e, _includedFormAssets.js) === -1) {
+            $.getScript(e);
+            _includedFormAssets.js.push(e);            
+          }
+        })
+  <?php endif ?>
+  <?php // load stylesheets ?>
+  <?php $stylesheets = $form->getStylesheets() ?>
+  <?php if (count($stylesheets)): ?>
+    <?php foreach ($stylesheets as &$css): ?>
+      <?php $css = stylesheet_path($css) ?>
+    <?php endforeach ?>
+      var stylesheets = ['<?php echo join($stylesheets, "','") ?>'];
+      $.each(stylesheets, function(i,e){
+        if ($.inArray(e, _includedFormAssets.css) === -1) {
+          $('<link>').appendTo('head').attr({
+            rel: 'stylesheet',
+            type: 'text/css',
+            href: e
+          });
+          _includedFormAssets.css.push(e);            
+        }
+      })
+    })
+  <?php endif ?>
+  })(jQuery);
+</script>
+<?php endif ?>
\ No newline at end of file

Added: 
plugins/srPageChooserPlugin/trunk/modules/srPageChooser/templates/chooseInvalidCredentials.php
===================================================================
--- 
plugins/srPageChooserPlugin/trunk/modules/srPageChooser/templates/chooseInvalidCredentials.php
                              (rev 0)
+++ 
plugins/srPageChooserPlugin/trunk/modules/srPageChooser/templates/chooseInvalidCredentials.php
      2010-04-27 23:13:56 UTC (rev 29277)
@@ -0,0 +1 @@
+You must be logged in as a CMS administrator.
\ No newline at end of file

Added: 
plugins/srPageChooserPlugin/trunk/modules/srPageChooser/templates/chooseSuccess.php
===================================================================
--- 
plugins/srPageChooserPlugin/trunk/modules/srPageChooser/templates/chooseSuccess.php
                         (rev 0)
+++ 
plugins/srPageChooserPlugin/trunk/modules/srPageChooser/templates/chooseSuccess.php
 2010-04-27 23:13:56 UTC (rev 29277)
@@ -0,0 +1,98 @@
+<?php use_helper('jQuery') ?>
+
+<?php 
sfContext::getInstance()->getResponse()->addJavascript('/apostrophePlugin/js/jsTree/_lib/css.js')
 ?>
+<?php 
sfContext::getInstance()->getResponse()->addJavascript('/apostrophePlugin/js/jsTree/source/tree_component.js')
 ?>
+<?php 
sfContext::getInstance()->getResponse()->addStylesheet('/apostrophePlugin/js/jsTree/source/tree_component.css')
 ?>
+
+<style type="text/css">
+body {
+  background: #fff none;
+}
+p, li {
+  font-size: 11px;
+  font-family: Verdana, Arial, Helvetica, sans-serif;
+}
+</style>
+
+<div id="page-chooser-page-tree-container">
+
+       <div id="tree"></div>
+       
+</div>
+
+<script type="text/javascript">
+var PageChooser = {
+  
+  treeData: <?php echo json_encode($treeData) ?>,
+  
+  baseUrl: false,
+  
+  extractPageInfo: function (targetId, node) {
+    if (typeof(node) == 'undefined') {
+      var node = PageChooser.treeData;
+    }
+    var pageInfo = null;
+
+    if (node.attributes.id === targetId) {
+      return { slug: node.slug, id: PageChooser.parseId(node.attributes.id), 
title: node.data };
+    } else if (typeof(node.children) == 'undefined') {
+      return null;
+    } else {
+      for (var index in node.children) {
+        var pageInfo = PageChooser.extractPageInfo(targetId, 
node.children[index])
+        if (pageInfo !== null) {
+          return pageInfo;
+        }
+      }
+    }
+    return pageInfo;
+  },
+  
+  parseId: function(treeId) {
+    return treeId.split('-').pop();
+  }
+  
+};
+
+$(function() {
+  $('#tree').tree({
+    data: {
+      type: 'json',
+      <?php // Supports multiple roots so we have to specify a list ?>
+      json: [ PageChooser.treeData ]
+    },
+               ui: {
+                       theme_path: 
"/apostrophePlugin/js/jsTree/source/themes/",
+      theme_name: "punk",
+                       context: false
+               },
+    rules: {
+      // Turn off most operations as we're only here to reorg the tree.
+      // Allowing renames and deletes here is an interesting thought but
+      // there's back end stuff that must exist for that.
+      renameable: false,
+      deletable: false,
+      creatable: false,
+      draggable: 'all',
+      dragrules: 'all'
+    },
+    callback: {
+      // move completed (TYPE is BELOW|ABOVE|INSIDE)
+      onselect: function(node, refNode, type, treeObj, rb)
+      {
+        var pageInfo = PageChooser.extractPageInfo(node.id);
+        
+        try {
+          var parentOnSelect = window.parent.PageChooserParent.onPageSelect;
+          parentOnSelect(pageInfo, PageChooser.baseUrl);
+        } catch (e) {
+          if ( ! $('p#url').length) {
+            $('<p id="url">Page: <strong></strong></p>').appendTo('body');
+          }
+          $('p#url').children('strong').text(pageInfo.title);
+        }
+      }
+    }  
+  });
+});
+</script>

Added: plugins/srPageChooserPlugin/trunk/package.xml.tmpl
===================================================================
--- plugins/srPageChooserPlugin/trunk/package.xml.tmpl                          
(rev 0)
+++ plugins/srPageChooserPlugin/trunk/package.xml.tmpl  2010-04-27 23:13:56 UTC 
(rev 29277)
@@ -0,0 +1,48 @@
+<?xml version="1.0" encoding="##ENCODING##"?>
+<package xmlns="http://pear.php.net/dtd/package-2.0"; 
xmlns:tasks="http://pear.php.net/dtd/tasks-1.0"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; packagerversion="1.4.1" 
version="2.0" xsi:schemaLocation="http://pear.php.net/dtd/tasks-1.0 
http://pear.php.net/dtd/tasks-1.0.xsd http://pear.php.net/dtd/package-2.0 
http://pear.php.net/dtd/package-2.0.xsd";>
+  <name>srPageChooserPlugin</name>
+  <channel>plugins.symfony-project.org</channel>
+  <summary>This plugin is designed to work with the Apostrophe CMS by P'unk 
Ave. It allows
+  developers to add an srPageChooserWidget to forms, for use with choosing 
links
+  in slots, and also in the rich text slot.</summary>
+  <description>This plugin is designed to work with the Apostrophe CMS by 
P'unk Ave. It allows
+  developers to add an srPageChooserWidget to forms, for use with choosing 
links
+  in slots, and also in the rich text slot.</description>
+  <lead>
+    <name>Alexander "Spike" Brehm</name>
+    <user>spikebrehm</user>
+    <email>[email protected]</email>
+    <active>yes</active>
+  </lead>
+  <date>27 April 2010</date>
+  <version>
+    <release>1.0.0-DEV</release>
+  </version>
+  <stability>
+    <release>alpha</release>
+  </stability>
+  <license uri="http://www.symfony-project.org/license";>MIT license</license>
+  <notes>-</notes>
+  <contents>
+    ##CONTENTS##
+  </contents>
+  <dependencies>
+    <required>
+      <php>
+        <min>5.2.4</min>
+      </php>
+      <pearinstaller>
+        <min>1.4.1</min>
+      </pearinstaller>
+      <package>
+        <name>symfony</name>
+        <channel>pear.symfony-project.com</channel>
+        <min>1.2.0</min>
+        <max>1.3.0</max>
+        <exclude>1.3.0</exclude>
+      </package>
+    </required>
+  </dependencies>
+  <phprelease></phprelease>
+  <changelog></changelog>
+</package>

Added: plugins/srPageChooserPlugin/trunk/web/css/srPageChooserPlugin.css
===================================================================
--- plugins/srPageChooserPlugin/trunk/web/css/srPageChooserPlugin.css           
                (rev 0)
+++ plugins/srPageChooserPlugin/trunk/web/css/srPageChooserPlugin.css   
2010-04-27 23:13:56 UTC (rev 29277)
@@ -0,0 +1,26 @@
+div.srwidgetformpagechooser-container {
+}
+span.srwidgetformpagechooser {
+       float: left;
+}
+span.srwidgetformpagechooser span.title,
+p.srwidgetformpagechooser-url span.title {
+       font-weight: bold;
+       display: block;
+}
+button.srwidgetformpagechooser {
+       float: right;
+}
+div.srwidgetformpagechooser-iframe-container {
+       background: #fff url(../images/loading.gif) no-repeat scroll center 
center;
+       border: 1px solid #aaa;
+       padding: 10px;
+       position: absolute;
+       z-index: 1000;
+}
+
+iframe.srwidgetformpagechooser {
+       overflow: auto;
+       height: 300px;
+       width: 340px;
+}
\ No newline at end of file

Added: plugins/srPageChooserPlugin/trunk/web/images/loading.gif
===================================================================
(Binary files differ)


Property changes on: plugins/srPageChooserPlugin/trunk/web/images/loading.gif
___________________________________________________________________
Added: svn:mime-type
   + application/octet-stream

Added: plugins/srPageChooserPlugin/trunk/web/js/srPageChooserPlugin.js
===================================================================
--- plugins/srPageChooserPlugin/trunk/web/js/srPageChooserPlugin.js             
                (rev 0)
+++ plugins/srPageChooserPlugin/trunk/web/js/srPageChooserPlugin.js     
2010-04-27 23:13:56 UTC (rev 29277)
@@ -0,0 +1,80 @@
+(function($){
+       
+       srPageChooserWidget = {
+               
+               elInput: 'input.srwidgetformpagechooser',
+               elSpan: 'span.srwidgetformpagechooser',
+               elButton: 'button.srwidgetformpagechooser',
+               elIframeContainer: 
'div.srwidgetformpagechooser-iframe-container',
+               elIframe: 'iframe.srwidgetformpagechooser',
+               elButtonDone: 'button.srwidgetformpagechooser-done',
+               elPUrl: 'p.srwidgetformpagechooser-url',
+               elWidgetContainer: 'div.srwidgetformpagechooser-container',
+               
+               isEnabled: false,
+               
+               frameId: 'sr-page-chooser-frame',
+               
+               currentContainer: null,
+               
+               init: function() {
+                       $(srPageChooserWidget.elButton).click(function(){
+                               srPageChooserWidget.clickHandler(this)
+                       });
+                       
+                       if (!$(srPageChooserWidget.elIframe).length) {
+                               srPageChooserWidget.createIframe();
+                       }
+               },
+               
+               createIframe: function(){
+                       var ifrm = $('<div 
class="srwidgetformpagechooser-iframe-container" style="display:none"><iframe 
id="iPageChooser" frameborder="0" scrolling="no" src="" 
class="srwidgetformpagechooser"></iframe><p 
class="srwidgetformpagechooser-url"></p><button 
class="srwidgetformpagechooser-done" type="button">Ok</button></div>');
+                       ifrm.appendTo('body');
+               },
+               
+               clickHandler: function(elButton) {
+                       // so we can have multiple page choosers on one page or 
one slot
+                       srPageChooserWidget.currentContainer = 
$(elButton).parents(srPageChooserWidget.elWidgetContainer);
+                       var c = $(srPageChooserWidget.elIframeContainer);
+                       var i = $(srPageChooserWidget.elIframe)
+                       var viewportHeight = window.innerHeight ? 
window.innerHeight : $(window).height();
+                       var h = viewportHeight/2 - c.height()/2;
+                       var w = $(window).width()/2 - c.width()/2;
+                       var offset = {
+                               top: $(window).scrollTop(), //h > 0 ? h : 0,
+                               left: w > 0 ? w : 0
+                       }
+                       if (i.attr('src') === '') {
+                               i.attr('src', sPageChooserWidgetUrl);
+                       }       
+                       c.css(offset).show();
+                       
c.find(srPageChooserWidget.elButtonDone).click(function(){
+                               srPageChooserWidget.doneHandler(this)
+                       })
+                       return false;
+               },
+               
+               doneHandler: function(elButtonDone) {
+                       $(srPageChooserWidget.elIframeContainer).css().hide();
+               },
+               
+               pageSelectHandler: function(pageInfo, baseUrl) {
+                       var url = (typeof(baseUrl) !== 'undefined' && baseUrl) 
? 'http://' + baseUrl + pageInfo.slug : pageInfo.title;
+                       var c = srPageChooserWidget.currentContainer;
+                       c.find(srPageChooserWidget.elPUrl).html('<span 
class="title">'+pageInfo.title+'</span>'+pageInfo.slug);
+                       c.find(srPageChooserWidget.elInput).val(pageInfo.slug);
+                       c.find(srPageChooserWidget.elSpan).html('<span 
class="title">'+pageInfo.title+'</span>'+pageInfo.slug);
+               }
+               
+       }
+       
+       PageChooserParent = {
+               onPageSelect: function(pageInfo, baseUrl) {
+                       srPageChooserWidget.pageSelectHandler(pageInfo, baseUrl)
+               }
+       }
+
+       $(document).ready(function(){
+               srPageChooserWidget.init();
+       });
+})(jQuery);
\ No newline at end of file

-- 
You received this message because you are subscribed to the Google Groups 
"symfony SVN" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/symfony-svn?hl=en.

Reply via email to