Exemplo n.º 1
0
 public function executeSave(dmWebRequest $request)
 {
     $file = dmProject::rootify($request->getParameter('file'));
     $this->forward404Unless(file_exists($file), $file . ' does not exists');
     try {
         @$this->getService('file_backup')->save($file);
     } catch (dmException $e) {
         return $this->renderJson(array('type' => 'error', 'message' => 'backup failed : ' . $e->getMessage()));
     }
     @file_put_contents($file, $request->getParameter('code'));
     if (dmOs::getFileExtension($file, false) == 'css') {
         $return = array('type' => 'css', 'path' => $this->getHelper()->getStylesheetWebPath(dmOs::getFileWithoutExtension($file)));
     } else {
         $this->getService('cache_cleaner')->clearTemplate();
         $return = array('type' => 'php', 'widgets' => $this->getWidgetInnersForFile($file));
     }
     $return['message'] = $this->getI18n()->__('Your modifications have been saved');
     return $this->renderJson($return);
 }
Exemplo n.º 2
0
 public function destroyThumbnails()
 {
     if (!$this->isImage() || !$this->getService('filesystem')) {
         return true;
     }
     $thumbs = sfFinder::type('file')->name(dmOs::getFileWithoutExtension($this->get('file')) . '*')->maxdepth(0)->in(dmOs::join($this->Folder->getFullPath(), '.thumbs'));
     return $this->getServiceContainer()->getService('filesystem')->unlink($thumbs);
 }