phpgroupware-cvs
[Top][All Lists]
Advanced

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

[Phpgroupware-cvs] phpgwapi/inc class.common.inc.php, 1.229 class.css.in


From: ceb
Subject: [Phpgroupware-cvs] phpgwapi/inc class.common.inc.php, 1.229 class.css.inc.php, 1.1
Date: Tue, 15 Mar 2005 02:12:00 +0100

Update of phpgwapi/inc

Modified Files:
     Branch: MAIN
            class.common.inc.php lines: +34 -19
Added Files:
     Branch: MAIN
            class.css.inc.php 

Log Message:
added css support class

====================================================
Index: phpgwapi/inc/class.common.inc.php
diff -u phpgwapi/inc/class.common.inc.php:1.228 
phpgwapi/inc/class.common.inc.php:1.229
--- phpgwapi/inc/class.common.inc.php:1.228     Tue Jan 18 17:13:59 2005
+++ phpgwapi/inc/class.common.inc.php   Tue Mar 15 01:12:31 2005
@@ -694,7 +694,7 @@
                /**
                * Get template dir of an application
                *
-               * @param string $appname appication name optional can be 
derived from $phpgw_info['flags']['currentapp'];
+               * @param string $appname application name optional can be 
derived from $phpgw_info['flags']['currentapp'];
                * @param string? $layout optional can force the template set to 
a specific layout
                */
                function get_tpl_dir($appname = '',$layout = '')
@@ -1112,26 +1112,41 @@
                */
                function get_css()
                {
-                       $tpl = createObject('phpgwapi.Template', 
$this->get_tpl_dir('phpgwapi'));
-                       $tpl->set_file('css', 'css.tpl');
-                       $tpl->set_var($GLOBALS['phpgw_info']['theme']);
+                       $all_css = '';
+                       if(@is_object($GLOBALS['phpgw']->css))
+                       {
+                               $all_css .= 
$GLOBALS['phpgw']->css->get_css_links();
+                       }
+
+                       if (isset($GLOBALS['phpgw_info']['flags']['css_link']))
+               {
+                       $all_css .= $GLOBALS['phpgw_info']['flags']['css_link'] 
. "\n";
+               }
+
                        $app_css = '';
-                       if(@isset($GLOBALS['phpgw_info']['menuaction']))
-                       {
-                               list($app,$class,$method) = 
explode('.',$GLOBALS['phpgw_info']['menuaction']);
-                               if(is_array($GLOBALS[$class]->public_functions)
-                                       && 
$GLOBALS[$class]->public_functions['css'])
-                               {
-                                       $app_css .= $GLOBALS[$class]->css();
-                               }
-                       }
-                       if (isset($GLOBALS['phpgw_info']['flags']['css']))
+                       if(@isset($GLOBALS['phpgw_info']['menuaction']))
+                   {
+                       list($app,$class,$method) = 
explode('.',$GLOBALS['phpgw_info']['menuaction']);
+                       if(is_array($GLOBALS[$class]->public_functions)
+                               && $GLOBALS[$class]->public_functions['css'])
                        {
-                               $app_css .= 
$GLOBALS['phpgw_info']['flags']['css'];
+                               $app_css .= $GLOBALS[$class]->css();
                        }
-                       $tpl->set_var('app_css', $app_css);
-
-                       return $tpl->subst('css');
+               }
+
+                       if (isset($GLOBALS['phpgw_info']['flags']['css']))
+               {
+                       $app_css .= $GLOBALS['phpgw_info']['flags']['css'] . 
"\n";
+               }
+
+            $tpl = CreateObject('phpgwapi.Template', 
$this->get_tpl_dir('phpgwapi'));
+            $all_css .= $tpl->set_file('css', 'css.tpl');
+
+            $all_css .= $tpl->set_var('app_css', $app_css);
+                       $all_css .= 
$tpl->set_var($GLOBALS['phpgw_info']['theme']);
+                       $all_css .= $tpl->subst('css');
+
+                       return $all_css;
                }

                /**

====================================================
Index: class.css.inc.php
<?php
        /**
        * CSS support class
        * @copyright Copyright (C) 2005 Free Software Foundation, Inc 
http://www.fsf.org/
        * @license http://www.fsf.org/licenses/gpl.html GNU General Public 
License
        * @package phpgwapi
        * @subpackage gui
        * @version $Id:
        */

        /**
        * phpGroupWare css support class
        *
        * Only instanstiate this class using:
        * <code>
        *  if(address@hidden($GLOBALS['phpgw']->css))
        *  {
        *    $GLOBALS['phpgw']->css = CreateObject('phpgwapi.css');
        *  }
        * </code>
        *
        * This way a theme can see if this is a defined object and include the 
data,
        * while the is_object() wrapper prevents whiping out existing data held 
in
        * this instance variables, primarily the $files variable.
        *
        *
        * @package phpgwapi
        * @subpackage gui
        * @uses template
        */
        class css
        {
                /**
                * @var array list of validated files to be included in the head 
section of a page
                */
                var $files;

                /**
                * Constructor
                *
                * Initialize the instance variables
                */
                function css()
                {
                }

                /**
                * Used for generating the list of external css files to be 
included in the head of a page
                *
                * NOTE: This method should only be called by the template class.
                * The validation is done when the file is added so we don't 
have to worry now
                *
                * @returns string the html needed for importing the css into a 
page
                */
                function get_css_links()
                {
                        $links = '';
                        if(!empty($this->files) && is_array($this->files))
                        {
                                $links = "<!--CSS Imports from phpGW css class 
-->\n";
                                foreach($this->files as $app => $tplset)
                                {
                                        if(!empty($tplset) && is_array($tplset))
                                        {
                                                foreach($tplset as $tpl => 
$files)
                                                {
                                                        if(!empty($files) && 
is_array($files))
                                                        {
                                                                foreach($files 
as $file => $ignored)
                                                                {

                                                                        $links 
.= '<link rel="stylesheet" type="text/css" href="'
                                                                        . 
$GLOBALS['phpgw_info']['server']['webserver_url']
                                                                        . '/' . 
$app . '/templates/' . $tpl . '/css/' . $file . '.css" />' . "\n";
                                                                }
                                                        }
                                                }
                                        }
                                }
                        }
                        return $links;
                }

                /**
                * Checks to make sure a valid package and file name is provided
                *
                * @param string $file file to be included - no ".css" on the end
                * @param string $app application directory to search - default 
= phpgwapi
                * @returns bool was the file found?
                */
                function validate_file($file, $app='phpgwapi')
                {
                        if(is_readable(PHPGW_INCLUDE_ROOT . "/$app/templates/" 
. $GLOBALS['phpgw_info']['user']['preferences']['common']['template_set'] . 
"/css/$file.css"))
                        {
                                
$this->files[$app][$GLOBALS['phpgw_info']['user']['preferences']['common']['template_set']][$file]
 = True;
                                return True;
                        }
                        elseif(is_readable(PHPGW_INCLUDE_ROOT . 
"/$app/templates/base/css/$file.css"))
                        {
                                $this->files[$app]['base'][$file] = True;
                                return True;
                        }
                        return False;
                }
        }
?>






reply via email to

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