public function __construct($albumId) { parent::__construct(self::FORM_NAME); $album = PHOTO_BOL_PhotoAlbumService::getInstance()->findAlbumById($albumId); $this->setAction(OW::getRouter()->urlForRoute('photo.ajax_update_photo')); $this->setAjax(true); $this->setAjaxResetOnSuccess(false); $albumIdField = new HiddenField(self::ELEMENT_ALBUM_ID); $albumIdField->setValue($album->id); $albumIdField->setRequired(); $albumIdField->addValidator(new PHOTO_CLASS_AlbumOwnerValidator()); $this->addElement($albumIdField); $albumNameField = new TextField(self::ELEMENT_ALBUM_NAME); $albumNameField->setValue($album->name); $albumNameField->setRequired(); if ($album->name != trim(OW::getLanguage()->text('photo', 'newsfeed_album'))) { $albumNameField->addValidator(new PHOTO_CLASS_AlbumNameValidator(true, null, $album->name)); } $albumNameField->addAttribute('class', 'ow_photo_album_name_input'); $this->addElement($albumNameField); $desc = new Textarea(self::ELEMENT_DESC); $desc->setValue(!empty($album->description) ? $album->description : NULL); $desc->setHasInvitation(TRUE); $desc->setInvitation(OW::getLanguage()->text('photo', 'describe_photo')); $desc->addAttribute('class', 'ow_photo_album_description_textarea'); $this->addElement($desc); $this->triggerReady(array('albumId' => $albumId)); }
public function __construct($entityType, $entityId, $albumId = null, $albumName = null, $albumDescription = null, $url = null, $data = null) { parent::__construct(self::FORM_NAME); $this->setAjax(true); $this->setAjaxResetOnSuccess(false); $this->setAction(OW::getRouter()->urlForRoute('photo.ajax_upload_submit')); $this->bindJsFunction(self::BIND_SUCCESS, UTIL_JsGenerator::composeJsString('function( data ) { if ( data ) { if ( !data.result ) { if ( data.msg ) { OW.error(data.msg); } else { OW.getLanguageText("photo", "photo_upload_error"); } } else { var url = {$url}; if ( url ) { window.location.href = url; } else if ( data.url ) { window.location.href = data.url; } } } else { OW.error("Server error"); } }', array('url' => $url))); $language = OW::getLanguage(); $albumField = new TextField(self::ELEMENT_ALBUM); $albumField->setRequired(); $albumField->addAttribute(FormElement::ATTR_CLASS, 'ow_dropdown_btn ow_inputready ow_cursor_pointer'); $albumField->addAttribute('autocomplete', 'off'); $albumField->addAttribute(FormElement::ATTR_READONLY); $albumNameField = new TextField(self::ELEMENT_ALBUM_NAME); $albumNameField->setRequired(); $albumNameField->addValidator(new PHOTO_CLASS_AlbumNameValidator(false)); $albumNameField->addAttribute('placeholder', $language->text('photo', 'album_name')); $this->addElement($albumNameField); $desc = new Textarea(self::ELEMENT_DESCRIPTION); $desc->addAttribute('placeholder', $language->text('photo', 'album_desc')); $desc->setValue(!empty($albumDescription) ? $albumDescription : null); $this->addElement($desc); $userId = OW::getUser()->getId(); $albumService = PHOTO_BOL_PhotoAlbumService::getInstance(); if (!empty($albumId) && ($album = $albumService->findAlbumById($albumId)) !== null && $album->userId == $userId && !$albumService->isNewsfeedAlbum($album)) { $albumField->setValue($album->name); $albumNameField->setValue($album->name); } elseif (!empty($albumName)) { $albumField->setValue($albumName); $albumNameField->setValue($albumName); } else { $event = OW::getEventManager()->trigger(new BASE_CLASS_EventCollector(PHOTO_CLASS_EventHandler::EVENT_SUGGEST_DEFAULT_ALBUM, array('userId' => $userId, 'entityType' => $entityType, 'entityId' => $entityId))); $eventData = $event->getData(); if (!empty($eventData)) { $value = array_shift($eventData); $albumField->setValue($value); $albumNameField->setValue($value); } else { $albumField->setValue($language->text('photo', 'choose_existing_or_create')); } } $this->addElement($albumField); $submit = new Submit('submit'); $submit->addAttribute('class', 'ow_ic_submit ow_positive'); $this->addElement($submit); $this->triggerReady(array('entityType' => $entityType, 'entityId' => $entityId, 'albumId' => $albumId, 'albumName' => $albumName, 'albumDescription' => $albumDescription, 'url' => $url, 'data' => $data)); }
public function __construct() { parent::__construct(self::FORM_NAME); $language = OW::getLanguage(); $this->setAjax(); $this->setAjaxResetOnSuccess(false); $this->setAction(OW::getRouter()->urlFor('PHOTO_CTRL_AjaxUpload', 'checkFakeAlbumData')); $this->bindJsFunction(self::BIND_SUCCESS, UTIL_JsGenerator::composeJsString('function( data ) { if ( !data.result ) { var form = owForms[this.name]; Object.keys(data.errors).forEach(function( item ) { var arr = data.errors[item]; if ( arr.length !== 0 ) { form.getElement(item).showError(arr.shift()); } }); return; } if ( OW.getActiveFloatBox() ) OW.getActiveFloatBox().close(); var formData = data.data; var params = { albumId: 0, albumName: formData[{$album_name}], albumDescription: formData[{$album_desc}], url: "", data: formData }; var ajaxUploadPhotoFB = OW.ajaxFloatBox("PHOTO_CMP_AjaxUpload", params, { title: {$title}, width: "746px", onLoad: function() { OW.trigger("photo.ready_fake_album", [formData]); } }); ajaxUploadPhotoFB.bind("close", function() { if ( ajaxPhotoUploader.isHasData() ) { if ( confirm({$confirm}) ) { OW.trigger("photo.onCloseUploaderFloatBox"); return true; } return false; } else { OW.trigger("photo.onCloseUploaderFloatBox"); } }); }', array('album_name' => self::ELEMENT_ALBUM_NAME, 'album_desc' => self::ELEMENT_ALBUM_DESC, 'title' => $language->text('photo', 'upload_photos'), 'confirm' => $language->text('photo', 'close_alert')))); $albumNameInput = new TextField(self::ELEMENT_ALBUM_NAME); $albumNameInput->setRequired(); $albumNameInput->addValidator(new PHOTO_CLASS_AlbumNameValidator(false)); $albumNameInput->setHasInvitation(true); $albumNameInput->setInvitation($language->text('photo', 'album_name')); $this->addElement($albumNameInput); $albumDescInput = new Textarea(self::ELEMENT_ALBUM_DESC); $albumDescInput->setHasInvitation(true); $albumDescInput->setInvitation($language->text('photo', 'album_desc')); $this->addElement($albumDescInput); $submit = new Submit(self::SUBMIT_SUBMIT); $submit->setValue($language->text('photo', 'add_photos')); $this->addElement($submit); $this->triggerReady(); }