/** * A shortcut for creating or updating a config value. * @param string $name The config name. * @param string $value The config value. * @return Dbi_Record The resulting record. */ public static function Set($name, $value) { $config = Model_Config::Get($name); if (!$config->exists()) { $config = Model_Config::Create(); $config['configname'] = $name; } $config['configvalue'] = $value; $config->save(); return $config; }
Plugin_Breadcrumbs::Add('Edit'); $config = Typeframe::Registry()->getConfig($_REQUEST['config']); if (!$config) { Typeframe::Redirect('Invalid config specified', Typeframe::CurrentPage()->applicationUri(), 1); return; } if ($config->redirect()) { Typeframe::Redirect('Redirecting to ' . $config->name() . ' admin...', $config->redirect()); return; } // update the config settings if ('POST' == $_SERVER['REQUEST_METHOD']) { foreach ($config->items() as $i) { $config = Model_Config::Get($i->name()); if (!$config->exists()) { $config = Model_Config::Create(); $config['configname'] = $i->name(); } $config['configvalue'] = isset($_POST[$i->name()]) ? $_POST[$i->name()] : ''; $config->save(); } Typeframe::Registry()->purgeRegistryCache(); Typeframe::Redirect('Configuration updated.', Typeframe::CurrentPage()->applicationUri()); return; } // otherwise, set it up to edit //if ($config->template()) Typeframe::SetPageTemplate($config->template()); $object = new stdClass(); $object->name = $config->name(); $items = array(); foreach ($config->items() as $i) {