Image Text 0.2

Have a question or a suggestion about a 3rd party addon module or plugin?
Let us know here.
megabob3
Power Poster
Power Poster
Posts: 498
Joined: Sat Jan 08, 2005 11:11 pm
Location: ITALY

Image Text 0.2

Post by megabob3 »

Download link

http://www.awakening.it/test/uploads/Im ... _0_2_1.zip

Did the ADMIN panel.

Next step learn more about smarty function integration on CMSMS, and permit the ImageText of {title} or something else.

Future step, don't use it as a plugin but like a real module.

You can view it here:
http://www.awakening.it/test/index.php?page=qwe

To access on administration
user: admin
pass: admin


Bye :)
Last edited by megabob3 on Sat Apr 16, 2005 9:47 pm, edited 1 time in total.
100rk

Re: Image Text 0.2

Post by 100rk »

Nice work! ;-)
megabob3
Power Poster
Power Poster
Posts: 498
Joined: Sat Jan 08, 2005 11:11 pm
Location: ITALY

Re: Image Text 0.2

Post by megabob3 »

100rk wrote: Nice work! ;-)
Thx :D
Olaf
Forum Members
Forum Members
Posts: 32
Joined: Sun Jan 23, 2005 12:31 pm
Location: Amsterdam

Re: Image Text 0.2

Post by Olaf »

Good work!!!
Found a way already to use it in the menu / title?
megabob3
Power Poster
Power Poster
Posts: 498
Joined: Sat Jan 08, 2005 11:11 pm
Location: ITALY

Re: Image Text 0.2

Post by megabob3 »

Olaf wrote: Good work!!!
Found a way already to use it in the menu / title?
You refer on {title} or insiede PHPLayers MENU??

If {title} i did it, with a query on DB
new function.imagetext.php is

Code: Select all

<?php
/*
 * Smarty plugin
 * -------------------------------------------------------------
 * File:     function.text.php
 * Purpose:  creates graphical headlines
 *
 * Author:   Christoph Erdmann <mail@cerdmann.com>
 * Version:  26.11.2004
 * Internet: http://www.cerdmann.com
 *
 * Changelog:
 * 2004-11-28 New "html"-paramter to use additional HTML-attributes
 * 2004-11-28 New "dynamic"-paramter recreates images without waste files
 * 2004-11-26 Some Change in structure, better documentation, better error-handling
 * 2004-11-25 Support for prehtml and posthtml
 * -------------------------------------------------------------
 */

// Todo:

if (!isset($smarty->imagetextcount)) $smarty->imagetextcount = 0;

function smarty_function_imagetext($params, &$smarty)
	{

        if(isset($params['now'])){
                if(isset($params['format']))
                  $format = $params['format'];
                else
		  $format = '%Y-%m-%d %H:%M:%S %z';
                $params['text'] = strftime($format,time());
        }


        if(isset($params['title'])){
          global $gCms;
          $params['text'] = strtoupper($gCms->variables[page_name]);


          $query  = "SELECT `content_name` FROM `".$gCms->config["db_prefix"]."content` WHERE ";
          $query .= "`content_alias` = '".$params['text']."'";
          $query .= " LIMIT 1;";
          $dbresult = $gCms->db->Execute($query);
          
          $params['text'] = " ";
          while ($row = $dbresult->FetchRow()) {
              $params['text'] = $row["content_name"];
          }
        

        }



### Voreinstellungen
	// Config einlesen

	$config = parse_ini_file('modules/ImageText/textcache/styles.ini',true);
	$config['main']['folder']	= 'modules/ImageText/textcache/';
	$config['main']['fonts']	= 'modules/ImageText/textcache/fonts/';
	$config['main']['cache']	= 'modules/ImageText/textcache/cache/'; 
// Nur dieser Ordner muss ffentlich zug?lich sein

	// Welcher Style soll verwendet werden
	$style = $config[$params['style']];
	// Params-Werte berschreiben style-werte (Den "text"-Wert aus Style herausnehmen)
	foreach ($params as $key=>$value) if ($key != 'text') $style[$key] = $value;

	// Fehlerhafte Eingaben abfangen
    if (empty($params['text'])) { $smarty->trigger_error("imagetext: missing 'text' parameter"); return; }
    if (empty($params['style'])) { $smarty->trigger_error("imagetext: missing 'style' parameter"); return; }
    if (empty($style['font'])) { $smarty->trigger_error("imagetext: missing 'font' parameter"); return; }
    if (empty($style['size'])) { $smarty->trigger_error("imagetext: missing 'size' parameter"); return; }
    if (empty($style['bgcolor'])) { $smarty->trigger_error("imagetext: missing 'bgcolor' parameter"); return; }
    if (empty($style['fgcolor'])) { $smarty->trigger_error("imagetext: missing 'fgcolor' parameter"); return; }
    if (empty($style['width'])) { $smarty->trigger_error("imagetext: missing 'width' parameter"); return; }
    if (empty($style['height'])) { $smarty->trigger_error("imagetext: missing 'height' parameter"); return; }

	// Welche Schrift soll verwendet werden
	$font = $config['main']['fonts'].$style['font'];
	// Hash des Textes sowie aller Paramter fr die Cache-Funktion
	$hash = md5(implode('',$style).$params['text']);
	// Die URL des zu erstellenden Bildes
	$imgurl	= $config['main']['cache'].$params['style'].'_'.$hash.'.gif';
	// Die URL ?ert sich bei dynamischen Bildern
	if (empty($style['fname'])){
	if ($style['dynamic'] OR $style['dev'])
		{
		$hash = md5(implode('',$style).$smarty->imagetextcount);
		$imgurl	= $config['main']['cache'].$smarty->imagetextcount.'_'.$hash.'.gif';
		$smarty->imagetextcount++;
		}
	}
	else {
    $imgurl	= $config['main']['cache'].$style['fname'].'.gif';
  }
		

### Bei Bedarf gecachtes Bild ausgeben
	if (file_exists($imgurl) && $style['dev'] != true && $style['dynamic'] != true) return $style['prehtml'].'<img src="'.$imgurl.'" border="0" alt="'.$params['text'].'" '.$style['html'].' />'.$style['posthtml'];


### ansonsten neu erstellen
	// Funktion, um aus Hex-Werten RGB-Werte zu gewinnen und einen Farb-Handler zurckzugeben
	if (!function_exists('fromhex'))
		{
		function fromhex($image,$string) {
			sscanf($string, "%2x%2x%2x", $red, $green, $blue);
			return ImageColorAllocate($image,$red,$green,$blue);
			}
   		}
		
	### Zuersteinmal ein viermal so gro?s Bild erstellen, welches danach heruntergerechnet wird, um das Kerning zu verbessern
	// Der Multiplikator. Je gr?r, desto besser das Kerning, aber desto langsamer das Ertellen
	$multi = 4;

	// Ausma? der Grafik ausrechnen
	$bbox = imageftbbox ($style['size']*$multi, 0, $font, $params['text']);
	
	$xcorr=0-$bbox[6]; // northwest X
	$ycorr=0-$bbox[7]; // northwest Y
	$box['left']=$bbox[6]+$xcorr;
	$box['height']=abs($bbox[5])+abs($bbox[1]);
	$box['width']=abs($bbox[2])+abs($bbox[0]);
	$box['top'] = abs($bbox[5]);

	// Nun das erste gro? Bild erstellen
	$im = imagecreate ($box['width'], $box['height']);
	$bgcolor = fromhex($im,$style['bgcolor']);
	$fgcolor = fromhex($im,$style['fgcolor']);
	imagettftext ($im, $style['size']*$multi, 0, $box['left'], $box['top'], $fgcolor, $font, $params['text']);
	
	// Jetzt das gro? Bild heruntersamplen
	if ($style['trim']) $ds = imagecreatetruecolor ($box['width']/$multi+$params['addx'], $style['height']);
	else $ds = imagecreatetruecolor ($style['width'], $style['height']);
	$bgcolor2 = fromhex($ds,$style['bgcolor']);
	imageFill($ds,0,0,$bgcolor2);
	imagecopyresampled($ds,$im,0,$style['y'],0,0,$box['width']/$multi, $box['height']/$multi,$box['width'], $box['height']);
	imagetruecolortopalette($ds,0,256);
	imagepalettecopy($ds,$im);
	ImageColorTransparent($ds,$bgcolor);

   	// Wohin schreiben
	ImageGIF ($ds,$imgurl);
	ImageDestroy ($im);
	ImageDestroy ($ds);

	// und ausgeben
	if ($style['dev']) $border = 1; else $border = 0;
	return $style['prehtml'].'<img src="'.$imgurl.'" style="border: '.$border.'px solid #00ff00" alt="'.$params['text'].'" '.$style['html'].' />'.$style['posthtml'];
	}
?>
for the other i don't now :D
Olaf
Forum Members
Forum Members
Posts: 32
Joined: Sun Jan 23, 2005 12:31 pm
Location: Amsterdam

Re: Image Text 0.2

Post by Olaf »

Roberto, you are superb! I'll try it.

Btw; little comment;  in Imagetext.module.php (0_2_3) I had to change line 20
require_once("modulefunctions.php");
in

require_once(dirname(__FILE__)."/modulefunctions.php");

to get it to work on my install.

Keep up the good work!
megabob3
Power Poster
Power Poster
Posts: 498
Joined: Sat Jan 08, 2005 11:11 pm
Location: ITALY

Re: Image Text 0.2

Post by megabob3 »

Olaf wrote: Roberto, you are superb! I'll try it.

Btw; little comment;  in Imagetext.module.php (0_2_3) I had to change line 20
require_once("modulefunctions.php");
in

require_once(dirname(__FILE__)."/modulefunctions.php");

to get it to work on my install.

Keep up the good work!
I am happy and thx with your response, i am learning ALOT with CMSMS :D
jah
Forum Members
Forum Members
Posts: 147
Joined: Thu Dec 30, 2004 9:09 am
Location: Norway

Re: Image Text 0.2

Post by jah »

I just tested out the ImageText module on your pages and it sure looks good!

Thanks Roberto!
megabob3
Power Poster
Power Poster
Posts: 498
Joined: Sat Jan 08, 2005 11:11 pm
Location: ITALY

Re: Image Text 0.2

Post by megabob3 »

jah wrote: I just tested out the ImageText module on your pages and it sure looks good!

Thanks Roberto!
I saw :D, "Mi piacce multo il tuo italiano!" :D

Enjoy it ;)
Olaf
Forum Members
Forum Members
Posts: 32
Joined: Sun Jan 23, 2005 12:31 pm
Location: Amsterdam

Stronza!

Post by Olaf »

Hi Roberto, tried to install imagetext on a  new site. The old one on which it worked is gone. I cannot remember and find out what I had changed to get it it to work again. I think I changed some smarty files at the time also. Would be easier if I learned how to program myself...
I just need scripts that work with a clean install of cmsms on a domain on a shared server. Can you help me?

Grtz!
Olaf
megabob3
Power Poster
Power Poster
Posts: 498
Joined: Sat Jan 08, 2005 11:11 pm
Location: ITALY

Re: Stronza!

Post by megabob3 »

Olaf wrote: Hi Roberto, tried to install imagetext on a  new site. The old one on which it worked is gone. I cannot remember and find out what I had changed to get it it to work again. I think I changed some smarty files at the time also. Would be easier if I learned how to program myself...
I just need scripts that work with a clean install of cmsms on a domain on a shared server. Can you help me?

Grtz!
Olaf
Hi,
  my last version of it is this www.awakening.it/test/modules/ImageText.zip and i guess is the same of the file present on WIKI http://wiki.cmsmadesimple.org/tiki-inde ... ed+Modules
http://wiki.cmsmadesimple.org/tiki-down ... p?attId=63

What version of CMSMS are you using? These version go on 0.9.2, i never tested ImageText on 0.10.4

I am doing that in these days.

Bye :)
psy
Power Poster
Power Poster
Posts: 463
Joined: Sat Jan 22, 2005 11:19 am

Re: Image Text 0.2

Post by psy »

Great stuff Megabob,

I use Imagetext one site and now want to include it on a CMSMS site but have forgotten how to install a new module.  I put the Imagetext folder in the modules dir but then what next?

psy
psy
Power Poster
Power Poster
Posts: 463
Joined: Sat Jan 22, 2005 11:19 am

Re: Image Text 0.2

Post by psy »

Hello Patricia

extensions->modules?

I went to plugin management but imagetext did not appear in the list of modules, installed or otherwise.  I have it working now (fabulous) but it doesn't appear anywhere in the list of modules installed or otherwise.

This site has been on the backburner for a while.  Maybe it has something to do with the version:

$CMS_VERSION = "0.8.1";
$CMS_VERSION_NAME = "Papeete";
$CMS_SCHEMA_VERSION = "9";
megabob3
Power Poster
Power Poster
Posts: 498
Joined: Sat Jan 08, 2005 11:11 pm
Location: ITALY

Re: Image Text 0.2

Post by megabob3 »

Patricia wrote: Bob: on 0.10, just the display in admin is not very easy to read (no padding in table cells), but everything goes well. I also had to create the folder cache here "ImageText/textcache/cache" as it isn't provided in the zip. I tested on local (windows) so no permission problem, but I guess on unix server, we have to chmod it to write permission... i will test online a bit later, but it would be good if the folder is already included.

it's a great one! I will use it on the site I'm currently working on (nocturnalhorde.com)
Thanks for it
Thanks i will modify it!! ;)
psy
Power Poster
Power Poster
Posts: 463
Joined: Sat Jan 22, 2005 11:19 am

Re: Image Text 0.2

Post by psy »

some feedback fyi....

I upgraded my site to cmsms v.10 but the ImageText mod didn't upgrade.  At least I couldn't find where/how to upgrade it from extensions->modules.  It did however allow me to install it.

It seemed to install a bit of a mix.  When I went to ImageText admin, it listed the styles and about 1000 lines of text that included just about every variable about the site, including login details etc.  hrrmmm...

The page templates only worked with {imagetext...}, not {cms_module module="imagetext"...}.  The fix was simple.  Manually delete ALL imagetext files from the site, upload and install the new ones.  It then all magically worked.

It's a great feature and thanks Megabob for adding it to cmsms.

Cheers
psy
Locked

Return to “Modules/Add-Ons”