protected function _init() { parent::_init(); $this->viewPath = Base::getApp()->getController()->getTemplatePath() . DIRECTORY_SEPARATOR . 'Widget' . DIRECTORY_SEPARATOR; $this->items = \CMSBackend\Library\MobileMenu::$items; $this->items = \Toxotes\Plugin::applyFilters('custom_admin_mobile_nav', $this->items); }
public function getParams() { if ($app = Base::getApp()) { /* @var \Flywheel\Application\ConsoleApp $app */ return $app->getParams(); } return array(); }
protected function _init() { /** @var Web $controller */ $controller = \Flywheel\Base::getApp()->getController(); $this->viewPath = $controller->getTemplatePath() . DIRECTORY_SEPARATOR . 'Widget' . DIRECTORY_SEPARATOR; if (null == $this->viewFile) { $this->viewFile = get_class($this); } }
protected function _makeUrl($url) { if (0 === stripos($url[0], 'http') || '#' == $url[0]) { return $url[0]; } if (($coll = \Flywheel\Base::getApp()->getController()) && $coll instanceof Web) { return $coll->createUrl($url[0], array_splice($url, 1)); } return Factory::getRouter()->createUrl($url[0], array_splice($url, 1)); }
public function init() { $app = \Flywheel\Base::getApp(); if (!$app instanceof \Flywheel\Application\ApiApp) { throw new \Flywheel\Exception('Response: application instance not is a "\\Flywheel\\Application\\ApiApp"'); } $this->format = strtolower($app->getFormat()); switch ($this->format) { case 'json': $this->setHeader('Content-type', 'application/json', true); break; case 'xml': $this->setHeader('Content-type', 'text/xml', true); break; default: } }
/** * initConfig * @param $config */ public function __construct($config = array()) { // Load config if (empty($config)) { ConfigHandler::get('session'); // Read config from session key in config file } $this->_config = array_merge($this->_config, $config); if (isset($this->_config['storage']) && $this->_config['storage']) { $handlerClass = $this->_config['storage']; unset($this->_config['handler']); $storage = new $handlerClass($this->_config); session_set_save_handler(array(&$storage, 'open'), array(&$storage, 'close'), array(&$storage, 'read'), array(&$storage, 'write'), array(&$storage, 'destroy'), array(&$storage, 'gc')); self::$_storage = $storage; } if (isset($this->_config['name'])) { session_name($this->_config['name']); } ini_set('session.gc_maxlifetime', $this->_config['lifetime']); //define the lifetime of the cookie if (isset($this->_config['cookie_ttl']) || isset($this->_config['cookie_domain']) || isset($this->_config['cookie_path'])) { // cross subdomain validity is default behavior $ttl = isset($this->_config['cookie_ttl']) ? (int) $this->_config['cookie_ttl'] : 0; $domain = isset($this->_config['cookie_domain']) ? $this->_config['cookie_domain'] : '.' . Factory::getRouter()->getDomain(); $path = isset($this->_config['cookie_path']) ? '/' . trim($this->_config['cookie_path'], '/') . '/' : '/'; session_set_cookie_params($ttl, $path, $domain); } else { $cookie = session_get_cookie_params(); session_set_cookie_params($cookie['lifetime'], $cookie['path'], $cookie['domain']); } if (Base::getApp()) { if (Factory::getRequest()->isSecure()) { ini_set('session.cookie_secure', true); } } ini_set('session.use_only_cookies', 1); if (isset($handlerClass)) { $this->dispatch('onAfterInitSessionConfig', new Event($this, array('handler' => $handlerClass))); } else { $this->dispatch('onAfterInitSessionConfig', new Event($this, array('handler' => 'default'))); } }
protected function _init() { parent::_init(); $this->viewPath = Base::getApp()->getController()->getTemplatePath() . DIRECTORY_SEPARATOR . 'Widget' . DIRECTORY_SEPARATOR; //f**k it foreach ($this->_menus as $m => $content) { $this->_menus[$m]['label'] = t($this->_menus[$m]['label']); } //Menu Widget $this->_addChildMenu('menu_widget', ['label' => t('Menu List'), 'url' => ['menu/default']]); $this->_addChildMenu('menu_widget', ['label' => t('Add Menu'), 'url' => ['menu/create']]); //Post $this->_addChildMenu('posts', ['label' => t('All Posts'), 'url' => ['post/default']]); $this->_addChildMenu('posts', ['label' => t('Compose New'), 'url' => ['post/create']]); $this->_addChildMenu('posts', ['label' => t('Categories'), 'url' => ['category/default', 'taxonomy' => 'category']]); $this->_addSiteContentMenu(); $this->_addProductsMenu(); $this->items = \Toxotes\Plugin::applyFilters('after_init_admin_main_nav', $this->items); $this->_addSystemMenu(); $this->_buildMenu(); }
public function authenticate($credential, $password, $cookie = false) { $this->dispatch('onBeginAuthenticate', new BaseEvent($this, array($credential))); if (empty($credential) || empty($password)) { return self::ERROR_CREDENTIAL_INVALID; } $this->_identity = $credential; $this->_credential = $password; if (strpos($credential, '@') !== false) { $user = \Users::retrieveByEmail($credential); } else { $user = \Users::retrieveByUsername($credential); } if (!$user || empty($user) || !$user instanceof \Users) { return self::ERROR_UNKNOWN_IDENTITY; } if ($user instanceof \Users) { if ($user->password != \Users::hashPassword($password, $user->password)) { return self::ERROR_CREDENTIAL_INVALID; } $this->_clearCookie(); if ($cookie) { $this->setCookie($user); } $this->setSession($user); $this->_setIsAuthenticated(true); $user->setLastVisitTime(new DateTime()); $user->setLastLoginIp(Base::getApp()->getClientIp()); $user->save(); if ($user) { $this->dispatch('onAfterAuthenticate', new BaseEvent($this, $user->getAttributes())); } return $this->isAuthenticated(); } return false; }
/** * Get Session * @deprecated Change method to \Flywheel\Session\Session::getInstance() * * @throws Exception * @return \Flywheel\Session\Session */ public static function getSession() { if (!Base::getApp()) { throw new Exception('Factory: Session must start after the application is initialized!'); } if (!isset(self::$_registry['session'])) { $config = ConfigHandler::load('app.config.session', 'session', false) or $config = ConfigHandler::load('global.config.session', 'session'); if (false == $config) { throw new Exception('Session: config file not found, "session.cfg.php" must be exist at globals/config or ' . Base::getAppPath() . ' config directory'); } $class = self::$_classesList['Session']; self::$_registry['session'] = new $class($config); } return self::$_registry['session']; }
public function __construct($render = null) { parent::__construct($render); $this->viewPath = Base::getApp()->getController()->getTemplatePath() . DIRECTORY_SEPARATOR . 'Widget' . DIRECTORY_SEPARATOR; }
protected function _init() { parent::_init(); $this->viewPath = Base::getApp()->getController()->getTemplatePath() . DIRECTORY_SEPARATOR . 'Widget' . DIRECTORY_SEPARATOR; }
protected function _setOptions() { if (isset($this->_config['session_name'])) { session_name($this->_config['session_name']); } if (isset($this->_config['session_id'])) { session_id($this->_config['session_id']); } //using cookie secure if (Base::getApp()) { if (Factory::getRequest()->isSecure()) { ini_set('session.cookie_secure', true); } } ini_set('session.gc_maxlifetime', $this->_config['lifetime']); ini_set('session.cookie_lifetime', $this->_config['lifetime']); }
protected function _init() { parent::_init(); $this->viewPath = Base::getApp()->getController()->getTemplatePath() . DIRECTORY_SEPARATOR . 'Widget' . DIRECTORY_SEPARATOR; $this->items = \Toxotes\Plugin::applyFilters('custom_admin_left_sidebar', $this->items); }