当前位置: 首页>>代码示例>>PHP>>正文


PHP I18n::hasMessage方法代码示例

本文整理汇总了PHP中I18n::hasMessage方法的典型用法代码示例。如果您正苦于以下问题:PHP I18n::hasMessage方法的具体用法?PHP I18n::hasMessage怎么用?PHP I18n::hasMessage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在I18n的用法示例。


在下文中一共展示了I18n::hasMessage方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getMatchReportMessages

 public static function getMatchReportMessages(WebSoccer $websoccer, DbConnection $db, I18n $i18n, $matchId)
 {
     $fromTable = $websoccer->getConfig('db_prefix') . '_matchreport AS R';
     $fromTable .= ' INNER JOIN ' . $websoccer->getConfig('db_prefix') . '_spiel_text AS T ON R.message_id = T.id';
     $columns['R.id'] = 'report_id';
     $columns['R.minute'] = 'minute';
     $columns['R.playernames'] = 'playerNames';
     $columns['R.goals'] = 'goals';
     $columns['T.nachricht'] = 'message';
     $columns['T.aktion'] = 'type';
     $columns['R.active_home'] = 'active_home';
     $whereCondition = 'R.match_id = %d ORDER BY R.minute DESC, R.id DESC';
     $parameters = $matchId;
     $reportmessages = array();
     $result = $db->querySelect($columns, $fromTable, $whereCondition, $parameters);
     $match = null;
     // required only for team name replacements
     $removeSlashes = get_magic_quotes_gpc();
     while ($reportmessage = $result->fetch_array()) {
         // replace placeholders
         $players = explode(';', $reportmessage['playerNames']);
         $rmsg = $reportmessage['message'];
         // remove escaping slashes
         if ($removeSlashes) {
             $rmsg = stripslashes($rmsg);
         }
         $msgKey = strip_tags($rmsg);
         if ($i18n->hasMessage($msgKey)) {
             $rmsg = $i18n->getMessage($msgKey);
         }
         for ($playerIndex = 1; $playerIndex <= count($players); $playerIndex++) {
             $rmsg = str_replace('{sp' . $playerIndex . '}', $players[$playerIndex - 1], $rmsg);
         }
         // replace team name placeholders
         if (strpos($rmsg, '{ma1}') || strpos($rmsg, '{ma2}')) {
             if ($match == null) {
                 $match = self::getMatchById($websoccer, $db, $matchId, FALSE);
             }
             if ($reportmessage['active_home']) {
                 $rmsg = str_replace('{ma1}', $match['match_home_name'], $rmsg);
                 $rmsg = str_replace('{ma2}', $match['match_guest_name'], $rmsg);
             } else {
                 $rmsg = str_replace('{ma1}', $match['match_guest_name'], $rmsg);
                 $rmsg = str_replace('{ma2}', $match['match_home_name'], $rmsg);
             }
         }
         $reportmessage['message'] = $rmsg;
         $reportmessages[] = $reportmessage;
     }
     $result->free();
     return $reportmessages;
 }
开发者ID:astroChasqui,项目名称:open-websoccer,代码行数:52,代码来源:MatchesDataService.class.php

示例2: getLatestNotifications

 /**
  * Retrieves the latest notifications for the specified user.
  * 
  * @param WebSoccer $websoccer Application contex
  * @param DbConnection $db DB connection
  * @param I18n $i18n I18n context.
  * @param int $userId ID of user
  * @param int $teamId ID of user's currently selected team
  * @param int $limit maximum number of notifications to return.
  * @return array Array of assoc. arrays which represent a notification. A notification has keys id, eventdate, eventtype, seen, message, link
  */
 public static function getLatestNotifications(WebSoccer $websoccer, DbConnection $db, I18n $i18n, $userId, $teamId, $limit)
 {
     $result = $db->querySelect('*', $websoccer->getConfig('db_prefix') . '_notification', 'user_id = %d AND (team_id = %d OR team_id IS NULL) ORDER BY eventdate DESC', array($userId, $teamId), $limit);
     $notifications = array();
     while ($row = $result->fetch_array()) {
         $notification = array('id' => $row['id'], 'eventdate' => $row['eventdate'], 'eventtype' => $row['eventtype'], 'seen' => $row['seen']);
         // prepare message
         if ($i18n->hasMessage($row['message_key'])) {
             $message = $i18n->getMessage($row['message_key']);
         } else {
             $message = $row['message_key'];
         }
         // replace place holders
         if (strlen($row['message_data'])) {
             $messageData = json_decode($row['message_data'], true);
             if ($messageData) {
                 foreach ($messageData as $placeholderName => $placeholderValue) {
                     $message = str_replace('{' . $placeholderName . '}', htmlspecialchars($placeholderValue, ENT_COMPAT, 'UTF-8'), $message);
                 }
             }
         }
         $notification['message'] = $message;
         // add target link
         $link = '';
         if ($row['target_pageid']) {
             if ($row['target_querystr']) {
                 $link = $websoccer->getInternalUrl($row['target_pageid'], $row['target_querystr']);
             } else {
                 $link = $websoccer->getInternalUrl($row['target_pageid']);
             }
         }
         $notification['link'] = $link;
         $notifications[] = $notification;
     }
     return $notifications;
 }
开发者ID:astroChasqui,项目名称:open-websoccer,代码行数:47,代码来源:NotificationsDataService.class.php

示例3: createFormGroup

 /**
  * Renders a new form element.
  * 
  * @param I18n $i18n Messages context.
  * @param string $fieldId ID of field.
  * @param array $fieldInfo Field configuration asan array.
  * @param string $fieldValue existing field value.
  * @param string $labelKeyPrefix prefix of i18n message key to use. Message key = labelKeyPrefix + field ID.
  */
 public static function createFormGroup($i18n, $fieldId, $fieldInfo, $fieldValue, $labelKeyPrefix)
 {
     $type = $fieldInfo['type'];
     // convert date
     if ($type == 'timestamp' && isset($fieldInfo['readonly']) && $fieldInfo['readonly']) {
         $website = WebSoccer::getInstance();
         $dateFormat = $website->getConfig('datetime_format');
         // generate date
         if (!strlen($fieldValue)) {
             $fieldValue = date($dateFormat);
         } else {
             if (is_numeric($fieldValue)) {
                 $fieldValue = date($dateFormat, $fieldValue);
             }
         }
         $type = 'text';
     } else {
         if ($type == 'date' && strlen($fieldValue)) {
             if (StringUtil::startsWith($fieldValue, '0000')) {
                 $fieldValue = '';
             } else {
                 $dateObj = DateTime::createFromFormat('Y-m-d', $fieldValue);
                 if ($dateObj !== FALSE) {
                     $website = WebSoccer::getInstance();
                     $dateFormat = $website->getConfig('date_format');
                     $fieldValue = $dateObj->format($dateFormat);
                 }
             }
         }
     }
     echo '<div class=\'control-group\'>';
     $helpText = '';
     $inlineHelpKey = $labelKeyPrefix . $fieldId . '_help';
     if ($i18n->hasMessage($inlineHelpKey)) {
         $helpText = '<span class=\'help-inline\'>' . $i18n->getMessage($inlineHelpKey) . '</span>';
     }
     if ($type == 'boolean') {
         echo '<label class=\'checkbox\'>';
         echo '<input type=\'checkbox\' value=\'1\' name=\'' . $fieldId . '\'';
         if ($fieldValue == '1') {
             echo ' checked';
         }
         echo '>';
         echo $i18n->getMessage($labelKeyPrefix . $fieldId);
         echo '</label>';
         echo $helpText;
     } else {
         $labelOutput = $i18n->getMessage($labelKeyPrefix . $fieldId);
         if (isset($fieldInfo['required']) && $fieldInfo['required'] == 'true') {
             $labelOutput = '<strong>' . $labelOutput . '</strong>';
         }
         echo '<label class=\'control-label\' for=\'' . $fieldId . '\'>' . $labelOutput . '</label>';
         echo '<div class=\'controls\'>';
         switch ($type) {
             // select from foreign DB table
             case 'foreign_key':
                 self::createForeignKeyField($i18n, $fieldId, $fieldInfo, $fieldValue);
                 break;
                 // textarea
             // textarea
             case 'html':
             case 'textarea':
                 $class = 'input-xxlarge';
                 if ($type == 'html') {
                     $class = 'htmleditor';
                 }
                 echo '<textarea id=\'' . $fieldId . '\' name=\'' . $fieldId . '\' wrap=\'virtual\' class=\'' . $class . '\' rows=\'10\'>' . $fieldValue . '</textarea>';
                 break;
                 // date and time picker
             // date and time picker
             case 'timestamp':
                 $website = WebSoccer::getInstance();
                 $dateFormat = $website->getConfig('date_format');
                 if (!$fieldValue) {
                     $fieldValue = $website->getNowAsTimestamp();
                 }
                 // time picker
                 echo '<div class=\'input-append date datepicker\'>';
                 echo '<input type=\'text\' name=\'' . $fieldId . '_date\' value=\'' . date($dateFormat, $fieldValue) . '\' class=\'input-small\'>';
                 echo '<span class=\'add-on\'><i class=\'icon-calendar\'></i></span>';
                 echo '</div>';
                 echo '<div class=\'input-append bootstrap-timepicker\'>';
                 echo '<input type=\'text\' name=\'' . $fieldId . '_time\' value=\'' . date('H:i', $fieldValue) . '\' class=\'timepicker input-small\'>';
                 echo '<span class=\'add-on\'><i class=\'icon-time\'></i></span>';
                 echo '</div>';
                 break;
                 // single selection from dropdown
             // single selection from dropdown
             case 'select':
                 echo '<select id=\'' . $fieldId . '\' name=\'' . $fieldId . '\'>';
                 $selection = explode(',', $fieldInfo['selection']);
//.........这里部分代码省略.........
开发者ID:astroChasqui,项目名称:open-websoccer,代码行数:101,代码来源:FormBuilder.class.php


注:本文中的I18n::hasMessage方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。