Changeset 203

Show
Ignore:
Timestamp:
06/30/08 21:27:26 (6 months ago)
Author:
llaumgui
Message:

fetch topic en place ;-)

Location:
ez_publish/ezfluxbb/trunk
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • ez_publish/ezfluxbb/trunk/classes/ezfluxbb.php

    r200 r203  
    189189        } 
    190190 
     191         
     192 
     193        /** 
     194         * Récupération des informations sur des topics 
     195         *  
     196         * @author Guillaume Kulakowski <guillaume_AT_llaumgui_DOT_com> 
     197         * @since 1.0 
     198         *  
     199         * @return array 
     200         */ 
     201        public function getTopics( $params ) 
     202        { 
     203                $db             = eZFluxBBDB::instance(); 
     204                 
     205                                 
     206                $topics         = $db->arrayQuery(      'SELECT t.id topic_id, t.poster, t.subject, t.num_replies, p.id post_id, p.message ' . 
     207                                                                                'FROM '.$this->fluxBBConfig['db_prefix'].'topics t ' . 
     208                                                                                /* TODO : Rendre la jointure paramÚtrable */ 
     209                                                                                        'LEFT JOIN '.$this->fluxBBConfig['db_prefix'].'posts p ON (p.topic_id=t.id AND t.posted = p.posted) ' . 
     210                                                                                'WHERE forum_id ' . $params['forum_id'] . ' ' . 
     211                                                                                'ORDER BY ' . $params['sort_by'] .' ' . 
     212                                                                                'LIMIT ' . $params['offset'] . ', ' . $params['limit']); 
     213 
     214                return $topics; 
     215        } 
     216         
     217         
     218         
    191219}       //EOC 
    192220  
  • ez_publish/ezfluxbb/trunk/classes/ezfluxbbfetchfonctions.php

    r200 r203  
    100100         * @return array 
    101101         */ 
    102         function fetchTopics() 
     102        function fetchTopics( $forum_id_filter_type, $forum_id_filter_array, $limit, $offset, $sort_by ) 
    103103        { 
    104                 //$eZFluxBB             = eZFluxBB::instance(); 
    105                 //$currentUser  = $eZFluxBB->getCurrentUserInfo(); 
    106                 //print_r($currentUser); 
     104                $sortingString          = 't.posted'; 
     105                $sortOrder                      = true; // true is ascending 
     106                $sortingForum_id        = 'IN'; 
    107107                 
    108                 $result                 = array( 'result' => array( ) ); 
    109                 return $result; 
     108                /* Sort_by */ 
     109                if ( is_array($sort_by) ) 
     110                { 
     111                        if ( array_key_exists(0, $sort_by) && !empty($sort_by[0]) ) 
     112                { 
     113                        $sortingString  = $sort_by[0]; 
     114                } 
     115                if ( array_key_exists(1, $sort_by) && is_bool($sort_by[1]) )  
     116                { 
     117                        $sortOrder              = $sort_by[1]; 
     118                } 
     119                } 
     120                else 
     121                { 
     122                if ( !empty($sort_by ) ) 
     123                { 
     124                        $sortingString = $sort_by; 
     125                } 
     126                 
     127        } 
     128                $sortingOrder   = $sortOrder ? ' ASC' : ' DESC'; 
     129                 
     130                /* $forum_id */ 
     131        if ( $forum_id_filter_type == 'exclude' ) 
     132        { 
     133                $sortingForum_id        = 'NOT IN'; 
     134        } 
     135        if ( is_array( $forum_id_filter_array ) ) 
     136        { 
     137                $sortingForum_id        .= ' (' . implode( ', ', $forum_id_filter_array) . ')'; 
     138        } 
     139        else 
     140        { 
     141                $sortingForum_id        .= ' (' . $forum_id_filter_array . ')'; 
     142        } 
     143                                 
     144                $eZFluxBB               = eZFluxBB::instance(); 
     145                $params                 = array(        'forum_id'                                      => $sortingForum_id, 
     146                                                                        'limit'                                         => $limit, 
     147                                                                        'offset'                                        => $offset, 
     148                                                                        'sort_by'                                       => $sortingString . ' ' . $sortingOrder ); 
     149                 
     150                $topics                 = $eZFluxBB->getTopics( $params ); 
     151 
     152                return array( 'result' => $topics ); 
    110153        } 
    111154} 
  • ez_publish/ezfluxbb/trunk/modules/ezfluxbb/function_definition.php

    r202 r203  
    8484                                'type'     => 'string', 
    8585                                'required' => false, 
    86                                 'default'  => false 
     86                                'default'  => 'include' 
    8787                ), 
    8888                array(  'name'     => 'forum_id_filter_array', 
    89                                 'type'     => 'string', 
     89                                'type'     => 'mixed', 
    9090                                'required' => false, 
    9191                                'default'  => false 
     
    9696                                'default'  => 20 
    9797                ), 
    98                 array(  'name'     => 'sort_by', 
    99                                 'type'     => 'array', 
    100                                 'required' => false, 
    101                                 'default'  => array( 'last_post', false ) 
    102                 ), 
    10398                array(  'name'     => 'offset', 
    10499                                'type'     => 'integer', 
     
    106101                                'default'  => 0 
    107102                ), 
     103                array(  'name'     => 'sort_by', 
     104                                'type'     => 'array', 
     105                                'required' => false, 
     106                                'default'  => array( 't.posted', false ) 
     107                ), 
    108108        ) 
    109109);