<?php

class ACMS_GET_Admin_Category_Name extends ACMS_GET
{
    function get()
    {
        $Tpl = new Template($this->tpl, new ACMS_Corrector());

        $categoryId = idval((string) CID);
        if ($categoryId > 0) {
            $DB  = DB::singleton(dsn());
            $SQL = SQL::newSelect('category');
            $SQL->setSelect('category_name');
            $SQL->addWhereOpr('category_id', $categoryId);
            $SQL->addWhereOpr('category_blog_id', BID);
            $name = strval($DB->query($SQL->get(dsn()), 'one'));
            if ($name !== '') {
                $Tpl->add(null, ['cid' => $categoryId, 'name' => $name]);
            }
        }
        return $Tpl->get();
    }
}
