public function loadCssJs($type = 'web', $action = '') { if (YII_DEBUG) { $staticUrl = Yii::app()->baseUrl . '/'; } else { $_staticUrl = zmf::config('cssJsStaticUrl'); $staticUrl = $_staticUrl ? $_staticUrl : zmf::config('baseurl'); } $cs = Yii::app()->clientScript; $c = Yii::app()->getController()->id; $a = Yii::app()->getController()->getAction()->id; $cssDir = Yii::app()->basePath . '/../common/css'; $jsDir = Yii::app()->basePath . '/../common/js'; $cssArr = array(); $jsArr = array(); if ($type == 'web') { $cssArr = array('bootstrap', 'font-awesome', 'zmf'); $jsArr = array('bootstrap', 'zmf'); $cs->registerCoreScript('jquery'); } elseif ($type == 'mobile') { $cssArr = array('frozen', 'font-awesome'); $jsArr = array('zepto', 'frozen'); $cssArr[] = 'mobile'; $jsArr[] = 'mobile'; } elseif ($type == 'admin') { $cssArr = array('frozen'); $jsArr = array('zepto', 'frozen'); $cssArr[] = 'mobile'; $jsArr[] = 'mobile'; } $cssDirArr = zmf::readDir($cssDir, false); $jsDirArr = zmf::readDir($jsDir, false); foreach ($cssArr as $cssFileName) { foreach ($cssDirArr as $cssfile) { if (strpos($cssfile, $type . '-' . $cssFileName) !== false) { $cs->registerCssFile($staticUrl . 'common/css/' . $cssfile); } } } foreach ($jsArr as $jsFileName) { foreach ($jsDirArr as $jsfile) { if (strpos($jsfile, $type . '-' . $jsFileName) !== false) { if (strpos($jsfile, 'head') !== false) { $pos = CClientScript::POS_HEAD; } else { $pos = CClientScript::POS_END; } $cs->registerScriptFile($staticUrl . 'common/js/' . $jsfile, $pos); } } } }