예제 #1
0
 /**
  * @param array $options
  * @param bool  $fromCreate
  *
  * @throws DreamFactory\Platform\Exceptions\BadRequestException
  */
 public function actionUpdate($options = array(), $fromCreate = false)
 {
     $_id = $_schema = $_errors = null;
     //	New provider
     if (false !== $fromCreate && null !== ($_resourceId = FilterInput::request('resource'))) {
         //	New request
         $_model = ResourceStore::model($_resourceId);
         $_displayName = Inflector::display($_resourceId);
         $_schema = $this->_loadConfigSchema($_resourceId, $_model->hasAttribute('config_text') ? $_model->config_text : array());
     } else {
         //	Requests will come in like: /admin/update/<resource>/<id>
         list($_resourceId, $_id) = $this->_parseRequest();
         $_displayName = Inflector::display($_resourceId);
         //	Load it up.
         /** @var $_model BasePlatformSystemModel */
         if (null !== ($_model = ResourceStore::model($_resourceId)->findByPk($_id))) {
             $_schema = $this->_loadConfigSchema($_resourceId, $_model->hasAttribute('config_text') ? $_model->config_text : array());
             if (Pii::postRequest()) {
                 //	On a post, update
                 if (null === ($_data = Option::get($_POST, $_displayName))) {
                     throw new BadRequestException('No payload received.');
                 }
                 /** @var Provider $_model */
                 if ($_model->hasAttribute('config_text')) {
                     $_len = strlen(static::SCHEMA_PREFIX);
                     $_config = Option::clean($_model->config_text);
                     foreach ($_data as $_key => $_value) {
                         if (static::SCHEMA_PREFIX == substr($_key, 0, $_len)) {
                             $_newKey = str_replace(static::SCHEMA_PREFIX, null, $_key);
                             if (isset($_config[$_newKey])) {
                                 $_config[$_newKey] = $_value;
                             }
                             unset($_data[$_key]);
                         }
                     }
                     $_model->config_text = $_config;
                     unset($_data['config_text']);
                 }
                 $_model->setAttributes($_data);
                 $_model->save();
                 Pii::setState('status_message', 'Resource Updated Successfully');
                 $this->redirect('/admin/' . $_resourceId . '/update/' . $_id);
             }
         }
         if ($_model->hasAttribute('name')) {
             $_displayName = $_model->name;
         } else {
             if ($_model->hasAttribute('provider_name')) {
                 $_displayName = $_model->provider_name;
             } else {
                 if ($_model->hasAttribute('api_name')) {
                     $_displayName = $_model->api_name;
                 }
             }
         }
     }
     $this->render('update', array('model' => $_model, 'schema' => $_schema, 'errors' => $_errors, 'resourceName' => $_resourceId, 'displayName' => $_displayName, 'update' => null !== $_id));
 }
예제 #2
0
 /**
  * Adds the first admin from a form
  */
 public function actionInitAdmin()
 {
     if ($this->_activated) {
         $this->redirect('/');
     }
     //	Clear the skipped flag...
     Pii::setState('app.registration_skipped', false);
     $_model = new InitAdminForm();
     if (isset($_POST, $_POST['InitAdminForm'])) {
         $_model->attributes = $_POST['InitAdminForm'];
         if ($_model->validate()) {
             try {
                 SystemManager::initAdmin($_model->attributes);
                 $this->redirect('/');
                 return;
             } catch (\Exception $_ex) {
                 $_model->addError('email', $_ex->getMessage());
             }
         }
     }
     $this->render('initAdmin', array('model' => $_model));
 }
예제 #3
0
use Kisma\Core\Utility\FilterInput;
/**
 * @var string          $content
 * @var ConsoleController $this
 */
$_route = $this->route;
$_step = 'light';
$_headline = 'DSP Settings';
$_themeList = null;
//	Change these to update the CDN versions used. Set to false to disable
$_bootstrapVersion = '3.1.1';
// Set to false to disable
$_bootswatchVersion = '3.1.1';
$_dataTablesVersion = '1.9.4';
$_bootswatchTheme = FilterInput::request('theme', Pii::getState('admin.default_theme', 'default'), FILTER_SANITIZE_STRING);
Pii::setState('dsp.admin_theme', $_bootswatchTheme);
$_useBootswatchThemes = 'default' != $_bootswatchTheme;
$_fontAwesomeVersion = '4.0.3';
// Set to false to disable
$_jqueryVersion = '1.11.0';
$_themes = array('Default', 'Amelia', 'Cerulean', 'Cosmo', 'Cyborg', 'Flatly', 'Journal', 'Readable', 'Simplex', 'Slate', 'Spacelab', 'United');
$_url = Curl::currentUrl(false);
foreach ($_themes as $_item) {
    $_name = strtolower($_item);
    $_class = $_bootswatchTheme == $_name ? 'class="active"' : null;
    $_themeList .= <<<HTML
\t<li {$_class}><a href="{$_url}?theme={$_name}">{$_item}</a></li>
HTML;
}
//	Our css building begins...
$_css = '<link href="https://fonts.googleapis.com/css?family=Open+Sans:400,700,800" rel="stylesheet" type="text/css">';