本文整理汇总了PHP中JApplicationCms类的典型用法代码示例。如果您正苦于以下问题:PHP JApplicationCms类的具体用法?PHP JApplicationCms怎么用?PHP JApplicationCms使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了JApplicationCms类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* MonitorRouter constructor.
*
* @param JApplicationCms $app Application object that the router should use
* @param JMenu $menu Menu object that the router should use
* @param MonitorModelProject $modelProject Project model to use in the router.
* @param MonitorModelIssue $modelIssue Issue model to use in the router.
*
* @throws Exception
*/
public function __construct($app = null, $menu = null, $modelProject = null, $modelIssue = null)
{
JLoader::register('MonitorModelAbstract', JPATH_ROOT . '/administrator/components/com_monitor/model/abstract.php');
JLoader::register('MonitorModelProject', JPATH_ROOT . '/administrator/components/com_monitor/model/project.php');
JLoader::register('MonitorModelIssue', JPATH_ROOT . '/administrator/components/com_monitor/model/issue.php');
if ($app) {
$this->app = $app;
} else {
$this->app = JFactory::getApplication();
}
if ($menu) {
$this->menu = $menu;
} else {
$this->menu = $this->app->getMenu();
}
if ($modelProject) {
$this->modelProject = $modelProject;
} else {
$this->modelProject = new MonitorModelProject($app, false);
}
if ($modelIssue) {
$this->modelIssue = $modelIssue;
} else {
$this->modelIssue = new MonitorModelIssue($app, false);
}
}
开发者ID:Harmageddon,项目名称:com_monitor,代码行数:36,代码来源:router.php
示例2: __construct
/**
* Class constructor.
*
* @param JApplicationCms $app Application-object that the router should use
* @param JMenu $menu Menu-object that the router should use
*
* @since 3.4
*/
public function __construct($app = null, $menu = null)
{
if ($app) {
$this->app = $app;
} else {
$this->app = JFactory::getApplication('site');
}
if ($menu) {
$this->menu = $menu;
} else {
$this->menu = $this->app->getMenu();
}
}
开发者ID:adjaika,项目名称:J3Base,代码行数:21,代码来源:base.php
示例3: postflight
/**
* method to run after an install/update/uninstall method
*
* @return void
*/
function postflight($type, $parent)
{
// $parent is the class calling this method
// $type is the type of change (install, update or discover_install)
$siteApp = JApplicationCms::getInstance('site');
$menu = $siteApp->getMenu()->getItems('link', 'index.php?option=com_alfcontact&view=alfcontact');
$firstmenu = array_shift($menu);
if ($type == 'update' && !$firstmenu->params->exists('header')) {
//upgrade v3.1.1: moved parameters from component to menu-item
echo 'The Title, Header and Footer parameters have now been moved to the menu-item settings!';
//check for component parameters
$c_params = JComponentHelper::getParams('com_alfcontact');
// get the 'old' values from the component settings
$temp_title = $c_params->get('title');
$temp_header = $c_params->get('header');
$temp_footer = $c_params->get('footer');
//clear the 'old' settings in the component settings
$c_params->set('title', '');
$c_params->set('header', '');
$c_params->set('footer', '');
//Copy the parameteres to the menu-item settings
$db = JFactory::getDBO();
$name = 'com_alfcontact';
$query = "UPDATE #__extensions SET params =" . $db->quote((string) $c_params) . "WHERE name =" . $db->quote((string) $name);
$db->setQuery($query);
foreach ($menu as $val) {
$val->params->set('title', $temp_title);
$val->params->set('header', $temp_header);
$val->params->set('footer', $temp_footer);
$query = "UPDATE #__menu SET params = " . $db->quote((string) $val->params) . " WHERE id = " . $db->quote((string) $val->id);
$db->setQuery($query);
}
}
echo '<p>' . JText::_('COM_ALFCONTACT_POSTFLIGHT_' . $type . '_TEXT') . '</p>';
}
开发者ID:grlf,项目名称:eyedock,代码行数:40,代码来源:script.php
示例4: execute
/**
* Dispatch the application.
*
* @param JApplicationCms $app
*
* @return string An rendered view from executing the controller.
*/
public function execute()
{
$view = $this->app->input->get('view');
if ($view === null) {
throw new ControllerResolutionException('No view was specified.');
}
$fqcn = __NAMESPACE__ . '\\Controllers\\' . ($this->app->isAdmin() ? 'Admin\\' : '') . ucfirst($view) . 'Controller';
if (!class_exists($fqcn)) {
throw new ControllerResolutionException(sprintf('Controller for view (%s) cannot be found.', $view));
}
/** @var \Framework\Controllers\AbstractBaseController $controller */
$controller = $this->container->buildObject($fqcn);
$controller->setContainer($this->container);
$controller->createDefaultModel();
$controller->createDefaultView();
return $controller->execute();
}
开发者ID:beingsane,项目名称:com_framework,代码行数:24,代码来源:Dispatcher.php
示例5: execute
/**
* Execute the controller.
*
* @return boolean True if controller finished execution, false if the controller did not
* finish execution. A controller might return false if some precondition for
* the controller to run has not been satisfied.
*
* @since 12.1
* @throws LogicException
* @throws RuntimeException
*/
public function execute()
{
$model = new MonitorModelIssue();
$id = $this->input->getInt('id');
$user = JFactory::getUser();
// Get the params
// TODO: may be removed when new MVC is implemented completely
$this->app = JFactory::getApplication();
if ($this->app instanceof JApplicationSite) {
$params = $this->app->getParams();
}
if (!$model->canEdit($user, $id)) {
if ($user->guest && isset($params) && $params->get('redirect_login', 1)) {
$this->app->enqueueMessage(JText::_('JGLOBAL_YOU_MUST_LOGIN_FIRST'), 'error');
$this->app->redirect(JRoute::_('index.php?option=com_users&view=login&return=' . base64_encode(JUri::getInstance()->toString()), '403'));
} else {
throw new Exception(JText::_('JERROR_ALERTNOAUTHOR'), 403);
}
}
if ($id) {
$model->setIssueId($id);
}
$model->loadForm();
$view = new MonitorViewIssueHtml($model);
$view->setLayout('edit');
$view->loadForm();
echo $view->render();
return true;
}
开发者ID:Harmageddon,项目名称:com_monitor,代码行数:40,代码来源:edit.php
示例6: onUserLoginFailure
public function onUserLoginFailure($response)
{
var_dump($response);
if ($response['status'] === 4 && $response['error_message'] == "suspended") {
$this->app->redirect(JRoute::_('account-suspended', false));
}
//die();
}
开发者ID:camigreen,项目名称:ttop,代码行数:8,代码来源:zoostore.php
示例7: execute
/**
* Method to remove root in global configuration.
*
* @return boolean True on success.
*
* @since 3.2
*/
public function execute()
{
// Check for request forgeries.
if (!JSession::checkToken('get')) {
$this->app->enqueueMessage(JText::_('JINVALID_TOKEN'));
$this->app->redirect('index.php');
}
// Check if the user is authorized to do this.
if (!JFactory::getUser()->authorise('core.admin')) {
$this->app->enqueueMessage(JText::_('JERROR_ALERTNOAUTHOR'));
$this->app->redirect('index.php');
}
// Initialise model.
$model = new ConfigModelApplication();
// Attempt to save the configuration and remove root.
try {
$model->removeroot();
} catch (RuntimeException $e) {
// Save failed, go back to the screen and display a notice.
$this->app->enqueueMessage(JText::sprintf('JERROR_SAVE_FAILED', $e->getMessage()), 'error');
$this->app->redirect(JRoute::_('index.php', false));
}
// Set the redirect based on the task.
$this->app->enqueueMessage(JText::_('COM_CONFIG_SAVE_SUCCESS'));
$this->app->redirect(JRoute::_('index.php', false));
}
开发者ID:01J,项目名称:skazkipronebo,代码行数:33,代码来源:removeroot.php
示例8: onAfterInitialise
/**
* Listener for the `onAfterInitialise` event
*
* @return void
*
* @since 3.5
*/
public function onAfterInitialise()
{
if (!$this->app->isAdmin() || !$this->isAllowedUser()) {
return;
}
if (!$this->isDebugEnabled() && !$this->isUpdateRequired()) {
return;
}
JHtml::_('jquery.framework');
JHtml::script('plg_system_stats/stats.js', false, true, false);
}
开发者ID:nemmar,项目名称:joomla-cms,代码行数:18,代码来源:stats.php
示例9: __construct
/**
* Constructor
*
* @param array $config An array of configuration options (name, state, dbo, table_path, ignore_request).
*
* @since 3.3.4
* @throws Exception
*/
public function __construct($config = array())
{
$this->app = JArrayHelper::getValue($config, 'app', JFactory::getApplication());
$this->user = JArrayHelper::getValue($config, 'user', JFactory::getUser());
$this->config = JArrayHelper::getValue($config, 'config', JFactory::getConfig());
$this->session = JArrayHelper::getValue($config, 'session', JFactory::getSession());
$this->date = JArrayHelper::getValue($config, 'date', JFactory::getDate());
$this->lang = JArrayHelper::getValue($config, 'lang', JFactory::getLanguage());
$this->package = $this->app->getUserState('com_fabrik.package', 'fabrik');
parent::__construct($config);
}
开发者ID:LGBGit,项目名称:tierno,代码行数:19,代码来源:fabrik.php
示例10: createView
/**
* @param array $data
* @return Renderer
*/
public function createView(array $data = array())
{
$renderer = new Renderer($data);
$name = $this->getName();
// Add the default view path
$renderer->addIncludePath(COMPONENT_ROOT . '/src/views/' . $this->getName());
$template = $this->app->getTemplate();
$option = $this->input->get('option');
// Prepend the template path
$renderer->addIncludePath(JPATH_ROOT . '/templates/' . $template . '/html/' . $option . '/' . $this->getName(), true);
return $renderer;
}
开发者ID:beingsane,项目名称:com_framework,代码行数:16,代码来源:AbstractBaseController.php
示例11: execute
/**
* Method to save global configuration.
*
* @return boolean True on success.
*
* @since 3.2
*/
public function execute()
{
// Check for request forgeries.
if (!JSession::checkToken()) {
$this->app->enqueueMessage(JText::_('JINVALID_TOKEN'));
$this->app->redirect('index.php');
}
// Check if the user is authorized to do this.
if (!JFactory::getUser()->authorise('core.admin')) {
$this->app->enqueueMessage(JText::_('JERROR_ALERTNOAUTHOR'));
$this->app->redirect('index.php');
}
// Set FTP credentials, if given.
JClientHelper::setCredentialsFromRequest('ftp');
$model = new ConfigModelConfig();
$form = $model->getForm();
$data = $this->input->post->get('jform', array(), 'array');
// Validate the posted data.
$return = $model->validate($form, $data);
// Check for validation errors.
if ($return === false) {
/*
* The validate method enqueued all messages for us, so we just need to redirect back.
*/
// Save the data in the session.
$this->app->setUserState('com_config.config.global.data', $data);
// Redirect back to the edit screen.
$this->app->redirect(JRoute::_('index.php?option=com_config&controller=config.display.config', false));
}
// Attempt to save the configuration.
$data = $return;
// Access back-end com_config
JLoader::registerPrefix('Config', JPATH_ADMINISTRATOR . '/components/com_config');
$saveClass = new ConfigControllerApplicationSave();
// Get a document object
$document = JFactory::getDocument();
// Set back-end required params
$document->setType('json');
// Execute back-end controller
$return = $saveClass->execute();
// Reset params back after requesting from service
$document->setType('html');
// Check the return value.
if ($return === false) {
/*
* The save method enqueued all messages for us, so we just need to redirect back.
*/
// Save the data in the session.
$this->app->setUserState('com_config.config.global.data', $data);
// Save failed, go back to the screen and display a notice.
$this->app->redirect(JRoute::_('index.php?option=com_config&controller=config.display.config', false));
}
// Redirect back to com_config display
$this->app->enqueueMessage(JText::_('COM_CONFIG_SAVE_SUCCESS'));
$this->app->redirect(JRoute::_('index.php?option=com_config&controller=config.display.config', false));
return true;
}
开发者ID:01J,项目名称:skazkipronebo,代码行数:64,代码来源:save.php
示例12: onUserLogout
public function onUserLogout($options)
{
// No remember me for admin
if ($this->app->isAdmin()) {
return false;
}
$cookieName = JUserHelper::getShortHashedUserAgent();
// Check for the cookie
if ($this->app->input->cookie->get($cookieName)) {
// Make sure authentication group is loaded to process onUserAfterLogout event
JPluginHelper::importPlugin('authentication');
}
}
开发者ID:Tommar,项目名称:vino2,代码行数:13,代码来源:remember.php
示例13: onAfterInitialise
/**
* Listener for onAfterInitialise event
*
* @return void
*/
public function onAfterInitialise()
{
// Only for site
if (!$this->app->isSite()) {
return;
}
// Register listeners for JHtml helpers
if (!JHtml::isRegistered('bootstrap.loadCss')) {
JHtml::register('bootstrap.loadCss', 'PlgSystemBootstrap3::loadCss');
}
if (!JHtml::isRegistered('bootstrap.carousel')) {
JHtml::register('bootstrap.carousel', 'PlgSystemBootstrap3::carousel');
}
}
开发者ID:brianteeman,项目名称:bs3-demo,代码行数:19,代码来源:bootstrap3.php
示例14: execute
/**
* Execute the controller.
*
* @return boolean True if controller finished execution, false if the controller did not
* finish execution. A controller might return false if some precondition for
* the controller to run has not been satisfied.
*
* @since 12.1
* @throws LogicException
* @throws RuntimeException
*/
public function execute()
{
$id = $this->input->getInt('id');
$user = JFactory::getUser();
if ($user->guest) {
$this->app->enqueueMessage(JText::_('JGLOBAL_YOU_MUST_LOGIN_FIRST'), 'error');
} else {
$model = new MonitorModelSubscription();
if ($model->isSubscriberIssue($id, $user->id)) {
$model->unsubscribeIssue($id, $user->id);
$this->app->enqueueMessage(JText::_('COM_MONITOR_SUBSCRIPTION_ISSUE_UNSUBSCRIBED'), 'message');
}
}
$this->app->redirect(JRoute::_('index.php?option=com_monitor&view=issue&id=' . $id, false));
}
开发者ID:Harmageddon,项目名称:com_monitor,代码行数:26,代码来源:unsubscribe.php
示例15: onAfterRouteAdmin
/**
* Re-route Gantry templates to Gantry Administration component.
*/
private function onAfterRouteAdmin()
{
$input = $this->app->input;
$option = $input->getCmd('option');
$task = $input->getCmd('task');
if (in_array($option, ['com_templates', 'com_advancedtemplates']) && $task && strpos($task, 'style') === 0) {
// Get all ids.
$cid = $input->post->get('cid', (array) $input->getInt('id'), 'array');
if ($cid) {
$styles = $this->getStyles();
$selected = array_intersect(array_keys($styles), $cid);
// If no Gantry templates were selected, just let com_templates deal with the request.
if (!$selected) {
return;
}
// Special handling for tasks coming from com_template.
if ($task == 'style.edit') {
$id = (int) array_shift($cid);
if (isset($styles[$id])) {
$token = JSession::getFormToken();
$this->app->redirect("index.php?option=com_gantry5&view=configurations/{$id}/styles&style={$id}&{$token}=1");
}
}
}
}
}
开发者ID:Ettore495,项目名称:Ettore-Work,代码行数:29,代码来源:gantry5.php
示例16: onUserLogout
/**
* This method should handle any logout logic and report back to the subject
*
* @param array $user Holds the user data.
* @param array $options Array holding options (client, ...).
*
* @return object True on success
*
* @since 1.5
*/
public function onUserLogout($user, $options = array())
{
$my = JFactory::getUser();
$session = JFactory::getSession();
// Make sure we're a valid user first
if ($user['id'] == 0 && !$my->get('tmp_user')) {
return true;
}
// Check to see if we're deleting the current session
if ($my->get('id') == $user['id'] && $options['clientid'] == $this->app->getClientId()) {
// Hit the user last visit field
$my->setLastVisit();
// Destroy the php session for this user
$session->destroy();
}
// Enable / Disable Forcing logout all users with same userid
$forceLogout = $this->params->get('forceLogout', 1);
if ($forceLogout) {
$query = $this->db->getQuery(true)->delete($this->db->quoteName('#__session'))->where($this->db->quoteName('userid') . ' = ' . (int) $user['id'])->where($this->db->quoteName('client_id') . ' = ' . (int) $options['clientid']);
try {
$this->db->setQuery($query)->execute();
} catch (RuntimeException $e) {
return false;
}
}
return true;
}
开发者ID:brenot,项目名称:forumdesenvolvimento,代码行数:37,代码来源:joomla.php
示例17: __construct
/**
* Class constructor.
*
* @since 3.1
*/
public function __construct()
{
// Run the parent constructor
parent::__construct();
// Load and set the dispatcher
$this->loadDispatcher();
// Enable sessions by default.
if (is_null($this->config->get('session'))) {
$this->config->set('session', true);
}
// Set the session default name.
if (is_null($this->config->get('session_name'))) {
$this->config->set('session_name', 'installation');
}
// Create the session if a session name is passed.
if ($this->config->get('session') !== false) {
$this->loadSession();
// Register the session with JFactory
JFactory::$session = $this->getSession();
}
// Store the debug value to config based on the JDEBUG flag
$this->config->set('debug', JDEBUG);
// Register the config to JFactory
JFactory::$config = $this->config;
// Register the application to JFactory
JFactory::$application = $this;
// Register the application name
$this->_name = 'installation';
// Register the client ID
$this->_clientId = 2;
// Set the root in the URI one level up.
$parts = explode('/', JUri::base(true));
array_pop($parts);
JUri::root(null, implode('/', $parts));
}
开发者ID:shoffmann52,项目名称:install-from-web-server,代码行数:40,代码来源:web.php
示例18: onAfterInitialise
/**
* Listener for the `onAfterInitialise` event
*
* @return void
*
* @since 3.5
*/
public function onAfterInitialise()
{
if (!$this->app->isAdmin() || !$this->isAllowedUser()) {
return;
}
if (!$this->isDebugEnabled() && !$this->isUpdateRequired()) {
return;
}
if (JUri::getInstance()->getVar("tmpl") === "component") {
return;
}
// Load plugin language files only when needed (ex: they are not needed in site client).
$this->loadLanguage();
JHtml::_('jquery.framework');
JHtml::script('plg_system_stats/stats.js', false, true, false);
}
开发者ID:joomla-projects,项目名称:media-manager-improvement,代码行数:23,代码来源:stats.php
示例19: onUserLogout
/**
* This method should handle any logout logic and report back to the subject
*
* @param array $user Holds the user data.
* @param array $options Array holding options (client, ...).
*
* @return object True on success
*
* @since 1.5
*/
public function onUserLogout($user, $options = array())
{
$my = JFactory::getUser();
$session = JFactory::getSession();
// Make sure we're a valid user first
if ($user['id'] == 0 && !$my->get('tmp_user')) {
return true;
}
// Check to see if we're deleting the current session
if ($my->get('id') == $user['id'] && $options['clientid'] == $this->app->getClientId()) {
// Hit the user last visit field
$my->setLastVisit();
// Destroy the php session for this user
$session->destroy();
}
// Enable / Disable Forcing logout all users with same userid
$forceLogout = $this->params->get('forceLogout', 1);
if ($forceLogout) {
$query = $this->db->getQuery(true)->delete($this->db->quoteName('#__session'))->where($this->db->quoteName('userid') . ' = ' . (int) $user['id'])->where($this->db->quoteName('client_id') . ' = ' . (int) $options['clientid']);
try {
$this->db->setQuery($query)->execute();
} catch (RuntimeException $e) {
return false;
}
}
// Delete "user state" cookie used for reverse caching proxies like Varnish, Nginx etc.
$conf = JFactory::getConfig();
$cookie_domain = $conf->get('cookie_domain', '');
$cookie_path = $conf->get('cookie_path', '/');
if ($this->app->isSite()) {
$this->app->input->cookie->set("joomla_user_state", "", time() - 86400, $cookie_path, $cookie_domain, 0);
}
return true;
}
开发者ID:ITPrism,项目名称:GamificationDistribution,代码行数:44,代码来源:joomla.php
示例20: onAfterInitialise
/**
* Remember me method to run onAfterInitialise
*
* @return boolean
*
* @since 1.5
* @throws InvalidArgumentException
*/
public function onAfterInitialise()
{
// No remember me for admin
if ($this->app->isAdmin()) {
return false;
}
$user = JFactory::getUser();
$this->app->rememberCookieLifetime = $this->lifetime;
$this->app->rememberCookieSecure = $this->secure;
$this->app->rememberCookieLength = $this->length;
// Check for a cookie
if ($user->get('guest') == 1) {
// Create the cookie name and data
$rememberArray = JUserHelper::getRememberCookieData();
if ($rememberArray !== false) {
if (count($rememberArray) != 3) {
// Destroy the cookie in the browser.
$this->app->input->cookie->set(end($rememberArray), false, time() - 42000, $this->app->get('cookie_path'), $this->app->get('cookie_domain'));
JLog::add('Invalid cookie detected.', JLog::WARNING, 'error');
return false;
}
list($privateKey, $series, $uastring) = $rememberArray;
if (!JUserHelper::clearExpiredTokens($this)) {
JLog::add('Error in deleting expired cookie tokens.', JLog::WARNING, 'error');
}
// Find the matching record if it exists
$query = $this->db->getQuery(true)->select($this->db->quoteName(array('user_id', 'token', 'series', 'time', 'invalid')))->from($this->db->quoteName('#__user_keys'))->where($this->db->quoteName('series') . ' = ' . $this->db->quote(base64_encode($series)))->where($this->db->quoteName('uastring') . ' = ' . $this->db->quote($uastring))->order($this->db->quoteName('time') . ' DESC');
$results = $this->db->setQuery($query)->loadObjectList();
$countResults = count($results);
// We have a user but a cookie that is not in the database, or it is invalid. This is a possible attack, so invalidate everything.
if (($countResults === 0 || $results[0]->invalid != 0) && !empty($results[0]->user_id)) {
JUserHelper::invalidateCookie($results[0]->user_id, $uastring);
JLog::add(JText::sprintf('PLG_SYSTEM_REMEMBER_ERROR_LOG_INVALIDATED_COOKIES', $user->username), JLog::WARNING, 'security');
// Possibly e-mail user and admin here.
return false;
}
// We have a user with one cookie with a valid series and a corresponding record in the database.
if ($countResults === 1) {
if (substr($results[0]->token, 0, 4) === '$2y$') {
if (JCrypt::hasStrongPasswordSupport()) {
$match = password_verify($privateKey, $results[0]->token);
}
} else {
if (JCrypt::timingSafeCompare($results[0]->token, $privateKey)) {
$match = true;
}
}
if (empty($match)) {
JUserHelper::invalidateCookie($results[0]->user_id, $uastring);
JLog::add(JText::sprintf('PLG_SYSTEM_REMEMBER_ERROR_LOG_LOGIN_FAILED', $user->username), JLog::WARNING, 'security');
return false;
}
// Set up the credentials array to pass to onUserAuthenticate
$credentials = array('username' => $results[0]->user_id);
return $this->app->login($credentials, array('silent' => true, 'lifetime' => $this->lifetime, 'secure' => $this->secure, 'length' => $this->length));
}
}
}
return false;
}
开发者ID:shoffmann52,项目名称:install-from-web-server,代码行数:68,代码来源:remember.php
注:本文中的JApplicationCms类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论