Archive for the 'Dev' Category

Add rel field attribute in FCKEditor when editing link attribute

Mercredi, août 25th, 2010

In fckeditor/fckeditor/editor/dialog/fck_link/fck_link.js, add the following:

[469] // Get Advances Attributes
GetE(’txtAttRelation’).value = oLink.rel ;

[764] // Advances Attributes
SetAttribute( oLink, ‘rel’ , GetE(’txtAttRelation’).value ) ;

And in fckeditor/fckeditor/editor/dialog/fck_link.html, add the following:


<table cellspacing=”0″ cellpadding=”0″ width=”100%” align=”center” border=”0″>
<tr>
<td>
<span fckLang=”DlgGenRel”>Relation</span><br />
<input id=”txtAttRelation” style=”WIDTH: 100%” type=”text” />
</td>
</tr>
</table>

In fckeditor/fckeditor/editor/lang > your language file.

In “// General Dialogs Labels”, put something like:
DlgGenRel : “Rel-tag”,

Source

Html to Pdf

Dimanche, juillet 4th, 2010

Some ideas… If you already use one of them, please leave your feedback !

  1. http://html2pdf.fr
  2. http://code.google.com/p/wkhtmltopdf/

Regexp cheat sheet

Mardi, juin 1st, 2010

http://www.autohotkey.com/docs/misc/RegEx-QuickRef.htm

PHP fgets doesn’t detect end of line

Dimanche, mai 23rd, 2010

If you parse some files, you can get an issue with fgets not detecting end of lines…

In my case, files come from mac users, so I have to enable this option :

ini_set(’auto_detect_line_endings’, true);

Php documentation here : http://us2.php.net/manual/en/filesystem.configuration.php#ini.auto-detect-line-endings

Get website speed loading

Mardi, mai 18th, 2010

http://gtmetrix.com

Mass deleting

Jeudi, avril 1st, 2010

If you want to delete files by size (here files of 912345 bytes):

find . -size 912345c -print -exec rm -f {} \;

CKeditor Internet Explorer Error Line 23 / 24

Dimanche, mars 21st, 2010

Be careful with CKeditor, if you get a javascript error “line 23″ or “line 24″ with “unsupported property or method” : CKeditor doesn’t like that your form had a submit button named “submit”

TCPDF : html content and href link empty

Samedi, mars 20th, 2010

If you get an issue with TCPDF and link inside html content, here is a little patch (apply it in tcpdf.php file) :

// get attributes
// patch
if ($dom[$key]['value']==’a')
{
$element = str_replace(’\\\”‘, ‘”‘, $element);
}

// en patch
preg_match_all(’/([^=\s]*)=["]?([^"]*)["]?/’, $element, $attr_array, PREG_PATTERN_ORDER);
$dom[$key]['attribute'] = array(); // reset attribute array
while (list($id, $name) = each($attr_array[1])) {
$dom[$key]['attribute'][strtolower($name)] = $attr_array[2][$id];
}

PHP Imagick black background gif transparency

Lundi, mars 8th, 2010

If you want to put a white background instead of black background, add this piece of code :

$path_parts = pathinfo($file);
if ($path_parts['extension']==’gif’)
{
$img = imagecreatefromgif($file);
$imgr = imagecreatetruecolor($neww, $newh);
$bgc = imagecolorallocate ($imgr, 255, 255, 255);
imagefilledrectangle ($imgr, 0, 0, $neww, $newh, $bgc);

imagecopyresampled($imgr, $img, 0, 0, 0, 0, $neww, $newh, $pixw, $pixh);
}

PHPMailer : inline image seen as attachment

Vendredi, mars 5th, 2010

There is an issue with PHPMailer and AddEmbeddedImage method.

In some email client, you will get image as an attachment and not inline as expected.

To fix that, patch the class.phpmailer.php with following :

$disposition = $this->attachment[$i][6];
$cid         = $this->attachment[$i][7];

// patch
$path_parts = pathinfo($filename);
$extension = $path_parts['extension'];
// end patch

$mime[] = sprintf(”–%s%s”, $this->boundary[1], $this->LE);

// patch
//$mime[] = sprintf(”Content-Type: %s; name=\”%s\”%s”, $type, $name, $this->LE);
$mime[] = sprintf(”Content-Type: image/”.$extension.”;\n”);
// end patch
$mime[] = sprintf(”Content-Transfer-Encoding: %s%s”, $encoding, $this->LE);

if($disposition == “inline”)
$mime[] = sprintf(”Content-ID: <%s>%s”, $cid, $this->LE);