action.php
changeset 1 347546fd9315
parent 0 11a7dcc4af7a
child 3 88d936428bed
equal deleted inserted replaced
0:11a7dcc4af7a 1:347546fd9315
    22     }
    22     }
    23 
    23 
    24     function register(&$controller) {
    24     function register(&$controller) {
    25         global $JSINFO;
    25         global $JSINFO;
    26         $JSINFO['plugin']['datapopup']['registered_types'] = $this->getConf('registered_types');
    26         $JSINFO['plugin']['datapopup']['registered_types'] = $this->getConf('registered_types');
       
    27         
       
    28         $controller->register_hook('AJAX_CALL_UNKNOWN', 'BEFORE', $this, 'handle_ajax_call_unknown');
    27     }
    29     }
    28 
    30 
    29     function getFields($link, $name) {
    31     protected function _getFields($link, $name) {
    30         return $this->dthlp->_resolveSummary($link, $name);
    32         if(!$this->dthlp)
       
    33           return "The datapopup plugin reported an error. Please report.";
       
    34         
       
    35         $sqlite = $this->dthlp->_getDB();
       
    36         if(!$sqlite) return "The datapopup had an error retrieving the SQLite plugin. Please report.";
       
    37         $query = "SELECT data.value FROM data JOIN pages ON data.pid=pages.pid WHERE pages.page='".$link."' AND data.key='".strtolower($name)."';";
       
    38         $res = $sqlite->query($query);
       
    39         $rows = $sqlite->res2arr($res);
       
    40         return $rows[0]['value'];
    31     }
    41     }
       
    42     
       
    43     public function handle_ajax_call_unknown(Doku_Event &$event, $param) {
       
    44         if($event->data != 'plugin_datapopup') return;    
       
    45         global $auth;
       
    46         global $INPUT;
       
    47 
       
    48         $link = $INPUT->str('link');
       
    49         
       
    50         $fields = explode(',',$this->getConf('fields'));
       
    51         $fields = array_map('trim',$fields);
       
    52         $fields = array_filter($fields);
       
    53 
       
    54         echo '<ul>';
       
    55         foreach($fields as $name){
       
    56             $val = $this->_getFields($link, $name);
       
    57             if($val != "")
       
    58             {
       
    59                 echo '<li class="dataov_name">';
       
    60                 echo '<div class="li">';
       
    61                 echo hsc($name);
       
    62                 echo '</div></li>';
       
    63                 echo '<li class="dataov_'.hsc($name).'">';
       
    64                 echo '<div class="li">';
       
    65                 echo hsc($val);
       
    66                 echo '</div></li>';
       
    67             }
       
    68         }
       
    69         echo '</ul>';                
       
    70     
       
    71         
       
    72         $event->preventDefault();
       
    73         $event->stopPropagation();
       
    74     }        
    32 
    75 
    33 }
    76 }
    34 
    77 
    35 // vim:ts=4:sw=4:et:enc=utf-8:
    78 // vim:ts=4:sw=4:et:enc=utf-8: