plugins:showid:showid_code

NP_ShowID.phpのソースコード

<?php 
class NP_ShowID extends NucleusPlugin { 
	function getName() { return 'NP_ShowID'; }
	function getMinNucleusVersion() { return 330; }
	function getAuthor()  { return 'Katsumi'; }
	function getVersion() { return '0.1.2'; }
	function getURL() {return 'http://japan.nucleuscms.org/wiki/plugins:showid';}
	function getDescription() { return $this->getName().' plugin'; } 
	function supportsFeature($what) { return ($what=='SqlTablePrefix')?1:0; }
	function getEventList() { return array('AdminPrePageHead','AdminPrePageFoot'); }
	var $actions=array('overview','blogsettings','itemlist','blogcommentlist',
		'itemcommentlist','usermanagement','manageteam');
	var $ob_ok=false;
	function event_AdminPrePageHead(&$data){
		if (in_array($data['action'],$this->actions)) $this->ob_ok=ob_start();
	}
	function event_AdminPrePageFoot(&$data){
		if (!$this->ob_ok) return;
		$html=ob_get_contents();
		ob_end_clean();
		echo call_user_func(array(&$this,$data['action']),&$html);
	}
	function overview(&$html){
		$html=str_replace('<tr><th>'._NAME.'</th>','<tr><th>ID</th><th>'._NAME.'</th>',$html);
		$html=preg_replace('/<td title=\'blogid:([0-9]+) shortname:/','<td>$1</td><td title=\'blogid:$1 shortname:',$html);
		return $html;
	}
	function blogsettings(&$html){
		$html=str_replace("<th>"._LISTS_NAME."</th><th>"._LISTS_DESC."</th><th colspan='2'>"._LISTS_ACTIONS."</th>",
			"<th>ID</th><th>"._LISTS_NAME."</th><th>"._LISTS_DESC."</th><th colspan='2'>"._LISTS_ACTIONS."</th>",$html);
		$html=preg_replace('/<td><input type="checkbox" id="batch([0-9]+)" name="batch\[([0-9]+)\]" value="([0-9]+)" \/>/',
			'<td>$3</td><td><input type="checkbox" id="batch$1" name="batch[$2]" value="$3" />',$html);
		return $html;
	}
	function usermanagement(&$html){
		$html=str_replace('<th>' . _LIST_MEMBER_NAME . '</th><th>' . _LIST_MEMBER_RNAME . '</th><th>',
			'<th>ID</th><th>' . _LIST_MEMBER_NAME . '</th><th>' . _LIST_MEMBER_RNAME . '</th><th>',$html);
		$html=preg_replace('/<td><input type="checkbox" id="batch([0-9]+)" name="batch\[([0-9]+)\]" value="([0-9]+)" \/>/',
			'<td>$3</td><td><input type="checkbox" id="batch$1" name="batch[$2]" value="$3" />',$html);
		return $html;
	}
	function manageteam(&$html){
		return $this->usermanagement($html);
	}
	function itemlist(&$html){
		$html=preg_replace('/<\/td><td[\s]?><input type="checkbox" id="batch([0-9]+)" name="batch\[([0-9]+)\]" value="([0-9]+)" \/>/',
			'<br />ID: $3</td><td><input type="checkbox" id="batch$1" name="batch[$2]" value="$3" />',$html);	
		return $html;
	}
	function blogcommentlist(&$html){
		return $this->itemlist($html);
	}
	function itemcommentlist(&$html){
		return $this->itemlist($html);
	}
}
?>
 
plugins/showid/showid_code.txt · 最終更新: 2011/03/23 21:28 (外部編集)