本文整理汇总了PHP中JApplicationCms类的典型用法代码示例。如果您正苦于以下问题:PHP JApplicationCms类的具体用法?PHP JApplicationCms怎么用?PHP JApplicationCms使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了JApplicationCms类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
}
}
示例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();
}
}
示例3: 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;
}
示例4: onUserLoginFailure
public function onUserLoginFailure($response)
{
var_dump($response);
if ($response['status'] === 4 && $response['error_message'] == "suspended") {
$this->app->redirect(JRoute::_('account-suspended', false));
}
//die();
}
示例5: 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));
}
示例6: 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);
}
示例7: __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);
}
示例8: 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;
}
示例9: 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;
}
示例10: 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');
}
}
示例11: 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');
}
}
示例12: 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));
}
示例13: 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");
}
}
}
}
}
示例14: 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;
}
示例15: __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));
}