2009-01-13 00:47:13 +00:00
< ? php
/*
2009-11-17 13:27:14 +00:00
* e107 website system
*
2009-11-18 01:06:08 +00:00
* Copyright ( C ) 2008 - 2009 e107 Inc ( e107 . org )
2009-11-17 13:27:14 +00:00
* Released under the terms and conditions of the
* GNU General Public License ( http :// www . gnu . org / licenses / gpl . txt )
*
*
*
* $Source : / cvs_backup / e107_0 . 8 / e107_plugins / download / download_shortcodes . php , v $
2010-02-10 18:18:01 +00:00
* $Revision $
* $Date $
* $Author $
2009-11-17 13:27:14 +00:00
*/
2009-01-13 00:47:13 +00:00
if ( ! defined ( 'e107_INIT' )) { exit ; }
2009-08-06 22:34:59 +00:00
require_once ( e_HANDLER . 'shortcode_handler.php' );
2009-02-11 21:41:54 +00:00
register_shortcode ( 'download_shortcodes' , true );
initShortcodeClass ( 'download_shortcodes' );
2009-01-13 00:47:13 +00:00
2009-02-11 21:41:54 +00:00
/**
* download_shortcodes
*/
class download_shortcodes
2009-01-13 00:47:13 +00:00
{
2009-02-11 21:41:54 +00:00
var $e107 ;
var $postInfo ;
2009-01-13 00:47:13 +00:00
2009-02-11 21:41:54 +00:00
/**
* download_shortcodes constructor
*/
function download_shortcodes ()
2009-01-13 00:47:13 +00:00
{
2009-02-11 21:41:54 +00:00
$this -> e107 = e107 :: getInstance ();
$this -> postInfo = array ();
2009-01-13 00:47:13 +00:00
}
2009-02-11 21:41:54 +00:00
// Category ************************************************************************************
2009-07-21 07:10:25 +00:00
function sc_download_cat_main_name () {
2009-02-11 21:41:54 +00:00
global $tp , $dlrow ;
2010-01-02 22:10:35 +00:00
return $tp -> toHTML ( $dlrow [ 'download_category_name' ], FALSE , 'TITLE' );
2009-02-11 21:41:54 +00:00
}
2009-07-21 07:10:25 +00:00
function sc_download_cat_main_description () {
2009-02-11 21:41:54 +00:00
global $tp , $dlrow ;
return $tp -> toHTML ( $dlrow [ 'download_category_description' ], TRUE , 'DESCRIPTION' );
}
2009-07-21 07:10:25 +00:00
function sc_download_cat_main_icon () {
2009-02-11 21:41:54 +00:00
global $dlrow ;
// Pass count as 1 to force non-empty icon
2009-07-21 07:10:25 +00:00
return $this -> _sc_cat_icons ( $dlrow [ 'download_category_icon' ], 1 , $dlrow [ 'download_category_name' ]);
2009-02-11 21:41:54 +00:00
}
// Sub-Category ********************************************************************************
2009-07-21 07:10:25 +00:00
function sc_download_cat_sub_name () {
2009-02-11 21:41:54 +00:00
global $tp , $dlsubrow ;
if ( $dlsubrow [ 'd_count' ])
{
2010-01-02 22:10:35 +00:00
return " <a href=' " . e_PLUGIN . " download/download.php?list. " . $dlsubrow [ 'download_category_id' ] . " '> " . $tp -> toHTML ( $dlsubrow [ 'download_category_name' ], FALSE , 'TITLE' ) . " </a> " ;
2009-02-11 21:41:54 +00:00
}
else
{
2010-01-02 22:10:35 +00:00
return $tp -> toHTML ( $dlsubrow [ 'download_category_name' ], FALSE , 'TITLE' );
2009-02-11 21:41:54 +00:00
}
}
2009-07-21 07:10:25 +00:00
function sc_download_cat_sub_description () {
2009-02-11 21:41:54 +00:00
global $tp , $dlsubrow ;
return $tp -> toHTML ( $dlsubrow [ 'download_category_description' ], TRUE , 'DESCRIPTION' );
}
2009-07-21 07:10:25 +00:00
function sc_download_cat_sub_icon () {
2009-02-11 21:41:54 +00:00
global $dlsubrow ;
2009-07-21 07:10:25 +00:00
return $this -> _sc_cat_icons ( $dlsubrow [ 'download_category_icon' ], $dlsubrow [ 'd_count' ], $dlsubrow [ 'download_category_name' ]);
2009-02-11 21:41:54 +00:00
}
2009-07-21 07:10:25 +00:00
function sc_download_cat_sub_new_icon () {
2009-02-11 21:41:54 +00:00
global $dlsubrow ;
return $this -> _check_new_download ( $dlsubrow [ 'd_last_subs' ]);
}
2009-07-21 07:10:25 +00:00
function sc_download_cat_sub_count () {
2009-02-11 21:41:54 +00:00
global $dlsubrow ;
return $dlsubrow [ 'd_count' ];
}
2009-07-21 07:10:25 +00:00
function sc_download_cat_sub_size () {
2009-02-11 21:41:54 +00:00
global $e107 , $dlsubrow ;
return $this -> e107 -> parseMemorySize ( $dlsubrow [ 'd_size' ]);
}
2009-07-21 07:10:25 +00:00
function sc_download_cat_sub_downloaded () {
2009-02-11 21:41:54 +00:00
global $dlsubrow ;
return intval ( $dlsubrow [ 'd_requests' ]);
}
// Sub-Sub-Category ****************************************************************************
2009-07-21 07:10:25 +00:00
function sc_download_cat_subsub_name () {
2009-02-11 21:41:54 +00:00
global $tp , $dlsubsubrow ;
if ( $dlsubsubrow [ 'd_count' ])
{
2010-01-02 22:10:35 +00:00
return " <a href=' " . e_PLUGIN . " download/download.php?list. " . $dlsubsubrow [ 'download_category_id' ] . " '> " . $tp -> toHTML ( $dlsubsubrow [ 'download_category_name' ], FALSE , 'TITLE' ) . " </a> " ;
2009-02-11 21:41:54 +00:00
}
else
{
2010-01-02 22:10:35 +00:00
return $tp -> toHTML ( $dlsubsubrow [ 'download_category_name' ], FALSE , 'TITLE' );
2009-02-11 21:41:54 +00:00
}
}
2009-07-21 07:10:25 +00:00
function sc_download_cat_subsub_description () {
2009-02-11 21:41:54 +00:00
global $tp , $dlsubsubrow ;
return $tp -> toHTML ( $dlsubsubrow [ 'download_category_description' ], TRUE , 'DESCRIPTION' );
}
2009-07-21 07:10:25 +00:00
function sc_download_cat_subsub_icon () {
2009-02-11 21:41:54 +00:00
global $dlsubsubrow ;
2009-07-21 07:10:25 +00:00
return $this -> _sc_cat_icons ( $dlsubsubrow [ 'download_category_icon' ], $dlsubsubrow [ 'd_count' ], $dlsubsubrow [ 'download_category_name' ]);
2009-02-11 21:41:54 +00:00
}
2009-07-21 07:10:25 +00:00
function sc_download_cat_subsub_count () {
2009-02-11 21:41:54 +00:00
global $dlsubsubrow ;
return $dlsubsubrow [ 'd_count' ];
}
2009-07-21 07:10:25 +00:00
function sc_download_cat_subsub_size () {
2009-02-11 21:41:54 +00:00
global $e107 , $dlsubsubrow ;
return $this -> e107 -> parseMemorySize ( $dlsubsubrow [ 'd_size' ]);
}
2009-07-21 07:10:25 +00:00
function sc_download_cat_subsub_downloaded () {
2009-02-11 21:41:54 +00:00
global $dlsubsubrow ;
return intval ( $dlsubsubrow [ 'd_requests' ]);
}
// List ****************************************************************************************
2009-07-21 07:10:25 +00:00
function sc_download_list_name ()
2009-02-11 21:41:54 +00:00
{
global $dlrow , $tp , $pref , $parm ;
if ( $parm == " nolink " ){
return $tp -> toHTML ( $dlrow [ 'download_name' ], TRUE , 'LINKTEXT' );
}
if ( $parm == " request " ){
$agreetext = $tp -> toJS ( $tp -> toHTML ( $pref [ 'agree_text' ], FALSE , 'DESCRIPTION' ));
if ( $dlrow [ 'download_mirror_type' ]){
$text = ( $pref [ 'agree_flag' ] ? " <a href=' " . e_PLUGIN . " download/download.php?mirror. " . $dlrow [ 'download_id' ] . " ' onclick= \" return confirm(' { $agreetext } '); \" > " : " <a href=' " . e_PLUGIN . " download/download.php?mirror. " . $dlrow [ 'download_id' ] . " ' title=' " . LAN_dl_32 . " '> " );
} else {
$text = ( $pref [ 'agree_flag' ] ? " <a href=' " . e_BASE . " request.php? " . $dlrow [ 'download_id' ] . " ' onclick= \" return confirm(' { $agreetext } '); \" > " : " <a href=' " . e_BASE . " request.php? " . $dlrow [ 'download_id' ] . " ' title=' " . LAN_dl_32 . " '> " );
}
2010-01-02 22:10:35 +00:00
$text .= $tp -> toHTML ( $dlrow [ 'download_name' ], FALSE , 'TITLE' ) . " </a> " ;
2009-02-11 21:41:54 +00:00
return $text ;
}
return " <a href=' " . e_PLUGIN . " download/download.php?view. " . $dlrow [ 'download_id' ] . " '> " . $tp -> toHTML ( $dlrow [ 'download_name' ], TRUE , 'LINKTEXT' ) . " </a> " ;
}
2009-07-21 07:10:25 +00:00
function sc_download_list_author ()
2009-02-11 21:41:54 +00:00
{
global $dlrow ;
return $dlrow [ 'download_author' ];
}
2009-07-21 07:10:25 +00:00
function sc_download_list_requested ()
2009-02-11 21:41:54 +00:00
{
global $dlrow ;
return $dlrow [ 'download_requested' ];
}
2009-07-21 07:10:25 +00:00
function sc_download_list_newicon ()
2009-02-11 21:41:54 +00:00
{
global $dlrow ;
return ( USER && $dlrow [ 'download_datestamp' ] > USERLV ? " <img src=' " . IMAGE_NEW . " ' alt='*' style='vertical-align:middle' /> " : " " );
}
2009-07-21 07:10:25 +00:00
function sc_download_list_recenticon ()
2009-02-11 21:41:54 +00:00
{
global $dlrow , $pref ;
// convert "recent_download_days" to seconds
return ( $dlrow [ 'download_datestamp' ] > time () - ( $pref [ 'recent_download_days' ] * 86400 ) ? '<img src="' . IMAGE_NEW . '" alt="" style="vertical-align:middle" />' : '' );
}
2013-02-23 03:04:45 -08:00
2009-07-21 07:10:25 +00:00
function sc_download_list_filesize ()
2009-02-11 21:41:54 +00:00
{
global $dlrow , $e107 ;
return $e107 -> parseMemorySize ( $dlrow [ 'download_filesize' ]);
}
2013-02-23 03:04:45 -08:00
2009-07-21 07:10:25 +00:00
function sc_download_list_datestamp ()
2009-02-11 21:41:54 +00:00
{
global $dlrow ;
$gen = new convert ;
return $gen -> convert_date ( $dlrow [ 'download_datestamp' ], " short " );
}
2013-02-23 03:04:45 -08:00
2009-07-21 07:10:25 +00:00
function sc_download_list_thumb ()
2009-02-11 21:41:54 +00:00
{
global $dlrow , $parm ;
2012-04-20 07:28:53 +00:00
$tp = e107 :: getParser ();
$img = ( $dlrow [ 'download_thumb' ]) ? " <img src=' " . $tp -> replaceConstants ( $dlrow [ 'download_thumb' ]) . " ' alt='*' style=' " . DL_IMAGESTYLE . " ' /> " : " " ;
2009-02-11 21:41:54 +00:00
if ( $parm == " link " && $dlrow [ 'download_thumb' ]){
return " <a href=' " . e_PLUGIN . " download/download.php?view. " . $dlrow [ 'download_id' ] . " '> " . $img . " </a> " ;
}
else
{
return $img ;
}
}
2013-02-23 03:04:45 -08:00
2009-07-21 07:10:25 +00:00
function sc_download_list_id ()
2009-02-11 21:41:54 +00:00
{
global $dlrow ;
return $dlrow [ 'download_id' ];
}
2013-02-23 03:04:45 -08:00
2009-07-21 07:10:25 +00:00
function sc_download_list_rating ()
2009-02-11 21:41:54 +00:00
{
2013-02-23 03:04:45 -08:00
global $dlrow ;
return e107 :: getForm () -> rate ( " download " , $dlrow [ 'download_id' ]);
2009-02-11 21:41:54 +00:00
$rater = new rater ();
$ratearray = $rater -> getrating ( " download " , $dlrow [ 'download_id' ]);
if ( ! $ratearray [ 0 ]) {
return LAN_dl_13 ;
}
else
{
return ( $ratearray [ 2 ] ? " { $ratearray [ 1 ] } . { $ratearray [ 2 ] } / { $ratearray [ 0 ] } " : " { $ratearray [ 1 ] } / { $ratearray [ 0 ] } " );
}
}
2009-07-21 07:10:25 +00:00
function sc_download_list_link ()
2009-02-11 21:41:54 +00:00
{
global $tp , $dlrow , $pref , $parm ;
$agreetext = $tp -> toJS ( $tp -> toHTML ( $pref [ 'agree_text' ], FALSE , 'DESCRIPTION' ));
$img = " <img src=' " . IMAGE_DOWNLOAD . " ' alt=' " . LAN_dl_32 . " ' title=' " . LAN_dl_32 . " ' /> " ;
if ( $dlrow [ 'download_mirror_type' ])
{
return " <a href=' " . e_PLUGIN . " download/download.php?mirror. " . $dlrow [ 'download_id' ] . " '> { $img } </a> " ;
}
else
{
return ( $pref [ 'agree_flag' ] ? " <a href=' " . e_BASE . " request.php? " . $dlrow [ 'download_id' ] . " ' onclick= \" return confirm(' { $agreetext } '); \" > { $img } </a> " : " <a href=' " . e_BASE . " request.php? " . $dlrow [ 'download_id' ] . " ' > { $img } </a> " );
}
}
2012-04-20 07:28:53 +00:00
2009-07-21 07:10:25 +00:00
function sc_download_list_icon ()
2009-02-11 21:41:54 +00:00
{
global $dlrow , $parm ;
if ( $parm == " link " ){
return " <a href=' " . e_PLUGIN . " download/download.php?view. " . $dlrow [ 'download_id' ] . " ' > " . $img . " </a> " ;
}
else
{
return $img ;
}
return ;
}
2012-04-20 07:28:53 +00:00
function sc_download_list_imagefull ()
{
global $dlrow , $parm ;
$tp = e107 :: getParser ();
$img = ( $dlrow [ 'download_image' ]) ? " <img class='dl_image' src=' " . $tp -> replaceConstants ( $dlrow [ 'download_image' ]) . " ' alt='' style=' " . DL_IMAGESTYLE . " ' /> " : " " ;
if ( $parm == " link " && $dlrow [ 'download_image' ])
{
return " <a href=' " . e_BASE . " download.php?view. " . $dlrow [ 'download_id' ] . " '> " . $img . " </a> " ;
}
else
{
return $img ;
}
}
2009-07-21 07:10:25 +00:00
function sc_download_list_nextprev ()
2009-02-11 21:41:54 +00:00
{
global $nextprev_parms , $tp ;
return $tp -> parseTemplate ( " { NEXTPREV= { $nextprev_parms } } " );
}
2009-07-21 07:10:25 +00:00
function sc_download_list_total_amount () {
2009-02-11 21:41:54 +00:00
global $dltdownloads ;
return $dltdownloads . " " . LAN_dl_16 ;
}
2009-07-21 07:10:25 +00:00
function sc_download_list_total_files () {
2009-02-11 21:41:54 +00:00
global $dlft ;
return $dlft . " " . LAN_dl_17 ;
}
2012-04-20 07:28:53 +00:00
2009-02-11 21:41:54 +00:00
// View ****************************************************************************************
2009-07-21 07:10:25 +00:00
function sc_download_view_id ()
2009-02-11 21:41:54 +00:00
{
global $dlrow ;
return $dlrow [ 'download_id' ];
}
2009-07-21 07:10:25 +00:00
function sc_download_admin_edit ()
2009-02-11 21:41:54 +00:00
{
global $dlrow ;
return ( ADMIN && getperms ( '6' )) ? " <a href=' " . e_ADMIN . " download.php?create.edit. " . $dlrow [ 'download_id' ] . " ' title='edit'><img src=' " . e_IMAGE . " generic/lite/edit.png' alt='*' style='padding:0px;border:0px' /></a> " : " " ;
}
2009-07-21 07:10:25 +00:00
function sc_download_category ()
2009-02-11 21:41:54 +00:00
{
global $dlrow ;
return $dlrow [ 'download_category_name' ];
}
2009-07-21 07:10:25 +00:00
function sc_download_category_description ()
2009-02-11 21:41:54 +00:00
{
global $tp , $dl , $parm ;
$text = $tp -> toHTML ( $dl [ 'download_category_description' ], TRUE , 'DESCRIPTION' );
if ( $parm ){
return substr ( $text , 0 , $parm );
} else {
return $text ;
}
}
2009-07-21 07:10:25 +00:00
function sc_download_view_name ()
2009-02-11 21:41:54 +00:00
{
global $dlrow , $parm ;
$link [ 'view' ] = " <a href=' " . e_PLUGIN . " download/download.php?view. " . $dlrow [ 'download_id' ] . " '> " . $dlrow [ 'download_name' ] . " </a> " ;
$link [ 'request' ] = " <a href=' " . e_BASE . " request.php? " . $dlrow [ 'download_id' ] . " ' title=' " . LAN_dl_46 . " '> " . $dlrow [ 'download_name' ] . " </a> " ;
if ( $parm ){
return $link [ $parm ];
}
return $dlrow [ 'download_name' ];
}
2009-07-21 07:10:25 +00:00
function sc_download_view_name_linked ()
2009-02-11 21:41:54 +00:00
{
global $pref , $dl , $tp ;
if ( $pref [ 'agree_flag' ] == 1 ) {
2012-05-27 10:42:16 +00:00
return " <a href=' " . e_BASE . " request.php? " . $dl [ 'download_id' ] . " ' onclick= \" return confirm(' " . $tp -> toJS ( $tp -> toHTML ( $pref [ 'agree_text' ], FALSE , 'DESCRIPTION' )) . " '); \" title=' " . LAN_dl_46 . " '> " . $dl [ 'download_name' ] . " </a> " ;
2009-02-11 21:41:54 +00:00
} else {
return " <a href=' " . e_BASE . " request.php? " . $dl [ 'download_id' ] . " ' title=' " . LAN_dl_46 . " '> " . $dl [ 'download_name' ] . " </a> " ;
}
}
2009-07-21 07:10:25 +00:00
function sc_download_view_author ()
2009-02-11 21:41:54 +00:00
{
global $dlrow ;
return ( $dlrow [ 'download_author' ] ? $dlrow [ 'download_author' ] : " " );
}
2009-07-21 07:10:25 +00:00
function sc_download_view_authoremail ()
2009-02-11 21:41:54 +00:00
{
global $tp , $dlrow ;
return ( $dlrow [ 'download_author_email' ]) ? $tp -> toHTML ( $dlrow [ 'download_author_email' ], TRUE , 'LINKTEXT' ) : " " ;
}
2009-07-21 07:10:25 +00:00
function sc_download_view_authorwebsite ()
2009-02-11 21:41:54 +00:00
{
global $tp , $dlrow ;
return ( $dlrow [ 'download_author_website' ]) ? $tp -> toHTML ( $dlrow [ 'download_author_website' ], TRUE , 'LINKTEXT' ) : " " ;
}
2009-07-21 07:10:25 +00:00
function sc_download_view_description ()
2009-02-11 21:41:54 +00:00
{
global $tp , $dlrow , $parm ;
$maxlen = ( $parm ? intval ( $parm ) : 0 );
$text = ( $dlrow [ 'download_description' ] ? $tp -> toHTML ( $dlrow [ 'download_description' ], TRUE , 'DESCRIPTION' ) : " " );
if ( $maxlen ){
return substr ( $text , 0 , $maxlen );
} else {
return $text ;
}
return $text ;
}
2009-07-21 07:10:25 +00:00
function sc_download_view_date ()
2009-02-11 21:41:54 +00:00
{
global $gen , $dlrow , $parm ;
return ( $dlrow [ 'download_datestamp' ]) ? $gen -> convert_date ( $dlrow [ 'download_datestamp' ], $parm ) : " " ;
}
2009-07-21 07:10:25 +00:00
function sc_download_view_date_short ()
2009-02-11 21:41:54 +00:00
{
// deprecated: DOWNLOAD_VIEW_DATE should be used instead.
global $gen , $dlrow ;
return ( $dlrow [ 'download_datestamp' ]) ? $gen -> convert_date ( $dlrow [ 'download_datestamp' ], " short " ) : " " ;
}
2009-07-21 07:10:25 +00:00
function sc_download_view_date_long ()
2009-02-11 21:41:54 +00:00
{
// deprecated: DOWNLOAD_VIEW_DATE should be used instead.
global $gen , $dlrow ;
return ( $dlrow [ 'download_datestamp' ]) ? $gen -> convert_date ( $dlrow [ 'download_datestamp' ], " long " ) : " " ;
}
2009-07-21 07:10:25 +00:00
function sc_download_view_image ()
2009-02-11 21:41:54 +00:00
{
global $dlrow ;
2012-04-20 07:28:53 +00:00
$tp = e107 :: getParser ();
2009-02-11 21:41:54 +00:00
if ( $dlrow [ 'download_thumb' ]) {
2012-04-20 07:28:53 +00:00
return ( $dlrow [ 'download_image' ] ? " <a href=' " . e_BASE . " request.php?download. " . $dlrow [ 'download_id' ] . " '><img class='dl_image' src=' " . $tp -> replaceConstants ( $dlrow [ 'download_thumb' ]) . " ' alt='*' style=' " . DL_IMAGESTYLE . " ' /></a> " : " <img class='dl_image' src=' " . $tp -> replaceConstants ( $dlrow [ 'download_thumb' ]) . " ' alt='*' style=' " . DL_IMAGESTYLE . " ' /> " );
2009-02-11 21:41:54 +00:00
}
else if ( $dlrow [ 'download_image' ]) {
return " <a href=' " . e_BASE . " request.php?download. " . $dlrow [ 'download_id' ] . " '> " . LAN_dl_40 . " </a> " ;
}
else
{
return LAN_dl_75 ;
}
}
2009-07-21 07:10:25 +00:00
function sc_download_view_imagefull ()
2009-02-11 21:41:54 +00:00
{
global $dlrow ;
2012-04-20 07:28:53 +00:00
$tp = e107 :: getParser ();
return ( $dlrow [ 'download_image' ]) ? " <img class='dl_image' src=' " . $tp -> replaceConstants ( $dlrow [ 'download_image' ]) . " ' alt='*' style=' " . DL_IMAGESTYLE . " ' /> " : " " ;
2009-02-11 21:41:54 +00:00
}
2009-07-21 07:10:25 +00:00
function sc_download_view_link ()
2009-02-11 21:41:54 +00:00
{
global $pref , $dlrow , $tp ;
$click = " " ;
if ( $pref [ 'agree_flag' ] == 1 ) {
2009-05-03 21:16:15 +00:00
$click = " onclick='return confirm( \" " . $tp -> toJS ( $tp -> toHTML ( $pref [ 'agree_text' ], true , 'emotes, no_tags' )) . " \" )' " ;
2009-02-11 21:41:54 +00:00
}
$dnld_link = " <a href=' " . e_BASE . " request.php? " . $dlrow [ 'download_id' ] . " ' { $click } > " ;
if ( $dlrow [ 'download_mirror' ])
{
if ( $dlrow [ 'download_mirror_type' ])
{
return " <a href=' " . e_PLUGIN . " download/download.php?mirror. " . $dlrow [ 'download_id' ] . " '> " . LAN_dl_66 . " </a> " ;
}
else
{
2009-07-25 07:54:36 +00:00
return $dnld_link . " <img src=' " . IMAGE_DOWNLOAD . " ' alt='*' /></a> " ;
2009-02-11 21:41:54 +00:00
}
}
else
{
2012-05-27 10:42:16 +00:00
return $dnld_link . " <img src=' " . IMAGE_DOWNLOAD . " ' alt='*' /></a> " ;
2009-02-11 21:41:54 +00:00
}
}
2009-07-21 07:10:25 +00:00
function sc_download_view_filesize ()
2009-02-11 21:41:54 +00:00
{
global $dlrow , $e107 ;
return ( $dlrow [ 'download_filesize' ]) ? $e107 -> parseMemorySize ( $dlrow [ 'download_filesize' ]) : " " ;
}
2009-07-21 07:10:25 +00:00
function sc_download_view_rating ()
2009-02-11 21:41:54 +00:00
{
2012-05-27 10:42:16 +00:00
global $dlrow ;
$frm = e107 :: getForm ();
$options = array ( 'label' => ' ' , 'template' => 'RATE|VOTES|STATUS' );
return $frm -> rate ( " download " , $dlrow [ 'download_id' ], $options );
2009-02-11 21:41:54 +00:00
require_once ( e_HANDLER . " rate_class.php " );
$rater = new rater ;
2012-05-27 10:42:16 +00:00
2009-02-11 21:41:54 +00:00
$text = "
< table style = 'width:100%' >
< tr >
< td style = 'width:50%' > " ;
if ( $ratearray = $rater -> getrating ( " download " , $dlrow [ 'download_id' ])) {
for ( $c = 1 ; $c <= $ratearray [ 1 ]; $c ++ ) {
2009-07-07 07:33:00 +00:00
$text .= " <img src=' " . e_IMAGE . " rate/star.png' alt='*' /> " ;
2009-02-11 21:41:54 +00:00
}
if ( $ratearray [ 2 ]) {
2009-07-07 07:33:00 +00:00
$text .= " <img src=' " . e_IMAGE . " rate/ " . $ratearray [ 2 ] . " .png' alt='*' /> " ;
2009-02-11 21:41:54 +00:00
}
if ( $ratearray [ 2 ] == " " ) {
$ratearray [ 2 ] = 0 ;
}
$text .= " " . $ratearray [ 1 ] . " . " . $ratearray [ 2 ] . " - " . $ratearray [ 0 ] . " " ;
$text .= ( $ratearray [ 0 ] == 1 ? LAN_dl_43 : LAN_dl_44 );
} else {
$text .= LAN_dl_13 ;
}
$text .= " </td><td style='width:50%; text-align:right'> " ;
if ( ! $rater -> checkrated ( " download " , $dlrow [ 'download_id' ]) && USER ) {
$text .= $rater -> rateselect ( " <b> " . LAN_dl_14 , " download " , $dlrow [ 'download_id' ]) . " </b> " ;
}
else if ( ! USER ) {
$text .= " " ;
} else {
$text .= LAN_dl_15 ;
}
$text .= " </td></tr></table> " ;
return $text ;
}
2009-07-21 07:10:25 +00:00
function sc_download_report_link ()
2009-02-11 21:41:54 +00:00
{
global $dlrow , $pref ;
return ( check_class ( $pref [ 'download_reportbroken' ])) ? " <a href=' " . e_PLUGIN . " download/download.php?report. " . $dlrow [ 'download_id' ] . " '> " . LAN_dl_45 . " </a> " : " " ;
}
2009-07-21 07:10:25 +00:00
function sc_download_view_caption ()
2009-02-11 21:41:54 +00:00
{
global $dlrow ;
$text = $dlrow [ 'download_category_name' ];
$text .= ( $dlrow [ 'download_category_description' ]) ? " [ " . $dlrow [ 'download_category_description' ] . " ] " : " " ;
return $text ;
}
// Mirror **************************************************************************************
2009-07-21 07:10:25 +00:00
function sc_download_mirror_request () {
2009-02-11 21:41:54 +00:00
global $dlrow ;
return $dlrow [ 'download_name' ];
2009-01-13 00:47:13 +00:00
}
2009-07-21 07:10:25 +00:00
function sc_download_mirror_request_icon () {
2009-02-11 21:41:54 +00:00
global $dlrow ;
2012-04-20 07:28:53 +00:00
$tp = e107 :: getParser ();
return ( $dlrow [ 'download_thumb' ] ? " <img src=' " . $tp -> replaceConstants ( $dlrow [ 'download_thumb' ]) . " ' alt='*'/> " : " " );
2009-01-13 00:47:13 +00:00
}
2009-07-21 07:10:25 +00:00
function sc_download_mirror_name () {
2009-02-11 21:41:54 +00:00
global $dlmirror ;
return " <a href=' { $dlmirror [ 'mirror_url' ] } ' rel='external'> " . $dlmirror [ 'mirror_name' ] . " </a> " ;
2009-01-13 00:47:13 +00:00
}
2009-07-21 07:10:25 +00:00
function sc_download_mirror_image () {
2009-02-11 21:41:54 +00:00
global $dlrow , $dlmirror ;
2012-04-20 07:28:53 +00:00
$tp = e107 :: getParser ();
return ( $dlmirror [ 'mirror_image' ] ? " <a href=' { $dlmirror [ 'mirror_url' ] } ' rel='external'><img src=' " . $tp -> replaceConstants ( $dlmirror [ 'mirror_image' ]) . " ' alt='*'/></a> " : " " );
2009-01-13 00:47:13 +00:00
}
2009-07-21 07:10:25 +00:00
function sc_download_mirror_location () {
2009-02-11 21:41:54 +00:00
global $dlmirror ;
return ( $dlmirror [ 'mirror_location' ] ? $dlmirror [ 'mirror_location' ] : " " );
2009-01-13 00:47:13 +00:00
}
2009-07-21 07:10:25 +00:00
function sc_download_mirror_description () {
2009-02-11 21:41:54 +00:00
global $dlmirror , $tp ;
return ( $dlmirror [ 'mirror_description' ] ? $tp -> toHTML ( $dlmirror [ 'mirror_description' ], TRUE ) : " " );
2009-01-13 00:47:13 +00:00
}
2009-07-21 07:10:25 +00:00
function sc_download_mirror_filesize () {
2009-02-11 21:41:54 +00:00
global $e107 , $dlmirrorfile ;
return $e107 -> parseMemorySize ( $dlmirrorfile [ 3 ]);
}
2009-07-21 07:10:25 +00:00
function sc_download_mirror_link () {
2009-02-11 21:41:54 +00:00
global $dlrow , $dlmirrorfile , $tp , $pref ;
$click = " onclick='return confirm( \" " . $tp -> toJS ( $tp -> toHTML ( $pref [ 'agree_text' ], FALSE , 'DESCRIPTION' )) . " \" )' " ;
return " <a href=' " . e_PLUGIN . " download/download.php?mirror. { $dlrow [ 'download_id' ] } . { $dlmirrorfile [ 0 ] } ' title=' " . LAN_dl_32 . " ' { $click } >
< img src = '".IMAGE_DOWNLOAD."' alt = '*' title = '".LAN_dl_32."' /></ a > " ;
}
2009-07-21 07:10:25 +00:00
function sc_download_mirror_requests () {
2009-02-11 21:41:54 +00:00
global $dlmirrorfile ;
return ( ADMIN ? LAN_dl_73 . $dlmirrorfile [ 2 ] : " " );
}
2009-07-21 07:10:25 +00:00
function sc_download_total_mirror_requests () {
2009-02-11 21:41:54 +00:00
global $dlmirror ;
return ( ADMIN ? LAN_dl_74 . $dlmirror [ 'mirror_count' ] : " " );
}
// --------- Download View Lans -----------------------------
2009-07-21 07:10:25 +00:00
function sc_download_view_author_lan ()
2009-02-11 21:41:54 +00:00
{
global $dlrow ;
return ( $dlrow [ 'download_author' ]) ? LAN_dl_24 : " " ;
}
2009-07-21 07:10:25 +00:00
function sc_download_view_authoremail_lan ()
2009-02-11 21:41:54 +00:00
{
global $dlrow ;
return ( $dlrow [ 'download_author_email' ]) ? LAN_dl_30 : " " ;
}
2009-07-21 07:10:25 +00:00
function sc_download_view_authorwebsite_lan ()
2009-02-11 21:41:54 +00:00
{
global $dlrow ;
return ( $dlrow [ 'download_author_website' ]) ? LAN_dl_31 : " " ;
}
2009-07-21 07:10:25 +00:00
function sc_download_view_date_lan ()
2009-02-11 21:41:54 +00:00
{
global $dlrow ;
return ( $dlrow [ 'download_datestamp' ]) ? LAN_dl_22 : " " ;
}
2009-07-21 07:10:25 +00:00
function sc_download_view_image_lan ()
2009-02-11 21:41:54 +00:00
{
return LAN_dl_11 ;
}
2009-07-21 07:10:25 +00:00
function sc_download_view_requested ()
2009-02-11 21:41:54 +00:00
{
global $dlrow ;
return $dlrow [ 'download_requested' ];
}
2009-07-21 07:10:25 +00:00
function sc_download_view_rating_lan ()
2009-02-11 21:41:54 +00:00
{
return LAN_dl_12 ;
}
2009-07-21 07:10:25 +00:00
function sc_download_view_filesize_lan ()
2009-02-11 21:41:54 +00:00
{
return LAN_dl_10 ;
}
2009-07-21 07:10:25 +00:00
function sc_download_view_description_lan ()
2009-02-11 21:41:54 +00:00
{
return LAN_dl_7 ;
}
2009-07-21 07:10:25 +00:00
function sc_download_view_requested_lan ()
2009-02-11 21:41:54 +00:00
{
return LAN_dl_77 ;
}
2009-07-21 07:10:25 +00:00
function sc_download_view_link_lan ()
2009-02-11 21:41:54 +00:00
{
return LAN_dl_32 ;
}
// ----------- Download View : Previous and Next ---------------
2009-07-21 07:10:25 +00:00
function sc_download_view_prev ()
2009-02-11 21:41:54 +00:00
{
global $dlrow , $sql ;
$dlrow_id = intval ( $dlrow [ 'download_id' ]);
if ( $sql -> db_Select ( " download " , " * " , " download_category=' " . intval ( $dlrow [ 'download_category_id' ]) . " ' AND download_id < { $dlrow_id } AND download_active > 0 && download_visible IN ( " . USERCLASS_LIST . " ) ORDER BY download_datestamp DESC LIMIT 1 " )) {
$dlrowrow = $sql -> db_Fetch ();
return " <a href=' " . e_PLUGIN . " download/download.php?view. " . $dlrowrow [ 'download_id' ] . " '><< " . LAN_dl_33 . " [ " . $dlrowrow [ 'download_name' ] . " ]</a> \n " ;
} else {
return " " ;
}
}
2009-07-21 07:10:25 +00:00
function sc_download_view_next ()
2009-02-11 21:41:54 +00:00
{
global $dlrow , $sql ;
$dlrow_id = intval ( $dlrow [ 'download_id' ]);
if ( $sql -> db_Select ( " download " , " * " , " download_category=' " . intval ( $dlrow [ 'download_category_id' ]) . " ' AND download_id > { $dlrow_id } AND download_active > 0 && download_visible IN ( " . USERCLASS_LIST . " ) ORDER BY download_datestamp ASC LIMIT 1 " )) {
$dlrowrow = $sql -> db_Fetch ();
extract ( $dlrowrow );
return " <a href=' " . e_PLUGIN . " download/download.php?view. " . $dlrowrow [ 'download_id' ] . " '>[ " . $dlrowrow [ 'download_name' ] . " ] " . LAN_dl_34 . " >></a> \n " ;
} else {
return " " ;
}
}
2009-07-21 07:10:25 +00:00
function sc_download_back_to_list ()
2009-02-11 21:41:54 +00:00
{
global $dlrow ;
return " <a href=' " . e_PLUGIN . " download/download.php?list. " . $dlrow [ 'download_category' ] . " '> " . LAN_dl_35 . " </a> " ;
}
2009-07-21 07:10:25 +00:00
function sc_download_back_to_category_list ()
2009-02-11 21:41:54 +00:00
{
return " <a href=' " . e_SELF . " '> " . LAN_dl_9 . " </a> " ;
}
// Misc stuff ---------------------------------------------------------------------------------
2009-07-21 07:10:25 +00:00
function sc_download_cat_newdownload_text ()
2009-02-11 21:41:54 +00:00
{
return " <img src=' " . IMAGE_NEW . " ' alt='*' style='vertical-align:middle' /> " . LAN_dl_36 ;
}
2009-07-21 07:10:25 +00:00
function sc_download_cat_search ()
2009-02-11 21:41:54 +00:00
{
2013-03-24 03:02:31 -07:00
return " <form class='form-search' method='get' action=' " . e_BASE . " search.php'>
2009-02-11 21:41:54 +00:00
< p >
2013-03-24 03:02:31 -07:00
< input class = 'tbox search-query' type = 'text' name = 'q' size = '30' value = '' maxlength = '50' />
< input class = 'btn button' type = 'submit' name = 's' value = '".LAN_dl_41."' />
2009-02-11 21:41:54 +00:00
< input type = 'hidden' name = 'r' value = '0' />
</ p >
</ form > " ;
}
/**
* @ private
*/
2009-07-21 07:10:25 +00:00
function _sc_cat_icons ( $source , $count , $alt )
2009-02-11 21:41:54 +00:00
{
if ( ! $source ) return " " ;
list ( $ret [ TRUE ], $ret [ FALSE ]) = explode ( chr ( 1 ), $source . chr ( 1 ));
if ( ! $ret [ FALSE ]) $ret [ FALSE ] = $ret [ TRUE ];
return " <img src=' " . e_IMAGE . " icons/ { $ret [( $count != 0 )] } ' alt='*'/> " ;
}
function _check_new_download ( $last_val )
{
if ( USER && ( $last_val > USERLV ))
{
return " <img src=' " . IMAGE_NEW . " ' alt='*' style='vertical-align:middle' /> " ;
}
else
{
return " " ;
}
}
}
?>