public function renameAction()
 {
     $path = $this->_getPath();
     $this->view->fileIndex = $this->_getParam('index');
     if (!is_file($path)) {
         return $this->_helper->redirector->gotoRoute(array('action' => 'index'));
     }
     @(list($fileName, $fileExt) = explode('.', basename($path), 2));
     $this->view->form = $form = new Core_Form_Admin_File_Rename();
     $form->name->setValue($fileName);
     if (!$this->getRequest()->isPost()) {
         return;
     }
     if (!$form->isValid($this->getRequest()->getPost())) {
         return;
     }
     $filename = $form->getValue('name');
     $newPath = dirname($path) . DIRECTORY_SEPARATOR . $filename . '.' . $fileExt;
     if (!rename($path, $newPath)) {
         $form->addError('Unable to rename');
         return;
     }
     $this->view->fileName = basename($newPath);
     $this->view->status = true;
     // Redirect
     if (null === $this->_helper->contextSwitch->getCurrentContext()) {
         return $this->_helper->redirector->gotoRoute(array('action' => 'index'));
     } else {
         if ('smoothbox' === $this->_helper->contextSwitch->getCurrentContext()) {
             return $this->_forward('success', 'utility', 'core', array('smoothboxClose' => true, 'parentRefresh' => true));
         }
     }
 }
예제 #2
0
 public function renameAction()
 {
     $path = $this->_getPath();
     $this->view->fileIndex = $this->_getParam('index');
     if (!is_file($path)) {
         return $this->_helper->redirector->gotoRoute(array('action' => 'index'));
     }
     @(list($fileName, $fileExt) = explode('.', basename($path), 2));
     $this->view->form = $form = new Core_Form_Admin_File_Rename();
     $form->name->setValue($fileName);
     if (!$this->getRequest()->isPost()) {
         return;
     }
     if (!$form->isValid($this->getRequest()->getPost())) {
         return;
     }
     $filename = $form->getValue('name');
     $newPath = dirname($path) . DIRECTORY_SEPARATOR . $filename . '.' . $fileExt;
     if (!rename($path, $newPath)) {
         $form->addError('Unable to rename');
         return;
     }
     $this->view->fileName = basename($newPath);
     $this->view->status = true;
 }