fmsystem-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Fmsystem-commits] [10441] api: localised yui3 and formvalidator


From: Sigurd Nes
Subject: [Fmsystem-commits] [10441] api: localised yui3 and formvalidator
Date: Sat, 03 Nov 2012 21:36:20 +0000

Revision: 10441
          http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=10441
Author:   sigurdne
Date:     2012-11-03 21:36:19 +0000 (Sat, 03 Nov 2012)
Log Message:
-----------
api: localised yui3 and formvalidator

Added Paths:
-----------
    trunk/phpgwapi/inc/yui-combo-master/
    trunk/phpgwapi/inc/yui-combo-master/LICENSE
    trunk/phpgwapi/inc/yui-combo-master/README.textile
    trunk/phpgwapi/inc/yui-combo-master/combo.php
    trunk/phpgwapi/inc/yui-combo-master/lib/
    trunk/phpgwapi/inc/yui-combo-master/lib/YUICombo.php
    trunk/phpgwapi/inc/yui-combo-master/lib/YUIFileUtil.php
    trunk/phpgwapi/inc/yui-combo-master/lib/YUIHeaderUtil.php
    trunk/phpgwapi/inc/yui-combo-master/settings.php
    trunk/phpgwapi/js/yui3/gallery-formvalidator/images/
    trunk/phpgwapi/js/yui3/gallery-formvalidator/images/blue_gradient.png
    trunk/phpgwapi/js/yui3/gallery-formvalidator/images/checkmark_small.png
    trunk/phpgwapi/js/yui3/gallery-formvalidator/images/exclamation_small.png
    trunk/phpgwapi/js/yui3/gallery-formvalidator/images/red_gradient.png
    trunk/phpgwapi/js/yui3/gallery-formvalidator/validatorCss.css

Added: trunk/phpgwapi/inc/yui-combo-master/LICENSE
===================================================================
--- trunk/phpgwapi/inc/yui-combo-master/LICENSE                         (rev 0)
+++ trunk/phpgwapi/inc/yui-combo-master/LICENSE 2012-11-03 21:36:19 UTC (rev 
10441)
@@ -0,0 +1,30 @@
+Software License Agreement (BSD License)
+
+Copyright (c) 2007, Eduardo Lundgren <address@hidden>.
+All rights reserved.
+
+Redistribution and use of this software in source and binary forms, with or 
without modification, are
+permitted provided that the following conditions are met:
+
+* Redistributions of source code must retain the above
+  copyright notice, this list of conditions and the
+  following disclaimer.
+
+* Redistributions in binary form must reproduce the above
+  copyright notice, this list of conditions and the
+  following disclaimer in the documentation and/or other
+  materials provided with the distribution.
+
+* The name of Eduardo Lundgren may not be used to endorse or promote products
+  derived from this software without specific prior
+  written permission of Eduardo Lundgren.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 
AND ANY EXPRESS OR IMPLIED
+WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
MERCHANTABILITY AND FITNESS FOR A
+PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 
CONTRIBUTORS BE LIABLE FOR
+ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 
(INCLUDING, BUT NOT
+LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 
PROFITS; OR BUSINESS
+INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
CONTRACT, STRICT LIABILITY, OR
+TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 
THIS SOFTWARE, EVEN IF
+ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+

Added: trunk/phpgwapi/inc/yui-combo-master/README.textile
===================================================================
--- trunk/phpgwapi/inc/yui-combo-master/README.textile                          
(rev 0)
+++ trunk/phpgwapi/inc/yui-combo-master/README.textile  2012-11-03 21:36:19 UTC 
(rev 10441)
@@ -0,0 +1,42 @@
+h1. YUI3 Combo
+
+<p>Inspired on the YUI Development Combo Server 
(http://github.com/davglass/yui-dev-combo).</p>
+<p>Designed to be used to generate the combo file for the request made from 
loader.js using YUI3. In summary, read the parameters keys (combo files), 
concatenate them, gzip, cache, set the HTTP headers, print out the combo 
file.</p>
+
+h2. Example
+
+<p>Testing with YUI3 Loader metadata:</p>
+
+<pre class="console">
+var PATH_BASE = YUI.config.base;
+
+var YUI_metadata = {
+       combine: true,
+    root: './../../build/',
+       comboBase: PATH_BASE + '../lib/yui-combo/combo.php?'
+};
+
+// testing the request
+YUI(YUI_metadata).use('io');
+</pre>
+
+<p>The combo.php invoke the YUICombo class to manage the request of the YUI3 
loader.js for your and for the YUI3 modules.</p>
+
+<pre class="console">
+<?php
+       include_once("settings.php");
+       include_once("lib/YUIFileUtil.php");
+       include_once("lib/YUIHeaderUtil.php");
+       include_once("lib/YUICombo.php");
+
+       $config = array(
+               // "cache" => false, // cache the request
+               // "cacheCombo" => false, // cache the gzipped combo file in 
the server (for performance)
+               // "gzip" => false // gzip the request
+       );
+
+       $combo = new YUICombo($_GET, $config);
+
+       $combo->loadModules();
+?>
+</pre>
\ No newline at end of file

Added: trunk/phpgwapi/inc/yui-combo-master/combo.php
===================================================================
--- trunk/phpgwapi/inc/yui-combo-master/combo.php                               
(rev 0)
+++ trunk/phpgwapi/inc/yui-combo-master/combo.php       2012-11-03 21:36:19 UTC 
(rev 10441)
@@ -0,0 +1,16 @@
+<?php
+include_once("settings.php");
+include_once("lib/YUIFileUtil.php");
+include_once("lib/YUIHeaderUtil.php");
+include_once("lib/YUICombo.php");
+
+$config = array(
+       // "cache" => false,
+       // "cacheCombo" => false,
+       // "gzip" => false
+);
+
+$combo = new YUICombo($_GET, $config);
+
+$combo->loadModules();
+?>

Added: trunk/phpgwapi/inc/yui-combo-master/lib/YUICombo.php
===================================================================
--- trunk/phpgwapi/inc/yui-combo-master/lib/YUICombo.php                        
        (rev 0)
+++ trunk/phpgwapi/inc/yui-combo-master/lib/YUICombo.php        2012-11-03 
21:36:19 UTC (rev 10441)
@@ -0,0 +1,214 @@
+<?php
+define(DOT, ".");
+define(EMPTY_STRING, "");
+
+class YUICombo {
+       function __construct($modules, $config) {
+               $this->init($modules, $config);
+       }
+
+       function init($modules, $config) {
+               $this->defaults = array(
+                       "cache" => true,
+                       "cacheCombo" => true,
+                       "gzip" => true
+               );
+
+               $this->mimetype = array(
+                       "js" => "text/javascript",
+                       "css" => "text/css"
+               );
+
+               $this->setModules($modules);
+               $this->setConfig($config);
+       }
+
+       function fixPath($path) {
+       $path = str_replace(array('\\','_'), array('/', '.'), $path);
+//echo $path . '<br/>'; 
+//             $path = ereg_replace("[/\]+", "/", $path);
+//             return str_replace("_", ".", $path);
+               return $path;
+       }
+
+       function getBasePath() {
+               $config = $this->getConfig();
+               $basePath = $config[basePath];
+
+               return $basePath ? $basePath : COMBO_FILE_PATH;
+       }
+
+       function getContent($path) {
+               return file_get_contents($path);
+       }
+
+       function getModule($index) {
+               $modules = $this->getModules();
+
+               return $modules[$index];
+       }
+
+       function getRequestId() {
+               $config = $this->getConfig();
+               $cache = $config["cache"];
+               $cacheCombo = $config["cacheCombo"];
+               $gzip = $config["gzip"];
+
+               $filemtimes = EMPTY_STRING;
+               $query = $_SERVER["QUERY_STRING"].("gzip=".$gzip);
+
+               foreach($this->getModules() as $index => $module) {
+                       $path = $this->path($module);
+
+                       if ($path) {
+                               $filemtimes .= filemtime($path);
+                       }
+               }
+
+               return sha1($query.$filemtimes);
+       }
+
+       function isSecureRequest() {
+               $hasPermission = true;
+
+               // checking security, not allow access files outside the 
builder folder
+               foreach($this->getModules() as $index => $module) {
+                       $path = $this->path($module);
+
+                       if (!YUIFileUtil::isSubDir($path, YUI_BUILD_PATH)) {
+                               $hasPermission = false;
+                       }
+               }
+
+               if (!$hasPermission) {
+                       YUIHeaderUtil::setForbidden();
+               }
+
+               return $hasPermission;
+       }
+
+       function fixImagePath($content, $dirname) {
+               $pattern = "/(url[(][\"']?)(?!https?)([^)\"']+)([\"']?[)])/i";
+               $replacement = "$1$dirname$2$3";
+
+               return preg_replace($pattern, $replacement, $content);
+       }
+
+       function loadModules() {
+               $config = $this->getConfig();
+               $cache = $config["cache"];
+               $cacheCombo = $config["cacheCombo"];
+               $gzip = $config["gzip"];
+
+               $this->REQUEST_CACHE_ID = $this->getRequestId();
+
+               // base the mimetype of the request on the first module
+               $firstModulePath = $this->path(
+                       $this->getModule(0)
+               );
+
+               if ($firstModulePath && $this->isSecureRequest()) {
+                       $content = EMPTY_STRING;
+
+                       // including the module content...
+                       if ($cacheCombo) {
+                               $cachedContent = YUIFileUtil::getCache(
+                                       $this->REQUEST_CACHE_ID
+                               );
+                       }
+
+                       if ($cachedContent) {
+                               $content = $cachedContent;
+                       }
+                       else {
+                               // concatenate the files
+                               foreach($this->getModules() as $index => 
$module) {
+                                       $path = $this->path($module);
+
+                                       if 
(YUIFileUtil::getFileExtension($path) == 'css') {
+                                               // fixing url() for CSS, 
concatenating DOT.DS (./) to all fixed url to force it to be relative
+                                               // the fixImagePath() won't fix 
for http(s) urls
+                                               $dirname = dirname( 
$this->fixPath(DOT . DS . $module) ) . DS;
+
+                                               $content .= $this->fixImagePath(
+                                                       
$this->getContent($path),
+                                                       $dirname
+                                               );
+                                       }
+                                       else {
+                                               // JavaScript...
+                                               $content .= 
$this->getContent($path);
+                                       }
+                               }
+
+                               if ($gzip) {
+                                       // gzip the content before save the 
cache
+                                       $content = gzencode($content, 9);
+                               }
+
+                               if ($cacheCombo) {
+                                       YUIFileUtil::writeCache(
+                                               $this->REQUEST_CACHE_ID,
+                                               $content
+                                       );
+                               }
+                       }
+
+                       $requestMimeType = $this->mimetype[
+                               YUIFileUtil::getFileExtension($firstModulePath)
+                       ];
+
+                       if ($cache) {
+                               YUIHeaderUtil::setAge();
+                               YUIHeaderUtil::setExpires();
+                               YUIHeaderUtil::setCacheControl();
+                       }
+
+                       YUIHeaderUtil::setContentType($requestMimeType);
+
+                       if ($gzip) {
+                               YUIHeaderUtil::setGzip();
+                       }
+
+                       echo $content;
+               }
+       }
+
+       function path($path) {
+               $path = $this->fixPath($path);
+//             $path = $this->getBasePath() . DS . $path;
+               $path = YUI_BUILD_PATH . DS . $path;
+               $realpath = realpath($path);
+               return (file_exists($realpath) && is_readable($realpath)) ? 
$realpath : false;
+       }
+
+       /*
+       * Getters and Setters
+       */
+
+       function getConfig() {
+               return $this->config;
+       }
+
+       function setConfig($config) {
+               $this->config = array_merge($this->defaults, $config);
+       }
+
+       function getModules() {
+               return $this->modules;
+       }
+
+       function setModules($modules) {
+               $newModules = array();
+
+               foreach($modules as $module => $val) {
+                       $path = $this->path($module);
+                       if ($path) {
+                               $newModules[] = $module;
+                       }
+               }
+
+               $this->modules = $newModules;
+       }
+}
+?>

Added: trunk/phpgwapi/inc/yui-combo-master/lib/YUIFileUtil.php
===================================================================
--- trunk/phpgwapi/inc/yui-combo-master/lib/YUIFileUtil.php                     
        (rev 0)
+++ trunk/phpgwapi/inc/yui-combo-master/lib/YUIFileUtil.php     2012-11-03 
21:36:19 UTC (rev 10441)
@@ -0,0 +1,53 @@
+<?php
+class YUIFileUtil {
+       public static function getFileExtension($filename) {
+               preg_match("/\\.([^.]+)*$/i", basename($filename), $m);
+               return strtolower($m[1]);
+       }
+
+       public static function isSubDir($path = NULL, $parent_folder) {
+           //Get directory path minus last folder
+           $dir = dirname($path);
+           $folder = substr($path, strlen($dir));
+
+           //Check the the base dir is valid
+           $dir = realpath($dir);
+
+           //Only allow valid filename characters
+           $folder = preg_replace('/[^a-z0-9\.\-_]/i', '', $folder);
+
+           //If this is a bad path or a bad end folder name
+           if( !$dir OR !$folder OR $folder === '.') {
+               return FALSE;
+           }
+
+           //Rebuild path
+           $path = $dir.DS.$folder;
+
+           //If this path is higher than the parent folder
+           if( strcasecmp($path, realpath($parent_folder)) > 0 ) {
+               return $path;
+           }
+
+           return false;
+       }
+
+       function writeCache($id, $content) {
+               if (!is_dir(TEMP_DIR)) {
+                       mkdir(TEMP_DIR, 0777);
+               }
+
+               file_put_contents(TEMP_DIR.DS.$id, $content);
+       }
+
+       function getCache($id) {
+               $file = TEMP_DIR.DS.$id;
+
+               if (is_file($file)) {
+                       return file_get_contents(TEMP_DIR.DS.$id);
+               }
+
+               return false;
+       }
+}
+?>

Added: trunk/phpgwapi/inc/yui-combo-master/lib/YUIHeaderUtil.php
===================================================================
--- trunk/phpgwapi/inc/yui-combo-master/lib/YUIHeaderUtil.php                   
        (rev 0)
+++ trunk/phpgwapi/inc/yui-combo-master/lib/YUIHeaderUtil.php   2012-11-03 
21:36:19 UTC (rev 10441)
@@ -0,0 +1,31 @@
+<?php
+class YUIHeaderUtil {
+       public function setAge($age = 0) {
+               header("Age: $age");
+       }
+
+       public function setCacheControl($cacheControl = "max-age=315360000") {
+               header("Cache-Control: $cacheControl");
+       }
+
+       public function setContentLength($bytes) {
+               header("Content-Length: $bytes");
+       }
+
+       public static function setContentType($mimetype) {
+               header("Content-Type: ".$mimetype);
+       }
+
+       public function setExpires() {
+               header("Expires: " . @date("r", @mktime() + (60 * 60 * 24 * 365 
* 10)));
+       }
+
+       public static function setForbidden() {
+               header("HTTP/1.1 403 Forbidden");
+       }
+
+       public function setGzip() {
+               header("Content-Encoding: gzip");
+       }
+}
+?>
\ No newline at end of file

Added: trunk/phpgwapi/inc/yui-combo-master/settings.php
===================================================================
--- trunk/phpgwapi/inc/yui-combo-master/settings.php                            
(rev 0)
+++ trunk/phpgwapi/inc/yui-combo-master/settings.php    2012-11-03 21:36:19 UTC 
(rev 10441)
@@ -0,0 +1,17 @@
+<?php
+define(COMBO_FILE_PATH, dirname(__FILE__));
+
+//define(YUI_BUILD_PATH, COMBO_FILE_PATH . '/../../build');
+define(YUI_BUILD_PATH, realpath(COMBO_FILE_PATH . '/../../js/yui3'));
+
+if ( substr(PHP_OS, 3) == 'WIN' )
+{
+       define(TEMP_DIR, 'c:/temp/yuicombo');
+}
+else
+{
+       define(TEMP_DIR, '/tmp/yuicombo');
+}
+
+define(DS, DIRECTORY_SEPARATOR);
+?>

Added: trunk/phpgwapi/js/yui3/gallery-formvalidator/images/blue_gradient.png
===================================================================
(Binary files differ)


Property changes on: 
trunk/phpgwapi/js/yui3/gallery-formvalidator/images/blue_gradient.png
___________________________________________________________________
Added: svn:mime-type
   + application/octet-stream

Added: trunk/phpgwapi/js/yui3/gallery-formvalidator/images/checkmark_small.png
===================================================================
(Binary files differ)


Property changes on: 
trunk/phpgwapi/js/yui3/gallery-formvalidator/images/checkmark_small.png
___________________________________________________________________
Added: svn:mime-type
   + application/octet-stream

Added: trunk/phpgwapi/js/yui3/gallery-formvalidator/images/exclamation_small.png
===================================================================
(Binary files differ)


Property changes on: 
trunk/phpgwapi/js/yui3/gallery-formvalidator/images/exclamation_small.png
___________________________________________________________________
Added: svn:mime-type
   + application/octet-stream

Added: trunk/phpgwapi/js/yui3/gallery-formvalidator/images/red_gradient.png
===================================================================
(Binary files differ)


Property changes on: 
trunk/phpgwapi/js/yui3/gallery-formvalidator/images/red_gradient.png
___________________________________________________________________
Added: svn:mime-type
   + application/octet-stream

Added: trunk/phpgwapi/js/yui3/gallery-formvalidator/validatorCss.css
===================================================================
--- trunk/phpgwapi/js/yui3/gallery-formvalidator/validatorCss.css               
                (rev 0)
+++ trunk/phpgwapi/js/yui3/gallery-formvalidator/validatorCss.css       
2012-11-03 21:36:19 UTC (rev 10441)
@@ -0,0 +1,163 @@
+
+body {
+    margin:0;
+    padding:0;
+    border:0;
+    height:100%;
+}
+
+div.mainContainer {
+    width:740px;
+    color:#06c;
+    position:relative;
+    background-color:#fff;
+    font-family:Arial;
+    font-size:10pt;
+    padding-top:0px;
+    margin:0 auto;
+}
+.clearDiv {
+    clear:both;
+}
+
+div.formBody {
+}
+
+div.formBody div.info{
+    padding-bottom:10px;
+}
+
+div.formBody h2{
+    
+}
+
+div.formBody div.row {
+    position:relative;
+    width:100%;
+    margin-bottom:1px;
+}
+div.formBody div.label {
+    float:left;
+    position:relative;
+    z-index:1;
+    padding:4px 2px 4px 0;
+    text-align:right;
+    width:19%;
+}
+div.formBody div.row div.column1Backing {
+    position:absolute;
+    top:0;
+    z-index:0;
+    left:0;
+    background-color:#C3D9FF;
+    width:19%;
+    height:100%;
+}
+div.formBody div.row div.column2Backing {
+    position:absolute;
+    top:0;
+    z-index:0;
+    left:49.7%;
+    width:19%;
+    background-color:#C3D9FF;
+    height:100%;
+}
+div.formBody div.value {
+    float:left;
+    position:relative;
+    background-color:#e0ecff;
+    padding:4px 2px 4px 0;
+    width:30%;
+}
+
+div.formBody div.value div.innerValue{
+    margin-left:5px;
+    position:relative;
+    margin-left:5px;
+}
+
+
+div.formBody div.value input {
+    position:relative;
+    margin-left:5px;
+    z-index:1;
+}
+
+div.formBody div.value div.innerValue input{
+    margin-left:0;
+}
+
+div.validator {
+    display:block;
+    position:absolute;
+    top:0;
+    left:0;
+    width:100%;
+    height:100%;
+    z-index:0;
+    padding:0;
+    background-image:url(images/red_gradient.png);
+    background-repeat:repeat-x;
+    background-position:0 0;
+    /*filter:alpha(opacity=40);
+    -moz-opacity:.40;
+    opacity:.40;*/
+}
+
+div.indicator {
+    position:absolute;
+    top:0;
+    left:0;
+    width:100%;
+    height:100%;
+    z-index:0;
+    background-image:url(images/green_gradient.png);
+    background-repeat:repeat-x;
+    background-position:0 0;
+}
+
+div.validator span.validator,
+div.indicator span.indicator {
+    position:absolute;
+    right:10px;
+    margin-top:7px;
+}
+
+span.validator{
+    background-image:url(images/exclamation_small.png);
+    background-repeat:no-repeat;
+    background-position:center center;
+    padding-left:17px;
+}
+
+span.indicator{
+    background-image:url(images/checkmark_small.png);
+    background-repeat:no-repeat;
+    background-position:center 0;
+    padding-left:17px;
+}
+
+div.buttonRow {
+    background-color:#e0ecff;
+    text-align:right;
+    padding:5px 5px;
+    margin-right:8px;
+}
+
+div.buttonRow .button {
+    background-image:url(images/blue_gradient.png);
+    background-repeat:repeat-x;
+    xcolor:#06c;
+    border:1px solid #C3D9FF;
+    padding:3px 5px;
+}
+
+input.valid,
+select.valid{
+    border:2px solid #0f0;
+}
+
+input.invalid,
+select.invalid{
+    border:2px solid #f00;
+}




reply via email to

[Prev in Thread] Current Thread [Next in Thread]