Skip to content

Commit e967b82

Browse files
authored
编辑器
1 parent bdfde8d commit e967b82

File tree

1 file changed

+95
-0
lines changed

1 file changed

+95
-0
lines changed

plugin/class/edit/edit.php

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
<?php
2+
/* (C)2005-2021 FoundPHP Framework.
3+
* 官网:http://www.FoundPHP.com
4+
* 邮箱:43309611@qq.com
5+
* This is not a freeware, use is subject to license terms.
6+
* 此软件为授权使用软件,请参考软件协议。
7+
* http://www.foundphp.com/?m=agreement
8+
* Last:2020-01-20
9+
*/
10+
11+
class FoundPHP_edit{
12+
public $type = 'text'; //编辑器类型
13+
14+
//构造快递方法
15+
function __construct($ary=array()) {
16+
17+
if (!isset($ary['type']) || $ary['type'] == '') {
18+
return '请设置类型';
19+
}
20+
21+
$this->type = strtolower($ary['type']);
22+
//默认字符文本
23+
if (in_array($this->type,array('text',''))){
24+
$this->type = 'text';
25+
}else{ //引入的接口存在与否
26+
$api_file = 'plugin/class/edit/edit_'.$this->type.'.php';
27+
28+
if (is_file($api_file)){
29+
include_once $api_file;
30+
$this->ed = new edit_api($ary);
31+
32+
}else{
33+
die('抱歉,找不到 '.$this->type.'');//不存在
34+
}
35+
}
36+
}
37+
38+
//初始化数据
39+
function welcome(){
40+
$this->ed->welcome();
41+
}
42+
43+
/*
44+
编辑器
45+
ary 用法
46+
id 编辑器id等于接收post名称
47+
data 编辑器默认数据
48+
width 编辑器宽度 最小宽度500
49+
height 编辑器高度 自动为auto
50+
readonly true 表示只读
51+
echo edit(array('id'=>'content','data'=>$content,'height'=>300));
52+
*/
53+
function edit($ary=array()){
54+
if ($this->type=='text'){
55+
$set = '';
56+
if ($ary['readonly']){
57+
$set .= ' readonly="readonly"';
58+
}
59+
$width = 'width:'.($ary['width']!=''?$ary['width']:'100%').';';
60+
$height = 'height:'.($ary['height']!=''?$ary['height']:'300px').';';
61+
$set .= ' style="'.$width.$height.'"';
62+
63+
return '<textarea name="'.$ary['id'].'"'.$set.'>'.$ary['data'].'</textarea>';
64+
}else{
65+
return $this->ed->edit($ary);
66+
}
67+
}
68+
69+
/*消息提示
70+
code 0失败 1成功
71+
ary
72+
msg 消息内容
73+
url 链接
74+
*/
75+
function msg($code=0,$ary=array()){
76+
return $this->ed->msg($code,$ary);
77+
}
78+
79+
/*上传文件
80+
*/
81+
function get_id($ary=array()){
82+
return $this->ed->get_id($ary);
83+
}
84+
85+
/*上传文件类型
86+
*/
87+
function get_type($ary=array()){
88+
return $this->ed->get_type($ary);
89+
}
90+
91+
//管理文件
92+
function manger($dirs=''){
93+
return $this->ed->manger($dirs);
94+
}
95+
}

0 commit comments

Comments
 (0)