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

Source for file data.articles.php

Documentation is available at data.articles.php

  1. <?php
  2. /**
  3.  * @version  $Revision$
  4.  * @package  liberty
  5.  * @subpackage plugins_data
  6.  */
  7. // +----------------------------------------------------------------------+
  8. // | Copyright (c) 2004, bitweaver.org
  9. // +----------------------------------------------------------------------+
  10. // | All Rights Reserved. See below for details and a complete list of authors.
  11. // | Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See http://www.gnu.org/copyleft/lesser.html for details
  12. // |
  13. // | For comments, please use phpdocu.sourceforge.net documentation standards!!!
  14. // | -> see http://phpdocu.sourceforge.net/
  15. // +----------------------------------------------------------------------+
  16. // | Author (TikiWiki): Gustavo Muslera <gmuslera@users.sourceforge.net>
  17. // | Reworked for Bitweaver (& Undoubtedly Screwed-Up)
  18. // | by: StarRider <starrrider@users.sourceforge.net>
  19. // | Reworked from: wikiplugin_articles.php - see deprecated code below
  20. // +----------------------------------------------------------------------+
  21. // $Id$
  22.  
  23. /**
  24.  * definitions
  25.  */
  26. global $gBitSystem$gBitSmarty;
  27. define'PLUGIN_GUID_DATAARTICLES''dataarticles' );
  28. global $gLibertySystem;
  29. $pluginParams array (
  30.     'tag' => 'ARTICLES',
  31.     'auto_activate' => FALSE,
  32.     'requires_pair' => FALSE,
  33.     'load_function' => 'data_articles',
  34.     'help_function' => 'data_articles_help',
  35.     'title' => 'Articles',
  36.     'help_page' => 'DataPluginArticles',
  37.     'description' => tra"This plugin will display several Articles." ),
  38.     'syntax' => "{ARTICLES max= topic= type= }",
  39.     'plugin_type' => DATA_PLUGIN
  40. );
  41. $gLibertySystem->registerPluginPLUGIN_GUID_DATAARTICLES$pluginParams );
  42. $gLibertySystem->registerDataTag$pluginParams['tag']PLUGIN_GUID_DATAARTICLES );
  43.  
  44. // Help Routine
  45. function data_articles_help()
  46. {
  47.     $help =
  48.         '<table class="data help">'
  49.             .'<tr>'
  50.                 .'<th>' tra"Key" '</th>'
  51.                 .'<th>' tra"Type" '</th>'
  52.                 .'<th>' tra"Comments" '</th>'
  53.             .'</tr>'
  54.             .'<tr class="odd">'
  55.                 .'<td>max</td>'
  56.                 .'<td>' tra"numeric"'<br />' tra("(optional)"'</td>'
  57.                 .'<td>' tra"The number of Articles to be displayed. (Default = 3)"'</td>'
  58.             .'</tr>'
  59.             .'<tr class="even">'
  60.                 .'<td>topic</td>'
  61.                 .'<td>' tra"topic name"'<br />' tra("(optional)"'</td>'
  62.                 .'<td>' tra"Filters the Articles so that only the Topic specified is displayed"'</td>'
  63.             .'</tr>'
  64.             .'<tr class="odd">'
  65.                 .'<td>type</td>'
  66.                 .'<td>' tra"type name"'<br />' tra("(optional)"'</td>'
  67.                 .'<td>' tra"Filters the Articles so that only the Type specified is displayed"'</td>'
  68.             .'</tr>'
  69.             .'<tr class="even">'
  70.                 .'<td>format</td>'
  71.                 .'<td>' tra"string"'<br />' tra("(optional)"'</td>'
  72.                 .'<td>' tra"Specify format for article display - options: full, list (default)"'</td>'
  73.             .'</tr>'
  74.         .'</table>'
  75.         . tra("Example: ""{ARTICLES max=5 topic='some_topic'}<br />"
  76.         . tra("Example: ""{ARTICLES max=5 type='some_type'}";
  77.     return $help;
  78. }
  79.  
  80. // Executable Routine
  81. function data_articles($data$params// No change in the parameters with Clyde
  82.     global $gLibertySystem$gBitSmarty$gBitSystem;
  83.     if$gBitSystem->isPackageActive'articles' ) ) // Do not include this Plugin if the Package is not active
  84.         // The next 2 lines allow access to the $pluginParams given above and may be removed when no longer needed
  85.         $pluginParams $gLibertySystem->mPlugins[PLUGIN_GUID_DATAARTICLES];
  86.  
  87.         require_onceARTICLES_PKG_PATH.'BitArticle.php');
  88.         require_onceLIBERTY_PKG_PATH.'lookup_content_inc.php' );
  89.  
  90.         $module_params $params;
  91.         $articlesObject new BitArticle();
  92.         $stati array'pending''approved' );
  93.         if!empty$module_params['status'&& in_array$module_params['status']$stati ) ) {
  94.             $status_id constant'ARTICLE_STATUS_'.strtoupper$module_params['status') );
  95.         else {
  96.             $status_id ARTICLE_STATUS_APPROVED;
  97.         }
  98.  
  99.         $sortOptions array(
  100.             "last_modified_asc",
  101.             "last_modified_desc",
  102.             "created_asc",
  103.             "created_desc",
  104.             "random",
  105.         );
  106.         if!empty$module_params['sort_mode'&& in_array$module_params['sort_mode']$sortOptions ) ) {
  107.             $sort_mode $module_params['sort_mode'];
  108.         else {
  109.             $sort_mode 'last_modified_desc';
  110.         }
  111.  
  112.         $getHash Array();
  113.         $getHash['status_id']     $status_id;
  114.         $getHash['sort_mode']     $sort_mode;
  115.         $getHash['max_records']   empty$module_params['max'$module_params['max'];
  116.         ifisset$module_params['topic')) {
  117.             $getHash['topic']     !empty$module_params['topic'$module_params['topic'NULL;
  118.         }
  119.         ifisset$module_params['topic_id')) {
  120.             $getHash['topic_id']  $module_params['topic_id'];
  121.         }
  122.         $articles_results $articlesObject->getList$getHash );
  123.  
  124.         $display_format empty$module_params['format''simple_title_list' $module_params['format'];
  125.         $display_result "";
  126.  
  127.         switch$display_format {
  128.             case 'full':
  129.                 $display_result '<div class="articles">';
  130.                 $gBitSmarty->assign'showDescriptionsOnly'TRUE );
  131.                 foreach$articles_results as $article {
  132.                     $gBitSmarty->assign'article'$article );
  133.                     $gBitSmarty->assign'gContent'$articlesObject );
  134.                     $display_result .= $gBitSmarty->fetch'bitpackage:articles/article_display.tpl' );
  135.                 }
  136.                 $display_result .= '</div>';
  137.                 $display_result eregi_replace"\n"""$display_result );
  138.                 break;
  139.             case 'list':
  140.             default:
  141.                 $display_result "<ul>";
  142.                 foreach$articles_results as $article {
  143.                     $link $articlesObject->getdisplaylink$article['title']$article );
  144.                     $display_result .= "<li>$link</li>\n";
  145.                 }
  146.                 $display_result .= "</ul>\n";
  147.                 break;
  148.         }
  149.         return $display_result;
  150.     else {
  151.         return "<div class=error>The articles package is not active.</div>";
  152.     }
  153. }

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