60 $this->CachedMultyFS =
get_package(
'cached_multy_fs' ,
'last' , __FILE__ );
61 $this->CategoryAccess =
get_package(
'category::category_access' ,
'last' , __FILE__ );
62 $this->CategoryAlgorithms =
get_package(
'category::category_algorithms' ,
'last' , __FILE__ );
63 $this->CategoryView =
get_package(
'category::category_view' ,
'last' , __FILE__ );
64 $this->String =
get_package(
'string' ,
'last' , __FILE__ );
100 return( $this->CategoryVie->Output );
102 catch( Exception $e )
136 $Template = $this->CachedMultyFS->get_template( __FILE__ ,
'categories_list_type_list.tpl' );
138 $TitleTemplate = $this->CachedMultyFS->get_template( __FILE__ ,
'title_item.tpl' );
140 return( str_replace(
'{titles}' , implode( $TitleTemplate , $Titles ) , $Template ) );
142 catch( Exception $e )
174 private function compile_active_list_code( &$AllCategories , &$Categories )
181 foreach( $AllCategories as $i => $Category )
184 $Title =
get_field( $Category ,
'title' );
186 $Checked =
in_array( $id , $ids ) ?
'on' :
'off';
188 $Code .= $this->CachedMultyFS->get_template( __FILE__ ,
'category_active_list.tpl' );
189 $PlaceHolders = array(
'{id}' ,
'{checked}' ,
'{title}' );
191 $Code = str_replace( $PlaceHolders , array( $id , $Checked , $Title ) , $Code );
194 catch( Exception $e )
235 $MasterId , $MasterType )
239 $Code = $this->compile_active_list_code( $AllCategories , $Categories );
241 $ActiveListTemplate = $this->CachedMultyFS->get_template( __FILE__ ,
'active_list.tpl' );
243 $PlaceHolders = array(
'{code}' ,
'{master_id}' ,
'{master_type}' );
245 return( str_replace( $PlaceHolders , array( $Code , $MasterId , $MasterType ) , $ActiveListTemplate ) );
247 catch( Exception $e )
283 private function redefine_type( $MasterId , $MasterType , $Type )
287 if( $this->OwnershipAccess->owner_was_registered( $MasterId , $MasterType ) === false )
294 catch( Exception $e )
326 private function categories_list( &$AllCategories , $Type )
330 list( $MasterId , $MasterType ) = $this->BlockSettings->get_settings(
'master_id,master_type' );
332 $Type = $this->redefine_type( $MasterId , $MasterType , $Type );
334 $Categories = $this->CategoryAlgorithms->get_object_categories( $MasterId , $MasterType );
339 case(
'active_list' ):
341 $AllCategories , $Categories , $MasterId , $MasterType );
343 default:
return(
'{lang:illegal_list_type}' );
346 catch( Exception $e )
381 if( $Type ==
'checkbox_list' )
383 $ids = implode(
' , ' , $this->CategoryAlgorithms->get_category_ids( $CategoryName ) );
384 $Code =
"{checkboxset:cols=1;query=SELECT id , title FROM umx_category WHERE ".
385 "direct_category IN ( $ids ) AND id <> direct_category;checked_all=1}";
389 $AllCategories = $this->CategoryAccess->get_children_by_name( $CategoryName );
390 $Code = $this->categories_list( $AllCategories , $Type );
395 catch( Exception $e )
427 private function get_dialog_parameters( &
$BlockSettings , $CategoryName )
431 $CategoryId = $this->CategoryAccess->get_category_id( $CategoryName );
433 $id =
$BlockSettings->get_setting(
'id' ,
"select_category_from_tree_$CategoryId" );
439 "{record_field:access_package_name=category::category_algorithms;field=title;id=$Value}"
442 return( array( $id , $Value , $VisibleValue ) );
444 catch( Exception $e )
478 $Title =
$BlockSettings->get_setting(
'title' ,
'category_selection' );
479 $Class =
$BlockSettings->get_setting(
'class' ,
'width_160 flat' );
481 list( $id , $Value , $VisibleValue ) = $this->get_dialog_parameters(
$BlockSettings , $CategoryName );
485 'category_name' => $CategoryName ,
'name' => $Name ,
'title' => $Title ,
486 'class' => $Class ,
'value' => $Value ,
'visible_value' => $VisibleValue ,
'id' => $id
490 catch( Exception $e )
524 $Code = $this->CachedMultyFS->get_template( __FILE__ ,
'select_category_from_tree.tpl' );
526 $Code = $this->String->print_record( $Code , $Data );
530 catch( Exception $e )