コード例 #1
0
 public function saveImageAction()
 {
     $this->_helper->layout->disableLayout();
     try {
         $uploader = new Axis_File_Uploader('image');
         $file = $uploader->setAllowedExtensions(array('jpg', 'jpeg', 'gif', 'png'))->setUseDispersion(true)->save(Axis::config()->system->path . '/media/category');
         $data = array('success' => true, 'data' => array('path' => $file['path'], 'file' => $file['file']));
     } catch (Axis_Exception $e) {
         $data = array('success' => false, 'messages' => array('error' => $e->getMessage()));
     }
     return $this->getResponse()->appendBody(Zend_Json::encode($data));
 }
コード例 #2
0
 public function importAction()
 {
     $this->_helper->layout->disableLayout();
     try {
         $uploader = new Axis_File_Uploader('template');
         $file = $uploader->setAllowedExtensions(array('xml'))->setUseDispersion(false)->save(Axis::config('system/path') . '/var/templates');
     } catch (Axis_Exception $e) {
         return $this->getResponse()->appendBody(Zend_Json::encode(array('success' => false, 'messages' => array('error' => $e->getMessage()))));
     }
     $themeFile = $file['path'] . $file['file'];
     $model = Axis::model('core/template');
     if (!$this->_getParam('overwrite_existing') && !$model->validateBeforeImport($themeFile)) {
         return $this->getResponse()->appendBody(Zend_Json::encode(array('errorCode' => 'template_exists')));
     }
     if (!$model->importTemplateFromXmlFile($themeFile)) {
         return $this->getResponse()->appendBody(Zend_Json::encode(array('success' => false)));
     }
     return $this->getResponse()->appendBody(Zend_Json::encode(array('success' => true, 'messages' => array('success' => Axis::translate('admin')->__('Template was imported successfully')))));
 }
コード例 #3
0
 private function _uploadAction()
 {
     $this->_helper->layout->disableLayout();
     $path = Axis::config()->system->path . '/' . $this->_getParam('path');
     if (!($path = $this->_getValidPath($path))) {
         return $this->getResponse()->appendBody(Zend_Json::encode(array('success' => false, 'messages' => array('error' => 'Invalid destination directory'))));
     }
     $result = array();
     foreach ($_FILES as $key => $values) {
         if (strpos($key, 'ext-gen') !== 0) {
             continue;
         }
         try {
             $uploader = new Axis_File_Uploader($key);
             $file = $uploader->setUseDispersion(false)->save($path);
             $result = array('success' => true, 'data' => array('path' => $file['path'], 'file' => $file['file']));
         } catch (Axis_Exception $e) {
             $result = array('success' => false, 'messages' => array('error' => $e->getMessage()));
         }
     }
     return $this->getResponse()->appendBody(Zend_Json::encode($result));
 }