本文整理汇总了PHP中modX::lexicon方法的典型用法代码示例。如果您正苦于以下问题:PHP modX::lexicon方法的具体用法?PHP modX::lexicon怎么用?PHP modX::lexicon使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类modX
的用法示例。
在下文中一共展示了modX::lexicon方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getViewing
/**
* Gets the viewing message for the bottom of the thread
*
* @access public
* @param string $placePrefix
* @return string The who is viewing message
*/
public function getViewing($placePrefix = 'thread')
{
if (!$this->xpdo->getOption('discuss.show_whos_online', null, true)) {
return '';
}
if (!$this->xpdo->hasPermission('discuss.view_online')) {
return '';
}
$canViewProfiles = $this->xpdo->hasPermission('discuss.view_profiles');
$c = $this->xpdo->newQuery('disSession');
$c->innerJoin('disUser', 'User');
$c->select($this->xpdo->getSelectColumns('disSession', 'disSession', '', array('id')));
$c->select(array('CONCAT_WS(":",User.id,IF(User.use_display_name,User.display_name,User.username)) AS reader'));
$c->where(array('disSession.place' => $placePrefix . ':' . $this->get('id')));
$c->groupby('disSession.user');
$sessions = $this->xpdo->getCollection('disSession', $c);
if (!empty($sessions)) {
$members = array();
foreach ($sessions as $member) {
$r = explode(':', $member->get('reader'));
$members[] = $canViewProfiles ? '<a href="' . $this->xpdo->discuss->request->makeUrl('user', array('type' => 'username', 'user' => str_replace('%20', '', $r[0]))) . '">' . $r[1] . '</a>' : $r[1];
}
$members = array_unique($members);
$members = implode(',', $members);
} else {
$members = $this->xpdo->lexicon('discuss.zero_members');
}
$c = $this->xpdo->newQuery('disSession');
$c->where(array('place' => $placePrefix . ':' . $this->get('id'), 'user' => 0));
$guests = $this->xpdo->getCount('disSession', $c);
return $this->xpdo->lexicon('discuss.thread_viewing', array('members' => $members, 'guests' => $guests));
}
示例2: notify
/**
* Sends notification to all watchers of this thread saying a new post has been made.
*
* @param quipComment $comment A reference to the actual comment
* @return boolean True if successful
*/
public function notify(quipComment &$comment)
{
if (!$this->_loadLexicon()) {
return false;
}
$this->xpdo->lexicon->load('quip:emails');
/* get the poster's email address */
$posterEmail = false;
$user = $comment->getOne('Author');
if ($user) {
$profile = $user->getOne('Profile');
if ($profile) {
$posterEmail = $profile->get('email');
}
}
/* get email body/subject */
$properties = $comment->toArray();
$properties['url'] = $comment->makeUrl('', array(), array('scheme' => 'full'));
$body = $this->xpdo->lexicon('quip.email_notify', $properties);
$subject = $this->xpdo->lexicon('quip.email_notify_subject');
/* send notifications */
$success = true;
$notifyEmails = $this->get('notify_emails');
$emails = explode(',', $notifyEmails);
/* send notifications to notify_emails subjects */
if (!empty($emails)) {
$this->sendEmail($subject, $body, $emails);
}
/* now send to notified users */
$notifiees = $this->getMany('Notifications');
/** @var quipCommentNotify $notification */
foreach ($notifiees as $notification) {
$email = $notification->get('email');
/* remove invalid emails */
if (empty($email) || strpos($email, '@') == false) {
$notification->remove();
continue;
}
/* don't notify the poster, since they posted the comment. */
if ($posterEmail == $email) {
continue;
}
$notification->send($comment, $properties);
}
return $success;
}
示例3: getUserTop
public function getUserTop()
{
/* topbar profile links. Moved from class Discuss */
if ($this->discuss->user->isLoggedIn) {
$authphs = array('authLink' => '<a href="' . $this->discuss->request->makeUrl('logout') . '">Logout</a>');
$authphs = array_merge($this->discuss->user->toArray('user.'), $authphs);
$authphs['user.avatar_url'] = $this->discuss->user->getAvatarUrl();
/* Get counts */
$authphs['user.unread_messages_count'] = $newMessages = $this->discuss->user->countUnreadMessages();
$authphs['user.unread_posts_count'] = $unreadPosts = $this->discuss->user->countUnreadPosts();
$authphs['user.new_replies_count'] = $newReplies = $this->discuss->user->countNewReplies();
$authphs['user.unanswered_questions_count'] = $unansweredQuestions = $this->discuss->user->countUnansweredQuestions();
$authphs['user.no_replies_count'] = $noReplies = $this->discuss->user->countWithoutReplies();
/* Format counts nicely */
$authphs['user.unread_messages'] = $newMessages > 1 ? $this->modx->lexicon('discuss.user.new_messages', array('total' => $newMessages)) : ($newMessages == 1 ? $this->modx->lexicon('discuss.user.one_new_message') : $this->modx->lexicon('discuss.user.no_new_messages'));
$authphs['user.unread_posts'] = $unreadPosts > 1 ? $this->modx->lexicon('discuss.user.new_posts', array('total' => $unreadPosts)) : ($unreadPosts == 1 ? $this->modx->lexicon('discuss.user.one_new_post') : $this->modx->lexicon('discuss.user.no_new_posts'));
$authphs['user.new_replies'] = $newReplies > 1 ? $this->modx->lexicon('discuss.user.new_replies', array('total' => $newReplies)) : ($newReplies == 1 ? $this->modx->lexicon('discuss.user.one_new_reply') : $this->modx->lexicon('discuss.user.no_new_replies'));
$authphs['user.unanswered_questions'] = $unansweredQuestions > 1 ? $this->modx->lexicon('discuss.user.unanswered_questions', array('total' => $unansweredQuestions)) : ($unansweredQuestions == 1 ? $this->modx->lexicon('discuss.user.one_unanswered_question') : $this->modx->lexicon('discuss.user.no_unanswered_questions'));
$authphs['user.no_replies'] = $noReplies > 1 ? $this->modx->lexicon('discuss.user.no_replies', array('total' => $noReplies)) : ($noReplies == 1 ? $this->modx->lexicon('discuss.user.one_no_reply') : $this->modx->lexicon('discuss.user.no_no_replies'));
$this->discuss->user->isGlobalModerator();
$this->discuss->user->isAdmin();
} else {
$authphs = array('authLink' => '<a href="' . $this->discuss->request->makeUrl('login') . '">Login</a>', 'user.avatar_url' => '', 'user.unread_messages' => '');
}
$this->modx->toPlaceholders($authphs, 'discuss');
}
示例4: verify
/**
* Verifies the authenticity of the provider
*
* @return boolean True if verified, xml if failed
*/
public function verify()
{
$response = $this->request('verify', 'GET');
if ($response->isError()) {
$message = $response->getError();
if ($this->xpdo->lexicon && $this->xpdo->lexicon->exists('provider_err_' . $message)) {
$message = $this->xpdo->lexicon('provider_err_' . $message);
}
return $message;
}
$status = $response->toXml();
return (bool) $status->verified;
}
示例5: remove
/**
* Overrides modElement::remove to add custom error logging and fire
* modX-specific events.
*
* {@inheritdoc}
*/
public function remove(array $ancestors = array())
{
if ($this->xpdo instanceof modX) {
$this->xpdo->invokeEvent('OnTemplateVarBeforeRemove', array('templateVar' => &$this, 'cacheFlag' => true));
}
$removed = parent::remove($ancestors);
if ($removed && $this->xpdo instanceof modX) {
$this->xpdo->invokeEvent('OnTemplateVarRemove', array('templateVar' => &$this, 'cacheFlag' => true));
} else {
if (!$removed && !empty($this->xpdo->lexicon)) {
$this->xpdo->log(xPDO::LOG_LEVEL_ERROR, $this->xpdo->lexicon('tv_err_remove') . $this->toArray());
}
}
return $removed;
}
示例6: delete
/**
* Handle DELETE requests
* @return array
*/
public function delete()
{
$id = $this->getProperty($this->primaryKeyField, false);
if (empty($id)) {
return $this->failure($this->modx->lexicon('rest.err_field_ns', array('field' => $this->primaryKeyField)));
}
$c = $this->getPrimaryKeyCriteria($id);
$this->object = $this->modx->getObject($this->classKey, $c);
if (empty($this->object)) {
return $this->failure($this->modx->lexicon('rest.err_obj_nf', array('class_key' => $this->classKey)));
}
if (!empty($this->deleteRequiredFields)) {
if (!$this->checkRequiredFields($this->deleteRequiredFields)) {
return $this->failure();
}
}
$this->object->fromArray($this->getProperties());
$beforeDelete = $this->beforeDelete();
if ($beforeDelete !== true) {
return $this->failure($beforeDelete === false ? $this->errorMessage : $beforeDelete);
}
if (!$this->object->{$this->deleteMethod}()) {
$this->setObjectErrors();
return $this->failure($this->modx->lexicon('rest.err_class_remove', array('class_key' => $this->classKey)));
}
$objectArray = $this->object->toArray();
$this->afterDelete($objectArray);
return $this->success('', $objectArray);
}
示例7: dateFormat
/**
* Formats date to "10 minutes ago" or "Yesterday in 22:10"
* This algorithm taken from https://github.com/livestreet/livestreet/blob/7a6039b21c326acf03c956772325e1398801c5fe/engine/modules/viewer/plugs/function.date_format.php
*
* @param string $date Timestamp to format
* @param string $dateFormat
*
* @return string
*/
public function dateFormat($date, $dateFormat = null)
{
//print_r($date);die;
$date = preg_match('/^\\d+$/', $date) ? $date : strtotime($date);
$dateFormat = !empty($dateFormat) ? $dateFormat : $this->MlmSystem->getOption('format_date');
$current = time();
$delta = $current - $date;
if ($this->MlmSystem->getOption('format_date_now')) {
if ($delta < $this->MlmSystem->getOption('format_date_now')) {
return $this->modx->lexicon('mlmsystem_date_now');
}
}
if ($this->MlmSystem->getOption('format_date_minutes')) {
$minutes = round($delta / 60);
if ($minutes < $this->MlmSystem->getOption('format_date_minutes')) {
if ($minutes > 0) {
return $this->declension($minutes, $this->modx->lexicon('mlmsystem_date_minutes_back', array('minutes' => $minutes)));
} else {
return $this->modx->lexicon('mlmsystem_date_minutes_back_less');
}
}
}
if ($this->MlmSystem->getOption('format_date_hours')) {
//
$hours = round($delta / 3600);
if ($hours < $this->MlmSystem->getOption('format_date_hours')) {
if ($hours > 0) {
return $this->declension($hours, $this->modx->lexicon('mlmsystem_date_hours_back', array('hours' => $hours)));
} else {
return $this->modx->lexicon('mlmsystem_date_hours_back_less');
}
}
}
if ($this->MlmSystem->getOption('format_date_day')) {
switch (date('Y-m-d', $date)) {
case date('Y-m-d'):
$day = $this->modx->lexicon('mlmsystem_date_today');
break;
case date('Y-m-d', mktime(0, 0, 0, date('m'), date('d') - 1, date('Y'))):
$day = $this->modx->lexicon('mlmsystem_date_yesterday');
break;
case date('Y-m-d', mktime(0, 0, 0, date('m'), date('d') + 1, date('Y'))):
$day = $this->modx->lexicon('mlmsystem_date_tomorrow');
break;
default:
$day = null;
}
if ($day) {
$format = str_replace("day", preg_replace("#(\\w{1})#", '\\\\${1}', $day), $this->MlmSystem->getOption('format_date_day'));
return date($format, $date);
}
}
$m = date("n", $date);
$month_arr = $this->modx->fromJSON($this->modx->lexicon('mlmsystem_date_months'));
$month = $month_arr[$m - 1];
$format = preg_replace("~(?<!\\\\)F~U", preg_replace('~(\\w{1})~u', '\\\\${1}', $month), $dateFormat);
return date($format, $date);
}
示例8: send
/**
* Send the notification
*
* @param quipComment $comment
* @param array $properties
* @return boolean
*/
public function send(quipComment $comment, array $properties = array())
{
$this->xpdo->getService('mail', 'mail.modPHPMailer');
if (!$this->xpdo->mail) {
return false;
}
$email = $this->get('email');
/* set unsubscription link */
$unsubscribeSecretHash = 'One sees great things from the valley, only small things from the peak.';
$hash = md5('quip.' . $unsubscribeSecretHash . $email . $this->get('createdon'));
$properties['unsubscribeUrl'] = $comment->makeUrl('', array('quip_unsub' => $email, 'quip_uhsh' => $hash), array('scheme' => 'full'), false) . '#quip-success-' . $comment->get('idprefix');
$properties['unsubscribeText'] = $this->xpdo->lexicon('quip.unsubscribe_text', array('unsubscribeUrl' => $properties['unsubscribeUrl']));
$body = $this->xpdo->lexicon('quip.email_notify', $properties);
$subject = $this->xpdo->lexicon('quip.email_notify_subject');
$emailFrom = $this->xpdo->context->getOption('quip.emailsFrom', $this->xpdo->context->getOption('emailsender'));
$emailReplyTo = $this->xpdo->context->getOption('quip.emailsReplyTo', $this->xpdo->context->getOption('emailsender'));
if (empty($email) || strpos($email, '@') == false) {
return false;
}
if ($this->xpdo->parser) {
$this->xpdo->parser->processElementTags('', $body, true, false);
$this->xpdo->parser->processElementTags('', $subject, true, false);
$this->xpdo->parser->processElementTags('', $emailFrom, true, false);
$this->xpdo->parser->processElementTags('', $emailReplyTo, true, false);
}
$this->xpdo->mail->set(modMail::MAIL_BODY, $body);
$this->xpdo->mail->set(modMail::MAIL_FROM, $emailFrom);
$this->xpdo->mail->set(modMail::MAIL_FROM_NAME, $this->xpdo->context->getOption('quip.emails_from_name', 'Quip'));
$this->xpdo->mail->set(modMail::MAIL_SENDER, $emailFrom);
$this->xpdo->mail->set(modMail::MAIL_SUBJECT, $subject);
$this->xpdo->mail->address('to', $email);
$this->xpdo->mail->address('reply-to', $emailReplyTo);
$this->xpdo->mail->setHTML(true);
$success = $this->xpdo->mail->send();
$this->xpdo->mail->reset();
return $success;
}
示例9: math
/**
* Math field hook for anti-spam math input field.
*
* @access public
* @param array $fields An array of cleaned POST fields
* @return boolean True if email was successfully sent.
*/
public function math(array $fields = array())
{
$mathField = $this->modx->getOption('mathField', $this->config, 'math');
if (!isset($fields[$mathField])) {
$this->errors[$mathField] = $this->modx->lexicon('formit.math_field_nf', array('field' => $mathField));
return false;
}
if (empty($fields[$mathField])) {
$this->errors[$mathField] = $this->modx->lexicon('formit.field_required', array('field' => $mathField));
return false;
}
$op1Field = $this->modx->getOption('mathOp1Field', $this->config, 'op1');
if (empty($fields[$op1Field])) {
$this->errors[$mathField] = $this->modx->lexicon('formit.math_field_nf', array('field' => $op1Field));
return false;
}
$op2Field = $this->modx->getOption('mathOp2Field', $this->config, 'op2');
if (empty($fields[$op2Field])) {
$this->errors[$mathField] = $this->modx->lexicon('formit.math_field_nf', array('field' => $op2Field));
return false;
}
$operatorField = $this->modx->getOption('mathOperatorField', $this->config, 'operator');
if (empty($fields[$operatorField])) {
$this->errors[$mathField] = $this->modx->lexicon('formit.math_field_nf', array('field' => $operatorField));
return false;
}
$answer = false;
$op1 = (int) $fields[$op1Field];
$op2 = (int) $fields[$op2Field];
switch ($fields[$operatorField]) {
case '+':
$answer = $op1 + $op2;
break;
case '-':
$answer = $op1 - $op2;
break;
case '*':
$answer = $op1 * $op2;
break;
}
$guess = (int) $fields[$mathField];
$passed = (bool) ($guess == $answer);
if (!$passed) {
$this->addError($mathField, $this->modx->lexicon('formit.math_incorrect'));
}
return $passed;
}
示例10: _getErrorMessage
/**
* Check for a custom error message, otherwise use a lexicon entry.
* @param string $field
* @param string $parameter
* @param string $lexiconKey
* @param array $properties
* @return null|string
*/
public function _getErrorMessage($field, $parameter, $lexiconKey, array $properties = array())
{
if (!empty($this->formit->config[$field . '.' . $parameter])) {
$message = $this->formit->config[$field . '.' . $parameter];
$this->modx->lexicon->set($lexiconKey, $message);
$this->modx->lexicon($lexiconKey, $properties);
} else {
if (!empty($this->formit->config[$parameter])) {
$message = $this->formit->config[$parameter];
$this->modx->lexicon->set($lexiconKey, $message);
$this->modx->lexicon($lexiconKey, $properties);
} else {
$message = $this->modx->lexicon($lexiconKey, $properties);
}
}
return $message;
}
示例11: fenomFunction
/**
* @param $method
* @param array $params
*
* @return string
*/
public function fenomFunction($method, array $params)
{
if (empty($params[0])) {
return '';
}
$result = '';
switch ($method) {
case 'lexicon':
$key = array_shift($params);
if (!empty($params[0]) && is_array($params[0])) {
$properties = $params[0];
$topic = !empty($properties['topic']) ? $properties['topic'] : 'default';
$namespace = !empty($properties['namespace']) ? $properties['namespace'] : 'core';
$language = !empty($properties['language']) ? $properties['language'] : $this->modx->getOption('cultureKey', null, 'en');
$this->modx->lexicon->load($language . ':' . $namespace . ':' . $topic);
}
$placeholders = !empty($params[1]) && is_array($params[1]) ? $params[1] : array();
$result = $this->modx->lexicon($key, $placeholders);
break;
case 'url':
$id = trim(array_shift($params), '[]~');
if (is_numeric($id)) {
$context = $this->modx->context->get('key');
$scheme = $this->modx->getOption('link_tag_scheme', null, -1);
$options = array();
if (!empty($params[0]) && is_array($params[0])) {
$options = $params[0];
if (isset($options['context'])) {
$context = $options['context'];
unset($options['context']);
}
if (isset($options['scheme'])) {
$scheme = $options['scheme'];
unset($options['scheme']);
}
}
$args = !empty($params[1]) && is_array($params[1]) ? $params[1] : array();
$result = $this->modx->makeUrl($id, $context, $args, $scheme, $options);
}
break;
}
return $result;
}
示例12: run
/**
* Run the processor, returning a modProcessorResponse object.
* @return modProcessorResponse
*/
public function run()
{
if (!$this->checkPermissions()) {
$o = $this->failure($this->modx->lexicon('permission_denied'));
} else {
$topics = $this->getLanguageTopics();
foreach ($topics as $topic) {
$this->modx->lexicon->load($topic);
}
$initialized = $this->initialize();
if ($initialized !== true) {
$o = $this->failure($initialized);
} else {
$o = $this->process();
}
}
$response = new modProcessorResponse($this->modx, $o);
return $response;
}
示例13: prepareTreeNode
/**
* This runs each time the tree is drawn.
* @param array $node
* @return array
*/
public function prepareTreeNode(array $node = array())
{
$this->xpdo->lexicon->load('articles:default');
$menu = array();
$idNote = $this->xpdo->hasPermission('tree_show_resource_ids') ? ' <span dir="ltr">(' . $this->id . ')</span>' : '';
// Template ID should 1st default to the container settings for articleTemplate,
// then to system settings for articles.default_article_template.
// getContainerSettings() is not in scope here.
// System Default
$template_id = $this->getOption('articles.default_article_template');
// Attempt to override for this container
$container = $this->xpdo->getObject('modResource', $this->id);
if ($container) {
$props = $container->get('properties');
if ($props) {
if (isset($props['articles']['articleTemplate']) && !empty($props['articles']['articleTemplate'])) {
$template_id = $props['articles']['articleTemplate'];
}
}
}
$menu[] = array('text' => '<b>' . $this->get('pagetitle') . '</b>' . $idNote, 'handler' => 'Ext.emptyFn');
$menu[] = '-';
$menu[] = array('text' => $this->xpdo->lexicon('articles.articles_manage'), 'handler' => 'this.editResource');
$menu[] = array('text' => $this->xpdo->lexicon('articles.articles_write_new'), 'handler' => "function(itm,e) { \n\t\t\t\tvar at = this.cm.activeNode.attributes;\n\t\t var p = itm.usePk ? itm.usePk : at.pk;\n\t\n\t Ext.getCmp('modx-resource-tree').loadAction(\n\t 'a='+MODx.action['resource/create']\n\t + '&class_key='+itm.classKey\n\t + '&parent='+p\n\t + '&template=" . $template_id . "'\n\t + (at.ctx ? '&context_key='+at.ctx : '')\n );\n \t}");
$menu[] = array('text' => $this->xpdo->lexicon('articles.container_duplicate'), 'handler' => 'function(itm,e) { itm.classKey = "ArticlesContainer"; this.duplicateResource(itm,e); }');
$menu[] = '-';
if ($this->get('published')) {
$menu[] = array('text' => $this->xpdo->lexicon('articles.container_unpublish'), 'handler' => 'this.unpublishDocument');
} else {
$menu[] = array('text' => $this->xpdo->lexicon('articles.container_publish'), 'handler' => 'this.publishDocument');
}
if ($this->get('deleted')) {
$menu[] = array('text' => $this->xpdo->lexicon('articles.container_undelete'), 'handler' => 'this.undeleteDocument');
} else {
$menu[] = array('text' => $this->xpdo->lexicon('articles.container_delete'), 'handler' => 'this.deleteDocument');
}
$menu[] = '-';
$menu[] = array('text' => $this->xpdo->lexicon('articles.articles_view'), 'handler' => 'this.preview');
$node['menu'] = array('items' => $menu);
$node['hasChildren'] = true;
return $node;
}
示例14: checkBlocked
public function checkBlocked()
{
/* blocked until */
$blockedUntil = $this->processor->getProperty('blockeduntil');
if (!empty($blockedUntil)) {
$blockedUntil = str_replace('-', '/', $blockedUntil);
if (!($blockedUntil = strtotime($blockedUntil))) {
$this->processor->addFieldError('blockeduntil', $this->modx->lexicon('user_err_not_specified_blockeduntil'));
}
$this->processor->setProperty('blockeduntil', $blockedUntil);
$this->profile->set('blockeduntil', $blockedUntil);
}
/* blocked after */
$blockedAfter = $this->processor->getProperty('blockedafter');
if (!empty($blockedAfter)) {
$blockedAfter = str_replace('-', '/', $blockedAfter);
if (!($blockedAfter = strtotime($blockedAfter))) {
$this->processor->addFieldError('blockedafter', $this->modx->lexicon('user_err_not_specified_blockedafter'));
}
$this->processor->setProperty('blockedafter', $blockedAfter);
$this->profile->set('blockedafter', $blockedAfter);
}
}
示例15: dirname
<?php
if (!defined('MODX_API_MODE')) {
define('MODX_API_MODE', false);
}
include dirname(dirname(dirname(dirname(__FILE__)))) . '/config.core.php';
if (!defined('MODX_CORE_PATH')) {
define('MODX_CORE_PATH', dirname(dirname(dirname(dirname(__FILE__)))) . '/core/');
}
include_once MODX_CORE_PATH . "model/modx/modx.class.php";
$modx = new modX();
$modx->initialize('mgr');
$modx->lexicon->load('core:default');
if (!$modx->user->isAuthenticated('mgr')) {
echo $modx->lexicon('permission_denied');
exit;
}
$modx->getService('error', 'error.modError');
$modx->getService('smarty', 'smarty.modSmarty');
$templates = array('home');
//$modx->smarty->assign('var', $results);
$modx->smarty->caching = false;
$modx->smarty->template_dir = $modx->getOption('core_path') . 'components/tag_manager2/templates/';
$template_name = isset($_GET['a']) && in_array($_GET['a'], $templates) ? $_GET['a'] : 'home';
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">