source: trunk/spip/esqueleto-redcta/themes/alternatives/plugins/sktheme/1_9_1/inc/sktheme_list.php @ 30

Last change on this file since 30 was 30, checked in by sebas, 17 years ago

nueva importacion del codigo del esqueleto de redcta con los plugins

File size: 4.4 KB
Line 
1<?php
2  // ---------------------------------------------------------------------
3  //
4  // Sktheme : manage themes under SPIP (squelettes + habillages)
5  //
6  // Copyright (c) 2006 - Skedus
7  //
8  // This program is free software; you can redistribute it and/or modify
9  // it under the terms of the GNU General Public License as published by
10  // the Free Software Foundation; either version 2 of the License, or
11  // (at your option) any later version.
12  //
13  // You should have received a copy of the GNU General Public License
14  // along with this program;
15  //
16  // ---------------------------------------------------------------------
17 
18  // Create theme list
19function sktheme_list() {
20   
21  include_spip('inc/sktheme_xml');
22
23  $original = _T('sktheme:original');
24  $sktheme_list = array();
25 
26  $s_dir = _DIR_RACINE.$GLOBALS['meta']['sktheme_squelettes_public_dir'];
27  $squelettes_list = array('dist' => '' );
28  if (is_dir($s_dir)) {
29    if ($dh = opendir($s_dir)) {
30      while (($dir = readdir($dh)) !== false) {
31        if ( (is_dir($s_dir."/".$dir)) AND ($dir[0]!=".") ) {
32          // Check if a theme.xml exists and if the type is squelettes
33          if (is_file($s_dir."/".$dir."/theme.xml")) {
34            $s_info = sktheme_xml_get_infos($s_dir."/".$dir,"theme");
35            $type = (isset($s_info['type'])) ? propre($s_info['type']) : "";
36            if ($type == 'squelettes') {
37              $squelettes_list[$dir]=$s_dir."/".$dir;
38            }
39          }
40        }
41      }
42      closedir($dh);
43    }
44  } else {
45    // no extra directory for squelette
46    array_push($sktheme_list,"dist::".$original);
47    return $sktheme_list;
48  }
49
50  $h_dir = _DIR_RACINE.$GLOBALS['meta']['sktheme_habillages_public_dir'];
51  $habillages_list = array($original => '');
52  if (is_dir($h_dir)) {
53    if ($dh = opendir($h_dir)) {
54      while (($dir = readdir($dh)) !== false) {
55        if ( (is_dir($h_dir."/".$dir)) AND ($dir[0]!=".") ) {
56          // Check if a theme.xml exists and if the type is themes
57          if (is_file($h_dir."/".$dir."/theme.xml")) {
58            $h_info = sktheme_xml_get_infos($h_dir."/".$dir,"theme");
59            $type = (isset($h_info['type'])) ? propre($h_info['type']) : "";
60            if ($type == 'themes') {
61              $habillages_list[$dir] = sktheme_xml_get_infos($h_dir."/".$dir,"theme");
62            }
63          }
64        }
65      }
66      closedir($dh);
67    } 
68  } else {
69    // no habillage directory
70    foreach( $squelettes_list as $s_key => $s_value) {
71      array_push($sktheme_list,$s_key."::".$original);
72      return $sktheme_list;
73    }
74  }
75
76  // Look for matching theme
77  foreach( $squelettes_list as $s_key => $s_value) {
78   
79    foreach( $habillages_list as $h_key => $h_info) {
80      if ($h_key == $original) {
81        array_push($sktheme_list,$s_key."::".$h_key);
82      } else {
83        $squelette_ok = false;
84        if (is_array($h_info['squelettes'])) {
85          foreach ($h_info['squelettes'] as $sq){
86            $sq = trim($sq);
87            if ($sq == $s_key) {
88              $squelette_ok = true;
89            }
90          }
91        } else {
92          if ($h_info['squelettes'] == $s_key) {
93            $squelette_ok = true;
94          }
95        }
96        if ($squelette_ok) {
97          array_push($sktheme_list,$s_key."::".$h_key);
98        }
99      }
100    }
101  }
102  return $sktheme_list;
103}
104
105
106
107function sktheme_habillage_list() {
108   
109  include_spip('inc/sktheme_xml');
110
111  $original = _T('sktheme:original');
112  $sktheme_habillage_list = array();
113 
114  $squelette_name = $GLOBALS['meta']['sktheme_squelette_public_name'];
115 
116  $h_dir = _DIR_RACINE.$GLOBALS['meta']['sktheme_habillages_public_dir'];
117  $habillages_list = array($original => '');
118  if (is_dir($h_dir)) {
119    if ($dh = opendir($h_dir)) {
120      while (($file = readdir($dh)) !== false) {
121        if ( (is_dir($h_dir."/".$file)) AND ($file[0]!=".") ) {
122          $habillages_list[$file] = sktheme_xml_get_infos($h_dir."/".$file,"theme");
123        }
124      }
125      closedir($dh);
126    } 
127  } else {
128    // no habillage directory
129    array_push($sktheme_habillage_list,$original);
130    return $sktheme_habillage_list;
131  }
132
133  // Look for matching theme
134   
135  foreach( $habillages_list as $h_key => $h_info) {
136    if ($h_key == $original) {
137      array_push($sktheme_habillage_list,$h_key);
138    } else {
139      $squelette_ok = false;
140      if (is_array($h_info['squelettes'])) {
141        foreach ($h_info['squelettes'] as $sq){
142          $sq = trim($sq);
143          if ($sq == $squelette_name) {
144            $squelette_ok = true;
145          }
146        }
147      } else {
148        if ($h_info['squelettes'] == $squelette_name) {
149          $squelette_ok = true;
150        }
151      }
152      if ($squelette_ok) {
153        array_push($sktheme_habillage_list,$h_key);
154      }
155    }
156  }
157  return $sktheme_habillage_list;
158}
159?>
Note: See TracBrowser for help on using the repository browser.