Source for file _coll_media_index.widget.php
Documentation is available at _coll_media_index.widget.php
* This file implements the Media Index Widget class.
* This file is part of the evoCore framework - {@link http://evocore.net/}
* See also {@link http://sourceforge.net/projects/evocms/}.
* @copyright (c)2003-2010 by Francois PLANQUE - {@link http://fplanque.net/}
* {@internal License choice
* - If you have received this file as part of a package, please find the license.txt file in
* the same folder or the closest folder above for complete license terms.
* - If you have received this file individually (e-g: from http://evocms.cvs.sourceforge.net/)
* then you must choose one of the following licenses before using the file:
* - GNU General Public License 2 (GPL) - http://www.opensource.org/licenses/gpl-license.php
* - Mozilla Public License 1.1 (MPL) - http://www.opensource.org/licenses/mozilla1.1.php
* {@internal Below is a list of authors who have contributed to design/coding of this file: }}
* @author fplanque: Francois PLANQUE.
* @author Yabba - {@link http://www.astonishme.co.uk/}
* @version $Id: _coll_media_index.widget.php,v 1.22 2010/02/08 17:54:48 efy-yury Exp $
if( !defined('EVO_MAIN_INIT') ) die( 'Please, do not access this page directly.' );
load_class( 'widgets/model/_widget.class.php', 'ComponentWidget' );
load_class( '_core/model/dataobjects/_dataobjectlist2.class.php', 'DataObjectList2' );
* A ComponentWidget is a displayable entity that can be placed into a Container on a web page.
// Call parent constructor:
* Get definitions for editable params
* @see Plugin::GetDefaultSettings()
* @param local params like 'for_editing' => true
'label' =>
T_('Block title'),
'note' =>
T_( 'Title to display in your skin.' ),
'defaultvalue' =>
T_('Recent photos'),
'label' =>
T_('Thumbnail size'),
'note' =>
T_('Cropping and sizing of thumbnails'),
'defaultvalue' =>
'crop-80x80',
'note' =>
T_('How to lay out the thumbnails'),
'options' =>
array( 'grid' =>
T_( 'Grid' ), 'list' =>
T_( 'List' ) ),
'defaultvalue' =>
'grid',
'label' =>
T_( 'Columns' ),
'note' =>
T_( 'Number of columns in grid mode.' ),
'label' =>
T_( 'Max items' ),
'note' =>
T_( 'Maximum number of items to display.' ),
'label' =>
T_('Order by'),
'note' =>
T_('How to sort the items'),
'defaultvalue' =>
'datestart',
'label' =>
T_('Direction'),
'note' =>
T_('How to sort the items'),
'options' =>
array( array( 'ASC', T_('Ascending') ),
array( 'DESC', T_('Descending') ) ),
'defaultvalue' =>
'DESC',
'label' =>
T_( 'Blogs' ),
'note' =>
T_( 'IDs of the blogs to use, leave empty for the current blog. Separate multiple blogs by commas.' ),
return T_('Photo index');
* Get a very short desc. Used in the widget list.
return T_('Index of photos; click goes to original image post.');
* @param array MUST contain at least the basic display params
if( $this->disp_params[ 'order_by' ] ==
'RAND' && isset
($this->BlockCache) )
{ // Do NOT cache if display order is random
$this->BlockCache->abort_collect();
//pre_dump( $list_blogs );
// Display title if requested
// TODO: permissions, complete statuses...
// TODO: A FileList object based on ItemListLight but adding File data into the query?
// overriding ItemListLigth::query() for starters ;)
$SQL->SELECT( 'post_ID, post_datestart, post_datemodified, post_main_cat_ID, post_urltitle, post_ptyp_ID, post_title, post_excerpt, post_url,
file_ID, file_title, file_root_type, file_root_ID, file_path, file_alt, file_desc' );
$SQL->FROM( 'T_categories INNER JOIN T_postcats ON cat_ID = postcat_cat_ID
INNER JOIN T_items__item ON postcat_post_ID = post_ID
INNER JOIN T_links ON post_ID = link_itm_ID
INNER JOIN T_files ON link_file_ID = file_ID' );
$SQL->WHERE( 'cat_blog_ID IN ('.
$list_blogs.
')' ); // fp> TODO: want to restrict on images :]
$SQL->WHERE_and( 'post_status = "published"' ); // TODO: this is a dirty hack. More should be shown.
$SQL->WHERE_and( 'post_datestart <= \''.
remove_seconds( $localtimenow ).
'\'' );
$SQL->GROUP_BY( 'link_ID' );
$SQL->LIMIT( $this->disp_params[ 'limit' ]*
4 ); // fp> TODO: because we have no way of getting images only, we get 4 times more data than requested and hope that 25% at least will be images :/
'post_', 'post_ID '.
$this->disp_params['order_dir'].
', link_ID' ) );
$FileList->sql =
$SQL->get();
$FileList->query( false, false, false, 'Media index widget' );
while( $File =
& $FileList->get_next() )
{ // We have enough images already!
if( ! $File->is_image() )
{ // Skip anything that is not an image
// fp> TODO: maybe this property should be stored in link_ltype_ID or in the files table
if( $count %
$nb_cols ==
0 )
// 1/ Hack a dirty permalink( will redirect to canonical):
// $link = url_add_param( $Blog->get('url'), 'p='.$post_ID );
// 2/ Hack a link to the right "page". Very daring!!
// $link = url_add_param( $Blog->get('url'), 'paged='.$count );
// 3/ Instantiate a light object in order to get permamnent url:
$ItemLight =
new ItemLight( $FileList->get_row_by_idx( $FileList->current_idx -
1 ) ); // index had already been incremented
echo
'<a href="'.
$ItemLight->get_permanent_url().
'">';
// Generate the IMG THUMBNAIL tag with all the alt, title and desc if available
echo
$File->get_thumb_imgtag( $this->disp_params['thumb_size'] );
if( $count %
$nb_cols ==
0 )
if( $count &&
( $count %
$nb_cols !=
0 ) )
* $Log: _coll_media_index.widget.php,v $
* Revision 1.22 2010/02/08 17:54:48 efy-yury
* Revision 1.21 2010/01/30 18:55:36 blueyed
* Fix "Assigning the return value of new by reference is deprecated" (PHP 5.3)
* Revision 1.20 2010/01/27 15:20:08 efy-asimo
* Change select list to radio button
* Revision 1.19 2009/12/23 01:38:46 fplanque
* one server was missing this...
* Revision 1.18 2009/12/13 02:28:36 fplanque
* dirty fix / better than nothing
* Revision 1.17 2009/11/30 04:31:38 fplanque
* BlockCache Proof Of Concept
* Revision 1.16 2009/09/27 15:59:13 tblue246
* Photo index widget: Allow specifying multiple blogs
* Revision 1.15 2009/09/26 12:00:44 tblue246
* Revision 1.14 2009/09/25 07:33:31 efy-cantor
* replace get_cache to get_*cache
* Revision 1.13 2009/09/19 13:02:51 tblue246
* Media index: Do not show images from posts in the future, fixes: http://forums.b2evolution.net/viewtopic.php?t=19659
* Revision 1.12 2009/09/14 13:54:13 efy-arrin
* Included the ClassName in load_class() call with proper UpperCase
* Revision 1.11 2009/09/12 11:03:13 efy-arrin
* Included the ClassName in the loadclass() with proper UpperCase
* Revision 1.10 2009/08/27 13:15:28 tblue246
* Removed left over pre_dump()...
* Revision 1.9 2009/08/27 13:13:54 tblue246
* Revision 1.8 2009/07/07 04:52:54 sam2kb
* Made some strings translatable
* Revision 1.7 2009/03/31 18:28:25 tblue246
* Fixing http://forums.b2evolution.net/viewtopic.php?t=18387
* Revision 1.6 2009/03/13 02:32:07 fplanque
* Removed stupid widget_name param.
* Revision 1.5 2009/03/08 23:57:46 fplanque
* Revision 1.4 2009/02/08 11:31:56 yabs
* Revision 1.3 2008/09/29 08:30:36 fplanque
* Revision 1.2 2008/09/24 08:44:11 fplanque
* Fixed and normalized order params for widgets (Comments not done yet)
* Revision 1.1 2008/09/23 09:04:33 fplanque
* moved media index to a widget
* Revision 1.7 2008/05/06 23:35:47 fplanque
* The correct way to add linebreaks to widgets is to add them to $disp_params when the container is called, right after the array_merge with defaults.
* Revision 1.5 2008/01/21 09:35:37 fplanque
* Revision 1.4 2007/12/26 23:12:48 yabs
* changing RANDOM to RAND
* Revision 1.3 2007/12/26 20:04:54 fplanque
* Revision 1.2 2007/12/24 12:05:31 yabs
* bugfix "order" is a reserved name, used by wi_order
* Revision 1.1 2007/12/24 11:02:42 yabs