<?php


if (!defined('IN_CONTEXT')) die('access violation error!');

/**
 * Module block object
 *
 */
class Template extends RecordObject {
    public $belong_to = array('TemplateCategory');

    public static function &allRemoteTemplates($cateid) {
        $client =& Toolkit::initSoapClient();
        $templates = unserialize($client->getAvailableTpls(EZSITE_UID, $cateid, EZSITE_LEVEL));
        return $templates;
    }

    public static function &getMyTemplates($cateid) {
        $rearranged = array();
        $o_tpl = new Template();
        $templates =& $o_tpl->findAll("template_category_id=?", array($cateid), "ORDER BY id");
        if (sizeof($templates) > 0) {
            foreach ($templates as $template) {
                $curr_tpl['id'] = $template->id;
                $curr_tpl['name'] = $template->template;
                $curr_tpl['screenshot_url'] = Toolkit::fixpic('../template/'.$template->template.'/screenshot.jpg');
                $rearranged[] = $curr_tpl;
            }
        }

        return $rearranged;
    }
}
?>
