This Question is Resolved.

If you have a similiar issue that this thread does not address, click the button below to open a new related support topic.

 
 
Forum Feeds stop working when extension using typography_parse_type_start is enabled.
Posted: 24 November 2008 02:05 PM   [ Ignore ]  
Grad Student
Rank
Total Posts:  72
Joined  05-04-2007

Related thread : http://expressionengine.com/forums/viewthread/97703/

Hello,

I have a simple extension on the site Ocean Rodeo Forums which ads the path of phpThumb to the front of any image that is attached to a forum thread. When the extension is enabled, all images in the forum are resized on the fly to a maximum of 600px and cached locally:

Final result if <img /> tag looks like this:

<img src="/_inc/phpthumb/phpThumb.php?w=700&amp;q=70&amp;src=http://farm2.static.flickr.com/1356/1311955635_e6adac5a42_b.jpg"  alt='1311955635_e6adac5a42_b.jpg' />

We do this as a lot of people were uploading very large images which were difficult to view in the forums. The extension does its job, however the forum feeds stop working when I enable the extension. If I disable the extension the forum feeds work again.

This is my first extension, so the answer will most likely be quite obvious to someone with a wee bit more experience than myself. Here is the code I wrote:

<?php
/*
* Add phpthumb resizing to [img][/img] tags for ExpressionEngine
*
* @package ooc_phpThumbImg
* @version 0.0.1
* @author James Riordon <http://outofcontrol.ca>
* @see http://www.outofcontrol.ca/extensions/phpThumb_img
* @copyright Copyright (c)2008 James Riordon
* @license {@link http://creativecommons.org/licenses/by-sa/3.0/ Creative Commons Attribution-Share Alike 3.0 Unported} All source code commenting and attribution must not be removed. This is a condition of the attribution clause of the license.
*/

if ( ! defined('EXT')) exit('Invalid file request');


class
ooc_phpthumb_img
{

    
var $settings         = array();
    var
$name            = 'phpThumb IMG';
    var
$version        = '0.0.1';
    var
$description    = 'Write [img] tag to include phpthumbs.php prefix.';
    var
$settings_exist    = 'y';
    var
$docs_url        = 'http://www.outofcontrol.ca/extensions/phpThumb_img/docs';
    
    var
$max_width        = '700';
    var
$image_quality    = '70'; // From 0 - 100 for jpeg compression. 0 being worst.
    
var $phpThumb_path    = '/_inc/phpthumb/';
    var
$phpThumb_script_name    = 'phpThumb.php';
    
    
/**
    * PHP5 Constructor
    *
    * @param    array|string $settings Extension settings associative array or an empty string
    */
    
function __construct($settings='')
    
{
        $this
->settings = $settings;
    
}
    
    
/**
    * PHP4 Constructor
    *
    * @see __construct()
    */
    
function ooc_phpthumb_img($settings='')
    
{
    
        
return __construct($settings);
    
}
    
    
function settings()
    
{
        
global $LANG;

        
$settings = array();
        
        
$settings['max_width'] = '600';
        
$settings['image_quality'] = '70';
        
$settings['phpThumb_path'] = '/phpthumb/';
        
$settings['phpThumb_scriptName'] = 'phpThumb.php';
        
        return
$settings;
    
}
    
    
function activate_extension()
    
{
        
global $DB;
        
        
$DB->query($DB->insert_string('exp_extensions',
                                        array (
                                                
'extension_id'    => '',
                                                
'class'            => 'ooc_phpthumb_img',
                                                
'method'        => 'alter_img_tag',
                                                
'hook'            => 'typography_parse_type_start',
                                                
'settings'        => '',
                                                
'priority'        => '10',
                                                
'version'        => $this->version,
                                                
'enabled'        => 'y'
                                        
)
                                    )
                    );
    
}
    
    
function alter_img_tag($str, $self, $prefs)
    
{
        $phpThumb_path
= $this->phpThumb_path . $this->phpThumb_script_name . '?w=' . $this->max_width . '&q=' . $this->image_quality . '&src;=';
        
        
// Do not modify if phpThumb is already used.
        
if (strpos($phpThumb_path, $str))
        
{
            
return $str;
        
}
        $from_pattern
= '[img]';
        
$to_pattern = '[img]' . $phpThumb_path;
        
        return
str_replace($from_pattern,$to_pattern,$str);
        
    
}

    
function update_extension($current='')
    
{
        
global $DB;
        
        if (
$current == '' OR $current == $this->version)
        
{
            
return false;
        
}
        
        $DB
->query("UPDATE exp_extensions
                    SET version = '"
. $DB->escape_str($this->version) . "'
                    WHERE class = 'ooc_phpthumb_img'"
);
    
}

    
function disable_extension()
    
{
        
global $DB;
        
        
$DB->query("DELETE FROM exp_extensions WHERE class = 'ooc_phpthumb_img'");
    
}
}

?>

 Signature 

Out of Control™ - Keeping you in control
Find Mac Stuff - Your Mac product homepage finder

Profile
 
 
Posted: 24 November 2008 03:24 PM   [ Ignore ]   [ # 1 ]  
Grad Student
Rank
Total Posts:  72
Joined  05-04-2007

After a little more research, I get the following error from EE core when my extension is enabled:

Fatal error: Call to undefined method: stdClass->log_item() in /homepages/24/d216939193/htdocs/dojohints.com/html/content_mgt/core/core.extensions.php on line 253

Not sure why I get this. Do I need to instantiate the stdClass in my extension?

 Signature 

Out of Control™ - Keeping you in control
Find Mac Stuff - Your Mac product homepage finder

Profile
 
 
Posted: 24 November 2008 03:58 PM   [ Ignore ]   [ # 2 ]  
Grad Student
Rank
Total Posts:  72
Joined  05-04-2007

I have gone about as far as I can. My extension has been tested on EE 1.6.3 and EE 1.6.6.

If I comment out line 253 in core.extensions.php then everything works as expected with my plugin enabled, which obviously is not what the solution should be.

Forum is v2.1.0 and v2.1.1.

 Signature 

Out of Control™ - Keeping you in control
Find Mac Stuff - Your Mac product homepage finder

Profile
 
 
Posted: 26 November 2008 04:39 PM   [ Ignore ]   [ # 3 ]  
Moderator
Avatar
RankRankRankRankRankRankRank
Total Posts:  23744
Joined  05-20-2002

It looks like you’ve spotted a fairly obscure bug, plattapuss.  The fix is easy, and as soon as it’s been committed I’ll update you on the outcome.  For now, I’ll go ahead and shift this to the bug forum.

Oh- and just a quick note- the closer you stay to the API on things such as naming convensions, the easier things will be.  I cleaned up a few things in the above before testing to reduce the possibility of errors.  Check out the naming guidelines if you haven’t already.

And thinks again for bringing this to our attention.

 Signature 

AKA rob1

Help Request TipsPro Network

Profile
 
 
Posted: 26 November 2008 05:17 PM   [ Ignore ]   [ # 4 ]  
Grad Student
Rank
Total Posts:  72
Joined  05-04-2007

Ah cool, I found a bug. Well, you know what I mean. wink

I have been using Zend Framework and looking at Code Igniter, mixed with my own bad programming methodologies, in the end I get confused on naming conventions *sigh*. Too much stuff in my head.

 Signature 

Out of Control™ - Keeping you in control
Find Mac Stuff - Your Mac product homepage finder

Profile
 
 
Posted: 03 December 2008 11:43 AM   [ Ignore ]   [ # 5 ]  
Moderator
Avatar
RankRankRankRankRankRankRank
Total Posts:  23744
Joined  05-20-2002

A bug indeed.  A fix has been committed- we tweaked core.extensions.php around line 251:

if (is_object($TMPL) && method_exists($TMPL, 'log_item'))


The check for method_exists wasn’t in there before- hence your difficulties.  The next update should see your extension behaving normally on the rss page!  Thanks for spotting the bug and sorry it caused confusion!

 Signature 

AKA rob1

Help Request TipsPro Network

Profile
 
 
 

This Question is Resolved.

If you have a similiar issue that this thread does not address, click the button below to open a new related support topic.

 
 
 
Post Marker Legend
New Topic New posts Hot Topic Hot Topic with new posts New Poll New Poll Moved Topic Moved Topic Sticky Topic Sticky topic
Old Topic No new posts Hot Old Topic Hot Topic with no new posts Old Poll Old Poll Closed Topic Closed Topic Announcement Announcements
Theme
Change Theme
Visitor Statistics
The most visitors ever was 1149, on July 16, 2007 09:33 AM
Total Registered Members: 66391 Total Logged-in Users: 44
Total Topics: 84715 Total Anonymous Users: 15
Total Replies: 454694 Total Guests: 169
Total Posts: 539409    
Members ( View Memberlist )