<?php
//v1.0.4 www.bcoos.net 2006/10 GPL
//v1.2 www.exoops.info 2006/03 
// $Id: mysections_top.php,v 1.1 2004/03/20 18:35:12 greyhead Exp $
// ------------------------------------------------------------------------- //
//               E-Xoops: Content Management for the Masses                  //
//                       < http://www.e-xoops.com >                          //
// ------------------------------------------------------------------------- //
// Original Author: Half-Dead
// Author Website : http://www.e-xoops.com
// License Type   : GPL: See /manual/LICENSES/GPL.txt
// ------------------------------------------------------------------------- //
// Passed on      : My Downloads
// New module name: My Sections
// Version        : 1.1
// Modified by    : Faisal
// Website        : < http://www.a-xoops.com >
// Email          : info@a-xoops.com
// ------------------------------------------------------------------------- //
//---------------------------------------------------------------------------------------//
/**
* Description
*
* @param type $var description
* @return type description
*/
function b_mysections_top_show($options) {
global $db, $myts;
$block  = array();
if (!empty($options[4]) && is_numeric($options[4])) {
        $extra = "AND cid=".$options[4];
}
$sql    = "
                SELECT lid, title, date, counter
                FROM ".$db->prefix("mysections_articles")."
                WHERE status>0 $extra ORDER BY ".$options[0]." DESC";
if ( empty($options[3]) || !is_numeric($options[3]) ) {
        $options[3] = 5;
}
if ( empty($options[2]) || !is_numeric($options[2]) ) {
        $options[2] = 35;
}
$block['content'] = "";
$result = $db->query($sql, $options[3], 0);
while ( list($lid, $title, $date, $counter) = $db->fetchRow($result) ) {
        $title = $myts->makeTboxData4Show($title);
        if ( strlen($title) > $options[2] ) {
                $title = substr($title, 0, $options[2])."..";
        }
        $block['content'] .= "
                        &nbsp;<strong><big>&middot;</big></strong>
                        <a href='".XOOPS_URL."/modules/mysections/singlefile.php?lid=".$lid."'>$title</a>";
        if ($options[0] == "date") {
                $block['title'] = _MB_MYSECTIONS_TITLE1;
                if ($options[1] == 1) {
                        $block['content'] .= " (".formatTimestamp($date, "s").")";
                        }
                $block['content'] .= "<br />";
                } elseif ($options[0] == "counter") {
                        $block['title'] = _MB_MYSECTIONS_TITLE2;
                        if ($options[1] == 1) {
                                $block['content'] .= " (".$counter.")";
                                }
                        $block['content'] .= "<br />";
                }
        }
return $block;
}
//---------------------------------------------------------------------------------------//
/**
* Description
*
* @param type $var description
* @return type description
*/
function b_mysections_top_edit($options) {
global $db;
$form   = "<input type='hidden' name='options[0]' value='".$options[0]."' />";
$form  .= "<table border='0'>";
// Show Date/counter?
$form .= "<tr><td>"._MB_MYSECTIONS_SHOW." "._MB_COUNTER.":</td><td>";
$chk   = "";
if ($options[1] == 0) {
        $chk = " checked='checked'";
        }
$form .= "<input type='radio' class='radio' name='options[1]' value='0'".$chk." />"._NO."";
$chk   = "";
if ($options[1] == 1) {
        $chk = " checked='checked'";
        }
$form .= "<input type='radio' class='radio' name='options[1]' value='1'".$chk." />"._YES."</td></tr>";
// TRIM
$form .= "
<tr><td>"._MB_MYSECTIONS_TRIM."</td>
<td><input type='text' class='text' size='3' maxlength='2' name='options[2]' value='".$options[2]."'></td>
</tr>";
// LIMIT TO
$form .= "
<tr><td>"._LIMIT."</td>
<td><input type='text' class='text' name='options[3]' value='".$options[3]."' size='3' maxlength='2' /></td>
</tr>";
// LIMIT TO CATS
include_once(XOOPS_ROOT_PATH."/class/xoopstree.php");
$cats = new XoopsTree($db->prefix("mysections_cat"), "cid", "pid");
ob_start();
$cats->makeMySelBox("title", "title", $options[4], 1, "options[4]");
$content = ob_get_contents();
ob_end_clean();
$form .= "
<tr><td>"._LIMIT."</td>
<td>$content</td>
</tr>";
$form .= "</table>";
return $form;
}
?>