Attached Files |
inbpatch1.patch [^] (9,316 bytes) 2011-07-06 02:58
[Show Content]
Index: units/private_messages/private_message_eh.php
===================================================================
--- units/private_messages/private_message_eh.php (revision 12148)
+++ units/private_messages/private_message_eh.php (revision 12149)
@@ -21,6 +21,7 @@
'OnItemBuild' => Array('self' => true),
'OnCreate' => Array('self' => true),
'OnDelete' => Array('self' => true),
+ 'OnPreview' => Array('self' => true),
);
$this->permMapping = array_merge($this->permMapping, $permissions);
@@ -244,6 +245,31 @@
$object->SetDBField('ToId', $user_id);
}
}
+
+ /**
+ * Allows to preview message, before submitting
+ *
+ * @param kEvent $event
+ */
+ function OnPreview(&$event)
+ {
+ $object =& $event->getObject( Array('skip_autoload' => true) );
+
+ $post_helper =& $this->Application->recallObject('PostHelper');
+ /* @var $post_helper PostHelper */
+
+ $items_info = $this->Application->GetVar( $event->getPrefixSpecial(true) );
+ if ($items_info) {
+ foreach ($items_info as $id => $field_values) {
+ $object->Load($id);
+ $object->SetFieldsFromHash($field_values);
+ $post_helper->calculatePostOptions($object);
+ $object->setID($id);
+ }
+ }
+
+ $event->redirect = false;
+ }
}
?>
\ No newline at end of file
Index: units/topics/topics_tag_processor.php
===================================================================
--- units/topics/topics_tag_processor.php (revision 12148)
+++ units/topics/topics_tag_processor.php (revision 12149)
@@ -74,6 +74,26 @@
return $this->Application->ProcessParsedTag('m', 'Link', $params);
}
+
+ function PostBody($params)
+ {
+ $object =& $this->getObject($params);
+
+ $post_helper =& $this->Application->recallObject('PostHelper');
+ /* @var $post_helper PostHelper */
+
+ $body = $object->GetDBField('PostingText');
+
+ // 2. parse post body
+ $sub_blocks = Array (
+ 'smileys' => $params['smiley_render_as'],
+ 'bbcode' => $params['bbcode_render_as'],
+ 'quote' => $params['quote_render_as'],
+ );
+ $body = $post_helper->parsePostBody($body, $object->GetDBField('Options'), $sub_blocks);
+
+ return $body;
+ }
}
?>
\ No newline at end of file
Index: units/topics/topics_event_handler.php
===================================================================
--- units/topics/topics_event_handler.php (revision 12148)
+++ units/topics/topics_event_handler.php (revision 12149)
@@ -14,7 +14,21 @@
class TopicsEventHandler extends kCatDBEventHandler {
+ /**
+ * Allows to override standart permission mapping
+ *
+ */
+ function mapPermissions()
+ {
+ parent::mapPermissions();
+ $permissions = Array (
+ 'OnPreview' => Array ('self' => true),
+ );
+
+ $this->permMapping = array_merge($this->permMapping, $permissions);
+ }
+
/**
* Checks topic lock permission
*
@@ -164,6 +178,7 @@
if ($item_id !== false) {
$this->Application->SetVar($event->getPrefixSpecial().'_id', $item_id);
$vars[$event->getPrefixSpecial().'_id'] = $item_id;
+ array_pop($url_parts);
}
elseif ($url_part !== 'index') {
// otherwise category/index.html is parsed as /index.tpl
@@ -318,6 +333,31 @@
}
/**
+ * Allows to preview message, before submitting
+ *
+ * @param kEvent $event
+ */
+ function OnPreview(&$event)
+ {
+ $object =& $event->getObject( Array('skip_autoload' => true) );
+
+ $post_helper =& $this->Application->recallObject('PostHelper');
+ /* @var $post_helper PostHelper */
+
+ $items_info = $this->Application->GetVar( $event->getPrefixSpecial(true) );
+ if ($items_info) {
+ foreach ($items_info as $id => $field_values) {
+ $object->Load($id);
+ $object->SetFieldsFromHash($field_values);
+ $post_helper->calculatePostOptions($object);
+ $object->setID($id);
+ }
+ }
+
+ $event->redirect = false;
+ }
+
+ /**
* Sets default values to posting options based on persistent session
*
* @param kEvent $event
Index: units/helpers/post_helper.php
===================================================================
--- units/helpers/post_helper.php (revision 12148)
+++ units/helpers/post_helper.php (revision 12149)
@@ -79,6 +79,22 @@
}
/**
+ * Sets post options field
+ *
+ * @param kDBItem $object
+ */
+ function calculatePostOptions(&$object)
+ {
+ $options_map = $this->getOptionsMap();
+ $post_options = $object->GetDBField('Options');
+ foreach ($options_map as $option_name => $field_name) {
+ $option_value = $object->GetDBField($field_name);
+ $this->SetPostOption($option_name, $option_value, $post_options);
+ }
+ $object->SetDBField('Options', $post_options);
+ }
+
+ /**
* @return void
* @param int $date
* @desc Set any field to category & all it's parent categories
Index: units/posts/post_eh.php
===================================================================
--- units/posts/post_eh.php (revision 12148)
+++ units/posts/post_eh.php (revision 12149)
@@ -21,7 +21,7 @@
*/
function CheckPermission(&$event)
{
- $events = Array('OnUpdate', 'OnDelete');
+ $events = Array('OnUpdate', 'OnDelete', 'OnPreview');
if (in_array($event->Name, $events)) {
return true;
}
@@ -58,17 +58,10 @@
WHERE PortalUserId = '.$user_id;
$object->SetDBField('PosterAlias', $this->Conn->GetOne($sql));
- // set post options
$post_helper =& $this->Application->recallObject('PostHelper');
/* @var $post_helper PostHelper */
- $options_map = $post_helper->getOptionsMap();
- $post_options = $object->GetDBField('Options');
- foreach ($options_map as $option_name => $field_name) {
- $option_value = $object->GetDBField($field_name);
- $post_helper->SetPostOption($option_name, $option_value, $post_options);
- }
- $object->SetDBField('Options', $post_options);
+ $post_helper->calculatePostOptions($object);
$table_info = $object->getLinkedInfo($event->Special, true);
$object->SetDBField($table_info['ForeignKey'], $table_info['ParentId']);
@@ -121,13 +114,7 @@
$post_helper =& $this->Application->recallObject('PostHelper');
/* @var $post_helper PostHelper */
- $options_map = $post_helper->getOptionsMap();
- $post_options = $object->GetDBField('Options');
- foreach ($options_map as $option_name => $field_name) {
- $option_value = $object->GetDBField($field_name);
- $post_helper->SetPostOption($option_name, $option_value, $post_options);
- }
- $object->SetDBField('Options', $post_options);
+ $post_helper->calculatePostOptions($object);
}
/**
@@ -280,6 +267,31 @@
}
/**
+ * Allows to preview message, before submitting
+ *
+ * @param kEvent $event
+ */
+ function OnPreview(&$event)
+ {
+ $object =& $event->getObject( Array('skip_autoload' => true) );
+
+ $post_helper =& $this->Application->recallObject('PostHelper');
+ /* @var $post_helper PostHelper */
+
+ $items_info = $this->Application->GetVar( $event->getPrefixSpecial(true) );
+ if ($items_info) {
+ foreach ($items_info as $id => $field_values) {
+ $object->Load($id);
+ $object->SetFieldsFromHash($field_values);
+ $post_helper->calculatePostOptions($object);
+ $object->setID($id);
+ }
+ }
+
+ $event->redirect = false;
+ }
+
+ /**
* Moves reference to last post in topic, when it is deleted
*
* @param kEvent $event
Index: install/english.lang
===================================================================
--- install/english.lang (revision 12148)
+++ install/english.lang (revision 12149)
@@ -106,6 +106,7 @@
<PHRASE Label="lu_btn_ModifyPost" Module="In-Bulletin" Type="0">TW9kaWZ5IFBvc3Q=</PHRASE>
<PHRASE Label="lu_btn_NewPrivateMessage" Module="In-Bulletin" Type="0">TmV3IFByaXZhdGUgTWVzc2FnZQ==</PHRASE>
<PHRASE Label="lu_btn_newtopic" Module="In-Bulletin" Type="0">TmV3IHRvcGlj</PHRASE>
+ <PHRASE Label="lu_btn_Preview" Module="In-Bulletin" Type="0">UHJldmlldw==</PHRASE>
<PHRASE Label="lu_btn_RateThisTopic" Module="In-Bulletin" Type="0">UmF0ZSBUb3BpYw==</PHRASE>
<PHRASE Label="lu_btn_Reply" Module="In-Bulletin" Type="0">UmVwbHk=</PHRASE>
<PHRASE Label="lu_btn_ReplyQuoted" Module="In-Bulletin" Type="0">UmVwbHkgUXVvdGVk</PHRASE>
@@ -155,6 +156,7 @@
<PHRASE Label="lu_forum_locked_for_posting" Module="In-Bulletin" Type="0">Rm9ydW0gaXMgbG9ja2VkIGZvciBwb3N0aW5n</PHRASE>
<PHRASE Label="lu_LockedTopic" Module="In-Bulletin" Type="0">TG9ja2VkIFRvcGlj</PHRASE>
<PHRASE Label="lu_MessageCreated" Module="In-Bulletin" Type="0">RGF0ZQ==</PHRASE>
+ <PHRASE Label="lu_MessagePreview" Module="In-Bulletin" Type="0">TWVzc2FnZSBQcmV2aWV3</PHRASE>
<PHRASE Label="lu_MyTopics" Module="In-Bulletin" Type="0">TXkgVG9waWNz</PHRASE>
<PHRASE Label="lu_NewTopic" Module="In-Bulletin" Type="0">TmV3IFRvcGlj</PHRASE>
<PHRASE Label="lu_newtopic_confirm_pending_text" Module="In-Bulletin" Type="0">VGhlIHN5c3RlbSBhZG1pbmlzdHJhdG9yIG11c3QgYXBwcm92ZSB5b3VyIHRvcGljIGJlZm9yZSBpdCBpcyBwdWJsaWNseSBhdmFpbGFibGUu</PHRASE>
Property changes on: .
___________________________________________________________________
Added: svn:mergeinfo
Merged /in-bulletin/branches/5.0.x/in-bulletin:r12120-12148
inbpatch2.patch [^] (6,250 bytes) 2011-07-06 02:58
[Show Content]
Index: default2009/in-bulletin/my_account/private_messages/new_message.tpl
===================================================================
--- default2009/in-bulletin/my_account/private_messages/new_message.tpl (revision 12148)
+++ default2009/in-bulletin/my_account/private_messages/new_message.tpl (revision 12150)
@@ -61,7 +61,8 @@
<inp2:m_RenderElement name="inp_edit_checkbox" prefix="private-message" field="ShowSignatures" title="lu_fld_ShowSignatures" is_last="1"/>
<inp2:m_RenderElement design="inp_edit_buttons">
<input type="hidden" name="next_template" value="in-bulletin/my_account/private_messages/add_confirm"/>
- <input class="button" type="submit" name="events[private-message][OnCreate]" value="<inp2:m_phrase label="lu_btn_Create"/>"/>
+ <input class="button" type="submit" name="events[private-message][OnCreate]" value="<inp2:m_phrase label='lu_btn_Create' html_escape='1'/>"/>
+ <input class="button" type="submit" name="events[private-message][OnPreview]" value="<inp2:m_Phrase label='lu_btn_Preview' html_escape='1'/>"/>
<input class="button" type="button" onclick="redirect('<inp2:m_Link template="in-bulletin/my_account/private_messages/private_messages"/>');" value="<inp2:m_Phrase label="lu_btn_Cancel"/>"/>
</inp2:m_RenderElement>
</table>
Index: default2009/in-bulletin/topics/new_topic_reply.tpl
===================================================================
--- default2009/in-bulletin/topics/new_topic_reply.tpl (revision 12148)
+++ default2009/in-bulletin/topics/new_topic_reply.tpl (revision 12150)
@@ -64,8 +64,9 @@
<inp2:m_RenderElement design="inp_edit_buttons">
<input type="hidden" name="next_template" value="__default__"/>
- <input class="button" type="submit" name="events[bb-post][OnCreate]" value="<inp2:m_phrase label="lu_btn_Create"/>"/>
- <input class="button" type="button" value="<inp2:m_phrase label="lu_btn_Cancel"/>" onclick="redirect('<inp2:bb_TopicLink template="__default__"/>');"/>
+ <input class="button" type="submit" name="events[bb-post][OnCreate]" value="<inp2:m_phrase label='lu_btn_Create' html_escape='1'/>"/>
+ <input class="button" type="submit" name="events[bb-post][OnPreview]" value="<inp2:m_Phrase label='lu_btn_Preview' html_escape='1'/>"/>
+ <input class="button" type="button" value="<inp2:m_phrase label='lu_btn_Cancel'/>" onclick="redirect('<inp2:bb_TopicLink template="__default__"/>');"/>
</inp2:m_RenderElement>
</table>
</form>
Index: default2009/in-bulletin/topics/new_topic.tpl
===================================================================
--- default2009/in-bulletin/topics/new_topic.tpl (revision 12148)
+++ default2009/in-bulletin/topics/new_topic.tpl (revision 12150)
@@ -64,7 +64,8 @@
<inp2:m_RenderElement design="inp_edit_buttons">
<input type="hidden" name="suggest_confirm_template" value="in-bulletin/topics/add_confirm"/>
<input type="hidden" name="suggest_pending_confirm_template" value="in-bulletin/topics/add_pending_confirm"/>
- <input class="button" type="submit" name="events[bb][OnCreate]" value="<inp2:m_phrase label="lu_btn_Create"/>"/>
+ <input class="button" type="submit" name="events[bb][OnCreate]" value="<inp2:m_phrase label='lu_btn_Create' html_escape='1'/>"/>
+ <input class="button" type="submit" name="events[bb][OnPreview]" value="<inp2:m_Phrase label='lu_btn_Preview' html_escape='1'/>"/>
<input class="button" type="button" value="<inp2:m_phrase label="lu_btn_Cancel"/>" onclick="redirect('<inp2:m_Link template="__default__"/>');"/>
</inp2:m_RenderElement>
</table>
Index: default2009/in-bulletin/topics/modify_post.tpl
===================================================================
--- default2009/in-bulletin/topics/modify_post.tpl (revision 12148)
+++ default2009/in-bulletin/topics/modify_post.tpl (revision 12150)
@@ -63,7 +63,8 @@
<inp2:m_RenderElement design="inp_edit_buttons">
<input type="hidden" name="next_template" value="__default__"/>
- <input class="button" type="submit" name="events[bb-post][OnUpdate]" value="<inp2:m_phrase label="lu_btn_Update"/>"/>
+ <input class="button" type="submit" name="events[bb-post][OnUpdate]" value="<inp2:m_Phrase label='lu_btn_Update' html_escape='1'/>"/>
+ <input class="button" type="submit" name="events[bb-post][OnPreview]" value="<inp2:m_Phrase label='lu_btn_Preview' html_escape='1'/>"/>
<input class="button" type="button" value="<inp2:m_phrase label="lu_btn_Cancel"/>" onclick="redirect('<inp2:bb_TopicLink template="__default__"/>');"/>
</inp2:m_RenderElement>
</table>
Index: default2009/in-bulletin/elements/forms.elm.tpl
===================================================================
--- default2009/in-bulletin/elements/forms.elm.tpl (revision 12148)
+++ default2009/in-bulletin/elements/forms.elm.tpl (revision 12150)
@@ -2,6 +2,21 @@
<tr class="<inp2:m_odd_even odd="table_color1" even="table_color2"/>">
<inp2:m_RenderElement name="inp_edit_field_caption" prefix="$prefix" field="$field" title="$title"/>
<td class="field-value">
+ <inp2:m_if check="m_Param" name="prefix" equals_to="private-message">
+ <inp2:m_include template="in-bulletin/elements/private_messages.elm"/>
+ <inp2:$prefix_MessageBody smiley_render_as="smiley_element" bbcode_render_as="bbcode_element" result_to_var="preview"/>
+ <inp2:m_else/>
+ <inp2:m_include template="in-bulletin/elements/posts.elm"/>
+ <inp2:$prefix_PostBody quote_render_as="post_quote_element" smiley_render_as="smiley_element" bbcode_render_as="bbcode_element" result_to_var="preview"/>
+ </inp2:m_if>
+
+ <inp2:m_if check="m_Param" name="preview">
+ <inp2:m_Phrase name="lu_MessagePreview"/>:<br/>
+ <div style="border: 1px solid #7091B9; padding: 4px; margin-bottom: 4px;">
+ <inp2:m_Param name="preview"/>
+ </div>
+ </inp2:m_if>
+
<a href="<inp2:m_Link/>" onclick="insertTags('[B]', '[/B]', 'bold text', '<inp2:{$prefix}_InputName field="$field"/>'); return false;">
<img src="<inp2:m_TemplatesBase module="in-bulletin"/>img/toolbar/bold_icon.png" border="0"/>
</a>
|