/**
  * Add Folder Action
  * Adds the new folder
  *
  * @param Rsc_Http_Request $request
  * @return Rsc_Http_Response
  */
 public function addFolderAction(Rsc_Http_Request $request)
 {
     $env = $this->getEnvironment();
     $folders = new SupsysticSlider_Photos_Model_Folders();
     $stats = $this->getEnvironment()->getModule('stats');
     $stats->save('folders.add');
     if ($env->getConfig()->isEnvironment(Rsc_Environment::ENV_DEVELOPMENT)) {
         $folders->setDebugEnabled(true);
     }
     $folderName = $request->post->get('folder_name');
     $viewType = $request->post->get('view_type');
     if (!$folders->add($folderName ? $folderName : $env->translate('New Folder'))) {
         $response = array('error' => true, 'folder' => null);
     } else {
         $folder = $env->getTwig()->render(sprintf('@ui/%s/folder.twig', $viewType ? $viewType : 'block'), array('folder' => $folders->getById($folders->getInsertId())));
         $response = array('error' => false, 'folder' => $folder, 'id' => $folders->getInsertId());
     }
     return $this->response('ajax', $response);
 }
示例#2
0
 /**
  * Returns the folder by the photo id
  * @param int $photoId The identifier of the photo
  * @return null|object
  */
 public function getFolderByPhotoId($photoId)
 {
     if (!($photo = $this->getById($photoId))) {
         return null;
     }
     if (!class_exists($classname = 'SupsysticSlider_Photos_Model_Folders', false)) {
         if ($this->debugEnabled) {
             wp_die(sprintf('The required class \'%s\' is does not exists', $classname));
         }
         return null;
     }
     $folders = new SupsysticSlider_Photos_Model_Folders($this->debugEnabled);
     return $folders->getById($photo->folder_id);
 }