articles
[ class tree: articles ] [ index: articles ] [ all elements ]

Source for file mod_articles.php

Documentation is available at mod_articles.php

  1. <?php
  2. /**
  3.  * @version $Header$
  4.  * @package articles
  5.  * @subpackage modules
  6.  */
  7.  
  8. /**
  9.  * Initialization
  10.  */
  11. include_once( ARTICLES_PKG_PATH.'BitArticle.php' );
  12.  
  13. extract( $moduleParams );
  14.  
  15. $articles = new BitArticle();
  16. $stati = array( 'pending', 'approved' );
  17. if( !empty( $module_params['status'] ) && in_array( $module_params['status'], $stati ) ) {
  18.     $status_id = constant( 'ARTICLE_STATUS_'.strtoupper( $module_params['status'] ) );
  19. } else {
  20.     $status_id = ARTICLE_STATUS_APPROVED;
  21. }
  22.  
  23. $sortOptions = array(
  24.     "last_modified_asc",
  25.     "last_modified_desc",
  26.     "created_asc",
  27.     "created_desc",
  28.     "publish_date_desc",
  29.     "publish_date_asc",
  30.     "expire_date_desc",
  31.     "expire_date_asc",
  32. );
  33. if( !empty( $module_params['sort_mode'] ) && in_array( $module_params['sort_mode'], $sortOptions ) ) {
  34.     $sort_mode = $module_params['sort_mode'];
  35. } else {
  36.     $sort_mode = 'last_modified_desc';
  37. }
  38.  
  39. $getHash['status_id']     = $status_id;
  40. $getHash['sort_mode']     = $sort_mode;
  41. $getHash['max_records']   = !empty( $module_rows ) ? $module_rows : $gBitSystem->getConfig( 'articles_max_list' );
  42. $getHash['topic_name']    = !empty( $module_params['topic_name'] ) ? $module_params['topic_name'] : NULL;
  43. $getHash['topic_id']      = !empty( $module_params['topic_id'] ) ? $module_params['topic_id'] : NULL;
  44. $articlelist = $articles->getList( $getHash );
  45.  
  46. if( ( !empty( $module_params['topic_id'] ) || !empty( $module_params['topic_name'] ) ) && empty($moduleParams['title']) && !empty( $articles ) ) {
  47.     $_template->tpl_vars['moduleTitle'] = new Smarty_variable( $articles[0]['topic_name'] );
  48. } elseif( !empty($moduleParams['title']) ) {
  49.     $_template->tpl_vars['moduleTitle'] = new Smarty_variable( $moduleParams['title'] );
  50. } else {
  51.     $_template->tpl_vars['moduleTitle'] = new Smarty_variable( "Articles" );
  52. }
  53.  
  54. $_template->tpl_vars['params'] = new Smarty_variable( !empty( $moduleParams['params'] ) );
  55. $_template->tpl_vars['listtype'] = new Smarty_variable(  ( isset($module_params['list_type']) && (strncasecmp($module_params['list_type'], 'u', 1) == 0) ) ? 'ul' : 'ol' );
  56. $_template->tpl_vars['modArticles'] = new Smarty_variable( $articlelist );

Documentation generated on Wed, 29 Jul 2015 13:57:10 +0000 by phpDocumentor 1.5.0-lsces