Show
Ignore:
Timestamp:
02/05/07 11:51:37 (22 months ago)
Author:
mbonetti
Message:

experimental: if the item has an image enclosure, display it inline with the item's content. Testcase: http://favicon2dots.com/rss

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/gregarius/util.php

    r1672 r1685  
    3030 
    3131function getLastModif() { 
    32     return getProperty('__meta__','meta.lastupdate'); 
     32    return getProperty('__meta__','meta.lastupdate'); 
    3333} 
    3434 
     
    316316            if (array_key_exists('enclosure@url', $item) ) { 
    317317                $enclosure = $item['enclosure@url']; 
     318                // If the enclosure is an image, append it to the content 
     319                if ($enclosure && array_key_exists('enclosure@type', $item) && preg_match('#image/(png|gif|jpe?g)#', $item['enclosure@type'])) { 
     320                    $description = '<img src="'.$enclosure.'" alt="" />' . $description; 
     321                    $enclosure = ''; 
     322                } 
    318323            } else { 
    319324                $enclosure = ""; 
     
    460465        } 
    461466        elseif (is_object($rss) && array_key_exists('title#', $rss->channel)) { 
    462             if (array_key_exists('title', $rss->channel)) { 
    463                 $title = rss_real_escape_string($rss->channel['title']); 
     467            if (array_key_exists('title', $rss->channel)) { 
     468                $title = rss_real_escape_string($rss->channel['title']); 
    464469            } else { 
    465                 $title = " "; 
     470                $title = " "; 
    466471            } 
    467472        } 
     
    521526                $mode |= RSS_MODE_PRIVATE_STATE; 
    522527            } 
    523              
     528 
    524529            $sql = "insert into ".getTable("channels") 
    525530                   ." (title, url, siteurl, parent, descr, dateadded, icon, position, mode, daterefreshed)" 
     
    534539            } 
    535540 
    536             if($tags != ""){ 
     541            if($tags != "") { 
    537542                __exp__submitTag($newid,$tags,"'channel'"); 
    538543            } 
     
    638643            $ret = substr($ret, 0, strlen($ret) - strlen(RSS_FILE_LOCATION)); 
    639644        } 
    640     if (substr($ret, -1) == "\\") { // Take off trailing backslash 
     645        if (substr($ret, -1) == "\\") { // Take off trailing backslash 
    641646            $ret = substr($ret, 0, -1); 
    642     } 
     647        } 
    643648        if (substr($ret, -1) != "/") {  // Add a frontslash 
    644649            $ret .= "/"; 
     
    846851 
    847852function showViewForm($args) { //$curValue, $show_private) { 
    848         list($curValue, $show_private) = $args; 
     853    list($curValue, $show_private) = $args; 
    849854 
    850855    // post back to self, we should be able to handle the request, shouldn't we. 
     
    856861    ."</select>" 
    857862    ."</p>\n"; 
    858 /* 
    859         if(isLoggedIn()) { 
    860             echo "<p><label for=\"chkPrivate\">".__('Show Private:')."</label>\n" 
    861             ."<input type=\"checkbox\" name=\"chkPrivate\" id=\"chkPrivate\" value=\"1\" onchange=\"if(false == document.getElementById('chkPrivate').checked) { document.getElementById('chkPrivate').value = 0; document.getElementById('chkPrivate').checked = true; } document.getElementById('frmShow').submit();\"" . (1 == $show_private ? " checked" : "") . ">\n" 
    862             ."</p>\n"; 
    863         } 
    864         */ 
    865         echo "</form>\n"; 
     863    /* 
     864            if(isLoggedIn()) { 
     865                echo "<p><label for=\"chkPrivate\">".__('Show Private:')."</label>\n" 
     866                ."<input type=\"checkbox\" name=\"chkPrivate\" id=\"chkPrivate\" value=\"1\" onchange=\"if(false == document.getElementById('chkPrivate').checked) { document.getElementById('chkPrivate').value = 0; document.getElementById('chkPrivate').checked = true; } document.getElementById('frmShow').submit();\"" . (1 == $show_private ? " checked" : "") . ">\n" 
     867                ."</p>\n"; 
     868            } 
     869            */ 
     870    echo "</form>\n"; 
    866871} 
    867872 
     
    965970// moved from ajax.php 
    966971function __exp__submitTag($id,$tags,$type = "'item'") { 
    967     $tags = strip_tags($tags); 
     972    $tags = strip_tags($tags); 
    968973    $ftags = utf8_encode( preg_replace(ALLOWED_TAGS_REGEXP,'', trim($tags))); 
    969974    $tarr = array_slice(explode(" ",$ftags),0,MAX_TAGS_PER_ITEM); 
     
    981986            continue; 
    982987        } 
    983         $ttag = sanitize($ttag, 
    984             RSS_SANITIZER_NO_SPACES | RSS_SANITIZER_SIMPLE_SQL 
    985         ); 
    986          
     988        $ttag = sanitize($ttag, 
     989                         RSS_SANITIZER_NO_SPACES | RSS_SANITIZER_SIMPLE_SQL 
     990                        ); 
     991 
    987992        rss_query( "insert into ". getTable('tag') 
    988993                   . " (tag) values ('$ttag')", false ); 
     
    10681073    return ("echo stripslashes(\"".addslashes($arr[1])."\");"); 
    10691074} 
    1070  
     1075  
    10711076function eval_mixed($string) { 
    10721077    $string = "<? ?>".$string."<? ?>"; 
     
    10941099 
    10951100function cacheFavicon($icon) { 
    1096     // Make sure only real favicons get fetched into the DB 
    1097     if (! preg_match('#^https?://.+$#',$icon)) { 
    1098         return false; 
    1099     } 
    1100       
     1101    // Make sure only real favicons get fetched into the DB 
     1102    if (! preg_match('#^https?://.+$#',$icon)) { 
     1103        return false; 
     1104    } 
     1105 
    11011106    $icon_ = rss_real_escape_string($icon); 
    11021107    $binIcon = getUrl($icon); 
     
    11441149 
    11451150function hidePrivate() { 
    1146     $ret = 0; 
    1147  
    1148   if(isLoggedIn()) { 
    1149         $ret = rss_user_show_private(); 
    1150     } 
    1151  
    1152     return !$ret; 
     1151    $ret = 0; 
     1152 
     1153    if(isLoggedIn()) { 
     1154        $ret = rss_user_show_private(); 
     1155    } 
     1156 
     1157    return !$ret; 
    11531158} 
    11541159 
    11551160function isLoggedIn() { 
    1156     if (!isset($GLOBALS['rssuser'])) { 
    1157         require_once('cls/user.php'); 
    1158     } 
    1159  
    1160     return rss_user_check_user_level(RSS_USER_LEVEL_PRIVATE); 
    1161 } 
    1162  
    1163 // Send a crappy 404 (to save bandwidth) for webbots  
     1161    if (!isset($GLOBALS['rssuser'])) { 
     1162        require_once('cls/user.php'); 
     1163    } 
     1164 
     1165    return rss_user_check_user_level(RSS_USER_LEVEL_PRIVATE); 
     1166} 
     1167 
     1168// Send a crappy 404 (to save bandwidth) for webbots 
    11641169function rss_404() { 
    1165     header("HTTP/1.1 404 Not Found"); 
    1166     echo "404 Page Not Found\n"; 
     1170    header("HTTP/1.1 404 Not Found"); 
     1171    echo "404 Page Not Found\n"; 
    11671172} 
    11681173 
    11691174function rss_uri($title, $sep=RSS_URI_SEPARATOR) { 
    1170     return utf8_uri_encode(preg_replace('#[ \#%&/\+\'"\?]#',$sep,$title)); 
     1175    return utf8_uri_encode(preg_replace('#[ \#%&/\+\'"\?]#',$sep,$title)); 
    11711176} 
    11721177?>