[pLog-svn] r3366 - in plog/trunk: class/action/admin js/tinymcejs/ui locale templates/admin

Mark Wu markplace at gmail.com
Mon May 8 15:24:38 GMT 2006


Hi:

It is easy to test.

Just open newpost link, and type something in postText and postExtented.

Then just close your browser. And ope it again ...

Login to lifetype, and click the newpost. You will see it ask you =
restore
the unsaved post or not.

** It tested in Firefox and IE, both browsers are works well. I never =
test
it under opera and safari, so.... If you use these two kind of browsers,
please kindly test it.

Mark=20

> -----Original Message-----
> From: plog-svn-bounces at devel.lifetype.net=20
> [mailto:plog-svn-bounces at devel.lifetype.net] On Behalf Of=20
> mark at devel.lifetype.net
> Sent: Monday, May 08, 2006 10:54 PM
> To: plog-svn at devel.lifetype.net
> Subject: [pLog-svn] r3366 - in plog/trunk: class/action/admin=20
> js/tinymcejs/ui locale templates/admin
>=20
> Author: mark
> Date: 2006-05-08 14:54:18 +0000 (Mon, 08 May 2006) New Revision: 3366
>=20
> Modified:
>    plog/trunk/class/action/admin/adminaddpostaction.class.php
>    plog/trunk/js/tinymce/tiny_mce-plog.js
>    plog/trunk/js/ui/plogui.js
>    plog/trunk/locale/locale_en_UK.php
>    plog/trunk/locale/locale_zh_TW.php
>    plog/trunk/templates/admin/header.template
>    plog/trunk/templates/admin/newpost.template
> Log:
> Autosvae done. Now, user don't need to worry about system=20
> crash, browser crash ...or even session time out ...
>=20
> All data saved in cookie, if something wrong. It will come=20
> out when you click newpost link next time.
>=20
> ** I only implement it in newPost, I think it should be enough.
>=20
> Modified: plog/trunk/class/action/admin/adminaddpostaction.class.php
> =
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
> ---=20
> plog/trunk/class/action/admin/adminaddpostaction.class.php=09
> 2006-05-08 14:14:46 UTC (rev 3365)
> +++=20
> plog/trunk/class/action/admin/adminaddpostaction.class.php=09
> 2006-05-08 14:54:18 UTC (rev 3366)
> @@ -122,7 +122,9 @@
>  		=09
>          	// once we have built the object, we can add it=20
> to the database
>          	if( $artId ) {
> -		=09
> +	            // clear autosave cookie
> +	            $this->clearAutoSaveCookie();
> +
>                  $this->_view =3D new AdminPostsListView(=20
> $this->_blogInfo );
>              	//$article->setId( $artId );
>                  $message =3D $this->_locale->tr("post_added_ok");
> @@ -204,9 +206,15 @@
>          	}
> =20
>              $this->setCommonData();
> -
> +           =20
>              // better to return true if everything fine
>              return true;
>          }
> +       =20
> +        function clearAutoSaveCookie()
> +        {
> +        	// set the auto save cookie as false
> +	    	setcookie( 'LTpostNotSaved', '0', -1, '/' );=09
> +        }
>      }
>  ?>
> \ No newline at end of file
>=20
> Modified: plog/trunk/js/tinymce/tiny_mce-plog.js
> =
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
> --- plog/trunk/js/tinymce/tiny_mce-plog.js	2006-05-08=20
> 14:14:46 UTC (rev 3365)
> +++ plog/trunk/js/tinymce/tiny_mce-plog.js	2006-05-08=20
> 14:54:18 UTC (rev 3366)
> @@ -18,6 +18,7 @@
>  	theme_advanced_path_location : "bottom",
>  	theme_advanced_resizing : true,
>  	theme_advanced_resize_horizontal : false,
> +	onchange_callback : "tinyMCEOnChangeEvent",
>  	extended_valid_elements :=20
> "a[class|name|href|target|title|onclick],img[class|src|border=3D
> 0|alt|title|hspace|vspace|width|height|align|onmouseover|onmou
seout|name],hr[class|width|size|noshade],font[face|size|color|style],span=
[cl
ass|align|style]",
>  	verify_html : true,
>  	valid_elements : ""
>=20
> Modified: plog/trunk/js/ui/plogui.js
> =
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
> --- plog/trunk/js/ui/plogui.js	2006-05-08 14:14:46 UTC=20
> (rev 3365)
> +++ plog/trunk/js/ui/plogui.js	2006-05-08 14:54:18 UTC=20
> (rev 3366)
> @@ -1,4 +1,76 @@
>  /**
> + * functions for auto save
> + */
> +
> +function initialAutoSave()
> +{
> +	LTpostNotSaved =3D getCookie( 'LTpostNotSaved' );
> +	if ( LTpostNotSaved =3D=3D 1 )
> +	{
> +		$('autoSaveMessage').innerHTML =3D msgAutoSaveMessage;
> +		Element.show($('autoSaveMessage'));
> +	}
> +	else
> +	{
> +		deleteCookie( 'LTpostNotSaved' );
> +		deleteCookie( 'LTpostText' );
> +		deleteCookie( 'LTpostExtendedText' );
> +	}
> +}
> +
> +function restoreAutoSave()
> +{
> +	if( htmlAreaEnabled )
> +	{
> +	=09
> tinyMCE.getInstanceById('postText').getBody().innerHTML  =3D=20
> decodeURIComponent( getCookie( 'LTpostText' ) );
> +	=09
> tinyMCE.getInstanceById('postExtendedText').getBody().innerHTM
> L  =3D decodeURIComponent( getCookie( 'LTpostExtendedText' ) );
> +	}
> +	else
> +	{
> +		$('postText').value =3D decodeURIComponent(=20
> getCookie( 'LTpostText' ) );
> +		$('postExtendedText').value =3D=20
> decodeURIComponent( getCookie( 'LTpostExtendedText' ) );
> +	}
> +=09
> +	$('autoSaveMessage').innerHTML =3D '';
> +	Element.hide($('autoSaveMessage'));
> +}
> +
> +function eraseAutoSave()
> +{
> +	deleteCookie( 'LTpostNotSaved' );
> +	deleteCookie( 'LTpostText' );
> +	deleteCookie( 'LTpostExtendedText' );
> +=09
> +	$('autoSaveMessage').innerHTML =3D '';
> +	Element.hide($('autoSaveMessage'));
> +}
> +
> +function tinyMCEOnChangeEvent( inst ) {
> +	// set the postNotSaved ture
> +	setCookie( 'LTpostNotSaved', 1, 7);
> +=09
> +	// postText
> +	if( inst.editorId =3D=3D 'mce_editor_0' )
> +		cookieId =3D 'LTpostText';
> +	else
> +		cookieId =3D 'LTpostExtendedText';
> +=09
> +	setCookie( cookieId, encodeURIComponent(=20
> inst.getBody().innerHTML ), 7=20
> +); }
> +
> +function plogEditorOnChangeEvent( editor ) {
> +	setCookie( 'LTpostNotSaved', 1, 7);
> +=09
> +	// postText
> +	if( editor.id =3D=3D 'postText' )
> +		cookieId =3D 'LTpostText';
> +	else
> +		cookieId =3D 'LTpostExtendedText';
> +	=09
> +	setCookie( cookieId, encodeURIComponent( editor.value ), 7 ); }
> +
> +/**
>   * when adding a new form, checks that there is at least one=20
> category selected
>   */
>  function submitNewPost(form)
>=20
> Modified: plog/trunk/locale/locale_en_UK.php
> =
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
> --- plog/trunk/locale/locale_en_UK.php	2006-05-08=20
> 14:14:46 UTC (rev 3365)
> +++ plog/trunk/locale/locale_en_UK.php	2006-05-08=20
> 14:54:18 UTC (rev 3366)
> @@ -1024,4 +1024,6 @@
> =20
>  $messages['change_album'] =3D 'Change Album';
> =20
> +$messages['warning_autosave_message'] =3D '<img=20
> +src=3D"imgs/admin/icon_warning-16.png" alt=3D"Error"=20
> class=3D"InfoIcon"/><p=20
> +class=3D"ErrorText">You seem to have left here without saving=20
> your post.=20
> +If so, you may <a href=3D"#"=20
> onclick=3D"restoreAutoSave();">click here to=20
> +restore it</a> or <a href=3D"#" onclick=3D"eraseAutoSave();">delete=20
> +it</a>.</p>';
> +
>  ?>
> \ No newline at end of file
>=20
> Modified: plog/trunk/locale/locale_zh_TW.php
> =
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
> --- plog/trunk/locale/locale_zh_TW.php	2006-05-08=20
> 14:14:46 UTC (rev 3365)
> +++ plog/trunk/locale/locale_zh_TW.php	2006-05-08=20
> 14:54:18 UTC (rev 3366)
> @@ -1022,6 +1022,8 @@
>  $messages['enable_pull_down_menu'] =3D =
'=A4U=A9=D4=A6=A1=BF=EF=B3=E6';
>  $messages['enable_pull_down_menu_help'] =3D =
'=B1=D2=A5=CE=A9=CE=C3=F6=B3=AC=A4U=A9=D4=A6=A1=BF=EF=B3=E6=A1C';
> =20
> -$messages['change_album'] =3D '=AD=D7=A7=EF=C0=C9=AE=D7=A7=A8';
> -
> +$messages['change_album'] =3D '=AD=D7=A7=EF=C0=C9=AE=D7=A7=A8';
> =20
> +
> +$messages['warning_autosave_message'] =3D '<img=20
> +src=3D"imgs/admin/icon_warning-16.png" alt=3D"Error"=20
> class=3D"InfoIcon"/><p=20
> =
+class=3D"ErrorText">=A7A=A6n=B9=B3=A6=B3=A4=A7=ABe=A9|=A5=BC=A6s=C0=C9=AA=
=BA=A4=E5=B3=B9=A1C=A6p=AAG=A7A=C1=D9=B7Q=C4~=C4=F2=BDs=BF=E8=A1A=A7A=A5i=
=A5H
<a href=3D"#"=20
> =
+onclick=3D"restoreAutoSave();">=A8=FA=A6^=A5=BC=A6s=C0=C9=A4=E5=B3=B9=C4=
~=C4=F2=BDs=BF=E8</a> =A9=CE=ACO <a href=3D"#"=20
> +onclick=3D"eraseAutoSave();">=A7=E2=A5L=A7R=B0=A3</a> =A1C</p>';
> +
>  ?>
> \ No newline at end of file
>=20
> Modified: plog/trunk/templates/admin/header.template
> =
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
> --- plog/trunk/templates/admin/header.template=09
> 2006-05-08 14:14:46 UTC (rev 3365)
> +++ plog/trunk/templates/admin/header.template=09
> 2006-05-08 14:54:18 UTC (rev 3366)
> @@ -16,6 +16,7 @@
>  <![endif] -->
>  <script type=3D"text/javascript"=20
> src=3D"js/ui/default.js"></script>  <script=20
> type=3D"text/javascript" src=3D"js/ui/common.js"></script>
> +<script type=3D"text/javascript" =
src=3D"js/cookie/cookie.js"></script>
>  <script type=3D"text/javascript">
>      var blogLocale =3D '{$locale->getCharset()|upper}';  </script>
>=20
> Modified: plog/trunk/templates/admin/newpost.template
> =
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
> --- plog/trunk/templates/admin/newpost.template=09
> 2006-05-08 14:14:46 UTC (rev 3365)
> +++ plog/trunk/templates/admin/newpost.template=09
> 2006-05-08 14:54:18 UTC (rev 3366)
> @@ -24,7 +24,8 @@
>    var msgErrorPostText =3D =
"{$locale->tr("error_missing_post_text")}";
>    var msgSaving =3D "{$locale->tr("saving_message")}";
>    var msgShowOptionPanel =3D "{$locale->tr("show_option_panel")}";
> -  var msgHideOptionPanel =3D "{$locale->tr("hide_option_panel")}"; =20
> +  var msgHideOptionPanel =3D "{$locale->tr("hide_option_panel")}";
> +  var msgAutoSaveMessage =3D=20
> '{$locale->tr("warning_autosave_message")}';
>   =20
>    var todayDay =3D '{$today->getDay()}';
>    var todayMonth =3D '{$today->getMonth()}'; @@ -43,6 +44,7 @@
>     </div>=20
> =20
>     <div id=3D"mainPanel" style=3D"float:left; width: 73%;=20
> border-right: 1px solid #DEDEDE;">
> +	   <div id=3D"autoSaveMessage" style=3D"display: none;"></div>
>  	   {include=20
> file=3D"$admintemplatepath/formvalidate.template"=20
> message=3D$locale->tr("error_adding_post")} =20
>  	   <div class=3D"field">
>  	     <label for=3D"postTopic">{$locale->tr("topic")}</label>
> @@ -60,7 +62,7 @@
>  		 <span class=3D"required">*</span>
>  		 <div class=3D"formHelp">{$locale->tr("text_help")}</div>
>  	     {if !$htmlarea}<script type=3D"text/javascript">var=20
> ed1 =3D new pLogEditor('postText','ed1');</script>{/if}
> -	     <textarea {if=20
> $htmlarea=3D=3D1}rows=3D"20"{else}rows=3D"15"{/if} id=3D"postText"=20
> name=3D"postText" style=3D"width:100%">{$postText}</textarea>
> +	     <textarea {if =
$htmlarea=3D=3D1}rows=3D"20"{else}rows=3D"15"{/if}=20
> +id=3D"postText" name=3D"postText" style=3D"width:100%" {if=20
> +!$htmlarea}onChange=3D"javascript:plogEditorOnChangeEvent(this)
> ;"{/if}>{$
> +postText}</textarea>
>  	     {include=20
> file=3D"$admintemplatepath/validate.template" field=3DpostText=20
> message=3D$locale->tr("error_missing_post_text")}  =20
>  	   </div>
>  	  =20
> @@ -68,7 +70,7 @@
>  	     <label=20
> for=3D"postExtendedText">{$locale->tr("extended_text")}</label>
>  		 <div=20
> class=3D"formHelp">{$locale->tr("extended_text_help")}</div>
>  	     {if !$htmlarea}<script type=3D"text/javascript">var=20
> ed2 =3D new pLogEditor('postExtendedText','ed2');</script>{/if}
> -	     <textarea {if=20
> $htmlarea}rows=3D"25"{else}rows=3D"20"{/if} id=3D"postExtendedText"=20
> name=3D"postExtendedText"=20
> style=3D"width:100%">{$postExtendedText}</textarea>
> +	     <textarea {if $htmlarea}rows=3D"25"{else}rows=3D"20"{/if}=20
> +id=3D"postExtendedText" name=3D"postExtendedText" =
style=3D"width:100%" {if=20
> +!$htmlarea}onChange=3D"javascript:plogEditorOnChangeEvent(this)
> ;"{/if}>{$
> +postExtendedText}</textarea>
>  	   </div>
> =20
>  	   <div class=3D"field">
> @@ -192,5 +194,10 @@
>  		<input type=3D"hidden" name=3D"postId" id=3D"postId"=20
> value=3D"{$postId}" />
>      </div>
>    </form>
> +  {literal}
> +  <script type=3D"text/javascript">
> +    initialAutoSave();
> +  </script>
> +  {/literal}
>  {include file=3D"$admintemplatepath/footernavigation.template"}
>  {include file=3D"$admintemplatepath/footer.template"}
> \ No newline at end of file
>=20
> _______________________________________________
> pLog-svn mailing list
> pLog-svn at devel.lifetype.net
> http://devel.lifetype.net/mailman/listinfo/plog-svn



More information about the pLog-svn mailing list