ultimix

- Main Page
- Data Structures
- Files
- Examples

- File List
- Globals

category_markup.php
Go to the documentation of this file.
1 <?php
2
3 /*
4 * This source code is a part of the Ultimix Project.
5 * It is distributed under BSD license. All other third side source code (like tinyMCE) is distributed under
6 * it's own license wich could be found from the corresponding files or sources.
7 * This source code is provided "as is" without any warranties or garanties.
8 *
9 * Have a nice day!
10 *
11 * @url http://ultimix.sorceforge.net
12 *
13 * @author Alexey "gdever" Dodonov
14 */
15
26 class category_markup_1_0_0{
27
38 var $CachedMultyFS = false;
39 var $CategoryAccess = false;
40 var $CategoryAlgorithms = false;
41 var $CategoryView = false;
42 var $String = false;
43
54 function __construct()
55 {
56 try
57 {
58 $this->CachedMultyFS = get_package( 'cached_multy_fs' , 'last' , __FILE__ );
59 $this->CategoryAccess = get_package( 'category::category_access' , 'last' , __FILE__ );
60 $this->CategoryAlgorithms = get_package( 'category::category_algorithms' , 'last' , __FILE__ );
61 $this->CategoryView = get_package( 'category::category_view' , 'last' , __FILE__ );
62 $this->String = get_package( 'string' , 'last' , __FILE__ );
63 }
64 catch( Exception $e )
65 {
66 $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
67 }
68 }
69
92 private function get_null_category( &$Settings )
93 {
94 try
95 {
96 $NullCategory = '';
97
98 if( $Settings->get_setting( 'null_category' , false ) !== false )
99 {
100 $Id = $Settings->get_setting( 'null_category' );
101
102 $Title = $Settings->get_setting( 'null_category_title' , '' );
103
104 $NullCategory = "SELECT $Id AS id , '{lang:$Title}' AS value UNION ";
105 }
106
107 return( $NullCategory );
108 }
109 catch( Exception $e )
110 {
111 $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
112 }
113 }
114
137 function compile_category( &$Settings )
138 {
139 try
140 {
141 list( $Name , $Default , $Class ) = $Settings->get_settings(
142 'name,default,class' , 'category,0,width_160 flat'
143 );
144
145 $Default = $Default == 0 ? '' : "default=$Default;";
146 $NullCategory = $this->get_null_category( $Settings );
147 $Id = $this->CategoryView->get_category_id( $Settings );
148 $Value = $Settings->get_setting( 'value' , false );
149
150 $Code = "{select:$Default"."class=$Class;name=$Name;query=$NullCategory SELECT id , title as ".
151 "`value` FROM umx_category WHERE direct_category![eq]id AND direct_category IN ( $Id )".
152 ( $Value ? ";value=$Value" : '' )."}";
153
154 return( $Code );
155 }
156 catch( Exception $e )
157 {
158 $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
159 }
160 }
161
184 function compile_category_id( &$Settings )
185 {
186 try
187 {
188 $Names = $Settings->get_setting( 'names' , '' );
189
190 $Names = $Settings->get_setting( 'name' , $Names );
191
192 $Ids = implode( ',' , $this->CategoryAlgorithms->get_category_ids( $Names ) );
193
194 return( $Ids );
195 }
196 catch( Exception $e )
197 {
198 $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
199 }
200 }
201
224 function compile_category_siblings_ids( &$Settings )
225 {
226 try
227 {
228 $CategoryId = $Settings->get_setting( 'id' );
229
230 $SiblingsIds = implode( ',' , $this->CategoryAccess->get_siblings_ids( $CategoryId ) );
231
232 return( $SiblingsIds );
233 }
234 catch( Exception $e )
235 {
236 $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
237 }
238 }
239
262 function compile_category_name( &$Settings )
263 {
264 try
265 {
266 $Category = $this->CategoryAlgorithms->get_by_id( $Settings->get_setting( 'id' ) );
267
268 $Title = get_field( $Category , 'title' );
269
270 return( $Title );
271 }
272 catch( Exception $e )
273 {
274 $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
275 }
276 }
277 }
278 ?>