Beispiel #1
0
 function uploaded()
 {
     if (!is_admin()) {
         return info_page(__('ADMIN_ONLY_LOGIN'));
     }
     if ($_FILES['pfile']['error'] != 0) {
         return info_page(__('PLUGIN_UPLOAD_FILE_ERROR_RETRY'));
     }
     $tmp_name = $_FILES['pfile']['tmp_name'];
     $tname = uid() . '-' . time();
     $plug_path = c('plugin_path') . DS . $tname;
     if (@mkdir($plug_path)) {
         include_once AROOT . 'lib' . DS . 'dUnzip2.inc.php';
         $zip = new dUnzip2($tmp_name);
         $zip->debug = false;
         $zip->unzipAll($plug_path);
         @chmod($plug_path, 0755);
         $info_file = $plug_path . DS . 'app.php';
         if (file_exists($info_file)) {
             if ($info = get_plugin_info(file_get_contents($info_file))) {
                 if (isset($info['folder_name'])) {
                     $folder_name = $info['folder_name'];
                 }
                 if (strlen($folder_name) < 1) {
                     $folder_name = reset(explode('.', basename($_FILES['pfile']['name'])));
                 }
                 if (strlen($folder_name) > 0) {
                     if (file_exists(c('plugin_path') . DS . $folder_name)) {
                         @rename(c('plugin_path') . DS . $folder_name . DS . 'app.php', c('plugin_path') . DS . $folder_name . DS . 'app.bak.php');
                         @rename(c('plugin_path') . DS . $folder_name, c('plugin_path') . DS . $folder_name . '_' . uid() . '_' . time());
                     }
                     rename($plug_path, c('plugin_path') . DS . $folder_name);
                     header("Location: ?c=pluglist");
                     return true;
                 } else {
                     return info_page(__('PLUGIN_GET_NAME_ERROR_RETRY', $tname));
                 }
             }
         } else {
             // clear dir
         }
         return info_page(__('PLUGIN_PACKAGE_FORMAT_ERROR'));
     } else {
         return info_page(__('PLUGIN_CREATE_FOLDER_ERROR'));
     }
 }
Beispiel #2
0
 function uploaded()
 {
     if (!is_admin()) {
         return info_page('只有管理员才能进入此页面,<a href="?c=guest&a=logout">请先用管理员账户登入</a>');
     }
     if ($_FILES['pfile']['error'] != 0) {
         return info_page('文件上传错误,请重新上传');
     }
     $tmp_name = $_FILES['pfile']['tmp_name'];
     $tname = uid() . '-' . time();
     $plug_path = c('plugin_path') . DS . $tname;
     if (@mkdir($plug_path)) {
         include_once AROOT . 'lib' . DS . 'dUnzip2.inc.php';
         $zip = new dUnzip2($tmp_name);
         $zip->debug = false;
         $zip->unzipAll($plug_path);
         @chmod($plug_path, 0755);
         $info_file = $plug_path . DS . 'app.php';
         if (file_exists($info_file)) {
             if ($info = get_plugin_info(file_get_contents($info_file))) {
                 if (isset($info['folder_name'])) {
                     $folder_name = $info['folder_name'];
                 }
                 if (strlen($folder_name) < 1) {
                     $folder_name = reset(explode('.', basename($_FILES['pfile']['name'])));
                 }
                 if (strlen($folder_name) > 0) {
                     if (file_exists(c('plugin_path') . DS . $folder_name)) {
                         @rename(c('plugin_path') . DS . $folder_name . DS . 'app.php', c('plugin_path') . DS . $folder_name . DS . 'app.bak.php');
                         @rename(c('plugin_path') . DS . $folder_name, c('plugin_path') . DS . $folder_name . '_' . uid() . '_' . time());
                     }
                     rename($plug_path, c('plugin_path') . DS . $folder_name);
                     header("Location: ?c=pluglist");
                     return true;
                 } else {
                     return info_page('尝试获取插件名称失败,启用' . $tname . '作为临时名称,<a href="?c=pluglist">请点击继续</a>');
                 }
             }
         } else {
             // clear dir
         }
         return info_page('找不到插件执行脚本-app.php文件,<a href="?c=pluglist">请重新上传格式正确的插件包</a>');
     } else {
         return info_page('创建插件目录失败,请将plugin目录设置为可写后<a href="?c=pluglist">重试</a>');
     }
 }
Beispiel #3
0
                $error = true;
                $sysmsg[] = $ids_arr[1];
            } else {
                $plugin_ids = $ids_arr[1];
            }
            if (!$error) {
                $db->query_unbuffered("update {$tpf}plugins set actived=0 where plugin_name in({$plugin_ids})");
                $sysmsg[] = __('plugins_inactived_success');
                redirect($_SERVER['HTTP_REFERER'], $sysmsg);
            } else {
                redirect('back', $sysmsg);
            }
        } else {
            syn_plugins();
            $sql_do = "";
            $perpage = 10;
            $rs = $db->fetch_one_array("select count(*) as total_num from {$tpf}plugins {$sql_do}");
            $total_num = $rs['total_num'];
            $start_num = ($pg - 1) * $perpage;
            $q = $db->query("select * from {$tpf}plugins {$sql_do} order by actived desc, plugin_name asc limit {$start_num},{$perpage}");
            while ($rs = $db->fetch_array($q)) {
                if (check_plugin($rs['plugin_name'])) {
                    $plugins_arr[] = get_plugin_info($rs['plugin_name']);
                }
            }
            $db->free($q);
            unset($rs);
            $page_nav = multi($total_num, $perpage, $pg, urr(ADMINCP, "item={$item}&menu=plugin&action={$action}"));
            require_once template_echo($item, $admin_tpl_dir, '', 1);
        }
}
Beispiel #4
0
/**
 * Plugins admin page
 *
 * @param App $a
 * @return string
 */
function admin_page_plugins(&$a)
{
    /**
     * Single plugin
     */
    if ($a->argc == 3) {
        $plugin = $a->argv[2];
        if (!is_file("addon/{$plugin}/{$plugin}.php")) {
            notice(t("Item not found."));
            return '';
        }
        if (x($_GET, "a") && $_GET['a'] == "t") {
            check_form_security_token_redirectOnErr('/admin/plugins', 'admin_themes', 't');
            // Toggle plugin status
            $idx = array_search($plugin, $a->plugins);
            if ($idx !== false) {
                unset($a->plugins[$idx]);
                uninstall_plugin($plugin);
                info(sprintf(t("Plugin %s disabled."), $plugin));
            } else {
                $a->plugins[] = $plugin;
                install_plugin($plugin);
                info(sprintf(t("Plugin %s enabled."), $plugin));
            }
            set_config("system", "addon", implode(", ", $a->plugins));
            goaway($a->get_baseurl(true) . '/admin/plugins');
            return '';
            // NOTREACHED
        }
        // display plugin details
        require_once 'library/markdown.php';
        if (in_array($plugin, $a->plugins)) {
            $status = "on";
            $action = t("Disable");
        } else {
            $status = "off";
            $action = t("Enable");
        }
        $readme = Null;
        if (is_file("addon/{$plugin}/README.md")) {
            $readme = file_get_contents("addon/{$plugin}/README.md");
            $readme = Markdown($readme);
        } else {
            if (is_file("addon/{$plugin}/README")) {
                $readme = "<pre>" . file_get_contents("addon/{$plugin}/README") . "</pre>";
            }
        }
        $admin_form = "";
        if (is_array($a->plugins_admin) && in_array($plugin, $a->plugins_admin)) {
            @(require_once "addon/{$plugin}/{$plugin}.php");
            $func = $plugin . '_plugin_admin';
            $func($a, $admin_form);
        }
        $t = get_markup_template("admin_plugins_details.tpl");
        return replace_macros($t, array('$title' => t('Administration'), '$page' => t('Plugins'), '$toggle' => t('Toggle'), '$settings' => t('Settings'), '$baseurl' => $a->get_baseurl(true), '$plugin' => $plugin, '$status' => $status, '$action' => $action, '$info' => get_plugin_info($plugin), '$str_author' => t('Author: '), '$str_maintainer' => t('Maintainer: '), '$admin_form' => $admin_form, '$function' => 'plugins', '$screenshot' => '', '$readme' => $readme, '$form_security_token' => get_form_security_token("admin_themes")));
    }
    /**
     * List plugins
     */
    $plugins = array();
    $files = glob("addon/*/");
    /* */
    if ($files) {
        foreach ($files as $file) {
            if (is_dir($file)) {
                list($tmp, $id) = array_map("trim", explode("/", $file));
                $info = get_plugin_info($id);
                $show_plugin = true;
                // If the addon is unsupported, then only show it, when it is enabled
                if (strtolower($info["status"]) == "unsupported" and !in_array($id, $a->plugins)) {
                    $show_plugin = false;
                }
                // Override the above szenario, when the admin really wants to see outdated stuff
                if (get_config("system", "show_unsupported_addons")) {
                    $show_plugin = true;
                }
                if ($show_plugin) {
                    $plugins[] = array($id, in_array($id, $a->plugins) ? "on" : "off", $info);
                }
            }
        }
    }
    $t = get_markup_template("admin_plugins.tpl");
    return replace_macros($t, array('$title' => t('Administration'), '$page' => t('Plugins'), '$submit' => t('Save Settings'), '$baseurl' => $a->get_baseurl(true), '$function' => 'plugins', '$plugins' => $plugins, '$form_security_token' => get_form_security_token("admin_themes")));
}
Beispiel #5
0
/**
+----------------------------------------------------------
* 读取插件
+----------------------------------------------------------
* @param string $path 插件目录
* @param string $app 所属项目名
+----------------------------------------------------------
* @return Array
+----------------------------------------------------------
*/
function get_plugins($path = PLUGIN_PATH, $app = APP_NAME, $ext = '.php')
{
    static $plugins = array();
    if (isset($plugins[$app])) {
        return $plugins[$app];
    }
    // 如果插件目录为空 返回空数组
    if (empty_dir($path)) {
        return array();
    }
    $path = realpath($path);
    // 缓存无效 重新读取插件文件
    /*
        $dir = glob ( $path . '/*' );
        if($dir) {
    foreach($dir as $val) {
         if(is_dir($val)){
             $subdir = glob($val.'/*'.$ext);
             if($subdir) {
                 foreach($subdir as $file)
                     $plugin_files[] = $file;
             }
         }else{
             if (strrchr($val, '.') == $ext)
                 $plugin_files[] = $val;
         }
    }
    */
    $dir = dir($path);
    if ($dir) {
        $plugin_files = array();
        while (false !== ($file = $dir->read())) {
            if ($file == "." || $file == "..") {
                continue;
            }
            if (is_dir($path . '/' . $file)) {
                $subdir = dir($path . '/' . $file);
                if ($subdir) {
                    while (($subfile = $subdir->read()) !== false) {
                        if ($subfile == "." || $subfile == "..") {
                            continue;
                        }
                        if (preg_match('/\\.php$/', $subfile)) {
                            $plugin_files[] = "{$file}/{$subfile}";
                        }
                    }
                    $subdir->close();
                }
            } else {
                $plugin_files[] = $file;
            }
        }
        $dir->close();
        //对插件文件排序
        if (count($plugin_files) > 1) {
            sort($plugin_files);
        }
        $plugins[$app] = array();
        foreach ($plugin_files as $plugin_file) {
            if (!is_readable("{$path}/{$plugin_file}")) {
                continue;
            }
            //取得插件文件的信息
            $plugin_data = get_plugin_info("{$path}/{$plugin_file}");
            if (empty($plugin_data['name'])) {
                continue;
            }
            $plugins[$app][] = $plugin_data;
        }
        return $plugins[$app];
    } else {
        return array();
    }
}
Beispiel #6
0
 /**
  * Plugins admin page
  *
  * @param App $a
  * @return string
  */
 function admin_page_plugins(&$a)
 {
     /*
      * Single plugin
      */
     if (\App::$argc == 3) {
         $plugin = \App::$argv[2];
         if (!is_file("addon/{$plugin}/{$plugin}.php")) {
             notice(t("Item not found."));
             return '';
         }
         $enabled = in_array($plugin, \App::$plugins);
         $info = get_plugin_info($plugin);
         $x = check_plugin_versions($info);
         // disable plugins which are installed but incompatible versions
         if ($enabled && !$x) {
             $enabled = false;
             $idz = array_search($plugin, \App::$plugins);
             if ($idz !== false) {
                 unset(\App::$plugins[$idz]);
                 uninstall_plugin($plugin);
                 set_config("system", "addon", implode(", ", \App::$plugins));
             }
         }
         $info['disabled'] = 1 - intval($x);
         if (x($_GET, "a") && $_GET['a'] == "t") {
             check_form_security_token_redirectOnErr('/admin/plugins', 'admin_plugins', 't');
             // Toggle plugin status
             $idx = array_search($plugin, \App::$plugins);
             if ($idx !== false) {
                 unset(\App::$plugins[$idx]);
                 uninstall_plugin($plugin);
                 info(sprintf(t("Plugin %s disabled."), $plugin));
             } else {
                 \App::$plugins[] = $plugin;
                 install_plugin($plugin);
                 info(sprintf(t("Plugin %s enabled."), $plugin));
             }
             set_config("system", "addon", implode(", ", \App::$plugins));
             goaway(z_root() . '/admin/plugins');
         }
         // display plugin details
         require_once 'library/markdown.php';
         if (in_array($plugin, \App::$plugins)) {
             $status = 'on';
             $action = t('Disable');
         } else {
             $status = 'off';
             $action = t('Enable');
         }
         $readme = null;
         if (is_file("addon/{$plugin}/README.md")) {
             $readme = file_get_contents("addon/{$plugin}/README.md");
             $readme = Markdown($readme);
         } else {
             if (is_file("addon/{$plugin}/README")) {
                 $readme = "<pre>" . file_get_contents("addon/{$plugin}/README") . "</pre>";
             }
         }
         $admin_form = '';
         $r = q("select * from addon where plugin_admin = 1 and name = '%s' limit 1", dbesc($plugin));
         if ($r) {
             @(require_once "addon/{$plugin}/{$plugin}.php");
             if (function_exists($plugin . '_plugin_admin')) {
                 $func = $plugin . '_plugin_admin';
                 $func($a, $admin_form);
             }
         }
         $t = get_markup_template('admin_plugins_details.tpl');
         return replace_macros($t, array('$title' => t('Administration'), '$page' => t('Plugins'), '$toggle' => t('Toggle'), '$settings' => t('Settings'), '$baseurl' => z_root(), '$plugin' => $plugin, '$status' => $status, '$action' => $action, '$info' => $info, '$str_author' => t('Author: '), '$str_maintainer' => t('Maintainer: '), '$str_minversion' => t('Minimum project version: '), '$str_maxversion' => t('Maximum project version: '), '$str_minphpversion' => t('Minimum PHP version: '), '$str_requires' => t('Requires: '), '$disabled' => t('Disabled - version incompatibility'), '$admin_form' => $admin_form, '$function' => 'plugins', '$screenshot' => '', '$readme' => $readme, '$form_security_token' => get_form_security_token('admin_plugins')));
     }
     /*
      * List plugins
      */
     $plugins = array();
     $files = glob('addon/*/');
     if ($files) {
         foreach ($files as $file) {
             if (is_dir($file)) {
                 list($tmp, $id) = array_map('trim', explode('/', $file));
                 $info = get_plugin_info($id);
                 $enabled = in_array($id, \App::$plugins);
                 $x = check_plugin_versions($info);
                 // disable plugins which are installed but incompatible versions
                 if ($enabled && !$x) {
                     $enabled = false;
                     $idz = array_search($id, \App::$plugins);
                     if ($idz !== false) {
                         unset(\App::$plugins[$idz]);
                         uninstall_plugin($id);
                         set_config("system", "addon", implode(", ", \App::$plugins));
                     }
                 }
                 $info['disabled'] = 1 - intval($x);
                 $plugins[] = array($id, $enabled ? "on" : "off", $info);
             }
         }
     }
     usort($plugins, 'self::plugin_sort');
     $admin_plugins_add_repo_form = replace_macros(get_markup_template('admin_plugins_addrepo.tpl'), array('$post' => 'admin/plugins/addrepo', '$desc' => t('Enter the public git repository URL of the plugin repo.'), '$repoURL' => array('repoURL', t('Plugin repo git URL'), '', ''), '$repoName' => array('repoName', t('Custom repo name'), '', '', t('(optional)')), '$submit' => t('Download Plugin Repo')));
     $newRepoModalID = random_string(3);
     $newRepoModal = replace_macros(get_markup_template('generic_modal.tpl'), array('$id' => $newRepoModalID, '$title' => t('Install new repo'), '$ok' => t('Install'), '$cancel' => t('Cancel')));
     $reponames = $this->listAddonRepos();
     $addonrepos = [];
     foreach ($reponames as $repo) {
         $addonrepos[] = array('name' => $repo, 'description' => '');
         // TODO: Parse repo info to provide more information about repos
     }
     $t = get_markup_template('admin_plugins.tpl');
     return replace_macros($t, array('$title' => t('Administration'), '$page' => t('Plugins'), '$submit' => t('Submit'), '$baseurl' => z_root(), '$function' => 'plugins', '$plugins' => $plugins, '$disabled' => t('Disabled - version incompatibility'), '$form_security_token' => get_form_security_token('admin_plugins'), '$addrepo' => t('Add Plugin Repo'), '$expandform' => false, '$form' => $admin_plugins_add_repo_form, '$newRepoModal' => $newRepoModal, '$newRepoModalID' => $newRepoModalID, '$addonrepos' => $addonrepos, '$repoUpdateButton' => t('Update'), '$repoBranchButton' => t('Switch branch'), '$repoRemoveButton' => t('Remove')));
 }
	function run($data, $params)
	{
		global $wikilib, $helpurl, $tikilib;
		if (!is_dir(PLUGINS_DIR)) {
			return $this->error('No plugin directory defined');
		}
		if (empty($helpurl)) {
			$helpurl = 'http://doc.tiki.org/';
		}
		
		$params = $this->getParams($params);
		extract($params, EXTR_SKIP);

		if (!empty($module) && !empty($plugin)) {
			return $this->error(tra('The module or plugin parameter must be set, but not both.'));
		} elseif (!empty($module)) {
			$aPrincipalField = array('field' => 'plugin', 'name' => 'Module');
			$helppath = $helpurl . $aPrincipalField['name'] . ' ';
			$filepath = 'mod-func-';
			global $modlib;
			include_once 'lib/modules/modlib.php';
			$aPlugins = $modlib->list_module_files();
			$mod = true;
			$type = ' module';
			$plugin = $module;
		} else {
			$aPrincipalField = array('field' => 'plugin', 'name' => 'Plugin');
			$helppath = $helpurl . $aPrincipalField['name'];
			$filepath = 'wikiplugin_';
			$aPlugins = $wikilib->list_plugins();
			$mod = false;
			$type = ' plugin';
		}
		$all = $aPlugins;
		//if the user set $module, that setting has now been moved to $plugin so that one code set is used
		//$aPlugins and $all now has the complete list of plugin or module file names - the code below modifies $aPlugins
		//if necessary based on user settings
		if (!empty($plugin)) {
			if (strpos($plugin, '|') !== false) {
				$aPlugins = array();
				$userlist = explode('|', $plugin);
				foreach ($userlist as $useritem) {
					$file = $filepath . $useritem . '.php';
					$confirm = in_array($file, $all);
					if ($confirm === false) {
						return '^' . tr('Plugin Manager error: %0%1 not found', $useritem, $type) . '^';
					} else {
						$aPlugins[] = $file;
					}
				}
			} elseif (strpos($plugin, '-') !== false) {
				$userrange = explode('-', $plugin);
				$begin = array_search($filepath . $userrange[0] . '.php', $aPlugins);
				$end = array_search($filepath . $userrange[1] . '.php', $aPlugins);
				$beginerror = '';
				$enderror = '';
				$type2 = $type;
				if ($begin === false || $end === false) {
					if ($begin === false) {
						$beginerror = $userrange[0];
					} 
					if ($end === false) {
						$enderror = $userrange[1];
						if (!empty($beginerror)) {
							$and = ' and ';
						} else {
							$and = '';
							$type = '';
						}
					}
					return '^' . tr('Plugin Manager error: %0%1%2%3%4 not found', $beginerror, $type, $and, $enderror, $type2) . '^';
				} elseif ($end > $begin) {
					$aPlugins = array_slice($aPlugins, $begin, $end-$begin+1);
				} else {
					$aPlugins = array_slice($aPlugins, $end, $begin-$end+1);
				}	 		
			} elseif (!empty($limit)) { 
				$begin = array_search($filepath . $plugin . '.php', $aPlugins); 
				if ($begin === false) {
					return '^' . tr('Plugin Manager error: %0%1 not found', $begin, $type) . '^';
				} else {
					$aPlugins = array_slice($aPlugins, $begin, $limit);
				}
			} elseif ($plugin != 'all') {
				$file = $filepath . $plugin . '.php';
				$confirm = in_array($file, $aPlugins);
				if ($confirm === false) {
					return '^' . tr('Plugin Manager error:  %0%1 not found', $plugin, $type) . '^';
				} else {
					$aPlugins = array();
					$aPlugins[] = $file;
				}
			}
		} else {
			if (!empty($start) || !empty($limit)) {
				if (!empty($start) && !empty($limit)) {
					$aPlugins = array_slice($aPlugins, $start-1, $limit);
				} elseif (!empty($start)) {
					$aPlugins = array_slice($aPlugins, $start-1);
				} else {			
					$aPlugins = array_slice($aPlugins, 0, $limit);
				}
			}
		}
		//Set all data variables needed for separate code used to generate the display table
		$aData=array();
		if ($singletitle == 'table' || count($aPlugins) > 1) {
			foreach ($aPlugins as $sPluginFile) {
				global $sPlugin, $numparams;
				if ($mod) {
					$infoPlugin = get_module_params($sPluginFile);
					$namepath = $sPlugin;
				} else {
					$infoPlugin = get_plugin_info($sPluginFile);
					$namepath = ucfirst($sPlugin);
				}
				if (in_array('description', $info)) {
					if (isset($infoPlugin['description'])) {
						if ($numparams > 1) {
							$aData[$sPlugin]['description']['onekey'] = $infoPlugin['description'];
						} else {
							$aData[$sPlugin]['description'] = $infoPlugin['description'];
						}
					} else {
						$aData[$sPlugin]['description'] = ' --- ';
					}
				}
				if (in_array('parameters', $info)) {
					if ($numparams > 0) {
						if ($aPrincipalField['field'] == 'plugin' && !in_array('options', $info) && $numparams > 1) {
							$aData[$sPlugin][$aPrincipalField['field']]['rowspan'] = $numparams;
							if (in_array('description', $info)) {
								$aData[$sPlugin]['description']['rowspan'] = $numparams;
							}
						}
						foreach ($infoPlugin['params'] as $paramname => $param) {
							if (isset($infoPlugin['params'][$paramname]['description'])) {
								$paramblock = '~np~' . $infoPlugin['params'][$paramname]['description'] . '~/np~';
							}
							if (isset($param['options']) && is_array($param['options'])) {
								$paramblock .= '<br /><em>' . tra('Options:') . '</em> ';
								$i = 0;
								foreach ($param['options'] as $oplist => $opitem) {
									if (isset($opitem['value'])) {
										$paramblock .= $opitem['value'];
									} else {
										$paramblock .=  $opitem['text'];
									}
									$paramblock .= ' | ';
									$i++;
								}
								$paramblock = substr($paramblock, 0, -3);
							}
							if (isset($infoPlugin['params'][$paramname]['required']) && $infoPlugin['params'][$paramname]['required'] == true) {
								$aData[$sPlugin]['parameters']['<b>' . $paramname . '</b>'] = $paramblock;
							} else {
								$aData[$sPlugin]['parameters'][$paramname] = $paramblock;
							}
						}
					} else {
						$aData[$sPlugin]['parameters']['<em>no parameters</em>'] = '<em>' . tra('n/a') . '</em>';
					}
				}
				$aData[$sPlugin]['plugin']['plugin'] = '[' . $helppath . $namepath . '|' . ucfirst($sPlugin) . ']';
			} // Plugins Loop
			return PluginsLibUtil::createTable($aData, $info, $aPrincipalField);
		} else {
			//Replicates a documentation table for parameters for a single plugin or module
			//Not using plugin lib table to avoid making custom modifications
			global $sPlugin, $numparams;
			if ($mod) {
				$infoPlugin = get_module_params($aPlugins[0]);
				$namepath = $sPlugin;
			} else {
				$infoPlugin = get_plugin_info($aPlugins[0]);
				$namepath = ucfirst($sPlugin);
			}
			if ($singletitle == 'top') {
				$title = '<' . $titletag . '>['. $helppath . $namepath 
					. '|' . ucfirst($sPlugin) . ']</' . $titletag . '>';
				$title .= $infoPlugin['description'] . '<br />';
				if (isset($infoPlugin['introduced'])) {
					$title .= '<em>' . tr('Introduced in Tiki version %0', $infoPlugin['introduced']) . '</em><br />';
				}
				$title .= '<br />';
			} else {
				$title = '';
			}
			$headbegin = "\n\t\t" . '<td class="heading">';
			$cellbegin = "\n\t\t" . '<td>';
			$header =  "\n\t" . '<tr class="heading">' . $headbegin . 'Parameters</td>';
			$rows = '';
			if (isset($numparams) && $numparams > 0) {
				$header .= $headbegin . tra('Accepted Values') . '</td>';
 			   	$header .= $headbegin . tra('Description') . '</td>';
				$rowCounter = 1;
				if (!empty($infoPlugin['body'])) {
					$body = array('(body of plugin)' => array('description' => $infoPlugin['body']));
					$infoPlugin['params'] = array_merge($body, $infoPlugin['params']);
				}
				foreach ($infoPlugin['params'] as $paramname => $paraminfo) {
					$class = ($rowCounter%2) ? 'odd' : 'even';
					$rows .= "\n\t" . '<tr class="' . $class . '">' . $cellbegin;
					//Parameters column
					if (isset($paraminfo['required']) && $paraminfo['required'] == true) {
						$rows .= '<b><em>' . $paramname . '</em></b>';
					} elseif ($paramname == '(body of plugin)') {
						$rows .= tra('(body of plugin)');
					} else {
						$rows .= '<em>' . $paramname . '</em>' ;
					}
					$rows .= '</td>';
					$rows .= $cellbegin;
					//Accepted Values column
					if (isset($paraminfo['accepted'])) {
						$rows .= $paraminfo['accepted'] . '</td>';
					} elseif (isset($paraminfo['options'])) {
						$optcounter = 1;
						$numoptions = count($paraminfo['options']);
						foreach ($paraminfo['options'] as $oplist => $opitem) {
							$rows .= strlen($opitem['value']) == 0 ? tra('(blank)') : $opitem['value'];
							if ($optcounter < $numoptions) {
								if ($numoptions > 10) {
									$rows .= ' | ';
								} else {
									$rows .= '<br />';
								}
							}
							$optcounter++;
						}
						$rows .= '</td>';
					} elseif (isset($paraminfo['filter'])) {
						if ($paraminfo['filter'] == 'striptags') {
							$rows .= tra('any string except for HTML and PHP tags');
						} else {
							$rows .= $paraminfo['filter'];
						}
						$rows .= '</td>';
					} else {
						$rows .= '</td>';
					}
					//Description column
					$rows .= $cellbegin . $paraminfo['description'] . '</td>';
					//Default column
					if ($rowCounter == 1) {
						$header .= $headbegin . tra('Default') . '</td>';
					}
					if (!isset($paraminfo['default'])) {
						$paraminfo['default'] = '';
					}
					$rows .= $cellbegin . $paraminfo['default'] . '</td>';
					//Since column
					if ($rowCounter == 1) {
						$header .= $headbegin . tra('Since') . '</td>';
					}
					$rows .= $cellbegin . $paraminfo['since'] . '</td>';
 			   		$rows .= "\n\t" . '</tr>';
 			   		$rowCounter++;
				}
			} else {
				$rows .= "\n\t" . '<tr class="odd">' . $cellbegin . '<em>' . tra('no parameters') . '</em></td>';
			}
			$header .= "\n\t" . '</tr>';
			if (!empty($infoPlugin['prefs'])) {
				$pluginprefs = '<em>' . tra('Preferences required:') . '</em> ' . implode(', ', $infoPlugin['prefs']). '<br/>';
			} else {
				$pluginprefs = '';
			}
			$sOutput = $title . '<em>' . tr('Required parameters are in%0 %1bold%2', '</em>', '<b>', '</b>') . '<br />' . 
						$pluginprefs . '<table class="normal">' . $header . $rows . '</table>' . "\n";
			return $sOutput;
		}
	}
Beispiel #8
0
/**
 * Plugins admin page
 *
 * @param App $a
 * @return string
 */
function admin_page_plugins(&$a)
{
    /*
     * Single plugin
     */
    if ($a->argc == 3) {
        $plugin = $a->argv[2];
        if (!is_file("addon/{$plugin}/{$plugin}.php")) {
            notice(t("Item not found."));
            return '';
        }
        if (x($_GET, "a") && $_GET['a'] == "t") {
            check_form_security_token_redirectOnErr('/admin/plugins', 'admin_plugins', 't');
            // Toggle plugin status
            $idx = array_search($plugin, $a->plugins);
            if ($idx !== false) {
                unset($a->plugins[$idx]);
                uninstall_plugin($plugin);
                info(sprintf(t("Plugin %s disabled."), $plugin));
            } else {
                $a->plugins[] = $plugin;
                install_plugin($plugin);
                info(sprintf(t("Plugin %s enabled."), $plugin));
            }
            set_config("system", "addon", implode(", ", $a->plugins));
            goaway($a->get_baseurl(true) . '/admin/plugins');
        }
        // display plugin details
        require_once 'library/markdown.php';
        if (in_array($plugin, $a->plugins)) {
            $status = 'on';
            $action = t('Disable');
        } else {
            $status = 'off';
            $action = t('Enable');
        }
        $readme = null;
        if (is_file("addon/{$plugin}/README.md")) {
            $readme = file_get_contents("addon/{$plugin}/README.md");
            $readme = Markdown($readme);
        } else {
            if (is_file("addon/{$plugin}/README")) {
                $readme = "<pre>" . file_get_contents("addon/{$plugin}/README") . "</pre>";
            }
        }
        $admin_form = '';
        if (is_array($a->plugins_admin) && in_array($plugin, $a->plugins_admin)) {
            @(require_once "addon/{$plugin}/{$plugin}.php");
            if (function_exists($plugin . '_plugin_admin')) {
                $func = $plugin . '_plugin_admin';
                $func($a, $admin_form);
            }
        }
        $t = get_markup_template('admin_plugins_details.tpl');
        return replace_macros($t, array('$title' => t('Administration'), '$page' => t('Plugins'), '$toggle' => t('Toggle'), '$settings' => t('Settings'), '$baseurl' => $a->get_baseurl(true), '$plugin' => $plugin, '$status' => $status, '$action' => $action, '$info' => get_plugin_info($plugin), '$str_author' => t('Author: '), '$str_maintainer' => t('Maintainer: '), '$admin_form' => $admin_form, '$function' => 'plugins', '$screenshot' => '', '$readme' => $readme, '$form_security_token' => get_form_security_token('admin_plugins')));
    }
    /*
     * List plugins
     */
    $plugins = array();
    $files = glob('addon/*/');
    if ($files) {
        foreach ($files as $file) {
            if (is_dir($file)) {
                list($tmp, $id) = array_map('trim', explode('/', $file));
                $info = get_plugin_info($id);
                $plugins[] = array($id, in_array($id, $a->plugins) ? "on" : "off", $info);
            }
        }
    }
    $t = get_markup_template('admin_plugins.tpl');
    return replace_macros($t, array('$title' => t('Administration'), '$page' => t('Plugins'), '$submit' => t('Submit'), '$baseurl' => $a->get_baseurl(true), '$function' => 'plugins', '$plugins' => $plugins, '$form_security_token' => get_form_security_token('admin_plugins')));
}
Beispiel #9
0
function scan_plugin_info()
{
    if (file_exists(c('plugin_path'))) {
        foreach (glob(c('plugin_path') . DS . "*", GLOB_ONLYDIR) as $pfold) {
            $app_file = $pfold . DS . 'app.php';
            if (file_exists($app_file)) {
                if ($pinfo = get_plugin_info(file_get_contents($app_file))) {
                    $plist[] = $pinfo;
                }
            }
        }
    }
    return isset($plist) ? $plist : false;
}
Beispiel #10
0
function macro_admin($formatter, $value = '', $options = array())
{
    global $DBInfo;
    if ($DBInfo->include_path) {
        $dirs = explode(':', $DBInfo->include_path);
    } else {
        $dirs = array('.');
    }
    $arena = 'plugin';
    $plcur = ' class="current"';
    $prcur = '';
    if ($options['arena'] == 'processor') {
        $arena = 'processor';
        $prcur = ' class="current"';
        $plcur = '';
    }
    $pdir = $arena == 'plugin' ? 'plugin' : 'plugin/processor';
    $tag = $arena == 'plugin' ? 'pl' : 'pr';
    // make plugins list
    foreach ($dirs as $dir) {
        $handle = @opendir($dir . '/' . $pdir);
        if (!$handle) {
            continue;
        }
        while ($file = readdir($handle)) {
            if (is_dir($dir . '/' . $pdir . '/' . $file)) {
                continue;
            }
            if ($file[0] == '.') {
                continue;
            }
            if (substr($file, -4) != '.php') {
                continue;
            }
            $name = substr($file, 0, -4);
            $plugins[strtolower($name)] = $name;
            $pl_infos[strtolower($name)] = get_plugin_info($dir . '/' . $pdir . '/' . $file);
        }
    }
    ksort($plugins);
    //
    $formatter->set_wordrule(array('#camelcase' => 0));
    // get settings
    $sc = new Cache_text('settings');
    $pls = $sc->fetch($arena . 's');
    #$pl="<tr><th colspan='3'>"._($arena)."</th></tr>\n";
    $pl = '';
    $i = 0;
    foreach ($plugins as $p => $v) {
        ++$i;
        $ck = isset($pls[$p]) ? 'checked="checked"' : '';
        $disabled = empty($ck) ? ' disabled' : '';
        $name = $pl_infos[$p]['Name'] ? $pl_infos[$p]['Name'] : $p;
        $version = $pl_infos[$p]['Version'];
        $author = $pl_infos[$p]['Author'];
        $version = $pl_infos[$p]['Version'];
        $license = $pl_infos[$p]['License'];
        $depend = $pl_infos[$p]['Depend'];
        $url = $pl_infos[$p]['URL'];
        $desc = $pl_infos[$p]['Description'] ? $pl_infos[$p]['Description'] : '';
        $pl .= "<tr><th class='info{$disabled}' width='10%'>" . $name . ' ' . $version . '</th><td>' . "{$v}</td><td width='2%'><input type='checkbox' name='{$tag}[{$p}]' value='{$v}' {$ck}/></td></tr>\n";
        if ($author or $desc or $license) {
            $msg = _("Description");
            $pl .= "<tr><td colspan='3'><fieldset class='collapsible collapsed'><legend>{$msg}: </legend>";
            if ($author) {
                $pl .= '<strong>' . _("Author") . ': ' . $author . "</strong><br />\n";
            }
            if ($license) {
                $pl .= '<strong>' . _("License") . ': ' . $license . "</strong><br />\n";
            }
            if ($depend) {
                $pl .= '<strong>' . _("Depend") . ': ' . $depend . "</strong><br />\n";
            }
            if ($url) {
                $url = preg_replace_callback("/(" . $formatter->wordrule . ")/", array(&$formatter, 'link_repl'), $url);
                $pl .= '<strong>' . _("URL") . ': ' . $url . "</strong><br />\n";
            }
            if ($desc) {
                $desc = preg_replace_callback("/(" . $formatter->wordrule . ")/", array(&$formatter, 'link_repl'), $desc);
                $pl .= "<p><pre>{$desc}</pre></p>\n";
            }
            $pl .= "</fieldset></td></tr>\n";
        }
    }
    $pl .= "<tr><td colspan='3'>Total <b>{$i}</b></td></tr>\n";
    $out = <<<MENU
<ul id="admin-submenu">
    <li><a href="?action=admin&amp;arena=plugin"{$plcur}>Plugins</a></li>
    <li><a href="?action=admin&amp;arena=processor"{$prcur}>Processors</a></li>
</ul>
MENU;
    $out .= "<form method='post' action=''><table algin='center'><tr valign='top'>" . $pl . "</table>";
    if (is_array($DBInfo->owners) and in_array($options['id'], $DBInfo->owners)) {
        $out .= '<input type="hidden" name="action" value="admin" />';
        $out .= '<input type="submit" value="Update" />';
    }
    $out .= '</form>';
    return $out;
}
Beispiel #11
0
function admin_page_plugins(&$a)
{
    /**
     * Single plugin
     */
    if ($a->argc == 3) {
        $plugin = $a->argv[2];
        if (!is_file("addon/{$plugin}/{$plugin}.php")) {
            notice(t("Item not found."));
            return;
        }
        if (x($_GET, "a") && $_GET['a'] == "t") {
            // Toggle plugin status
            $idx = array_search($plugin, $a->plugins);
            if ($idx !== false) {
                unset($a->plugins[$idx]);
                uninstall_plugin($plugin);
                info(sprintf(t("Plugin %s disabled."), $plugin));
            } else {
                $a->plugins[] = $plugin;
                install_plugin($plugin);
                info(sprintf(t("Plugin %s enabled."), $plugin));
            }
            set_config("system", "addon", implode(", ", $a->plugins));
            goaway($a->get_baseurl() . '/admin/plugins');
            return;
            // NOTREACHED
        }
        // display plugin details
        require_once 'library/markdown.php';
        if (in_array($plugin, $a->plugins)) {
            $status = "on";
            $action = t("Disable");
        } else {
            $status = "off";
            $action = t("Enable");
        }
        $readme = Null;
        if (is_file("addon/{$plugin}/README.md")) {
            $readme = file_get_contents("addon/{$plugin}/README.md");
            $readme = Markdown($readme);
        } else {
            if (is_file("addon/{$plugin}/README")) {
                $readme = "<pre>" . file_get_contents("addon/{$plugin}/README") . "</pre>";
            }
        }
        $admin_form = "";
        if (is_array($a->plugins_admin) && in_array($plugin, $a->plugins_admin)) {
            @(require_once "addon/{$plugin}/{$plugin}.php");
            $func = $plugin . '_plugin_admin';
            $func($a, $admin_form);
        }
        $t = get_markup_template("admin_plugins_details.tpl");
        return replace_macros($t, array('$title' => t('Administration'), '$page' => t('Plugins'), '$toggle' => t('Toggle'), '$settings' => t('Settings'), '$baseurl' => $a->get_baseurl(), '$plugin' => $plugin, '$status' => $status, '$action' => $action, '$info' => get_plugin_info($plugin), '$admin_form' => $admin_form, '$readme' => $readme));
    }
    /**
     * List plugins
     */
    $plugins = array();
    $files = glob("addon/*/");
    if ($files) {
        foreach ($files as $file) {
            if (is_dir($file)) {
                list($tmp, $id) = array_map("trim", explode("/", $file));
                $info = get_plugin_info($id);
                $plugins[] = array($id, in_array($id, $a->plugins) ? "on" : "off", $info);
            }
        }
    }
    $t = get_markup_template("admin_plugins.tpl");
    return replace_macros($t, array('$title' => t('Administration'), '$page' => t('Plugins'), '$submit' => t('Submit'), '$baseurl' => $a->get_baseurl(), '$plugins' => $plugins));
}
Beispiel #12
0
function plugins()
{
    global $ADMIN_CONF;
    global $CatPage;
    global $message;
    global $specialchars;
    global $debug;
    $plugin_manage_open = false;
    # plugins löschen
    if (getRequestValue('plugin-all-del', 'post') and getRequestValue('plugin-del', 'post')) {
        plugin_del();
        $plugin_manage_open = true;
    }
    # hochgeladenes plugin installieren
    if (isset($_FILES["plugin-install-file"]["error"]) and getRequestValue('plugin-install', 'post') and $_FILES["plugin-install-file"]["error"] == 0 and strtolower(substr($_FILES["plugin-install-file"]["name"], -4)) == ".zip") {
        $debug .= "install=" . $_FILES["plugin-install-file"]["name"] . "<br />\n";
        plugin_install();
        $plugin_manage_open = true;
    } elseif ($plugin_select = $specialchars->rebuildSpecialChars(getRequestValue('plugin-install-select', 'post'), false, false) and getRequestValue('plugin-install', 'post') and is_file(PLUGIN_DIR_REL . $specialchars->replaceSpecialChars($plugin_select, false)) !== false and strtolower(substr($plugin_select, -4)) == ".zip") {
        $debug .= "local install=" . getRequestValue('plugin-install-select', 'post') . "<br />\n";
        plugin_install($plugin_select);
        $plugin_manage_open = true;
    }
    $showdebug = false;
    if ($showdebug and !empty($debug)) {
        $message .= returnMessage(false, $debug);
    }
    require_once BASE_DIR_CMS . "Plugin.php";
    if (false !== ($plugin_name = getRequestValue('pluginadmin'))) {
        #,'get'
        if (file_exists(PLUGIN_DIR_REL . $plugin_name)) {
            define("PLUGINADMIN", $plugin_name);
            if (file_exists(PLUGIN_DIR_REL . PLUGINADMIN . "/plugin.conf.php") and file_exists(PLUGIN_DIR_REL . PLUGINADMIN . "/index.php")) {
                require_once PLUGIN_DIR_REL . PLUGINADMIN . "/index.php";
                # Enthält der Code eine Klasse mit dem Namen des Plugins und ist es auch der Dirname?
                if (class_exists(PLUGINADMIN) and in_array(PLUGINADMIN, get_declared_classes())) {
                    # $PLUGIN_ADMIN_ADD_HEAD gibts nur hier und ist für sachen die in den head sollen
                    global $PLUGIN_ADMIN_ADD_HEAD;
                    $PLUGIN_ADMIN_ADD_HEAD = array();
                    $multi_user = "";
                    if (defined('MULTI_USER') and MULTI_USER) {
                        $multi_user = "******";
                    }
                    define("PLUGINADMIN_GET_URL", URL_BASE . ADMIN_DIR_NAME . "/index.php?pluginadmin=" . PLUGINADMIN . "&amp;nojs=true&amp;action=" . ACTION . $multi_user);
                    $plugin = new $plugin_name();
                    $info = $plugin->getInfo();
                    $config = $plugin->getConfig();
                    if (PLUGIN_DIR_REL . $plugin_name . '/' . $config["--admin~~"]["datei_admin"] == PLUGIN_DIR_REL . PLUGINADMIN . "/index.php") {
                        return $plugin->getContent("");
                    } else {
                        return require_once PLUGIN_DIR_REL . $plugin_name . '/' . $config["--admin~~"]["datei_admin"];
                    }
                }
            } else {
                die;
            }
        } else {
            die;
        }
    }
    if (getRequestValue('chanceplugin', 'post') == "true" and false !== ($plugin_name = getRequestValue('plugin_name', 'post'))) {
        if (file_exists(PLUGIN_DIR_REL . $plugin_name) and file_exists(PLUGIN_DIR_REL . $plugin_name . "/plugin.conf.php") and file_exists(PLUGIN_DIR_REL . $plugin_name . "/index.php")) {
            $conf_plugin = new Properties(PLUGIN_DIR_REL . $plugin_name . "/plugin.conf.php");
        } else {
            die("Fatal Error");
        }
        if (false !== ($activ = getRequestValue(array($plugin_name, 'active'), 'post')) and ($activ == "true" or $activ == "false")) {
            $conf_plugin->set("active", $activ);
            ajax_return("success", true);
        } elseif ($conf_plugin->get("active") == "true") {
            require_once PLUGIN_DIR_REL . $plugin_name . "/index.php";
            # Enthält der Code eine Klasse mit dem Namen des Plugins und ist es auch der Dirname?
            if (class_exists($plugin_name) and in_array($plugin_name, get_declared_classes())) {
                $plugin = new $plugin_name();
                # das ist nötig weil es sein kann das in getInfo() variblen initaliesiert werden
                $tmp = $plugin->getInfo();
                $config = $plugin->getConfig();
                echo save_plugin_settings($conf_plugin, $config, $plugin_name);
                exit;
            } else {
                die("Fatal Error");
            }
        }
        die("Fatal Error");
    }
    $pagecontent = '';
    $show = $ADMIN_CONF->get("plugins");
    if (!is_array($show)) {
        $show = array();
    }
    if (ROOT or in_array("plugin_-_manage", $show)) {
        $multi_user = "";
        if (defined('MULTI_USER') and MULTI_USER) {
            $multi_user = "******";
        }
        $html_manage = "";
        $plugin_manage = array();
        $disabled = '';
        if (!function_exists('gzopen')) {
            $disabled = ' disabled="disabled"';
        }
        $plugin_install = array();
        foreach (getDirAsArray(PLUGIN_DIR_REL, array(".zip")) as $zip_file) {
            $plugin_install[] = '<option value="' . mo_rawurlencode($zip_file) . '">' . $zip_file . '</option>';
        }
        $plugin_install_html = "";
        if (count($plugin_install) > 0) {
            $plugin_install_html .= '<br /><select class="mo-install-select mo-select-div" name="plugin-install-select" size="1"' . $disabled . '>' . '<option value="">' . getLanguageValue("plugins_select", true) . '</option>' . implode("", $plugin_install) . '</select>';
        }
        $plugin_manage["plugins_title_manage"][] = '<form id="js-plugin-manage" action="index.php?nojs=true&amp;action=plugins' . $multi_user . '" method="post" enctype="multipart/form-data">' . '<div class="mo-nowrap align-right ui-helper-clearfix">' . '<span class="align-left" style="float:left"><span class="mo-bold">' . getLanguageValue("plugins_text_filebutton") . '</span><br />' . getLanguageValue("plugins_text_fileinfo") . '</span>' . '<input type="file" id="js-plugin-install-file" name="plugin-install-file" class="mo-select-div"' . $disabled . ' />' . $plugin_install_html . '<input type="submit" id="js-plugin-install-submit" name="plugin-install" value="' . getLanguageValue("plugins_button_install", true) . '"' . $disabled . ' /><br />' . '<input type="submit" id="js-plugin-del-submit" value="' . getLanguageValue("plugins_button_delete", true) . '" class="mo-margin-top js-send-del-stop" />' . '</div></form>';
        $plugin_manage["plugins_title_manage"]["toggle"] = true;
        $html_manage = contend_template($plugin_manage);
        $html_manage = str_replace("js-toggle", "js-toggle-manage", $html_manage);
        # es wurde in der template verwaltung was gemacht dann soll die aufgeklapt bleiben
        if ($plugin_manage_open) {
            $html_manage = str_replace("display:none;", "", $html_manage);
        }
        $pagecontent .= $html_manage;
    }
    $pagecontent .= '<ul class="js-plugins mo-ul">';
    $dircontent = getDirAsArray(PLUGIN_DIR_REL, "dir", "natcasesort");
    foreach ($dircontent as $currentelement) {
        $new_plugin_conf = false;
        if (!ROOT and !in_array($currentelement, $show)) {
            continue;
        }
        if (file_exists(PLUGIN_DIR_REL . $currentelement . "/index.php")) {
            if (!is_file(PLUGIN_DIR_REL . $currentelement . "/plugin.conf.php")) {
                if (false === newConf(PLUGIN_DIR_REL . $currentelement . "/plugin.conf.php")) {
                    die;
                } else {
                    $new_plugin_conf = true;
                }
            }
            require_once PLUGIN_DIR_REL . $currentelement . "/index.php";
            # Enthält der Code eine Klasse mit dem Namen des Plugins und ist es auch der Dirname?
            if (class_exists($currentelement) and in_array($currentelement, get_declared_classes())) {
                $plugin = new $currentelement();
            } else {
                # Plugin Dirname stimt nicht mit Plugin Classnamen überein
                continue;
            }
            # plugin.conf.php wurde neu erstelt.
            # Wenn es die getDefaultSettings() gibt fühle die plugin.conf.php damit
            if ($new_plugin_conf and method_exists($plugin, 'getDefaultSettings')) {
                $plugin->settings->setFromArray($plugin->getDefaultSettings());
            }
            $plugin_css_li_error = NULL;
            $plugin_error = false;
            $plugin_info = $plugin->getInfo();
            # Plugin Info Prüfen
            if (isset($plugin_info) and count($plugin_info) > 0) {
                $plugin_name = strip_tags($plugin_info[0], '<b>');
                if (substr(strip_tags($plugin_name), 0, strlen($currentelement)) != $currentelement) {
                    $plugin_name = "<b>" . $currentelement . "</b> " . strip_tags($plugin_name);
                }
                $plugin_name = htmlentities($plugin_name, ENT_COMPAT, CHARSET);
                $plugin_name = str_replace(array("&lt;", "&gt;", "\$"), array("<", ">", ""), $plugin_name);
            } else {
                $plugin_error = '<img class="mo-tool-icon mo-icons-icon mo-icons-error" src="' . ICON_URL_SLICE . '" alt="error" />' . getLanguageValue('plugins_error') . ' <b>' . $currentelement . '</b>';
                $plugin_css_li_error = ' ui-state-error';
            }
            $pagecontent .= '<li class="js-plugin mo-li ui-widget-content ui-corner-all' . $plugin_css_li_error . '">' . '<div class="js-tools-show-hide mo-li-head-tag mo-li-head-tag-no-ul ui-state-active ui-corner-all ui-helper-clearfix">';
            $check_show = ' style="display:none;"';
            if ($plugin_manage_open) {
                $check_show = '';
            }
            if ($plugin_error === false) {
                $pagecontent .= '<span class="js-plugin-name mo-padding-left mo-middle">' . $plugin_name . '</span>' . '<div style="float:right;" class="mo-tag-height-from-icon mo-middle mo-nowrap">' . '<span class="js-plugin-active mo-staus">' . buildCheckBox($currentelement . '[active]', $plugin->settings->get("active") == "true", getLanguageValue("plugins_input_active")) . '</span>' . '<img class="js-tools-icon-show-hide js-toggle mo-tool-icon mo-icons-icon mo-icons-edit" src="' . ICON_URL_SLICE . '" alt="edit" />' . '<input type="checkbox" value="' . $currentelement . '" class="mo-checkbox mo-checkbox-del js-plugin-del"' . $check_show . ' />' . '</div>' . '</div>' . '<div class="js-toggle-content mo-in-ul-ul ui-helper-clearfix" style="display:none;">' . get_plugin_info($plugin_info);
                # geändert damit getConfig() nicht 2mal ausgeführt wird
                $config = $plugin->getConfig();
                # Beschreibung und inputs der Konfiguration Bauen und ausgeben
                $pagecontent .= get_plugin_config($plugin->settings, $config, $currentelement);
            } else {
                $pagecontent .= $plugin_error;
            }
            $pagecontent .= '</div></li>';
            unset($plugin);
        }
    }
    $pagecontent .= '</ul>';
    return $pagecontent;
}
Beispiel #13
0
function macro_PluginInfo($formatter = '', $value = '')
{
    global $_revision, $_release;
    $version = phpversion();
    $uname = php_uname();
    list($aversion, $dummy) = explode(" ", $_SERVER['SERVER_SOFTWARE'], 2);
    if (!$value) {
        $num = getPlugin(true);
        return sprintf(_("Total %s plugin activated."), $num);
    }
    $file = getPlugin(strtolower($value));
    if (empty($file)) {
        if ($m = function_exists('macro_' . $value) or $m = function_exists('do_' . $value)) {
            return sprintf(_("%s is internal plugin."), $value);
        } else {
            return sprintf(_("%s plugin is not found."), $value);
        }
    }
    $info = get_plugin_info(dirname(__FILE__) . "/{$file}.php");
    $name = !empty($info['Name']) ? $info['Name'] . ' (' . $value . ')' : $value;
    $version = !empty($info['Version']) ? $info['Version'] : '';
    $author = !empty($info['Author']) ? $info['Author'] : '';
    $license = !empty($info['License']) ? $info['License'] : '';
    $depend = !empty($info['Depend']) ? $info['Depend'] : '';
    $url = !empty($info['URL']) ? $info['URL'] : '';
    $desc = !empty($info['Description']) ? $info['Description'] : '';
    $msg = _("Description");
    $pl = "<tr><td colspan='3'><fieldset class='collapsible collapsed'><legend>{$msg}: </legend><div>";
    $pl .= '<strong>' . _("Name") . ': ' . $name . "</strong><br />\n";
    if ($version) {
        $pl .= '<strong>' . _("Version") . ': ' . $version . "</strong><br />\n";
    }
    if ($author) {
        $pl .= '<strong>' . _("Author") . ': ' . $author . "</strong><br />\n";
    }
    if ($license) {
        $pl .= '<strong>' . _("License") . ': ' . $license . "</strong><br />\n";
    }
    if ($depend) {
        $pl .= '<strong>' . _("Depend") . ': ' . $depend . "</strong><br />\n";
    }
    if (empty($formatter->wordrule)) {
        $formatter->set_wordrule();
    }
    if ($url) {
        $url = preg_replace_callback("/(" . $formatter->wordrule . ")/", array(&$formatter, 'link_repl'), $url);
        $pl .= '<strong>' . _("URL") . ': ' . $url . "</strong><br />\n";
    }
    if ($desc) {
        $desc = preg_replace_callback("/(" . $formatter->wordrule . ")/", array(&$formatter, 'link_repl'), $desc);
        $pl .= "<p><pre>{$desc}</pre></p>\n";
    }
    $pl .= "</div></fieldset></td></tr>\n";
    return <<<EOF
<div class='pluginInfo'>
<table border='0' cellpadding='5'>
{$pl}
</table>
</div>
EOF;
    // vim:et:sts=4:sw=4:
}
/**
 * Returns the latest version for a plugin
 *
 * @return string
 */
function plugin_latest_version()
{
    $version = '';
    if (post_meta('plugin')) {
        $version = get_plugin_info(post_meta('plugin'), 'version');
    }
    if (post_meta('download_id')) {
        $version = get_post_meta(post_meta('download_id'), '_edd_sl_version', true);
    }
    return $version;
}
			<dt><?php 
_e('# Ratings', 'yoastcom');
?>
</dt>
			<dd><?php 
echo esc_html(get_plugin_info(post_meta('plugin'), 'num_ratings'));
?>
</dd>

			<dt><?php 
_e('Rating', 'yoastcom');
?>
</dt>
			<dd itemprop="aggregateRating" itemscope itemtype="http://schema.org/AggregateRating">
				<?php 
get_template_part('html_includes/partials/plugin-rating', array('rating' => get_plugin_info(post_meta('plugin'), 'rating'), 'rating_raw' => get_plugin_info(post_meta('plugin'), 'rating_raw')));
?>
			</dd>
		</dl>
	</div>
	<div class="one-third">
		<?php 
if (post_meta('extra_content')) {
    ?>
			<?php 
    echo post_meta('extra_content');
    ?>
		<?php 
}
?>
	</div>
Beispiel #16
0
/**
 * Plugins admin page
 *
 * @param App $a
 * @return string
 */
function admin_page_plugins(&$a)
{
    /*
     * Single plugin
     */
    if (App::$argc == 3) {
        $plugin = App::$argv[2];
        if (!is_file("addon/{$plugin}/{$plugin}.php")) {
            notice(t("Item not found."));
            return '';
        }
        $enabled = in_array($plugin, App::$plugins);
        $info = get_plugin_info($plugin);
        $x = check_plugin_versions($info);
        // disable plugins which are installed but incompatible versions
        if ($enabled && !$x) {
            $enabled = false;
            $idz = array_search($plugin, App::$plugins);
            if ($idz !== false) {
                unset(App::$plugins[$idz]);
                uninstall_plugin($plugin);
                set_config("system", "addon", implode(", ", App::$plugins));
            }
        }
        $info['disabled'] = 1 - intval($x);
        if (x($_GET, "a") && $_GET['a'] == "t") {
            check_form_security_token_redirectOnErr('/admin/plugins', 'admin_plugins', 't');
            // Toggle plugin status
            $idx = array_search($plugin, App::$plugins);
            if ($idx !== false) {
                unset(App::$plugins[$idx]);
                uninstall_plugin($plugin);
                info(sprintf(t("Plugin %s disabled."), $plugin));
            } else {
                App::$plugins[] = $plugin;
                install_plugin($plugin);
                info(sprintf(t("Plugin %s enabled."), $plugin));
            }
            set_config("system", "addon", implode(", ", App::$plugins));
            goaway(z_root() . '/admin/plugins');
        }
        // display plugin details
        require_once 'library/markdown.php';
        if (in_array($plugin, App::$plugins)) {
            $status = 'on';
            $action = t('Disable');
        } else {
            $status = 'off';
            $action = t('Enable');
        }
        $readme = null;
        if (is_file("addon/{$plugin}/README.md")) {
            $readme = file_get_contents("addon/{$plugin}/README.md");
            $readme = Markdown($readme);
        } else {
            if (is_file("addon/{$plugin}/README")) {
                $readme = "<pre>" . file_get_contents("addon/{$plugin}/README") . "</pre>";
            }
        }
        $admin_form = '';
        $r = q("select * from addon where plugin_admin = 1 and name = '%s' limit 1", dbesc($plugin));
        if ($r) {
            @(require_once "addon/{$plugin}/{$plugin}.php");
            if (function_exists($plugin . '_plugin_admin')) {
                $func = $plugin . '_plugin_admin';
                $func($a, $admin_form);
            }
        }
        $t = get_markup_template('admin_plugins_details.tpl');
        return replace_macros($t, array('$title' => t('Administration'), '$page' => t('Plugins'), '$toggle' => t('Toggle'), '$settings' => t('Settings'), '$baseurl' => z_root(), '$plugin' => $plugin, '$status' => $status, '$action' => $action, '$info' => $info, '$str_author' => t('Author: '), '$str_maintainer' => t('Maintainer: '), '$str_minversion' => t('Minimum project version: '), '$str_maxversion' => t('Maximum project version: '), '$str_minphpversion' => t('Minimum PHP version: '), '$str_requires' => t('Requires: '), '$disabled' => t('Disabled - version incompatibility'), '$admin_form' => $admin_form, '$function' => 'plugins', '$screenshot' => '', '$readme' => $readme, '$form_security_token' => get_form_security_token('admin_plugins')));
    }
    /*
     * List plugins
     */
    $plugins = array();
    $files = glob('addon/*/');
    if ($files) {
        foreach ($files as $file) {
            if (is_dir($file)) {
                list($tmp, $id) = array_map('trim', explode('/', $file));
                $info = get_plugin_info($id);
                $enabled = in_array($id, App::$plugins);
                $x = check_plugin_versions($info);
                // disable plugins which are installed but incompatible versions
                if ($enabled && !$x) {
                    $enabled = false;
                    $idz = array_search($id, App::$plugins);
                    if ($idz !== false) {
                        unset(App::$plugins[$idz]);
                        uninstall_plugin($id);
                        set_config("system", "addon", implode(", ", App::$plugins));
                    }
                }
                $info['disabled'] = 1 - intval($x);
                $plugins[] = array($id, $enabled ? "on" : "off", $info);
            }
        }
    }
    $t = get_markup_template('admin_plugins.tpl');
    return replace_macros($t, array('$title' => t('Administration'), '$page' => t('Plugins'), '$submit' => t('Submit'), '$baseurl' => z_root(), '$function' => 'plugins', '$plugins' => $plugins, '$disabled' => t('Disabled - version incompatibility'), '$form_security_token' => get_form_security_token('admin_plugins')));
}