• R/O
  • SSH
  • HTTPS

jeanscms: コミット


コミットメタ情報

リビジョン353 (tree)
日時2014-10-26 12:20:59
作者kmorimatsu

ログメッセージ

jp_SearchJeansEvents created.

変更サマリ

差分

--- plugins/SearchJeansEvents/trunk/jp_SearchJeansEvents.php (revision 0)
+++ plugins/SearchJeansEvents/trunk/jp_SearchJeansEvents.php (revision 353)
@@ -0,0 +1,23 @@
1+<?php
2+/*
3+ * Jeans CMS (GPL license)
4+ * $Id$
5+ */
6+
7+class jp_SearchJeansEvents extends plugin{
8+ static public function name(){
9+ return 'Search Jeans Events';
10+ }
11+ static public function author(){
12+ return 'Katsumi';
13+ }
14+ static public function url(){
15+ return 'http://jeanscms.sourceforge.jp/';
16+ }
17+ static public function desc(){
18+ return 'This is to find out what Jeans events are defined.';
19+ }
20+ static public function version(){
21+ return '0.1';
22+ }
23+}
\ No newline at end of file
Added: svn:keywords
## -0,0 +1 ##
+Id HeadURL LastChangedDate LastChangedBy LastChangedRevision
\ No newline at end of property
Added: svn:eol-style
## -0,0 +1 ##
+CRLF
\ No newline at end of property
--- plugins/SearchJeansEvents/trunk/searchjeansevents/jp_SearchJeansEvents_class.php (revision 0)
+++ plugins/SearchJeansEvents/trunk/searchjeansevents/jp_SearchJeansEvents_class.php (revision 353)
@@ -0,0 +1,124 @@
1+<?php
2+class jp_SearchJeansEvents_class extends jeans{
3+ static private $events=array();
4+ static public function init(){
5+ // Only superadmin can use this class
6+ if (!member::is_admin()) error::quit('_ADMIN_NO_PERMISSION');
7+ // Find out all tags
8+ self::$events=self::import_tag_data();
9+ }
10+ static private function import_tag_data($base_dir='',$dir='',&$events=null){
11+ if ($base_dir==='') {
12+ // Initialize, search two directories and return result.
13+ $events=array();
14+ self::import_tag_data(_DIR_LIBS,'',$events);
15+ // Enable following line if you need to pick up tags from plugins
16+ //self::import_tag_data(_DIR_PLUGINS,'',$events);
17+ return $events;
18+ }
19+ if (!self::local_file_exists($base_dir,$dir)) return;
20+ $d=dir($base_dir.$dir);
21+ while($file=$d->read()){
22+ if (is_dir($base_dir.$dir.$file) && substr($file,0,1)!='.') {
23+ self::import_tag_data($base_dir,$dir.$file.'/',$events);
24+ } elseif (substr($file,-4)=='.php') {
25+ $events=array_merge($events,self::pick_up_tags($base_dir,$dir.$file));
26+ }
27+ }
28+ }
29+ static private function pick_up_tags($base_dir,$file){
30+ static $search;
31+ if (!isset($search)) {
32+ $search='/';
33+ $search.='(?:static[\s]+public|public[\s]+static)[\s]+function[\s]+';
34+ $search.='(tag_|if_)([\S]+)[\s]*';
35+ $search.='\(('. '[^\)]*|' . "'(?:[^'\\\\]+|\\\\[.])'" .'"(?:[^"\\\\]+|\\\\[.])"' . ')\)';
36+ $search.='/i';
37+
38+ $search='/';
39+ $search.='core::event[\s]*\([\s]*\'';
40+ $search.='([^\']*)\'';
41+ $search.='/i';
42+ }
43+ $events=array();
44+ $contents=self::local_file_contents($base_dir,$file);
45+ if (!$contents) return array();
46+ $array=preg_split('/(class[\s]+(?:[\S]+)[\s]+extends)/i',$contents,-1,PREG_SPLIT_DELIM_CAPTURE);
47+ $data=array();
48+ $cr=1;
49+ foreach($array as $each){
50+ if (preg_match('/^class[\s]+([\S]+)[\s]+extends$/i',$each,$m)){
51+ $class=strtr($m[1],'_','.');
52+ } elseif (isset($class) && preg_match_all($search,$each,$ms,PREG_SET_ORDER)) {
53+ if ($class=='nonmember') continue;
54+ foreach($ms as $m){
55+ $line=$cr+preg_match_all('/(\r\n|\r|\n)/',substr($each,0,strpos($each,$m[0])),$temp);
56+ $name=$m[1];
57+ $events[$name]=array($file,$line,preg_replace('/^.*\/([^\/]*)$/','$1',$file));
58+ }
59+ }
60+ $cr+=preg_match_all('/(\r\n|\r|\n)/',$each,$temp);
61+ }
62+ return $events;
63+ }
64+ static public function tag_list(&$data,$skin=false){
65+ $array=array();
66+ foreach(self::$events as $event=>$desc){
67+ $array[]=array('event'=>$event,'file'=>$desc[0],'line'=>$desc[1],'basename'=>$desc[2]);
68+ }
69+ view::show_using_array($data,$array,$skin);
70+ }
71+ static public function action_get_showphp(){
72+ $contents=self::local_file_contents(_DIR_LIBS,$_GET['file_path']);
73+ $contents=htmlspecialchars($contents,ENT_NOQUOTES,'UTF-8');
74+ $contents=self::color_code($contents);
75+ if (!preg_match_all('/(.*)(\r\n|\r|\n|$)/',$contents,$ms,PREG_SET_ORDER)) exit;
76+ self::echo_html('<html><body><pre>');
77+ foreach($ms as $key=>$m){
78+ self::echo_html('<a name="'.($key+1).'"></a>'.$m[0]);
79+ }
80+ self::echo_html('</body></html>');
81+ exit;
82+ }
83+ static private function color_code($m){
84+ static $statements;
85+ if (!is_array($m) && !isset($statements)) {
86+ $statements=array('abstract','and','array','as','break',
87+ 'case','catch','class','clone',
88+ 'const','continue','declare','default','do',
89+ 'else','elseif','enddeclare','endfor','endforeach',
90+ 'endif','endswitch','endwhile','extends','final',
91+ 'for','foreach','function','global','goto',
92+ 'if','implements','interface','instanceof',
93+ 'namespace','new','or','private',
94+ 'protected','public','static','switch','throw',
95+ 'try','use','var','while','xor',
96+ 'die','echo','empty','exit','eval',
97+ 'include','include_once','isset','list','require',
98+ 'require_once','return','print','unset');
99+ $search='/\*[\s\S]*?\*/'; // multi line comments
100+ $search.='|//.*[\r\n]'; // single line comments
101+ $search.='|#.*[\r\n]'; // single line comments
102+ $search.='|\?>[\s\S]*?<\?php'; // strings
103+ $search.='|\$?(?:[a-z_][a-z0-9_]*)'; // valiables, statements and functions
104+ $search.='|[0-9]+'; // numbers
105+ $search.='|"(?:\\\\.|[^"]*)"'; // strings
106+ $search.="|'(?:\\\\.|[^']*)'"; // strings
107+ return substr(preg_replace_callback('@'.$search.'@i',array('self','color_code'),'?>'.$m),2);
108+ }
109+ switch(substr($m[0],0,1)){
110+ case '/':
111+ return '<span style="color:grey;">'.$m[0].'</span>';
112+ case '$':
113+ return '<span style="color:brown;">'.$m[0].'</span>';
114+ case '"': case "'":
115+ return '<span style="color:green;">'.$m[0].'</span>';
116+ case '0': case '1': case '2': case '3': case '4':
117+ case '5': case '6': case '7': case '8': case '9':
118+ return '<span style="color:red;">'.$m[0].'</span>';
119+ default:
120+ if (in_array($m[0],$statements)) return '<span style="color: blue;">'.$m[0].'</span>';
121+ return $m[0];
122+ }
123+ }
124+}
\ No newline at end of file
Added: svn:keywords
## -0,0 +1 ##
+Id HeadURL LastChangedDate LastChangedBy LastChangedRevision
\ No newline at end of property
Added: svn:eol-style
## -0,0 +1 ##
+CRLF
\ No newline at end of property
旧リポジトリブラウザで表示