/**
 * Gets metadata about plugins
 *
 * Thanks to Wordpress, admin-functions.php, lines 1525-1534
 * @author Wordpress Development Team
 * @param string $plugin_file Plugin file to search for metadata
 * @return object Plugin metadata
 */
function plugins_meta($plugin_file)
{
    $plugin_data = implode('', file($plugin_file));
    $headers = array('name' => 'Plugin Name', 'uri' => 'Plugin URI', 'description' => 'Description', 'author' => 'Author', 'author_uri' => 'Author URI', 'version' => 'Version', 'min_version' => 'Min Version');
    $headers = apply_filters('plugin_headers', $headers);
    foreach ($headers as $friendly => $regex) {
        $value = null;
        $success = preg_match('|' . preg_quote($regex, '|') . ':(.*)|i', $plugin_data, $value);
        if (!$success) {
            $value = array(1 => '');
        }
        $value = trim(preg_replace("/\\s*(?:\\*\\/|\\?>).*/", '', $value[1]));
        $vals[$friendly] = $value;
    }
    // New-style docblock parsing
    $docblock = parse_docblock($plugin_data);
    // Use the short and long description as the name and description respectively
    if (!empty($docblock['short'])) {
        $vals['name'] = $docblock['short'];
    }
    if (!empty($docblock['long'])) {
        $vals['description'] = $docblock['long'];
    }
    // Parse the docblock tags
    if (!empty($docblock['tags']['author'])) {
        $author = explode('<', $docblock['tags']['author']);
        $vals['author'] = trim($author[0]);
    }
    if (!empty($docblock['tags']['version'])) {
        $vals['version'] = $docblock['tags']['version'];
    }
    if (empty($vals['version'])) {
        $vals['version'] = '1.0';
    }
    if (empty($vals['min_version'])) {
        $vals['min_version'] = LILINA_CORE_VERSION;
    }
    $plugin = (object) $vals;
    return $plugin;
}
示例#2
0
            $description = empty($params['version']) ? $params['description'] : "<strong>{$params['version']}</strong> {$params['description']}";
            $mp[] = array($params['name'], $description, "{$pluginPath}/{$params['filename']}", $params['properties'], $params['events'], $params['guid'], $params['modx_category'], $params['legacy_names'], array_key_exists('installset', $params) ? preg_split("/\\s*,\\s*/", $params['installset']) : false, intval($params['disabled']));
        }
    }
    $d->close();
}
// setup modules - array : name, description, type - 0:file or 1:content, file or content,properties, guid,enable_sharedparams
$mm =& $moduleModules;
$mdp =& $moduleDependencies;
if (is_dir($modulePath) && is_readable($modulePath)) {
    $d = dir($modulePath);
    while (false !== ($tplfile = $d->read())) {
        if (substr($tplfile, -4) != '.tpl') {
            continue;
        }
        $params = parse_docblock($modulePath, $tplfile);
        if (is_array($params) && count($params) > 0) {
            $description = empty($params['version']) ? $params['description'] : "<strong>{$params['version']}</strong> {$params['description']}";
            $mm[] = array($params['name'], $description, "{$modulePath}/{$params['filename']}", $params['properties'], $params['guid'], intval($params['shareparams']), $params['modx_category'], array_key_exists('installset', $params) ? preg_split("/\\s*,\\s*/", $params['installset']) : false);
        }
        if (intval($params['shareparams']) || !empty($params['dependencies'])) {
            $dependencies = explode(',', $dependencies);
            foreach ($dependencies as $dependency) {
                $dependency = explode(':', $dependency);
                switch (trim($dependency[0])) {
                    case 'template':
                        $mdp[] = array('module' => $params['name'], 'table' => 'templates', 'column' => 'templatename', 'type' => 50, 'name' => trim($dependency[1]));
                        break;
                    case 'tv':
                    case 'tmplvar':
                        $mdp[] = array('module' => $params['name'], 'table' => 'tmplvars', 'column' => 'name', 'type' => 60, 'name' => trim($dependency[1]));
示例#3
0
        $params = parse_docblock($tplfile);
        if (is_array($params) && 0 < count($params)) {
            if (!empty($params['version'])) {
                $description = "<strong>{$params['version']}</strong> {$params['description']}";
            } else {
                $description = $params['description'];
            }
            if ($installmode == 1 && compare_check($params) == 'same') {
                continue;
            }
            $mp[] = array($params['name'], $description, $tplfile, $params['properties'], $params['events'], $params['guid'], $params['modx_category'], $params['legacy_names'], array_key_exists('installset', $params) ? preg_split("/\\s*,\\s*/", $params['installset']) : false);
        }
    }
}
// setup modules - array : name, description, type - 0:file or 1:content, file or content,properties, guid,enable_sharedparams
$mm =& $moduleModules;
if (is_dir($modulePath) && is_readable($modulePath)) {
    $files = collectTpls($modulePath);
    foreach ($files as $tplfile) {
        $params = parse_docblock($tplfile);
        if (is_array($params) && count($params) > 0) {
            $description = empty($params['version']) ? $params['description'] : "<strong>{$params['version']}</strong> {$params['description']}";
            if ($installmode == 1 && compare_check($params) == 'same') {
                continue;
            }
            $mm[] = array($params['name'], $description, $tplfile, $params['properties'], $params['guid'], intval($params['shareparams']), $params['modx_category'], array_key_exists('installset', $params) ? preg_split("/\\s*,\\s*/", $params['installset']) : false);
        }
    }
}
// setup callback function
$callBackFnc = 'clean_up';