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

Source for file data.blog.php

Documentation is available at data.blog.php

  1. <?php
  2. /**
  3.  * @version  $Revision$
  4.  * @package  liberty
  5.  * @subpackage plugins_data
  6.  */
  7. // +----------------------------------------------------------------------+
  8. // | Copyright (c) 2005, 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: wjames5
  19. // | Reworked from: data.articles.php from wikiplugin_articles.php
  20. // +----------------------------------------------------------------------+
  21. // $Id$
  22.  
  23. /**
  24.  * definitions
  25.  */
  26. global $gBitSystem$gBitSmarty;
  27. //it seems this is loaded before the package is activated.
  28. //if( $gBitSystem->isPackageActive( 'blogs' ) ) { // Do not include this Plugin if the Package is not active
  29. define'PLUGIN_GUID_DATABLOG''datablog' );
  30. global $gLibertySystem;
  31. $pluginParams array (
  32.     'tag' => 'BLOG',
  33.     'auto_activate' => FALSE,
  34.     'requires_pair' => FALSE,
  35.     'load_function' => 'data_blog',
  36.     'help_function' => 'data_blog_help',
  37.     'title' => 'Blog',
  38.     'help_page' => 'DataPluginBlog',
  39.     'description' => tra"This plugin will display several posts from a blog." ),
  40.     'syntax' => "{BLOG id= user= max= format= }",
  41.     'plugin_type' => DATA_PLUGIN
  42. );
  43. $gLibertySystem->registerPluginPLUGIN_GUID_DATABLOG$pluginParams );
  44. $gLibertySystem->registerDataTag$pluginParams['tag']PLUGIN_GUID_DATABLOG );
  45.  
  46. // Help Routine
  47. function data_blog_help({
  48.     $help =
  49.         '<table class="data help">'
  50.             .'<tr>'
  51.                 .'<th>' tra"Key" '</th>'
  52.                 .'<th>' tra"Type" '</th>'
  53.                 .'<th>' tra"Comments" '</th>'
  54.             .'</tr>'
  55.             .'<tr class="even">'
  56.                 .'<td>id</td>'
  57.                 .'<td>' tra"numeric"'<br />' tra("(optional)"'</td>'
  58.                 .'<td>' tra"Filters for the specified Blog by id"'</td>'
  59.             .'</tr>'
  60.             .'<tr class="odd">'
  61.                 .'<td>user</td>'
  62.                 .'<td>' tra"string"'<br />' tra("(optional)"'</td>'
  63.                 .'<td>' tra"The login name of the user who's posts are to be displayed. (Default = 3)"'</td>'
  64.             .'</tr>'
  65.             .'<tr class="even">'
  66.                 .'<td>max</td>'
  67.                 .'<td>' tra"numeric"'<br />' tra("(optional)"'</td>'
  68.                 .'<td>' tra"The number of posts to be displayed. (Default = 3)"'</td>'
  69.             .'</tr>'
  70.             .'<tr class="odd">'
  71.                 .'<td>format</td>'
  72.                 .'<td>' tra"string"'<br />' tra("(optional)"'</td>'
  73.                 .'<td>' tra"Specify format for posts display - options: full, list (default)"'</td>'
  74.             .'</tr>'
  75.         .'</table>'
  76.         . tra("Example: ""{BLOG id=2 max=5 format='full'}<br />"
  77.         . tra("Example: ""{BLOG id=5 format='list'}";
  78.     return $help;
  79. }
  80.  
  81. // Executable Routine
  82. function data_blog($data$params// No change in the parameters with Clyde
  83.     global $gLibertySystem$gBitSmarty$gBitSystem$gBitUser;
  84.     $display_result "";
  85.  
  86.     if ($gBitSystem->isPackageActive('blogs'&& $gBitUser->hasPermission'p_blogs_view')) {
  87.     // The next 2 lines allow access to the $pluginParams given above and may be removed when no longer needed
  88.         $pluginParams $gLibertySystem->mPlugins[PLUGIN_GUID_DATABLOG];
  89.         
  90.         require_onceBLOGS_PKG_PATH.'BitBlog.php');
  91.         require_onceLIBERTY_PKG_PATH.'lookup_content_inc.php' );
  92.         
  93.         $module_params $params;
  94.         
  95.         if (isset($module_params['id'])) {
  96.             $gBitSmarty->assign('blog_id'$module_params['id']);
  97.         }
  98.         
  99.         $blogPost new BitBlogPost();
  100.         
  101.         $sortOptions array(
  102.                              "publish_date_desc",
  103.                              "publish_date_asc",
  104.                              "last_modified_asc",
  105.                              "last_modified_desc",
  106.                              "created_asc",
  107.                              "created_desc",
  108.                              "random",
  109.                              );
  110.         if!empty$module_params['sort_mode'&& in_array$module_params['sort_mode']$sortOptions ) ) {
  111.             $sort_mode $module_params['sort_mode'];
  112.         else {
  113.             $sort_mode 'publish_date_desc';
  114.         }
  115.         
  116.         $getHash Array();
  117.         
  118.         if isset($module_params['user']) )$getHash['user'$module_params['user']}
  119.         if isset($module_params['id']) )$getHash['blog_id'$module_params['id'];}
  120.         if isset($module_params['group_id']) )$getHash['group_id'$module_params['group_id'];}
  121.         if isset($module_params['role_id']) )$getHash['role_id'$module_params['role_id'];}
  122.         
  123.         // handle draft posts
  124.         $getHash['enforce_status'TRUE;
  125.         // @TODO enable lists that include draft posts
  126.         // the current tpl configuration doesnt allow us to support draft lists right now
  127.         // there is an object reference problem in liberty::service_content_body_inc.tpl
  128.         // if the object reference problem in the above mentions tpl is patched then use this if to enable drafts
  129.         // if ( !empty( $module_params['status'] ) && $module_params['status'] = "draft" && isset( $gBitUser->mUserId ) ){
  130.         if FALSE ){
  131.             // if we are getting drafts then get future posts too 
  132.             $getHash['show_future'TRUE;
  133.             $getHash['min_status_id'= -6;
  134.             $getHash['max_status_id'= -4;
  135.             $getHash['min_owner_status_id'= -6;
  136.             // limit by user
  137.             $getHash['user_id'$gBitUser->mUserId;
  138.         }else{
  139.             $getHash['min_owner_status_id'0;
  140.         }
  141.  
  142.         $getHash['sort_mode']   $sort_mode;
  143.         $getHash['parse_data'TRUE;
  144.         $getHash['max_records'empty($module_params['max']$module_params['max'];
  145.         $getHash['load_num_comments'TRUE;
  146.         $getHash['page'(!empty($module_params['page']$module_params['page'1);
  147.         $getHash['offset'(!empty($module_params['offset']$module_params['offset'0);
  148.         $blogPosts $blogPost->getList$getHash );
  149.         
  150.         $display_format empty($module_params['format']'simple_title_list' $module_params['format'];
  151.         
  152.         switch$display_format {
  153.             case 'full':
  154.                 $display_result '<div class="blogs">';                
  155.                 if $gBitSystem->isPackageActive'rss' ) ){
  156.                     if isset($module_params['user']) ){
  157.                         $rssUser new BitUser();
  158.                         $rssUser->load(false$module_params['user']);
  159.                         $rssUserId $rssUser->getField('user_id');
  160.                     }
  161.                     $rssPath BLOGS_PKG_URL.'blogs_rss.php?'
  162.                         .isset($module_params['id']'blog_id='.$module_params['id'"" )
  163.                         .( (isset($module_params['id']&& isset($rssUserId))"&""")
  164.                         .isset($rssUserId'user_id='.$rssUserId "" )
  165.                         .( (isset($rssUserId&& isset($module_params['group_id']))"&""")
  166.                         .isset($module_params['group_id']'group_id='.$module_params['group_id'"" )
  167.                         .( (isset($rssUserId&& isset($module_params['role_id']))"&""")
  168.                         .isset($module_params['role_id']'role_id='.$module_params['role_id'"" );
  169.                     // something like this would be better, calling smarty directly so translation can also be called -wjames5
  170.                     // $rssIcon = smarty_function_biticon( array('ipackage'=>"rss", 'iname'="rss-16x16", 'iexplain'=>"RSS feed"), &$gBitSmarty );
  171.                     $display_result .= '<div class="floaticon"><a title="RSS feed" href="'.$rssPath.'"><img src="'.BIT_ROOT_URL.'rss/icons/rss-16x16.png" alt="RSS feed" title="RSS feed" class="icon" /></a></div>';
  172.                 }
  173.  
  174.                 $gBitSmarty->assign'showDescriptionsOnly'TRUE );
  175.                 
  176.                 foreach$blogPosts['data'as $aPost {
  177.                     $gBitSmarty->assign('aPost'$aPost);
  178.                     $display_result .= $gBitSmarty->fetch'bitpackage:blogs/blog_list_post.tpl' );
  179.                 }
  180.  
  181.                 $display_result .= '</div>';
  182.                 $display_result eregi_replace"\n"""$display_result );
  183.                 break;
  184.             case 'list':
  185.             default:
  186.                 $display_result "<ul>";
  187.                 foreach$blogPosts['data'as $post {
  188.                     $link $blogPost->getDisplayLink$post['title']$post );
  189.                     $display_result .= "<li>$link</li>\n";
  190.                 }
  191.                 $display_result .= "</ul>\n";
  192.                 break;
  193.         }
  194.     }
  195.     else {
  196.         $display_result '<div class=error>'.tra('Blogs Package Deactivated.')'</div>';
  197.     }
  198.     return $display_result;
  199. }
  200. //}
  201. ?>

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