How to limit characters in JFactory::getEditor - Joomla - joomla

$editor = & JFactory::getEditor();
$params = array('smilies'=> '0' ,'style' => '0' ,'layer' => '0' ,'table' => '0' ,'clear_entities'=>'0');
$editor->display('description', $description , 550, 400, 60, 20, false, $params);
I use above code to generate a WYSIWYG editor in Joomla. Is there are way to limit character you enter in the editor?
Thanks

In order to limit the number of characters in an wysiwyg editor you will have to take into account that you may count the visible characters only or to count all characters (html overhead too). For tinymce there is a decription of the developers on how to count and limit characters/words (on submit): http://www.tinymce.com/wiki.php/How_to_limit_number_of_characters/words
If you want to limit the insertion of characters you will need to write an own plugin or configure your tinymce with some special functionality (functions).
Here are some helpfull ressources to get you started:
http://www.ryann.ca/?p=186
Limit the number of character in tinyMCE
http://pogostick.co.nz/limiting-character-count-with-tinymce/

Related

The plus sign is deleted when importing to the xls file

Laravel version 5.4
Expected behaviour
Actual behaviour
Steps to reproduce the behaviour
$sheet->setColumnFormat(array(
'A' => '#'
));
foreach ($order_details as $key => $detail) {
$sheet->appendRow([(string)$detail->model->id_supplier, $detail->model->mintitle, $detail->qty, $detail->price, $detail->qty * $detail->price,]);
$sheet->setHeight($sheet->getHighestRow(), 45);
}
How to import a number with a plus sign?
if that is microsoft excel, or some similar app; then it is not in your code, excel treats the +digit as a positive digit, and hence it removes the +, happens with the zeroes as well, try to include '' wrapper around your value to convert it to string and to prevent excel from doing so.
It happens because the number you expect was a positive digit(+49983), if you reproduce the number with + sign, it removes + sign while displaying in excel.,
To check open a new excel and try to add +49983 and move to next column, the + will automatically gone, because of the positive digit.

Ruby and TkText

I need to get data from text fields. I used TkText but could not pass it the argument 'textvariable'. This argument only works for Tk::Tile:Entry is a single line in height, and I need 3. I went to change settings for :rowspan when rendering 'Entry' widget, but it did not help.
$message = TkVariable.new
text = Tk::Tile::Entry.new(content) {
textvariable $message # not worked in TkText :(
width 1
font TkFont.new('bold times 12')
pack('side' => 'left', 'padx'=> '0', 'pady'=> '0')
}
How it to make?
The text widget has a get method, which takes two indices that describe a region to get. The first character is the string 1.0, and the last character is the string end-1c (technically, the last character in the widget is end, but tk always adds an extra newline at the end which you normally don't want to get)
My ruby is very rusty, but I think this will work:
data = text.get('1.0', 'end-1c')

How to solve invalid parameter error using Codeigniter and Pesapal

Am trying to test my payment module using codeigniter and pesapal but I keep getting this error "Problem: parameter_rejected | Advice: invalid_value_for_amount> oauth_parameters_rejected | Ksh.4%2C999".
Where Ksh. 4%2C999 is the bill ksh. 4999. I have used the right Pesapal keys so I don't know what am doing wrong.
Problem
Your amount has a thousand separator ... something like this Ksh.4,999 instead of passing a value that's an integer like 4999.
Either you are passing in the amount with the comma (which you can fix by removing the comma in your logic) or the number_format() method is adding the thousand separator (explanation given below in solution).
Solution
According to the PHP docs number_format() does something like this (basic case only)...
// english notation (default)
$english_format_number = number_format($number);
// 1,235
Note how it's added a , as the thousand separator. This is what is being converted(encoded) to %2C. Pesapal doesn't understand numbers with the , which is what you are passing to them. ... to stop the function from using the thousands operator do something like this ...
// english notation without thousands separator
$english_format_number = number_format($number, 2, '.', '');
// 1234.57
3rd parameter specifies the decimal separator (which is .) and the 4th specifies the thousand separator (which is an empty string).
But as #BabyAzerty has said, without code there's nothing much that we can work with to assist you. I'll amend the answer the more context you give to your problem but the above is pretty much what I've seen wrong with your implementation elaborated in the question and comment above.
$amount1 = (integer)$data->amount;
$amount = number_format($amount1, 2, '.', '');//format amount to 2 decimal places
$desc = $data->phone_type;
$type = "MERCHANT"; //default value = MERCHANT
$reference = $data->reference;//unique order id of the transaction, generated by merchant
$first_name = $data->name1;
$last_name = $data->name2;
$email = $data->email;
$phonenumber = $data->mobile;//ONE of email or phonenumber is required
This error means that your account on Pesapal has a limit on the amount it can transact. By default the amount is usually set to USD 10 or the equivalent of it in local currency.
You need to contact the team at support.pesapal.com to complete your sign-up by submitting contract and documents for your business in order to have the account activate for full transactions.

Characters with accent counted as two characters in configurable products

We sell configurable products that require a text field with a character limit (we sell personalized bracelets with customer's name on it).
So, we created on our product page a text field with 15 characters limit.
It is perfectly working if I put in this feld for example : "abcdefghijklmno" (which is 15 letters).
But if I put "abcdéfghijklmno" (which still is 15 letters but with the "e" acute), it just won't work, it says "please specify product option".
After a few tests, I found out that letters with accents are counted as 2 characters.
How can I avoid this error ?
This is most likely an issue of character encoding — UTF-8 vs Latin1, for example.
You don't mention what programming language you're using. Taking a guess that it's a web app and odds that it's PHP, you may be able to use mb_strlen (which counts characters) instead of strlen (which counts bytes).
If it's not PHP, other programming languages have similar functions to count characters instead of bytes.
É É É
Wrap your variable with html_entity_decode($string);
$example = html_entity_decode("abcdéfghijklmno");
print_r($example);
Try to learn htmlentities and html_entity_decode
if you want to replace all acutes,
you must make a list and str_replace it before specify product option
url_encode
I found the solution thanks to you too :
You have to edit this file : app/code/core/Mage/Catalog/Model/Product/Option/Type/Text.php
replace (around line 49) :
if (strlen($value) == 0 && $option->getIsRequire() && !$this->getProduct()->getSkipCheckRequiredOption()) {
$this->setIsValid(false);
Mage::throwException(Mage::helper('catalog')->__('Please specify the product\'s required option(s).'));
}
if (strlen($value) > $option->getMaxCharacters() && $option->getMaxCharacters() > 0) {
$this->setIsValid(false);
Mage::throwException(Mage::helper('catalog')->__('The text is too long'));
by :
if (mb_strlen($value,'UTF-8') == 0 && $option->getIsRequire() && !$this->getProduct()->getSkipCheckRequiredOption()) {
$this->setIsValid(false);
Mage::throwException(Mage::helper('catalog')->__('Please specify the product\'s required option(s).'));
}
if (mb_strlen($value,'UTF-8') > $option->getMaxCharacters() && $option->getMaxCharacters() > 0) {
$this->setIsValid(false);
Mage::throwException(Mage::helper('catalog')->__('The text is too long'));

jqGrid record count has space before the thousands digit

When the record count in jqGrid exceeds 1000, there is a visible space between the hundreds and thousands digits. See image below (taken from the jqGrid demo page)
alt text http://img180.imageshack.us/img180/3066/jqgridspace.png
Is there a way to remove this space, or replace it with with a standard thousands separator (comma or other)?
You can change the pre-defined formatter options. Here is a link:
EDIT:
Thought I'd give credit to Oleg and paste his comment below wherein he actually does the work to give the code from the documentation:
If you redefine $.jgrid.formatter.integer as following $.jgrid.formatter.integer = {thousandsSeparator: ""}; you will see all integers in jqGrid inclusive the total records number formated without blanks as the separator of thousands. – Oleg May 20 '10 at 8:52
Thanks, Oleg!
changed file grid.locale-en.js
from
integer : {thousandsSeparator: " ", defaultValue: '0'}
to
integer : {thousandsSeparator: ",", defaultValue: '0'}
to add comma "," as thousands separator

Resources