Source for file dashboard.ctrl.php
Documentation is available at dashboard.ctrl.php
* This file implements the UI controller for the dashboard.
* Quam Plures - {@link http://quamplures.net/}
* Released under GNU GPL License - {@link http://quamplures.net/license.html}
* @copyright (c) 2009 - 2011 by the Quam Plures developers - {@link http://quamplures.net/}
* @copyright (c)2003-2007 by Francois PLANQUE - {@link http://fplanque.net/}
* {@internal Open Source relicensing agreement:
* {@internal Below is a list of authors who have contributed to design/coding of this file: }}
* @author fplanque: Francois PLANQUE.
* @todo add 5 plugin hooks. Will be widgetized later (same as TemplateTag became Widgets)
if( !defined('QP_MAIN_INIT') ) die( 'Please, do not access this page directly.' );
if( ! $current_User->check_perm( 'blog_ismember', 1, false, $blog ) )
{ // We don't have permission for the requested blog (may happen if we come to admin from a link on a different blog)
$AdminUI->set_coll_list_params( 'blog_ismember', 'view', array(), T_('Global'), '?blog=0' );
$AdminUI->set_path( 'dashboard' );
// Display <html><head>...</head> section! (Note: should be done early if actions do not redirect)
$AdminUI->disp_html_head();
// Display title, menu, messages, etc. (Note: messages MUST be displayed AFTER the actions)
$AdminUI->disp_body_top();
{ // We want to look at a specific blog:
$AdminUI->disp_payload_begin();
echo '<h2>'. $Blog->dget( 'name' ). '</h2>';
echo '<table class="browse" cellspacing="0" cellpadding="0" border="0"><tr><td>';
$block_item_Widget = new Widget( 'block_item' );
$nb_blocks_displayed = 0;
$CommentList = new CommentList( $Blog, "'comment','trackback'", array( 'draft' ), '', '', 'DESC', '', $dash_disp_num );
if( $CommentList->result_num_rows )
$block_item_Widget->title = get_manual_link( 'comments-awaiting-moderation' ). T_('Comments awaiting moderation');
$block_item_Widget->disp_template_replaced( 'block_start' );
while( $Comment = & $CommentList->get_next() )
{ // Loop through comments:
echo '<div class="dashboard_post">';
echo '<h3 class="dashboard_post_title">';
echo $Comment->get_title(array('author_format'=> '<strong>%s</strong>'));
$comment_Item = & $Comment->get_Item();
echo ' '. T_('in response to')
. ' <a href="?ctrl=items&blog='. $comment_Item->get_blog_ID(). '&p='. $comment_Item->ID. '"><strong>'. $comment_Item->dget('title'). '</strong></a>';
echo '<div class="notes">';
// display a comment's rating
// display the comment's date
$Comment->date( array() );
// display a link to comment author's URL
if( $Comment->author_url( array(
'before' => ' • Url: <span class="bUrl">',
if( $current_User->check_perm( 'spamblacklist', 'edit' ) )
{ // There is an URL and we have permission to ban...
// TODO: really ban the base domain! - not by keyword
. '&aspm_source=reported">'. get_icon( 'ban' ). '</a> ';
// display mailto link to comment author's email
$Comment->author_email( array(
'before' => ' • Email: <span class="bEmail">',
'after' => '</span> • ',
// display comment author's IP address
$Comment->author_ip( array(
'before' => 'IP: <span class="bIP">',
'after' => '</span> • ',
$Comment->spam_karma( T_('Spam Karma'). ': %s%', T_('No Spam Karma') );
<?php $Comment->content(); // display the comment's contents ?>
<div class="dashboard_action_area">
// display a link to edit a comment
$Comment->edit_link( array(
'class' => 'ActionButton',
// display a link to publish a comment
$Comment->publish_link( array(
'class' => 'PublishButton',
// display a link to deprecate a comment
$Comment->deprecate_link( array(
'class' => 'DeleteButton',
// display a link to delete a comment
$Comment->delete_link( array(
'class' => 'DeleteButton',
<div class="clear"></div>
$block_item_Widget->disp_template_raw( 'block_end' );
$ItemList = new ItemList2( $Blog, NULL, NULL );
$ItemList->set_filters( array(
'visibility_array' => array( 'draft' ),
'orderby' => 'datemodified',
'posts' => $dash_disp_num,
// Get ready for display (runs the query):
$ItemList->display_init();
if( $ItemList->result_num_rows )
$block_item_Widget->disp_template_replaced( 'block_start' );
while( $Item = & $ItemList->get_item() )
echo '<div class="dashboard_post" lang="'. $Item->get('locale'). '">';
// We don't switch locales in the backoffice, since we use the user pref anyway
// Load item's creator user:
$Item->get_creator_User();
echo '<div class="dashboard_float_actions">';
// display link to edit an item
'class' => 'ActionButton'
// display a link to 'publish NOW' an item if user has edit rights
$Item->publish_link( array(
'class' => 'PublishButton'
echo '<img src="'. $rsc_url. '/img/blank.gif">';
echo '<h3 class="dashboard_post_title">';
echo '<a href="?ctrl=items&blog='. $Blog->ID. '&p='. $Item->ID. '">'. $Item->dget( 'title' ). '</a>';
$block_item_Widget->disp_template_raw( 'block_end' );
$ItemList = new ItemList2( $Blog, NULL, NULL );
$ItemList->set_filters( array(
'visibility_array' => array( 'published', 'protected', 'private', 'deprecated', 'redirected' ),
'orderby' => 'datemodified',
'posts' => $dash_disp_num,
// Get ready for display (runs the query):
$ItemList->display_init();
if( $ItemList->result_num_rows )
{ // We have recent edits
if( $current_User->check_perm( 'blog_post_statuses', 'edit', false, $Blog->ID ) )
{ // We have permission to add a post with at least one status:
$block_item_Widget->global_icon( T_('Write a new post...'), 'new', '?ctrl=items&action=new&blog='. $Blog->ID, T_('New post'). ' »', 3, 4 );
$block_item_Widget->title = get_manual_link( 'recently-edited' ). T_('Recently edited');
$block_item_Widget->disp_template_replaced( 'block_start' );
while( $Item = & $ItemList->get_item() )
echo '<div class="dashboard_post" lang="'. $Item->get('locale'). '">';
// We don't switch locales in the backoffice, since we use the user pref anyway
// Load item's creator user:
$Item->get_creator_User();
echo '<div class="dashboard_float_actions">';
// display a link to edit an item if user has edit rights
'class' => 'ActionButton'
echo '<h3 class="dashboard_post_title">';
echo '<a href="?ctrl=items&blog='. $Blog->ID. '&p='. $Item->ID. '">'. $Item->dget( 'title' ). '</a>';
echo ' <span class="dashboard_post_details">';
// display item's view count
// display images linked to this item
'before' => '<div class="dashboard_thumbnails">',
'before_image_legend' => NULL, // No legend
'after_image_legend' => NULL,
'image_size' => 'fit-80x80'
echo '<div class="small">'. $Item->get_content_excerpt( 150 ). '</div>';
echo '<div style="clear:left;">'. get_icon('pixel'). '</div>'; // IE crap
$block_item_Widget->disp_template_raw( 'block_end' );
if( $nb_blocks_displayed == 0 )
{ // We haven't displayed anything yet!
$block_item_Widget->title = T_('Getting started');
$block_item_Widget->disp_template_replaced( 'block_start' );
echo '<p><strong>'. T_('Welcome to your new blog\'s dashboard!'). '</strong></p>';
echo '<p>'. T_('Use the links on the right to write a first post or to customize your blog.'). '</p>';
printf( T_('You can see your blog page at any time by clicking "See" in the %s toolbar at the '
. 'top of this page.'), $app_name );
echo '<p>'. T_('You can come back here at any time by clicking "Manage" in that same navbar.'). '</p>';
$block_item_Widget->disp_template_raw( 'block_end' );
* DashboardBlogMain to be added here (anyone?)
$side_item_Widget = new Widget( 'side_item' );
$side_item_Widget->title = get_manual_link( 'manage-your-blog' ). T_('Manage your blog');
$side_item_Widget->disp_template_replaced( 'block_start' );
echo '<div class="dashboard_sidebar">';
echo '<li><a href="'. $dispatcher. '?ctrl=items&action=new&blog='. $Blog->ID. '">'. T_('Write a new post'). ' »</a></li>';
echo '<li>'. T_('Browse'). ':<ul>';
echo '<li><a href="'. $dispatcher. '?ctrl=items&tab=full&filter=restore&blog='. $Blog->ID. '">'. T_('Posts (full)'). ' »</a></li>';
echo '<li><a href="'. $dispatcher. '?ctrl=items&tab=list&filter=restore&blog='. $Blog->ID. '">'. T_('Posts (list)'). ' »</a></li>';
echo '<li><a href="'. $dispatcher. '?ctrl=comments&blog='. $Blog->ID. '">'. T_('Comments'). ' »</a></li>';
if( $current_User->check_perm( 'blog_cats', '', false, $Blog->ID ) )
echo '<li><a href="'. $dispatcher. '?ctrl=chapters&blog='. $Blog->ID. '">'. T_('Edit categories'). ' »</a></li>';
echo '<li><a href="'. $Blog->get('url'). '">'. T_('View this blog'). '</a></li>';
$side_item_Widget->disp_template_raw( 'block_end' );
if( $current_User->check_perm( 'blog_properties', 'edit', false, $Blog->ID ) )
$side_item_Widget->title = get_manual_link( 'customize-your-blog' ). T_('Customize your blog');
$side_item_Widget->disp_template_replaced( 'block_start' );
echo '<div class="dashboard_sidebar">';
echo '<li><a href="'. $dispatcher. '?ctrl=coll_settings&tab=general&blog='. $Blog->ID. '">'. T_('Blog properties'). ' »</a></li>';
echo '<li><a href="'. $dispatcher. '?ctrl=coll_settings&tab=features&blog='. $Blog->ID. '">'. T_('Blog features'). ' »</a></li>';
echo '<li><a href="'. $dispatcher. '?ctrl=coll_settings&tab=template&blog='. $Blog->ID. '">'. T_('Blog template'). ' »</a></li>';
echo '<li><a href="'. $dispatcher. '?ctrl=widgets&blog='. $Blog->ID. '">'. T_('Blog widgets'). ' »</a></li>';
echo '<li><a href="'. $dispatcher. '?ctrl=coll_settings&tab=urls&blog='. $Blog->ID. '">'. T_('Blog URLs'). ' »</a></li>';
$side_item_Widget->disp_template_raw( 'block_end' );
* DashboardBlogSide to be added here (anyone?)
{ // We're on the GLOBAL tab...
$AdminUI->disp_payload_begin();
echo '<h2>'. T_('Select a blog'). '</h2>';
echo '<table class="browse" cellspacing="0" cellpadding="0" border="0"><tr><td>';
// Display blog list VIEW:
$AdminUI->disp_view( 'collections/views/_coll_list.view.php' );
* DashboardGlobalMain to be added here (anyone?)
if( $current_User->check_perm( 'options', 'edit' ) )
{ // We have some serious admin privilege:
* DashboardAdminMain to be added here (anyone?)
$side_item_Widget = new Widget( 'side_item' );
$side_item_Widget->title = get_manual_link( 'administrative-tasks' ). T_('Administrative tasks');
$side_item_Widget->disp_template_replaced( 'block_start' );
echo '<div class="dashboard_sidebar">';
if( $current_User->check_perm( 'users', 'edit' ) )
echo '<li><a href="'. $dispatcher. '?ctrl=users&action=new_user">'. T_('Create new user'). ' »</a></li>';
if( $current_User->check_perm( 'blogs', 'create' ) )
echo '<li><a href="'. $dispatcher. '?ctrl=collections&action=new">'. T_('Create new blog'). ' »</a></li>';
echo '<li><a href="'. $dispatcher. '?ctrl=templates">'. T_('Install a template'). ' »</a></li>';
echo '<li><a href="'. $dispatcher. '?ctrl=plugins">'. T_('Install a plugin'). ' »</a></li>';
// TODO: remember system date check and only remind every 3 months
echo '<li><a href="'. $dispatcher. '?ctrl=system">'. T_('Check system & security'). ' »</a></li>';
$side_item_Widget->disp_template_raw( 'block_end' );
* DashboardAdminSide to be added here (anyone?)
echo '</td></tr></table>';
$AdminUI->disp_payload_end();
// Display body bottom, debug info and close </html>:
$AdminUI->disp_global_footer();
|