Changeset 2356

Show
Ignore:
Timestamp:
05/16/08 07:45:14 (6 months ago)
Author:
takayama
Message:

Fixed BugId:79763
* When author object was not found in the context, try to load author object from entry in the context

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/release-38/lib/MT/Template/ContextHandlers.pm

    r2333 r2356  
    62736273sub _hdlr_author_id { 
    62746274    my ($ctx) = @_; 
    6275     my $author = $ctx->stash('author') 
    6276         or return $ctx->_no_author_error(); 
     6275    my $author = $ctx->stash('author'); 
     6276    unless ($author) { 
     6277        my $e = $ctx->stash('entry');  
     6278        $author = $e->author if $e;  
     6279    } 
     6280    return $ctx->_no_author_error() unless $author; 
    62776281    return $author->id; 
    62786282} 
     
    62906294sub _hdlr_author_name { 
    62916295    my ($ctx) = @_; 
    6292     my $author = $ctx->stash('author') 
    6293         or return $ctx->_no_author_error(); 
     6296    my $author = $ctx->stash('author'); 
     6297    unless ($author) { 
     6298        my $e = $ctx->stash('entry');  
     6299        $author = $e->author if $e;  
     6300    } 
     6301    return $ctx->_no_author_error() unless $author; 
    62946302    return $author->name; 
    62956303} 
     
    63096317        my $e = $ctx->stash('entry');  
    63106318        $a = $e->author if $e;  
    6311     }  
     6319    } 
    63126320    return $ctx->_no_author_error() unless $a; 
    63136321    return $a->nickname || MT->translate('(Display Name not set)', $a->id); 
    6314 }  
     6322} 
    63156323 
    63166324########################################################################### 
     
    63266334sub _hdlr_author_email { 
    63276335    my ($ctx, $args) = @_; 
    6328     my $author = $ctx->stash('author') 
    6329         or return $ctx->_no_author_error(); 
     6336    my $author = $ctx->stash('author'); 
     6337    unless ($author) { 
     6338        my $e = $ctx->stash('entry');  
     6339        $author = $e->author if $e;  
     6340    } 
     6341    return $ctx->_no_author_error() unless $author; 
    63306342    my $email = $author->email; 
    63316343    return '' unless defined $email; 
     
    63436355sub _hdlr_author_url { 
    63446356    my ($ctx) = @_; 
    6345     my $author = $ctx->stash('author') 
    6346         or return $ctx->_no_author_error(); 
     6357    my $author = $ctx->stash('author'); 
     6358    unless ($author) { 
     6359        my $e = $ctx->stash('entry');  
     6360        $author = $e->author if $e;  
     6361    } 
     6362    return $ctx->_no_author_error() unless $author; 
    63476363    my $url = $author->url; 
    63486364    return defined $url ? $url : ''; 
     
    63606376sub _hdlr_author_auth_type { 
    63616377    my ($ctx) = @_; 
    6362     my $author = $ctx->stash('author') 
    6363         or return $ctx->_no_author_error(); 
     6378    my $author = $ctx->stash('author'); 
     6379    unless ($author) { 
     6380        my $e = $ctx->stash('entry');  
     6381        $author = $e->author if $e;  
     6382    } 
     6383    return $ctx->_no_author_error() unless $author; 
    63646384    my $auth_type = $author->auth_type; 
    63656385    return defined $auth_type ? $auth_type : ''; 
     
    63996419sub _hdlr_author_auth_icon_url { 
    64006420    my ($ctx, $args) = @_; 
    6401     my $author = $ctx->stash('author') 
    6402         or return $ctx->_no_author_error(); 
     6421    my $author = $ctx->stash('author'); 
     6422    unless ($author) {  
     6423        my $e = $ctx->stash('entry');  
     6424        $author = $e->author if $e;  
     6425    } 
     6426    return $ctx->_no_author_error() unless $author; 
    64036427    my $size = $args->{size} || 'logo_small'; 
    64046428    return $author->auth_icon_url($size); 
     
    64196443sub _hdlr_author_userpic { 
    64206444    my ($ctx) = @_; 
    6421     my $author = $ctx->stash('author') 
    6422         or return $ctx->_no_author_error(); 
     6445    my $author = $ctx->stash('author'); 
     6446    unless ($author) { 
     6447        my $e = $ctx->stash('entry');  
     6448        $author = $e->author if $e;  
     6449    } 
     6450    return $ctx->_no_author_error() unless $author; 
    64236451    return $author->userpic_html() || ''; 
    64246452} 
     
    64376465sub _hdlr_author_userpic_url { 
    64386466    my ($ctx) = @_; 
    6439     my $author = $ctx->stash('author') 
    6440         or return $ctx->_no_author_error(); 
     6467    my $author = $ctx->stash('author'); 
     6468    unless ($author) { 
     6469        my $e = $ctx->stash('entry');  
     6470        $author = $e->author if $e;  
     6471    } 
     6472    return $ctx->_no_author_error() unless $author; 
    64416473    return $author->userpic_url() || ''; 
    64426474} 
     
    64656497    my ($ctx, $args, $cond) = @_; 
    64666498 
    6467     my $author = $ctx->stash('author') 
    6468         or return $ctx->_no_author_error(); 
     6499    my $author = $ctx->stash('author'); 
     6500    unless ($author) { 
     6501        my $e = $ctx->stash('entry');  
     6502        $author = $e->author if $e;  
     6503    } 
     6504    return $ctx->_no_author_error() unless $author; 
    64696505    my $asset = $author->userpic or return ''; 
    64706506 
  • branches/release-38/php/lib/block.mtauthoruserpicasset.php

    r1174 r2356  
    88function smarty_block_mtauthoruserpicasset($args, $content, &$ctx, &$repeat) { 
    99    $author = $ctx->stash('author'); 
    10     if (!$author) { 
     10    if (empty($author)) { 
     11        $entry = $ctx->stash('entry'); 
     12        if (!empty($entry)) { 
     13            $author = $ctx->mt->db->fetch_author($entry['entry_author_id']); 
     14        } 
     15    } 
     16    if (empty($author)) { 
    1117        return $ctx->error("No author available"); 
    1218    } 
  • branches/release-38/php/lib/function.mtauthorauthiconurl.php

    r1174 r2356  
    88function smarty_function_mtauthorauthiconurl($args, &$ctx) { 
    99    $author = $ctx->stash('author'); 
    10     if (!$author) { 
    11         return ""; 
     10    if (empty($author)) { 
     11        $entry = $ctx->stash('entry'); 
     12        if (!empty($entry)) { 
     13            $author = $ctx->mt->db->fetch_author($entry['entry_author_id']); 
     14        } 
     15    } 
     16 
     17    if (empty($author)) { 
     18        return $ctx->error("No author available"); 
    1219    } 
    1320    require_once "function.mtstaticwebpath.php"; 
  • branches/release-38/php/lib/function.mtauthorauthtype.php

    r1174 r2356  
    88function smarty_function_mtauthorauthtype($args, &$ctx) { 
    99    $author = $ctx->stash('author'); 
    10     if (!$author) { 
     10    if (empty($author)) { 
     11        $entry = $ctx->stash('entry'); 
     12        if (!empty($entry)) { 
     13            $author = $ctx->mt->db->fetch_author($entry['entry_author_id']); 
     14        } 
     15    } 
     16 
     17    if (empty($author)) { 
    1118        return $ctx->error("No author available"); 
    1219    } 
  • branches/release-38/php/lib/function.mtauthordisplayname.php

    r1174 r2356  
    1010    // parameters: none 
    1111    $author = $ctx->stash('author'); 
     12    if (empty($author)) { 
     13        $entry = $ctx->stash('entry'); 
     14        if (!empty($entry)) { 
     15            $author = $ctx->mt->db->fetch_author($entry['entry_author_id']); 
     16        } 
     17    } 
     18    if (empty($author)) { 
     19        return $ctx->error("No author available"); 
     20    } 
    1221    $author_name = $author['author_nickname']; 
    1322    $author_name or $author_name = 
  • branches/release-38/php/lib/function.mtauthoremail.php

    r1174 r2356  
    88function smarty_function_mtauthoremail($args, &$ctx) { 
    99    $author = $ctx->stash('author'); 
    10     if (!$author) { 
     10    if (empty($author)) { 
     11        $entry = $ctx->stash('entry'); 
     12        if (!empty($entry)) { 
     13            $author = $ctx->mt->db->fetch_author($entry['entry_author_id']); 
     14        } 
     15    } 
     16 
     17    if (empty($author)) { 
    1118        return $ctx->error("No author available"); 
    1219    } 
    13     return isset($author['author_email']) ? $author['author_email'] : ''; 
     20    return isset($author['author_email']) ? $author['author_email'] : ''; 
    1421} 
    1522?> 
  • branches/release-38/php/lib/function.mtauthorid.php

    r1174 r2356  
    88function smarty_function_mtauthorid($args, &$ctx) { 
    99    $author = $ctx->stash('author'); 
    10     if (!$author) { 
     10    if (empty($author)) { 
     11        $entry = $ctx->stash('entry'); 
     12        if (!empty($entry)) { 
     13            $author = $ctx->mt->db->fetch_author($entry['entry_author_id']); 
     14        } 
     15    } 
     16 
     17    if (empty($author)) { 
    1118        return $ctx->error("No author available"); 
    1219    } 
  • branches/release-38/php/lib/function.mtauthorname.php

    r1174 r2356  
    88function smarty_function_mtauthorname($args, &$ctx) { 
    99    $author = $ctx->stash('author'); 
    10     if (!$author) { 
     10    if (empty($author)) { 
     11        $entry = $ctx->stash('entry'); 
     12        if (!empty($entry)) { 
     13            $author = $ctx->mt->db->fetch_author($entry['entry_author_id']); 
     14        } 
     15    } 
     16 
     17    if (empty($author)) { 
    1118        return $ctx->error("No author available"); 
    1219    } 
  • branches/release-38/php/lib/function.mtauthorurl.php

    r1174 r2356  
    88function smarty_function_mtauthorurl($args, &$ctx) { 
    99    $author = $ctx->stash('author'); 
    10     if (!$author) { 
     10    if (empty($author)) { 
     11        $entry = $ctx->stash('entry'); 
     12        if (!empty($entry)) { 
     13            $author = $ctx->mt->db->fetch_author($entry['entry_author_id']); 
     14        } 
     15    } 
     16 
     17    if (empty($author)) { 
    1118        return $ctx->error("No author available"); 
    1219    } 
  • branches/release-38/php/lib/function.mtauthoruserpic.php

    r1174 r2356  
    88function smarty_function_mtauthoruserpic($args, &$ctx) { 
    99    $author = $ctx->stash('author'); 
    10     if (!$author) return ''; 
     10    if (empty($author)) { 
     11        $entry = $ctx->stash('entry'); 
     12        if (!empty($entry)) { 
     13            $author = $ctx->mt->db->fetch_author($entry['entry_author_id']); 
     14        } 
     15    } 
     16    if (empty($author)) { 
     17        return $ctx->error("No author available"); 
     18    } 
    1119 
    1220    $asset_id = isset($author['author_userpic_asset_id']) ? $author['author_userpic_asset_id'] : 0; 
  • branches/release-38/php/lib/function.mtauthoruserpicurl.php

    r1174 r2356  
    88function smarty_function_mtauthoruserpicurl($args, &$ctx) { 
    99    $author = $ctx->stash('author'); 
    10     if (!$author) return ''; 
     10    if (empty($author)) { 
     11        $entry = $ctx->stash('entry'); 
     12        if (!empty($entry)) { 
     13            $author = $ctx->mt->db->fetch_author($entry['entry_author_id']); 
     14        } 
     15    } 
     16 
     17    if (empty($author)) { 
     18        return $ctx->error("No author available"); 
     19    } 
    1120 
    1221    $asset_id = isset($author['author_userpic_asset_id']) ? $author['author_userpic_asset_id'] : 0;