예제 #1
0
 /**
  * Available plugins list.
  *
  * @return array List of the available plugins.
  */
 public static function getPluginsAvailable()
 {
     $classNames = array();
     $classNames['category'] = 'FilterUtil_Filter_Category';
     $classNames['default'] = 'FilterUtil_Filter_Default';
     $classNames['date'] = 'FilterUtil_Filter_Date';
     $classNames['mnlist'] = 'FilterUtil_Filter_Mnlist';
     $classNames['pmlist'] = 'FilterUtil_Filter_Pmlist';
     $classNames['replaceName'] = 'FilterUtil_Filter_ReplaceName';
     // collect classes from other providers also allows for override
     // TODO A [This is only allowed for the module which owns this object.]
     $event = new \Zikula\Core\Event\GenericEvent();
     $event->setData($classNames);
     $classNames = EventUtil::getManager()->dispatch('zikula.filterutil.get_plugin_classes', $event)->getData();
     return $classNames;
 }
예제 #2
0
파일: DataUtil.php 프로젝트: rmaiwald/core
 /**
  * Format a variable for HTML display. This method is recursive array safe.
  *
  * @param string $var The variable to format.
  *
  * @return string The formatted variable.
  */
 public static function formatForDisplayHTML($var)
 {
     static $allowedtags = null;
     static $outputfilter;
     static $event;
     if (!$event) {
         $event = new \Zikula\Core\Event\GenericEvent();
     }
     if (!isset($allowedtags)) {
         $allowedHTML = array();
         $allowableHTML = System::getVar('AllowableHTML');
         if (is_array($allowableHTML)) {
             foreach ($allowableHTML as $k => $v) {
                 if ($k == '!--') {
                     if ($v != 0) {
                         $allowedHTML[] = "{$k}.*?--";
                     }
                 } else {
                     switch ($v) {
                         case 0:
                             break;
                         case 1:
                             $allowedHTML[] = "/?{$k}\\s*/?";
                             break;
                         case 2:
                             $allowedHTML[] = "/?\\s*{$k}" . "(\\s+[\\w:]+\\s*=\\s*(\"[^\"]*\"|'[^']*'))*" . '\\s*/?';
                             break;
                     }
                 }
             }
         }
         if (count($allowedHTML) > 0) {
             $allowedtags = '~<\\s*(' . implode('|', $allowedHTML) . ')\\s*>~is';
         } else {
             $allowedtags = '';
         }
     }
     if (!isset($outputfilter)) {
         if (ModUtil::available('ZikulaSecurityCenterModule') && !System::isInstalling()) {
             $outputfilter = System::getVar('outputfilter', 0);
         } else {
             $outputfilter = 0;
         }
     }
     if (is_array($var)) {
         foreach ($var as $k => $v) {
             $var[$k] = self::formatForDisplayHTML($v);
         }
     } else {
         // Run additional filters
         if ($outputfilter > 0) {
             $event->setData($var)->setArg('filter', $outputfilter);
             $var = EventUtil::dispatch('system.outputfilter', $event)->getData();
         }
         // Preparse var to mark the HTML that we want
         if (!empty($allowedtags)) {
             $var = preg_replace($allowedtags, "\\1", $var);
         }
         // Fix html entities
         $var = htmlspecialchars($var);
         // Fix the HTML that we want
         $var = preg_replace_callback('#\\022([^\\024]*)\\024#', create_function('$m', 'return DataUtil::formatForDisplayHTML_callback($m);'), $var);
         // Fix entities if required
         if (System::getVar('htmlentities')) {
             $var = preg_replace('/&amp;([a-z#0-9]+);/i', "&\\1;", $var);
         }
     }
     return $var;
 }