コード例 #1
0
 /**
  * Formatiert den String <code>$value</code>
  *
  * @param $value zu formatierender String
  * @param $format_type Formatierungstype
  * @param $format Format
  *
  * Unterstützte Formatierugen:
  *
  * - <Formatierungstype>
  *    + <Format>
  *
  * - sprintf
  *    + siehe www.php.net/sprintf
  * - date
  *    + siehe www.php.net/date
  * - strftime
  *    + dateformat
  *    + datetime
  *    + siehe www.php.net/strftime
  * - number
  *    + siehe www.php.net/number_format
  *    + array( <Kommastelle>, <Dezimal Trennzeichen>, <Tausender Trennzeichen>)
  * - email
  *    + array( 'attr' => <Linkattribute>, 'params' => <Linkparameter>,
  * - url
  *    + array( 'attr' => <Linkattribute>, 'params' => <Linkparameter>,
  * - truncate
  *    + array( 'length' => <String-Laenge>, 'etc' => <ETC Zeichen>, 'break_words' => <true/false>,
  * - nl2br
  *    + siehe www.php.net/nl2br
  * - rexmedia
  *    + formatiert ein Medium via OOMedia
  * - custom
  *    + formatiert den Wert anhand einer Benutzer definierten Callback Funktion
  */
 function format($value, $format_type, $format)
 {
     global $I18N, $REX;
     if ($value === null || $value == '') {
         return '';
     }
     // Stringformatierung mit sprintf()
     if ($format_type == 'sprintf') {
         $value = rex_formatter::_formatSprintf($value, $format);
     } elseif ($format_type == 'date') {
         $value = rex_formatter::_formatDate($value, $format);
     } elseif ($format_type == 'strftime') {
         $value = rex_formatter::_formatStrftime($value, $format);
     } elseif ($format_type == 'number') {
         $value = rex_formatter::_formatNumber($value, $format);
     } elseif ($format_type == 'email') {
         $value = rex_formatter::_formatEmail($value, $format);
     } elseif ($format_type == 'url') {
         $value = rex_formatter::_formatUrl($value, $format);
     } elseif ($format_type == 'truncate') {
         $value = rex_formatter::_formatTruncate($value, $format);
     } elseif ($format_type == 'nl2br') {
         $value = rex_formatter::_formatNl2br($value, $format);
     } elseif ($format_type == 'rexmedia' && $value != '') {
         $value = rex_formatter::_formatRexMedia($value, $format);
     } elseif ($format_type == 'custom') {
         $value = rex_call_func($format, $value);
     }
     return $value;
 }
コード例 #2
0
/**
* Definiert einen Extension Point
*
* @param $extension Name der Extension
* @param $subject Objekt/Variable die beeinflusst werden soll
* @param $params Parameter für die Callback-Funktion
*/
function rex_register_extension_point($extension, $subject = '', $params = array(), $read_only = false)
{
    global $REX;
    $result = $subject;
    if (!is_array($params)) {
        $params = array();
    }
    if (isset($REX['EXTENSIONS'][$extension]) && is_array($REX['EXTENSIONS'][$extension])) {
        $params['subject'] = $subject;
        if ($read_only) {
            foreach ($REX['EXTENSIONS'][$extension] as $ext) {
                rex_call_func($ext, $params);
            }
        } else {
            foreach ($REX['EXTENSIONS'][$extension] as $ext) {
                $temp = rex_call_func($ext, $params);
                // RÜckgabewert nur auswerten wenn auch einer vorhanden ist
                // damit $params['subject'] nicht verfälscht wird
                if ($temp !== null) {
                    $result = $temp;
                    $params['subject'] = $result;
                }
            }
        }
    }
    return $result;
}
コード例 #3
0
/**
 * Definiert einen Extension Point
 *
 * @param $extensionPoint Name des ExtensionPoints
 * @param $subject Objekt/Variable die beeinflusst werden soll
 * @param $params Parameter für die Callback-Funktion
 */
function rex_register_extension_point($extensionPoint, $subject = '', $params = array(), $read_only = false)
{
    global $REX;
    $result = $subject;
    if (!is_array($params)) {
        $params = array();
    }
    // Name des EP als Parameter mit übergeben
    $params['extension_point'] = $extensionPoint;
    if (isset($REX['EXTENSIONS'][$extensionPoint]) && is_array($REX['EXTENSIONS'][$extensionPoint])) {
        $params['subject'] = $subject;
        if ($read_only) {
            foreach ($REX['EXTENSIONS'][$extensionPoint] as $ext) {
                $func = $ext[0];
                $local_params = array_merge($params, $ext[1]);
                rex_call_func($func, $local_params);
            }
        } else {
            foreach ($REX['EXTENSIONS'][$extensionPoint] as $ext) {
                $func = $ext[0];
                $local_params = array_merge($params, $ext[1]);
                $temp = rex_call_func($func, $local_params);
                // Rückgabewert nur auswerten wenn auch einer vorhanden ist
                // damit $params['subject'] nicht verfälscht wird
                // null ist default Rückgabewert, falls kein RETURN in einer Funktion ist
                if ($temp !== null) {
                    $result = $temp;
                    $params['subject'] = $result;
                }
            }
        }
    }
    return $result;
}
コード例 #4
0
/**
* Definiert einen Extension Point
*
* @param $extension Name der Extension
* @param $subject Objekt/Variable die beeinflusst werden soll
* @param $params Parameter für die Callback-Funktion
*/
function rex_register_extension_point($extension, $subject = '', $params = array(), $read_only = false)
{
    global $REX;
    $result = $subject;
    if (!is_array($params)) {
        $params = array();
    }
    if (isset($REX['EXTENSIONS'][$extension]) && is_array($REX['EXTENSIONS'][$extension])) {
        $params['subject'] = $subject;
        if ($read_only) {
            foreach ($REX['EXTENSIONS'][$extension] as $ext) {
                rex_call_func($ext, $params);
            }
        } else {
            foreach ($REX['EXTENSIONS'][$extension] as $ext) {
                $result = rex_call_func($ext, $params);
                $params['subject'] = $result;
            }
        }
    }
    return $result;
}
コード例 #5
0
/**
 * Erweitert das Meta-Formular um die neuen Meta-Felder
 *
 * @param $prefix Feldprefix
 * @param $params EP Params
 * @param $saveCallback callback, dass die
 */
function _rex_a62_metainfo_form($prefix, $params, $saveCallback)
{
    global $REX;
    $debug = false;
    $qry = 'SELECT
            *
          FROM
            ' . $REX['TABLE_PREFIX'] . '62_params p,
            ' . $REX['TABLE_PREFIX'] . '62_type t
          WHERE
            `p`.`type` = `t`.`id` AND
            `p`.`name` LIKE "' . $prefix . '%"
          ORDER BY
            prior';
    $sqlFields = new rex_sql();
    // $sqlFields->debugsql = true;
    $sqlFields->setQuery($qry);
    $params = rex_call_func($saveCallback, array($params, $sqlFields), false);
    // Beim ADD gibts noch kein activeItem
    $activeItem = null;
    if (isset($params['activeItem'])) {
        $activeItem = $params['activeItem'];
    }
    return rex_a62_metaFields($sqlFields, $activeItem, 'rex_a62_metainfo_form_item', $params);
}
コード例 #6
0
 function apiCall($method, $arguments)
 {
     if (!is_array($arguments)) {
         trigger_error('Expecting $arguments to be an array!', E_USER_ERROR);
     }
     // addonName als 1. Parameter einfügen
     array_unshift($arguments, $this->addonName);
     return rex_call_func(array('OOPlugin', $method), $arguments, false);
 }
コード例 #7
0
 static function _formatCustom($value, $format)
 {
     if (!is_callable($format)) {
         if (!is_callable($format[0])) {
             trigger_error('Unable to find callable ' . $format[0] . ' for custom format!');
         }
         $params = array();
         $params['subject'] = $value;
         if (is_array($format[1])) {
             $params = array_merge($format[1], $params);
         } else {
             $params['params'] = $format[1];
         }
         // $format ist in der Form
         // array(Name des Callables, Weitere Parameter)
         return rex_call_func($format[0], $params);
     }
     return rex_call_func($format, $value);
 }
コード例 #8
0
/**
 * Erweitert das Meta-Formular um die neuen Meta-Felder
 *
 * @param string   $prefix       Feldprefix
 * @param string   $params       EP Params
 * @param callback $saveCallback Callback, dass die Daten speichert
 */
function _rex_a62_metainfo_form($prefix, $params, $saveCallback)
{
    // Beim ADD gibts noch kein activeItem
    $activeItem = null;
    if (isset($params['activeItem'])) {
        $activeItem = $params['activeItem'];
    }
    $restrictionsCondition = '';
    if ($prefix == 'art_') {
        if ($params['id'] != '') {
            $s = '';
            $OOArt = OOArticle::getArticleById($params['id'], $params['clang']);
            // Alle Metafelder des Pfades sind erlaubt
            foreach (explode('|', $OOArt->getPath()) as $pathElement) {
                if ($pathElement != '') {
                    $s .= ' OR `p`.`restrictions` LIKE "%|' . $pathElement . '|%"';
                }
            }
            $restrictionsCondition = 'AND (`p`.`restrictions` = ""' . $s . ')';
        }
    } elseif ($prefix == 'cat_') {
        $s = '';
        if ($params['id'] != '') {
            $OOCat = OOCategory::getCategoryById($params['id'], $params['clang']);
            // Alle Metafelder des Pfades sind erlaubt
            foreach (explode('|', $OOCat->getPath()) as $pathElement) {
                if ($pathElement != '') {
                    $s .= ' OR `p`.`restrictions` LIKE "%|' . $pathElement . '|%"';
                }
            }
            // Auch die Kategorie selbst kann Metafelder haben
            $s .= ' OR `p`.`restrictions` LIKE "%|' . $params['id'] . '|%"';
        }
        $restrictionsCondition = 'AND (`p`.`restrictions` = ""' . $s . ')';
    } elseif ($prefix == 'med_') {
        $catId = rex_session('media[rex_file_category]', 'int');
        if ($activeItem) {
            $catId = $activeItem->getValue('category_id');
        }
        if ($catId !== '') {
            $s = '';
            if ($catId != 0) {
                $OOCat = OOMediaCategory::getCategoryById($catId);
                // Alle Metafelder des Pfades sind erlaubt
                foreach (explode('|', $OOCat->getPath()) as $pathElement) {
                    if ($pathElement != '') {
                        $s .= ' OR `p`.`restrictions` LIKE "%|' . $pathElement . '|%"';
                    }
                }
            }
            // Auch die Kategorie selbst kann Metafelder haben
            $s .= ' OR `p`.`restrictions` LIKE "%|' . $catId . '|%"';
            $restrictionsCondition = 'AND (`p`.`restrictions` = ""' . $s . ')';
        }
    }
    $sqlFields = _rex_a62_metainfo_sqlfields($prefix, $restrictionsCondition);
    $params = rex_call_func($saveCallback, array($params, $sqlFields), false);
    return rex_a62_metaFields($sqlFields, $activeItem, 'rex_a62_metainfo_form_item', $params);
}
コード例 #9
0
 function handleGlobalVarParams($varname, $args, $value)
 {
     if (isset($args['callback'])) {
         $args['subject'] = $value;
         return rex_call_func($args['callback'], $args);
     }
     $prefix = '';
     $suffix = '';
     if (isset($args['instead']) && $value != '') {
         $value = $args['instead'];
     }
     if (isset($args['ifempty']) && $value == '') {
         $value = $args['ifempty'];
     }
     if ($value != '' && isset($args['prefix'])) {
         $prefix = $args['prefix'];
     }
     if ($value != '' && isset($args['suffix'])) {
         $suffix = $args['suffix'];
     }
     return $prefix . $value . $suffix;
 }