1
0
Fork 0
mirror of https://github.com/Oreolek/ifhub.club.git synced 2024-06-26 03:30:48 +03:00

Доработка дополнительных полей + update fw

This commit is contained in:
Mzhelskiy Maxim 2014-01-08 18:15:46 +07:00
parent 12d18f1b69
commit 4b1eba1656
6 changed files with 60 additions and 13 deletions

View file

@ -89,6 +89,8 @@ class ActionAjax extends Action {
$this->AddEventPreg('/^media$/i','/^load-gallery$/','/^$/','EventMediaLoadGallery');
$this->AddEventPreg('/^media$/i','/^remove-file$/','/^$/','EventMediaRemoveFile');
$this->AddEventPreg('/^media$/i','/^save-data-file$/','/^$/','EventMediaSaveDataFile');
$this->AddEventPreg('/^property$/i','/^tags$/','/^autocompleter$/','/^$/','EventPropertyTagsAutocompleter');
}
@ -98,6 +100,27 @@ class ActionAjax extends Action {
*/
protected function EventPropertyTagsAutocompleter() {
/**
* Первые буквы тега переданы?
*/
if (!($sValue=getRequest('value',null,'post')) or !is_string($sValue)) {
return ;
}
$aItems=array();
/**
* Формируем список тегов
*/
$aTags=$this->Property_GetPropertyTagsByLike($sValue,getRequestStr('property_id'),10);
foreach ($aTags as $oTag) {
$aItems[]=$oTag->getText();
}
/**
* Передаем результат в ajax ответ
*/
$this->Viewer_AssignAjax('aItems',$aItems);
}
protected function EventMediaUploadLink() {
/**
* Пользователь авторизован?

View file

@ -149,13 +149,13 @@ class ModuleProperty extends ModuleORM {
* Сохраняет текущие значения свойств
*
* @param array $aProperties
* @param Entity $oTarget
* @param Entity|int $oTarget Объект сущности или ID сущности
*/
public function UpdatePropertiesValue($aProperties,$oTarget) {
if ($aProperties) {
foreach($aProperties as $oProperty) {
$oValue=$oProperty->getValue();
$oValue->setTargetId($oTarget->getId());
$oValue->setTargetId(is_object($oTarget) ? $oTarget->getId() : $oTarget);
$oValue->setPropertyType($oProperty->getType());
$oValue->Save();
}

View file

@ -150,6 +150,14 @@ class ModuleProperty_EntityProperty extends EntityORM {
public function getUrlAdminUpdate() {
return Router::GetPath('admin/properties/'.$this->getTargetType().'/update/'.$this->getId());
}
/**
* Возвращает URL админки для редактирования поля
*
* @return string
*/
public function getUrlAdminRemove() {
return Router::GetPath('admin/properties/'.$this->getTargetType().'/remove/'.$this->getId());
}
/**
* Возвращает описание типа поля
*

View file

@ -22,7 +22,9 @@
class ModuleProperty_EntityValueTypeSelect extends ModuleProperty_EntityValueType {
public function getValueForDisplay() {
return $this->getValueObject()->getValueText();
$oValue=$this->getValueObject();
$aValues=$oValue->getDataOne('values');
return join(', ',$aValues);
}
public function getValueForForm() {
@ -83,14 +85,16 @@ class ModuleProperty_EntityValueTypeSelect extends ModuleProperty_EntityValueTyp
/**
* Сохраняем с data, т.к. может быть множественный выбор
*/
if (is_array($mValue)) {
$aSelectItems=$this->Property_GetSelectItemsByFilter(array('property_id'=>$oProperty->getId(),'id in'=>$mValue));
foreach($aSelectItems as $oSelect) {
$aValues[$oSelect->getId()]=$oSelect->getValue();
}
} else {
if ($oSelect=$this->Property_GetSelectByIdAndPropertyId($mValue,$oProperty->getId())) {
$aValues[$oSelect->getId()]=$oSelect->getValue();
if ($mValue) {
if (is_array($mValue)) {
$aSelectItems=$this->Property_GetSelectItemsByFilter(array('property_id'=>$oProperty->getId(),'id in'=>$mValue));
foreach($aSelectItems as $oSelect) {
$aValues[$oSelect->getId()]=$oSelect->getValue();
}
} else {
if ($oSelect=$this->Property_GetSelectByIdAndPropertyId($mValue,$oProperty->getId())) {
$aValues[$oSelect->getId()]=$oSelect->getValue();
}
}
}
$oValue->setData($aValues ? array('values'=>$aValues) : array());
@ -126,4 +130,16 @@ class ModuleProperty_EntityValueTypeSelect extends ModuleProperty_EntityValueTyp
}
return $aRules;
}
public function removeValue() {
$oValue=$this->getValueObject();
/**
* Удаляем значения select'а из дополнительной таблицы
*/
if ($aSelects=$this->Property_GetValueSelectItemsByFilter(array('property_id'=>$oValue->getPropertyId(),'target_id'=>$oValue->getTargetId()))) {
foreach($aSelects as $oSelect) {
$oSelect->Delete();
}
}
}
}

View file

@ -22,7 +22,7 @@
class ModuleProperty_EntityValueTypeTags extends ModuleProperty_EntityValueType {
public function getValueForDisplay() {
return $this->getValueObject()->getValueVarchar();
return htmlspecialchars($this->getValueObject()->getValueVarchar());
}
public function validate() {

@ -1 +1 @@
Subproject commit 8dfab0e33655a07d05df67ea00af09a6ced6d56c
Subproject commit 143860c7eba5a047551a92203d1a12e270c81c27