public function loadClass() { ClassLoader::import('application.model.searchable.item.SearchableItem'); ClassLoader::import('application.model.searchable.index.SearchableConfigurationIndexing'); SearchableConfigurationIndexing::buildIndexIfNeeded(); }
/** * @role update */ public function save() { $values = $this->config->getSettingsBySection($this->request->get('id')); $validation = $this->getValidationRules($values); $validator = $this->buildValidator($values, $validation); if (!$validator->isValid()) { return new JSONResponse(array('errors' => $validator->getErrorList()), 'failure', $this->translate('_could_note_save_section')); } else { $languages = $this->application->getLanguageArray(); $defLang = $this->application->getDefaultLanguageCode(); $this->config->setAutoSave(false); $data = array(); foreach ($values as $key => $value) { if ($this->config->isMultiLingual($key) && 'string' == $value['type'] || 'longtext' == $value['type']) { $this->config->setValueByLang($key, $defLang, $this->request->get($key)); foreach ($languages as $lang) { $this->config->setValueByLang($key, $lang, $this->request->get($key . '_' . $lang)); } } else { if ('image' == $value['type']) { $file = 'upload/' . $key . '-' . $_FILES[$key]['name']; $path = ClassLoader::getRealPath('public.') . $file; if (@move_uploaded_file($_FILES[$key]['tmp_name'], $path)) { $this->config->set($key, $file); } } else { $this->config->set($key, $this->request->get($key, 'bool' == $value['type'] ? 0 : '')); } } $data[$key] = $this->config->get($key); } $this->config->save(); $this->config->setAutoSave(true); ClassLoader::import('application.model.searchable.index.SearchableConfigurationIndexing'); SearchableConfigurationIndexing::buildIndexIfNeeded(); $sc = new SearchableConfigurationIndexing($this->config, $this->application); $sc->buildIndex($this->request->get('id')); return new JSONResponse($data, 'success', $this->translate('_save_conf')); } }