当前位置: 首页>>代码示例>>PHP>>正文


PHP App::isAdmin方法代码示例

本文整理汇总了PHP中App::isAdmin方法的典型用法代码示例。如果您正苦于以下问题:PHP App::isAdmin方法的具体用法?PHP App::isAdmin怎么用?PHP App::isAdmin使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在App的用法示例。


在下文中一共展示了App::isAdmin方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: onAfterRoute

 /**
  * Hook for after parsing route
  *
  * @return void
  */
 public function onAfterRoute()
 {
     if (User::isGuest()) {
         $current = Request::getWord('option', '');
         $current .= ($controller = Request::getWord('controller', false)) ? '.' . $controller : '';
         $current .= ($task = Request::getWord('task', false)) ? '.' . $task : '';
         $current .= ($view = Request::getWord('view', false)) ? '.' . $view : '';
         if (App::isSite()) {
             $pages = ['com_users.login'];
             $granted = Session::get('user_consent', false);
             if (in_array($current, $pages) && !$granted) {
                 Request::setVar('option', 'com_users');
                 Request::setVar('view', 'userconsent');
             }
         } else {
             if (App::isAdmin()) {
                 $exceptions = ['com_login.grantconsent'];
                 $granted = Session::get('user_consent', false);
                 if (!in_array($current, $exceptions) && !$granted) {
                     Request::setVar('option', 'com_login');
                     Request::setVar('task', 'consent');
                 }
             }
         }
     }
 }
开发者ID:mined-gatech,项目名称:hubzero-cms,代码行数:31,代码来源:userconsent.php

示例2: resource

 /**
  * Route resource to single controller
  */
 public static function resource()
 {
     $arguments = func_get_args();
     $path = $arguments[0];
     $controller = end($arguments);
     $options = array();
     // check if opstions is passed
     if (count($arguments) == 3) {
         $options = $arguments[1];
         unset($arguments[1]);
     }
     $prefix = App::isAdmin() ? 'admin_' : '';
     $resourceRoutes = array('get' => array('pattern' => "{$path}", 'method' => 'get', 'handler' => "{$controller}:{$prefix}index"), 'get_paginate' => array('pattern' => "{$path}/page/:page", 'method' => 'get', 'handler' => "{$controller}:{$prefix}index"), 'get_create' => array('pattern' => "{$path}/create", 'method' => 'get', 'handler' => "{$controller}:{$prefix}create"), 'get_edit' => array('pattern' => "{$path}/:id/edit", 'method' => 'get', 'handler' => "{$controller}:{$prefix}edit"), 'get_show' => array('pattern' => "{$path}/:id", 'method' => 'get', 'handler' => "{$controller}:{$prefix}show"), 'post' => array('pattern' => "{$path}", 'method' => 'post', 'handler' => "{$controller}:{$prefix}store"), 'put' => array('pattern' => "{$path}/:id", 'method' => 'put', 'handler' => "{$controller}:{$prefix}update"), 'delete' => array('pattern' => "{$path}/:id", 'method' => 'delete', 'handler' => "{$controller}:{$prefix}destroy"));
     foreach ($resourceRoutes as $key => $route) {
         $callable = $arguments;
         //put edited pattern to the top stack
         array_shift($callable);
         array_unshift($callable, $route['pattern']);
         //put edited controller to the bottom stack
         array_pop($callable);
         array_push($callable, $route['handler']);
         if (empty($options['name'])) {
             $name = $prefix . $key . '-' . ltrim($path, "/");
         } else {
             $name = $prefix . $key . '-' . $options['name'];
         }
         call_user_func_array(array(self::$slim, $route['method']), $callable)->name($name);
     }
 }
开发者ID:thantalas,项目名称:slim-nne,代码行数:32,代码来源:RouteFacade.php

示例3: onAfterRoute

 /**
  * Hook for after routing application
  * 
  * @return  void
  */
 public function onAfterRoute()
 {
     if (!App::isAdmin() && !App::isSite()) {
         return;
     }
     $client = 'Site';
     if (App::isAdmin()) {
         $client = 'Admin';
         return;
     }
     // Check if active for this client (Site|Admin)
     if (!$this->params->get('activate' . $client) || Request::getVar('format') == 'pdf') {
         return;
     }
     Html::behavior('framework');
     if ($this->params->get('jqueryui')) {
         Html::behavior('framework', true);
     }
     if ($this->params->get('jqueryfb')) {
         Html::behavior('modal');
     }
     if ($this->params->get('noconflict' . $client)) {
         Document::addScript(Request::root(true) . '/core/assets/js/jquery.noconflict.js');
     }
 }
开发者ID:mined-gatech,项目名称:hubzero-cms,代码行数:30,代码来源:jquery.php

示例4: actionIndex

 function actionIndex()
 {
     if (App::isAdmin()) {
         Controller::redirect('/admin/article');
     } else {
         Controller::redirect('/log-in');
     }
 }
开发者ID:ArtemRochev,项目名称:MVC-Framework,代码行数:8,代码来源:ControllerMain.php

示例5: base

 /**
  * Get the base path
  *
  * @return  string
  */
 public static function base()
 {
     $base = JPATH_SITE;
     if (\App::isAdmin()) {
         $base = JPATH_ADMINISTRATOR;
     }
     return $base;
 }
开发者ID:mined-gatech,项目名称:hubzero-cms,代码行数:13,代码来源:Assets.php

示例6: paginator_item_active

/**
 * Method to create an active pagination link to the item
 *
 * @param   Item    $item  The object with which to make an active link.
 * @return  string  HTML link
 */
function paginator_item_active($item, $prefix)
{
    if (App::isAdmin()) {
        return '<a title="' . $item->text . '" onclick="document.adminForm.' . $prefix . 'limitstart.value=' . ($item->base > 0 ? $item->base : 0) . '; Joomla.submitform();return false;">' . $item->text . '</a>';
    } else {
        return '<a title="' . $item->text . '" href="' . $item->link . '" ' . ($item->rel ? 'rel="' . $item->rel . '" ' : '') . 'class="pagenav">' . $item->text . '</a>';
    }
}
开发者ID:mined-gatech,项目名称:hubzero-cms,代码行数:14,代码来源:paginator.php

示例7: actionDeleteComment

 public function actionDeleteComment()
 {
     if (empty($_POST['id']) || !App::isAdmin()) {
         return $this->redirect('/article');
     }
     $currentArticleUrl = Article::findById(Comment::findById($_POST['id'])->article_id)->url;
     Comment::deleteComment($_POST['id']);
     $this->redirect('/article/show/' . $currentArticleUrl);
 }
开发者ID:ArtemRochev,项目名称:MVC-Framework,代码行数:9,代码来源:ControllerArticle.php

示例8: display

 /**
  * Display module contents
  *
  * @return  void
  */
 public function display()
 {
     if (!\App::isAdmin()) {
         return;
     }
     $buttons = self::getButtons($this->params);
     include_once __DIR__ . DS . 'icons.php';
     require $this->getLayoutPath($this->params->get('layout', 'default'));
 }
开发者ID:mined-gatech,项目名称:hubzero-cms,代码行数:14,代码来源:helper.php

示例9: handleError

 /**
  * Method to handle an error condition.
  *
  * @param   Exception  &$error  The Exception object to be handled.
  * @return  void
  */
 public static function handleError(&$error)
 {
     $renderer = new \Hubzero\Error\Renderer\Page(App::get('document'), App::get('template')->template, App::get('config')->get('debug'));
     // Make sure the error is a 404 and we are not in the administrator.
     if (!App::isAdmin() and $error->getCode() == 404) {
         // Render the error page.
         $renderer->render($error);
     }
     // Get the full current URI.
     $uri = JURI::getInstance();
     $current = $uri->toString(array('scheme', 'host', 'port', 'path', 'query', 'fragment'));
     // Attempt to ignore idiots.
     if (strpos($current, 'mosConfig_') !== false || strpos($current, '=http://') !== false) {
         // Render the error page.
         $renderer->render($error);
     }
     // See if the current url exists in the database as a redirect.
     $db = App::get('db');
     $db->setQuery('SELECT ' . $db->quoteName('new_url') . ', ' . $db->quoteName('published') . ' FROM ' . $db->quoteName('#__redirect_links') . ' WHERE ' . $db->quoteName('old_url') . ' = ' . $db->quote($current), 0, 1);
     $link = $db->loadObject();
     // If no published redirect was found try with the server-relative URL
     if (!$link or $link->published != 1) {
         $currRel = $uri->toString(array('path', 'query', 'fragment'));
         $db->setQuery('SELECT ' . $db->quoteName('new_url') . ', ' . $db->quoteName('published') . ' FROM ' . $db->quoteName('#__redirect_links') . ' WHERE ' . $db->quoteName('old_url') . ' = ' . $db->quote($currRel), 0, 1);
         $link = $db->loadObject();
     }
     // If a redirect exists and is published, permanently redirect.
     if ($link and $link->published == 1) {
         App::redirect($link->new_url, null, null, true, false);
     } else {
         $referer = empty($_SERVER['HTTP_REFERER']) ? '' : $_SERVER['HTTP_REFERER'];
         $db->setQuery('SELECT id FROM ' . $db->quoteName('#__redirect_links') . '  WHERE old_url= ' . $db->quote($current));
         $res = $db->loadResult();
         if (!$res) {
             // If not, add the new url to the database.
             $query = $db->getQuery(true);
             $query->insert($db->quoteName('#__redirect_links'), false);
             $columns = array($db->quoteName('old_url'), $db->quoteName('new_url'), $db->quoteName('referer'), $db->quoteName('comment'), $db->quoteName('hits'), $db->quoteName('published'), $db->quoteName('created_date'));
             $query->columns($columns);
             $query->values($db->Quote($current) . ', ' . $db->Quote('') . ' ,' . $db->Quote($referer) . ', ' . $db->Quote('') . ',1,0, ' . $db->Quote(Date::toSql()));
             $db->setQuery($query);
             $db->query();
         } else {
             // Existing error url, increase hit counter
             $query = $db->getQuery(true);
             $query->update($db->quoteName('#__redirect_links'));
             $query->set($db->quoteName('hits') . ' = ' . $db->quoteName('hits') . ' + 1');
             $query->where('id = ' . (int) $res);
             $db->setQuery((string) $query);
             $db->query();
         }
         // Render the error page.
         $renderer->render($error);
     }
 }
开发者ID:sumudinie,项目名称:hubzero-cms,代码行数:61,代码来源:redirect.php

示例10: onAfterInitialise

 public function onAfterInitialise()
 {
     // No remember me for admin
     if (App::isAdmin()) {
         return;
     }
     if (User::isGuest()) {
         $hash = App::hash('JLOGIN_REMEMBER');
         if ($str = Request::getString($hash, '', 'cookie', 1 | 2)) {
             $credentials = array();
             $goodCookie = true;
             $filter = JFilterInput::getInstance();
             // Create the encryption key, apply extra hardening using the user agent string.
             // Since we're decoding, no UA validity check is required.
             $privateKey = App::hash(@$_SERVER['HTTP_USER_AGENT']);
             $crypt = new \Hubzero\Encryption\Encrypter(new \Hubzero\Encryption\Cipher\Simple(), new \Hubzero\Encryption\Key('simple', $privateKey, $privateKey));
             try {
                 $str = $crypt->decrypt($str);
                 if (!is_string($str)) {
                     throw new Exception('Decoded cookie is not a string.');
                 }
                 $cookieData = json_decode($str);
                 if (null === $cookieData) {
                     throw new Exception('JSON could not be docoded.');
                 }
                 if (!is_object($cookieData)) {
                     throw new Exception('Decoded JSON is not an object.');
                 }
                 // json_decoded cookie could be any object structure, so make sure the
                 // credentials are well structured and only have user and password.
                 if (isset($cookieData->username) && is_string($cookieData->username)) {
                     $credentials['username'] = $filter->clean($cookieData->username, 'username');
                 } else {
                     throw new Exception('Malformed username.');
                 }
                 if (isset($cookieData->password) && is_string($cookieData->password)) {
                     $credentials['password'] = $filter->clean($cookieData->password, 'string');
                 } else {
                     throw new Exception('Malformed password.');
                 }
                 $return = App::get('auth')->login($credentials, array('silent' => true));
                 if (!$return) {
                     throw new Exception('Log-in failed.');
                 }
             } catch (Exception $e) {
                 $cookie_domain = Config::get('cookie_domain', '');
                 $cookie_path = Config::get('cookie_path', '/');
                 // Clear the remember me cookie
                 setcookie(App::hash('JLOGIN_REMEMBER'), false, time() - 86400, $cookie_path, $cookie_domain);
                 Log::warning('A remember me cookie was unset for the following reason: ' . $e->getMessage());
             }
         }
     }
 }
开发者ID:sumudinie,项目名称:hubzero-cms,代码行数:54,代码来源:remember.php

示例11: fetchElement

 /**
  * Return any options this element may have
  *
  * @param   string  $name          Name of the field
  * @param   string  $value         Value to check against
  * @param   object  $element       Data Source Object.
  * @param   string  $control_name  Control name (eg, control[fieldname])
  * @return  string  HTML
  */
 public function fetchElement($name, $value, &$element, $control_name)
 {
     $rows = isset($element->rows) ? $element->rows : 6;
     $cols = isset($element->cols) ? $element->cols : 50;
     $cls = array();
     if (isset($element->class)) {
         $cls[] = $element->class;
     }
     $cls[] = \App::isAdmin() ? 'no-footer' : 'minimal no-footer';
     // convert <br /> tags so they are not visible when editing
     $value = str_replace('<br />', "\n", $value);
     return '<span class="field-wrap">' . \App::get('editor')->display($control_name . '[' . $name . ']', $value, '', '', $cols, $rows, false, $control_name . '-' . $name, null, null, array('class' => implode(' ', $cls))) . '</span>';
 }
开发者ID:mined-gatech,项目名称:hubzero-cms,代码行数:22,代码来源:textarea.php

示例12: path

 /**
  * Get array of help pages for component
  *
  * @param   string  $component  Component to get pages for
  * @return  array
  */
 private static function path($component)
 {
     $client = \App::isAdmin() ? 'admin' : 'site';
     return \App::get('component')->path($component) . DS . $client;
     /*if (file_exists(PATH_CORE . DS . 'components' . DS . $component . DS . $client))
     		{
     			return PATH_CORE . DS . 'components' . DS . $component . DS . $client;
     		}
     		else
     		{
     			return PATH_APP . DS . 'components' . DS . $component;
     		}*/
 }
开发者ID:kevinwojo,项目名称:hubzero-cms,代码行数:19,代码来源:finder.php

示例13: render

 public function render($view = 'index', $data = null, $theme = 'user', $layout = 'main')
 {
     if ($this->forAdmin && !App::isAdmin()) {
         return Controller::redirect('/admin');
     }
     if ($this->forAdmin) {
         $theme = 'admin';
         $layout = 'admin';
     }
     $view = VIEWS_PATH . $theme . '/' . $view . PHP_EXT;
     $layout = VIEWS_PATH . 'layout/' . $layout . PHP_EXT;
     include $layout;
 }
开发者ID:ArtemRochev,项目名称:MVC-Framework,代码行数:13,代码来源:View.php

示例14: __get

	public function __get($key)
	{
		if(!array_key_exists($this->_module, $this->_options)){
			if(App::isAdmin()){
				$fullpath = APPLICATION_PATH . DIRECTORY_SEPARATOR . 'code' 
	              			. DIRECTORY_SEPARATOR . 'admin' . DIRECTORY_SEPARATOR . strtolower($this->_module)
	              			. DIRECTORY_SEPARATOR . 'etc' . DIRECTORY_SEPARATOR . 'module.ini';
			}else{
	            $fullpath = APPLICATION_PATH . DIRECTORY_SEPARATOR . 'code' 
	              			. DIRECTORY_SEPARATOR . 'front' . DIRECTORY_SEPARATOR . strtolower($this->_module)
	              			. DIRECTORY_SEPARATOR . 'etc' . DIRECTORY_SEPARATOR . 'module.ini';
			} 			
            $config = $this->_loadOptions($fullpath);
            $this->_options[$this->_module] = $config; 			
		}
		return $this->_options[$this->_module]->$key;
	}
开发者ID:richard-cai,项目名称:Zend-Framework-Extended,代码行数:17,代码来源:Config.php

示例15: bake

 /**
  * Drop a cookie
  *
  * @param  (string) $namespace - make sure the cookie name is unique
  * @param  (time)   $lifetime  - how long the cookie should last
  * @param  (array)  $data      - data to be saved in cookie
  * @return void
  **/
 public static function bake($namespace, $lifetime, $data = array())
 {
     $hash = \App::hash(\App::get('client')->name . ':' . $namespace);
     $key = \App::hash('');
     $crypt = new \Hubzero\Encryption\Encrypter(new \Hubzero\Encryption\Cipher\Simple(), new \Hubzero\Encryption\Key('simple', $key, $key));
     $cookie = $crypt->encrypt(serialize($data));
     // Determine whether cookie should be 'secure' or not
     $secure = false;
     $forceSsl = \Config::get('force_ssl', false);
     if (\App::isAdmin() && $forceSsl >= 1) {
         $secure = true;
     } else {
         if (\App::isSite() && $forceSsl == 2) {
             $secure = true;
         }
     }
     // Set the actual cookie
     setcookie($hash, $cookie, $lifetime, '/', '', $secure, true);
 }
开发者ID:mined-gatech,项目名称:framework,代码行数:27,代码来源:Cookie.php


注:本文中的App::isAdmin方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。