1
+ <?php
2
+
3
+ class Metadataextractor_ConfigController extends Metadataextractor_AppController
4
+ {
5
+ public $ _moduleForms =array ('Config ' );
6
+ public $ _components =array ('Utility ' , 'Date ' );
7
+
8
+
9
+ /** index action*/
10
+ function indexAction ()
11
+ {
12
+ if (!$ this ->logged ||!$ this ->userSession ->Dao ->getAdmin ()==1 )
13
+ {
14
+ throw new Zend_Exception ("You should be an administrator " );
15
+ }
16
+
17
+ if (file_exists (BASE_PATH ."/core/configs/metadataextractor.local.ini " ))
18
+ {
19
+ $ applicationConfig = parse_ini_file (BASE_PATH ."/core/configs/ " .$ this ->moduleName .".local.ini " , true );
20
+ }
21
+ else
22
+ {
23
+ $ applicationConfig = parse_ini_file (BASE_PATH .'/modules/".$this->moduleName."/configs/module.ini ' , true );
24
+ }
25
+ $ configForm = $ this ->ModuleForm ->Config ->createConfigForm ();
26
+
27
+ $ formArray = $ this ->getFormAsArray ($ configForm );
28
+ $ formArray ['hachoir ' ]->setValue ($ applicationConfig ['global ' ]['hachoir ' ]);
29
+
30
+ $ this ->view ->configForm = $ formArray ;
31
+
32
+ if ($ this ->_request ->isPost ())
33
+ {
34
+ $ this ->_helper ->layout ->disableLayout ();
35
+ $ this ->_helper ->viewRenderer ->setNoRender ();
36
+ $ submitConfig = $ this ->_getParam ('submitConfig ' );
37
+ if (isset ($ submitConfig ))
38
+ {
39
+ if (file_exists (BASE_PATH ."/core/configs/ " .$ this ->moduleName .".local.ini.old " ))
40
+ {
41
+ unlink (BASE_PATH ."/core/configs/ " .$ this ->moduleName .".local.ini.old " );
42
+ }
43
+ if (file_exists (BASE_PATH ."/core/configs/ " .$ this ->moduleName .".local.ini " ))
44
+ {
45
+ rename (BASE_PATH ."/core/configs/ " .$ this ->moduleName .".local.ini " ,BASE_PATH ."/core/configs/ " .$ this ->moduleName .".local.ini.old " );
46
+ }
47
+ $ applicationConfig ['global ' ]['hachoir ' ] = $ this ->_getParam ('hachoir ' );
48
+ $ this ->Component ->Utility ->createInitFile (BASE_PATH ."/core/configs/ " .$ this ->moduleName .".local.ini " , $ applicationConfig );
49
+ echo JsonComponent::encode (array (true , 'Changed saved ' ));
50
+ }
51
+ }
52
+ }
53
+
54
+ }//end class
0 commit comments