/** * @param CM_Frontend_Render $render * @throws CM_Exception */ public function __construct(CM_Frontend_Render $render) { parent::__construct($render); $this->addVariables(); $file = new CM_File(DIR_PUBLIC . 'static/css/library/icon.less'); if ($file->exists()) { $this->add($file->read()); } foreach (array_reverse($render->getSite()->getModules()) as $moduleName) { foreach (array_reverse($render->getSite()->getThemes()) as $theme) { foreach (CM_Util::rglob('*.less', $render->getThemeDir(true, $theme, $moduleName) . 'css/') as $path) { $file = new CM_File($path); $this->add($file->read()); } } } $viewClasses = CM_View_Abstract::getClassChildren(true); foreach ($viewClasses as $viewClassName) { $validModule = in_array(CM_Util::getNamespace($viewClassName), $render->getSite()->getModules()); $validViewClass = $this->_isValidViewClass($viewClassName); if ($validModule && $validViewClass) { $asset = new CM_Asset_Css_View($this->_render, $viewClassName); $this->add($asset->_getContent()); } } }
public function __construct($params = null) { parent::__construct($params); $className = get_class($this); if (!preg_match('/^\\w+_Form_(.+)$/', $className, $matches)) { throw new CM_Exception('Cannot detect namespace from form\'s classname', null, ['className' => $className]); } $name = lcfirst($matches[1]); $name = preg_replace('/([A-Z])/', '_\\1', $name); $name = strtolower($name); $this->_name = $name; $this->_initialize(); }
/** * @param CM_View_Abstract $view * @param string $templateName * @throws CM_Exception * @return string|null */ public function getTemplatePath(CM_View_Abstract $view, $templateName) { $templateName = (string) $templateName; foreach ($view->getClassHierarchy() as $className) { if (!preg_match('/^([a-zA-Z]+)_([a-zA-Z]+)_(.+)$/', $className, $matches)) { throw new CM_Exception('Cannot detect namespace/view-class/view-name for className:`' . $className . '` templateName: `' . $templateName . '`.'); } $templatePathRelative = $matches[2] . DIRECTORY_SEPARATOR . $matches[3] . DIRECTORY_SEPARATOR . $templateName . '.tpl'; $namespace = $matches[1]; if ($templatePath = $this->getLayoutPath($templatePathRelative, $namespace, null, false, false)) { return $templatePath; } } return null; }
public function __construct($params = null) { parent::__construct($params); $this->_name = $this->_params->getString('name', uniqid()); $this->_initialize(); }