本文整理汇总了PHP中JApplication类的典型用法代码示例。如果您正苦于以下问题:PHP JApplication类的具体用法?PHP JApplication怎么用?PHP JApplication使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了JApplication类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testIsSSLConnection
/**
* Test JApplication::isSSLConnection
*
* @return void
*/
public function testIsSSLConnection()
{
unset($_SERVER['HTTPS']);
$this->assertThat($this->object->isSSLConnection(), $this->equalTo(false));
$_SERVER['HTTPS'] = 'on';
$this->assertThat($this->object->isSSLConnection(), $this->equalTo(true));
}
示例2: checkPermission
function checkPermission($function)
{
$c = jomtube_configs::get_instance();
$user =& JFactory::getUser();
if ($user->gid < $c->{$function} && $c->{$function} != 29) {
// Redirect to login
$uri = JFactory::getURI();
$return = $uri->toString();
$url = 'index.php?option=com_user&view=login';
$url .= '&return=' . base64_encode($return);
$r = new JApplication();
$r->redirect($url, JText::_('You do not have permission to upload videos'));
return;
}
}
示例3: display
public function display()
{
$portal = $this->getModel()->getItem();
header('X-Portal-ID: ' . $portal->id);
$doc =& JFactory::getDocument();
if ($portal->title) {
$doc->setTitle($portal->title);
}
if ($portal->meta_keywords) {
$doc->setMetaData('Keywords', $portal->meta_keywords);
}
if ($portal->meta_description) {
$doc->setMetaData('Description', $portal->meta_description);
}
//TODO: Check if itemId
$pathway = JFactory::getApplication()->getPathway();
if (!JApplication::getInstance('site')->getMenu()->getItems('link', 'index.php?option=com_portals&view=portal&id=' . $portal->id, true)) {
$category = $this->getService('com://site/portals.model.categories')->id($portal->portals_category_id)->getItem();
if ($category->id) {
$item = JApplication::getInstance('site')->getMenu()->getItems('link', 'index.php?option=com_portals&view=category&id=' . $category->id, true);
if ($item) {
$i = 0;
foreach (explode('/', $item->route) as $part) {
$pathway->addItem(ucfirst($part), 'index.php?Itemid=' . $item->tree[$i]);
$i++;
}
}
$pathway->addItem($portal->title);
}
}
return parent::display();
}
示例4: prepareDisplay
protected function prepareDisplay($preconfig)
{
if (JCck::getConfig_Param('debug', 0)) {
jimport('joomla.error.profiler');
$profiler = new JProfiler();
}
$app = JFactory::getApplication();
$this->form = $this->get('Form');
$this->option = $app->input->get('option', '');
$this->item = $this->get('Item');
$this->state = $this->get('State');
$option = $this->option;
$params = new JRegistry();
$view = $this->getName();
$isNew = 1;
$live = '';
$lives = array();
$variation = '';
jimport('cck.base.form.form');
include_once JPATH_LIBRARIES_CCK . '/base/form/form_inc.php';
if (isset($config['id'])) {
JFactory::getSession()->set('cck_hash_seblod_form', JApplication::getHash($id . '|' . $type->name . '|' . $config['id']));
}
$this->config =& $config;
$this->data =& $data;
$this->id =& $id;
$this->isNew =& $isNew;
$this->params =& $params;
$this->stage =& $stage;
$this->type =& $type;
$title = isset($type->title) ? $type->title : '';
$name = isset($type->name) ? $type->name : '';
$this->addToolbar($title, $name);
}
示例5: prepareTable
protected function prepareTable($table)
{
jimport('joomla.filter.output');
$date = JFactory::getDate();
$user = JFactory::getUser();
$table->title = htmlspecialchars_decode($table->title, ENT_QUOTES);
$table->alias = JApplication::stringURLSafe($table->alias);
if (empty($table->alias)) {
$table->alias = JApplication::stringURLSafe($table->title);
}
if (intval($table->date) == 0) {
$table->date = JFactory::getDate()->toSql();
}
if (empty($table->id)) {
// Set the values
//$table->created = $date->toSql();
// Set ordering to the last item if not set
if (empty($table->ordering)) {
$db = JFactory::getDbo();
$db->setQuery('SELECT MAX(ordering) FROM #__phocagallery_comments WHERE catid = ' . (int) $table->catid);
$max = $db->loadResult();
$table->ordering = $max + 1;
}
} else {
// Set the values
//$table->modified = $date->toSql();
//$table->modified_by = $user->get('id');
}
}
示例6: store
public function store($updateNulls = false)
{
$isNew = false;
if (!$this->id) {
// New document
$this->downloaded = 0;
$isNew = true;
}
if (isset($this->alias) && isset($this->name) && $this->alias == "") {
$this->alias = preg_replace("/ /", "-", strtolower($this->name));
}
if (version_compare(JVERSION, '3.0', '>=')) {
$this->alias = JApplicationHelper::stringURLSafe($this->alias);
} else {
$this->alias = JApplication::stringURLSafe($this->alias);
}
// Trigger events to osdownloads plugins
$dispatcher = $this->getDispatcher();
$pluginResults = $dispatcher->trigger('onOSDownloadsBeforeSaveFile', array(&$this, $isNew));
$result = false;
if ($pluginResults !== false) {
$result = parent::store($updateNulls);
$dispatcher->trigger('onOSDownloadsAfterSaveFile', array($result, &$this));
}
return $result;
}
示例7: check
/**
* Overloaded check function
*
* @return boolean True on success
*
* @see JTable::check
* @since 11.1
*/
public function check()
{
// If the alias field is empty, set it to the title.
$this->alias = trim($this->alias);
if (empty($this->alias) && ($this->type != 'alias' && $this->type != 'url')) {
$this->alias = $this->title;
}
// Make the alias URL safe.
$this->alias = JApplication::stringURLSafe($this->alias);
if (trim(str_replace('-', '', $this->alias)) == '') {
$this->alias = JFactory::getDate()->format('Y-m-d-H-i-s');
}
// Cast the home property to an int for checking.
$this->home = (int) $this->home;
// Verify that a first level menu item alias is not 'component'.
if ($this->parent_id == 1 && $this->alias == 'component') {
$this->setError(JText::_('JLIB_DATABASE_ERROR_MENU_ROOT_ALIAS_COMPONENT'));
return false;
}
// Verify that a first level menu item alias is not the name of a folder.
jimport('joomla.filesystem.folder');
if ($this->parent_id == 1 && in_array($this->alias, JFolder::folders(JPATH_ROOT))) {
$this->setError(JText::sprintf('JLIB_DATABASE_ERROR_MENU_ROOT_ALIAS_FOLDER', $this->alias, $this->alias));
return false;
}
// Verify that the home item a component.
if ($this->home && $this->type != 'component') {
$this->setError(JText::_('JLIB_DATABASE_ERROR_MENU_HOME_NOT_COMPONENT'));
return false;
}
return true;
}
示例8: _findItemId
protected static function _findItemId($needles)
{
// Prepare the reverse lookup array.
if (self::$lookup === null) {
self::$lookup = array();
$component =& JComponentHelper::getComponent('com_xmap');
$menus =& JApplication::getMenu('site', array());
$items = $menus->getItems('component_id', $component->id);
foreach ($items as &$item) {
if (isset($item->query) && isset($item->query['view'])) {
$view = $item->query['view'];
if (!isset(self::$lookup[$view])) {
self::$lookup[$view] = array();
}
if (isset($item->query['id'])) {
self::$lookup[$view][$item->query['id']] = $item->id;
}
}
}
}
$match = null;
foreach ($needles as $view => $id) {
if (isset(self::$lookup[$view])) {
if (isset(self::$lookup[$view][$id])) {
return self::$lookup[$view][$id];
}
}
}
return null;
}
示例9: store
public function store($updateNulls = false)
{
if (isset($this->alias)) {
$this->alias = JApplication::stringURLSafe($this->alias);
}
if (!empty($this->metakey)) {
// Only process if not empty
$bad_characters = array("\n", "\r", "\"", "<", ">");
// array of characters to remove
$after_clean = JString::str_ireplace($bad_characters, "", $this->metakey);
// remove bad characters
$keys = explode(',', $after_clean);
// create array using commas as delimiter
$clean_keys = array();
foreach ($keys as $key) {
if (trim($key)) {
// Ignore blank keywords
$clean_keys[] = trim($key);
}
}
$this->metakey = implode(", ", $clean_keys);
// put array back together delimited by ", "
}
if (empty($this->answer_created_by_id)) {
$this->answer_created_by_id = JFactory::getUser()->id;
}
return parent::store($updateNulls);
}
示例10: createNewUser
public function createNewUser($params)
{
$user = new JUser(0);
JLoader::import('joomla.application.component.helper');
$usersConfig = JComponentHelper::getParams('com_users');
$newUsertype = $usersConfig->get('new_usertype');
// get the New User Group from com_users' settings
if (empty($newUsertype)) {
$newUsertype = 2;
}
$params['groups'] = array($newUsertype);
$params['sendEmail'] = 0;
// Set the user's default language to whatever the site's current language is
if (version_compare(JVERSION, '3.0', 'ge')) {
$params['params'] = array('language' => JFactory::getConfig()->get('language'));
} else {
$params['params'] = array('language' => JFactory::getConfig()->getValue('config.language'));
}
JLoader::import('joomla.user.helper');
$params['block'] = 0;
$randomString = JUserHelper::genRandomPassword();
if (version_compare(JVERSION, '3.2', 'ge')) {
$hash = JApplication::getHash($randomString);
} else {
$hash = JFactory::getApplication()->getHash($randomString);
}
$params['activation'] = $hash;
$user->bind($params);
$userIsSaved = $user->save();
if ($userIsSaved) {
return $user->id;
} else {
return false;
}
}
示例11: onAfterInitialise
/**
* Event onAfterInitialise
*
* @access public
* @param null
* @return null
*/
public function onAfterInitialise()
{
// If this is the Administrator-application, or if debugging is set, do nothing
$application = JFactory::getApplication();
if ($application->isAdmin()) {
return;
}
// Disable browser-detection
$application->setDetectBrowser(false);
// Detect the language
$languageTag = JFactory::getLanguage()->getTag();
$languageInput = JRequest::getString('language');
// Get the bindings
$bindings = $this->getBindings();
// Check for the binding of the current language
if (!empty($languageInput)) {
if (isset($bindings[$languageTag])) {
$domain = $bindings[$languageTag];
if (stristr(JURI::current(), $domain) == false) {
// Add URL-elements to the domain
$domain = $this->getUrlFromDomain($domain);
// Replace the current domain with the new domain
$currentUrl = JURI::current();
$newUrl = str_replace(JURI::base(), $domain, $currentUrl);
// Strip out the sef-language-part
$languages = JLanguageHelper::getLanguages('sef');
foreach ($languages as $languageSef => $language) {
if ($language->lang_code == $languageTag) {
//$newUrl = str_replace('/'.$languageSef.'/', '/', $newUrl); // @todo: This d
break;
}
}
// Set the cookie
$conf = JFactory::getConfig();
$cookie_domain = $conf->get('config.cookie_domain', '');
$cookie_path = $conf->get('config.cookie_path', '/');
setcookie(JApplication::getHash('language'), $languageTag, time() + 365 * 86400, $cookie_path, $cookie_domain);
// Redirect
$application->redirect($newUrl);
$application->close();
}
}
} else {
// Check if the current default language is correct
foreach ($bindings as $languageCode => $domain) {
if (stristr(JURI::current(), $domain) == true) {
// Set the cookie
$conf = JFactory::getConfig();
$cookie_domain = $conf->get('config.cookie_domain', '');
$cookie_path = $conf->get('config.cookie_path', '/');
setcookie(JApplication::getHash('language'), $languageCode, time() + 365 * 86400, $cookie_path, $cookie_domain);
// Change the current default language
JRequest::setVar('language', $languageCode);
JFactory::getLanguage()->setDefault($languageCode);
JFactory::getLanguage()->setLanguage($languageCode);
break;
}
}
}
}
示例12: check
function check()
{
jimport('joomla.filter.output');
$this->name = htmlspecialchars_decode($this->name, ENT_QUOTES);
if (empty($this->ordering)) {
$this->ordering = self::getNextOrder();
}
if (empty($this->alias)) {
$this->alias = $this->name;
}
$this->alias = JApplication::stringURLSafe($this->alias);
if (trim(str_replace('1', '', $this->alias)) == '') {
$this->alias = JFactory::getDate()->format("Y-m-d-H-i-s");
}
$this->alias = str_replace("-", "_", $this->alias);
if ($this->type == '0') {
return false;
}
if (is_array($_REQUEST['jform']['type_' . $this->type])) {
$_REQUEST['jform']['type_' . $this->type]['value'] = $this->remove_array_empty_values($_REQUEST['jform']['type_' . $this->type]['value']);
$_REQUEST['jform']['type_' . $this->type] = serialize($_REQUEST['jform']['type_' . $this->type]);
}
if ($this->type != 'image') {
$this->default_values = $_REQUEST['jform']['type_' . $this->type];
}
return true;
}
示例13: loadMultilangData
function loadMultilangData($prepareElementCallback)
{
$languages = JLanguageHelper::getLanguages();
$app = JApplication::getInstance('site');
$menu = $app->getMenu();
$config = JFactory::getConfig();
$sef = $config->get('sef', 0);
$sefRewrite = $config->get('sef_rewrite', 0);
$defaultLangCode = JFactory::getLanguage()->getDefault();
$websites = array();
//$websites['*'] = $menu->getDefault('*'); // TODO add?
$languageFilterEnabled = JPluginHelper::isEnabled('system', 'languagefilter');
if (!$languageFilterEnabled || $sef != '1') {
// TODO check also if sef is enabled
return $websites;
}
$oldLanguageFilterValue = $app->setLanguageFilter(true);
// necessary that $menu->getDefault() works
foreach ($languages as $language) {
$langCode = $language->lang_code;
$default = $menu->getDefault($langCode);
if ($default && $default->language == $langCode) {
$websites[$langCode] = $prepareElementCallback($language, $langCode, $defaultLangCode, $sefRewrite);
}
}
$app->setLanguageFilter($oldLanguageFilterValue);
return $websites;
}
示例14: getItems
/**
*
*/
public static function getItems($option = '')
{
static $items;
if (empty($option)) {
$com = DSC::getApp();
$option = 'com_' . $com->getName();
}
$app = JApplication::getInstance('site');
$menus = $app->getMenu();
if (empty($menus)) {
return array();
}
if (empty($items)) {
$items = array();
}
if (empty($items[$option])) {
$component = JComponentHelper::getComponent($option);
foreach ($menus->getItems('component', $option) as $item) {
if (!is_object($item)) {
continue;
}
if ($item->component_id == $component->id || $item->componentid == $component->id || !empty($item->query['option']) && $item->query['option'] == $option) {
$items[$option][] = $item;
}
}
}
if (empty($items[$option])) {
return array();
}
return $items[$option];
}
示例15: populateState
/**
* Method to auto-populate the model state.
*
* Note. Calling getState in this method will result in recursion.
*
* @since 1.6
*/
protected function populateState()
{
$basename = JRequest::getString(JApplication::getHash($this->_context . '.basename'), '__SITE__', 'cookie');
$this->setState('basename', $basename);
$compressed = JRequest::getInt(JApplication::getHash($this->_context . '.compressed'), 1, 'cookie');
$this->setState('compressed', $compressed);
}