<?php
/*
* @package LabCMS
* @copyright (c) 2006 Alexander Levin aka Loki (loki_angel@mail.ru)
* @support http://labcms.ru
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
*/

abstract class ModuleTools
{
	protected static function _assign($key, $var=null)
	{
		if (is_array($key)) Tpl::i()->assign($key);
		else Tpl::i()->assign($key, $var);
	}
	
	protected static function _assignByRef($key, $var=null)
	{
		return Tpl::i()->assignByRef($key, $var);
	}
	
	protected static function _setTpl($tpl='', $strict=false)
	{
		if ($tpl && !$strict) $tpl.=".tpl";
		if ($tpl) LabCMS::i()->setModuleTemplate($tpl);
		else LabCMS::i()->setModuleTemplate('');
	}
	
	protected static function _getTpl()
	{
		return LabCMS::i()->getModuleTemplate();
	}
	
	protected static function _debug($var, $module=null, $color=null, $tip=null)
	{
		if (!$module) $module=LabCMS::i()->getModuleName();
		Debug_HackerConsole_Main::out($var, $module, $color, $tip);
	}
	
	protected static function _error($msg, $lang=false)
	{
		return LabCMS::i()->error($msg, $lang);
	}

	protected function _renderForm($form)
	{
		$renderer = HTML_QuickForm2_Renderer::factory(config::get('core.form_renderer'));
		$renderer=$form->render($renderer);
		LabCMS::i()->skins[LabCMS::i()->getSkin()]['js']=
			LabCMS::i()->skins[LabCMS::i()->getSkin()]['js']
			+$renderer->getJSLibs(false, false);
		return $renderer;
	}
}