Example #1
0
 public function saveValue()
 {
     $request = \Ip\ServiceLocator::request();
     $request->mustBePost();
     $post = $request->getPost();
     if (empty($post['fieldName'])) {
         throw new \Exception('Missing required parameter');
     }
     $fieldName = $post['fieldName'];
     if (!isset($post['value'])) {
         throw new \Exception('Missing required parameter');
     }
     $value = $post['value'];
     if (!in_array($fieldName, array('websiteTitle', 'websiteEmail')) && !(in_array($fieldName, array('automaticCron', 'cronPassword', 'removeOldRevisions', 'removeOldRevisionsDays', 'removeOldEmails', 'removeOldEmailsDays', 'allowAnonymousUploads', 'trailingSlash')) && ipAdminPermission('Config advanced'))) {
         throw new \Exception('Unknown config value');
     }
     $emailValidator = new \Ip\Form\Validator\Email();
     $error = $emailValidator->getError(array('value' => $value), 'value', \Ip\Form::ENVIRONMENT_ADMIN);
     if ($fieldName === 'websiteEmail' && $error !== false) {
         return $this->returnError($error);
     }
     if (in_array($fieldName, array('websiteTitle', 'websiteEmail'))) {
         if (!isset($post['languageId'])) {
             throw new \Exception('Missing required parameter');
         }
         $languageId = $post['languageId'];
         $language = ipContent()->getLanguage($languageId);
         ipSetOptionLang('Config.' . $fieldName, $value, $language->getCode());
     } else {
         ipSetOption('Config.' . $fieldName, $value);
     }
     return new \Ip\Response\Json(array(1));
 }
Example #2
0
 /**
  *  @throws \Ip\Exception\Db
  */
 public function activate()
 {
     $savedTableTypes = ipGetOption(TableType::OPTION);
     if (empty($savedTableTypes)) {
         ipSetOption(TableType::OPTION, array());
         TableType::create(array('name' => 'default', 'language' => ipContent()->getLanguages()[0]->getId(), 'columnOption' => TableType::SHOW_ALL_COLUMNS, 'specificColumns' => array()))->save();
     }
     $this->createDataTableRepository();
 }
Example #3
0
 public static function import($configFile)
 {
     $content = file_get_contents($configFile);
     $values = json_decode($content, true);
     if (!is_array($values)) {
         throw new \Exception("Can't parse configuration file: " . $configFile);
     }
     foreach ($values as $key => $value) {
         ipSetOption($key, $value);
     }
 }
Example #4
0
 /**
  * @param array $data
  * @param $info ['pluginName']
  */
 public static function ipPluginSaveOptions_20($data, $info)
 {
     $plugin = Helper::getPluginData($info['pluginName']);
     if (empty($plugin['options'])) {
         return $data;
     }
     $form = new \Ip\Form();
     /* @var $form \Ip\Form */
     $form = Helper::pluginPropertiesFormFields($info['pluginName'], $form);
     foreach ($plugin['options'] as $option) {
         if (empty($option['type'])) {
             $option['type'] = 'text';
         }
         if (empty($option['name'])) {
             continue;
         }
         $field = $form->getField($option['name']);
         if (!$field) {
             continue;
         }
         $optionName = $info['pluginName'] . '.' . $option['name'];
         if ($field instanceof \Ip\Form\FieldLang) {
             //multilingual field
             $value = '';
             if (!empty($data[$option['name']])) {
                 $value = $data[$option['name']];
             }
             if (!is_array($value)) {
                 $value = array();
             }
             foreach ($value as $languageKey => $langValue) {
                 if (!is_string($languageKey)) {
                     continue;
                 }
                 if (!is_string($langValue)) {
                     continue;
                 }
                 ipSetOptionLang($optionName, $langValue, $languageKey);
             }
         } else {
             //standard field
             if (method_exists($field, 'isChecked')) {
                 //checkbox uniqueness
                 $value = $field->isChecked($data, $option['name']);
             } else {
                 $value = $field->getValueAsString($data, $option['name']);
             }
             ipSetOption($optionName, $value);
         }
         unset($data[$option['name']]);
         // this option is processed
     }
     return $data;
 }
Example #5
0
 public function saveWidgetOptions(Theme $theme)
 {
     $widgetOptions = $theme->getWidgetOptions();
     if (!empty($widgetOptions['image']['width'])) {
         ipSetOption('Content.widgetImageWidth', $widgetOptions['image']['width']);
     }
     if (!empty($widgetOptions['image']['height'])) {
         ipSetOption('Content.widgetImageHeight', $widgetOptions['image']['height']);
     }
     if (!empty($widgetOptions['gallery']['width'])) {
         ipSetOption('Content.widgetGalleryWidth', $widgetOptions['gallery']['width']);
     }
     if (!empty($widgetOptions['gallery']['height'])) {
         ipSetOption('Content.widgetGalleryHeight', $widgetOptions['gallery']['height']);
     }
     if (!empty($widgetOptions['heading']['maxLevel'])) {
         ipSetOption('Content.widgetHeadingMaxLevel', $widgetOptions['heading']['maxLevel']);
     }
 }
Example #6
0
 protected static function importDefaultOptions($pluginName, $options)
 {
     $form = new \Ip\Form();
     /* @var $form \Ip\Form */
     $form = Helper::pluginPropertiesFormFields($pluginName, $form);
     foreach ($options as $option) {
         if (empty($option['name'])) {
             continue;
         }
         $field = $form->getField($option['name']);
         if (!$field) {
             continue;
         }
         $optionKey = $pluginName . '.' . $option['name'];
         if (!is_null(ipGetOption($optionKey))) {
             // option already exists
             continue;
         }
         ipSetOption($pluginName . '.' . $option['name'], $field->getValue());
     }
 }
Example #7
0
 public static function update_70()
 {
     ipSetOption('Config.trailingSlash', 0);
     // to keep the system as it was before. New default value is 1;
 }
Example #8
0
 public static function generateCronPassword()
 {
     $password = \rand(100000, 999999);
     ipSetOption('Config.cronPassword', $password);
     return $password;
 }
Example #9
0
 /**
  * Saves the TableType
  */
 public function save()
 {
     $savedTableTypes = ipGetOption(self::OPTION);
     $savedTableTypes[$this->getId()] = $this->toArray();
     ipSetOption(self::OPTION, $savedTableTypes);
 }