Not signed in ( Sign In)

Categories

Welcome, Guest

Want to take part in these discussions? Sign in if you have an account, or apply for one below

Vanilla 1.1.10 is a product of Lussumo. More Information: Documentation, Community Support.

    •  
      CommentAuthorskatebored
    • CommentTimeOct 10th 2008 edited
     permalink
    hai...

    >> adding some script
    how can i attach my code to display some emoticons bar under comment form?

    >> resize picture
    how come the scale parameter wont works?
    i have used [img=path_to_picture_file scale=50%]
    but nothing happen...

    thanks...
    •  
      CommentAuthorNoWhereMan
    • CommentTimeOct 10th 2008 edited
     permalink
    i think you should something like (pseudocode):
    (in the emoticon plugin)


    // outputs this code after the antispam, before the textarea
    do_action('comment_form'. 'plugin_emoticons_bar');

    function plugin_emoticons_bar() {

    $emoticons = get_somehow_emoticons();
    $path = get_emoticons_basepath();

    echo '<script type="text/javascript">/* <![CDATA */
    function insert_emoticon(string) {
    // do something to insert string into the textarea
    /* ]]> */</script>';

    echo '<div id="emoticon-toolbar">

    foreach ($emoticons as $shortcut => $img) {
    echo "<a href=\"#emoticon-toolbar\" onclick=\"insert_emoticon('{$shortcut}')\">";
    echo "<img src=\"{$path}{$img}\" title=\"{$shortcut}\" alt=\"{$shortcut}\" /></a>"
    }

    echo '</div>';
    }


    If I have time later I'll come with a working example



    >> resize picture
    how come the scale parameter wont works?
    i have used [img=path_to_picture_file scale=50%]
    but nothing happen...

    need more info. what is that "path" ? do you have GD2 installed on your server?
    •  
      CommentAuthorskatebored
    • CommentTimeOct 10th 2008 edited
     permalink
    hai...

    actually, this is the code i used :

    <script language="Javascript" type="text/javascript">
    function sisipkanemoticons(text) {ldelim}
    var space=" ";
    document.comments.content.value += space + text + space;
    {rdelim}
    </script>

    <p>silakan klik sembarang emoticons untuk menyisipkan kodenya...</p>
    <p><a href="javascript:void(0)" onClick="Javascript:sisipkanemoticons('#catman01#');return false;"><img src="../../fp-plugins/smilies/smilies/catman01.gif" border="0" alt=""></a>  
    <a href="javascript:void(0)" onClick="Javascript:sisipkanemoticons('#lineman01#');return false;"><img src="../../fp-plugins/smilies/smilies/lineman01.gif" border="0" alt=""></a>  </p>

    my emoticons bar is already show up,
    but when i click the emoticon,
    nothing happen,
    the value wont show up on the form...

    ---

    gd2 works fine on the server

    ---

    thanks
    •  
      CommentAuthorNoWhereMan
    • CommentTimeOct 10th 2008 edited
     permalink
    as usual I almost didn't test anything :D
    just tested and it works, you can also style the id #emoticons-toolbar in your CSS! have fun!

    <?php
    /*
    Plugin Name: emoticons
    Plugin URI: http://www.flatpress.org/
    Description: Adds emoticons to FlatPress
    Author: NoWhereMan
    Version: 1.0
    Author URI: http://www.nowhereland.it/
    */

    /*
    put your imgs in FP_CONTENT/emoticons/
    (tipically FP_CONTENT is fp-content/ )
    */

    define('EMOTICONS_DIR', BLOG_BASEURL . FP_CONTENT . 'emoticons/');

    function plugin_emoticons_list() {
    static $EMOTICONS = array(
    ':)' => 'smile.gif', // of course format can be whatever; I use PNGs
    ':(' => 'sad.gif', // these are the images you have in fp-content/emoticons/
    ':-)' => 'smile.gif', // you can put multiple shortcuts for the same

    // etc etc
    );
    return $EMOTICONS;
    }


    /* now please notice how I follow this naming convention: */
    function plugin_emoticons_filter($string) {

    $ed = EMOTICONS_DIR;
    $EMOTICONS = plugin_emoticons_list();

    foreach ($EMOTICONS as $emo => $img) {
    $string = str_replace(
    " $emo ", /* replace one of the codes defined above,
    when *sourrounded by spaces* */
    "<img src=\"{$ed}{$img}\" class=\"emoticon\" alt=\"{$emo}\" />", /* with the <img> tag
    .emoticon class can be styled as you prefer in your css */
    $string
    );
    }
    return $string;

    }

    /* and now, don't forget to register to the hook */
    add_filter( 'the_content', 'plugin_emoticons_filter' );
    /* if you want it in comments too */
    add_filter( 'comment_text', 'plugin_emoticons_filter' );

    // outputs this code after the antispam, before the textarea
    add_action('comment_form', 'plugin_emoticons_bar');

    function plugin_emoticons_bar() {

    $EMOTICONS = plugin_emoticons_list();
    $path = EMOTICONS_DIR;

    echo '<script type="text/javascript">/* <![CDATA */
    function insert_emoticon(string) {
    $("content").value+=" "+string+ " ";
    } /* ]]> */</script>';

    echo '<div id="emoticons-toolbar">';

    foreach ($EMOTICONS as $shortcut => $img) {
    echo "<a href=\"#emoticons-toolbar\" onclick=\"insert_emoticon('{$shortcut}');return false\">";
    echo "<img class=\"emoticon\" src=\"{$path}{$img}\" title=\"{$shortcut}\" alt=\"{$shortcut}\" /></a>";
    }

    echo '</div>';
    }




    as for images, [img=image/blahbla.jpg] points to fp-content/images/blahblah.jpg; if you put there an http:// link, scale won't work
    •  
      CommentAuthorlaborix
    • CommentTimeOct 10th 2008
     permalink
    Tested with Flatpress 0.804.1 Vivace and there are some things, that are not work in comments:

    Test comment that works fine:
    text"space":)"space"
    bye


    Test comment display only :) and not the emoticon:
    "space":)"space"

    Test comment that also not work:
    text"space":)"space"

    It only works in the comments, if there is an text then the emoticons and a new line with text. It's the same as you use the emoticons plugin in the wiki. It also work in comments, but only with two spaces and a new line with text.
    •  
      CommentAuthorskatebored
    • CommentTimeOct 11th 2008 edited
     permalink
    hai...

    my emoticon bar already show up,
    but when i click the picture,
    the represent value not pass/send to the textarea,
    could you please tell me whats wrong with my script below?

    --- begin ---

    {if !$entry_commslock}
    <h4>{$lang.comments.head}</h4>
    <p>{$lang.comments.descr}</p>

    <form id="commentform" method="post"
    action="{$flatpress.params.entry|link:comments_link}#commentform"
    enctype="multipart/form-data">

    {include file='shared:errorlist.tpl'}

    {if not $flatpress.loggedin}

    <fieldset id="comment-userdata">
    <legend>{$lang.comments.fieldset1}</legend>
    <p><label class="textlabel" for="name">{$lang.comments.name}</label><br />
    <input type="text" {$error.name|notempty:'class="field-error"'} name="name" id="name" value="{$values.name|default:$cookie.name}" /></p>

    <p><label class="textlabel" for="email">{$lang.comments.email}</label><br />
    <input type="text" {$error.email|notempty:'class="field-error"'} name="email" id="email" value="{$values.email|default:$cookie.email}" /></p>

    <p><label class="textlabel" for="url">{$lang.comments.www}</label><br />
    <input type="text" {$error.url|notempty:'class="field-error"'} name="url" id="url" value="{$values.url|default:$cookie.url}" /></p>

    {comment_form}

    </fieldset>
    {else}
    <p><input type="hidden" name="name" id="name" value="{$flatpress.user.userid}" />
    <input type="hidden" name="email" id="email" value="{$flatpress.user.email}" />
    <input type="hidden" name="url" id="url" value="{$flatpress.user.www}" /></p>
    {/if}

    <fieldset><legend>{$lang.comments.fieldset2}</legend>

    <p><label for="content">{$lang.comments.comment}</label><br />
    <textarea name="content" {$error.content|notempty:'class="field-error"'}
    id="content" rows="10" cols="74">{$values.content}</textarea></p>

    {literal}
    <script language="Javascript">
    function sisipkanemoticons(text){
    var space=" ";
    document.commentform.comments.comment.content.value += space + text + space;
    }
    </script>
    {/literal}
    <p>silakan klik sembarang emoticons untuk menyisipkan kodenya...[masih trial, blom bisa dipake]</p>
    <p>
    <a href="javascript:void(0)" onClick="Javascript:sisipkanemoticons(':catman01:');return false;"><img src="../../fp-plugins/smilies/smilies/catman01.gif" border="0" alt=""></a>  
    <a href="javascript:void(0)" onClick="Javascript:sisipkanemoticons(':lineman01:');return false;"><img src="../../fp-plugins/smilies/smilies/lineman01.gif" border="0" alt=""></a>  
    </p>


    {*here will go a plugin hook*}
    </fieldset>

    <div class="buttonbar">
    <input type="submit" name="submit" id="submit" value="{$lang.comments.submit}" />
    <input type="reset" name="reset" id="reset" value="{$lang.comments.reset}" />
    </div>

    </form>
    {/if}

    --- end ---

    especialy for this line below :

    document.commentform.comments.comment.content.value += space + text + space;

    what is exactly i should i use for that line ?
    thanks...
    •  
      CommentAuthorNoWhereMan
    • CommentTimeOct 11th 2008
     permalink
    first of all onclick="Javascript:sisipkanemoticons(':catman01:');return false" should read onclick="sisipkanemoticons(':catman01:');return false"

    for the line you're asking about, since mootools is installed by default you can just use
    $('content') += ' ' + text + ' ';

    which is anyway what the plugin I posted does.
    You shouldn't edit core files, and use the plugin instead.



    Posted By: laborix
    It only works in the comments, if there is an text then the emoticons and a new line with text. It's the same as you use the emoticons plugin in the wiki. It also work in comments, but only with two spaces and a new line with text.


    well that's the usual "bug" of text trimming. You can avoid it by changin the code from " $emo " to "$emo" in the str_replace section
    •  
      CommentAuthorskatebored
    • CommentTimeOct 11th 2008
     permalink
    hai...

    onclick="sisipkanemoticons(':catman01:');return false"
    >> tried, but still no luck :(

    for the line you're asking about, since mootools is installed by default you can just use
    $('content') += ' ' + text + ' ';
    >> no luck also...
    im afraid mootools not works,
    since i have tested with [img=picture.jpg scale=50%]
    and nothin happen with scalling...

    It only works in the comments, if there is an text then the emoticons and a new line with text. It's the same as you use the emoticons plugin in the wiki. It also work in comments, but only with two spaces and a new line with text.
    >> the first idea is make it much easier for my visitor to including the emoticon [just click],
    and thats why im just focusing on comment part,
    but thanks a lot for that suggestion :)

    this is my sample comment url :
    http://www.dit.web.id/cuap/?x=entry:entry081009-190049;comments:1#comments

    and this is my php info url :
    http://dit.web.id/info.php

    waitin for any further help from all of you,
    thanks...
    •  
      CommentAuthorlaborix
    • CommentTimeOct 11th 2008
     permalink
    Posted By: NoWhereManwell that's the usual "bug" of text trimming. You can avoid it by changin the code from " $emo " to "$emo" in the str_replace section

    I will try this also today evening and see if this will work. Thanks for your answer :)
    •  
      CommentAuthorNoWhereMan
    • CommentTimeOct 11th 2008 edited
     permalink
    @skatebored: sorry I forgot one thing; here's the right snippet:

    <script type="text/javascript">/* <![CDATA[ */
    function sisipkanemoticons(text){
    $('content').value += ' ' + text + ' ';
    }
    /* ]>*/</script>


    beside this, I still strongly recommend to use the plugin

    as for the images, the image you uploaded must be linked using [img=images/MYIMG.jpg scale=NN%]

    images DO NOT work in comments!
    •  
      CommentAuthorflat2007
    • CommentTimeOct 13th 2008 edited
     permalink
    It works for me finely, the only problem is that the toolbar is shown before the securimage plugin that I am using. Any help?

    btw <!-- --> needed for the code for xhtml validation.
    echo '<script type="text/javascript">
    <!--
    /* &lt;![CDATA */
    function insert_emoticon(string) {
    $(&quot;content&quot;).value+=&quot; &quot;+string+ &quot; &quot;;
    } /* ]]&gt; */
    -->
    </script>';
    •  
      CommentAuthorskatebored
    • CommentTimeOct 13th 2008 edited
     permalink
    hai...
    sorry for the delay responding this issue...

    both code from NoWhereMan and flat2007,
    doesnt works for me,
    the comments area not even show up,
    kinda desperate down here...
    •  
      CommentAuthorNoWhereMan
    • CommentTimeOct 13th 2008 edited
     permalink
    It works for me finely, the only problem is that the toolbar is shown before the securimage plugin that I am using


    lower the priority, by changing to:
    add_action('comment_form', 'plugin_emoticons_bar', 100);

    doesnt works for me,
    the comments area not even show up,
    kinda desperate down here...


    I don't understand. Maybe you have a corrupt installation? try re-downloading from sourceforge and upload it
    •  
      CommentAuthorskatebored
    • CommentTimeJan 15th 2010
     permalink
    yo guys, howsa goin down there...
    wow, its been a while [back to 2008] huh, he...

    anyway im still using flatpress and last night i decided to re-coding this issue.
    guess what, i did it guys [finally] :)

    bars of emoticons of my own.
    simply click the emo and the code will appear at comment textarea,
    exactly what i want, pfiuh...

    im not creating any plugin for this one,
    im just put some lines at comments.tpl
    and it works like a charm...

    feel free to see the result at :
    http://dit.web.id [add comment section]