source: trunk/admin/include/functions_plugins.inc.php @ 1790

Last change on this file since 1790 was 1731, checked in by rvelices, 17 years ago

plugin simplification: adding admin links does not require the plugin_id anymore...

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 3.4 KB
Line 
1<?php
2// +-----------------------------------------------------------------------+
3// | PhpWebGallery - a PHP based picture gallery                           |
4// | Copyright (C) 2003-2007 PhpWebGallery Team - http://phpwebgallery.net |
5// +-----------------------------------------------------------------------+
6// | branch        : BSF (Best So Far)
7// | file          : $Id: functions_plugins.inc.php 1731 2007-01-18 02:09:31Z rvelices $
8// | last update   : $Date: 2007-01-18 02:09:31 +0000 (Thu, 18 Jan 2007) $
9// | last modifier : $Author: rvelices $
10// | revision      : $Revision: 1731 $
11// +-----------------------------------------------------------------------+
12// | This program is free software; you can redistribute it and/or modify  |
13// | it under the terms of the GNU General Public License as published by  |
14// | the Free Software Foundation                                          |
15// |                                                                       |
16// | This program is distributed in the hope that it will be useful, but   |
17// | WITHOUT ANY WARRANTY; without even the implied warranty of            |
18// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU      |
19// | General Public License for more details.                              |
20// |                                                                       |
21// | You should have received a copy of the GNU General Public License     |
22// | along with this program; if not, write to the Free Software           |
23// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
24// | USA.                                                                  |
25// +-----------------------------------------------------------------------+
26
27/* Returns an array of plugins defined in the plugin directory
28*/
29function get_fs_plugins()
30{
31  $plugins = array();
32
33  $dir = opendir(PHPWG_PLUGINS_PATH);
34  while ($file = readdir($dir))
35  {
36    if ($file!='.' and $file!='..')
37    {
38      $path = PHPWG_PLUGINS_PATH.$file;
39      if (is_dir($path) and !is_link($path)
40          and preg_match('/^[a-zA-Z0-9-_]+$/', $file )
41          and file_exists($path.'/main.inc.php')
42          )
43      {
44        $plugin = array('name'=>$file, 'version'=>'0', 'uri'=>'', 'description'=>'');
45        $plg_data = implode( '', file($path.'/main.inc.php') );
46
47        if ( preg_match("|Plugin Name: (.*)|i", $plg_data, $val) )
48        {
49          $plugin['name'] = trim( $val[1] );
50        }
51        if (preg_match("|Version: (.*)|i", $plg_data, $val))
52        {
53          $plugin['version'] = trim($val[1]);
54        }
55        if ( preg_match("|Plugin URI: (.*)|i", $plg_data, $val) )
56        {
57          $plugin['uri'] = $val[1];
58        }
59        if ( preg_match("|Description: (.*)|i", $plg_data, $val) )
60        {
61          $plugin['description'] = trim($val[1]);
62        }
63        $plugins[$file] = $plugin;
64      }
65    }
66  }
67  closedir($dir);
68  return $plugins;
69}
70
71/**
72 * Retrieves an url for a plugin page.
73 * @param string file - php script full name
74 */
75function get_admin_plugin_menu_link($file)
76{
77  global $page;
78  $real_file = realpath($file);
79  $url = get_root_url().'admin.php?page=plugin';
80  if (false!==$real_file)
81  {
82    $real_plugin_path = realpath(PHPWG_PLUGINS_PATH);
83    $file = substr($real_file, strlen($real_plugin_path)+1);
84    $file = str_replace('\\', '/', $file);//Windows
85    $url .= '&amp;section='.urlencode($file);
86  }
87  else if (isset($page['errors']))
88  {
89    array_push($page['errors'], 'PLUGIN ERROR: "'.$file.'" is not a valid file');
90  }
91  return $url;
92}
93
94?>
Note: See TracBrowser for help on using the repository browser.