예제 #1
0
파일: importer.php 프로젝트: vazahat/dudex
 function addphoto()
 {
     //$script = "$(window).bind('beforeunload', function(){return 'Processing your request...';});";
     //OW::getDocument()->addOnloadScript($script);
     OW::getDocument()->addStyleSheet(OW::getPluginManager()->getPlugin('ynmediaimporter')->getStaticCssUrl() . 'ynmediaimporter.css');
     $this->setPageTitle(OW::getLanguage()->text("ynmediaimporter", "adding_photo"));
     $this->setPageHeading(OW::getLanguage()->text("ynmediaimporter", "index_page_heading"));
     if (!OW::getRequest()->isPost()) {
         $url = OW::getRouter()->urlForRoute('ynmediaimporter.index');
         $this->redirect($url);
         exit;
     }
     $lang = OW::getLanguage();
     if (!strlen($albumName = htmlspecialchars(trim($_POST['album'])))) {
         $resp = array('result' => false, 'msg' => $lang->text('photo', 'photo_upload_error'));
         exit(json_encode($resp));
     }
     $photoService = PHOTO_BOL_PhotoService::getInstance();
     $tagService = BOL_TagService::getInstance();
     $photoAlbumService = PHOTO_BOL_PhotoAlbumService::getInstance();
     $photoTmpService = PHOTO_BOL_PhotoTemporaryService::getInstance();
     $userId = OW::getUser()->getId();
     // check album exists
     if (!($album = $photoAlbumService->findAlbumByName($albumName, $userId))) {
         $album = new PHOTO_BOL_PhotoAlbum();
         $album->name = $albumName;
         $album->userId = $userId;
         $album->createDatetime = time();
         $albumId = $photoAlbumService->addAlbum($album);
         $newAlbum = true;
     } else {
         $albumId = $album->id;
     }
     $data = str_replace("'", "\"", $_POST['json_data']);
     $data = json_decode($data);
     if (!empty($data->albums)) {
         $schedulerId = Ynmediaimporter::setupScheduler($data->photos, $data->albums, $albumId, array());
     } else {
         $schedulerId = Ynmediaimporter::setupScheduler($data->photos, null, $albumId, array());
     }
     $schedulerUrl = OW::getRouter()->urlForRoute('ynmediaimporter.scheduler', array('scheduler_id' => $schedulerId));
     $this->assign('callback_url', OW::getRouter()->urlForRoute("ynmediaimporter.index") . "/" . $data->provider);
     $this->assign('scheduler_id', $schedulerId);
     $this->assign('scheduler_url', $schedulerUrl);
 }