当前位置: 首页>>代码示例>>PHP>>正文


PHP GeSHi::get_language_name_from_extension方法代码示例

本文整理汇总了PHP中GeSHi::get_language_name_from_extension方法的典型用法代码示例。如果您正苦于以下问题:PHP GeSHi::get_language_name_from_extension方法的具体用法?PHP GeSHi::get_language_name_from_extension怎么用?PHP GeSHi::get_language_name_from_extension使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在GeSHi的用法示例。


在下文中一共展示了GeSHi::get_language_name_from_extension方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: language

 function language()
 {
     global $ID;
     $parts = explode(".", $ID);
     if (count($parts) <= 1) {
         return NULL;
     }
     $extension = array_pop($parts);
     $lang = GeSHi::get_language_name_from_extension($extension);
     return $lang;
 }
开发者ID:omusico,项目名称:isle-web-framework,代码行数:11,代码来源:content.php

示例2: LoadData

 /**
  * Loads data for this template
  */
 protected function LoadData()
 {
     $head = $this->GetProject()->GetHeadCommit();
     $data = null;
     if ($this->params['graphtype'] == 'commitactivity') {
         $data = array();
         $commits = explode("\n", $this->exe->Execute($this->GetProject()->GetPath(), 'rev-list', array('--format=format:"%H %ct"', $head->GetHash())));
         foreach ($commits as $commit) {
             if (preg_match('/^([0-9a-fA-F]{40}) ([0-9]+)$/', $commit, $regs)) {
                 $data[] = array('CommitEpoch' => (int) $regs[2]);
             }
         }
     } else {
         if ($this->params['graphtype'] == 'languagedist') {
             $data = array();
             include_once GITPHP_GESHIDIR . "geshi.php";
             $geshi = new GeSHi("", 'php');
             $files = explode("\n", $this->exe->Execute($this->GetProject()->GetPath(), 'ls-tree', array('-r', '--name-only', $head->GetTree()->GetHash())));
             foreach ($files as $file) {
                 $filename = GitPHP_Util::BaseName($file);
                 $lang = GitPHP_Util::GeshiFilenameToLanguage($filename);
                 if (empty($lang)) {
                     $lang = $geshi->get_language_name_from_extension(substr(strrchr($filename, '.'), 1));
                     if (empty($lang)) {
                         $lang = 'Other';
                     }
                 }
                 if (!empty($lang) && $lang !== 'Other') {
                     $fulllang = $geshi->get_language_fullname($lang);
                     if (!empty($fulllang)) {
                         $lang = $fulllang;
                     }
                 }
                 if (isset($data[$lang])) {
                     $data[$lang]++;
                 } else {
                     $data[$lang] = 1;
                 }
             }
         }
     }
     $this->tpl->assign('data', json_encode($data));
 }
开发者ID:fboender,项目名称:gitphp,代码行数:46,代码来源:Controller_GraphData.class.php

示例3: git_blob

function git_blob($projectroot, $project, $hash, $file, $hashbase)
{
    global $gitphp_conf, $tpl;
    $cachekey = sha1($project) . "|" . $hashbase . "|" . $hash . "|" . sha1($file);
    if (!$tpl->is_cached('blob.tpl', $cachekey)) {
        $head = git_read_head($projectroot . $project);
        if (!isset($hashbase)) {
            $hashbase = $head;
        }
        if (!isset($hash) && isset($file)) {
            $hash = git_get_hash_by_path($projectroot . $project, $hashbase, $file, "blob");
        }
        $catout = git_cat_file($projectroot . $project, $hash);
        $tpl->assign("hash", $hash);
        $tpl->assign("hashbase", $hashbase);
        $tpl->assign("head", $head);
        if ($co = git_read_commit($projectroot . $project, $hashbase)) {
            $tpl->assign("fullnav", TRUE);
            $refs = read_info_ref($projectroot . $project);
            $tpl->assign("tree", $co['tree']);
            $tpl->assign("title", $co['title']);
            if (isset($file)) {
                $tpl->assign("file", $file);
            }
            if ($hashbase == "HEAD") {
                if (isset($refs[$head])) {
                    $tpl->assign("hashbaseref", $refs[$head]);
                }
            } else {
                if (isset($refs[$hashbase])) {
                    $tpl->assign("hashbaseref", $refs[$hashbase]);
                }
            }
        }
        $paths = git_path_trees($projectroot . $project, $hashbase, $file);
        $tpl->assign("paths", $paths);
        if ($gitphp_conf['filemimetype']) {
            $mime = file_mime($catout, $file);
            if ($mime) {
                $mimetype = strtok($mime, "/");
            }
        }
        if ($mimetype == "image") {
            $tpl->assign("mime", $mime);
            $tpl->assign("data", base64_encode($catout));
        } else {
            $usedgeshi = $gitphp_conf['geshi'];
            if ($usedgeshi) {
                $usedgeshi = FALSE;
                include_once $gitphp_conf['geshiroot'] . "geshi.php";
                if (class_exists("GeSHi")) {
                    $geshi = new GeSHi($catout, $lang = Geshi::get_language_name_from_extension(substr(strrchr($file, '.'), 1)));
                    if ($geshi) {
                        $lang = "";
                        if (isset($file)) {
                            $lang = $geshi->get_language_name_from_extension(substr(strrchr($file, '.'), 1));
                        }
                        if (isset($lang) && strlen($lang) > 0) {
                            #$geshi->set_source($catout);
                            #$geshi->set_language($lang);
                            #$geshi->set_header_type(GESHI_HEADER_DIV);
                            #$geshi->enable_line_numbers(GESHI_FANCY_LINE_NUMBERS);
                            $tpl->assign("geshiout", $geshi->parse_code());
                            $usedgeshi = TRUE;
                        }
                    }
                }
            }
            if (!$usedgeshi) {
                $lines = explode("\n", $catout);
                $tpl->assign("lines", $lines);
            }
        }
    }
    $tpl->display('blob.tpl', $cachekey);
}
开发者ID:nterray,项目名称:tuleap,代码行数:76,代码来源:display.git_blob.php

示例4: execAction

    function execAction($dir, $item)
    {
        // show file contents
        global $action;
        if (@eregi($GLOBALS["images_ext"], $item)) {
            $html = '<img src="' . make_link('get_image', $dir, rawurlencode($item)) . '" alt="' . $GLOBALS["messages"]["actview"] . ": " . $item . '" /><br /><br />';
        } elseif (@eregi($GLOBALS["editable_ext"], $item)) {
            $geshiFile = _EXT_PATH . '/libraries/geshi/geshi.php';
            ext_RaiseMemoryLimit('32M');
            // GeSHi 1.0.7 is very memory-intensive
            include_once $geshiFile;
            // Create the GeSHi object that renders our source beautiful
            $geshi = new GeSHi('', '', dirname($geshiFile) . '/geshi');
            $file = get_abs_item($dir, $item);
            $pathinfo = pathinfo($file);
            if (ext_isFTPMode()) {
                $file = ext_ftp_make_local_copy($file);
            }
            if (is_callable(array($geshi, 'load_from_file'))) {
                $geshi->load_from_file($file);
            } else {
                $geshi->set_source(file_get_contents($file));
            }
            if (is_callable(array($geshi, 'get_language_name_from_extension'))) {
                $lang = $geshi->get_language_name_from_extension($pathinfo['extension']);
            } else {
                $pathinfo = pathinfo($item);
                $lang = $pathinfo['extension'];
            }
            $geshi->set_language($lang);
            $geshi->enable_line_numbers(GESHI_NORMAL_LINE_NUMBERS);
            $langs = $GLOBALS["language"];
            if ($langs == "japanese") {
                $enc_list = array("ASCII", "ISO-2022-JP", "UTF-8", "EUCJP-WIN", "SJIS-WIN");
                $_e0 = strtoupper(mb_detect_encoding($geshi->source, $enc_list, true));
                if ($_e0 == "SJIS-WIN") {
                    $_encoding = "Shift_JIS";
                } elseif ($_e0 == "EUCJP-WIN") {
                    $_e0 = "EUC-JP";
                } elseif ($_e0 == "ASCII") {
                    $_e0 = "UTF-8";
                } else {
                    $_encoding = $_e0;
                }
                $geshi->set_encoding($_encoding);
            }
            $html = $geshi->parse_code();
            if ($langs == "japanese") {
                if (empty($lang) || strtoupper(mb_detect_encoding($html, $enc_list)) != "UTF-8") {
                    $html = mb_convert_encoding($html, "UTF-8", $_e0);
                }
            }
            if (ext_isFTPMode()) {
                unlink($file);
            }
            $html .= '<hr /><div style="line-height:25px;vertical-align:middle;text-align:center;" class="small">Rendering Time: <strong>' . $geshi->get_time() . ' Sec.</strong></div>';
        } else {
            $html = '
			<iframe src="' . make_link('download', $dir, $item, null, null, null, '&action2=view') . '" id="iframe1" width="100%" height="100%" frameborder="0"></iframe>';
        }
        $html = str_replace(array("\r", "\n"), array('\\r', '\\n'), addslashes($html));
        ?>
		{

	"dialogtitle": "<?php 
        echo $GLOBALS['messages']['actview'] . ": " . $item;
        ?>
",
	"height": 500,
	"autoScroll": true,
	"html": "<?php 
        echo $html;
        ?>
"

}
		<?php 
    }
开发者ID:elevenfox,项目名称:VTree,代码行数:78,代码来源:view.php

示例5: LoadData

 /**
  * Loads data for this template
  */
 protected function LoadData()
 {
     $head = $this->GetProject()->GetHeadCommit();
     $this->tpl->assign('head', $head);
     $commit = $this->GetProject()->GetCommit($this->params['hashbase']);
     $this->tpl->assign('commit', $commit);
     if (!isset($this->params['hash']) && isset($this->params['file'])) {
         $this->params['hash'] = $commit->GetTree()->PathToHash($this->params['file']);
         if (empty($this->params['hash'])) {
             throw new GitPHP_FileNotFoundException($this->params['file']);
         }
     }
     $blob = $this->GetProject()->GetObjectManager()->GetBlob($this->params['hash']);
     if ($this->params['file']) {
         $blob->SetPath($this->params['file']);
     }
     $blob->SetCommit($commit);
     $this->tpl->assign('blob', $blob);
     $blame = new GitPHP_FileBlame($this->GetProject(), $commit, $this->params['file'], $this->exe);
     $this->tpl->assign('blame', $blame->GetBlame());
     if (isset($this->params['output']) && $this->params['output'] == 'js') {
         return;
     }
     $this->tpl->assign('tree', $commit->GetTree());
     if ($this->config->GetValue('geshi')) {
         include_once GITPHP_GESHIDIR . "geshi.php";
         if (class_exists('GeSHi')) {
             $geshi = new GeSHi("", 'php');
             if ($geshi) {
                 $lang = GitPHP_Util::GeshiFilenameToLanguage($blob->GetName());
                 if (empty($lang)) {
                     $lang = $geshi->get_language_name_from_extension(substr(strrchr($blob->GetName(), '.'), 1));
                 }
                 if (!empty($lang)) {
                     $geshi->enable_classes();
                     $geshi->enable_strict_mode(GESHI_MAYBE);
                     $geshi->set_source($blob->GetData());
                     $geshi->set_language($lang);
                     $geshi->set_header_type(GESHI_HEADER_PRE_TABLE);
                     $geshi->enable_line_numbers(GESHI_NORMAL_LINE_NUMBERS);
                     $output = $geshi->parse_code();
                     $bodystart = strpos($output, '<td');
                     $bodyend = strrpos($output, '</tr>');
                     if ($bodystart !== false && $bodyend !== false) {
                         $geshihead = substr($output, 0, $bodystart);
                         $geshifoot = substr($output, $bodyend);
                         $geshibody = substr($output, $bodystart, $bodyend - $bodystart);
                         $this->tpl->assign('geshihead', $geshihead);
                         $this->tpl->assign('geshibody', $geshibody);
                         $this->tpl->assign('geshifoot', $geshifoot);
                         $this->tpl->assign('geshicss', $geshi->get_stylesheet());
                         $this->tpl->assign('geshi', true);
                     }
                 }
             }
         }
     }
 }
开发者ID:hmcclungiii,项目名称:gitphp,代码行数:61,代码来源:Controller_Blame.class.php

示例6: LoadData

 /**
  * Loads data for this template
  */
 protected function LoadData()
 {
     $commit = $this->GetProject()->GetCommit($this->params['hashbase']);
     $this->tpl->assign('commit', $commit);
     $tree = $commit->GetTree();
     $this->tpl->assign('tree', $commit->GetTree());
     if (!isset($this->params['hash']) && isset($this->params['file'])) {
         $this->params['hash'] = $tree->PathToHash($this->params['file']);
         if (empty($this->params['hash'])) {
             throw new GitPHP_FileNotFoundException($this->params['file']);
         }
     }
     $blob = $this->GetProject()->GetObjectManager()->GetBlob($this->params['hash']);
     if (!empty($this->params['file'])) {
         $blob->SetPath($this->params['file']);
     }
     $blob->SetCommit($commit);
     $this->tpl->assign('blob', $blob);
     if ($this->Plain()) {
         return;
     }
     $head = $this->GetProject()->GetHeadCommit();
     $this->tpl->assign('head', $head);
     if ($this->config->GetValue('filemimetype')) {
         $mimeReader = new GitPHP_FileMimeTypeReader($blob, $this->GetMimeStrategy());
         $mimetype = $mimeReader->GetMimeType(true);
         if ($mimetype == 'image') {
             $this->tpl->assign('datatag', true);
             $this->tpl->assign('mime', $mimeReader->GetMimeType());
             $this->tpl->assign('data', base64_encode($blob->GetData()));
             return;
         }
     }
     if ($this->config->GetValue('geshi')) {
         include_once GITPHP_GESHIDIR . "geshi.php";
         if (class_exists('GeSHi')) {
             $geshi = new GeSHi("", 'php');
             if ($geshi) {
                 $lang = GitPHP_Util::GeshiFilenameToLanguage($blob->GetName());
                 if (empty($lang)) {
                     $lang = $geshi->get_language_name_from_extension(substr(strrchr($blob->GetName(), '.'), 1));
                 }
                 if (!empty($lang)) {
                     $geshi->enable_classes();
                     $geshi->enable_strict_mode(GESHI_MAYBE);
                     $geshi->set_source($blob->GetData());
                     $geshi->set_language($lang);
                     $geshi->set_header_type(GESHI_HEADER_PRE_TABLE);
                     $geshi->enable_line_numbers(GESHI_NORMAL_LINE_NUMBERS);
                     $geshi->set_overall_id('blobData');
                     $this->tpl->assign('geshiout', $geshi->parse_code());
                     $this->tpl->assign('geshicss', $geshi->get_stylesheet());
                     $this->tpl->assign('geshi', true);
                     return;
                 }
             }
         }
     }
     $this->tpl->assign('bloblines', $blob->GetData(true));
 }
开发者ID:hmcclungiii,项目名称:gitphp,代码行数:63,代码来源:Controller_Blob.class.php

示例7: geshi_format_code

function geshi_format_code($text, $ext)
{
    $str = '';
    $geshi = new GeSHi($text, '');
    $lang = $ext == 'diff' ? $ext : $geshi->get_language_name_from_extension($ext);
    $geshi->set_language($lang);
    if ($geshi->error() == GESHI_ERROR_NO_SUCH_LANG) {
        return null;
    }
    $geshi->set_encoding('UTF-8');
    //$geshi->enable_classes();
    //$geshi->set_overall_class( "source-$lang" );
    //$geshi->enable_keyword_links( false );
    $geshi->enable_line_numbers(GESHI_FANCY_LINE_NUMBERS);
    $geshi->set_header_type(GESHI_HEADER_DIV);
    $str .= $geshi->parse_code($text, 1);
    if ($geshi->error()) {
        $str .= $geshi->error();
    }
    return $str;
}
开发者ID:eclecticdave,项目名称:gitbrowser,代码行数:21,代码来源:GitBrowser.php

示例8: LoadData

 /**
  * LoadData
  *
  * Loads data for this template
  *
  * @access protected
  */
 protected function LoadData()
 {
     $commit = $this->project->GetCommit($this->params['hashbase']);
     $this->tpl->assign('commit', $commit);
     if (!isset($this->params['hash']) && isset($this->params['file'])) {
         $this->params['hash'] = $commit->PathToHash($this->params['file']);
     }
     $blob = $this->project->GetBlob($this->params['hash']);
     if (!empty($this->params['file'])) {
         $blob->SetPath($this->params['file']);
     }
     $blob->SetCommit($commit);
     $this->tpl->assign('blob', $blob);
     if (isset($this->params['plain']) && $this->params['plain']) {
         return;
     }
     $head = $this->project->GetHeadCommit();
     $this->tpl->assign('head', $head);
     $this->tpl->assign('tree', $commit->GetTree());
     if (GitPHP_Config::GetInstance()->GetValue('filemimetype', true)) {
         $mime = $blob->FileMime();
         if ($mime) {
             $mimetype = strtok($mime, '/');
             if ($mimetype == 'image') {
                 $this->tpl->assign('datatag', true);
                 $this->tpl->assign('mime', $mime);
                 $this->tpl->assign('data', base64_encode($blob->GetData()));
                 return;
             }
         }
     }
     if (GitPHP_Config::GetInstance()->GetValue('geshi', true)) {
         include_once GitPHP_Util::AddSlash(GitPHP_Config::GetInstance()->GetValue('geshiroot', 'lib/geshi/')) . "geshi.php";
         if (class_exists('GeSHi')) {
             $geshi = new GeSHi("", 'php');
             if ($geshi) {
                 $lang = $geshi->get_language_name_from_extension(substr(strrchr($blob->GetName(), '.'), 1));
                 if (!empty($lang)) {
                     $geshi->enable_classes();
                     $geshi->enable_strict_mode(GESHI_MAYBE);
                     $geshi->set_source($blob->GetData());
                     $geshi->set_language($lang);
                     $geshi->set_header_type(GESHI_HEADER_PRE_TABLE);
                     $geshi->enable_line_numbers(GESHI_NORMAL_LINE_NUMBERS);
                     $geshi->set_overall_id('blobData');
                     $this->tpl->assign('geshiout', $geshi->parse_code());
                     $this->tpl->assign('geshicss', $geshi->get_stylesheet());
                     $this->tpl->assign('geshi', true);
                     return;
                 }
             }
         }
     }
     $this->tpl->assign('bloblines', $blob->GetData(true));
 }
开发者ID:sandassha,项目名称:gitstack,代码行数:62,代码来源:Controller_Blob.class.php


注:本文中的GeSHi::get_language_name_from_extension方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。