本文整理汇总了PHP中JText::sprintf方法的典型用法代码示例。如果您正苦于以下问题:PHP JText::sprintf方法的具体用法?PHP JText::sprintf怎么用?PHP JText::sprintf使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JText
的用法示例。
在下文中一共展示了JText::sprintf方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: display
/**
* Method to display a view.
*
* @param boolean If true, the view output will be cached
* @param array An array of safe url parameters and their variable types, for valid values see {@link JFilterInput::clean()}.
*
* @return JController This object to support chaining.
* @since 1.5
*/
public function display($cachable = false, $urlparams = false)
{
require_once JPATH_COMPONENT . '/helpers/users.php';
// Load the submenu.
UsersHelper::addSubmenu(JRequest::getCmd('view', 'users'));
$view = JRequest::getCmd('view', 'users');
$layout = JRequest::getCmd('layout', 'default');
$id = JRequest::getInt('id');
if (!$this->canView($view)) {
JError::raiseWarning(404, JText::_('JERROR_ALERTNOAUTHOR'));
return;
}
// Check for edit form.
if ($view == 'user' && $layout == 'edit' && !$this->checkEditId('com_users.edit.user', $id)) {
// Somehow the person just went to the form - we don't allow that.
$this->setError(JText::sprintf('JLIB_APPLICATION_ERROR_UNHELD_ID', $id));
$this->setMessage($this->getError(), 'error');
$this->setRedirect(JRoute::_('index.php?option=com_users&view=users', false));
return false;
} elseif ($view == 'group' && $layout == 'edit' && !$this->checkEditId('com_users.edit.group', $id)) {
// Somehow the person just went to the form - we don't allow that.
$this->setError(JText::sprintf('JLIB_APPLICATION_ERROR_UNHELD_ID', $id));
$this->setMessage($this->getError(), 'error');
$this->setRedirect(JRoute::_('index.php?option=com_users&view=groups', false));
return false;
} elseif ($view == 'level' && $layout == 'edit' && !$this->checkEditId('com_users.edit.level', $id)) {
// Somehow the person just went to the form - we don't allow that.
$this->setError(JText::sprintf('JLIB_APPLICATION_ERROR_UNHELD_ID', $id));
$this->setMessage($this->getError(), 'error');
$this->setRedirect(JRoute::_('index.php?option=com_users&view=levels', false));
return false;
}
return parent::display();
}
示例2: getInput
protected function getInput()
{
if (!NNFrameworkFunctions::extensionInstalled('virtuemart')) {
return '<fieldset class="alert alert-danger">' . JText::_('ERROR') . ': ' . JText::sprintf('NN_FILES_NOT_FOUND', JText::_('NN_VIRTUEMART')) . '</fieldset>';
}
$this->params = $this->element->attributes();
$this->db = JFactory::getDBO();
$group = $this->get('group', 'categories');
$tables = $this->db->getTableList();
if (!in_array($this->db->getPrefix() . 'virtuemart_' . $group, $tables)) {
return '<fieldset class="alert alert-danger">' . JText::_('ERROR') . ': ' . JText::sprintf('NN_TABLE_NOT_FOUND', JText::_('NN_VIRTUEMART')) . '</fieldset>';
}
$parameters = NNParameters::getInstance();
$params = $parameters->getPluginParams('nnframework');
$this->max_list_count = $params->max_list_count;
if (!is_array($this->value)) {
$this->value = explode(',', $this->value);
}
$options = $this->{'get' . $group}();
$size = (int) $this->get('size');
$multiple = $this->get('multiple');
if ($group == 'categories') {
require_once JPATH_PLUGINS . '/system/nnframework/helpers/html.php';
return nnHtml::selectlist($options, $this->name, $this->value, $this->id, $size, $multiple);
}
$attr = '';
$attr .= ' size="' . (int) $size . '"';
$attr .= $multiple ? ' multiple="multiple"' : '';
return JHtml::_('select.genericlist', $options, $this->name, trim($attr), 'value', 'text', $this->value, $this->id);
}
示例3: display
function display($tpl = null)
{
global $mainframe, $option;
$cid = JRequest::getVar('cid_user');
if (!is_array($cid)) {
$mainframe->redirect('index.php?option=' . $option);
return;
}
$user_id = $cid[0];
$model = $this->getModel('user');
$model->load($user_id);
$this->_setToolBar();
$say = JText::sprintf('USER_RESOURCES_TITLE', $model->user->username);
$root_node = JText::_('RESOURCES_TREE_ROOT_NODE');
$nowdate = JFactory::getDate();
$str_now = JHTML::_('date', $nowdate->toMySQL(), '%Y-%m-%d %H:%M:%S');
$this->assign('nowdate', $str_now);
$this->assign('say', $say);
$this->assign('root_node', $root_node);
$this->assignRef('uid', $user_id);
$this->assignRef('option', $option);
//hide the menu
JRequest::setVar('hidemainmenu', 1);
parent::display();
}
示例4: _prepareDocument
/**
* Prepares the document
*/
protected function _prepareDocument()
{
$app = JFactory::getApplication();
$menus = $app->getMenu();
$pathway = $app->getPathway();
$title = null;
// Because the application sets a default page title,
// we need to get it from the menu item itself
$menu = $menus->getActive();
if ($menu) {
$this->params->def('page_heading', $this->params->get('page_title', $menu->title));
} else {
$this->params->def('page_heading', JText::_('COM_TESTYOURSELF_DEFAULT_PAGE_TITLE'));
}
$title = $this->params->get('page_title', '');
$id = (int) @$menu->query['id'];
if (empty($title)) {
$title = $app->getCfg('sitename');
} elseif ($app->getCfg('sitename_pagetitles', 0) == 1) {
$title = JText::sprintf('JPAGETITLE', $app->getCfg('sitename'), $title);
} elseif ($app->getCfg('sitename_pagetitles', 0) == 2) {
$title = JText::sprintf('JPAGETITLE', $title, $app->getCfg('sitename'));
}
if (empty($title)) {
$title = $this->item->name;
}
$this->document->setTitle($title);
if ($this->params->get('robots')) {
$this->document->setMetadata('robots', $this->params->get('robots'));
}
}
示例5: import
public function import()
{
$app = JFactory::getApplication();
$model = F0FModel::getTmpInstance('Imports', 'AkeebasubsModel');
$file = JRequest::getVar('csvfile', '', 'FILES');
$delimiter = $this->input->getInt('csvdelimiters', 0);
$field = $this->input->getString('field_delimiter', '');
$enclosure = $this->input->getString('field_enclosure', '');
if ($file['error']) {
$this->setRedirect('index.php?option=com_akeebasubs&view=import', JText::_('COM_AKEEBASUBS_IMPORT_ERR_UPLOAD'), 'error');
return true;
}
if ($delimiter != -99) {
list($field, $enclosure) = $model->decodeDelimiterOptions($delimiter);
}
// Import ok, but maybe I have warnings (ie skipped lines)
$result = $model->import($file['tmp_name'], $field, $enclosure);
if ($result !== false) {
$errors = $model->getErrors();
if ($errors) {
$app->enqueueMessage(JText::_('COM_AKEEBASUBS_IMPORT_WITH_WARNINGS'), 'notice');
foreach ($errors as $error) {
$app->enqueueMessage($error, 'notice');
}
} else {
// Import ok, congrat with yourself!
$app->enqueueMessage(JText::sprintf('COM_AKEEBASUBS_IMPORT_OK', $result));
}
} else {
//Uh oh... import failed, let's inform the user why it happened
$app->enqueueMessage(JText::sprintf('COM_AKEEBASUBS_IMPORT_FAIL', $model->getError()), 'error');
}
$this->setRedirect('index.php?option=com_akeebasubs&view=import');
}
示例6: onUserBeforeSave
/**
* Method is called before user data is stored in the database.
*
* Changes the password in LDAP if the user changed their password.
*
* @param array $user Holds the old user data.
* @param boolean $isNew True if a new user is stored.
* @param array $new Holds the new user data.
*
* @return boolean Cancels the save if False.
*
* @since 2.0
*/
public function onUserBeforeSave($user, $isNew, $new)
{
if ($isNew) {
// We dont want to deal with new users here
return;
}
// Get username and password to use for authenticating with Ldap
$username = JArrayHelper::getValue($user, 'username', false, 'string');
$password = JArrayHelper::getValue($new, 'password_clear', null, 'string');
if (!empty($password)) {
$auth = array('authenticate' => SHLdap::AUTH_USER, 'username' => $username, 'password' => $password);
try {
// We will double check the password for double safety (breaks password reset if on)
$authenticate = $this->params->get('authenticate', 0);
// Get the user adapter then set the password on it
$adapter = SHFactory::getUserAdapter($auth);
$adapter->setPassword($password, JArrayHelper::getValue($new, 'current-password', null, 'string'), $authenticate);
SHLog::add(JText::sprintf('PLG_LDAP_PASSWORD_INFO_12411', $username), 12411, JLog::INFO, 'ldap');
} catch (Exception $e) {
// Log and Error out
SHLog::add($e, 12401, JLog::ERROR, 'ldap');
return false;
}
}
}
示例7: getList
static function getList(&$params)
{
//get database
$db = JFactory::getDbo();
$query = $db->getQuery(true);
$query->select('MONTH(created) AS created_month, created, id, title, YEAR(created) AS created_year');
$query->from('#__content');
$query->where('state = 2 AND checked_out = 0');
$query->group('created_year DESC, created_month DESC');
// Filter by language
if (JFactory::getApplication()->getLanguageFilter()) {
$query->where('language in (' . $db->quote(JFactory::getLanguage()->getTag()) . ',' . $db->quote('*') . ')');
}
$db->setQuery($query, 0, intval($params->get('count')));
$rows = (array) $db->loadObjectList();
$app = JFactory::getApplication();
$menu = $app->getMenu();
$item = $menu->getItems('link', 'index.php?option=com_content&view=archive', true);
$itemid = isset($item) && !empty($item->id) ? '&Itemid=' . $item->id : '';
$i = 0;
$lists = array();
foreach ($rows as $row) {
$date = JFactory::getDate($row->created);
$created_month = $date->format('n');
$created_year = $date->format('Y');
$created_year_cal = JHTML::_('date', $row->created, 'Y');
$month_name_cal = JHTML::_('date', $row->created, 'F');
$lists[$i] = new stdClass();
$lists[$i]->link = JRoute::_('index.php?option=com_content&view=archive&year=' . $created_year . '&month=' . $created_month . $itemid);
$lists[$i]->text = JText::sprintf('MOD_ARTICLES_ARCHIVE_DATE', $month_name_cal, $created_year_cal);
$i++;
}
return $lists;
}
示例8: loadManifestFromXML
/**
* Load a manifest from an XML file
*
* @param string $xmlpath Path to XML manifest file
*
* @return boolean Result of load
* @since 1.6
*/
function loadManifestFromXML($xmlfile)
{
$this->manifest_file = JFile::stripExt(basename($xmlfile));
$xml = JFactory::getXML($xmlfile);
if (!$xml) {
$this->_errors[] = JText::sprintf('JLIB_INSTALLER_ERROR_LOAD_XML', $xmlfile);
return false;
} else {
$this->name = (string) $xml->name;
$this->packagename = (string) $xml->packagename;
$this->update = (string) $xml->update;
$this->authorurl = (string) $xml->authorUrl;
$this->author = (string) $xml->author;
$this->authoremail = (string) $xml->authorEmail;
$this->description = (string) $xml->description;
$this->packager = (string) $xml->packager;
$this->packagerurl = (string) $xml->packagerurl;
$this->version = (string) $xml->version;
if (isset($xml->files->file) && count($xml->files->file)) {
foreach ($xml->files->file as $file) {
// NOTE: JExtension doesn't expect a string.
// DO NOT CAST $file
$this->filelist[] = new JExtension($file);
}
}
return true;
}
}
示例9: load
/**
* Loads the entire menu table into memory (taken from Joomla 1.7.3).
*
* @return array
*/
protected static function load()
{
// Initialise variables.
$db = JFactory::getDbo();
$query = $db->getQuery(true);
$query->select('m.id, m.menutype, m.title, m.alias, m.path AS route, m.link, m.type, m.level, m.language');
$query->select('m.browserNav, m.access, m.params, m.home, m.img, m.template_style_id, m.component_id, m.parent_id');
$query->select('e.element as component, m.published');
$query->from('#__menu AS m');
$query->leftJoin('#__extensions AS e ON m.component_id = e.extension_id');
$query->where('m.parent_id > 0');
$query->where('m.client_id = 0');
$query->order('m.lft');
// Set the query
$db->setQuery($query);
if (!(self::$items = $db->loadObjectList('id'))) {
JError::raiseWarning(500, JText::sprintf('JERROR_LOADING_MENUS', $db->getErrorMsg()));
return false;
}
foreach (self::$items as &$item) {
// Get parent information.
$parent_tree = array();
if (isset(self::$items[$item->parent_id])) {
$parent_tree = self::$items[$item->parent_id]->tree;
}
// Create tree
$parent_tree[] = $item->id;
$item->tree = $parent_tree;
// Create the query array.
$url = str_replace('index.php?', '', $item->link);
$url = str_replace('&', '&', $url);
parse_str($url, $item->query);
}
}
示例10: _prepareDocument
/**
* Prepares the document
*/
protected function _prepareDocument()
{
$app = JFactory::getApplication();
$menus = $app->getMenu();
$title = null;
// Because the application sets a default page title,
// we need to get it from the menu item itself
$menu = $menus->getActive();
if (empty($this->item->id)) {
$head = JText::_('COM_USERNOTIFY_FORM_SUBMIT_USERSUBS');
} else {
$head = JText::_('COM_USERNOTIFY_FORM_EDIT_USERSUBS');
}
if ($menu) {
$this->params->def('page_heading', $this->params->get('page_title', $menu->title));
} else {
$this->params->def('page_heading', $head);
}
$title = $this->params->def('page_title', $head);
if ($app->getCfg('sitename_pagetitles', 0)) {
$title = JText::sprintf('JPAGETITLE', $app->getCfg('sitename'), $title);
}
$this->document->setTitle($title);
if ($this->params->get('menu-meta_description')) {
$this->document->setDescription($this->params->get('menu-meta_description'));
}
if ($this->params->get('menu-meta_keywords')) {
$this->document->setMetadata('keywords', $this->params->get('menu-meta_keywords'));
}
if ($this->params->get('robots')) {
$this->document->setMetadata('robots', $this->params->get('robots'));
}
}
示例11: send_certificate
function send_certificate()
{
$app = JFactory::getApplication();
$params = $app->getParams();
$moodle_url = $params->get('MOODLE_URL');
$cert_id = JRequest::getVar('cert_id');
$simple = JRequest::getVar('simple');
$email = JRequest::getString('mailto', '', 'post');
$sender = JRequest::getString('sender', '', 'post');
$from = JRequest::getString('from', '', 'post');
$user = JFactory::getUser();
$username = $user->username;
$subject_default = JText::sprintf('COM_JOOMDLE_CERTIFICATE_EMAIL_SUBJECT', $user->name);
$subject = JRequest::getString('subject', $subject_default, 'post');
if (!$subject) {
$subject = $subject_default;
}
$mailer = JFactory::getMailer();
$config = JFactory::getConfig();
$sender = array($config->get('mailfrom'), $config->get('fromname'));
$mailer->setSender($sender);
$mailer->addRecipient($email);
$body = JText::sprintf('COM_JOOMDLE_CERTIFICATE_EMAIL_BODY', $user->name);
$mailer->setSubject($subject);
$mailer->setBody($body);
$session = JFactory::getSession();
$token = md5($session->getId());
$pdf = file_get_contents($moodle_url . '/auth/joomdle/' . $simple . 'certificate_view.php?id=' . $cert_id . '&certificate=1&action=review&username=' . $username . '&token=' . $token);
$tmp_path = $config->get('tmp_path');
$filename = 'certificate-' . $cert_id . '-' . $user->name . '.pdf';
file_put_contents($tmp_path . '/' . $filename, $pdf);
$mailer->addAttachment($tmp_path . '/' . $filename);
$send = $mailer->Send();
unlink($tmp_path . '/' . $filename);
if ($send !== true) {
JError::raiseNotice(500, JText::_('COM_JOOMDLE_EMAIL_NOT_SENT'));
} else {
?>
<div style="padding: 10px;">
<div style="text-align:right">
<a href="javascript: void window.close()">
<?php
echo JText::_('COM_JOOMDLE_CLOSE_WINDOW');
?>
<?php
echo JHtml::_('image', 'mailto/close-x.png', NULL, NULL, true);
?>
</a>
</div>
<h2>
<?php
echo JText::_('COM_JOOMDLE_EMAIL_SENT');
?>
</h2>
</div>
<?php
}
}
示例12: postflight
/**
* method to run after an install/update/uninstall method
*
* @return void
*/
function postflight($type, $parent)
{
$manifest = $parent->getParent()->getManifest();
if ($type != 'uninstall' && !$this->_installAllowed($manifest)) {
return false;
}
// Remove AjaxHelpAry
$db = JFactory::getDbo();
$query = $db->getQuery(true);
$query->select(array('extension_id', 'name', 'params', 'element'));
$query->from('#__extensions');
$query->where($db->quoteName('element') . ' = ' . $db->quote('ajaxhelpary'));
$query->where($db->quoteName('folder') . ' = ' . $db->quote('ajax'));
$db->setQuery($query);
$row = $db->loadAssoc();
if (!empty($row)) {
$installer = new JInstaller();
$res = $installer->uninstall('plugin', $row['extension_id']);
if ($res) {
$msg = '<b style="color:green">' . JText::sprintf('COM_INSTALLER_UNINSTALL_SUCCESS', $row['name']) . '</b>';
} else {
$msg = '<b style="color:red">' . JText::sprintf('COM_INSTALLER_UNINSTALL_ERROR', $row['name']) . '</b>';
}
$this->messages[] = $msg;
}
parent::postflight($type, $parent, $publishPlugin = true);
}
示例13: publish
/**
* Method to change the state of a list of records.
*/
public function publish()
{
// Check for request forgeries.
JRequest::checkToken() or jexit(JText::_('JInvalid_Token'));
// Initialise variables.
$user = JFactory::getUser();
$ids = JRequest::getVar('cid', array(), '', 'array');
$values = array('publish' => 1, 'unpublish' => 0);
$task = $this->getTask();
$value = JArrayHelper::getValue($values, $task, 0, 'int');
if (empty($ids)) {
JError::raiseWarning(500, JText::_('JError_No_items_selected'));
} else {
// Get the model.
$model = $this->getModel();
// Change the state of the records.
if (!$model->publish($ids, $value)) {
JError::raiseWarning(500, $model->getError());
} else {
if ($value == 1) {
$text = 'JSuccess_N_Items_published';
} else {
$text = 'JSuccess_N_Items_unpublished';
}
$this->setMessage(JText::sprintf($text, count($ids)));
}
}
$this->setRedirect('index.php?option=com_plugins&view=plugins');
}
示例14: test
/**
* @param SimpleXMLElement $element The JXmlElement object representing the <field /> tag for the form field object.
* @param mixed $value The form field value to validate.
* @param string $group The field name group control value. This acts as as an array container for the field.
* For example if the field has name="foo" and the group value is set to "bar" then the
* full field name would end up being "bar[foo]".
* @param JRegistry $input An optional JRegistry object with the entire data set to validate against the entire form.
* @param JForm $form The form object for which the field is being tested.
*
* @return boolean True if the value is valid, false otherwise.
*/
public function test(SimpleXMLElement $element, $value, $group = null, JRegistry $input = null, JForm $form = null)
{
if (!parent::test($element, $value, $group, $input, $form)) {
return false;
} else {
//[%%START_CUSTOM_CODE%%]
if ($input->get('component_object_id') != 0) {
$db = JFactory::getDBO();
$query = $db->getQuery(true);
// Build the query.
$query->select('COUNT(*)');
$query->from('#__componentarchitect_fields');
$query->where('code_name = ' . $db->quote($value));
$query->where('component_object_id = ' . $db->quote($input->get('component_object_id')));
$query->where('id != ' . $db->quote($input->get('id')));
try {
// Set and query the database.
$db->setQuery($query);
$duplicate = (bool) $db->loadResult();
$title = $db->loadResult();
} catch (RuntimeException $e) {
throw new RuntimeException(JText::sprintf('COM_COMPONENTARCHITECT_ERROR_DATABASE_FATAL', $e->getMessage()));
}
if ($duplicate) {
// Change to RuntimeException when Joomla! 2.5 no longer supported as JException (deprecated) and will be removed from Joomla
return new JException(JText::_('COM_COMPONENTARCHITECT_FIELDS_FIELD_CODE_NAME_ERROR_DUPLICATE'), 1, E_WARNING);
}
}
//[%%END_CUSTOM_CODE%%]
return true;
}
}
示例15: saveJS
function saveJS()
{
$data = JRequest::get('get');
JRequest::setVar($data['token'], '1', 'post');
JRequest::checkToken() or jexit('Invalid Token save');
$model = VmModel::getModel($this->_cname);
$id = $model->store($data);
$errors = $model->getErrors();
if (empty($errors)) {
$msg = JText::sprintf('COM_VIRTUEMART_STRING_SAVED', $this->mainLangKey);
$type = 'save';
} else {
$type = 'error';
}
foreach ($errors as $error) {
$msg = $error . '<br />';
}
$json['msg'] = $msg;
if ($id) {
$json['product_id'] = $id;
$json['ok'] = 1;
} else {
$json['ok'] = 0;
}
echo json_encode($json);
jExit();
}