Changeset 1634 for branches

Show
Ignore:
Timestamp:
11/15/06 04:21:38 (2 years ago)
Author:
spetersen
Message:

Another merge to bring PostgreSQL branch in synce with trunk SVN 1632. previous was wrong directory

Location:
branches/postgresql
Files:
14 removed
48 modified
22 copied

Legend:

Unmodified
Added
Removed
  • branches/postgresql/api.php

    r1603 r1634  
    4949        blGetItems($cid,$date,$markread); 
    5050        break; 
    51     } 
     51    case 'search': 
     52        rss_require('extlib/JSON.php'); 
     53        $json = new Services_JSON(); 
     54        $query = preg_replace('#[^a-z0-9\s]#','',@$_REQUEST['q']); 
     55        if ($query) { 
     56            $res = osSearch($query); 
     57        } else { 
     58            $res = array($query,array(),array(),array()); 
     59        } 
     60        header('Content-Type: text/plain'); 
     61        die ($json->encode($res)); 
     62        break; 
     63    } 
     64 
    5265} 
    5366 
     
    195208 
    196209} 
     210 
     211function osSearch($q) { 
     212    rss_require('cls/search.php'); 
     213    $sil = new SearchItemList($q,5); 
     214    $results = array(); 
     215    foreach($sil -> feeds as $feed) { 
     216        foreach($feed -> items as $item) { 
     217            $results[] = $item -> title; 
     218        } 
     219    } 
     220    return array($q,$results,array(),array()); 
     221} 
    197222?> 
  • branches/postgresql/cls/categories.php

    r1603 r1634  
    119119            } 
    120120            $sql .= " and (c.mode & " . RSS_MODE_DELETED_STATE.")=0 "; 
    121             ." group by m.tid, t.tag"; 
     121            $sql .= " group by m.tid, t.tag"; 
    122122            _pf('query'); 
    123123            $res = rss_query($sql); 
  • branches/postgresql/cls/l10n.php

    r1603 r1634  
    8080       if (isset($_REQUEST['lang']) && preg_match('#^[a-z]{2}_?([A-Z]{2})?$#',$_REQUEST['lang']) && ($_REQUEST['lang'] == 'en' || file_exists(GREGARIUS_HOME .'intl/'.$_REQUEST['lang']))) { 
    8181            $this -> __setLocaleCookie($_REQUEST['lang']); 
     82            rss_invalidate_cache(); 
    8283            return  $_REQUEST['lang']; 
    8384        } elseif (isset($_COOKIE[RSS_LOCALE_COOKIE])) { 
  • branches/postgresql/cls/search.php

    r1603 r1634  
    4343define ('QUERY_MATCH_EXACT','exact'); 
    4444 
     45// This is needed for some constants 
     46rss_require('cls/wrappers/toolkit.php'); 
    4547 
    4648class SearchItemList extends ItemList { 
     
    5153 
    5254    var $currentPage; 
    53     var $resultsPerPage; 
     55    var $resultsPerPage = 0; 
    5456    var $startItem; 
    5557    var $endItem; 
     
    5860    var $logicSep; 
    5961 
    60     function SearchItemList() { 
     62    function SearchItemList($query=null,$results=0) { 
    6163        parent::ItemList(); 
     64        if ($query) { 
     65            $this -> query=$query; 
     66        } elseif(isset($_REQUEST[QUERY_PRM])) { 
     67            $this->query = $_REQUEST[QUERY_PRM]; 
     68        }else{ 
     69            $this -> query = null; 
     70        } 
     71         
     72         
     73        // Sanitize the query parameters: 
     74        // fixme: this probably breaks on queries with weird characters, depending 
     75        // on the locale.  
     76        // see: http://php.benscom.com/manual/en/reference.pcre.pattern.syntax.php 
     77        if ($this -> query) { 
     78            $this -> query = trim(preg_replace('#[^\w\s\x80-\xff]#','',$this -> query)); 
     79        } 
     80         
     81        $this->resultsPerPage = (int) $results; 
     82         
    6283        $this -> populate(); 
    6384 
     
    101122 
    102123    function populate() { 
    103         if (!isset($_REQUEST[QUERY_PRM])) { 
    104             return; 
    105         } 
    106  
    107                 // fixme: this probably breaks on queries with weird characters, depending 
    108                 // on the locale.  
    109                 // see: http://php.benscom.com/manual/en/reference.pcre.pattern.syntax.php 
    110         $this->query = trim(preg_replace('#[^\w\s\x80-\xff]#','',$_REQUEST[QUERY_PRM])); 
    111124         
    112125        if (!$this->query) { 
     
    122135            RSS_SANITIZER_NUMERIC); 
    123136 
    124         $this->resultsPerPage = sanitize( 
    125             ((array_key_exists(QUERY_RESULTS, $_REQUEST)) ? $_REQUEST[QUERY_RESULTS] : INFINE_RESULTS), 
    126             RSS_SANITIZER_NUMERIC); 
    127          
     137        if (!$this->resultsPerPage) { 
     138            $this->resultsPerPage = sanitize( 
     139                ((array_key_exists(QUERY_RESULTS, $_REQUEST)) ? $_REQUEST[QUERY_RESULTS] : INFINE_RESULTS), 
     140                RSS_SANITIZER_NUMERIC); 
     141        } 
     142 
    128143        $this->currentPage = sanitize( 
    129144            (array_key_exists(QUERY_CURRENT_PAGE, $_REQUEST) ? $_REQUEST[QUERY_CURRENT_PAGE] : 0), 
  • branches/postgresql/cls/update.php

    r1603 r1634  
    6565 
    6666    function Update($doPopulate = true, $updatePrivateAlso = false) { 
    67     rss_plugin_hook('rss.plugins.updates.before', null); 
     67        rss_plugin_hook('rss.plugins.updates.before', null); 
    6868        if($doPopulate) { 
    6969            $this->populate($updatePrivateAlso); 
     
    7777    function populate($updatePrivateAlso = false) { 
    7878        $sql = "select c.id, c.url, c.title from ".getTable("channels") . " c " 
    79              . " inner join " . getTable('folders') . " f on f.id = c.parent " 
    80              . " where (c.mode & ".RSS_MODE_DELETED_STATE.")=0 "; 
     79               . " inner join " . getTable('folders') . " f on f.id = c.parent " 
     80               . " where (c.mode & ".RSS_MODE_DELETED_STATE.")=0 "; 
    8181 
    8282        if (hidePrivate() && !$updatePrivateAlso) { 
     
    104104            } 
    105105        } 
    106          
     106 
    107107        setProperty('__meta__','meta.lastupdate','misc',time()); 
    108          
     108 
    109109        if (count($newIds) > 0) { 
    110110            rss_invalidate_cache(); 
    111111        } 
    112     rss_plugin_hook('rss.plugins.updates.after', null); 
     112        rss_plugin_hook('rss.plugins.updates.after', null); 
    113113    } 
    114114 
    115115    function magpieError($error) { 
    116         if ($error & MAGPIE_FEED_ORIGIN_CACHE) { 
     116        if (is_numeric($error) && ($error & MAGPIE_FEED_ORIGIN_CACHE)) { 
    117117            if ($error & MAGPIE_FEED_ORIGIN_HTTP_304) { 
    118118                $label = __('OK (304 Not modified)'); 
     
    121121            elseif ($error & MAGPIE_FEED_ORIGIN_HTTP_TIMEOUT) { 
    122122                $label = __('HTTP Timeout (Local cache)'); 
    123                 $cls = ERROR_WARNING; 
     123                $cls = ERROR_ERROR; 
    124124            } 
    125125            elseif ($error & MAGPIE_FEED_ORIGIN_NOT_FETCHED) { 
     
    131131                $cls = ERROR_ERROR; 
    132132            } 
     133            elseif ($error & MAGPIE_FEED_ORIGIN_HTTP_403) { 
     134                $label = __('403 Forbidden (Local cache)'); 
     135                $cls = ERROR_ERROR; 
     136            } 
    133137            else { 
    134138                $label = $error; 
     
    142146        else { 
    143147            if (is_numeric($error)) { 
    144                 $label = __('ERROR'); 
     148                $label = __('ERROR') ." $error"; 
    145149                $cls = ERROR_ERROR; 
    146150            } else { 
     
    169173        rss_set_hook('rss.plugins.bodystart', "pushHeaderCallBack"); 
    170174        rss_set_hook('rss.plugins.bodyend', "pushFooterCallBack"); 
    171          
     175 
    172176        ob_implicit_flush(); 
    173177    } 
     
    260264        echo "</table>\n"; 
    261265        echo "<script type=\"text/javascript\">\n"; 
    262         echo "function runAjaxUpdate() { \n"; 
     266        echo "function runAjaxUpdate() { \n"; 
    263267        echo "    for (k =0; k < " . AJAX_PARALLEL_SIZE . "; k++){\n"; 
    264         echo "    doUpdate();\n"; 
    265         echo "    }\n"; 
    266         echo "}\n"; 
    267         // Fix for IE's stupid "Operation Aborted" Error 
    268         echo "   if (window.addEventListener) window.addEventListener(\"load\",runAjaxUpdate,false); else if (window.attachEvent) window.attachEvent(\"onload\",runAjaxUpdate);\n"; 
    269         echo "</script>\n"; 
     268        echo "    doUpdate();\n"; 
     269        echo "    }\n"; 
     270        echo "}\n"; 
     271        // Fix for IE's stupid "Operation Aborted" Error 
     272        echo "   if (window.addEventListener) window.addEventListener(\"load\",runAjaxUpdate,false); else if (window.attachEvent) window.attachEvent(\"onload\",runAjaxUpdate);\n"; 
     273        echo "</script>\n"; 
    270274    } 
    271275} 
     
    305309 
    306310class MobileUpdate extends Update { 
    307     function MobileUpdate() { 
    308         parent::Update($doPopulate = true); 
    309     } 
    310     function render() { 
    311         $newIds = array(); 
    312     foreach ($this->chans as $chan) { 
    313             list ($cid, $url, $title) = $chan; 
    314             echo "$title ...\t"; 
    315             flush(); 
    316             $ret = update($cid); 
    317  
    318             if (is_array($ret)) { 
    319                     list ($error, $unreadIds) = $ret; 
    320                     $newIds = array_merge($newIds, $unreadIds); 
    321             } else { 
    322                     $error = 0; 
    323                     $unreadIds = array (); 
    324             } 
    325             $unread = count($unreadIds); 
    326             list($label,$cls) = parent::magpieError($error); 
    327             echo "\n$label, $unread " . __('New Items') . "<br />"; 
    328             flush(); 
    329     } 
    330     } 
    331 } 
    332  
    333      
     311    function MobileUpdate() { 
     312        parent::Update($doPopulate = true); 
     313    } 
     314    function render() { 
     315        $newIds = array(); 
     316        foreach ($this->chans as $chan) { 
     317            list ($cid, $url, $title) = $chan; 
     318            echo "$title ...\t"; 
     319            flush(); 
     320            $ret = update($cid); 
     321 
     322            if (is_array($ret)) { 
     323                list ($error, $unreadIds) = $ret; 
     324                $newIds = array_merge($newIds, $unreadIds); 
     325            } else { 
     326                $error = 0; 
     327                $unreadIds = array (); 
     328            } 
     329            $unread = count($unreadIds); 
     330            list($label,$cls) = parent::magpieError($error); 
     331            echo "\n$label, $unread " . __('New Items') . "<br />"; 
     332            flush(); 
     333        } 
     334    } 
     335} 
     336 
     337 
    334338/** 
    335339 * CommandLineUpdateNews updates the feeds and displays only feeds with 
     
    337341 */ 
    338342class CommandLineUpdateNews extends CommandLineUpdate { 
    339         function render() { 
    340                 $newIds = array(); 
    341                 foreach ($this->chans as $chan) { 
    342                         list ($cid, $url, $title) = $chan; 
    343                         $ret = update($cid); 
    344  
    345                         if (is_array($ret)) { 
    346                                 list ($error, $unreadIds) = $ret; 
    347                                 $newIds = array_merge($newIds, $unreadIds); 
    348                         } else { 
    349                                 $error = 0; 
    350                                 $unreadIds = array(); 
    351                         } 
    352                         $unread = count($unreadIds); 
    353  
    354                         list($label, $cls) = parent::magpieError($error); 
    355  
    356                         if (($cls != ERROR_NOERROR) || ($unread > 0)) { 
    357                                 echo "$title ...\t"; 
    358                                 flush(); 
    359                                 echo "\n$label, $unread " . __('New Items') . "\n\n"; 
    360                                 flush(); 
    361                         } 
    362                 } 
    363  
    364                 if (!hidePrivate()) { 
    365                         parent::cleanUp($newIds); 
    366                 } 
    367         } 
     343    function render() { 
     344        $newIds = array(); 
     345        foreach ($this->chans as $chan) { 
     346            list ($cid, $url, $title) = $chan; 
     347            $ret = update($cid); 
     348 
     349            if (is_array($ret)) { 
     350                list ($error, $unreadIds) = $ret; 
     351                $newIds = array_merge($newIds, $unreadIds); 
     352            } else { 
     353                $error = 0; 
     354                $unreadIds = array(); 
     355            } 
     356            $unread = count($unreadIds); 
     357 
     358            list($label, $cls) = parent::magpieError($error); 
     359 
     360            if (($cls != ERROR_NOERROR) || ($unread > 0)) { 
     361                echo "$title ...\t"; 
     362                flush(); 
     363                echo "\n$label, $unread " . __('New Items') . "\n\n"; 
     364                flush(); 
     365            } 
     366        } 
     367 
     368        if (!hidePrivate()) { 
     369            parent::cleanUp($newIds); 
     370        } 
     371    } 
    368372} 
    369373 
     
    417421    echo "\n".PUSH_BOUNDARY."\n"; 
    418422    echo "WARNING: YOUR BROWSER DOESN'T SUPPORT THIS SERVER-PUSH TECHNOLOGY.\n"; 
    419      
     423 
    420424    flush(); 
    421425} 
  • branches/postgresql/cls/wrappers/header.php

    r1603 r1634  
    135135} 
    136136 
    137 function rss_header_logininfo() { 
     137function rss_header_logininfo($showLoginBox = true) { 
    138138 
    139139    $ret = "<div id=\"loginfo\">\n"; 
     
    142142        $ret .= sprintf(__('Logged in as <strong>%s</strong>'), rss_user_name()) 
    143143                ."&nbsp;|&nbsp;<a href=\"".getPath()."?logout\">".__('Logout')."</a>\n"; 
    144     } else { 
     144    } else if(true == $showLoginBox) { 
    145145        $ret .= __('Not logged in') 
    146146                ."&nbsp;|&nbsp;<a href=\"#\" onclick=\"miniloginform(); return false;\">".__('Login')."</a>"; 
  • branches/postgresql/cls/wrappers/item.php

    r1603 r1634  
    4646    } 
    4747    if (getConfig('rss.output.usepermalinks')) { 
    48         list ($ply, $plm, $pld) = explode(":", rss_date("Y:m:d", $GLOBALS['rss'] -> currentItem -> date, false)); 
    49         $ptitle = ($label."'".$GLOBALS['rss'] -> currentItem -> parent -> escapedTitle 
    50             ."/$ply/$plm/$pld/".$GLOBALS['rss'] -> currentItem -> escapedTitle."'"); 
    51     } 
    52     return $ptitle; 
     48        //list ($ply, $plm, $pld) = explode(":", rss_date("Y:m:d", $GLOBALS['rss'] -> currentItem -> date, false)); 
     49        $ptitle = ($label."'". htmlentities($GLOBALS['rss'] -> currentItem -> title,ENT_QUOTES  ,'UTF-8') ."'"); 
     50    } 
     51    return @$ptitle; 
    5352} 
    5453 
  • branches/postgresql/dist/l10n.sh

    r1603 r1634  
    1818    echo "Updating $PO/$POFILE" 
    1919    touch $PO/$POFILE 
    20     msgmerge -v --update $PO/$POFILE $POT 
     20    msgmerge -N -v --update $PO/$POFILE $POT 
    2121    echo "Building $PO/$MOFILE"  
    2222    msgfmt -o $PO/$MOFILE $PO/$POFILE 
  • branches/postgresql/extlib/l10n/gettext.php

    r1484 r1634  
    103103    $this->enable_cache = $enable_cache; 
    104104 
    105     // $MAGIC1 = (int)0x950412de; //bug in PHP 5 
     105    $MAGIC1_alt = (int)0x950412de; //bug in PHP 5 
    106106    $MAGIC1 = (int) - 1794895138; 
    107     // $MAGIC2 = (int)0xde120495; //bug 
     107    $MAGIC2_alt = (int)0xde120495; //bug 
    108108    $MAGIC2 = (int) - 569244523; 
    109109 
    110110    $this->STREAM = $Reader; 
    111111    $magic = $this->readint(); 
    112     if ($magic == $MAGIC1) { 
     112    if ($magic == $MAGIC1 || $magic == $MAGIC1_alt) { 
    113113      $this->BYTEORDER = 0; 
    114     } elseif ($magic == $MAGIC2) { 
     114    } elseif ($magic == $MAGIC2 || $magic == $MAGIC2_alt) { 
    115115      $this->BYTEORDER = 1; 
    116116    } else { 
  • branches/postgresql/extlib/rss_fetch.inc

    r1164 r1634  
    5050// Not fetched because age < MAGPIE_CACHE_AGE 
    5151define ('MAGPIE_FEED_ORIGIN_NOT_FETCHED', 64); 
     52// 403 Forbidden 
     53define ('MAGPIE_FEED_ORIGIN_HTTP_403', 128); 
    5254 
    5355/* 
     
    239241                        $rss -> rss_origin |= MAGPIE_FEED_ORIGIN_HTTP_404; 
    240242                    break; 
     243                case '403': 
     244                        $rss -> rss_origin |= MAGPIE_FEED_ORIGIN_HTTP_403; 
     245                        break; 
    241246                default: 
    242247                    $rss -> rss_origin |= MAGPIE_FEED_ORIGIN_HTTP_TIMEOUT; 
  • branches/postgresql/intl/da/LC_MESSAGES/messages.po