Index: branches/unlabeled/unlabeled-1.27.2/core/units/admin/admin_tag_processor.php =================================================================== diff -u -r6889 -r6899 --- branches/unlabeled/unlabeled-1.27.2/core/units/admin/admin_tag_processor.php (.../admin_tag_processor.php) (revision 6889) +++ branches/unlabeled/unlabeled-1.27.2/core/units/admin/admin_tag_processor.php (.../admin_tag_processor.php) (revision 6899) @@ -537,9 +537,59 @@ */ function SetPopupSize($params) { - + $width = $params['width']; + $height = $params['height']; + + if ($this->Application->GetVar('ajax') == 'yes') { + // during AJAX request just output size + die($width.'x'.$height); + } + + $t = $this->Application->GetVar('t'); + $sql = 'SELECT * + FROM '.TABLE_PREFIX.'PopupSizes + WHERE TemplateName = '.$this->Conn->qstr($t); + $popup_info = $this->Conn->GetRow($sql); + if (!$popup_info) { + // create new popup size record + $fields_hash = Array ( + 'TemplateName' => $t, + 'PopupWidth' => $width, + 'PopupHeight' => $height, + ); + $this->Conn->doInsert($fields_hash, TABLE_PREFIX.'PopupSizes'); + } + elseif ($popup_info['PopupWidth'] != $width || $popup_info['PopupHeight'] != $height) { + // popup found and size in tag differs from one in db -> update in db + $fields_hash = Array ( + 'PopupWidth' => $width, + 'PopupHeight' => $height, + ); + $this->Conn->doUpdate($fields_hash, TABLE_PREFIX.'PopupSizes', 'PopupId = '.$popup_info['PopupId']); + } } + /** + * Returns popup size (by template), if not cached, then parse template to get value + * + * @param Array $params + * @return string + */ + function GetPopupSize($params) + { + $t = $this->Application->GetVar('template_name'); + $sql = 'SELECT * + FROM '.TABLE_PREFIX.'PopupSizes + WHERE TemplateName = '.$this->Conn->qstr($t); + $popup_info = $this->Conn->GetRow($sql); + if (!$popup_info) { + $this->Application->InitParser(); + $this->Application->Parser->ParseTemplate($t); // dies when SetPopupSize tag found & in ajax requrest + return '750x400'; // tag SetPopupSize not found in template -> use default size + } + return $popup_info['PopupWidth'].'x'.$popup_info['PopupHeight']; + } + function UsePopups($params) { return true;