diff --git a/inc/classes/BxDolStorageQuery.php b/inc/classes/BxDolStorageQuery.php index 0f7e038a61..a8806764ed 100644 --- a/inc/classes/BxDolStorageQuery.php +++ b/inc/classes/BxDolStorageQuery.php @@ -309,6 +309,7 @@ public function getFiles($mixedProfileId, $isGhostsOnly = false, $iContentId = f $sWhere = ''; $sJoin = ''; + $sOrder = ''; if ($isGhostsOnly) { $aBindings['object'] = $this->_aObject['object']; @@ -333,6 +334,8 @@ public function getFiles($mixedProfileId, $isGhostsOnly = false, $iContentId = f } $sJoin .= ')'; + + $sOrder = ' ORDER BY `g`.`order` ASC'; } else { if (is_array($mixedProfileId) && $mixedProfileId) { @@ -345,7 +348,7 @@ public function getFiles($mixedProfileId, $isGhostsOnly = false, $iContentId = f } } - $sQuery = "SELECT `f`.* FROM " . $this->_sTableFiles . " AS `f` " . $sJoin . $sWhere . " ORDER BY `g`.`order` ASC"; + $sQuery = "SELECT `f`.* FROM " . $this->_sTableFiles . " AS `f` " . $sJoin . $sWhere . $sOrder; return $this->getAll($sQuery, $aBindings); } diff --git a/modules/base/text/classes/BxBaseModTextTemplate.php b/modules/base/text/classes/BxBaseModTextTemplate.php index 5e89a98e85..45c1497951 100644 --- a/modules/base/text/classes/BxBaseModTextTemplate.php +++ b/modules/base/text/classes/BxBaseModTextTemplate.php @@ -786,8 +786,7 @@ protected function _getHeaderImage($aData) function mediaExif ($aMediaInfo, $iProfileId = false, $sFuncAuthorDesc = '', $sTemplateName = 'media-exif.html') { - - if (!$aMediaInfo['exif']) + if (empty($aMediaInfo['exif'])) return ''; $a = unserialize($aMediaInfo['exif']); diff --git a/modules/boonex/albums/classes/BxAlbumsConfig.php b/modules/boonex/albums/classes/BxAlbumsConfig.php index f61834d33d..59774b9ed4 100644 --- a/modules/boonex/albums/classes/BxAlbumsConfig.php +++ b/modules/boonex/albums/classes/BxAlbumsConfig.php @@ -126,6 +126,7 @@ function __construct($aModule) 'OBJECT_FORM_ENTRY_DISPLAY_DELETE' => 'bx_albums_entry_delete', 'OBJECT_FORM_MEDIA' => 'bx_albums_media', 'OBJECT_FORM_MEDIA_DISPLAY_EDIT' => 'bx_albums_media_edit', + 'OBJECT_FORM_MEDIA_DISPLAY_MOVE' => 'bx_albums_media_move', 'OBJECT_MENU_ACTIONS_VIEW_ENTRY' => 'bx_albums_view', // actions menu on view entry page 'OBJECT_MENU_ACTIONS_VIEW_ENTRY_ALL' => 'bx_albums_view_actions', // all actions menu on view entry page 'OBJECT_MENU_ACTIONS_VIEW_MEDIA' => 'bx_albums_view_media', // actions menu on view media page diff --git a/modules/boonex/albums/classes/BxAlbumsFormMedia.php b/modules/boonex/albums/classes/BxAlbumsFormMedia.php new file mode 100644 index 0000000000..57a83f9cfa --- /dev/null +++ b/modules/boonex/albums/classes/BxAlbumsFormMedia.php @@ -0,0 +1,72 @@ +_sModule = 'bx_albums'; + $this->_oModule = BxDolModule::getInstance($this->_sModule); + + parent::__construct($aInfo, $oTemplate); + } + + public function initChecker($aValues = array (), $aSpecificValues = array()) + { + if(!empty($this->_aMediaInfo) && is_array($this->_aMediaInfo)) + $aValues = $this->_aMediaInfo; + + parent::initChecker($aValues, $aSpecificValues); + } + + public function initForm($aAction, $iMediaId) + { + $CNF = &$this->_oModule->_oConfig->CNF; + + $this->_iMediaId = $iMediaId; + $this->_aMediaInfo = $this->_oModule->_oDb->getMediaInfoById($iMediaId); + + $this->aFormAttrs['action'] = BX_DOL_URL_ROOT . $this->_oModule->_oConfig->getBaseUri() . $aAction . '_media/' . $iMediaId; + + if(isset($this->aInputs['content_id'])) { + $aAlbums = $this->_oModule->_oDb->getEntriesBy(array('type' => 'author', 'author' => $this->_aMediaInfo['author'])); + foreach($aAlbums as $aAlbum) + $this->aInputs['content_id']['values'][] = ['key' => $aAlbum[$CNF['FIELD_ID']], 'value' => $aAlbum[$CNF['FIELD_TITLE']]]; + } + } + + public function update($val, $aValsToAdd = array(), &$aTrackTextFieldsChanges = null) + { + $CNF = &$this->_oModule->_oConfig->CNF; + + $sField = 'content_id'; + if(isset($this->aInputs[$sField])) { + $iContentId = $this->getCleanValue($sField); + + $oStorage = BxDolStorage::getObjectInstance($CNF['OBJECT_STORAGE']); + if(!$oStorage->updateGhostsContentId($this->_aMediaInfo['file_id'], $this->_aMediaInfo['author'], $iContentId)) + return false; + } + + return parent::update($val, $aValsToAdd, $aTrackTextFieldsChanges); + } +} + +/** @} */ diff --git a/modules/boonex/albums/classes/BxAlbumsMenuViewActionsMedia.php b/modules/boonex/albums/classes/BxAlbumsMenuViewActionsMedia.php index 1f52bff66b..3b7e08bc76 100644 --- a/modules/boonex/albums/classes/BxAlbumsMenuViewActionsMedia.php +++ b/modules/boonex/albums/classes/BxAlbumsMenuViewActionsMedia.php @@ -90,7 +90,16 @@ protected function _getMenuItemEditImage($aItem) )); } - protected function _getMenuItemDeleteImage($aItem) + protected function _getMenuItemDeleteImage($aItem) + { + $CNF = &$this->_oModule->_oConfig->CNF; + + return $this->_getMenuItemByNameActions($aItem, array( + 'object_menu' => $CNF['OBJECT_MENU_ACTIONS_VIEW_MEDIA'] + )); + } + + protected function _getMenuItemMoveImage($aItem) { $CNF = &$this->_oModule->_oConfig->CNF; diff --git a/modules/boonex/albums/classes/BxAlbumsModule.php b/modules/boonex/albums/classes/BxAlbumsModule.php index a88a39129d..15fe8db520 100644 --- a/modules/boonex/albums/classes/BxAlbumsModule.php +++ b/modules/boonex/albums/classes/BxAlbumsModule.php @@ -715,11 +715,10 @@ public function actionEditMedia($iMediaId) $CNF = &$this->_oConfig->CNF; $iMediaId = (int)$iMediaId; - $aMediaInfo = $this->_oDb->getMediaInfoById($iMediaId); $oForm = BxDolForm::getObjectInstance($CNF['OBJECT_FORM_MEDIA'], $CNF['OBJECT_FORM_MEDIA_DISPLAY_EDIT']); - $oForm->aFormAttrs['action'] = BX_DOL_URL_ROOT . $this->_oConfig->getBaseUri() . 'edit_media/' . $iMediaId; - $oForm->initChecker($aMediaInfo); + $oForm->initForm('edit', $iMediaId); + $oForm->initChecker(); if($oForm->isSubmittedAndValid()) { if($oForm->update($iMediaId) !== false) @@ -738,18 +737,44 @@ public function actionEditMedia($iMediaId) echoJson(array('popup' => array('html' => $sContent, 'options' => array('closeOnOuterClick' => false)))); } - - public function actionDeleteMedia($iMediaId) + public function actionDeleteMedia($iMediaId) { $CNF = &$this->_oConfig->CNF; - $aMediaInfo = $this->_oDb->getMediaInfoById($iMediaId); - $oUploader = BxDolUploader::getObjectInstance($CNF['OBJECT_UPLOADERS'][0], $CNF['OBJECT_STORAGE'], ''); + $aMediaInfo = $this->_oDb->getMediaInfoById($iMediaId); + $oUploader = BxDolUploader::getObjectInstance($CNF['OBJECT_UPLOADERS'][0], $CNF['OBJECT_STORAGE'], ''); $oUploader->deleteGhost($aMediaInfo['file_id'], bx_get_logged_profile_id()); echoJson(['redirect' => BX_DOL_URL_ROOT . BxDolPermalinks::getInstance()->permalink('page.php?i=' . $CNF['URI_VIEW_ENTRY'] . '&id=' . $aMediaInfo['content_id'])]); } + public function actionMoveMedia($iMediaId) + { + $CNF = &$this->_oConfig->CNF; + + $iMediaId = (int)$iMediaId; + + $oForm = BxDolForm::getObjectInstance($CNF['OBJECT_FORM_MEDIA'], $CNF['OBJECT_FORM_MEDIA_DISPLAY_MOVE']); + $oForm->initForm('move', $iMediaId); + $oForm->initChecker(); + + if($oForm->isSubmittedAndValid()) { + if($oForm->update($iMediaId) !== false) + $aRes = array('reload' => 1); + else + $aRes = array('msg' => _t('_bx_albums_txt_err_cannot_perform_action')); + + return echoJson($aRes); + } + + $sContent = BxTemplStudioFunctions::getInstance()->transBox('bx-albums-move-media-popup', $this->_oTemplate->parseHtmlByName('media-edit.html', array( + 'form_id' => $oForm->aFormAttrs['id'], + 'form' => $oForm->getCode(true) + ))); + + echoJson(array('popup' => array('html' => $sContent, 'options' => array('closeOnOuterClick' => false)))); + } + public function actionGetSiblingMedia($iMediaId, $mixedContext) { $aSiblings = false; diff --git a/modules/boonex/albums/install/langs/en.xml b/modules/boonex/albums/install/langs/en.xml index 6715e93bcc..9ff679a9c8 100644 --- a/modules/boonex/albums/install/langs/en.xml +++ b/modules/boonex/albums/install/langs/en.xml @@ -48,8 +48,11 @@ + + + @@ -197,8 +200,10 @@ - - + + + + diff --git a/modules/boonex/albums/install/sql/enable.sql b/modules/boonex/albums/install/sql/enable.sql index 6ff0d13c62..e5e9edd821 100644 --- a/modules/boonex/albums/install/sql/enable.sql +++ b/modules/boonex/albums/install/sql/enable.sql @@ -276,7 +276,8 @@ INSERT INTO `sys_menu_items`(`set_name`, `module`, `name`, `title_system`, `titl ('bx_albums_view_media', 'bx_albums', 'add-images-to-album', '_bx_albums_menu_item_title_system_add_images', '_bx_albums_menu_item_title_add_images', 'page.php?i=add-images&id={content_id}', '', '', 'plus', '', 2147483647, 1, 0, 10), ('bx_albums_view_media', 'bx_albums', 'edit-album', '_bx_albums_menu_item_title_system_edit_album', '_bx_albums_menu_item_title_edit_album', 'page.php?i=edit-album&id={content_id}', '', '', 'pencil-alt', '', 2147483647, 1, 0, 20), ('bx_albums_view_media', 'bx_albums', 'edit-image', '_bx_albums_menu_item_title_system_edit_image', '_bx_albums_menu_item_title_edit_image', 'javascript:void(0)', 'javascript:{js_object}.editMedia(this, {media_id});', '', 'pencil-alt', '', 2147483647, 1, 0, 30), -('bx_albums_view_media', 'bx_albums', 'delete-image', '_bx_albums_menu_item_title_system_delete_image', '_bx_albums_menu_item_title_delete_image', 'javascript:void(0)', 'javascript:{js_object}.deleteMedia(this, {media_id});', '', 'remove', '', 2147483647, 1, 0, 40); +('bx_albums_view_media', 'bx_albums', 'delete-image', '_bx_albums_menu_item_title_system_delete_image', '_bx_albums_menu_item_title_delete_image', 'javascript:void(0)', 'javascript:{js_object}.deleteMedia(this, {media_id});', '', 'remove', '', 2147483647, 1, 0, 40), +('bx_albums_view_media', 'bx_albums', 'move-image', '_bx_albums_menu_item_title_system_move_image', '_bx_albums_menu_item_title_move_image', 'javascript:void(0)', 'javascript:{js_object}.moveMedia(this, {media_id});', '', 'exchange-alt', '', 2147483647, 1, 0, 50); -- MENU: all actions menu for view media page @@ -291,6 +292,7 @@ INSERT INTO `sys_menu_items`(`set_name`, `module`, `name`, `title_system`, `titl ('bx_albums_view_actions_media', 'bx_albums', 'edit-album', '_bx_albums_menu_item_title_system_edit_album', '', '', '', '', '', '', '', 0, 2147483647, 0, 0, 20), ('bx_albums_view_actions_media', 'bx_albums', 'edit-image', '_bx_albums_menu_item_title_system_edit_image', '', '', '', '', '', '', '', 0, 2147483647, 1, 0, 30), ('bx_albums_view_actions_media', 'bx_albums', 'delete-image', '_bx_albums_menu_item_title_system_delete_image', '', '', '', '', '', '', '', 0, 2147483647, 1, 0, 40), +('bx_albums_view_actions_media', 'bx_albums', 'move-image', '_bx_albums_menu_item_title_system_move_image', '', '', '', '', '', '', '', 0, 2147483647, 1, 0, 50), ('bx_albums_view_actions_media', 'bx_albums', 'comment', '_sys_menu_item_title_system_va_comment', '', '', '', '', '', '', '', 0, 2147483647, 0, 0, 200), ('bx_albums_view_actions_media', 'bx_albums', 'view', '_sys_menu_item_title_system_va_view', '', '', '', '', '', '', '', 0, 2147483647, 1, 0, 210), ('bx_albums_view_actions_media', 'bx_albums', 'vote', '_sys_menu_item_title_system_va_vote', '', '', '', '', '', '', '', 0, 2147483647, 1, 0, 220), diff --git a/modules/boonex/albums/install/sql/install.sql b/modules/boonex/albums/install/sql/install.sql index 14a7582c90..7feaa04db2 100644 --- a/modules/boonex/albums/install/sql/install.sql +++ b/modules/boonex/albums/install/sql/install.sql @@ -443,13 +443,15 @@ INSERT INTO `sys_form_display_inputs` (`display_name`, `input_name`, `visible_fo ('bx_albums_entry_delete', 'title', 2147483647, 0, 0); INSERT INTO `sys_objects_form`(`object`, `module`, `title`, `action`, `form_attrs`, `table`, `key`, `uri`, `uri_title`, `submit_name`, `params`, `deletable`, `active`, `override_class_name`, `override_class_file`) VALUES -('bx_albums_media', 'bx_albums', '_bx_albums_form_media', '', 'a:1:{s:7:\"enctype\";s:19:\"multipart/form-data\";}', 'bx_albums_files2albums', 'id', '', '', 'do_submit', '', 0, 1, '', ''); +('bx_albums_media', 'bx_albums', '_bx_albums_form_media', '', 'a:1:{s:7:\"enctype\";s:19:\"multipart/form-data\";}', 'bx_albums_files2albums', 'id', '', '', 'do_submit', '', 0, 1, 'BxAlbumsFormMedia', 'modules/boonex/albums/classes/BxAlbumsFormMedia.php'); INSERT INTO `sys_form_displays`(`object`, `display_name`, `module`, `view_mode`, `title`) VALUES -('bx_albums_media', 'bx_albums_media_edit', 'bx_albums', 0, '_bx_albums_form_media_display_edit'); +('bx_albums_media', 'bx_albums_media_edit', 'bx_albums', 0, '_bx_albums_form_media_display_edit'), +('bx_albums_media', 'bx_albums_media_move', 'bx_albums', 0, '_bx_albums_form_media_display_move'); INSERT INTO `sys_form_inputs`(`object`, `module`, `name`, `value`, `values`, `checked`, `type`, `caption_system`, `caption`, `info`, `required`, `collapsed`, `html`, `attrs`, `attrs_tr`, `attrs_wrapper`, `checker_func`, `checker_params`, `checker_error`, `db_pass`, `db_params`, `editable`, `deletable`) VALUES ('bx_albums_media', 'bx_albums', 'title', '', '', 0, 'text', '_bx_albums_form_media_input_sys_title', '_bx_albums_form_media_input_title', '', 0, 0, 0, '', '', '', '', '', '', 'Xss', '', 1, 0), +('bx_albums_media', 'bx_albums', 'content_id', '', '', 0, 'select', '_bx_albums_form_media_input_sys_content_id', '_bx_albums_form_media_input_content_id', '', 0, 0, 0, '', '', '', '', '', '', 'Int', '', 1, 0), ('bx_albums_media', 'bx_albums', 'controls', '', 'do_submit,do_cancel', 0, 'input_set', '', '', '', 0, 0, 0, '', '', '', '', '', '', '', '', 0, 0), ('bx_albums_media', 'bx_albums', 'do_submit', '_bx_albums_form_media_input_do_submit', '', 0, 'submit', '_bx_albums_form_media_input_sys_do_submit', '', '', 0, 0, 0, '', '', '', '', '', '', '', '', 1, 0), ('bx_albums_media', 'bx_albums', 'do_cancel', '_bx_albums_form_media_input_do_cancel', '', 0, 'button', '_bx_albums_form_media_input_sys_do_cancel', '', '', 0, 0, 0, 'a:2:{s:7:"onclick";s:45:"$(''.bx-popup-applied:visible'').dolPopupHide()";s:5:"class";s:22:"bx-def-margin-sec-left";}', '', '', '', '', '', '', '', 0, 0); @@ -458,7 +460,12 @@ INSERT INTO `sys_form_display_inputs` (`display_name`, `input_name`, `visible_fo ('bx_albums_media_edit', 'title', 2147483647, 1, 1), ('bx_albums_media_edit', 'controls', 2147483647, 1, 2), ('bx_albums_media_edit', 'do_submit', 2147483647, 1, 3), -('bx_albums_media_edit', 'do_cancel', 2147483647, 1, 4); +('bx_albums_media_edit', 'do_cancel', 2147483647, 1, 4), + +('bx_albums_media_move', 'content_id', 2147483647, 1, 1), +('bx_albums_media_move', 'controls', 2147483647, 1, 2), +('bx_albums_media_move', 'do_submit', 2147483647, 1, 3), +('bx_albums_media_move', 'do_cancel', 2147483647, 1, 4); -- COMMENTS diff --git a/modules/boonex/albums/js/main.js b/modules/boonex/albums/js/main.js index 2f9179d26c..fb80a5acdd 100644 --- a/modules/boonex/albums/js/main.js +++ b/modules/boonex/albums/js/main.js @@ -54,31 +54,51 @@ BxAlbumsMain.prototype.editMedia = function(oButton, iId) { ); }; +BxAlbumsMain.prototype.onEditMedia = function(oData) { + if(oData && oData.content != undefined) + $('#' + this._oHtmlIds['subentry_votes'] + oData.content.subentry_id).html(oData.content.votes_formated); +}; + BxAlbumsMain.prototype.deleteMedia = function(oButton, iId) { var $this = this; - + bx_confirm(_t('_Are_you_sure'), function() { - var oDate = new Date(); - $this.loadingInButton(oButton, true); - - $.get( - $this._sActionsUrl + 'delete_media/' + iId, - { - _t: oDate.getTime() - }, - function(oData) { - $this.loadingInButton(oButton, false); - - processJsonData(oData); - }, - 'json' - ); - }); + var oDate = new Date(); + $this.loadingInButton(oButton, true); + + $.get( + $this._sActionsUrl + 'delete_media/' + iId, + { + _t: oDate.getTime() + }, + function(oData) { + $this.loadingInButton(oButton, false); + + processJsonData(oData); + }, + 'json' + ); + }); }; -BxAlbumsMain.prototype.onEditMedia = function(oData) { - if(oData && oData.content != undefined) - $('#' + this._oHtmlIds['subentry_votes'] + oData.content.subentry_id).html(oData.content.votes_formated); +BxAlbumsMain.prototype.moveMedia = function(oButton, iId) { + var $this = this; + var oDate = new Date(); + + this.loadingInButton(oButton, true); + + $.get( + this._sActionsUrl + 'move_media/' + iId, + { + _t: oDate.getTime() + }, + function(oData) { + $this.loadingInButton(oButton, false); + + processJsonData(oData); + }, + 'json' + ); }; BxAlbumsMain.prototype.loadingInButton = function(e, bShow) { diff --git a/modules/boonex/russian/data/langs/bx_albums/ru.xml b/modules/boonex/russian/data/langs/bx_albums/ru.xml index 1b4911c599..cb0b3dd005 100644 --- a/modules/boonex/russian/data/langs/bx_albums/ru.xml +++ b/modules/boonex/russian/data/langs/bx_albums/ru.xml @@ -48,8 +48,11 @@ + + + @@ -196,7 +199,9 @@ - + + +