getPath() 공개 메소드

Returns the plugin's full path with trailing slash.
public getPath ( ) : string
리턴 string
예제 #1
0
파일: admin.php 프로젝트: duanhv/mdg-social
/**
 * Serves up screenshots for plugins from
 * admin_plugin_screenshot/<plugin_id>/<size>/<ss_name>.<ext>
 *
 * @param array $pages The pages array
 * @return bool
 * @access private
 */
function admin_plugin_screenshot_page_handler($pages)
{
    // only admins can use this for security
    admin_gatekeeper();
    $plugin_id = elgg_extract(0, $pages);
    // only thumbnail or full.
    $size = elgg_extract(1, $pages, 'thumbnail');
    // the rest of the string is the filename
    $filename_parts = array_slice($pages, 2);
    $filename = implode('/', $filename_parts);
    $filename = sanitise_filepath($filename, false);
    $plugin = new ElggPlugin($plugin_id);
    if (!$plugin) {
        $file = elgg_get_root_path() . '_graphics/icons/default/medium.png';
    } else {
        $file = $plugin->getPath() . $filename;
        if (!file_exists($file)) {
            $file = elgg_get_root_path() . '_graphics/icons/default/medium.png';
        }
    }
    header("Content-type: image/jpeg");
    // resize to 100x100 for thumbnails
    switch ($size) {
        case 'thumbnail':
            echo get_resized_image_from_existing_file($file, 100, 100, true);
            break;
        case 'full':
        default:
            echo file_get_contents($file);
            break;
    }
    return true;
}