本文整理汇总了PHP中JUtility类的典型用法代码示例。如果您正苦于以下问题:PHP JUtility类的具体用法?PHP JUtility怎么用?PHP JUtility使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了JUtility类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testParseAttributes
/**
* Test parseAttributes
*
* @param string $tag tag to be parsed
* @param array $expected resulting array of attribute values
*
* @return void
*
* @dataProvider casesParseAttributes
* @covers JUtility::parseAttributes
*/
public function testParseAttributes($tag, $expected)
{
$this->assertThat(
JUtility::parseAttributes($tag),
$this->equalTo($expected)
);
}
示例2: sendEmail
function sendEmail()
{
// Check for request forgeries
JRequest::checkToken() or jexit('Invalid Token');
$post = JRequest::get('post');
$this->addModelPath(JPATH_COMPONENT_ADMINISTRATOR . DS . 'models');
$model = $this->getModel('location');
$location = $model->getData();
$contact_name = $post['contact_name'];
$contact_email = $post['contact_email'];
$contact_message = $post['contact_message'];
if ($contact_name == null || $contact_message == null) {
echo JText::_('Please enter a name and message to send.');
return false;
} else {
if (false) {
return false;
} else {
JUtility::sendMail($contact_email, $contact_name, $location->email, 'Contact Message for: ' . $location->name, $contact_message, 0, null, null, null, $contact_email, $contact_name);
echo JText::_('Message Sent');
return true;
}
}
return false;
}
示例3: save
function save()
{
// Check for request forgeries
JRequest::checkToken() or die('COM_JOOMLEAGUE_GLOBAL_INVALID_TOKEN');
$cid = JRequest::getInt("cid", 0);
$post = JRequest::get('post');
if ($cid > 0) {
$club =& JTable::getInstance("Club", "Table");
$club->load($cid);
$club->bind($post);
$params =& JComponentHelper::getParams('com_joomleague');
if ($club->store() && $params->get('cfg_edit_club_info_update_notify') == "1") {
$db = JFactory::getDBO();
$user = JFactory::getUser();
$query = "SELECT email\n FROM #__users \n WHERE usertype = 'Super Administrator' \n OR usertype = 'Administrator'";
$db->setQuery($query);
$to = $db->loadResultArray();
$subject = addslashes(sprintf(JText::_("COM_JOOMLEAGUE_ADMIN_EDIT_CLUB_INFO_SUBJECT"), $club->name));
$message = addslashes(sprintf(JText::_("COM_JOOMLEAGUE_ADMIN_EDIT_CLUB_INFO_MESSAGE"), $user->name, $club->name));
$message .= $this->_getShowClubInfoLink();
JUtility::sendMail('', '', $to, $subject, $message);
}
}
$this->setRedirect($this->_getShowClubInfoLink());
}
示例4: onAfterInitialise
function onAfterInitialise()
{
$app = JFactory::getApplication();
// No remember me for admin
if ($app->isAdmin()) {
return;
}
$user = JFactory::getUser();
if ($user->get('guest')) {
jimport('joomla.utilities.utility');
$hash = JUtility::getHash('JLOGIN_REMEMBER');
if ($str = JRequest::getString($hash, '', 'cookie', JREQUEST_ALLOWRAW | JREQUEST_NOTRIM)) {
jimport('joomla.utilities.simplecrypt');
//Create the encryption key, apply extra hardening using the user agent string
$key = JUtility::getHash(@$_SERVER['HTTP_USER_AGENT']);
$crypt = new JSimpleCrypt($key);
$str = $crypt->decrypt($str);
$options = array();
$options['silent'] = true;
if (!$app->login(@unserialize($str), $options)) {
$config = JFactory::getConfig();
$cookie_domain = $config->get('cookie_domain', '');
$cookie_path = $config->get('cookie_path', '/');
// Clear the remember me cookie
setcookie(JUtility::getHash('JLOGIN_REMEMBER'), false, time() - 86400, $cookie_path, $cookie_domain);
}
}
}
}
示例5: onAfterRoute
public function onAfterRoute()
{
$application = JFactory::getApplication();
if($application->isSite())
{
switch(JRequest::getVar('option', null, 'method', 'cmd'))
{
case 'com_user':
JRequest::setVar('option', 'com_users', 'get');
switch(JRequest::getVar('view', null, 'method', 'cmd'))
{
case 'login':
if(!JFactory::getUser()->guest) {
JRequest::setVar('view', 'logout', 'get');
}
break;
case 'remind':
JRequest::setVar('view', 'remind', 'get');
break;
case 'register':
JRequest::setVar('view', 'user', 'get');
JRequest::setVar('layout', 'register', 'get');
break;
case 'user':
if(JRequest::getVar('task', null, 'get', 'cmd') == 'edit') {
JRequest::setVar('layout', 'form', 'get');
}
}
switch(JRequest::getVar('task', null, 'method', 'cmd'))
{
case 'login':
JRequest::setVar('view', 'login', 'get');
JRequest::setVar('action', 'login', 'post');
JRequest::setVar('password', JRequest::getVar('passwd', null, 'method', 'none'), 'post');
break;
}
break;
}
if(JRequest::getMethod() == 'POST')
{
$token = JUtility::getToken();
if(JRequest::getVar($token, null, 'post', 'alnum') == 1) {
JRequest::setVar('_token', $token, 'post');
}
}
}
}
示例6: display
public function display()
{
$this->assign('sitebase', trim(JURI::root(), '/'));
$this->assign('token', JUtility::getToken());
$this->assign('container', $this->getModel()->getState()->container);
return parent::display();
}
示例7: delete
public function delete($id = null)
{
// Include dependencies
jimport('joomla.application.component.controller');
jimport('joomla.form.form');
jimport('joomla.database.table');
require_once JPATH_ADMINISTRATOR . '/components/com_categories/controllers/categories.php';
require_once JPATH_ADMINISTRATOR . '/components/com_categories/models/category.php';
JForm::addFormPath(JPATH_ADMINISTRATOR . '/components/com_categories/models/forms/');
// Fake parameters
$_POST['task'] = 'trash';
$_REQUEST['task'] = 'trash';
$_REQUEST[JUtility::getToken()] = 1;
$_POST[JUtility::getToken()] = 1;
JFactory::getLanguage()->load('com_categories', JPATH_ADMINISTRATOR);
$controller = new CategoriesControllerCategories();
try {
$controller->execute('trash');
} catch (JException $e) {
$success = false;
$controller->set('messageType', 'error');
$controller->set('message', $e->getMessage());
}
if ($controller->getError()) {
$response = $this->getErrorResponse(400, $controller->getError());
} elseif ('error' == $controller->get('messageType')) {
$response = $this->getErrorResponse(400, $controller->get('message'));
} else {
$response = $this->getSuccessResponse(200, $controller->get('message'));
}
$this->plugin->setResponse($response);
}
示例8: cria_html
function cria_html()
{
// adiciona a biblioteca juri
jimport('joomla.environment.uri');
// verifica se a urlbase foi adicionada
if (!is_null($this->url_base)) {
$u =& JURI::getInstance($this->url_base);
} else {
$u =& JURI::getInstance();
}
$links = '';
$paginas_adm_select = '';
$select = '';
// loop nas páginas
for ($i = 1; $i <= $this->total_paginas; $i++) {
// adiciona a var na url
$u->setVar($this->get_var_pagina, $i);
// retorna o html tag a
$class = $i == $this->pagina_atual ? ' class="atual"' : '';
$links .= sprintf('<a href="%s"%s>%d</a> ', JRoute::_($u->toString()), $class, $i);
// retorna o html select
$selected = $i == $this->pagina_atual ? ' selected="selected"' : '';
// cria o select para o site
$select .= sprintf('<option value="%s" %s>Página %d</option> ', JRoute::_($u->toString()), $selected, $i);
// cria o select para o adm
$paginas_adm_select .= sprintf('<option value="%s" %s>Página %d</option> ', $i, $selected, $i);
}
// paginas para o adm
$query = JRequest::get('post');
unset($query[JUtility::getToken()], $query['funcao'], $query['method'], $query['class'], $query['pagina'], $query['programa'], $query['template'], $query['processID']);
$u->setQuery($query);
$u->setVar($this->get_var_pagina, '');
$js = sprintf('<script type="text/javascript">$(function(){ $(\'select#%s\').change(function(){ eDesktop.dialog.load({programa: "%s", processID: "%s", pagina: "%s", query: "%s"+ $(this).val() }); });});</script>', $this->get_var_pagina, JRequest::getvar('programa'), JRequest::getvar('processID'), JRequest::getvar('pagina'), $u->getQuery());
$paginas_adm_select = sprintf('<select name="%s" id="%s">%s</select>%s ', $this->get_var_pagina, $this->get_var_pagina, $paginas_adm_select, $js);
$this->html['paginas.adm.select'] = $paginas_adm_select;
// páginas para o site
$js = sprintf('<script type="text/javascript">$(function(){ $(\'select#%s\').change(function(){window.location = $(this).val();});});</script>', $this->get_var_pagina);
$select = sprintf('<select name="%s" id="%s">%s</select>%s', $this->get_var_pagina, $this->get_var_pagina, $select, $js);
$this->html['paginas.links'] = $links;
$this->html['paginas.select'] = $select;
// ordem para site
$order = '';
$this->order_atual = JRequest::getVar($this->get_var_order);
if (count($this->orders)) {
foreach ($this->orders as $k => $v) {
$u->setVar($this->get_var_pagina, 1);
$u->setVar($this->get_var_order, $k);
$selected = $k == $this->order_atual ? ' selected="selected"' : '';
$order .= sprintf('<option value="%s" %s>%s</option> ', JRoute::_($u->toString()), $selected, $v['label']);
}
$js = sprintf('<script type="text/javascript">$(function(){ $(\'select#%s\').change(function(){window.location = $(this).val();});});</script>', $this->get_var_order);
$order = sprintf('<select name="%s" id="%s">%s</select>%s', $this->get_var_order, $this->get_var_order, $order, $js);
//
$this->html['order.select'] = $order;
}
foreach ($this->html as $k => $v) {
$key = str_replace('.', '_', $k);
$this->html[$key] = $v;
}
}
示例9: display
/**
* Display the view
*/
public function display($tpl = null)
{
$this->items = $this->get('Items');
$this->pagination = $this->get('Pagination');
$this->state = $this->get('State');
$this->enabled = $this->state->params->get('enabled');
// Check for errors. @todo this has to be queed up and converted to JSON
if (count($errors = $this->get('Errors'))) {
JError::raiseError(500, implode("\n", $errors));
return false;
}
$r = new JObject;
$r->token = JUtility::getToken(true);
$r->items = array();
foreach ($this->items as $i => $item) {
$rItem = new JObject;
$rItem->index = $i + 1 + $this->pagination->limitstart;
$rItem->search_term = $item->search_term;
if ($this->state->get('filter.results')) {
$rItem->results = (int) $item->returns;
} else {
$rItem->results = JText::_('COM_SEARCH_NO_RESULTS');
}
$r->items[$i] = $rItem;
}
echo json_encode($r);
}
示例10: alreadyVoted
function alreadyVoted($id)
{
$mainframe = JFactory::getApplication();
$cookieName = JUtility::getHash($mainframe->getName() . 'poll' . $id);
$voted = JRequest::getVar($cookieName, '0', 'COOKIE', 'INT');
return $voted;
}
示例11: display
function display($tpl = null)
{
// Frontpage hack
$this->addTemplatePath(JPATH_COMPONENT_ADMINISTRATOR . DS . 'views' . DS . 'link' . DS . 'tmpl');
// Only allow "component" template
JRequest::setVar('tmpl', 'component');
// JFactory
$user =& JFactory::getUser();
$config =& JFactory::getConfig();
$doc =& JFactory::getDocument();
$lingo =& JFactory::getLanguage();
// Include styles
$doc->addStyleSheet(LINKR_ASSETS . 'css/modal.css?' . LINKR_VERSION_INC);
// Template override
global $mainframe;
$tmpl = $mainframe->getTemplate();
if (file_exists(JPATH_BASE . DS . 'templates' . DS . $tmpl . DS . 'linkr.css')) {
$doc->addStyleSheet(JURI::base() . 'templates/' . $tmpl . '/linkr.css');
} elseif (file_exists(JPATH_BASE . DS . 'templates' . DS . $tmpl . DS . 'css' . DS . 'linkr.css')) {
$doc->addStyleSheet(JURI::base() . 'templates/' . $tmpl . '/css/linkr.css');
}
// Editor name, request endpoint, document base
$editor = JRequest::getString('e_name', 'text');
$rUrl = JURI::base() . 'index.php?option=com_linkr&view=request&' . JUtility::getToken() . '=1';
// Include scripts
JHTML::_('behavior.mootools');
$unc = LinkrHelper::getParam('compress', 1) ? '.js' : '-UCP.js';
$doc->addScript(LINKR_ASSETS . 'js/helper' . $unc . '?' . LINKR_VERSION_INC);
$doc->addScriptDeclaration('var Linkr=new LinkrAPI(' . '[' . implode(',', explode('.', LINKR_VERSION_READ)) . '],' . '"' . $rUrl . '",' . '"' . $editor . '",' . '"' . JURI::root() . '",' . '[' . '"' . JRequest::getWord('mode', 'squeezebox') . '",' . '"' . $lingo->getTag() . '",' . '"' . LinkrHelper::UTF8Encode(JText::_('MISSING_TEXT', true)) . '",' . '"' . LinkrHelper::UTF8Encode(JText::_('IMG_ANCHOR', true)) . '",' . '"' . LINKR_ASSETS . 'img/",' . $user->get('aid') . ']' . ');' . 'var LinkrHelper=Linkr;');
// Frontend fix
if (LinkrHelper::isSite()) {
//$doc->setBase(LinkrHelper::getLinkrUrl($editor));
}
// References
$this->assign('links', $this->get('Links'));
$this->assign('tools', $this->get('ToolLinks'));
// Localize text
if ($text = $this->get('L18N')) {
$l18n = array();
foreach ($text as $k => $v) {
$l18n[] = '["' . $k . '","' . $v . '"]';
}
$doc->addScriptDeclaration('Linkr.setL18N([' . implode(',', $l18n) . ']);');
}
// 3rd party javascript
if ($js = $this->get('Scripts')) {
$doc->addScriptDeclaration($js);
}
// Load single link
$load = '';
$inc = $this->get('IncludedLinks');
if (!$this->tools['count'] && $this->links['count'] == 1) {
$load = 'Linkr.__fr=function(){' . $inc[$this->links['name'][0]] . '};';
} elseif (!$this->links['count'] && $this->tools['count'] == 1) {
$load = 'Linkr.__fr=function(){' . $inc[$this->tools['name'][0]] . '};';
}
// Fire "onLoad" event
$doc->addScriptDeclaration('window.addEvent("domready",function(){' . $load . 'Linkr.fireEvent("onLoad");' . '});');
parent::display($tpl);
}
示例12: view
/**
* Show the form in the admin
*
* @return null
*/
public function view()
{
$document = JFactory::getDocument();
$model = JModel::getInstance('Form', 'FabrikFEModel');
$viewType = $document->getType();
$this->setPath('view', COM_FABRIK_FRONTEND . '/views');
$viewLayout = JRequest::getCmd('layout', 'default');
$view = $this->getView('form', $viewType, '');
$view->setModel($model, true);
$view->isMambot = $this->isMambot;
// Set the layout
$view->setLayout($viewLayout);
// @TODO check for cached version
JToolBarHelper::title(JText::_('COM_FABRIK_MANAGER_FORMS'), 'forms.png');
if (in_array(JRequest::getCmd('format'), array('raw', 'csv', 'pdf'))) {
$view->display();
} else {
$user = JFactory::getUser();
$post = JRequest::get('post');
$cacheid = serialize(array(JRequest::getURI(), $post, $user->get('id'), get_class($view), 'display', $this->cacheId));
$cache = JFactory::getCache('com_fabrik', 'view');
ob_start();
$cache->get($view, 'display', $cacheid);
$contents = ob_get_contents();
ob_end_clean();
$token = JUtility::getToken();
$search = '#<input type="hidden" name="[0-9a-f]{32}" value="1" />#';
$replacement = '<input type="hidden" name="' . $token . '" value="1" />';
echo preg_replace($search, $replacement, $contents);
}
FabrikAdminHelper::addSubmenu(JRequest::getWord('view', 'lists'));
}
示例13: parseLang
public function parseLang($vars)
{
if (Mijosef::getConfig()->multilang == 0) {
return;
}
if (empty($vars['lang'])) {
$lang = JRequest::getWord('lang', '');
if (empty($lang)) {
return;
}
$vars['lang'] = $lang;
}
$languages = JLanguageHelper::getLanguages('sef');
$lang_code = $languages[$vars['lang']]->lang_code;
// if current language, don't bother
if ($lang_code == JFactory::getLanguage()->getTag()) {
//self::checkHomepage($vars['lang']);
return;
}
// Create a cookie
$conf = JFactory::getConfig();
$cookie_domain = $conf->get('config.cookie_domain', '');
$cookie_path = $conf->get('config.cookie_path', '/');
setcookie(JUtility::getHash('language'), $lang_code, time() + 365 * 86400, $cookie_path, $cookie_domain);
// set the request var
JRequest::setVar('language', $lang_code);
// set current language
jimport('joomla.language.language');
$conf = JFactory::getConfig();
$debug = $conf->get('debug_lang');
$lang = JLanguage::getInstance($lang_code, $debug);
JFactory::$language = $lang;
self::$_lang = $vars['lang'];
}
示例14: sendOnPageLoad
function sendOnPageLoad($max = 5)
{
$db = EasyBlogHelper::db();
$config = EasyBlogHelper::getConfig();
$sendHTML = $config->get('main_mailqueuehtmlformat', 0);
// Delete existing mails that has already been sent.
$query = 'DELETE FROM ' . $db->nameQuote('#__easyblog_mailq') . ' WHERE ' . $db->nameQuote('status') . '=' . $db->Quote(1) . ' AND DATEDIFF(NOW(), `created`) >= 7';
$db->setQuery($query);
$db->Query();
$query = 'SELECT `id` FROM `#__easyblog_mailq` WHERE `status` = 0';
$query .= ' ORDER BY `created` ASC';
$query .= ' LIMIT ' . $max;
$db->setQuery($query);
$result = $db->loadObjectList();
if (!empty($result)) {
foreach ($result as $mail) {
$mailq = EasyBlogHelper::getTable('MailQueue', 'Table');
$mailq->load($mail->id);
// update the status to 1 == proccessed
$mailq->status = 1;
if ($mailq->store()) {
// Send emails out.
if (EasyBlogHelper::getJoomlaVersion() >= '3.0') {
$mail = JFactory::getMailer();
$mail->sendMail($mailq->mailfrom, $mailq->fromname, $mailq->recipient, $mailq->subject, $mailq->body, $sendHTML);
} else {
JUtility::sendMail($mailq->mailfrom, $mailq->fromname, $mailq->recipient, $mailq->subject, $mailq->body, $sendHTML);
}
}
}
}
}
示例15: _tokenValue
protected function _tokenValue($force = false)
{
if (empty($this->_token_value) || $force) {
$this->_token_value = JUtility::getToken($force);
}
return parent::_tokenValue($force);
}