<?php
/**
 * Copyright (C) LJCMS All rights reserved.
 * <E-Mail：aspcms@qq.com>
 * Url http://www.liangjing.org
 *     http://www.8CMS.com
 * Update 2016.03.19
 */

class sitemapAModel extends X {
    
    public function getLastList($mod, $num) {
        $sql = "";
        if ($mod == "product") {
            $sql = "SELECT v.productid AS id, v.addtime, c.dirname".
                    " FROM ".DB_PREFIX."product AS v";
        }
        elseif ($mod == "article") {
            $sql = "SELECT v.articleid AS id, v.addtime, c.dirname".
                " FROM ".DB_PREFIX."article AS v";
        }
        elseif ($mod == "photo") {
            $sql = "SELECT v.photoid AS id, v.addtime, c.dirname".
                " FROM ".DB_PREFIX."photo AS v";
        }
        elseif ($mod == "download") {
            $sql = "SELECT v.downid AS id, v.addtime, c.dirname".
                " FROM ".DB_PREFIX."download AS v";
        }
        else {
            $sql = "SELECT v.hrid AS id, v.addtime, c.dirname".
                " FROM ".DB_PREFIX."hr AS v";
        }
        $sql .= " LEFT JOIN ".DB_PREFIX."category AS c ON v.catid=c.catid".
                    " ORDER BY `id` DESC LIMIT 0, {$num}";
        $data = parent::$obj->getall($sql);
        foreach ($data as $key=>$value) {
            $data[$key]['url'] = $this->_rqUrl($mod, $value['dirname'], $value['id']);
        }
        return $data;
    }

    
    private function _rqUrl($module, $catalog, $id) {
        if (parent::$cfg['urlsuffix'] == 'php') {
            return parent::$cfg['siteurl'].'index.php?c='.$module.'&a=detail&id='.$id;
        }
        else {
            return parent::$cfg['siteurl'].$catalog.'/'.$id.'.html';
        }
    }
}
?>
