72 $this->CachedMultyFS =
get_package(
'cached_multy_fs' ,
'last' , __FILE__ );
73 $this->ContentAccess =
get_package(
'content::content_access' ,
'last' , __FILE__ );
74 $this->ContentAlgorithms =
get_package(
'content::content_algorithms' ,
'last' , __FILE__ );
75 $this->PageMeta =
get_package(
'page::page_meta' ,
'last' , __FILE__ );
76 $this->Security =
get_package(
'security' ,
'last' , __FILE__ );
77 $this->Settings =
get_package(
'settings::package_settings' ,
'last' , __FILE__ );
78 $this->String =
get_package(
'string' ,
'last' , __FILE__ );
109 $PageCSS =
get_package(
'page::page_css' ,
'last' , __FILE__ );
110 $PageCSS->add_stylesheet(
"{http_host}/$PackagePath/res/css/content.css" );
112 catch( Exception $e )
140 private function get_category_names( &$Options )
144 if( $Options->get_setting(
'category_name' ,
false ) )
146 $CategoryNames = $Options->get_setting(
'category_name' );
150 $CategoryNames = $this->Settings->get_package_setting(
'content::content_view' ,
'last' ,
151 'cf_content_view_conf' ,
'content_line_categories' ,
'news,article' );
154 return( $CategoryNames );
156 catch( Exception $e )
208 $Category =
get_package(
'category::category_algorithms' ,
'last' , __FILE__ );
210 $CategoryNames = $this->get_category_names( $Options );
212 $CategoryIds = $Category->get_category_ids( $CategoryNames );
215 $this->ContentAccess->select(
216 $Start , $Options->get_setting(
'display_limit' , $Limit ) , $Field , $Order ,
217 "( $Condition ) AND category IN ( ".implode(
' , ' , $CategoryIds ).
' )'
221 catch( Exception $e )
253 private function get_months( &$PublicationStructure , $Year )
261 $PublicationStructure ,
262 create_function(
"\$d" ,
"return( \$d->publication_year == $Year );" )
269 catch( Exception $e )
305 private function get_month_template( &$PublicationStructure , $Year , $Month )
309 $MonthTemplate = $this->CachedMultyFS->get_template( __FILE__ ,
'archive_month.tpl' );
311 $MonthTemplate = $this->String->print_record(
314 $PublicationStructure ,
316 "\$d" ,
"return( \$d->publication_year == $Year && \$d->publication_month == $Month );"
321 return( $MonthTemplate );
323 catch( Exception $e )
363 private function compile_month_content( $Year , $Month , $MonthTemplate , $CategoryIds )
367 if( $this->Security->get_gp(
'month' ,
'integer' , date(
'm' ) ) == $Month )
369 $Content = $this->ContentAccess->get_content_for_date( $Year , $Month , $CategoryIds );
371 foreach( $Content as $c )
373 $ContentTemplate = $this->CachedMultyFS->get_template(
374 __FILE__ ,
'archive_content.tpl'
376 $ContentTemplate = $this->String->print_record( $ContentTemplate , $c );
377 $MonthTemplate = str_replace(
378 '{content_data}' , $ContentTemplate.
'{content_data}' , $MonthTemplate
383 return( $MonthTemplate );
385 catch( Exception $e )
425 private function compile_year_content( $Year , $YearTemplate , $CategoryIds , $PublicationStructure )
429 if( $this->Security->get_gp(
'year' ,
'integer' , date(
'Y' ) ) == $Year )
431 $Months = $this->get_months( $PublicationStructure , $Year );
433 foreach( $Months as $Month )
435 $MonthTemplate = $this->get_month_template( $PublicationStructure , $Year , $Month );
437 $MonthTemplate = $this->compile_month_content( $Year , $Month , $MonthTemplate , $CategoryIds );
439 $MonthTemplate = str_replace(
'{content_data}' ,
'' , $MonthTemplate );
440 $YearTemplate = str_replace(
441 '{month_data}' , $MonthTemplate.
'{month_data}' , $YearTemplate
446 return( $YearTemplate );
448 catch( Exception $e )
480 private function compile_years( $PublicationStructure , $Years , $CategoryIds )
484 foreach( $Years as $Year )
486 $YearTemplate = $this->CachedMultyFS->get_template( __FILE__ ,
'archive_year.tpl' );
487 $YearTemplate = str_replace(
'{publication_year}' , $Year , $YearTemplate );
489 $YearTemplate = $this->compile_year_content(
490 $Year , $YearTemplate , $CategoryIds , $PublicationStructure
493 $YearTemplate = str_replace(
'{month_data}' ,
'' , $YearTemplate );
495 $this->Output .= $YearTemplate;
498 catch( Exception $e )
526 $CategoryAccess =
get_package(
'category::category_algorithms' ,
'last' , __FILE__ );
527 $CategoryIds = $CategoryAccess->get_category_ids(
528 $Options->get_setting(
'category' ,
'news,article,faq,blog' )
531 $PublicationStructure = $this->ContentAccess->get_publication_structure( $CategoryIds );
533 $Years = array_unique(
get_field_ex( $PublicationStructure ,
'publication_year' ) );
535 $this->compile_years( $PublicationStructure , $Years , $CategoryIds );
537 catch( Exception $e )
569 $Content = $this->ContentAlgorithms->get_by_id( $ContentId );
570 $Template = $this->CachedMultyFS->get_template( __FILE__ ,
'content_view_template.tpl' );
571 $Output = $this->String->print_record( $Template , $Content );
573 $this->PageMeta->set_page_title(
get_field( $Content ,
'title' ) );
574 $this->PageMeta->add_page_keywords(
get_field( $Content ,
'keywords' ) );
575 $this->PageMeta->add_page_description(
get_field( $Content ,
'description' ) );
579 catch( Exception $e )
607 if( ( $ContentId = $this->Security->get_gp(
'content_id' ,
'integer' ,
false ) ) ===
false )
609 $this->Output =
'{lang:exact_content_was_not_found}';
615 catch( Exception $e )
649 $Path = dirname( __FILE__ );
651 $ContextSet->add_context(
"$Path/conf/cfcxs_content_line" );
653 $ContextSet->add_context(
"$Path/conf/cfcxs_content_view" );
655 $ContextSet->add_context(
"$Path/conf/cfcxs_content_archive" );
657 $ContextSet->execute( $Options , $this , __FILE__ );
659 return( $this->Output );
661 catch( Exception $e )