format() 공개 정적인 메소드

Formats a string by the given format type.
public static format ( string $value, string $formatType, mixed $format ) : string
$value string Value
$formatType string Format type (any method name of this class)
$format mixed For possible values look at the other methods of this class
리턴 string
 function formatValue()
 {
     $value = $this->getValue();
     $format_type = $this->getFormatType();
     if ($format_type != '') {
         $value = rex_formatter::format($value, $format_type, $this->getFormat());
     }
     return $value;
 }
 function get()
 {
     global $REX;
     if ($this->checkPermission()) {
         $callable = array($this, '_get');
         $cachekey = $this->funcCache->computeCacheKey($callable, array($REX['USER']->getUserLogin()));
         $cacheBackend = $this->funcCache->getCache();
         $configForm = '';
         if ($this->config) {
             $configForm = $this->config ? $this->config->get() : '';
             // config changed -> remove cache to reflect changes
             if ($this->config->changed()) {
                 $cacheBackend->remove($cachekey);
             }
         }
         // refresh clicked in actionbar
         if (rex_get('refresh', 'string') == $this->getId()) {
             $cacheBackend->remove($cachekey);
         }
         // prueft ob inhalte des callables gecacht vorliegen
         $content = $this->funcCache->call($callable, array($REX['USER']->getUserLogin()));
         // wenn gecachter inhalt leer ist, vom cache entfernen und nochmals checken
         // damit leere komponenten sofort angezeigt werden, wenn neue inhalte verfuegbar sind
         if ($content == '') {
             $cacheBackend->remove($cachekey);
             $content = $this->funcCache->call($callable, array($REX['USER']->getUserLogin()));
         }
         $cachestamp = $cacheBackend->getLastModified($cachekey);
         if (!$cachestamp) {
             $cachestamp = time();
         }
         // falls kein gueltiger cache vorhanden
         $cachetime = rex_formatter::format($cachestamp, 'strftime', 'datetime');
         $content = strtr($content, array('%%actionbar%%' => $this->getActionBar()));
         $content = strtr($content, array('%%cachetime%%' => $cachetime));
         $content = strtr($content, array('%%config%%' => $configForm));
         // refresh clicked in actionbar
         if (rex_get('ajax-get', 'string') == $this->getId()) {
             // clear output-buffer
             while (@ob_end_clean()) {
             }
             rex_send_resource($content);
             exit;
         }
         return $content;
     }
     return '';
 }
 function format($row)
 {
     global $I18N;
     $format = parent::format($row);
     if (strlen($format) != 0) {
         return $format;
     }
     $value = $row[$this->name];
     if ($this->format_type == '') {
         if ($this->format == '') {
             $this->format = '%' . $this->name . '%';
         }
         // Alle Spaltenamen ersetzen durch deren Werte %id%, %name%, etc.
         $value = $this->parseString($this->format, $row);
     } else {
         $value = rex_formatter::format($value, $this->format_type, $this->format);
     }
     return $this->link($value, $this->parseParams($row));
 }
 }
 $qry = "SELECT * FROM " . $REX['TABLE_PREFIX'] . "file f WHERE " . $where . " ORDER BY f.updatedate desc";
 // ----- EXTENSION POINT
 $qry = rex_register_extension_point('MEDIA_LIST_QUERY', $qry, array('category_id' => $rex_file_category));
 $files = rex_sql::factory();
 //   $files->debugsql = 1;
 $files->setQuery($qry);
 print '<tbody>';
 for ($i = 0; $i < $files->getRows(); $i++) {
     $file_id = $files->getValue('file_id');
     $file_name = $files->getValue('filename');
     $file_oname = $files->getValue('originalname');
     $file_title = $files->getValue('title');
     $file_type = $files->getValue('filetype');
     $file_size = $files->getValue('filesize');
     $file_stamp = rex_formatter::format($files->getValue('updatedate'), "strftime", "datetime");
     $file_updateuser = $files->getValue('updateuser');
     $encoded_file_name = urlencode($file_name);
     // Eine titel Spalte schätzen
     $alt = '';
     foreach (array('title') as $col) {
         if ($files->hasValue($col) && $files->getValue($col) != '') {
             $alt = htmlspecialchars($files->getValue($col));
             break;
         }
     }
     // Eine beschreibende Spalte schätzen
     $desc = '';
     foreach (array('med_description') as $col) {
         if ($files->hasValue($col) && $files->getValue($col) != '') {
             $desc = htmlspecialchars($files->getValue($col));
 /**
  * Formatiert einen übergebenen String anhand der rexFormatter Klasse
  *
  * @param $value Zu formatierender String
  * @param $format Array mit den Formatierungsinformationen
  * @param $escape Flag, Ob escapen von $value erlaubt ist
  *
  * @return string
  */
 function formatValue($value, $format, $escape, $field = null)
 {
     if (is_array($format)) {
         // Callbackfunktion -> Parameterliste aufbauen
         if ($this->isCustomFormat($format)) {
             $format[2] = isset($format[2]) ? $format[2] : array();
             $format[1] = array($format[1], array('list' => $this, 'field' => $field, 'value' => $value, 'format' => $format[0], 'escape' => $escape, 'params' => $format[2]));
         }
         $value = rex_formatter::format($value, $format[0], $format[1]);
     }
     // Nur escapen, wenn formatter aufgerufen wird, der kein html zurückgeben können soll
     if ($escape && !$this->isCustomFormat($format) && $format[0] != 'rexmedia' && $format[0] != 'rexurl') {
         $value = htmlspecialchars($value);
     }
     return $value;
 }
예제 #6
0
         ';
     } else {
         // --------------------- ARTIKEL NORMAL VIEW | NO EDIT NO ENTER
         $add_td = '';
         if ($REX_USER->hasPerm('advancedMode[]')) {
             $add_td = '<td class="rex-icon">' . $sql->getValue('id') . '</td>';
         }
         $art_status = $artStatusTypes[$sql->getValue('status')][0];
         $art_status_class = $artStatusTypes[$sql->getValue('status')][1];
         echo '<tr>
           <td class="rex-icon"><img src="media/' . $icon . '" alt="' . htmlspecialchars($sql->getValue('name')) . '" title="' . htmlspecialchars($sql->getValue('name')) . '" /></td>
           ' . $add_td . '
           <td>' . htmlspecialchars($sql->getValue('name')) . '</td>
           <td>' . htmlspecialchars($sql->getValue('prior')) . '</td>
           <td>' . $TEMPLATE_NAME[$sql->getValue('template_id')] . '</td>
           <td>' . rex_formatter::format($sql->getValue('createdate'), 'strftime', 'date') . '</td>
           <td>' . $startpage . '</td>
           <td><span class="rex-strike">' . $I18N->msg('change') . '</span></td>
           <td><span class="rex-strike">' . $I18N->msg('delete') . '</span></td>
           <td class="' . $art_status_class . '"><span class="rex-strike">' . $art_status . '</span></td>
         </tr>
         ';
     }
     $sql->counter++;
 }
 // tbody nur anzeigen, wenn später auch inhalt drinnen stehen wird
 if ($sql->getRows() > 0 || $function == 'add_art') {
     echo '
     </tbody>';
 }
 echo '
예제 #7
0
	<div id="rex-ftr">
		<ul>
			<li><a href="http://www.yakamara.de" target="_blank" class="black"<?php 
echo rex_tabindex();
?>
>yakamara.de</a> | </li>
      <li><a href="http://www.redaxo.de" target="_blank" class="black"<?php 
echo rex_tabindex();
?>
>redaxo.de</a> | </li>
			<?php 
if (isset($REX_USER)) {
    echo '<li><a href="index.php?page=credits" class="black">' . $I18N->msg('credits') . '</a> | </li>';
}
?>
      <li><a href="http://forum.redaxo.de"<?php 
echo rex_tabindex();
?>
>?</a></li>
		</ul>
		<p><?php 
echo showScripttime();
?>
 sec | <?php 
echo rex_formatter::format(time(), 'strftime', 'date');
?>
</p>
	</div>
   </body>
</html>
예제 #8
0
 function _getList($lines, $caption = '', $summary = '')
 {
     global $REX, $I18N;
     $table_attr = '';
     if (!empty($summary)) {
         $table_attr .= ' summary="' . $summary . '"';
     }
     $table_head = '';
     if (!empty($caption)) {
         $table_head .= '<caption>' . $caption . '</caption>';
     }
     $list = '
   <table class="rex-table"' . $table_attr . '>
     ' . $table_head . '
     <colgroup>
       <col width="40" />
       <col width="140" />
       <col width="160" />
       <col width="*" />
     </colgroup>
     <thead>
       <tr>
         <th class="rex-icon"></th>
         <th>' . $I18N->msg('cronjob_log_date') . '</th>
         <th>' . $I18N->msg('cronjob_name') . '</th>
         <th>' . $I18N->msg('cronjob_log_message') . '</th>
       </tr>
     </thead>
     <tbody>';
     if (!is_array($lines) || count($lines) == 0) {
         $list .= '
       <tr><td colspan="4">' . $I18N->msg('cronjob_log_no_data') . '</td></tr>';
     } else {
         foreach ($lines as $line) {
             $data = explode(' | ', $line, 5);
             for ($i = 0; $i < 5; $i++) {
                 if (!isset($data[$i])) {
                     $data[$i] = '';
                 }
             }
             $data[0] = rex_formatter::format(strtotime($data[0]), 'strftime', 'datetime');
             $class = trim($data[1]) == 'ERROR' ? 'rex-warning' : 'rex-info';
             $data[4] = str_replace(' | ', '<br />', htmlspecialchars($data[4]));
             if ($data[2] == '--') {
                 $icon = '<span class="rex-i-element rex-i-cronjob" title="' . $I18N->msg('cronjob_not_editable') . '"><span class="rex-i-element-text">' . $I18N->msg('cronjob_not_editable') . '</span></span>';
             } else {
                 $icon = '<a href="index.php?page=cronjob&amp;list=cronjobs&amp;func=edit&amp;oid=' . trim($data[2]) . '" title="' . $I18N->msg('cronjob_edit') . '"><span class="rex-i-element rex-i-cronjob"><span class="rex-i-element-text">' . $I18N->msg('cronjob_edit') . '</span></span></a>';
             }
             $list .= '
       <tr class="' . $class . '">
         <td class="rex-icon">' . $icon . '</td>
         <td>' . $data[0] . '</td>
         <td>' . htmlspecialchars($data[3]) . '</td>
         <td>' . $data[4] . '</td>
       </tr>';
         }
     }
     $list .= '
     </tbody>
   </table>';
     return $list;
 }
 /**
  * Formatiert einen übergebenen String anhand der rexFormatter Klasse
  *
  * @param $value Zu formatierender String
  * @param $format Array mit den Formatierungsinformationen
  *
  * @return string
  */
 function formatValue($value, $format)
 {
     if (!is_array($format)) {
         return $value;
     }
     return rex_formatter::format($value, $format[0], $format[1]);
 }
예제 #10
0
     $where .= ' AND (' . implode(' OR ', $types) . ')';
 }
 $qry = 'SELECT * FROM ' . $REX['TABLE_PREFIX'] . 'file f WHERE ' . $where . ' ORDER BY f.updatedate desc, f.file_id desc';
 // ----- EXTENSION POINT
 $qry = rex_register_extension_point('MEDIA_LIST_QUERY', $qry, array('category_id' => $rex_file_category));
 //   $files->debugsql = 1;
 $files->setQuery($qry);
 print '<tbody>';
 for ($i = 0; $i < $files->getRows(); $i++) {
     $file_id = $files->getValue('file_id');
     $file_name = $files->getValue('filename');
     $file_oname = $files->getValue('originalname');
     $file_title = $files->getValue('title');
     $file_type = $files->getValue('filetype');
     $file_size = $files->getValue('filesize');
     $file_stamp = rex_formatter::format($files->getValue('updatedate'), 'strftime', 'datetime');
     $file_updateuser = $files->getValue('updateuser');
     $encoded_file_name = urlencode($file_name);
     // Eine titel Spalte schätzen
     $alt = '';
     foreach (array('title') as $col) {
         if ($files->hasValue($col) && $files->getValue($col) != '') {
             $alt = htmlspecialchars($files->getValue($col));
             break;
         }
     }
     // Eine beschreibende Spalte schätzen
     $desc = '';
     foreach (array('med_description') as $col) {
         if ($files->hasValue($col) && $files->getValue($col) != '') {
             $desc = '<p class="rex-tx1">' . htmlspecialchars($files->getValue($col)) . '</p>';