1
0
Fork 0
mirror of https://github.com/Oreolek/ifhub.club.git synced 2024-06-16 23:00:51 +03:00

Доработка фотосета + обновление fw

This commit is contained in:
Mzhelskiy Maxim 2014-01-05 20:28:53 +07:00
parent 8ebd7b1ea0
commit 39abe2b2c1
9 changed files with 135 additions and 32 deletions

View file

@ -196,37 +196,26 @@ class ActionAjax extends Action {
}
protected function EventMediaSubmitCreatePhotoset() {
$aIds=array(0);
foreach((array)getRequest('ids') as $iId) {
$aIds[]=(int)$iId;
}
$iUserId=$this->oUserCurrent ? $this->oUserCurrent->getId() : null;
$aMediaItems=$this->Media_GetMediaItemsByFilter(array(
'#where'=>array('id in (?a) AND ( user_id is null OR user_id = ?d )'=>array($aIds,$iUserId))
)
);
$aMediaItems=$this->Media_GetAllowMediaItemsById(getRequest('ids'));
if (!$aMediaItems) {
$this->Message_AddError('Необходимо выбрать элементы');
return false;
}
$aParams=array(
'size'=>'100crop',
);
$sProperties='';
if (getRequest('use_thumbs')) {
$sProperties.=' data-nav="thumbs" ';
}
$sTextResult='<div class="fotorama" '.$sProperties.'>'."\r\n";
$aItems=array();
foreach($aMediaItems as $oMedia) {
if (getRequest('show_caption')) {
$aParams['data']['caption']=$oMedia->getDataOne('title');
}
$sTextResult.="\t".$this->Media_BuildCodeForEditor($oMedia,$aParams)."\r\n";
$aItems[]=$oMedia->getId();
}
$sTextResult.="</div>\r\n";
$sTextResult='<gallery items="'.join(',',$aItems).'"';
if (getRequest('use_thumbs')) {
$sTextResult.=' nav="thumbs" ';
}
if (getRequest('show_caption')) {
$sTextResult.=' caption="1" ';
}
$sTextResult.=' />';
$this->Viewer_AssignAjax('sTextResult',$sTextResult);
}

View file

@ -446,8 +446,9 @@ class ActionTopic extends Action {
list($sTextShort,$sTextNew,$sTextCut) = $this->Text_Cut($oTopic->getTextSource());
$oTopic->setCutText($sTextCut);
$oTopic->setText($this->Text_Parser($sTextNew));
$oTopic->setTextShort($this->Text_Parser($sTextShort));
// TODO: передача параметров в Topic_Parser пока не используется - нужно заменить на этот вызов все места с парсингом топика
$oTopic->setText($this->Topic_Parser($sTextNew,$oTopic));
$oTopic->setTextShort($this->Topic_Parser($sTextShort,$oTopic));
/**
* Публикуем или сохраняем в черновиках
*/

View file

@ -318,7 +318,7 @@ class ModuleMedia extends ModuleORM {
$sPath=$oMedia->getFileWebPath($sSize=='original' ? null : $sSize);
$sCode='<img src="'.$sPath.'" ';
if ($oMedia->getDataOne('title')) {
if (!isset($aParams['skip_title']) and $oMedia->getDataOne('title')) {
$sCode.=' title="'.htmlspecialchars($oMedia->getDataOne('title')).'" ';
$sCode.=' alt="'.htmlspecialchars($oMedia->getDataOne('title')).'" ';
}
@ -329,16 +329,19 @@ class ModuleMedia extends ModuleORM {
$sCode.=' align="'.htmlspecialchars($aParams['align']).'" ';
}
}
$sDataParams='';
if (isset($aParams['data']) and is_array($aParams['data'])) {
foreach($aParams['data'] as $sDataName=>$sDataValue) {
if ($sDataValue) {
$sCode.=' data-'.$sDataName.'="'.htmlspecialchars($sDataValue).'"';
$sDataParams.=' data-'.$sDataName.'="'.htmlspecialchars($sDataValue).'"';
}
}
}
$sCode.=' />';
if ($bNeedHref) {
$sCode='<a href="'.$oMedia->getFileWebPath().'">'.$sCode.'</a>';
$sCode.=' />';
$sCode='<a href="'.$oMedia->getFileWebPath().'" '.$sDataParams.'>'.$sCode.'</a>';
} else {
$sCode.=$sDataParams.' />';
}
}
@ -401,4 +404,65 @@ class ModuleMedia extends ModuleORM {
return $oMedia->Delete();
}
/**
* Возвращает список media с учетов прав доступа текущего пользователя
*
* @param array $aId
*
* @return array
*/
public function GetAllowMediaItemsById($aId) {
$aIdItems=array();
foreach((array)$aId as $iId) {
$aIdItems[]=(int)$iId;
}
if (is_array($aIdItems) and count($aIdItems)) {
$iUserId=$this->oUserCurrent ? $this->oUserCurrent->getId() : null;
return $this->Media_GetMediaItemsByFilter(array(
'#where'=>array('id in (?a) AND ( user_id is null OR user_id = ?d )'=>array($aIdItems,$iUserId))
)
);
}
return array();
}
/**
* Обработка тега gallery в тексте
* <pre>
* <gallery items="12,55,38" />
* </pre>
*
* @param string $sTag Тег на ктором сработал колбэк
* @param array $aParams Список параметров тега
* @return string
*/
public function CallbackParserTagGallery($sTag,$aParams) {
if (isset($aParams['items'])) {
$aItems=explode(',',$aParams['items']);
}
if (!(isset($aItems) and $aMediaItems=$this->Media_GetAllowMediaItemsById($aItems))) {
return '';
}
$aParamsMedia=array(
'size'=>'100crop',
'skip_title'=>true
);
$sProperties='';
if (isset($aParams['nav']) and in_array($aParams['nav'],array('thumbs'))) {
$sProperties.=' data-nav="'.$aParams['nav'].'" ';
}
$sTextResult='<div class="fotorama" '.$sProperties.'>'."\r\n";
foreach($aMediaItems as $oMedia) {
if (isset($aParams['caption']) and $aParams['caption']) {
$aParamsMedia['data']['caption']=htmlspecialchars($oMedia->getDataOne('title'));
}
$sTextResult.="\t".$this->Media_BuildCodeForEditor($oMedia,$aParamsMedia)."\r\n";
}
$sTextResult.="</div>\r\n";
return $sTextResult;
}
}

View file

@ -1857,5 +1857,19 @@ class ModuleTopic extends Module {
public function GetTopicItemsByArrayId($aTopocId) {
return $this->GetTopicsByArrayId($aTopocId);
}
/**
* Парсинг текста с учетом конкретного топика
*
* @param string $sText
* @param ModuleTopic_EntityTopic $oTopic
*
* @return string
*/
public function Parser($sText,$oTopic) {
$this->Text_AddParams(array('oTopic'=>$oTopic));
$sResult=$this->Text_Parser($sText);
$this->Text_RemoveParams(array('oTopic'));
return $sResult;
}
}
?>

View file

@ -478,6 +478,7 @@ $config['head']['default']['js'] = array(
"___path.framework.frontend.web___/js/vendor/parsley/parsley.js",
"___path.framework.frontend.web___/js/vendor/parsley/i18n/messages.ru.js",
"___path.framework.frontend.web___/js/vendor/jquery.livequery.js",
"___path.framework.frontend.web___/js/vendor/fotorama/fotorama.js",
/* Core */
"___path.framework.frontend.web___/js/core/main.js",

View file

@ -2,11 +2,39 @@
return array(
'default' => array(
// Разрешённые теги
'cfgAllowTags' => array(
// вызов метода с параметрами
array(
array('ls','gallery'),
),
),
// Коротие теги типа
'cfgSetTagShort' => array(
array(
array('ls','gallery')
),
),
// Разрешённые параметры тегов
'cfgAllowTagParams' => array(
array(
'ls',
array('user'=>'#text')
),
array(
'gallery',
array('items'=>'#text','nav'=>array('thumbs'),'caption'=>array('0','1'))
),
),
'cfgSetTagCallbackFull' => array(
array(
'ls',
array('_this_','Tools_CallbackParserTagLs'),
),
),
array(
'gallery',
array('_this_','Media_CallbackParserTagGallery'),
),
)
),
);

View file

@ -141,6 +141,11 @@ ls.media = (function ($) {
this.saveDataFile($(e.currentTarget).attr('name'),$(e.currentTarget).val());
}.bind(this));
// инициализация фоторамы при предпросмотре
ls.hook.add('ls_topic_preview_after',function(){
$('.fotorama').fotorama();
});
this.loadImageList();
this.bindFileEvents();
};

View file

@ -33,6 +33,7 @@ $config['head']['default']['css'] = array_merge(Config::Get('head.default.css'),
"___path.framework.frontend.web___/js/vendor/prettify/prettify.css",
"___path.framework.frontend.web___/js/vendor/prettyphoto/css/prettyphoto.css",
"___path.framework.frontend.web___/js/vendor/notifier/jquery.notifier.css",
"___path.framework.frontend.web___/js/vendor/fotorama/fotorama.css",
"___path.skin.assets.web___/css/grid.css",
"___path.skin.assets.web___/css/forms.css",
"___path.skin.assets.web___/css/common.css",

@ -1 +1 @@
Subproject commit 75b3ca99739d899b78071850ab75d3855fd87c67
Subproject commit 8dfab0e33655a07d05df67ea00af09a6ced6d56c