| 1 | <?php |
|---|
| 2 | // Load configuration variables from database, plog-globals, & plog-includes/plog-functions |
|---|
| 3 | require_once(dirname(dirname(__FILE__)).'/plog-load-config.php'); |
|---|
| 4 | require(PLOGGER_DIR.'plog-admin/plog-admin.php'); |
|---|
| 5 | |
|---|
| 6 | global $config; |
|---|
| 7 | |
|---|
| 8 | function read_dir($path) { |
|---|
| 9 | $dir_arr = array (); |
|---|
| 10 | $handle = opendir($path); |
|---|
| 11 | |
|---|
| 12 | while ($file = readdir($handle)) { |
|---|
| 13 | if (is_dir($path.$file) && substr($file, 0, 1) != '.') { |
|---|
| 14 | $dir_arr[] = $path.$file.'/' ; |
|---|
| 15 | } |
|---|
| 16 | } |
|---|
| 17 | |
|---|
| 18 | return $dir_arr; |
|---|
| 19 | } |
|---|
| 20 | |
|---|
| 21 | $output = "\n\t" . '<h1>'.plog_tr('Manage Plugins').'</h1>'; |
|---|
| 22 | |
|---|
| 23 | $plugin_dir = $config['basedir'].'plog-content/plugins/'; |
|---|
| 24 | |
|---|
| 25 | // Scan list of folders within plugins directory |
|---|
| 26 | $plugin_list = read_dir($plugin_dir); |
|---|
| 27 | sort($plugin_list); |
|---|
| 28 | |
|---|
| 29 | $output .= "\n\n\t\t" . '<div class="info"> |
|---|
| 30 | |
|---|
| 31 | <p class="no-margin-top">'.plog_tr('Plugins allow you to extend your Plogger gallery by adding new functionality to the gallery itself or by making your gallery content available for use elsewhere on your website.').'</p> |
|---|
| 32 | |
|---|
| 33 | <p class="no-margin-bottom">'.plog_tr('New plugins should be uploaded to the <span style="color: #800; font-weight: bold;">/plog-content/plugins/</span> directory.').'</p> |
|---|
| 34 | |
|---|
| 35 | </div><!-- /info-->'; |
|---|
| 36 | |
|---|
| 37 | // Output table header |
|---|
| 38 | $output .= "\n\n\t\t" . '<table id="plugin-table" cellpadding="4" cellspacing="0" width="100%"> |
|---|
| 39 | <tr class="header"> |
|---|
| 40 | <th class="table-header-left align-left width-175">'.plog_tr('Plugin').'</th> |
|---|
| 41 | <th class="table-header-middle align-left width-75">'.plog_tr('Version').'</th> |
|---|
| 42 | <th class="table-header-middle align-left">'.plog_tr('Description').'</th> |
|---|
| 43 | <th class="table-header-middle align-left width-100">'.plog_tr('Author').'</th> |
|---|
| 44 | <th class="table-header-right align-left width-100">'.plog_tr('Usage Info').'</th> |
|---|
| 45 | </tr>' . "\n"; |
|---|
| 46 | $counter = 0; |
|---|
| 47 | |
|---|
| 48 | foreach($plugin_list as $plugin_folder_name) { |
|---|
| 49 | $meta_file = $plugin_folder_name.'meta.php'; |
|---|
| 50 | |
|---|
| 51 | $plugin_folder_basename = basename($plugin_folder_name); |
|---|
| 52 | |
|---|
| 53 | // Only display plugin as available if meta information exists for it |
|---|
| 54 | if (is_file($meta_file)) { |
|---|
| 55 | // Set up default variables if plugin author forgets a meta input |
|---|
| 56 | $plugin_name = $version = $author = $url = $description = $license = $instructions = ''; |
|---|
| 57 | // Pull in meta information |
|---|
| 58 | include($meta_file); |
|---|
| 59 | |
|---|
| 60 | if ($counter%2 == 0) { |
|---|
| 61 | $table_row_color = 'color-1'; |
|---|
| 62 | } else { |
|---|
| 63 | $table_row_color = 'color-2'; |
|---|
| 64 | } |
|---|
| 65 | |
|---|
| 66 | $output .= "\n\t\t\t" . '<tr class="'.$table_row_color.'" id="'.$plugin_folder_basename.'"> |
|---|
| 67 | <td class="align-left width-175"><strong>'.$plugin_name.'</strong></td> |
|---|
| 68 | <td class="align-left width-75">'.$version.'</td> |
|---|
| 69 | <td class="align-left">'.$description.'<br />• '.plog_tr('Released under the').' '.$license.'.</td> |
|---|
| 70 | <td class="align-left width-100"><a href="'.$url.'">'.$author.'</a></td> |
|---|
| 71 | <td class="width-100"> |
|---|
| 72 | <a id="'.$plugin_folder_basename.'-use" style="display: inline;" href="#'.$plugin_folder_basename.'" onclick="toggle(\''.$plugin_folder_basename.'-code, '.$plugin_folder_basename.'-use, '.$plugin_folder_basename.'-hide\');">'.plog_tr('Use this plugin').'</a> |
|---|
| 73 | <a id="'.$plugin_folder_basename.'-hide" style="display: none;" href="#'.$plugin_folder_basename.'" onclick="toggle(\''.$plugin_folder_basename.'-code, '.$plugin_folder_basename.'-use, '.$plugin_folder_basename.'-hide\');">'.plog_tr('Hide the code').'</a> |
|---|
| 74 | </td> |
|---|
| 75 | </tr>'; |
|---|
| 76 | |
|---|
| 77 | // Display the code to use the plugin |
|---|
| 78 | $output .= "\n\t\t\t" . '<tr class="'.$table_row_color.'" id="'.$plugin_folder_basename.'-code" style="display: none;"> |
|---|
| 79 | <td class="align-left width-175"> </td> |
|---|
| 80 | <td class="align-left" colspan="4"> |
|---|
| 81 | <div class="plugins"> |
|---|
| 82 | <p class="no-margin-top"><strong>'.plog_tr('PHP include code').':</strong><br /><span style="color: #264e75; font-weight: bold;"><?php include(\''.$plugin_folder_name.$plugin_folder_basename.'.php\'); ?></span></p>'; |
|---|
| 83 | if (!empty($instructions)) { |
|---|
| 84 | $output .= "\n\t\t\t\t\t" . '<p class="no-margin-bottom"><strong>'.plog_tr('Instructions').':</strong><br />'.$instructions.'</p>'; |
|---|
| 85 | } |
|---|
| 86 | $output .= "\n\t\t\t\t\t" . '</div> |
|---|
| 87 | </td> |
|---|
| 88 | </tr>'; |
|---|
| 89 | |
|---|
| 90 | $counter++; |
|---|
| 91 | } |
|---|
| 92 | |
|---|
| 93 | } |
|---|
| 94 | |
|---|
| 95 | $output .= "\n\t\t\t" . '<tr class="footer"> |
|---|
| 96 | <td colspan="5" style="padding: 1px;"> </td> |
|---|
| 97 | </tr> |
|---|
| 98 | </table>' . "\n"; |
|---|
| 99 | |
|---|
| 100 | display($output, 'plugins'); |
|---|
| 101 | |
|---|
| 102 | ?> |
|---|