]> CyberLeo.Net >> Repos - Github/YOURLS.git/blob - admin/plugins.php
Use global configuration constants (YOURLS_INC etc..) instead of hardcoded paths
[Github/YOURLS.git] / admin / plugins.php
1 <?php\r
2 define( 'YOURLS_ADMIN', true );\r
3 require_once( dirname(dirname(__FILE__)).'/includes/load-yourls.php' );\r
4 yourls_maybe_require_auth();\r
5 \r
6 yourls_html_head( 'plugins' );\r
7 yourls_html_logo();\r
8 yourls_html_menu();\r
9 ?>\r
10 \r
11         <h2>Plugins</h2>\r
12         \r
13         <?php\r
14         $plugins = (array)yourls_get_plugins();\r
15         $count = count( $plugins );\r
16         ?>\r
17         \r
18         <p>You currently have <strong><?php echo $count.' '.yourls_plural( 'plugin', $count ); ?></strong> activated on your setup.</p>\r
19 \r
20         <table id="tblUrl" class="tblSorter" cellpadding="0" cellspacing="1">\r
21         <thead>\r
22                 <tr>\r
23                         <th>Plugin Name</th>\r
24                         <th>Version</th>\r
25                         <th>Description</th>\r
26                         <th>Author</th>\r
27                 </tr>\r
28         </thead>\r
29         <tbody>\r
30         <?php\r
31         \r
32         foreach( $plugins as $location=>$plugin ) {\r
33                 \r
34                 // default fields to read from the plugin header\r
35                 $fields = array(\r
36                         'name'       => 'Plugin Name',\r
37                         'uri'        => 'Plugin URI',\r
38                         'desc'       => 'Description',\r
39                         'version'    => 'Version',\r
40                         'author'     => 'Author',\r
41                         'author_uri' => 'Author URI'\r
42                 );\r
43                 \r
44                 $location = str_replace( dirname( YOURLS_ABSPATH ) .'/', '', $location );\r
45                 \r
46                 // Loop through all default fields, get value if any and reset it\r
47                 foreach( $fields as $field=>$value ) {\r
48                         if( $plugin[ $value ] ) {\r
49                                 $data[ $field ] = $plugin[ $value ];\r
50                         } else {\r
51                                 $data[ $field ] = '(no info)';\r
52                         }\r
53                         unset( $plugin[$value] );\r
54                 }\r
55                 \r
56                 // Other "Fields: Value" in the header? Get them too\r
57                 if( $plugin ) {\r
58                         foreach( $plugin as $extra_field=>$extra_value ) {\r
59                                 $data['desc'] .= "<br/>\n<em>$extra_field</em>: $extra_value";\r
60                                 unset( $plugin[$extra_value] );\r
61                         }\r
62                 }\r
63                 \r
64                 $data['desc'] .= "<br/><small>plugin location: $location</small>";\r
65                 \r
66                 printf( "<tr><td><a href='%s'>%s</a></td><td>%s</td><td>%s</td><td><a href='%s'>%s</a></td></tr>",\r
67                         $data['uri'], $data['name'], $data['version'], $data['desc'], $data['author_uri'], $data['author']\r
68                         );\r
69                 \r
70         }\r
71         ?>\r
72         </tbody>\r
73         </table>\r
74         \r
75         <script type="text/javascript">\r
76         yourls_defaultsort = 0;\r
77         yourls_defaultorder = 0;\r
78         </script>\r
79         \r
80         <p>To deactivate a plugin, simply delete its directory, or rename the plugin file to something different than <code>plugin.php</code>\r
81 \r
82         \r
83 <?php yourls_html_footer(); ?>