1<?php 2/** 3 * DokuWiki Plugin likeit 4 * 5 * @license GPL 2 (http://www.gnu.org/licenses/gpl.html) 6 * @author lisps 7 */ 8 9// must be run within Dokuwiki 10if (!defined('DOKU_INC')) die(); 11 12if (!defined('DOKU_LF')) define('DOKU_LF', "\n"); 13if (!defined('DOKU_TAB')) define('DOKU_TAB', "\t"); 14if (!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/'); 15 16require_once(DOKU_INC.'inc/auth.php'); 17 18class helper_plugin_likeit extends DokuWiki_Plugin { 19 20 protected $_user = array(); 21 22 /* 23 * generate html code 24 * @param $ids string|array ids separated by space 25 * @return string html code 26 */ 27 public function setUser($users) { 28 global $auth; 29 $this->_user = array(); 30 if(!is_array($users)) { 31 if($users == '') return ''; 32 $users_r = explode(" ",trim($users)); 33 34 } else { 35 if(empty($users)) return ''; 36 $users_r = $users; 37 } 38 39 $userdata = array(); 40 foreach($users_r as $user) { 41 $data = $auth->getUserData($user); 42 if($data) { 43 $userdata[$user] = $data; 44 } 45 } 46 47 48 $this->_user = $userdata; 49 50 return count($users_r); 51 } 52 53 public function getUserCount() { 54 return count($this->_user); 55 } 56 57 58 public function getUserList() { 59 $user = array_map(function($value){return $value['name'];},$this->_user); 60 return $user; 61 62 63 } 64 65 public function renderUserList() { 66 $return = ''; 67 foreach($this->getUserList() as $user) { 68 $return .= "<span class='listitem'>" . hsc($user) . "</span>"; 69 } 70 71 return $return; 72 } 73 74 75 76} 77 78// vim:ts=4:sw=4:et: 79