コード例 #1
0
 public function editCatalogAction()
 {
     $catalogForm = Model_Static_Loader::loadForm("catalog");
     $catalogForm->preview->setDestination(APPLICATION_ROOT . "/public/files/catalogs");
     $catalogForm->file->setDestination(APPLICATION_ROOT . "/public/files/catalogs");
     $catalogs = new Zend_Config_Xml(APPLICATION_PATH . "/config/catalogs.xml");
     $id = $this->getRequest()->getParam('guid');
     if ($id && !isset($catalogs->{$id})) {
         throw new Zend_Exception("Not found", 404);
     } elseif ($id) {
         $catalogForm->setDefaults($catalogs->{$id}->toArray());
     }
     if ($this->getRequest()->isPost() && $catalogForm->isValid($_POST)) {
         $data = $catalogForm->getValues();
         $data["preview"] = "/files/catalogs/" . $data["preview"];
         $data["file"] = "/files/catalogs/" . $data["file"];
         $catalogs = $catalogs->toArray();
         if ($id) {
             $catalogs[$id] = $data;
         } else {
             $catalogs['cat' . date("ymdhis")] = $data;
         }
         $xml = new Zend_Config_Writer_Xml();
         $xml->setConfig(new Zend_Config($catalogs));
         $xml->setFilename(APPLICATION_PATH . "/config/catalogs.xml");
         $xml->write();
     }
     $this->view->form = $catalogForm;
 }
コード例 #2
0
 function backupAction()
 {
     //$message = var_export($this->getRequest()->getPost(), true);
     ignore_user_abort();
     /* @var $request Zend_Controller_Request_Http */
     $request = $this->getRequest();
     $fastAction = $request->getParam('a', false);
     if ($request->isPost() || $fastAction !== false) {
         $components = $request->getPost('components', array());
         $plugins = X_VlcShares_Plugins::broker()->getPlugins();
         $items = array();
         foreach ($plugins as $pId => $plugin) {
             if (array_key_exists($pId, $components) && (bool) $components[$pId] || $fastAction == 'all' || $fastAction == $pId) {
                 if ($plugin instanceof X_VlcShares_Plugins_BackuppableInterface) {
                     //$toBackup[$pId] = $plugin;
                     $items[$pId] = $plugin->getBackupItems();
                     X_Debug::i('Backuppable plugin: ' . $pId);
                 } elseif ($fastAction != 'all') {
                     $this->_helper->flashMessenger(array('text' => X_Env::_('p_backupper_backup_invalidplugin') . ": {$pId}", 'type' => 'error'));
                 }
             } else {
                 //X_Debug::i('Discarded plugin: '.$pId);
             }
         }
         //$this->_helper->flashMessenger(var_export($items, true));
         if (count($items)) {
             $writer = new Zend_Config_Writer_Xml();
             $date = date("Y-m-d_H-i-s");
             $type = $fastAction !== false ? $fastAction : 'custom';
             $data['metadata'] = array('version' => X_VlcShares::VERSION, 'created' => date('d/m/Y H:i:s'), 'decrypt' => 'backupper_decodevalues_0_5_5');
             $data['plugins'] = $items;
             $filename = APPLICATION_PATH . "/../data/backupper/backup_{$date}_{$type}.xml";
             $data['plugins'] = array_map('backupper_encodevalues', $data['plugins']);
             $configs = new Zend_Config($data);
             $writer->setFilename($filename);
             try {
                 $writer->write(null, $configs, true);
                 $this->_helper->flashMessenger(array('text' => X_Env::_('p_backupper_backup_done'), 'type' => 'info'));
             } catch (Exception $e) {
                 $this->_helper->flashMessenger(array('text' => X_Env::_('p_backupper_err_writefile') . ": {$e->getMessage()}", 'type' => 'error'));
             }
         } else {
             $this->_helper->flashMessenger(array('text' => X_Env::_('p_backupper_backup_nobackupactionneeded'), 'type' => 'warning'));
         }
     }
     //$this->_helper->flashMessenger($message);
     $this->_helper->redirector('index', 'backupper');
 }