• Main Page
  • Related Pages
  • Namespaces
  • Data Structures
  • Files
  • File List
  • Globals

classes/class.ilStyleDefinition.php

Go to the documentation of this file.
00001 <?php
00002 /*
00003         +-----------------------------------------------------------------------------+
00004         | ILIAS open source                                                           |
00005         +-----------------------------------------------------------------------------+
00006         | Copyright (c) 1998-2001 ILIAS open source, University of Cologne            |
00007         |                                                                             |
00008         | This program is free software; you can redistribute it and/or               |
00009         | modify it under the terms of the GNU General Public License                 |
00010         | as published by the Free Software Foundation; either version 2              |
00011         | of the License, or (at your option) any later version.                      |
00012         |                                                                             |
00013         | This program is distributed in the hope that it will be useful,             |
00014         | but WITHOUT ANY WARRANTY; without even the implied warranty of              |
00015         | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               |
00016         | GNU General Public License for more details.                                |
00017         |                                                                             |
00018         | You should have received a copy of the GNU General Public License           |
00019         | along with this program; if not, write to the Free Software                 |
00020         | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA. |
00021         +-----------------------------------------------------------------------------+
00022 */
00023 
00024 
00034 require_once("classes/class.ilSaxParser.php");
00035 
00036 class ilStyleDefinition extends ilSaxParser
00037 {
00038 
00046         function ilStyleDefinition($a_template_id = "")
00047         {
00048                 global $ilias;
00049 
00050                 if ($a_template_id == "")
00051                 {
00052                         $a_template_id = $ilias->account->skin;
00053                 }
00054 //echo "<br>parse:"."./templates/".$a_template_id."/template.xml".":";
00055                 parent::ilSaxParser("./templates/".$a_template_id."/template.xml");
00056         }
00057 
00058 
00059         // PUBLIC METHODS
00060 
00067         function getStyles()
00068         {
00069 //echo ":".count($this->styles).":";
00070                 if (is_array($this->styles))
00071                 {
00072                         return $this->styles;
00073                 }
00074                 else
00075                 {
00076                         return array();
00077                 }
00078         }
00079 
00080         function getTemplateName()
00081         {
00082                 return $this->template_name;
00083         }
00084 
00085 
00086         function getStyle($a_id)
00087         {
00088                 return $this->styles[$a_id];
00089         }
00090 
00091 
00092         function getStyleName($a_id)
00093         {
00094                 return $this->styles[$a_id]["name"];
00095         }
00096 
00097 
00098         function getImageDirectory($a_id)
00099         {
00100                 return $this->styles[$a_id]["image_directory"];
00101         }
00102 
00103         function getAllTemplates()
00104         {
00105                 global $ilias;
00106 
00107                 $skins = array();
00108 
00109                 if ($dp = @opendir($ilias->tplPath))
00110                 {
00111                         while (($file = readdir($dp)) != false)
00112                         {
00113                                 //is the file a directory?
00114                                 if (is_dir($ilias->tplPath.$file) && $file != "." && $file != ".." && $file != "CVS")
00115                                 {
00116                                         if (is_file($ilias->tplPath.$file."/template.xml"))
00117                                         {
00118                                                 $skins[] = array(
00119                                                         "id" => $file
00120                                                 );
00121                                         }
00122                                 }
00123                         } // while
00124                 }
00125                 else
00126                 {
00127                         return false;
00128                 }
00129                 return $skins;
00130         }
00131 
00132         // PRIVATE METHODS
00133 
00140         function setHandlers($a_xml_parser)
00141         {
00142                 xml_set_object($a_xml_parser,$this);
00143                 xml_set_element_handler($a_xml_parser, 'handlerBeginTag', 'handlerEndTag');
00144                 xml_set_character_data_handler($a_xml_parser, 'handlerCharacterData');
00145         }
00146 
00155         function handlerBeginTag($a_xml_parser, $a_name, $a_attribs)
00156         {
00157                 switch($a_name)
00158                 {
00159                         case "template" :
00160                                 $this->template_name = $a_attribs["name"];
00161                                 break;
00162 
00163                         case "style" :
00164                                 $this->styles[$a_attribs["id"]] =
00165                                         array(  "id" => $a_attribs["id"],
00166                                                         "name" => $a_attribs["name"],
00167                                                         "css_file" => $a_attribs["id"].".css",
00168                                                         "image_directory" => $a_attribs["image_directory"]
00169                                         );
00170                                 $browsers =
00171                                         explode(",", $a_attribs["browsers"]);
00172                                 foreach ($browsers as $val)
00173                                 {
00174                                         $this->styles[$a_attribs["id"]]["browsers"][] = trim($val);
00175                                 }
00176                                 break;
00177                 }
00178         }
00179 
00187         function handlerCharacterData($a_xml_parser,$a_data)
00188         {
00189                 // DELETE WHITESPACES AND NEWLINES OF CHARACTER DATA
00190                 $a_data = preg_replace("/\n/","",$a_data);
00191                 $a_data = preg_replace("/\t+/","",$a_data);
00192 
00193                 if(!empty($a_data))
00194                 {
00195                         switch($this->current_tag)
00196                         {
00197                                 default:
00198                                         break;
00199                         }
00200                 }
00201         }
00202 
00210         function handlerEndTag($a_xml_parser,$a_name)
00211         {
00212         }
00213 }
00214 ?>

Generated on Fri Dec 13 2013 09:06:35 for ILIAS Release_3_4_x_branch .rev 46804 by  doxygen 1.7.1