Changeset 11892

Show
Ignore:
Timestamp:
08/30/07 17:27:42 (1 year ago)
Author:
adrenalin
Message:

Changed the sorting to use metadata.score reversed

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/midcom/midcom.admin.folder/handler/order.php

    r5773 r11892  
    2222     * @access public 
    2323     */ 
    24     function midcom_admin_folder_handler_order () 
     24    public function midcom_admin_folder_handler_order () 
    2525    { 
    2626        parent::midcom_baseclasses_components_handler(); 
     
    3232     * @access private 
    3333     */ 
    34     function _process_order_form() 
    35     { 
    36         debug_push_class(__CLASS__, __FUNCTION__); 
    37          
     34    private function _process_order_form() 
     35    { 
    3836        // If the navigation order is changed, it will be saved first. After this it is possible 
    3937        // again to organize the folder 
     
    6664                } 
    6765                 
    68                 debug_add("Setting the score for article id '{$id}: {$key}", MIDCOM_LOG_DEBUG); 
    69                  
    7066                if (!$article->update()) 
    7167                { 
     68                    debug_push_class(__CLASS__, __FUNCTION__); 
    7269                    debug_add("Updating the article with id '{$id}' failed. Reason: ". mgd_errstr(), MIDCOM_LOG_ERROR); 
    7370                    debug_pop(); 
     
    8178                if ($approval_status) 
    8279                { 
    83                     debug_add('Maintaining the approval status: setting the object back to be approved.'); 
    8480                    $metadata =& midcom_helper_metadata::retrieve($article); 
    8581                    $metadata->approve(); 
     
    109105                } 
    110106                 
    111                 debug_add("Setting the score for topic id '{$id}: {$key}", MIDCOM_LOG_DEBUG); 
    112                  
    113107                if (!$topic->update()) 
    114108                { 
     109                    debug_push_class(__CLASS__, __FUNCTION__); 
    115110                    debug_add("Updating the topic with id '{$id}' failed. Reason: ". mgd_errstr(), MIDCOM_LOG_ERROR); 
    116111                    debug_pop(); 
     
    124119                if ($approval_status) 
    125120                { 
    126                     debug_add('Maintaining the approval status: setting the object back to be approved.'); 
    127121                    $metadata =& midcom_helper_metadata::retrieve($topic); 
    128122                    $metadata->approve(); 
     
    135129            $count = count($_POST['midcom_admin_content_mixed_score']); 
    136130             
    137             debug_add('Entering the mixed type mode', MIDCOM_LOG_DEBUG); 
    138131            foreach ($_POST['midcom_admin_content_mixed_score'] as $key => $id) 
    139132            { 
     
    150143                if (!is_object($object)) 
    151144                { 
     145                    debug_push_class(__CLASS__, __FUNCTION__); 
    152146                    debug_add("Could not get the {$type[1]} with id '{$id}'. Reason: ". mgd_errstr(), MIDCOM_LOG_ERROR); 
    153147                    debug_pop(); 
     
    171165                $object->score = (int) $key; 
    172166                 
    173                 debug_add("Setting the score for {$type[1]} id '{$id}: {$key}", MIDCOM_LOG_DEBUG); 
    174                  
    175167                if (!$object->update()) 
    176168                { 
     169                    debug_push_class(__CLASS__, __FUNCTION__); 
    177170                    debug_add("Updating the {$type[1]} with id '{$id}' failed. Reason: ". mgd_errstr(), MIDCOM_LOG_ERROR); 
    178171                    debug_pop(); 
     
    186179                if ($approval_status) 
    187180                { 
    188                     debug_add('Maintaining the approval status: setting the object back to be approved.'); 
    189181                    $metadata =& midcom_helper_metadata::retrieve($object); 
    190182                    $metadata->approve(); 
     
    193185        } 
    194186         
    195         debug_pop(); 
    196          
    197187        return true; 
    198188    } 
     
    200190    /** 
    201191     * Handler for setting the sort order 
    202      * 
    203      * @access protected 
    204192     */ 
    205193    function _handler_order($handler_id, $args, &$data) 
     
    207195        // Include Scriptaculous JavaScript library to headers 
    208196        // Scriptaculous/scriptaculous.js 
     197        $_MIDCOM->add_jsfile(MIDCOM_STATIC_URL.'/Pearified/JavaScript/Prototype/prototype.js'); 
    209198        $_MIDCOM->add_jsfile(MIDCOM_STATIC_URL.'/Pearified/JavaScript/Scriptaculous/scriptaculous.js'); 
    210199        $_MIDCOM->add_link_head 
     
    230219            if ($this->_process_order_form()) 
    231220            { 
     221                $_MIDCOM->uimessages->add($_MIDCOM->i18n->get_string('midcom.admin.folder'), $_MIDCOM->i18n->get_string('order saved')); 
    232222                $_MIDCOM->relocate($_MIDCOM->permalinks->create_permalink($this->_topic->guid)); 
     223                // This will exit 
    233224            } 
    234             // This will exit 
    235225        } 
    236226         
     
    283273        $qb = midcom_db_topic::new_query_builder(); 
    284274        $qb->add_constraint('up', '=', $this->_topic->id); 
    285         $qb->add_order('score'); 
     275        $qb->add_constraint('metadata.navnoentry', '=', 0); 
     276        $qb->add_order('metadata.score', 'DESC'); 
    286277        //$qb->add_order('name'); 
    287278        //$qb->add_order('extra'); 
     
    293284        $qb->add_constraint('name', '<>', 'index'); 
    294285        $qb->add_constraint('up', '=', 0); 
    295         $qb->add_order('score'); 
     286        $qb->add_order('metadata.score', 'DESC'); 
    296287        //$qb->add_order('name'); 
    297288        //$qb->add_order('title'); 
     
    385376     * @return string     String filled with leading zeros 
    386377     */ 
    387     function _get_score($int) 
     378    private function _get_score($int) 
    388379    { 
    389380        $string = (string) $int;