Current file: /home/greg/workspace/PHPDS-dev-trunk/PHPDevShell/stable/trunk/includes/models/PHPDS_tagger.query.php
Legend: executed not executed dead code

  Coverage
  Classes Functions / Methods Lines
Total
33.33%33.33%
33.33% 2 / 6
0.00%0.00%
0.00% 0 / 4 CRAP
15.38%15.38%
15.38% 4 / 26
 
PHPDS_taggerListQuery
0.00%0.00%
0.00% 0 / 1
0.00%0.00%
0.00% 0 / 1
0.00%0.00%
0.00% 0 / 4
 extraBuild($parameters = null)
0.00%0.00%
0.00% 0 / 1 20
0.00%0.00%
0.00% 0 / 4
PHPDS_taggerLookupQuery
0.00%0.00%
0.00% 0 / 1
0.00%0.00%
0.00% 0 / 1
0.00%0.00%
0.00% 0 / 1
 getResults()
0.00%0.00%
0.00% 0 / 1 2
0.00%0.00%
0.00% 0 / 1
PHPDS_taggerMarkQuery
0.00%0.00%
0.00% 0 / 1
0.00%0.00%
0.00% 0 / 1
80.00%80.00%
80.00% 4 / 5
 checkParameters(&$parameters = null)
0.00%0.00%
0.00% 0 / 1 3.14
75.00%75.00%
75.00% 3 / 4
PHPDS_taggerListTargetQuery
100.00%100.00%
100.00% 1 / 1
  
   
100.00%100.00%
100.00% 0 / 0
PHPDS_deleteTagsQuery
100.00%100.00%
100.00% 1 / 1
  
   
100.00%100.00%
100.00% 0 / 0
PHPDS_updateTagsQuery
0.00%0.00%
0.00% 0 / 1
0.00%0.00%
0.00% 0 / 1
0.00%0.00%
0.00% 0 / 16
 invoke($parameters = null)
0.00%0.00%
0.00% 0 / 1 30
0.00%0.00%
0.00% 0 / 16


       1                 : <?php                                                                                                                                    
       2                 : /**                                                                                                                                      
       3                 :  * PHPDevShell is a RAD Framework aimed at developing administrative applications.                                                       
       4                 :  *                                                                                                                                       
       5                 :  * @package PHPDevShell                                                                                                                  
       6                 :  * @link http://www.phpdevshell.org                                                                                                      
       7                 :  * @copyright Copyright (C) 2007 Jason Schoeman, All rights reserved.                                                                    
       8                 :  * @license GNU/LGPL, see readme/licensed_under_lgpl or http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html                           
       9                 :  *                                                                                                                                       
      10                 :  * Copyright notice: See readme/notice                                                                                                   
      11                 :  * By using PHPDevShell you agree to notice and license, if you dont agree to this notice/license you are not allowed to use PHPDevShell.
      12                 :  *                                                                                                                                       
      13                 :  * This is the query engine.                                                                                                             
      14                 :  */                                                                                                                                      
      15                 : /**                                                                                                                                      
      16                 :  * Tagger - Search for tags.                                                                                                             
      17                 :  * @author Greg                                                                                                                          
      18                 :  */                                                                                                                                      
      19                 : class PHPDS_taggerListQuery extends PHPDS_query                                                                                          
      20                 : {                                                                                                                                        
      21                 :     protected $sql = "                                                                                                                   
      22                 :         SELECT                                                                                                                           
      23                 :             tagID, tagObject, tagName, tagTarget, tagValue                                                                               
      24                 :         FROM                                                                                                                             
      25                 :             _db_core_tags"; // WHERE tagTarget = '%s', tagObject = '%s', tagName = '%s', tagValue = '%s' ";                              
      26                 :     protected $where = '1';                                                                                                              
      27                 :                                                                                                                                          
      28                 :     public function extraBuild($parameters = null)                                                                                       
      29                 :     {                                                                                                                                    
      30               0 :         if (!empty($parameters['object'])) $this->addWhere("tagObject = '%(object)s'");                                                  
      31               0 :         if (!empty($parameters['name'])) $this->addWhere("tagName = '%(name)s'");                                                        
      32               0 :         if (!empty($parameters['target'])) $this->addWhere("tagTarget = '%(target)s'");                                                  
      33                 :                                                                                                                                          
      34               0 :         return parent::extraBuild($parameters);                                                                                          
      35                 :     }                                                                                                                                    
      36                 :                                                                                                                                          
      37                 : }                                                                                                                                        
      38                 :                                                                                                                                          
      39                 : /**                                                                                                                                      
      40                 :  * Tagger - Look for tags.                                                                                                               
      41                 :  * @author Greg                                                                                                                          
      42                 :  */                                                                                                                                      
      43                 : class PHPDS_taggerLookupQuery extends  PHPDS_taggerListQuery                                                                             
      44                 : {                                                                                                                                        
      45                 :     protected $singleRow = true;                                                                                                         
      46                 :     protected $focus = 'tagValue';                                                                                                       
      47                 :                                                                                                                                          
      48                 :     public function getResults()                                                                                                         
      49                 :     {                                                                                                                                    
      50               0 :         return $this->asOne(0, $this->focus);                                                                                            
      51                 :     }                                                                                                                                    
      52                 : }                                                                                                                                        
      53                 :                                                                                                                                          
      54                 : /**                                                                                                                                      
      55                 :  * Tagger - Add tags                                                                                                                     
      56                 :  * @author Greg                                                                                                                          
      57                 :  */                                                                                                                                      
      58                 : class PHPDS_taggerMarkQuery extends PHPDS_query                                                                                          
      59                 : {                                                                                                                                        
      60                 :     protected $sql = "                                                                                                                   
      61                 :         REPLACE INTO                                                                                                                     
      62                 :             _db_core_tags                                                                                                                
      63                 :         SET                                                                                                                              
      64                 :             tagObject = '%(object)s', tagName = '%(name)s', tagTarget = '%(target)s', tagValue = %(value)s ";                            
      65                 :                                                                                                                                          
      66                 :     public function checkParameters(&$parameters = null)                                                                                 
      67                 :     {                                                                                                                                    
      68              20 :         if (!isset($parameter['value']) || is_null($parameter['value'])) {                                                               
      69              20 :             $parameter['value'] = 'NULL';                                                                                                
      70              20 :         } else {                                                                                                                         
      71               0 :             $parameter['value'] = "'{$parameter['value']}'";                                                                             
      72                 :         }                                                                                                                                
      73              20 :         return true;                                                                                                                     
      74                 :     }                                                                                                                                    
      75                 : }                                                                                                                                        
      76                 :                                                                                                                                          
      77                 : /**                                                                                                                                      
      78                 :  * Tagger - List available tags.                                                                                                         
      79                 :  * @author Jason Schoeman                                                                                                                
      80                 :  */                                                                                                                                      
      81                 : class PHPDS_taggerListTargetQuery extends PHPDS_query                                                                                    
      82                 : {                                                                                                                                        
      83                 :     protected $sql = "                                                                                                                   
      84                 :         SELECT                                                                                                                           
      85                 :             tagName                                                                                                                      
      86                 :         FROM                                                                                                                             
      87                 :             _db_core_tags                                                                                                                
      88                 :         WHERE                                                                                                                            
      89                 :             tagTarget = '%s'                                                                                                             
      90                 :         AND                                                                                                                              
      91                 :             tagObject = '%s'                                                                                                             
      92                 :         ";                                                                                                                               
      93                 : }                                                                                                                                        
      94                 :                                                                                                                                          
      95                 : /**                                                                                                                                      
      96                 :  * Tagger - Delete old tags.                                                                                                             
      97                 :  * @author Jason Schoeman, Contact: titan [at] phpdevshell [dot] org.                                                                    
      98                 :  */                                                                                                                                      
      99                 : class PHPDS_deleteTagsQuery extends PHPDS_query                                                                                          
     100                 : {                                                                                                                                        
     101                 :     protected $sql = "                                                                                                                   
     102                 :         DELETE FROM                                                                                                                      
     103                 :             _db_core_tags                                                                                                                
     104                 :         WHERE                                                                                                                            
     105                 :             tagObject = '%s'                                                                                                             
     106                 :         AND                                                                                                                              
     107                 :             tagTarget = '%s'                                                                                                             
     108                 :         ";                                                                                                                               
     109                 : }                                                                                                                                        
     110                 :                                                                                                                                          
     111                 : /**                                                                                                                                      
     112                 :  * Tagger - Update tags to database.                                                                                                     
     113                 :  * @author Jason Schoeman, Contact: titan [at] phpdevshell [dot] org.                                                                    
     114                 :  */                                                                                                                                      
     115                 : class PHPDS_updateTagsQuery extends PHPDS_query                                                                                          
     116                 : {                                                                                                                                        
     117                 :     protected $sql = "                                                                                                                   
     118                 :         REPLACE INTO                                                                                                                     
     119                 :             _db_core_tags (tagID, tagObject, tagName, tagTarget, tagValue)                                                               
     120                 :         VALUES                                                                                                                           
     121                 :             %s                                                                                                                           
     122                 :         ";                                                                                                                               
     123                 :                                                                                                                                          
     124                 :     /**                                                                                                                                  
     125                 :      * Initiate query invoke command.                                                                                                    
     126                 :      */                                                                                                                                  
     127                 :     public function invoke($parameters = null)                                                                                           
     128                 :     {                                                                                                                                    
     129               0 :         list($object, $target, $value, $names) = $parameters;                                                                            
     130               0 :         if (! empty($target)) {                                                                                                          
     131                 :             // Lets just clean up old tags before we save.                                                                               
     132               0 :             $this->db->invokeQuery('PHPDS_deleteTagsQuery', $object, $target);                                                           
     133               0 :             if (! empty($names)) {                                                                                                       
     134               0 :                 $new_tags_array = explode(",", $names);                                                                                  
     135               0 :                 $new_tags = '';                                                                                                          
     136               0 :                 foreach ($new_tags_array as $tags) {                                                                                     
     137               0 :                     $new_tags .= "('', '$object', '$tags', '$target', '$value'),";                                                       
     138               0 :                 }                                                                                                                        
     139               0 :                 if (! empty($new_tags)) {                                                                                                
     140               0 :                     $new_tags = rtrim($new_tags,",");                                                                                    
     141               0 :                     return parent::invoke(array($new_tags));                                                                             
     142                 :                 }                                                                                                                        
     143               0 :             } else {                                                                                                                     
     144               0 :                 return false;                                                                                                            
     145                 :             }                                                                                                                            
     146               0 :         }                                                                                                                                
     147               0 :     }                                                                                                                                    
     148                 : }                                                                                                                                        

Generated by PHP_CodeCoverage 1.0.4 using PHP 5.3.6 and PHPUnit 3.5.14 at Mon Aug 8 22:35:38 PDT 2011.