Example #1
1
 /**
  * Add language keys to Javascript. To add several keys, you can call one time this function, each parameters
  * being a language key that wille be added to JavaScript
  *
  * @param string ...$keys The keys to add
  *
  * @deprecated since version 0.7.0, use Controller::addKeysToJavascript instead
  */
 public static function addKeysToJavascript(...$keys)
 {
     $script = "";
     foreach ($keys as $key) {
         list($plugin, $langKey) = explode(".", $key);
         $script .= "Lang.set('{$key}', '" . addcslashes(self::get($key), "'") . "');";
     }
     App::router()->getCurrentController()->addJavaScriptInline($script);
 }
Example #2
0
 public static function run($uri)
 {
     self::$router = new Router($uri);
     # создаем обект базы данных и передаем параметры подключения
     self::$db = new DB(Config::get('db.host'), Config::get('db.user'), Config::get('db.password'), Config::get('db.db_name'));
     Lang::load(self::$router->getLanguage());
     $controller_class = ucfirst(self::$router->getController()) . 'Controller';
     $controller_method = strtolower(self::$router->getMethodPrefix() . self::$router->getAction());
     # при каждом запросе к руту admin выполняется проверка, имеет ли пользователь на это права
     $layout = self::$router->getRoute();
     if ($layout == 'admin' && Session::get('role') != 'admin') {
         if ($controller_method != 'admin_login') {
             Router::redirect('/admin/users/login');
         }
     }
     // Calling controller's method
     $controller_object = new $controller_class();
     if (method_exists($controller_object, $controller_method)) {
         $view_path = $controller_object->{$controller_method}();
         $view_object = new View($controller_object->getData(), $view_path);
         $content = $view_object->render();
     } else {
         throw new Exception('Method ' . $controller_method . ' of class ' . $controller_class . ' does not exist.');
     }
     # код віполняющий рендеринг
     $layout_path = VIEWS_PATH . DS . $layout . '.html';
     $layout_view_object = new View(compact('content'), $layout_path);
     echo $layout_view_object->render();
 }
Example #3
0
 public static function run($uri)
 {
     self::$router = new Router($uri);
     self::$db = new DB(config::get('db.host'), config::get('db.name'), config::get('db.user'), config::get('db.password'));
     Lang::load(self::$router->getLanguage());
     if ($_POST and (isset($_POST['username_in']) and isset($_POST['password_in'])) or isset($_POST['exit'])) {
         $us = new RegisterController();
         if (isset($_POST['exit'])) {
             $us->LogOut();
         } else {
             $us->Login($_POST);
         }
     }
     if (self::$router->getController() == 'admin' and !Session::getSession('root') or self::$router->getController() == 'myblog' and !Session::getSession('id')) {
         self::$router->setController(Config::get('default_controller'));
         self::$router->setAction(Config::get('default_action'));
         Session::setSession('message', 'Отказ в доступе');
     }
     $controller_class = ucfirst(self::$router->getController()) . 'Controller';
     $controller_method = strtolower(self::$router->getMethodPrefix() . self::$router->getAction());
     $controller_object = new $controller_class();
     if (method_exists($controller_object, $controller_method)) {
         $controller_object->{$controller_method}();
         $view_object = new View($controller_object->getData());
         $content = $view_object->render();
     } else {
         throw new Exception('Method ' . $controller_method . ' of class ' . $controller_class . ' does not exist');
     }
     $layout = self::$router->getRoute();
     $layout_path = VIEWS_PATH . DS . $layout . '.html';
     $layout_view_object = new View(compact('content'), $layout_path);
     echo $layout_view_object->render();
 }
Example #4
0
 /**
  * Display the widget
  *
  * @return string The generated HTML
  */
 public function display()
 {
     $plugin = $this->plugin;
     $installer = $plugin->getInstallerInstance();
     $buttons = array(ButtonInput::create(array('icon' => 'share icon-flip-horizontal', 'class' => 'btn-default btn-block', 'href' => App::router()->getUri('manage-plugins'), 'label' => Lang::get('main.back-button'))));
     if (isset($updates[$plugin->getName()])) {
         $buttons[] = ButtonInput::create(array('icon' => 'refresh', 'class' => 'btn-info update-plugin btn-block', 'label' => Lang::get($this->_plugin . '.update-plugin-button'), 'href' => App::router()->getUri('update-plugin', array('plugin' => $plugin->getName()))));
     }
     if (!$plugin->isInstalled()) {
         // the plugin is not installed
         // Install button
         $buttons[] = ButtonInput::create(array('label' => Lang::get($this->_plugin . '.install-plugin-button'), 'icon' => 'upload', 'class' => 'install-plugin btn-block', 'href' => App::router()->getUri('install-plugin', array('plugin' => $plugin->getName()))));
         // Delete button
         $buttons[] = ButtonInput::create(array('label' => Lang::get($this->_plugin . '.delete-plugin-button'), 'icon' => 'trash', 'class' => 'btn-danger delete-plugin btn-block', 'href' => App::router()->getUri('delete-plugin', array('plugin' => $plugin->getName()))));
     } elseif (!$plugin->isActive()) {
         // The plugin is installed but not activated
         // Activate button
         $buttons[] = ButtonInput::create(array('label' => Lang::get($this->_plugin . '.activate-plugin-button'), 'class' => 'btn-success activate-plugin btn-block', 'icon' => 'check', 'href' => App::router()->getUri('activate-plugin', array('plugin' => $plugin->getName()))));
         // Settings button
         if (method_exists($installer, 'settings')) {
             $buttons[] = ButtonInput::create(array('icon' => 'cogs', 'label' => Lang::get($this->_plugin . '.plugin-settings-button'), 'href' => App::router()->getUri('plugin-settings', array('plugin' => $plugin->getName())), 'target' => 'dialog', 'class' => 'btn-info btn-block'));
         }
         // Uninstall button
         $buttons[] = ButtonInput::create(array('label' => Lang::get($this->_plugin . '.uninstall-plugin-button'), 'class' => 'btn-danger uninstall-plugin btn-block', 'icon' => 'chain-broken', 'href' => App::router()->getUri('uninstall-plugin', array('plugin' => $plugin->getName()))));
     } else {
         // The plugin is installed and active
         // Settings button
         if (method_exists($installer, 'settings')) {
             $buttons[] = ButtonInput::create(array('icon' => 'cogs', 'label' => Lang::get($this->_plugin . '.plugin-settings-button'), 'href' => App::router()->getUri('plugin-settings', array('plugin' => $plugin->getName())), 'target' => 'dialog', 'class' => 'btn-info btn-block'));
         }
         $buttons[] = ButtonInput::create(array('label' => Lang::get($this->_plugin . '.deactivate-plugin-button'), 'class' => 'btn-warning deactivate-plugin btn-block', 'icon' => 'ban', 'href' => App::router()->getUri('deactivate-plugin', array('plugin' => $plugin->getName()))));
     }
     return View::make($this->getPlugin()->getView('plugin-details-actions.tpl'), array('buttons' => $buttons));
 }
Example #5
0
 public static function run($uri)
 {
     self::$router = new Router($uri);
     self::$db = new DB(Config::get('db.host'), Config::get('db.user'), Config::get('db.password'), Config::get('db.db_name'));
     Lang::load(self::$router->getLanguage());
     $controller_class = ucfirst(self::$router->getController()) . "Controller";
     $controller_method = strtolower(self::$router->getMethodPrefix() . self::$router->getAction());
     $layout = self::$router->getRoute();
     if ($layout == "admin" && Session::get("role") != "admin") {
         if ($controller_method != "admin_login") {
             Router::redirect("/admin/users/login");
         }
     }
     //Calling controller's method
     $controller_object = new $controller_class();
     if (method_exists($controller_object, $controller_method)) {
         $view_path = $controller_object->{$controller_method}();
         $view_object = new View($controller_object->getData(), $view_path);
         $content = $view_object->render();
     } else {
         throw new Exception("Method {$controller_method} does not exist in {$controller_class}");
     }
     $layout_path = VIEWS_PATH . DS . $layout . ".html";
     $layout_view_object = new View(compact('content'), $layout_path);
     echo $layout_view_object->render();
 }
Example #6
0
 public static function run($uri)
 {
     self::$router = new Router($uri);
     self::$db = DB::getInstance(Config::get('db.host'), Config::get('db.user'), Config::get('db.password'), Config::get('db.db_name'));
     Lang::load(self::$router->getLanguage());
     $controller_class = ucfirst(self::$router->getController()) . 'controller';
     $controller_method = strtolower(self::$router->getMethod_prefix() . self::$router->getAction());
     $controller_parametr = self::$router->getParams();
     $layout = self::$router->getRoute();
     if ($layout == 'admin' && Session::get('role') != 'admin') {
         if ($controller_method != 'admin_login') {
             Router::redirect('/admin/users/login');
         }
     }
     //Calling conrollers method
     $controller_object = new $controller_class();
     if (method_exists($controller_object, $controller_method)) {
         $view_path = $controller_object->{$controller_method}();
         $view_object = new View($controller_object->getData(), $view_path);
         $content = $view_object->render();
     } else {
         throw new Exception('Метод ' . $controller_method . ' в классе ' . $controller_class . 'не найден');
     }
     $layout_path = VIEW_PATH . DS . $layout . '.html';
     $layout_view_object = new View(compact('content'), $layout_path);
     // основной рендер вывода страниц
     echo $layout_view_object->render();
 }
 protected function formAction()
 {
     $form = new UrlForm();
     if (App::request()->isPost()) {
         $form->setValue('url', App::request()->getPostVar('url'));
         if ($form->isValid()) {
             // if URL is valid
             // find or generate short URL
             $existsUrlRecord = UrlModel::findOneByLongurl($form->getValue('url'));
             if (false !== $existsUrlRecord) {
                 // alredy exists - use it
                 $shortURI = App::alphaid()->toAlpha($existsUrlRecord->id);
             } else {
                 // not exists - create new
                 $urlRecord = new UrlModel();
                 $urlRecord->longurl = $form->getValue('url');
                 $urlRecord->save();
                 $shortURI = App::alphaid()->toAlpha($urlRecord->id);
             }
             $shortURL = App::router()->createUrl('Redirector', 'redirect', array('url' => $shortURI));
             $form->setValue('shortUrl', $shortURL);
         }
     }
     if (App::request()->isAjaxRequest()) {
         $this->setLayout('ajax');
         $this->view->form = $form->getData();
     } else {
         $this->view->form = $form;
         $this->render();
     }
 }
Example #8
0
 public static function start()
 {
     $router = new Router();
     self::$db = self::loadDb();
     self::$auth = self::loadAuth();
     self::$access = self::loadAccess();
     self::$router = $router::init();
 }
Example #9
0
 private function links($file)
 {
     $url = \App::request()->getBaseUrl();
     $skin = \App::user()->get()->config()->skin;
     $type = strtolower(pathinfo($file, PATHINFO_EXTENSION));
     $moduleDir = \App::router()->dir;
     $themeLink = $url . '/themes/';
     $skinLink = $themeLink . $skin . '/';
     $skinPath = THEMES_PATH . $skin . DS;
     return [[$skinPath . 'modules' . DS . $moduleDir . DS . $type . DS . $file, $skinLink . 'modules/' . $moduleDir . '/' . $type . '/' . $file], [ASSETS_PATH . 'modules' . DS . $moduleDir . DS . $type . DS . $file, $url . '/assets/modules/' . $moduleDir . '/' . $type . '/' . $file], [$skinPath . $type . DS . $file, $skinLink . $type . '/' . $file], [ASSETS_PATH . 'template' . DS . $type . DS . $file, $url . '/assets/template/' . $type . '/' . $file]];
 }
Example #10
0
 public static function run($uri)
 {
     self::$router = new Router($uri);
     $controller_class = ucfirst(self::$router->getController()) . 'Controller';
     $controller_method = strtolower(self::$router->getMethodPrefix() . self::$router->getAction());
     // Calling controller's method
     $controller_object = new $controller_class();
     if (method_exists($controller_object, $controller_method)) {
         $result = $controller_object->{$controller_method}();
     } else {
         throw new Exception('Method ' . $controller_method . ' of class ' . $controller_class . ' does not exist.');
     }
 }
Example #11
0
 public static function run($uri)
 {
     self::$router = new Router($uri);
     $controller_class = ucfirst(self::$router->getController()) . 'Controller';
     $controller_method = strtolower(self::$router->getMethodPrefix() . self::$router->getAction());
     $controller_object = new $controller_class();
     if (method_exists($controller_object, $controller_method)) {
         $view_path = $controller_object->{$controller_method}();
         $view_object = new View($controller_object->getData(), $view_path);
         $content = $view_object->render();
     } else {
         throw new Exception("Method " . $controller_method . " of class " . $controller_class . " does not exist.");
     }
     $layout = self::$router->getRoute();
     $layout_path = VIEWS_PATH . DS . $layout . ".phtml";
     $layout_view_object = new View(compact('content'), $layout_path);
     echo $layout_view_object->render();
 }
Example #12
0
 /**
  * Constructor
  *
  * @param array $filters The filters
  */
 public function __construct($filters)
 {
     $options = array();
     // active languages
     $languages = array();
     $allLanguages = Language::getAll('tag');
     foreach ($allLanguages as $tag => $language) {
         $options[$tag] = $language->label;
         if ($language->active) {
             $languages[$tag] = $language;
         }
     }
     if (!in_array($filters['tag'], array_keys($allLanguages))) {
         $filters['tag'] = Lang::DEFAULT_LANGUAGE;
     }
     $param = array('id' => 'language-filter-form', 'method' => 'get', 'action' => App::router()->getUri('language-keys-list'), 'fieldsets' => array('filters' => array('nofieldset' => true, new SelectInput(array('name' => 'tag', 'options' => $options, 'default' => $filters['tag'], 'style' => 'width: 80%; margin-right: 5px;', 'label' => Lang::get('language.filter-language-label'), 'after' => Icon::make(array('icon' => 'pencil', 'class' => 'text-primary edit-lang', 'title' => Lang::get('language.filter-language-edit'))) . (count($allLanguages) > 1 && Option::get('main.language') != $filters['tag'] && $filters['tag'] != Lang::DEFAULT_LANGUAGE ? Icon::make(array('icon' => 'close', 'class' => 'text-danger delete-lang', 'title' => Lang::get('language.filter-language-delete'))) : ''))), new RadioInput(array('name' => 'keys', 'options' => array('missing' => Lang::get('language.filter-keys-missing'), 'all' => Lang::get('language.filter-keys-all')), 'default' => isset($filters['keys']) ? $filters['keys'] : 'all', 'label' => Lang::get('language.filter-keys-label'), 'labelWidth' => '100%', 'layout' => 'vertical')))));
     $this->form = new Form($param);
 }
Example #13
0
 public static function run($uri)
 {
     self::$router = new Router($uri);
     Lang::load(self::$router->getLanguage());
     $controller_class = ucfirst(self::$router->getController()) . 'Controller';
     $controller_method = strtolower(self::$router->getMethodPrefix() . self::$router->getAction());
     //calling controller's method
     $controller_object = new $controller_class();
     if (method_exists($controller_object, $controller_method)) {
         $view_path = $controller_object->{$controller_method}();
         $view_object = new View($controller_object->getData(), $view_path);
         $content = $view_object->render();
     } else {
         throw new Exception('Method ' . $controller_method . ' of class ' . $controller_class . ' does not exist.');
     }
     $layout = self::$router->getRoute();
     $layout_paht = VIEWS_PATH . DS . $layout . '.html';
     $layout_view_object = new View(compact('content'), $layout_paht);
     echo $layout_view_object->render();
 }
Example #14
0
 public static function run($uri)
 {
     self::$router = new Router($uri);
     Lang::load(self::$router->getLanguage());
     self::$db = DB::getInstance();
     //        if (self::$router->getRoute() == 'admin' && is_null(Session::get('user'))) {
     //            self::$router->redirect('/admin/');
     //        }
     if (self::$router->getController() == "favicon.ico") {
         die;
     }
     //        $test = self::$router->getController();
     //        echo $test."<br>";
     //        $test = self::renameToSafeCall($test);
     //        echo $test."<br>";
     $controller_class = ucfirst(self::$router->getController()) . 'Controller';
     $controller_method = strtolower(self::$router->getMethodPrefix() . self::$router->getAction());
     if (self::$router->getRoute() == 'admin' && is_null(Session::get('user'))) {
         if (strtolower(self::$router->getAction()) != 'login') {
             Router::redirect('/admin/users/login');
         }
     }
     $controller_object = new $controller_class();
     if (method_exists($controller_object, $controller_method)) {
         $view_path = $controller_object->{$controller_method}();
         $view_object = new View($controller_object->getData(), $view_path);
         $content = $view_object->render();
     } else {
         throw new MethodException('Cannot run method ' . $controller_method . ' on class ' . $controller_class);
     }
     $layout = self::$router->getRoute();
     $layout_path = VIEWS_PATH . DS . $layout . '.php';
     $array_content = array();
     $array_content['content'] = $content;
     // exception from rules for account_count
     if (isset($controller_object->getData()['account_count'])) {
         $array_content['account_count'] = $controller_object->getData()['account_count'];
     }
     $layout_view_object = new View($array_content, $layout_path);
     echo $layout_view_object->render();
 }
Example #15
0
 public static function run($uri)
 {
     self::$router = new Router($uri);
     self::$db = new DB(Config::get('db.host'), Config::get('db.user'), Config::get('db.password'), Config::get('db.db_name'));
     $class_name = ucfirst(self::$router->getController()) . 'Controller';
     $controller_method = strtolower(self::$router->getMethodPrefix() . self::$router->getAction());
     $controller_object = new $class_name();
     if (method_exists($controller_object, $controller_method)) {
         $view_path = $controller_object->{$controller_method}();
         $view_object = new View($controller_object->getData(), $view_path);
         //content in obb
         $content = $view_object->render();
     } else {
         echo $controller_method . 'in ' . $class_name . 'does not exist';
     }
     $layout = self::$router->getRoute();
     $layout_path = VIEW . DS . $layout . '.html';
     $layout_view_object = new View(compact('content'), $layout_path);
     // content in obb
     echo $layout_view_object->render();
 }
Example #16
0
 /**
  *  List all the roles
  */
 public function listRoles()
 {
     if (App::request()->getParams('setdefault')) {
         Option::set('roles.default-role', App::request()->getParams('setdefault'));
         $defaultRole = App::request()->getParams('setdefault');
     } else {
         $defaultRole = Option::get('roles.default-role');
     }
     $param = array('id' => 'roles-list', 'action' => App::router()->getUri('list-roles'), 'model' => 'Role', 'navigation' => false, 'controls' => array(array('icon' => 'plus', 'label' => Lang::get('roles.add-role-btn'), 'href' => App::router()->getUri('edit-role', array('roleId' => -1)), 'target' => 'dialog', 'class' => 'btn-success'), array('icon' => 'unlock-alt', 'label' => Lang::get('roles.edit-permissions-btn'), 'href' => App::router()->getUri('permissions'), 'target' => 'newtab')), 'fields' => array('removable' => array('field' => 'removable', 'hidden' => true), 'color' => array('field' => 'color', 'hidden' => true), 'actions' => array('independant' => true, 'display' => function ($value, $field, $line) {
         return Icon::make(array('icon' => 'pencil', 'class' => 'text-info', 'href' => App::router()->getUri('edit-role', array('roleId' => $line->id)), 'target' => 'dialog')) . Icon::make(array('icon' => 'unlock-alt', 'class' => 'text-success', 'href' => App::router()->getUri('role-permissions', array('roleId' => $line->id)), 'target' => 'newtab')) . ($line->isRemovable() ? Icon::make(array('icon' => 'close', 'class' => 'text-danger delete-role', 'data-role' => $line->id)) : '');
     }, 'search' => false, 'sort' => false), 'name' => array('independant' => true, 'label' => Lang::get('roles.list-name-label'), 'display' => function ($value, $field, $line) {
         return "<span style='color:{$line->color}'>" . Lang::get("roles.role-{$line->id}-label") . "</span>";
     }), 'default' => array('independant' => true, 'label' => Lang::get('roles.list-default-label'), 'display' => function ($value, $field, $line) use($defaultRole) {
         if ($line->id != 0) {
             $checkbox = new CheckboxInput(array('class' => 'set-default-role', 'value' => $defaultRole == $line->id, 'disabled' => $defaultRole == $line->id, 'attributes' => array('value' => $line->id)));
             return $checkbox->display();
         }
     }, 'search' => false, 'sort' => false)));
     $this->addKeysToJavaScript("roles.delete-role-confirmation");
     return View::make(Plugin::current()->getView("roles-list.tpl"), array('list' => new ItemList($param)));
 }
Example #17
0
 public static function run($uri)
 {
     self::$router = new Router($uri);
     self::$db = DB::getInstance();
     Lang::load(self::$router->getLanguage());
     $controllerClass = ucfirst(self::$router->getController() . 'Controller');
     $controllerMethod = self::$router->getMethodPrefix() . self::$router->getAction();
     // Instancing the controller
     $controllerObject = new $controllerClass();
     if (method_exists($controllerObject, $controllerMethod)) {
         // Controller's may return a view
         $viewPath = $controllerObject->{$controllerMethod}();
         $viewObject = new View($controllerObject->getData(), $viewPath);
         $content = $viewObject->render();
     } else {
         throw new Exception("Method {$controllerMethod} of class {$controllerClass} was not found.");
     }
     $layout = self::$router->getRoute();
     $layoutPath = VIEWS_PATH . DS . $layout . '.html';
     $layoutViewObj = new View(compact('content'), $layoutPath);
     echo $layoutViewObj->render();
 }
Example #18
0
 /**
  * Customize the menu
  */
 public function index()
 {
     $items = MenuItem::getAll();
     $form = new Form(array('id' => 'set-menus-form', 'action' => App::router()->getUri('set-menu'), 'inputs' => array(new HiddenInput(array('name' => 'data', 'default' => json_encode($items, JSON_NUMERIC_CHECK), 'attributes' => array('e-value' => 'JSON.stringify(items.valueOf())'))), new SubmitInput(array('name' => 'valid', 'value' => Lang::get('main.valid-button')))), 'onsuccess' => 'app.refreshMenu()'));
     if (!$form->submitted()) {
         $this->addKeysToJavaScript($this->_plugin . '.plugins-advert-menu-changed');
         return View::make(Plugin::current()->getView('sort-main-menu.tpl'), array('form' => $form));
     } else {
         try {
             $items = MenuItem::getAll('id');
             $data = json_decode($form->getData('data'), true);
             foreach ($data as $line) {
                 $item = $items[$line['id']];
                 $item->set(array('active' => $line['active'], 'parentId' => $line['parentId'], 'order' => $line['order']));
                 $item->save();
             }
             return $form->response(Form::STATUS_SUCCESS, Lang::get($this->_plugin . '.sort-menu-success'));
         } catch (Exception $e) {
             return $form->response(Form::STATUS_ERROR, DEBUG_MODE ? $e->getMessage() : Lang::get($this->_plugin . '.sort-menu-error'));
         }
     }
 }
Example #19
0
 public static function run($uri)
 {
     self::$router = new Router($uri);
     //переопределяем значение router
     self::$db = new DB(Config::get('db.host'), Config::get('db.user'), Config::get('db.password'), Config::get('db.db_name'));
     //присваиваем в $db даннные для подключения к базе
     Lang::load(self::$router->getLanguage());
     //подгружаем язык из router.class.php
     $controller_class = ucfirst(self::$router->getController()) . 'Controller';
     //присваеваем значение контроллера ($controller из router.class.php)
     $controller_method = strtolower(self::$router->getMethodPrefix() . self::$router->getAction());
     //присваеваем значение метода ($method_prefix из router.class.php)
     $layout = self::$router->getRoute();
     //$route из router.class.php
     if ($layout == 'admin' && Session::get('role') != 'admin') {
         //проверяем если админ не залогинен
         if ($controller_method != 'admin_login') {
             Router::redirect('/admin/users/login');
             //перенаправляем на формулогина
         }
     }
     // Calling controller's method
     $controller_object = new $controller_class();
     if (method_exists($controller_object, $controller_method)) {
         //method_exists — Проверяет, существует ли метод в данном классе
         // Controller's action may return a view path
         $view_path = $controller_object->{$controller_method}();
         $view_object = new View($controller_object->getData(), $view_path);
         $content = $view_object->render();
     } else {
         throw new Exception('Method ' . $controller_method . ' of class ' . $controller_class . ' does not exist.');
     }
     $layout_path = VIEWS_PATH . DS . $layout . '.html';
     $layout_view_object = new View(compact('content'), $layout_path);
     echo $layout_view_object->render();
 }
Example #20
0
 /**
  * Generate the form to add a new media
  */
 public function addMediaForm()
 {
     $param = array('id' => 'add-theme-media-form', 'upload' => true, 'action' => App::router()->getUri('add-theme-media'), 'fieldsets' => array('form' => array(new FileInput(array('name' => 'medias[]', 'multiple' => true, 'required' => true, 'nl' => false)), new SubmitInput(array('name' => 'valid', 'icon' => 'upload', 'value' => Lang::get($this->_plugin . '.theme-add-media-submit'))))), 'onsuccess' => 'app.load(app.getUri("theme-medias"), {selector : "#admin-themes-medias-tab"});');
     return new Form($param);
 }
Example #21
0
 * @copyright   Copyright (C) mobiCMS Community
 * @license     LICENSE.md (see attached file)
 *
 * @module      System Tools
 * @author      Oleg (AlkatraZ) Kasyanov <dev@mobicms.net>
 * @version     v.1.0.0 2015-02-01
 */
@ini_set("max_execution_time", "600");
defined('MOBICMS') or die('Error: restricted access');
$user = App::user()->get();
if ($user->rights >= 7) {
    $sv_actions = ['counters' => 'counters.php', 'firewall' => 'firewall.php', 'languages' => 'languages.php', 'sitemap' => 'sitemap.php', 'system_settings' => 'system_settings.php'];
    $admin_actions = ['acl' => 'acl.php', 'links' => 'links.php', 'users_settings/quarantine' => 'quarantine.php', 'scanner' => 'scanner.php', 'smilies' => 'smilies.php', 'users_settings' => 'users_settings.php'];
    $common_actions = [];
    App::lng()->setModule('admin');
    $query = implode('/', App::router()->getQuery());
    $include = __DIR__ . '/includes/';
    if (!empty($query)) {
        if ($user->rights == 9 && isset($sv_actions[$query])) {
            $include .= $sv_actions[$query];
        } elseif ($user->rights >= 7 && isset($admin_actions[$query])) {
            $include .= $admin_actions[$query];
        } elseif (isset($common_actions[$query])) {
            $include .= $common_actions[$query];
        } else {
            $include = false;
        }
    } else {
        $include .= 'index.php';
    }
    if ($include && is_file($include)) {
Example #22
0
 /**
  * Display the widget
  *
  * @return string The generated HTML
  */
 public function display()
 {
     $form = new Form(array('id' => 'search-themes-form', 'method' => 'get', 'action' => App::router()->getUri('search-themes'), 'inputs' => array(new TextInput(array('name' => 'search', 'required' => true, 'default' => App::request()->getParams('search'), 'placeholder' => Lang::get('admin.search-theme-form-search-label'))), new SubmitInput(array('name' => 'valid', 'value' => Lang::get('admin.search-theme-form-submit-btn'), 'icon' => 'search')))));
     return View::make(Theme::getSelected()->getView('box.tpl'), array('content' => $form, 'title' => Lang::get('admin.search-theme-form-title'), 'icon' => 'search'));
 }
Example #23
0
 /**
  * Redirect to a route
  *
  * @param string $route The route name to redirect to
  * @param array  $vars  The route parameters value to set
  */
 public function redirectToAction($route, $vars = array())
 {
     $url = App::router()->getUri($route, $vars = array());
     $this->redirect($url);
 }
Example #24
0
<?php

#---------------------------------------------#
#      ********* RotorCMS *********           #
#           Author  :  Vantuz                 #
#            Email  :  visavi.net@mail.ru     #
#             Site  :  http://visavi.net      #
#              ICQ  :  36-44-66               #
#            Skype  :  vantuzilla             #
#---------------------------------------------#
include_once __DIR__ . '/../app/start.php';
$params = App::router('params');
if (App::router('target') && is_callable(App::router('target'))) {
    call_user_func_array(App::router('target'), $params);
} elseif (App::router('target')) {
    $target = explode('@', App::router('target'));
    $action = isset($target[1]) ? $target[1] : $params['action'];
    call_user_func_array([new $target[0](), $action], $params);
} else {
    App::abort(404);
}
if (isset($_SESSION['input'])) {
    unset($_SESSION['input']);
}
Example #25
0
    if (is_file(Theme::getSelected()->getStartFile())) {
        include Theme::getSelected()->getStartFile();
    }
    (new Event('before-routing'))->trigger();
    /*** Execute action just after routing ***/
    Event::on('after-routing', function ($event) {
        $route = $event->getData('route');
        if (!App::conf()->has('db') && App::request()->getUri() == App::router()->getUri('index')) {
            // The application is not installed yet
            App::logger()->notice('Hawk is not installed yet, redirect to install process page');
            App::response()->redirectToAction('install');
            return;
        }
    });
    /*** Compute the routage ***/
    App::router()->route();
} catch (HTTPException $err) {
    App::response()->setStatus($err->getStatusCode());
    $response = array('message' => $err->getMessage(), 'details' => $err->getDetails());
    if (App::request()->getWantedType() === 'json') {
        App::response()->setContentType('json');
        App::response()->setBody($response);
    } else {
        App::response()->setBody($response['message']);
    }
} catch (AppStopException $e) {
}
// Finish the script
App::logger()->debug('end of script');
$event = new Event('process-end', array('output' => App::response()->getBody(), 'execTime' => microtime(true) - SCRIPT_START_TIME));
$event->trigger();
Example #26
0
File: routes.php Project: svlt/back
<?php

$router = App::router();
// Root
$router->route('GET /', 'Controller\\Index->root');
$router->route('GET /ping.json', 'Controller\\Index->ping');
// Users
$router->route('GET /u/@username.json', 'Controller\\User->base');
$router->route('GET /u/@username/key.json', 'Controller\\User->key');
$router->route('GET /u/@username/posts.json', 'Controller\\User->posts');
$router->route('POST /u/@username/posts.json', 'Controller\\User->post');
$router->route('POST /register.json', 'Controller\\User->register');
$router->route('POST /auth.json', 'Controller\\User->auth');
$router->route('POST /logout.json', 'Controller\\User->logout');
$router->route('GET /keystore.json', 'Controller\\User->keystore');
// Posts
$router->route('POST /post.json', 'Controller\\Post->post');
$router->route('GET /post/@id.json', 'Controller\\Post->single');
$router->route('DELETE /post/@id.json', 'Controller\\Post->delete');
// Handle errors
$router->set('ONERROR', function (Base $f3) {
    $controller = new Controller\Index();
    switch ($f3->get('ERROR.code')) {
        case 404:
            $controller->_json(['error' => 'HTTP/1.1 404 Not Found', 'path' => $f3->get('PATH')]);
            break;
        case 401:
            $controller->_json(['error' => 'HTTP/1.1 401 Unauthorized', 'message' => 'Supply a valid `token` value to avoid this error.', 'path' => $f3->get('PATH')]);
            break;
        default:
            $controller->_json(['error' => $f3->get('ERROR.code')] + $f3->get('ERROR'));
Example #27
0
            // Display number of updates in menu
            if (App::session()->isAllowed('admin.all')) {
                Event::on(\Hawk\Plugins\Main\MainController::EVENT_AFTER_GET_MENUS, function (Event $event) {
                    SearchUpdatesWidget::getInstance()->display();
                });
            }
        });
        /**
         * Manage the languages and languages keys
         */
        App::router()->auth(App::session()->isAllowed('admin.languages'), function () {
            // list all the supported languages
            App::router()->any('manage-languages', 'languages/', array('action' => 'LanguageController.index'));
            App::router()->get('language-keys-list', 'languages/keys', array('action' => 'LanguageController.listKeys'));
            // Save the translations
            App::router()->post('save-language-keys', 'languages/keys/save', array('action' => 'LanguageController.editKeys'));
            // Edit a language
            App::router()->any('edit-language', 'languages/{tag}', array('where' => array('tag' => '[a-z]{2}|new'), 'action' => 'LanguageController.editLanguage'));
            // Delete a language
            App::router()->get('delete-language', 'languages/{tag}/delete', array('where' => array('tag' => '[a-z]{2}'), 'action' => 'LanguageController.deleteLanguage'));
            // Add a language key
            App::router()->post('add-language-key', 'languages/keys/add', array('action' => 'LanguageController.addKey'));
            // Delete a translation
            App::router()->any('delete-translation', 'languages/keys/{plugin}/{key}/{tag}/clean', array('where' => array('plugin' => '[\\w\\-]+', 'key' => '[\\w\\-]+', 'tag' => '[a-z]{2}'), 'action' => 'LanguageController.deleteTranslation'));
            // Import language file
            App::router()->any('import-language-keys', 'languages/import', array('action' => 'LanguageController.import'));
        });
    });
    // Reload the application routes for JavaScript
    App::router()->get('all-routes', 'routes', array('action' => 'PluginController.getRoutes'));
});
Example #28
-1
 public static function run($uri)
 {
     self::$router = new Router($uri);
     self::$db = new DB(Config::get('db.host'), Config::get('db.user'), Config::get('db.password'), Config::get('db.db_name'));
     Lang::load(self::$router->getLanguage());
     $controller_class = ucfirst(self::$router->getController()) . 'Controller';
     $controller_method = strtolower(self::$router->getMethodPrefix() . self::$router->getAction());
     $layout = self::$router->getRoute();
     if ($layout == 'user' && Session::get('role') != 'user') {
         if ($controller_method != 'login') {
             Router::redirect('/users/login');
         }
     } elseif ($layout == 'admin' && Session::get('role') != 'admin') {
         if ($controller_method != 'admin_login') {
             Router::redirect('/admin/users/login');
         }
     }
     $controller_object = new $controller_class();
     if (method_exists($controller_object, $controller_method)) {
         $view_path = $controller_object->{$controller_method}();
         $view_object = new View($controller_object->getData(), $view_path);
         $content = $view_object->render();
     } else {
         throw new Exception('Method ' . $controller_method . ' of class ' . $controller_class . ' does not exist.');
     }
     $layout_path = VIEWS_PATH . DS . $layout . '.html';
     $layout_view_object = new View(compact('content'), $layout_path);
     echo $layout_view_object->render();
 }
Example #29
-1
 /**
  * Display the list of the users
  */
 public function listUsers()
 {
     $example = array('id' => array('$ne' => User::GUEST_USER_ID));
     $filters = UserFilterWidget::getInstance()->getFilters();
     if (isset($filters['status']) && $filters['status'] != -1) {
         $example['active'] = $filters['status'];
     }
     $param = array('id' => 'admin-users-list', 'model' => 'User', 'action' => App::router()->getUri('list-users'), 'reference' => 'id', 'filter' => new DBExample($example), 'controls' => array(array('icon' => 'plus', 'label' => Lang::get($this->_plugin . '.new-user-btn'), 'class' => 'btn-success', 'href' => App::router()->getUri("edit-user", array('username' => '_new')), 'target' => 'dialog')), 'fields' => array('actions' => array('independant' => true, 'display' => function ($value, $field, $user) {
         $return = Icon::make(array('icon' => 'pencil', 'class' => 'text-primary', 'href' => App::router()->getUri('edit-user', array('username' => $user->username)), 'target' => 'dialog'));
         if ($user->isRemovable()) {
             $return .= Icon::make(array('icon' => 'close', 'class' => 'text-danger delete-user', 'data-user' => $user->username));
             $return .= $user->active ? Icon::make(array('icon' => 'lock', 'class' => 'text-warning lock-user', 'data-user' => $user->username)) : Icon::make(array('icon' => 'unlock', 'class' => 'text-success unlock-user', 'data-user' => $user->username));
         }
         return $return;
     }, 'search' => false, 'sort' => false), 'username' => array('label' => Lang::get($this->_plugin . '.users-list-username-label')), 'email' => array('label' => Lang::get($this->_plugin . '.users-list-email-label')), 'roleId' => array('label' => Lang::get($this->_plugin . '.users-list-roleId-label'), 'sort' => false, 'search' => array('type' => 'select', 'options' => call_user_func(function () {
         $options = array();
         foreach (Role::getAll('id', array('id')) as $id => $role) {
             $options[$id] = Lang::get('roles.role-' . $id . '-label');
         }
         return $options;
     }), 'invitation' => Lang::get($this->_plugin . '.user-filter-status-all')), 'display' => function ($value) {
         return Lang::get('roles.role-' . $value . '-label');
     }), 'active' => array('label' => Lang::get($this->_plugin . '.users-list-active-label'), 'search' => false, 'sort' => false, 'class' => function ($value) {
         return 'bold ' . ($value ? 'text-success' : 'text-danger');
     }, 'display' => function ($value) {
         return $value ? Lang::get($this->_plugin . '.users-list-active') : Lang::get($this->_plugin . '.users-list-inactive');
     }), 'createTime' => array('label' => Lang::get($this->_plugin . '.users-list-createTime-label'), 'search' => false, 'display' => function ($value) {
         return date(Lang::get('main.date-format'), $value);
     })));
     $list = new ItemList($param);
     if (App::request()->getParams('refresh')) {
         return $list->display();
     } else {
         $this->addKeysToJavaScript("admin.user-delete-confirmation");
         return View::make(Plugin::current()->getView("users-list.tpl"), array('list' => $list));
     }
 }
Example #30
-1
 *
 * For copyright and license information, please see the LICENSE.md
 * Installing the system or redistributions of files must retain the above copyright notice.
 *
 * @link        http://mobicms.net mobiCMS Project
 * @copyright   Copyright (C) mobiCMS Community
 * @license     LICENSE.md (see attached file)
 *
 * @module      IP WHOIS
 * @author      Oleg (AlkatraZ) Kasyanov <dev@mobicms.net>
 * @version     v.1.0.0 2015-02-01
 */
defined('MOBICMS') or die('Error: restricted access');
$form = new Mobicms\Form\Form(['action' => App::request()->getUri()]);
$form->infoMessages = false;
$query = App::router()->getQuery();
if (isset($query[0])) {
    $form->input['ip'] = $query[0];
    $form->isSubmitted = true;
    $form->isValid = true;
}
$form->title('IP WHOIS')->element('text', 'ip', ['label' => _s('IP address'), 'required' => true])->divider()->element('submit', 'submit', ['value' => _s('Search'), 'class' => 'btn btn-primary'])->html('<a class="btn btn-link" href="../">' . _s('Back') . '</a>');
//TODO: разобраться с обратной ссылкой
$form->validate('ip', 'ip');
if ($form->process() === true) {
    include_once __DIR__ . '/classes/WhoisClient.php';
    include_once __DIR__ . '/classes/Whois.php';
    include_once __DIR__ . '/classes/IpTools.php';
    $result = (new Whois())->lookup($form->output['ip']);
    $whois = nl2br(implode("\n", $result['rawdata']));
    // Выделяем цветом важные параметры