phpDocumentor pond
[ class tree: pond ] [ index: pond ] [ all elements ]

Source for file dashboard.ctrl.php

Documentation is available at dashboard.ctrl.php

  1. <?php
  2. /**
  3.  * This file implements the UI controller for the dashboard.
  4.  *
  5.  * Quam Plures - {@link http://quamplures.net/}
  6.  * Released under GNU GPL License - {@link http://quamplures.net/license.html}
  7.  *
  8.  * @copyright (c) 2009 - 2011 by the Quam Plures developers - {@link http://quamplures.net/}
  9.  * @copyright (c)2003-2007 by Francois PLANQUE - {@link http://fplanque.net/}
  10.  *
  11.  *  {@internal Open Source relicensing agreement:
  12.  *  }}}
  13.  *
  14.  *  {@internal Below is a list of authors who have contributed to design/coding of this file: }}
  15.  * @author fplanque: Francois PLANQUE.
  16.  *
  17.  * @todo add 5 plugin hooks. Will be widgetized later (same as TemplateTag became Widgets)
  18.  *
  19.  * @package pond
  20.  */
  21. if!defined('QP_MAIN_INIT') ) die'Please, do not access this page directly.' );
  22.  
  23. /**
  24.  * @var User 
  25.  */
  26. global $current_User;
  27.  
  28. global $dispatcher;
  29.  
  30. global $dash_disp_num;
  31.  
  32. if$blog )
  33. {
  34.     if$current_User->check_perm'blog_ismember'1false$blog ) )
  35.     {    // We don't have permission for the requested blog (may happen if we come to admin from a link on a different blog)
  36.         set_working_blog);
  37.         unset$Blog );
  38.     }
  39. }
  40.  
  41. $AdminUI->set_coll_list_params'blog_ismember''view'array()T_('Global')'?blog=0' );
  42.  
  43. $AdminUI->set_path'dashboard' );
  44.  
  45.  
  46. // Display <html><head>...</head> section! (Note: should be done early if actions do not redirect)
  47. $AdminUI->disp_html_head();
  48.  
  49. // Display title, menu, messages, etc. (Note: messages MUST be displayed AFTER the actions)
  50. $AdminUI->disp_body_top();
  51.  
  52.  
  53.  
  54. if$blog )
  55. {    // We want to look at a specific blog:
  56.     // Begin payload block:
  57.     $AdminUI->disp_payload_begin();
  58.  
  59.     echo '<h2>'.$Blog->dget'name' ).'</h2>';
  60.  
  61.     echo '<table class="browse" cellspacing="0" cellpadding="0" border="0"><tr><td>';
  62.  
  63.     load_class('items/model/_itemlist.class.php');
  64.  
  65.     $block_item_Widget new Widget'block_item' );
  66.  
  67.     $nb_blocks_displayed 0;
  68.  
  69.     /*
  70.      * COMMENTS:
  71.      */
  72.     $CommentList new CommentList$Blog"'comment','trackback'"array'draft' )'',    '',    'DESC',    '',    $dash_disp_num );
  73.  
  74.     if$CommentList->result_num_rows )
  75.     {    // We have drafts
  76.  
  77.         $nb_blocks_displayed++;
  78.  
  79.         $block_item_Widget->title get_manual_link'comments-awaiting-moderation' ).T_('Comments awaiting moderation');
  80.         $block_item_Widget->disp_template_replaced'block_start' );
  81.  
  82.     /**
  83.          * @var Comment 
  84.          */
  85.         while$Comment $CommentList->get_next() )
  86.         // Loop through comments:
  87.  
  88.             echo '<div class="dashboard_post">';
  89.             echo '<h3 class="dashboard_post_title">';
  90.             echo $Comment->get_title(array('author_format'=>'<strong>%s</strong>'));
  91.             $comment_Item $Comment->get_Item();
  92.             echo ' '.T_('in response to')
  93.                     .' <a href="?ctrl=items&amp;blog='.$comment_Item->get_blog_ID().'&amp;p='.$comment_Item->ID.'"><strong>'.$comment_Item->dget('title').'</strong></a>';
  94.  
  95.             echo '</h3>';
  96.  
  97.             echo '<div class="notes">';
  98.             // display a comment's rating
  99.             $Comment->ratingarray(
  100.                 'before' => '',
  101.                 'after' => ' &bull; ',
  102.                 'star_class' => 'top',
  103.             ) );
  104.  
  105.             // display the comment's date
  106.             $Comment->datearray() );
  107.  
  108.             // display a link to comment author's URL
  109.             if$Comment->author_urlarray(
  110.                 'before' => ' &bull; Url: <span class="bUrl">',
  111.                 'after' => '</span>',
  112.             ) ) )
  113.             {
  114.                 if$current_User->check_perm'spamblacklist''edit' ) )
  115.                 // There is an URL and we have permission to ban...
  116.                     // TODO: really ban the base domain! - not by keyword
  117.                     echo ' <a href="'.$dispatcher.'?ctrl=antispam&amp;action=ban&amp;keyword='.rawurlencode(get_ban_domain($Comment->author_url))
  118.                         .'&amp;aspm_source=reported">'.get_icon'ban' ).'</a> ';
  119.                 }
  120.             }
  121.             // display mailto link to comment author's email
  122.             $Comment->author_emailarray(
  123.                 'before' => ' &bull; Email: <span class="bEmail">',
  124.                 'after' => '</span> &bull; ',
  125.             ) );
  126.             // display comment author's IP address
  127.             $Comment->author_iparray(
  128.                 'before' => 'IP: <span class="bIP">',
  129.                 'after' => '</span> &bull; ',
  130.             ) );
  131.             $Comment->spam_karmaT_('Spam Karma').': %s%'T_('No Spam Karma') );
  132.             echo '</div>';
  133.          ?>
  134.  
  135.  
  136.         <div class="small">
  137.             <?php $Comment->content()// display the comment's contents ?>
  138.         </div>
  139.  
  140.         <div class="dashboard_action_area">
  141.             <?php
  142.             // display a link to edit a comment
  143.             $Comment->edit_linkarray(
  144.                 'class' => 'ActionButton',
  145.             ) );
  146.             // display a link to publish a comment
  147.             $Comment->publish_linkarray(
  148.                 'class' => 'PublishButton',
  149.             ) );
  150.             // display a link to deprecate a comment
  151.             $Comment->deprecate_linkarray(
  152.                 'class' => 'DeleteButton',
  153.             ) );
  154.             // display a link to delete a comment
  155.             $Comment->delete_linkarray(
  156.                 'class' => 'DeleteButton',
  157.             ) );
  158.             ?>
  159.             <div class="clear"></div>
  160.         </div>
  161.  
  162.         <?php
  163.         echo '</div>';
  164.         }
  165.  
  166.         $block_item_Widget->disp_template_raw'block_end' );
  167.     }
  168.  
  169.  
  170.     /*
  171.      * RECENT DRAFTS
  172.      */
  173.     // Create empty List:
  174.     $ItemList new ItemList2$BlogNULLNULL );
  175.  
  176.     // Filter list:
  177.     $ItemList->set_filtersarray(
  178.             'visibility_array' => array'draft' ),
  179.             'orderby' => 'datemodified',
  180.             'order' => 'DESC',
  181.             'posts' => $dash_disp_num,
  182.         ) );
  183.  
  184.     // Get ready for display (runs the query):
  185.     $ItemList->display_init();
  186.  
  187.     if$ItemList->result_num_rows )
  188.     {    // We have drafts
  189.  
  190.         $nb_blocks_displayed++;
  191.  
  192.         $block_item_Widget->title get_manual_link'recent-drafts' ).T_('Recent drafts');
  193.         $block_item_Widget->disp_template_replaced'block_start' );
  194.  
  195.         while$Item $ItemList->get_item() )
  196.         {
  197.             echo '<div class="dashboard_post" lang="'.$Item->get('locale').'">';
  198.             // We don't switch locales in the backoffice, since we use the user pref anyway
  199.             // Load item's creator user:
  200.             $Item->get_creator_User();
  201.  
  202.             echo '<div class="dashboard_float_actions">';
  203.             // display link to edit an item
  204.             $Item->edit_linkarray(
  205.                 'before' => ' ',
  206.                 'class' => 'ActionButton'
  207.             ) );
  208.             // display a link to 'publish NOW' an item if user has edit rights
  209.             $Item->publish_linkarray(
  210.                 'before' => ' ',
  211.                 'class' => 'PublishButton'
  212.             ) );
  213.             echo '<img src="'.$rsc_url.'/img/blank.gif">';
  214.             echo '</div>';
  215.  
  216.             echo '<h3 class="dashboard_post_title">';
  217.             echo '<a href="?ctrl=items&amp;blog='.$Blog->ID.'&amp;p='.$Item->ID.'">'.$Item->dget'title' ).'</a>';
  218.             echo '</h3>';
  219.  
  220.             echo '</div>';
  221.  
  222.         }
  223.  
  224.         $block_item_Widget->disp_template_raw'block_end' );
  225.     }
  226.  
  227.  
  228.     /*
  229.      * RECENTLY EDITED
  230.      */
  231.     // Create empty List:
  232.     $ItemList new ItemList2$BlogNULLNULL );
  233.  
  234.     // Filter list:
  235.     $ItemList->set_filtersarray(
  236.             'visibility_array' => array'published''protected''private''deprecated''redirected' ),
  237.             'orderby' => 'datemodified',
  238.             'order' => 'DESC',
  239.             'posts' => $dash_disp_num,
  240.         ) );
  241.  
  242.     // Get ready for display (runs the query):
  243.     $ItemList->display_init();
  244.  
  245.     if$ItemList->result_num_rows )
  246.     {    // We have recent edits
  247.  
  248.         $nb_blocks_displayed++;
  249.  
  250.         if$current_User->check_perm'blog_post_statuses''edit'false$Blog->ID ) )
  251.         {    // We have permission to add a post with at least one status:
  252.             $block_item_Widget->global_iconT_('Write a new post...')'new''?ctrl=items&amp;action=new&amp;blog='.$Blog->IDT_('New post').' &raquo;'3);
  253.         }
  254.  
  255.         $block_item_Widget->title get_manual_link'recently-edited' ).T_('Recently edited');
  256.         $block_item_Widget->disp_template_replaced'block_start' );
  257.  
  258.         while$Item $ItemList->get_item() )
  259.         {
  260.             echo '<div class="dashboard_post" lang="'.$Item->get('locale').'">';
  261.             // We don't switch locales in the backoffice, since we use the user pref anyway
  262.             // Load item's creator user:
  263.             $Item->get_creator_User();
  264.  
  265.             echo '<div class="dashboard_float_actions">';
  266.             // display a link to edit an item if user has edit rights
  267.             $Item->edit_linkarray(
  268.                 'class' => 'ActionButton'
  269.             ) );
  270.             echo '</div>';
  271.  
  272.             echo '<h3 class="dashboard_post_title">';
  273.             echo '<a href="?ctrl=items&amp;blog='.$Blog->ID.'&amp;p='.$Item->ID.'">'.$Item->dget'title' ).'</a>';
  274.             echo ' <span class="dashboard_post_details">';
  275.             $Item->statusarray(
  276.                 'before' => '',
  277.                 'after'  => ' &bull; ',
  278.             ) );
  279.  
  280.             // display item's view count
  281.             $Item->viewsarray() );
  282.  
  283.             echo '</span>';
  284.             echo '</h3>';
  285.  
  286.             // display images linked to this item
  287.             $Item->imagesarray(
  288.                 'before' => '<div class="dashboard_thumbnails">',
  289.                 'before_image' => '',
  290.                 'before_image_legend' => NULL// No legend
  291.                 'after_image_legend' => NULL,
  292.                 'after_image' => '',
  293.                 'image_size' => 'fit-80x80'
  294.             ) );
  295.  
  296.             echo '<div class="small">'.$Item->get_content_excerpt150 ).'</div>';
  297.  
  298.             echo '<div style="clear:left;">'.get_icon('pixel').'</div>'// IE crap
  299.             echo '</div>';
  300.         }
  301.  
  302.         $block_item_Widget->disp_template_raw'block_end' );
  303.     }
  304.  
  305.  
  306.     if$nb_blocks_displayed == )
  307.     {    // We haven't displayed anything yet!
  308.  
  309.         $nb_blocks_displayed++;
  310.  
  311.         $block_item_Widget->title T_('Getting started');
  312.         $block_item_Widget->disp_template_replaced'block_start' );
  313.  
  314.         echo '<p><strong>'.T_('Welcome to your new blog\'s dashboard!').'</strong></p>';
  315.  
  316.         echo '<p>'.T_('Use the links on the right to write a first post or to customize your blog.').'</p>';
  317.  
  318.         echo '<p>';
  319.         printfT_('You can see your blog page at any time by clicking "See" in the %s toolbar at the '
  320.                   .'top of this page.')$app_name );
  321.         echo '</p>';
  322.  
  323.          echo '<p>'.T_('You can come back here at any time by clicking "Manage" in that same navbar.').'</p>';
  324.  
  325.         $block_item_Widget->disp_template_raw'block_end' );
  326.     }
  327.  
  328.  
  329.     /*
  330.      * DashboardBlogMain to be added here (anyone?)
  331.      */
  332.  
  333.  
  334.     echo '</td><td>';
  335.  
  336.     /*
  337.      * RIGHT COL
  338.      */
  339.  
  340.     $side_item_Widget new Widget'side_item' );
  341.  
  342.     $side_item_Widget->title get_manual_link'manage-your-blog' ).T_('Manage your blog');
  343.     $side_item_Widget->disp_template_replaced'block_start' );
  344.  
  345.     echo '<div class="dashboard_sidebar">';
  346.     echo '<ul>';
  347.         echo '<li><a href="'.$dispatcher.'?ctrl=items&amp;action=new&amp;blog='.$Blog->ID.'">'.T_('Write a new post').' &raquo;</a></li>';
  348.  
  349.          echo '<li>'.T_('Browse').':<ul>';
  350.         echo '<li><a href="'.$dispatcher.'?ctrl=items&tab=full&filter=restore&blog='.$Blog->ID.'">'.T_('Posts (full)').' &raquo;</a></li>';
  351.         echo '<li><a href="'.$dispatcher.'?ctrl=items&tab=list&filter=restore&blog='.$Blog->ID.'">'.T_('Posts (list)').' &raquo;</a></li>';
  352.         echo '<li><a href="'.$dispatcher.'?ctrl=comments&amp;blog='.$Blog->ID.'">'.T_('Comments').' &raquo;</a></li>';
  353.         echo '</ul></li>';
  354.  
  355.         if$current_User->check_perm'blog_cats'''false$Blog->ID ) )
  356.         {
  357.             echo '<li><a href="'.$dispatcher.'?ctrl=chapters&blog='.$Blog->ID.'">'.T_('Edit categories').' &raquo;</a></li>';
  358.         }
  359.  
  360.          echo '<li><a href="'.$Blog->get('url').'">'.T_('View this blog').'</a></li>';
  361.     echo '</ul>';
  362.     echo '</div>';
  363.  
  364.     $side_item_Widget->disp_template_raw'block_end' );
  365.  
  366.     if$current_User->check_perm'blog_properties''edit'false$Blog->ID ) )
  367.     {
  368.         $side_item_Widget->title get_manual_link'customize-your-blog' ).T_('Customize your blog');
  369.         $side_item_Widget->disp_template_replaced'block_start' );
  370.  
  371.         echo '<div class="dashboard_sidebar">';
  372.         echo '<ul>';
  373.  
  374.         echo '<li><a href="'.$dispatcher.'?ctrl=coll_settings&amp;tab=general&amp;blog='.$Blog->ID.'">'.T_('Blog properties').' &raquo;</a></li>';
  375.         echo '<li><a href="'.$dispatcher.'?ctrl=coll_settings&amp;tab=features&amp;blog='.$Blog->ID.'">'.T_('Blog features').' &raquo;</a></li>';
  376.         echo '<li><a href="'.$dispatcher.'?ctrl=coll_settings&amp;tab=template&amp;blog='.$Blog->ID.'">'.T_('Blog template').' &raquo;</a></li>';
  377.         echo '<li><a href="'.$dispatcher.'?ctrl=widgets&amp;blog='.$Blog->ID.'">'.T_('Blog widgets').' &raquo;</a></li>';
  378.         echo '<li><a href="'.$dispatcher.'?ctrl=coll_settings&amp;tab=urls&amp;blog='.$Blog->ID.'">'.T_('Blog URLs').' &raquo;</a></li>';
  379.  
  380.         echo '</ul>';
  381.         echo '</div>';
  382.  
  383.         $side_item_Widget->disp_template_raw'block_end' );
  384.     }
  385.  
  386.  
  387.     /*
  388.      * DashboardBlogSide to be added here (anyone?)
  389.      */
  390.  
  391.  
  392. }
  393. else
  394. {    // We're on the GLOBAL tab...
  395.  
  396.     $AdminUI->disp_payload_begin();
  397.     echo '<h2>'.T_('Select a blog').'</h2>';
  398.     echo '<table class="browse" cellspacing="0" cellpadding="0" border="0"><tr><td>';
  399.     // Display blog list VIEW:
  400.     $AdminUI->disp_view'collections/views/_coll_list.view.php' );
  401.     echo '</td><td>';
  402.  
  403.     /*
  404.      * DashboardGlobalMain to be added here (anyone?)
  405.      */
  406. }
  407.  
  408.  
  409. /*
  410.  * Administrative tasks
  411.  */
  412.  
  413. if$current_User->check_perm'options''edit' ) )
  414. {    // We have some serious admin privilege:
  415.     /*
  416.      * DashboardAdminMain to be added here (anyone?)
  417.      */
  418.  
  419.     /*
  420.      * RIGHT COL
  421.      */
  422.     $side_item_Widget new Widget'side_item' );
  423.  
  424.     $side_item_Widget->title get_manual_link'administrative-tasks' ).T_('Administrative tasks');
  425.     $side_item_Widget->disp_template_replaced'block_start' );
  426.  
  427.     echo '<div class="dashboard_sidebar">';
  428.     echo '<ul>';
  429.         if$current_User->check_perm'users''edit' ) )
  430.         {
  431.             echo '<li><a href="'.$dispatcher.'?ctrl=users&amp;action=new_user">'.T_('Create new user').' &raquo;</a></li>';
  432.         }
  433.         if$current_User->check_perm'blogs''create' ) )
  434.         {
  435.             echo '<li><a href="'.$dispatcher.'?ctrl=collections&amp;action=new">'.T_('Create new blog').' &raquo;</a></li>';
  436.         }
  437.         echo '<li><a href="'.$dispatcher.'?ctrl=templates">'.T_('Install a template').' &raquo;</a></li>';
  438.         echo '<li><a href="'.$dispatcher.'?ctrl=plugins">'.T_('Install a plugin').' &raquo;</a></li>';
  439.         // TODO: remember system date check and only remind every 3 months
  440.         echo '<li><a href="'.$dispatcher.'?ctrl=system">'.T_('Check system &amp; security').' &raquo;</a></li>';
  441.     echo '</ul>';
  442.     echo '</div>';
  443.  
  444.     $side_item_Widget->disp_template_raw'block_end' );
  445.  
  446.     /*
  447.      * DashboardAdminSide to be added here (anyone?)
  448.      */
  449. }
  450. echo '</td></tr></table>';
  451. // End payload block:
  452. $AdminUI->disp_payload_end();
  453.  
  454. // Display body bottom, debug info and close </html>:
  455. $AdminUI->disp_global_footer();
  456.  
  457. ?>