How to prevent elgg from formating text?

Everytime I save the text, elgg puts spaces or tags like </b> in it, how do I prevent that?

  • Are you sure it's Elgg and not your editor?

  • Well, I disabled the editor and it gets the text and wrap it, it put a few tags, it deletes the html tag.

    In shortly I need something that can do the same as the bbc tag [code], but automatically.

    Thought that disabling the editor would be able to do that, but I was wrong.

    • save text @where ?
    • on which screen/page ?
    • what is the (elgg) url for that page ?
    • where do you see the 'extra' tags afterwards ?

    automatic 'bbc tag [code]' style ? forget it - unless your {php/js/elgg/etc} level know-how is rather high% and you've got much spare coding time..

  • lol, that should be simple, should be.

    I just want to be able to display a full html code as plain text in the form field on the page, impossible?

  • THose are the files codes:

    market.php

     

    <?php

    /**

     * Elgg Market Plugin

     * @package market

     * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2

     * @author slyhne

     * @copyright slyhne 2010-2011

     * @link www.zurf.dk/elgg

     * @version 1.8

     */

     

    $full = elgg_extract('full_view', $vars, FALSE);

    $marketpost = $vars['entity'];

     

    if (!$marketpost) {

    return TRUE;

    }

     

    $currency = elgg_get_plugin_setting('market_currency', 'market');

     

    $owner = $marketpost->getOwnerEntity();

    $tu = $marketpost->time_updated;

    $container = $marketpost->getContainerEntity();

    $category = "<b>" . elgg_echo('market:category') . ":</b> " . elgg_echo("market:{$marketpost->marketcategory}");

    $excerpt = elgg_get_excerpt($marketpost->description);

     

    $owner_link = elgg_view('output/url', array(

    'href' => "market/owned/{$owner->username}",

    'text' => $owner->name,

    ));

    $author_text = elgg_echo('byline', array($owner_link));

     

    $image = elgg_view('market/thumbnail', array('marketguid' => $marketpost->guid, 'size' => 'medium', 'tu' => $tu));

    $market_img = elgg_view('output/url', array(

    'href' => "market/view/$owner->username",

    'text' => $image,

    ));

     

    $tags = elgg_view('output/tags', array('tags' => $marketpost->tags));

    $date = elgg_view_friendly_time($marketpost->time_created);

     

    if(isset($marketpost->custom) && elgg_get_plugin_setting('market_custom', 'market') == 'yes'){

    $custom = "<br><b>" . elgg_echo('market:custom:text') . ": </b>" . elgg_echo($marketpost->custom);

    }

     

    $comments_count = $marketpost->countComments();

    //only display if there are commments

    if ($comments_count != 0) {

    $text = elgg_echo("comments") . " ($comments_count)";

    $comments_link = elgg_view('output/url', array(

    'href' => $marketpost->getURL() . '#market-comments',

    'text' => $text,

    ));

    } else {

    $comments_link = '';

    }

     

    $metadata = elgg_view_menu('entity', array(

    'entity' => $vars['entity'],

    'handler' => 'market',

    'sort_by' => 'priority',

    'class' => 'elgg-menu-hz',

    ));

     

    // do not show the metadata and controls in widget view

    if (elgg_in_context('widgets')) {

    $metadata = '';

    }

     

    if ($full && !elgg_in_context('gallery')) {

     

    $body = "<script type='text/javascript'>

    function SelectAll(id)

    {

        document.getElementById(id).focus();

        document.getElementById(id).select();

    }

    </script>

     

     

     

     

     

     

    <table border='0' width='100%'><tr>";

    $body .= "<td width='220px'><center>";

    $body .= elgg_view('output/url', array(

    'href' => elgg_get_site_url() . "mod/market/viewimage.php?marketguid={$marketpost->guid}",

    'text' => elgg_view('market/thumbnail', array('marketguid' => $marketpost->guid, 'size' => 'large', 'tu' => $tu)),

    'class' => "elgg-lightbox",

    ));

     

     

     

     

     

     

     

     

     

     

    $body .= "</center></td><td>";

     

     

     

     

     

     

    $body .= elgg_echo('market:copy-and-paste');

     

     

     

    $body .="

     

     

    <textarea id='txtarea' onClick='SelectAll(\"txtarea\");' style='height:180px;'>

     

     

     

     

     

    ";

    if ($allowhtml != 'yes') {

    $body .= elgg_view('output/longtext', array('value' => $marketpost->description));

    } else {

    $body .= elgg_view('output/longtext', array('value' => $marketpost->description));

    }

    $body .= "

     

     

     

     

     

     

    </textarea>

     

     

     

     

     

     

     

     

    </td></tr><tr>";

    $body .= "<td><center>";

    $body .= "<span class='market_pricetag'><b>" . elgg_echo('market:price') . "</b> {$currency}{$marketpost->price}</span>";

    $body .= "</center></td><td><center>";

    if (elgg_get_plugin_setting('market_pmbutton', 'market') == 'yes') {

    if ($owner->guid != elgg_get_logged_in_user_guid()) {

    $body .= elgg_view('output/url', array(

    'class' => 'elgg-button elgg-button-action',

    'href' => "messages/compose?send_to={$owner->guid}",

    'text' => elgg_echo('market:pmbuttontext'),

    ));

    }

    }

    $body .= "</center></td></tr></table>";

     

    $subtitle = "{$category}{$custom}<br>{$author_text} {$date} {$comments_link}";

     

     

    $params = array(

    'entity' => $marketpost,

    'header' => $header,

    'metadata' => $metadata,

    'subtitle' => $subtitle,

    'tags' => $tags,

    );

    $params = $params + $vars;

    $list_body = elgg_view('object/elements/summary', $params);

    $owner_icon = elgg_view_entity_icon($owner, 'small');

    $marketpost_info = elgg_view_image_block($owner_icon, $list_body);

     

    echo <<<HTML

    $marketpost_info

    <div class="market elgg-content">

    $body

    </div>

    HTML;

     

    } elseif (elgg_in_context('gallery')) {

    echo '<div class="market-gallery-item">';

    echo "<h3>{$category}: {$marketpost->title}</h3>";

    echo elgg_view_entity_icon($marketpost, 'medium');

    echo "<p class='subtitle'>$owner_link $date</p>";

    echo '</div>';

    } else {

    // brief view

    $market_img = elgg_view('output/url', array(

    'href' => "market/view/{$marketpost->guid}/" . elgg_get_friendly_title($marketpost->title),

    'text' => elgg_view('market/thumbnail', array('marketguid' => $marketpost->guid, 'size' => 'medium', 'tu' => $tu)),

    ));

     

    $subtitle = "{$category}<br><b>" . elgg_echo('market:price') . ":</b> {$currency}{$marketpost->price}{$custom}";

    $subtitle .= "<br>{$author_text} {$date} {$comments_link}";

     

     

    $params = array(

    'entity' => $marketpost,

    'metadata' => $metadata,

    'subtitle' => $subtitle,

    'tags' => $tags,

    'content' => $excerpt,

    );

    $params = $params + $vars;

    $list_body = elgg_view('object/elements/summary', $params);

     

    echo elgg_view_image_block($market_img, $list_body);

    }

     

     

     

    edit.php

     

     

    <?php

    /**

     * Elgg Market Plugin

     * @package market

     * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2

     * @author slyhne

     * @copyright slyhne 2010-2011

     * @link www.zurf.dk/elgg

     * @version 1.8

     */

     

    $object = $vars['entity'];

    // Get plugin settings

    $allowhtml = elgg_get_plugin_setting('market_allowhtml', 'market');

    $currency = elgg_get_plugin_setting('market_currency', 'market');

    $numchars = elgg_get_plugin_setting('market_numchars', 'market');

    if($numchars == ''){

    $numchars = '250';

    }

     

    // Set title, form destination

    if (isset($vars['entity'])) {

    $title = sprintf(elgg_echo("market:editpost"),$object->title);

    $action = "market/edit";

    $tu = $marketpost->time_updated;

    $title = $vars['entity']->title;

    if ($allowhtml != 'yes') {

    $body = strip_tags($vars['entity']->description);

    } else {

    $body = $vars['entity']->description;

    }

    $price = $vars['entity']->price;

    $custom = $vars['entity']->custom;

    $tags = $vars['entity']->tags;

    $access_id = $vars['entity']->access_id;

    }

     

    // Just in case we have some cached details

    if (isset($vars['markettitle'])) {

    $title = $vars['markettitle'];

    $body = $vars['marketbody'];

    $price = $vars['marketprice'];

    $custom = $vars['marketcustom'];

    $tags = $vars['markettags'];

    }

     

     

    ?>

    <script type="text/javascript">

    function textCounter(field,cntfield,maxlimit) {

    // if too long...trim it!

    if (field.value.length > maxlimit) {

    field.value = field.value.substring(0, maxlimit);

    } else {

    // otherwise, update 'characters left' counter

    cntfield.value = maxlimit - field.value.length;

    }

    }

    function acceptTerms() {

    error = 0;

    if(!(document.marketForm.accept_terms.checked) && (error==0)) {

    alert('<?php echo elgg_echo('market:accept:terms:error'); ?>');

    document.marketForm.accept_terms.focus();

    error = 1;

    }

    if(error == 0) {

    document.marketForm.submit();

    }

    }

    </script>

     

    <?php

    echo "<p><label>" . elgg_echo("title") . " <small><small>" . elgg_echo("market:title:help") . "</small></small><br />";

    echo elgg_view("input/text", array(

    "name" => "markettitle",

    "value" => $title,

    ));

    echo "</label></p>";

     

    $marketcategories = elgg_view('market/marketcategories',$vars);

    if (!empty($marketcategories)) {

    echo "<p>{$marketcategories}</p>";

    }

     

    if(elgg_get_plugin_setting('market_custom', 'market') == 'yes'){

    $marketcustom = elgg_view('market/custom',$vars);

    if (!empty($marketcustom)) {

    echo "<p>{$marketcustom}</p>";

    }

    }

     

    echo "<table border='0' cellpadding='40' width='100%'><tr>";

    echo "<td><p><label>" . elgg_echo("market:text") . "</label><br>";

    if ($allowhtml != 'yes') {

     

    echo "<small><small>" . sprintf(elgg_echo("market:text:help"), $numchars) . "</small></small><br />";

    echo "<textarea name='marketbody' class='mceNoEditor' rows='8' cols='40' onKeyDown='textCounter(document.marketForm.marketbody,document.marketForm.remLen1,{$numchars})' onKeyUp='textCounter(document.marketForm.marketbody,document.marketForm.remLen1,{$numchars})'>{$body}</textarea>";

    echo "<span><input readonly type='text' name='remLen1' size='3' maxlength='3' value='{$numchars}' class='market_charleft'>" . elgg_echo("market:charleft") . "</span>";

     

    } else {

    echo elgg_view("input/longtext", array("name" => "marketbody", "value" => $body));

    echo "</label>";

    }

     

    echo "</p></td>";

     

    echo "<td width='220px'>";

    echo "<p><label>" . elgg_echo("market:image") . "<br /><center>";

    echo elgg_view('market/thumbnail', array('marketguid' => $object->guid, 'size' => 'large', 'tu' => $tu));

    echo "</center><br /></label></p>";

    echo "</td><tr></table>";

     

    echo "<br><p><label>" . elgg_echo("market:price") . " <small><small>" . elgg_echo("market:price:help", array($currency)) . "</small></small><br />";

    echo elgg_view("input/text", array(

    "name" => "marketprice",

    "value" => $price,

    ));

    echo "</label></p>";

     

    echo "<p><label>" . elgg_echo("market:tags") . " <small><small>" . elgg_echo("market:tags:help") . "</small></small><br />";

    echo elgg_view("input/tags", array(

    "name" => "markettags",

    "value" => $tags,

    ));

    echo "</label></p>";

     

    echo "<p><label>" . elgg_echo("market:uploadimages") . "<br /><small><small>" . elgg_echo("market:imagelimitation") . "</small></small><br />";

    echo elgg_view("input/file",array('name' => 'upload'));

    echo "</label></p>";

     

    echo "<p><label>" . elgg_echo('access') . " <small><small>" . elgg_echo("market:access:help") . "</small></small><br />";

    echo elgg_view('input/access', array('name' => 'access_id','value' => $access_id));

    echo "</label></p>";

     

    echo "<p>";

    if (isset($vars['entity'])) {

    echo "<input type=\"hidden\" name=\"marketpost\" value=\"".$object->guid."\" />";

    }

     

     

    // Terms checkbox and link

    $termslink = elgg_view('output/url', array(

    'href' => "mod/market/terms.php",

    'text' => elgg_echo('market:terms:title'),

    'class' => "elgg-lightbox",

    ));

     

    $termsaccept = sprintf(elgg_echo("market:accept:terms"),$termslink);

    echo "<input type='checkbox' name='accept_terms'><label>{$termsaccept}</label></p>";

     

    echo "<p>";

    echo elgg_view('input/submit', array('name' => 'submit', 'text' => elgg_echo('save')));

    echo "</p>";

     

     

     

     

     

    Link: