-
Notifications
You must be signed in to change notification settings - Fork 591
/
Plugin.php
62 lines (57 loc) · 1.94 KB
/
Plugin.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
<?php
/**
* Prism 是一个轻量级,可扩展的语法着色工具,符合 Web 标准。
*
* @package Prism
* @author 冰剑
* @version 1.0.2
* @link http://www.binjoo.net/
*/
class Prism_Plugin implements Typecho_Plugin_Interface
{
public static function activate() {
Typecho_Plugin::factory('Widget_Archive')->header = array('Prism_Plugin', 'headlink');
Typecho_Plugin::factory('Widget_Archive')->footer = array('Prism_Plugin', 'footlink');
}
public static function deactivate(){}
public static function config(Typecho_Widget_Helper_Form $form){
$style = new Typecho_Widget_Helper_Form_Element_Radio('style',
array('default' => 'Default',
'dark' => 'Dark',
'funky' => 'Funky',
'okaidia' => 'Okaidia',
'twilight' => 'Twilight',
'coy' => 'Coy',
'solarized' => 'Solarized Light',
'tomorrow' => 'Tomorrow Night'),
'default', '高亮样式', NULL);
$form->addInput($style);
}
public static function personalConfig(Typecho_Widget_Helper_Form $form){}
/**
* 头部样式
*
* @access public
* @param unknown $headlink
* @return unknown
*/
public static function headlink($cssUrl) {
$settings = Helper::options()->plugin('Prism');
$url = Helper::options()->pluginUrl .'/Prism/';
$links = '<link rel="stylesheet" type="text/css" href="'.$url.'css/prism-'.$settings->style.'.css" />';
echo $links;
}
/**
* 底部脚本
*
* @access public
* @param unknown $footlink
* @return unknown
*/
public static function footlink($links) {
$settings = Helper::options()->plugin('Prism');
$url = Helper::options()->pluginUrl .'/Prism/';
$links= '<script type="text/javascript" src="'.$url.'js/prism.js"></script>';
echo $links;
}
}