private function parsing() { $style_ini = $this->stylePath . '/style.ini'; if (!file_exists($style_ini)) { Brightery::error_message($style_ini . " is missed."); } $this->styleAssets = parse_ini_file($style_ini, true); }
/** * Render * @param string $template * @param array $params * @return mixed */ public function render($template, $params = []) { if (!$this->twig) { $this->stylePath = STYLES . '/' . $this->interface . '/' . $this->styleName . '/'; $this->moduleStylePath = APPLICATION . '/' . 'modules' . '/' . Brightery::$RunningModule . '/' . 'views' . '/' . $this->interface . '/'; $viewPath[] = ROOT; // CHECK IF THERE'S A MAIN TEMPLATE if ($base = file_exists($this->stylePath . $template . '.twig')) { $viewPath[] = $this->stylePath; } if ($modules = file_exists($this->moduleStylePath . $template . '.twig')) { $viewPath[] = $this->moduleStylePath; } if (!$modules && !$base) { Brightery::error_message("The view file " . $template . " doesn't exist."); } $loader = new Twig_Loader_Filesystem($viewPath); $this->twig = new Twig_Environment($loader, ['autoescape' => false]); $this->twig->addExtension(new Twig_Extension_Text()); $this->twig->addExtension(new Twig_Extension_Debug()); $this->twig->addFilter(new Twig_SimpleFilter('cast_to_array', function ($stdClassObject) { $response = []; foreach ($stdClassObject as $key => $value) { $response[$key] = $value; } return $response; })); $this->twig->addFilter(new Twig_SimpleFilter('debug', function ($stdClassObject) { print_r($stdClassObject); })); } $params['this'] = Brightery::SuperInstance(); $params = array_merge($params, $this->layoutParams); $layout = $this->twig->render('styles/' . $this->interface . '/' . $this->styleName . '/layout/' . $this->layout . '.twig', $params); return str_replace("{layout}", $this->twig->render($template . '.twig', $params), $layout); }
public function library($file, $instance = null) { $file = ucfirst($file); if (!$instance) { $instance = $file; } if (in_array($file, $this->_libraries)) { // SYSTEM LIBRARY $this->importFile(SYSTEM_PATH . '/libraries/' . $file . '.php'); if ($inherited = file_exists($extension = APPLICATION_PATH . '/libraries/' . self::$configurations['Config']['core_extension_prefix'] . $file . '.php')) { $this->importFile($extension); } $this->getInstance($inherited ? self::$configurations['Config']['core_extension_prefix'] . $file : $file, [], $instance); } else { // CUSTOM LIBRARY if (file_exists($extension = APPLICATION_PATH . '/libraries/' . $file . '.php')) { $this->importFile($extension); } else { return Brightery::error_message("Can't find the library file " . $file); } $this->getInstance($file, [], $instance); } }
private function validate_field($model, $field, $rule, $options = null) { $_rule = "_" . $rule; if (is_array($options)) { $params = array_merge([$field], $options); } else { $params = [$field]; } if (method_exists($model, $_rule)) { if (!call_user_func_array([$model, $_rule], $params)) { $this->errors++; $this->error_messages[$field] = sprintf($this->getSystemValidationMessages($rule), isset($this->fields[$field]) ? $this->fields[$field] : $field); } } elseif (method_exists($this, $_rule)) { if (!call_user_func_array([$this, $_rule], $params)) { $this->errors++; $this->error_messages[$field] = sprintf($this->getSystemValidationMessages($rule), isset($this->fields[$field]) ? $this->fields[$field] : $field); } } else { return Brightery::error_message("This validation rule \"{$rule}\" is not exists.", "Validation"); } }