From ca6a78d9c328f4f547ccd3cbbe973754c3c17917 Mon Sep 17 00:00:00 2001 From: friendica Date: Mon, 6 Feb 2012 20:48:59 -0800 Subject: [PATCH] plugin to toggle plaintext editing --- editplain.tgz | Bin 0 -> 1229 bytes editplain/editplain.css | 14 +++++++ editplain/editplain.php | 87 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 101 insertions(+) create mode 100644 editplain.tgz create mode 100755 editplain/editplain.css create mode 100755 editplain/editplain.php diff --git a/editplain.tgz b/editplain.tgz new file mode 100644 index 0000000000000000000000000000000000000000..51b57d0d1c57089cbc6c47af6a49063397726fa4 GIT binary patch literal 1229 zcmV;;1Ty;{iwFQHtuRjj1MOE`Z{kK28_Nheb`;0 z!5;7k+hfg)NuqB4d+&@5hJ-ZQDoLf*M~M=T@7#}b?wtV|FqKAxC2sA-&_xV~gIaIU zANG3vT6b{VJMMdCy+FeCLYd0rP7h>Zlvh=Ja$vT=PaUbjK&ka z8-MY~Z8RG5Eb(<_u<6|?OE7#CIW73J(Wnc$U{X;r4LM&rb{b_1w2@Tl%%t50n*;&h z>iyj*&<3UJ&9>I*Q=X@~_PeGRKl8`0$lf?kj zi2EeM3=lt(rP-_97#1G7em;hu^8Gv)heXVO?Vr=LGvUI7t;+!~udC|t8Bf|%eW$V}iPwO14tTmgX#etAy$-0bO@9b%j&X`AGA z|J2#s`3X$7Om!yMRNub?F5NhJHSLn$Lz&HDhQzj7jXI8q%0z-nqVs8*=jd!ZYTNP_ z^^NVeZMN$p#ctzYth;djrF3q8Ynh>7$(%c&9D8$4l_F$mKoku+b_+Ui{^?_(;I4qE z@kYMSrl;Vtq%7`$IiiBVP|L5k-0RSwxY?PK1uZH4TT-1jNa&lU%*XKopW9qD>TVfZ zs@sUlkfO?4LACJL6nv88U1KcQ8AdoMkT9Q`tm;j2IMI8)*rAG}kdnau2Awh3XAw)5 zAZRqU$|x3qx=rcW(n7etloo`7&c~LGY-(2v6mmu+&4fN%I$*nx&mL~q+iVMBTqI)) znYX~5=tb+R_?lQnwZG`{ur@yvf+osbA6V6VtFv(s1T!~JUKLIBLjYq~{77r*Q>E#L z)L)vtjSY0UjTid-_sHlzYmBG9|9Qisd*A;C{oZl)`TsS5 zH`mYmj|F}A&m&IM2qHRHIB(Z1P~ixA-EMk=k1-K=cOK3-j!}%u1HF2;<8M9O4}9rc r`QI+RLWK$yDpaUYp+bcU6)IGyP@zJF3Kc3;_|M`mi@)j704M+edCX(Y literal 0 HcmV?d00001 diff --git a/editplain/editplain.css b/editplain/editplain.css new file mode 100755 index 00000000..697f6538 --- /dev/null +++ b/editplain/editplain.css @@ -0,0 +1,14 @@ + + + +#editplain-enable-label { + float: left; + width: 200px; + margin-bottom: 25px; +} + +#editplain-checkbox { + float: left; +} + + diff --git a/editplain/editplain.php b/editplain/editplain.php new file mode 100755 index 00000000..61273edf --- /dev/null +++ b/editplain/editplain.php @@ -0,0 +1,87 @@ + + * + * + */ + + +function editplain_install() { + + register_hook('plugin_settings', 'addon/editplain/editplain.php', 'editplain_settings'); + register_hook('plugin_settings_post', 'addon/editplain/editplain.php', 'editplain_settings_post'); + + logger("installed editplain"); +} + + +function editplain_uninstall() { + + unregister_hook('post_local', 'addon/editplain/editplain.php', 'editplain_post_hook'); + unregister_hook('plugin_settings', 'addon/editplain/editplain.php', 'editplain_settings'); + unregister_hook('plugin_settings_post', 'addon/editplain/editplain.php', 'editplain_settings_post'); + + + logger("removed editplain"); +} + + + +/** + * + * Callback from the settings post function. + * $post contains the $_POST array. + * We will make sure we've got a valid user account + * and if so set our configuration setting for this person. + * + */ + +function editplain_settings_post($a,$post) { + if(! local_user() || (! x($_POST,'editplain-submit'))) + return; + set_pconfig(local_user(),'system','plaintext',intval($_POST['editplain'])); + + info( t('Editplain settings updated.') . EOL); +} + + +/** + * + * Called from the Plugin Setting form. + * Add our own settings info to the page. + * + */ + + + +function editplain_settings(&$a,&$s) { + + if(! local_user()) + return; + + /* Add our stylesheet to the page so we can make our settings look nice */ + + $a->page['htmlhead'] .= '' . "\r\n"; + + /* Get the current state of our config variable */ + + $enabled = get_pconfig(local_user(),'system','plaintext'); + $checked = (($enabled) ? ' checked="checked" ' : ''); + + /* Add some HTML to the existing form */ + + $s .= '
'; + $s .= '

' . t('Editplain Settings') . '

'; + $s .= '
'; + $s .= ''; + $s .= ''; + $s .= '
'; + + /* provide a submit button */ + + $s .= '
'; + +} -- 2.39.5