CMS MADE SIMPLE FORGE

TruetypeText

 

[#3749] Add override place for hand-made text-replacement images

avatar
Created By: Rick Beton (rickb)
Date Submitted: 2009-07-18 11:08

Assigned To:
Resolution: Won't Fix
State: Open
Summary:
Add override place for hand-made text-replacement images
Detailed Description:
Some pages be special and may need hand-edited truetypetext images.  This is
quite easy to support by looking in a separate location before checking the
cache for existing files.

History

Comments
avatar
Date: 2009-07-18 11:13
Posted By: Rick Beton (rickb)

I made the following change to class.style.php to try out this suggestion. 
Please feel free to incorporate this work.

@@ -212,21 +214,26 @@
 		}
 		if (count($this->elements)==0)
 			return '<!-- TruetypeText error : empty style -->'.$text;
-		$filepath = cms_join_path('cache',
$this->getCacheName($text).'.'.$this->format);
-		$fileabsolutepath = cms_join_path(dirname(__FILE__), $filepath);
+		$filename = $this->getCacheName($text).'.'.$this->format;
+		$filepath = '../../uploads/handmadettt/'.$filename;
+		$fileabsolutepath = dirname(__FILE__) .'/'. $filepath;
+		$exists = true;
 		if (!file_exists($fileabsolutepath))
-			$result = $this->createImage($text, $fileabsolutepath);
-		else
-			$result = true;
-		if ($result)
 		{
+	        $filepath = 'cache/'.$filename;
+		    $fileabsolutepath = dirname(__FILE__) .'/'. $filepath;
+		    if (!file_exists($fileabsolutepath))
+			    $exists = $this->createImage($text, $fileabsolutepath);
+		}
+		if ($exists)
+		{
 			$size = @getimagesize($fileabsolutepath);
 			global $CMS_ADMIN_PAGE;
 			if (isset($CMS_ADMIN_PAGE))
-				$filepath = cms_join_path('..','modules','TruetypeText',$filepath);
+				$filepath = '../modules/TruetypeText/'.$filepath;
 			else
-				$filepath = cms_join_path('modules','TruetypeText',$filepath);
-			return ($result ? '<img src="'.$filepath.'" alt="'.$text.'" '.$size[3].'/>'
: $text);
+				$filepath = 'modules/TruetypeText/'.$filepath;
+			return ($exists ? '<img src="'.$filepath.'" alt="'.$text.'" '.$size[3].'/>'
: $text);
 		}
 		else return '<!-- Truetypetext error -->'.$text;
 	}


*** Note that I removed some usage of cms_join_path, which was not correctly
used in this case because it returns a string containing DIRECTORY_SEPARATOR -
not valid in URLs.  In any case, forward slash always works even on Windows, so
there is no need to use DIRECTORY_SEPARATOR in PHP programs.  (Well, that's
unless you want to support Windows 95/98)
      
avatar
Date: 2011-12-31 12:52
Posted By: Jonathan Schmid (Foaly*)

the purpose of this module is to generate images, not to embed them.
      
Updates

Updated: 2011-12-31 12:52
resolution_id: 5 => 8

Updated: 2009-07-18 11:13
resolution_id: => 5