function save_data($plugins, $data) { $plugin = $this->_get_plugin($plugins); if ($plugin && isset($plugin['data'])) { $save_data = array(); global $raw_input_data; foreach ($data as $name => $val) { if (isset($plugin['data'][$name])) { $info = $plugin['data'][$name]; if ($info['type'] === 'boolean') { $save_data[$name] = $val == 'true'; } else { if ($info['type'] === 'text' && isset($raw_input_data[$name])) { $save_data[$name] = $raw_input_data[$name]; } else { $save_data[$name] = $val; } } } } Shutter::call_method($plugin['php_class_name'], 'set_data', (object) $save_data); $this->data = serialize((array) Shutter::call_method($plugin['php_class_name'], 'get_data')); } }
public static function all($map) { self::scan("storage/plugins"); $final = array(); foreach (self::$plugin_info as $plugin) { if (isset($map[$plugin['path']]) || $plugin['internal']) { $plugin['activated'] = true; if (!$plugin['internal']) { $plugin['id'] = $map[$plugin['path']]['id']; $plugin['setup'] = $map[$plugin['path']]['setup']; $saved = $map[$plugin['path']]['data']; } if (isset($plugin['data'])) { foreach ($plugin['data'] as $key => &$d) { if (isset($saved[$key])) { $d['value'] = $saved[$key]; } } if ($d['type'] === 'boolean' && isset($d['value'])) { $d['value'] = $d['value'] == 'true'; } } } else { $plugin['setup'] = $plugin['activated'] = false; } if (isset($plugin['php_class_name'])) { $plugin['compatible'] = Shutter::call_method($plugin['php_class_name'], 'is_compatible'); if ($plugin['compatible'] !== true) { $plugin['compatible_error'] = $plugin['compatible']; $plugin['compatible'] = false; } } else { $plugin['compatible'] = true; } $final[] = $plugin; } return $final; }