1 | <?php |
---|
2 | class c_ThemeChangerConfig { |
---|
3 | // Déclarations des données membres |
---|
4 | |
---|
5 | var $categorySize; |
---|
6 | |
---|
7 | function SetcategorySize($categorySize){ |
---|
8 | $this->categorySize = $categorySize; |
---|
9 | } |
---|
10 | |
---|
11 | |
---|
12 | var $categories; |
---|
13 | |
---|
14 | function Setcategories($categories){ |
---|
15 | $this->categories = $categories; |
---|
16 | } |
---|
17 | |
---|
18 | var $themes ; |
---|
19 | function Setthemes($themes){ |
---|
20 | $this->themes = $themes; |
---|
21 | } |
---|
22 | var $listcategoryParamThemeChanger ; |
---|
23 | function SetlistcategoryParamThemeChanger($listcategoryParamThemeChanger){ |
---|
24 | $this->listcategoryParamThemeChanger = $listcategoryParamThemeChanger; |
---|
25 | } |
---|
26 | |
---|
27 | var $applysubcategory; |
---|
28 | function Setapplysubcategory($applysubcategory){ |
---|
29 | $this->applysubcategory = $applysubcategory; |
---|
30 | } |
---|
31 | |
---|
32 | var $thecategory; |
---|
33 | function Setthecategory($thecategory){ |
---|
34 | $this->thecategory = $thecategory; |
---|
35 | } |
---|
36 | var $nomGalerie; |
---|
37 | function SetnomGalerie($nomGalerie){ |
---|
38 | $this->nomGalerie = $nomGalerie; |
---|
39 | } |
---|
40 | var $OverWriteHome; |
---|
41 | function SetOverWriteHome($OverWriteHome){ |
---|
42 | $this->OverWriteHome = $OverWriteHome; |
---|
43 | } |
---|
44 | var $titreGalerie; |
---|
45 | function SettitreGalerie($titreGalerie){ |
---|
46 | $this->titreGalerie = $titreGalerie; |
---|
47 | } |
---|
48 | |
---|
49 | function get_categories () |
---|
50 | { |
---|
51 | if (ISSET($this->categories)) |
---|
52 | return $this->categories; |
---|
53 | $this->categorySize = 0; |
---|
54 | $cat=array(); |
---|
55 | $categoriesTmp = array(); |
---|
56 | |
---|
57 | //chargement des catégories |
---|
58 | $query = ' |
---|
59 | SELECT id, name, uppercats, global_rank |
---|
60 | FROM '.CATEGORIES_TABLE.' ; |
---|
61 | '; |
---|
62 | $result = pwg_query($query); |
---|
63 | |
---|
64 | while (($cat = pwg_db_fetch_assoc($result)) <> null) |
---|
65 | { |
---|
66 | array_push($categoriesTmp , array("id" => $cat['id'], |
---|
67 | "name" => $cat['name'], |
---|
68 | "uppercats" =>$cat['uppercats'], |
---|
69 | "longName" => get_cat_display_name_cache($cat['uppercats'], null, false), |
---|
70 | "global_rank" => $cat['global_rank'], |
---|
71 | )); |
---|
72 | $this->categorySize = $this->categorySize + 1; |
---|
73 | } |
---|
74 | $cat = array(); |
---|
75 | $this->Setcategories($categoriesTmp); |
---|
76 | return $categoriesTmp; |
---|
77 | } |
---|
78 | |
---|
79 | function get_categoriesLongName($id) |
---|
80 | { |
---|
81 | $i = 0; |
---|
82 | $length = $this->categorySize; |
---|
83 | |
---|
84 | while ($i < $length) { |
---|
85 | if ($id == $this->categories[$i]['id']) |
---|
86 | return $this->categories[$i]['longName']; |
---|
87 | $i = $i + 1; |
---|
88 | } |
---|
89 | return ''; |
---|
90 | } |
---|
91 | |
---|
92 | |
---|
93 | function get_themes() |
---|
94 | { |
---|
95 | if (ISSET($this->themes)) |
---|
96 | return $this->themes; |
---|
97 | |
---|
98 | $themesTmp = array(); |
---|
99 | foreach (get_pwg_themes() as $pwg_template) |
---|
100 | { |
---|
101 | $selected = $pwg_template; |
---|
102 | array_push($themesTmp, $selected); |
---|
103 | } |
---|
104 | $this->Setthemes($themesTmp); |
---|
105 | return $themesTmp; |
---|
106 | } |
---|
107 | function initThemeChanger ($thecategory, $nomGalerie, $titreGalerie, $applysubcategory, $OverWriteHome) |
---|
108 | { |
---|
109 | |
---|
110 | if (ISSET($this->listcategoryParamThemeChanger)) |
---|
111 | return $this->listcategoryParamThemeChanger; |
---|
112 | |
---|
113 | $listcategoryParamThemeChangerTmp = array(); |
---|
114 | |
---|
115 | if ($applysubcategory <> 'false') { |
---|
116 | foreach ($this->categories as $icat) { |
---|
117 | $tmp = explode("," , $icat['uppercats']); |
---|
118 | if (in_array ($thecategory, $tmp)) |
---|
119 | array_push($listcategoryParamThemeChangerTmp ,array('id' => $icat['id'], 'Parent' => isset($tmp[0]) ? $tmp[0] : $icat['id'], 'nomGalerie' => $nomGalerie, 'titreGalerie' => $titreGalerie, 'OverWriteHome' => $OverWriteHome, 'applysubcategory' => $applysubcategory)); // ajout pour la gestion du menu categorie |
---|
120 | } |
---|
121 | } |
---|
122 | else |
---|
123 | { |
---|
124 | $icat = get_cat_info($thecategory); |
---|
125 | $tmp = explode("," , $icat['uppercats']); |
---|
126 | array_push($listcategoryParamThemeChangerTmp ,array('id' => $thecategory, 'Parent' => isset($tmp[0]) ? $tmp[0] : $icat['id'], 'nomGalerie' => $nomGalerie, 'titreGalerie' => $titreGalerie, 'OverWriteHome' => $OverWriteHome, 'applysubcategory' => $applysubcategory)); |
---|
127 | } |
---|
128 | $this->listcategoryParamThemeChanger = $listcategoryParamThemeChangerTmp; |
---|
129 | return $this->listcategoryParamThemeChanger; |
---|
130 | } |
---|
131 | } |
---|
132 | |
---|
133 | class c_ThemeChanger { |
---|
134 | |
---|
135 | var $separator = '|'; |
---|
136 | |
---|
137 | var $listcategoryParamThemeChanger ; |
---|
138 | function SetlistcategoryParamThemeChanger($listcategoryParamThemeChanger){ |
---|
139 | $this->listcategoryParamThemeChanger = $listcategoryParamThemeChanger; |
---|
140 | } |
---|
141 | |
---|
142 | var $newconf_nbc_ThemeChanger = ''; |
---|
143 | function Setnewconf_nbc_ThemeChanger($newconf_nbc_ThemeChanger){ |
---|
144 | $this->newconf_nbc_ThemeChanger = $newconf_nbc_ThemeChanger; |
---|
145 | } |
---|
146 | |
---|
147 | |
---|
148 | function Get_newconf_nbc_ThemeChanger() |
---|
149 | { |
---|
150 | if (ISSET($this->newconf_nbc_ThemeChanger)) |
---|
151 | return $this->newconf_nbc_ThemeChanger; |
---|
152 | else return ''; |
---|
153 | } |
---|
154 | |
---|
155 | |
---|
156 | function initThemeChanger ($thecategory, $theme, $nomGalerie, $titreGalerie, $applysubcategory, $OverWriteHome) |
---|
157 | { |
---|
158 | if (ISSET($this->listcategoryParamThemeChanger)) |
---|
159 | return $this->listcategoryParamThemeChanger; |
---|
160 | |
---|
161 | |
---|
162 | $c_ThemeChangerConf = new c_ThemeChangerConfig(); |
---|
163 | $categories = $c_ThemeChangerConf->get_categories(); |
---|
164 | |
---|
165 | $listcategoryParamThemeChangerTmp = array(); |
---|
166 | $newconf_nbc_ThemeChanger = ''; |
---|
167 | |
---|
168 | if ($applysubcategory <> 'false') { |
---|
169 | foreach ($categories as $icat) { |
---|
170 | $tmp = explode("," , $icat['uppercats']); |
---|
171 | if (in_array ($thecategory, $tmp)) |
---|
172 | array_push($listcategoryParamThemeChangerTmp ,array('id' => $icat['id'], 'template' =>$theme[0], 'theme' => $theme[1],'Parent' => isset($tmp[0]) ? $tmp[0] : $icat['id'], 'nomGalerie' => $nomGalerie, 'titreGalerie' => $titreGalerie, 'OverWriteHome' => $OverWriteHome, 'applysubcategory' => $applysubcategory)); // ajout pour la gestion du menu categorie |
---|
173 | } |
---|
174 | } |
---|
175 | else |
---|
176 | { |
---|
177 | $icat = get_cat_info($thecategory); |
---|
178 | $tmp = explode("," , $icat['uppercats']); |
---|
179 | array_push($listcategoryParamThemeChangerTmp ,array('id' => $thecategory, 'template' =>$theme[0], 'theme' => $theme[1], 'Parent' => isset($tmp[0]) ? $tmp[0] : $icat['id'], 'nomGalerie' => $nomGalerie, 'titreGalerie' => $titreGalerie, 'OverWriteHome' => $OverWriteHome, 'applysubcategory' => $applysubcategory)); |
---|
180 | } |
---|
181 | $this->listcategoryParamThemeChanger = $listcategoryParamThemeChangerTmp; |
---|
182 | return $this->listcategoryParamThemeChanger; |
---|
183 | } |
---|
184 | |
---|
185 | function InsertEndAssocConf($id, $tpl, $thm, $cat, $name, $title, $overHome, $appSubCat){ |
---|
186 | if ($this->newconf_nbc_ThemeChanger <> '' and $this->newconf_nbc_ThemeChanger [strlen($this->newconf_nbc_ThemeChanger )-1] <> $this->separator) |
---|
187 | $this->newconf_nbc_ThemeChanger .= $this->separator; |
---|
188 | $this->newconf_nbc_ThemeChanger .= $id.','.$tpl.','.$thm.','.$cat.','.$name.','.$title.','.$overHome.','.$appSubCat; |
---|
189 | return 1; |
---|
190 | } |
---|
191 | |
---|
192 | function AddAssocConf ($conf_nbc_ThemeChanger) { |
---|
193 | foreach ($conf_nbc_ThemeChanger as $Theme_Cat) |
---|
194 | { |
---|
195 | $add_ok = false; |
---|
196 | $element_ThemeChanger = explode("," , $Theme_Cat); |
---|
197 | $i = 0; |
---|
198 | foreach ($this->listcategoryParamThemeChanger as $thecategory) |
---|
199 | { |
---|
200 | if ($element_ThemeChanger[0] == $thecategory['id']) //MAJ de la configuration d'une categorie déjà présente dans la liste |
---|
201 | { |
---|
202 | //echo ' MAJ: '.$element_ThemeChanger[0]; |
---|
203 | $this->InsertEndAssocConf($thecategory['id'],$thecategory['template'],$thecategory['theme'],$thecategory['Parent'],$thecategory['nomGalerie'],$thecategory['titreGalerie'],$thecategory['OverWriteHome'],$thecategory['applysubcategory']); |
---|
204 | $this->listcategoryParamThemeChanger[$i]['id'] = -1; |
---|
205 | $add_ok = true; |
---|
206 | break; |
---|
207 | } |
---|
208 | $i += 1; |
---|
209 | } |
---|
210 | if ($add_ok == false and $element_ThemeChanger[0] <> ''){//récupération des catégories qui n'ont pas été modifié. |
---|
211 | //echo ' Recup : '.$element_ThemeChanger[0]; |
---|
212 | $this->InsertEndAssocConf($element_ThemeChanger[0], $element_ThemeChanger[1], $element_ThemeChanger[2], $element_ThemeChanger[3], $element_ThemeChanger[4], $element_ThemeChanger[5], $element_ThemeChanger[6], $element_ThemeChanger[7]); |
---|
213 | } |
---|
214 | } |
---|
215 | |
---|
216 | foreach ($this->listcategoryParamThemeChanger as $thecategory) {//insertion des nouvelles catégories |
---|
217 | //echo ' Nouveau: '.$thecategory['id']; |
---|
218 | if ($thecategory['id'] <> -1) |
---|
219 | $this->InsertEndAssocConf($thecategory['id'],$thecategory['template'],$thecategory['theme'], $thecategory['Parent'], $thecategory['nomGalerie'], $thecategory['titreGalerie'], $thecategory['OverWriteHome'], $thecategory['applysubcategory']); |
---|
220 | $listcategoryParamThemeChanger[$i]['id'] = -1; |
---|
221 | } |
---|
222 | return 1; |
---|
223 | } |
---|
224 | |
---|
225 | function DeleteAssocConf () { |
---|
226 | |
---|
227 | } |
---|
228 | |
---|
229 | |
---|
230 | } |
---|
231 | |
---|
232 | ?> |
---|