<?php
/*
* 项目: iOrange(橘子)
* 作者: 离家出走(yzxh24)
* Email: yzxh24@gmail.com
* 主页: www.iorange.cc
*/
/* vim: set ts=4 sw=4: */
class Bcarts extends Model
{
    public static function table()
    {
        return 'ig_bcart';
    }

	public static function single($className = __CLASS__)
	{
		if (!isset(self::$_self[$className]))
		{
			self::$_self[$className] = new $className;
		}

		return self::$_self[$className];
	}

    public static function getScore($bcart)
    {
        if (!$bcart['score'] || !$bcart['scores'])
        {
            return '暂无评分';
        }

        $round = round($bcart['score'] / $bcart['scores']);
        switch ($round)
        {
            case 5:
                $img = printImage('1.gif') . printImage('1.gif') . printImage('1.gif') . printImage('1.gif'). printImage('1.gif') . '(非常好)';
                break;
            case 4:
                $img = printImage('1.gif') . printImage('1.gif') . printImage('1.gif') . printImage('1.gif') . '(不错)';
                break;
            case 3:
                $img = printImage('1.gif') . printImage('1.gif') . printImage('1.gif') . '(还行)';
                break;
            case 2:
                $img = printImage('1.gif') . printImage('1.gif') . '(一般般)';
                break;
            case 1:
            default:
                $img = printImage('1.gif') . '(纯支持)';
                break;
        }

        return $img;
    }
}
