Exemplo n.º 1
0
 /**
  * Add a prefix to the object whitelist.
  * 
  * @param string $prefix
  * @parsm bool $permanently
  * @return void
  */
 public static function addObjectPrefix($prefix, $permanently = false)
 {
     if (!count(self::$_object_whitelist)) {
         self::_loadWhitelists();
     }
     $prefix = self::formatPrefix($prefix);
     if (!in_array($prefix, self::$_object_whitelist)) {
         self::$_object_whitelist[] = $prefix;
         natcasesort(self::$_object_whitelist);
         if ($permanently) {
             Config::set('mediafilter.object', self::$_object_whitelist);
             Config::save();
         }
     }
 }
Exemplo n.º 2
0
 /**
  * Parse and get a configuration value.
  * 
  * @param array $value
  * @return mixed
  */
 protected static function _parseConfigValue(array $value)
 {
     $filters = array();
     $result = null;
     foreach ($value as $option) {
         $option = array_map('trim', explode(':', $option, 2));
         if (count($option) === 1) {
             if (function_exists($option[0])) {
                 $filters[] = $option[0];
             }
         } elseif ($result !== null) {
             continue;
         } elseif ($option[0] === 'common') {
             $result = Config::get($option[1]);
         } else {
             if (!isset(self::$_config_cache[$option[0]])) {
                 self::$_config_cache[$option[0]] = getModel('module')->getModuleConfig($option[0]) ?: new stdClass();
             }
             $options = explode('.', $option[1]);
             $temp = self::$_config_cache[$option[0]];
             foreach ($options as $step) {
                 if (is_object($temp) && isset($temp->{$step})) {
                     $temp = $temp->{$step};
                 } elseif (is_array($temp) && isset($temp[$step])) {
                     $temp = $temp[$step];
                 } else {
                     $temp = null;
                 }
             }
             $result = $temp;
         }
     }
     foreach ($filters as $filter) {
         $result = $filter($result);
     }
     return $result;
 }