Exemple #1
0
function formDownloads()
{
    $module_handler =& xoops_gethandler('module');
    $xoModule = $module_handler->getByDirname('vidshop');
    $config_handler =& xoops_gethandler('config');
    $xoConfigs = $config_handler->getConfigList($xoModule->getVar('mid'));
    $videoHandler =& xoops_getmodulehandler('video', 'vidshop');
    $downloadsHandler =& xoops_getmodulehandler('video_downloads', 'vidshop');
    if (is_object($GLOBALS['xoopsUser'])) {
        $session['uid'] = $GLOBALS['xoopsUser']->getVar('uid');
    } else {
        $session['uid'] = 0;
    }
    $session['ip'] = $_SERVER['REMOTE_ADDR'];
    $session['addy'] = gethostbyaddr($_SERVER['REMOTE_ADDR']);
    $criteria = new CriteriaCompo(new Criteria('ip', $session['ip']), 'AND');
    $criteria->add(new Criteria('addy', $session['addy']), 'AND');
    if ($session['uid'] > 0) {
        $criteria->add(new CriteriaCompo(new Criteria('uid', $session['uid']), 'OR'), 'OR');
    }
    if (isset($_COOKIE['vidshop']['key'])) {
        $criteria->add(new CriteriaCompo(Criteria('key', $_COOKIE['vidshop']['key']), 'OR'), 'OR');
    }
    $items = $downloadsHandler->getAll($criteria);
    $lform = new XoopsThemeForm(_VSP_FRM_CART_LIST, 'videocartlist');
    $lform->setExtra('enctype="multipart/form-data"');
    foreach ($items as $key => $item) {
        $video = $videoHandler->get($item->getVar('vid'));
        $lele[$key] = new XoopsFormElementTray(sprintf(_VSP_ELE_VIDSHOP_LIST, $video->getVar('id')));
        $lele[$key]->setDescription($video->getVar('name'));
        $lele[$key]->addElement(new XoopsFormLabel('', '<a href="' . $xoConfigs['download_spot'] . '/' . $item->getVar('download') . '">Download</a>'));
        $lele[$key]->addElement(new XoopsFormLabel('', 'Price: ' . $video->getVar('price') . ' ' . $video->getVar('currency')));
        $lform->addElement($lele[$key]);
    }
    return $lform->render();
}
//$modversion['onUpdate'] = "include/update.php";
$videoHandler =& xoops_getmodulehandler('video_category', 'vidshop');
$criteria = new CriteriaCompo(new Criteria('weight', '0', '>'));
$criteria->setOrder('weight');
$videoCats = $videoHandler->getObjects($criteria, true);
$ii++;
$modversion['sub'][$ii]['name'] = _VSP_SHOPPING_CART;
$modversion['sub'][$ii]['url'] = "cart.php";
$downloadsHandler =& xoops_getmodulehandler('video_downloads', 'vidshop');
$criteria = new CriteriaCompo(new Criteria('ip', $session['ip']), 'AND');
$criteria->add(new Criteria('addy', $session['addy']), 'AND');
if ($session['uid'] > 0) {
    $criteria->add(new CriteriaCompo(new Criteria('uid', $session['uid']), 'OR'), 'OR');
}
if (isset($_COOKIE['vidshop']['key'])) {
    $criteria->add(new CriteriaCompo(Criteria('key', $_COOKIE['vidshop']['key']), 'OR'), 'OR');
}
if ($downloadsHandler->getCount($criteria) > 0) {
    $ii++;
    $modversion['sub'][$ii]['name'] = _VSP_SHOPPING_DOWNLOADS;
    $modversion['sub'][$ii]['url'] = "downloads.php";
}
if (is_array($videoCats)) {
    foreach ($videoCats as $id => $videocat) {
        $ii++;
        $modversion['sub'][$ii]['name'] = $videocat->getVar('name');
        $modversion['sub'][$ii]['url'] = "index.php?op=cat&cid=" . $id;
    }
}
// Templates
$modversion['templates'] = array();