]> git.parisson.com Git - telemeta.git/commitdiff
eztelemeta: only load the player js and css deps if needed
authorolivier <>
Mon, 13 Apr 2009 13:11:33 +0000 (13:11 +0000)
committerolivier <>
Mon, 13 Apr 2009 13:11:33 +0000 (13:11 +0000)
tools/eztelemeta/autoloads/eztelemetadata.php [new file with mode: 0644]
tools/eztelemeta/autoloads/eztemplateautoload.php [new file with mode: 0644]
tools/eztelemeta/design/standard/override/templates/embed/eztelemetaitem.tpl
tools/eztelemeta/design/standard/templates/eztelemeta_head.tpl [new file with mode: 0644]
tools/eztelemeta/settings/design.ini.append
tools/eztelemeta/settings/site.ini.append [new file with mode: 0644]

diff --git a/tools/eztelemeta/autoloads/eztelemetadata.php b/tools/eztelemeta/autoloads/eztelemetadata.php
new file mode 100644 (file)
index 0000000..bc3fec0
--- /dev/null
@@ -0,0 +1,143 @@
+<?php
+//
+// Definition of eZTelemetaData class
+//
+// Note: this is a simplified version of the eZPageData utility from ezwebin
+//
+// Created on: <18-Aug-2007 10:49:08 ar>
+//
+// ## BEGIN COPYRIGHT, LICENSE AND WARRANTY NOTICE ##
+// SOFTWARE NAME: eZ Publish Website Interface
+// SOFTWARE RELEASE: 1.4-0
+// COPYRIGHT NOTICE: Copyright (C) 1999-2009 eZ Systems AS
+// SOFTWARE LICENSE: GNU General Public License v2.0
+// NOTICE: >
+//   This program is free software; you can redistribute it and/or
+//   modify it under the terms of version 2.0  of the GNU General
+//   Public License as published by the Free Software Foundation.
+//
+//   This program is distributed in the hope that it will be useful,
+//   but WITHOUT ANY WARRANTY; without even the implied warranty of
+//   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+//   GNU General Public License for more details.
+//
+//   You should have received a copy of version 2.0 of the GNU General
+//   Public License along with this program; if not, write to the Free
+//   Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+//   MA 02110-1301, USA.
+//
+//
+// ## END COPYRIGHT, LICENSE AND WARRANTY NOTICE ##
+//
+
+/*
+ Template operator to speed up page settings and style init time
+ Gets its parameters directly from template.
+ module_result.path | content_info | persistant_variable | menu.ini ++
+ are all used to generate page data, what menues to show
+ and so on.  
+*/
+
+class eZTelemetaData
+{
+    function eZTelemetaData()
+    {
+    }
+
+    function operatorList()
+    {
+        return array( 'eztelemetadata_set', 'eztelemetadata_append' );
+    }
+
+    function namedParameterPerOperator()
+    {
+        return true;
+    }
+
+    function namedParameterList()
+    {
+        return array( 'eztelemetadata_set' => array( 
+                              'key' => array( 'type' => 'string',
+                                              'required' => true,
+                                              'default' => false ),
+                            'value' => array( 'type' => 'mixed',
+                                              'required' => true,
+                                              'default' => false ) ),
+                      'eztelemetadata_append' => array( 
+                              'key' => array( 'type' => 'string',
+                                              'required' => true,
+                                              'default' => false ),
+                            'value' => array( 'type' => 'mixed',
+                                              'required' => true,
+                                              'default' => false ) ) );
+    }
+
+    function modify( $tpl, $operatorName, $operatorParameters, $rootNamespace, $currentNamespace, &$operatorValue, $namedParameters )
+    {
+        switch ( $operatorName )
+        {
+            // note: these functions are not cache-block safe
+            // as in: if called inside a cache-block then they will not be called when cache is used.
+            case 'eztelemetadata_set':
+            case 'eztelemetadata_append':
+            {
+                self::setPersistentVariable( $namedParameters['key'], $namedParameters['value'], $tpl, $operatorName === 'eztelemetadata_append' );
+            }break;
+        }
+    }
+
+    // reusable function for setting persistent_variable
+    static public function setPersistentVariable( $key, $value, $tpl, $append = false )
+    {
+        $persistentVariable = array();
+        if ( $tpl->hasVariable('persistent_variable') && is_array( $tpl->variable('persistent_variable') ) )
+        {
+           $persistentVariable = $tpl->variable('persistent_variable');
+        }
+        else if ( self::$persistentVariable !== null && is_array( self::$persistentVariable ) )
+        {
+            $persistentVariable = self::$persistentVariable;
+        }
+
+        if ( $append )
+        {
+            if ( isset( $persistentVariable[ $key ] ) && is_array( $persistentVariable[ $key ] ) )
+            {
+                $persistentVariable[ $key ][] = $value;
+            }
+            else
+            {
+                $persistentVariable[ $key ] = array( $value );
+            }
+        }
+        else
+        {
+            $persistentVariable[ $key ] = $value;
+        }
+
+        // set the finnished array in the template
+        $tpl->setVariable('persistent_variable', $persistentVariable);
+        
+        // storing the value internally as well in case this is not a view that supports persistent_variable (eztelemetadata will look for it)
+        self::$persistentVariable = $persistentVariable;
+    }
+    
+    // reusable function for getting persistent_variable
+    static public function getPersistentVariable( $key = null )
+    {
+        if ( $key !== null )
+        {
+            if ( isset( self::$persistentVariable[ $key ] ) )
+                return self::$persistentVariable[ $key ];
+            return null;
+        }
+        return self::$persistentVariable;
+    }
+
+    // Internal version of the $persistent_variable used on view that don't support it
+    static protected $persistentVariable = null;
+    
+}
+
+?>
diff --git a/tools/eztelemeta/autoloads/eztemplateautoload.php b/tools/eztelemeta/autoloads/eztemplateautoload.php
new file mode 100644 (file)
index 0000000..b222f88
--- /dev/null
@@ -0,0 +1,31 @@
+<?php
+//
+// ## BEGIN COPYRIGHT, LICENSE AND WARRANTY NOTICE ##
+// SOFTWARE NAME: eZ Publish Website Interface
+// SOFTWARE RELEASE: 1.4-0
+// COPYRIGHT NOTICE: Copyright (C) 1999-2009 eZ Systems AS
+// SOFTWARE LICENSE: GNU General Public License v2.0
+// NOTICE: >
+//   This program is free software; you can redistribute it and/or
+//   modify it under the terms of version 2.0  of the GNU General
+//   Public License as published by the Free Software Foundation.
+//
+//   This program is distributed in the hope that it will be useful,
+//   but WITHOUT ANY WARRANTY; without even the implied warranty of
+//   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+//   GNU General Public License for more details.
+//
+//   You should have received a copy of version 2.0 of the GNU General
+//   Public License along with this program; if not, write to the Free
+//   Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+//   MA 02110-1301, USA.
+//
+//
+// ## END COPYRIGHT, LICENSE AND WARRANTY NOTICE ##
+//
+
+$eZTemplateOperatorArray = array();
+$eZTemplateOperatorArray[] = array( 'script' => 'extension/eztelemeta/autoloads/eztelemetadata.php',
+                                    'class' => 'eZTelemetaData',
+                                    'operator_names' => array( 'eztelemetadata_set', 'eztelemetadata_append' ) );
+?>
index a1cbabefdaa136916c8756e6e38608934bb48faf..ee7b90673a099824442f74bd2a414bcfe129c08a 100755 (executable)
@@ -1,6 +1,4 @@
-<script language="javascript">
-soundManager.url = {'swf/'|ezdesign};
-</script>
+{eztelemetadata_set('eztelemeta_player', true)}
 <div class="view-embed">
     <div class="content-media">
     {let attribute=$object.data_map.item}
diff --git a/tools/eztelemeta/design/standard/templates/eztelemeta_head.tpl b/tools/eztelemeta/design/standard/templates/eztelemeta_head.tpl
new file mode 100644 (file)
index 0000000..4aa0a40
--- /dev/null
@@ -0,0 +1,26 @@
+{if is_set( $module_result.content_info.persistent_variable.eztelemeta_player )}
+<style type="text/css">
+  @import url({"stylesheets/eztelemeta.css"|ezdesign});
+  @import url({"stylesheets/page-player.css"|ezdesign});
+</style>
+  <script language="JavaScript" type="text/javascript" src={"javascript/soundmanager2.js"|ezdesign}></script>
+  <script language="JavaScript" type="text/javascript">
+    /* SoundManager2 configuration */
+    soundManager.debugMode = true;
+    soundManager.url = {'swf/'|ezdesign};
+
+    /* SoundManager2 Page Player configuration */
+    {literal}
+    var PP_CONFIG = {
+      flashVersion:     9,
+      usePeakData:      true,
+      useWaveformData:  false,
+      useEQData:        false,
+      useFavIcon:       false,
+      useMovieStar:     false,
+      updatePageTitle:  false
+    }
+    {/literal}
+  </script>
+  <script language="JavaScript" type="text/javascript" src={"javascript/page-player.js"|ezdesign}></script>
+{/if}
index 4473da943bbeebc6892e86d50f3a5de0cdd91f01..9243943a379c53e60589b7f83edf42174f1e1939 100644 (file)
@@ -1,11 +1,3 @@
 [ExtensionSettings]
 DesignExtensions[]=eztelemeta
 
-[StylesheetSettings]
-CSSFileList[]=eztelemeta.css
-CSSFileList[]=page-player.css
-
-[JavaScriptSettings]
-JavaScriptList[]=soundmanager2.js
-JavaScriptList[]=init.js
-JavaScriptList[]=page-player.js
diff --git a/tools/eztelemeta/settings/site.ini.append b/tools/eztelemeta/settings/site.ini.append
new file mode 100644 (file)
index 0000000..d339486
--- /dev/null
@@ -0,0 +1,3 @@
+[TemplateSettings]
+ExtensionAutoloadPath[]=eztelemeta
+