Archive for December, 2007

Apple Motion Text Scale Tip

I’ve been using Motion on and off for more than a year now and I’ve only just discovered this little quirk with text rendering - Point Size Affects Text Filters Quality.

When laying out text in a project I normally type the text using the text tool at something like 10pt and scale it up to the size that I think looks good. This works fine and looks great but as soon as you add a filter things can go wonky. It appears that when you scale up text using the distort nodes it doesn’t change the point size so filters are applied as if the text is still 10pt or whatever point you started at. So what does this mean? Basically the text changes from lovely clean vector shapes to ugly blocky bitmaps. Check out my example:

Bloom

Both Elephant text is the same text but the first one is scaled up and the second one is scaled down.. notice the bloom effect (with default settings) create a very different result!!

So what is the lesson learnt from all this? Don’t scale up text using the nodes.. scale text using its point size and you will have sharp looking effects text all the time!!! … unless of course you want blocky pixelated effects???

fckeditor delete file/folder

By default the fckeditor file browser that comes with it doesn't allow file deleting or folder deleting because of the security risk. Its a bit of a pain but it is possible to get the file browser to delete files. Here is how I went about it for php:

edit "editor/filemanager/connectors/php/commands.php" and add:

PHP:
  1. function DeleteFile( $resourceType, $currentFolder ) {
  2.     $file = $_SERVER['DOCUMENT_ROOT'].$_GET['FileUrl'];
  3.     if (is_file($file)) {
  4.         unlink($file);
  5.     } else {
  6.         echo '<error number="1" originaldescription="unable to locate file">' ;
  7.     }
  8. }
  9. function DeleteFolder( $resourceType, $currentFolder ) {
  10.     $folder = $_SERVER['DOCUMENT_ROOT'].$_GET['FolderName'];
  11.     if (is_dir($folder) )   {
  12.         DELETE_RECURSIVE_DIRS($folder);
  13.     } else {
  14.         echo '<error number="2" originaldescription="unable to locate folder">' ;
  15.     }
  16. }
  17. function DELETE_RECURSIVE_DIRS($dirname) { // recursive function to delete
  18.     // all subdirectories and contents:
  19.     if(is_dir($dirname))$dir_handle=opendir($dirname);
  20.     while($file=readdir($dir_handle)) {
  21.         if($file!="." && $file!="..") {
  22.             if(!is_dir($dirname."/".$file)) {
  23.                 unlink ($dirname."/".$file);
  24.             } else {
  25.                 DELETE_RECURSIVE_DIRS($dirname."/".$file);
  26.             }
  27.         }
  28.     }
  29.     closedir($dir_handle);
  30.     rmdir($dirname);
  31. }

modify editor/filemanager/connectors/php/connector.php so that the command switch looks like this:

PHP:
  1. switch ( $sCommand ) {
  2.     case 'GetFolders' :
  3.         GetFolders( $sResourceType, $sCurrentFolder ) ;
  4.     break ;
  5.     case 'GetFoldersAndFiles' :
  6.     GetFoldersAndFiles( $sResourceType, $sCurrentFolder ) ;
  7.     break ;
  8.     case 'CreateFolder' :
  9.         CreateFolder( $sResourceType, $sCurrentFolder ) ;
  10.     break ;
  11.     /******ADDED DELETE COMMANDS******/
  12.     case 'DeleteFile' :
  13.         DeleteFile( $sResourceType, $sCurrentFolder ) ;
  14.     break ;
  15.     case 'DeleteFolder' :
  16.         DeleteFolder( $sResourceType, $sCurrentFolder ) ;
  17.     break ;
  18. }

modify editor/filemanager/connectors/php/config.php allowed commands:

PHP:
  1. $Config['ConfigAllowedCommands'] = array('QuickUpload', 'FileUpload', 'GetFolders', 'GetFoldersAndFiles', 'CreateFolder', 'DeleteFile', 'DeleteFolder') ;

You will also need to make sure that this connector is enabled in this file also but you knew that already didn't you?

PHP:
  1. $Config['Enabled'] = true ;

modify editor/filemanager/browser/default/frmresourceslist.html.html so that the functions look like this:

PHP:
  1. oListManager.GetFolderRowHtml = function( folderName, folderPath, folderUrl ) //added folderUrl
  2. {   
  3.     // Build the link to view the folder.
  4.     var sLink = '<a href="#" onclick="OpenFolder(\'' + folderPath.replace( /'/g, '\\\'') + '\');return false;">' ;
  5.  
  6.     return '<tr>' +
  7.             '<td width="16">' +
  8.                 sLink +
  9.                 '<img alt="" src="images/Folder.gif" width="16" height="16" border="0"></a>' +
  10.             '</td><td nowrap colspan="2">&nbsp;' +
  11.                 sLink +
  12.                 folderName +
  13.                 '</a>' +
  14.         '</td><td align="right"><a href="#" onclick="DeleteFolder(\''+folderName+'\',\''+ folderUrl.replace( /'/g, '\\\'') + '\');return false;">DELETE</a></td></tr>' ;
  15. }
  16.  
  17. oListManager.GetFileRowHtml = function( fileName, fileUrl, fileSize )
  18. {      
  19.     // Build the link to view the folder.
  20.     var sLink = '<a href="#" onclick="OpenFile(\'' + fileUrl.replace( /'/g, '\\\'') + '\');return false;">' ;
  21.  
  22.     // Get the file icon.
  23.     var sIcon = oIcons.GetIcon( fileName ) ;
  24.  
  25.     return '<tr>' +
  26.             '<td width="16">' +
  27.                 sLink +
  28.                 '<img src="'+fileUrl+'" border="0" style="border:1px solid black; margin:5px;" alt="" height="70" /></a>' +
  29.             '</td><td>&nbsp;' +
  30.                 sLink +
  31.                 fileName +
  32.                 '</a>' +
  33.             '</td><td align="right" nowrap>&nbsp;' +
  34.                 fileSize +
  35.                 ' KB' +
  36.         '</td><td align="right"><a href="#" onclick="DeleteFile(\''+fileName+'\',\'' + fileUrl.replace( /'/g, '\\\'') + '\');return false;">DELETE</a></td></tr>' ;
  37. }
  38.  
  39. function DeleteFile( fileName, fileUrl )
  40. {
  41.     if (confirm('Are you sure you wish to delete ' + fileName + '?')) {
  42.         oConnector.SendCommand( 'DeleteFile', "FileUrl=" + escape( fileUrl ), Refresh ) ;
  43.     }
  44.  
  45. }
  46.  
  47. function DeleteFolder( folderName, folderPath )
  48. {
  49.     if (confirm('Are you sure you wish to delete \'' + folderName + '\' and all files in it?')) {
  50.         oConnector.SendCommand( 'DeleteFolder', "FolderName=" + escape( folderPath + folderName ), Refresh ) ;
  51.     }
  52. }

*NOTE* This will also show a thumbnail image - you can change the function to turn this off if you want *NOTE*
oh and also in the function modify this..

PHP:
  1. oHtml.Append( oListManager.GetFolderRowHtml( sFolderName, sCurrentFolderPath + sFolderName + "/" ) ) ;

to be this...

PHP:
  1. oHtml.Append( oListManager.GetFolderRowHtml( sFolderName, sCurrentFolderPath + sFolderName + "/", sCurrentFolderUrl ) ) ;

I think that is all.. if I missed anything let me know and I will update this quide.