Changeset 9242

Show
Ignore:
Timestamp:
08/13/08 22:23:16 (4 months ago)
Author:
afz
Message:

update Jaws_Component class

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/jaws/html/include/Jaws/Component.php

    r9241 r9242  
    99 * @license    http://www.gnu.org/copyleft/lesser.html 
    1010 */ 
     11define('JAWS_COMPONENT_ANY',    0); 
     12define('JAWS_COMPONENT_CORE',   1); 
     13define('JAWS_COMPONENT_GADGET', 2); 
     14define('JAWS_COMPONENT_PLUGIN', 3); 
     15 
    1116class Jaws_Component 
    1217{ 
     
    8590     * 
    8691     * @access  public 
    87      * @param   int     $id    Component's ID 
     92     * @param   int $id Component's ID 
    8893     * @return  boolean Returns true if component was sucessfully deleted, false if not 
    8994     */ 
     
    105110     * 
    106111     * @access  public 
    107      * @param   string  $comp_name  Component's name 
     112     * @param   string  $comp  Component's name 
    108113     * @return  mixed   Returns an array with the info of the component and false on error 
    109114     */ 
    110     function GetComponentByName($comp_name
     115    function GetComponentByName($comp
    111116    { 
    112117        $params = array(); 
    113         $params['comp_name'] = $comp_name
     118        $params['comp_name'] = $comp
    114119 
    115120        $sql = ' 
     
    127132    } 
    128133 
     134    /** 
     135     * Get the list of components 
     136     * 
     137     * @access  public 
     138     * @param   string  $comp   Component's name 
     139     * @param   string  $type   The type of the component, (core, gadget, plugin or any components) 
     140     * @return  mixed   Returns an array with the list of the components and false on error 
     141     */ 
     142    function GetComponents($comp = '', $type = JAWS_COMPONENT_ANY) 
     143    { 
     144        $params = array(); 
     145        $params['comp_name'] = $comp; 
     146        $params['comp_type'] = $type; 
     147 
     148        $sql = " 
     149            SELECT 
     150                [id], [comp_name], [enabled] 
     151            FROM [[components]]" 
     152 
     153        if (!empty($comp)) { 
     154            $sql .= " WHERE [comp_name] = {comp_name}"; 
     155        } elseif (!empty($type)) { 
     156            $sql .= " WHERE [comp_type] = {comp_type}"; 
     157        } 
     158        $sql .= " ORDER BY [comp_type], [comp_name]"; 
     159 
     160        $result = $GLOBALS['db']->query($sql, $params); 
     161        if (Jaws_Error::isError($result)) { 
     162            return false; 
     163        } 
     164 
     165        return $result; 
     166    } 
     167 
    129168}