2009-02-11 21:41:54 +00:00
< ? php
/*
2009-09-18 19:07:09 +00:00
+ ----------------------------------------------------------------------------+
| e107 website system
|
| Copyright ( c ) e107 Inc . 2001 - 2009
| http :// e107 . org
|
| Released under the terms and conditions of the
| GNU General Public License ( http :// gnu . org ) .
|
| $Source : / cvs_backup / e107_0 . 8 / e107_plugins / download / handlers / download_class . php , v $
| $Revision : 1.4 $
| $Date : 2009 - 09 - 18 19 : 07 : 09 $
| $Author : e107coders $
+----------------------------------------------------------------------------+
2009-02-11 21:41:54 +00:00
*/
2009-09-17 20:38:20 +00:00
if ( ! e107 :: isInstalled ( 'download' )) { exit (); }
2009-02-11 21:41:54 +00:00
class download
{
2009-05-03 21:16:15 +00:00
var $e107 ;
2009-02-11 21:41:54 +00:00
function download ()
{
2009-05-03 21:16:15 +00:00
$this -> e107 = e107 :: getInstance ();
2009-02-11 21:41:54 +00:00
}
function displayCategoryList () {
}
function getBreadcrumb ( $arr )
{
$dlbreadcrumb = array ();
$ix = 0 ;
foreach ( $arr as $key => $crumb ) {
$dlbreadcrumb [ $ix ][ 'sep' ] = " :: " ;
$ix ++ ;
if ( is_int ( $key ))
{
$dlbreadcrumb [ $ix ][ 'value' ] = $crumb ;
}
else
{
$dlbreadcrumb [ $ix ][ 'value' ] = " <a href=' { $crumb } '> " . $key . " </a> " ;
}
}
$dlbreadcrumb [ 'fieldlist' ] = implode ( " , " , array_keys ( $dlbreadcrumb ));
return $dlbreadcrumb ;
}
2009-05-03 21:16:15 +00:00
function getCategorySelectList ( $currentID = 0 , $incSubSub = true , $groupOnMain = true , $blankText = " " , $name = " download_category " )
2009-02-11 21:41:54 +00:00
{
global $sql , $parm ;
$boxinfo = " \n " ;
$qry = "
SELECT dc . download_category_name , dc . download_category_order , dc . download_category_id , dc . download_category_parent ,
dc1 . download_category_parent AS d_parent1
FROM #download_category AS dc
LEFT JOIN #download_category as dc1 ON dc1.download_category_id=dc.download_category_parent AND dc1.download_category_class IN (".USERCLASS_LIST.")
LEFT JOIN #download_category as dc2 ON dc2.download_category_id=dc1.download_category_parent ";
if ( ADMIN === FALSE ) $qry .= " WHERE dc.download_category_class IN ( " . USERCLASS_LIST . " ) " ;
$qry .= " ORDER by dc2.download_category_order, dc1.download_category_order, dc.download_category_order " ; // This puts main categories first, then sub-cats, then sub-sub cats
if ( ! $sql -> db_Select_gen ( $qry ))
{
return " Error reading categories<br /> " ;
exit ;
}
2009-05-03 21:16:15 +00:00
$boxinfo .= " <select name=' { $name } ' id='download_category' class='tbox'>
2009-02-11 21:41:54 +00:00
< option value = '' > { $blankText } </ option > \n " ;
// Its a structured display option - need a 2-step process to create a tree
$catlist = array ();
while ( $dlrow = $sql -> db_Fetch ( MYSQL_ASSOC ))
{
$tmp = $dlrow [ 'download_category_parent' ];
if ( $tmp == '0' )
{
$dlrow [ 'subcats' ] = array ();
$catlist [ $dlrow [ 'download_category_id' ]] = $dlrow ;
}
else
{
if ( isset ( $catlist [ $tmp ]))
{ // Sub-Category
$catlist [ $tmp ][ 'subcats' ][ $dlrow [ 'download_category_id' ]] = $dlrow ;
$catlist [ $tmp ][ 'subcats' ][ $dlrow [ 'download_category_id' ]][ 'subsubcats' ] = array ();
}
else
{ // Its a sub-sub category
if ( isset ( $catlist [ $dlrow [ 'd_parent1' ]][ 'subcats' ][ $tmp ]))
{
$catlist [ $dlrow [ 'd_parent1' ]][ 'subcats' ][ $tmp ][ 'subsubcats' ][ $dlrow [ 'download_category_id' ]] = $dlrow ;
}
}
}
}
// Now generate the options
foreach ( $catlist as $thiscat )
{ // Main categories
if ( count ( $thiscat [ 'subcats' ]) > 0 )
{
if ( $groupOnMain )
{
$boxinfo .= " <optgroup label=' " . htmlspecialchars ( $thiscat [ 'download_category_name' ]) . " '> " ;
$scprefix = '' ;
}
else
{
$boxinfo .= " <option value=' " . $thiscat [ 'download_category_id' ] . " ' " ;
if ( $currentID == $thiscat [ 'download_category_id' ]) {
$boxinfo .= " selected='selected' " ;
}
$boxinfo .= " > " . htmlspecialchars ( $thiscat [ 'download_category_name' ]) . " </option> \n " ;
$scprefix = ' ' ;
}
foreach ( $thiscat [ 'subcats' ] as $sc )
{ // Sub-categories
$sscprefix = '--> ' ;
$boxinfo .= " <option value=' " . $sc [ 'download_category_id' ] . " ' " ;
if ( $currentID == $sc [ 'download_category_id' ]) {
$boxinfo .= " selected='selected' " ;
}
$boxinfo .= " > " . $scprefix . htmlspecialchars ( $sc [ 'download_category_name' ]) . " </option> \n " ;
if ( $incSubSub )
{ // Sub-sub categories
foreach ( $sc [ 'subsubcats' ] as $ssc )
{
$boxinfo .= " <option value=' " . $ssc [ 'download_category_id' ] . " ' " ;
if ( $currentID == $ssc [ 'download_category_id' ]) { $boxinfo .= " selected='selected' " ; }
$boxinfo .= " > " . htmlspecialchars ( $sscprefix . $ssc [ 'download_category_name' ]) . " </option> \n " ;
}
}
}
if ( $groupOnMain )
{
$boxinfo .= " </optgroup> \n " ;
}
}
else
{
$sel = ( $currentID == $thiscat [ 'download_category_id' ]) ? " selected='selected' " : " " ;
$boxinfo .= " <option value=' " . $thiscat [ 'download_category_id' ] . " ' { $sel } > " . htmlspecialchars ( $thiscat [ 'download_category_name' ]) . " </option> \n " ;
}
}
$boxinfo .= " </select> \n " ;
return $boxinfo ;
}
}
?>