コード例 #1
0
ファイル: field.php プロジェクト: dalinhuang/zotop
 /**
  * 判断控件类型是否存在
  *
  * @param $type string  控件类型
  * @return bool 返回控件真假
  */
 public static function exists($type)
 {
     if (field::set($type)) {
         return true;
     }
     if (method_exists('field', $type)) {
         return true;
     }
     return false;
 }
コード例 #2
0
ファイル: admin.php プロジェクト: dalinhuang/zotop
function system_field_template()
{
    field::set('template', 'field_template');
    function field_template($attrs)
    {
        $html[] = field::text($attrs);
        $html[] = '<a class="dialog" href="' . zotop::url('system/template/select/' . $attrs['name']) . '" title="选择模板"><span class="zotop-icon zotop-icon-template"></span></a>';
        return implode("\n", $html);
    }
}
コード例 #3
0
ファイル: field.php プロジェクト: dalinhuang/zotop
 /**
  * 生成一个控件的Html数据
  *
  *
  * @param $name string 控件名称
  * @param $attrs array  控件参数
  * @return string 返回控件的代码
  */
 public static function get($name, $attrs = array())
 {
     $callback = field::set($name);
     if ($callback) {
         return call_user_func_array($callback, array($attrs));
     }
     if (method_exists('field', $name)) {
         return field::$name($attrs);
     }
     return 'Unkown FieldController : <b>' . $name . '</b>';
 }
コード例 #4
0
ファイル: admin.php プロジェクト: dalinhuang/zotop
function field_keywords()
{
    field::set('keyword', 'site_keywords');
    function site_keywords($attrs)
    {
        //$html[] = html::script('$common/js/zotop.keywords.js');
        $html[] = '<div class="field-wrapper clearfix">';
        $html[] = '	' . field::text($attrs);
        $html[] = '	<span class="field-handle">';
        $html[] = '		&nbsp;<a class="setkeywords" style="display:inline-block;" valueto="' . $attrs['name'] . '" title="' . zotop::t('常用关键词') . '"><span class="zotop-icon zotop-icon-keywords"></span></a>';
        $html[] = '	</span>';
        $html[] = '</div>';
        return implode("\n", $html);
    }
}
コード例 #5
0
ファイル: admin.php プロジェクト: dalinhuang/zotop
function field_codemirror()
{
    field::set('code', 'codemirror');
    function codemirror($attrs)
    {
        $url = zotop::module('codemirror', 'url');
        $options = new stdClass();
        $options->path = $url . '/codemirror/js/';
        $options->parserfile = array('parsexml.js');
        $options->stylesheet = array($url . '/codemirror/css/xmlcolors.css');
        $options->height = is_numeric($attrs['height']) ? $attrs['height'] . 'px' : $attrs['height'];
        $options->width = is_numeric($attrs['width']) ? $width . 'px' : $attrs['width'];
        $options->continuousScanning = 500;
        $options->autoMatchParens = true;
        if ($attrs['linenumbers'] !== false) {
            $options->lineNumbers = true;
            $options->textWrapping = false;
        }
        if ($attrs['tabmode'] == '') {
            $options->tabMode = 'shift';
        }
        $html = array();
        $html[] = html::script($url . '/codemirror/js/codemirror.js');
        $html[] = html::stylesheet($url . '/codemirror/css/codemirror.css');
        $html[] = '	' . field::textarea($attrs);
        $html[] = '<script type="text/javascript">';
        $html[] = '	var editor = CodeMirror.fromTextArea("' . $attrs['name'] . '", ' . json_encode($options) . ');';
        $html[] = '$(function(){';
        $html[] = '	$("form").submit(function(){';
        $html[] = '		$("textarea[name=+' . $attrs['name'] . '+]").val(editor.getCode());';
        $html[] = '	});';
        $html[] = '})';
        $html[] = '</script>';
        return implode("\n", $html);
    }
    field::set('templateeditor', templateeditor);
    function templateeditor($attrs)
    {
        return codemirror($attrs);
    }
}
コード例 #6
0
ファイル: admin.php プロジェクト: dalinhuang/zotop
function field_xheditor()
{
    field::set('editor', 'xheditor_rc1');
    function xheditor_rc1($attrs)
    {
        $attrs['class'] = isset($attrs['class']) ? 'editor ' . $attrs['class'] : 'editor';
        $tools = array('image' => '<a href="' . zotop::url('system/image/upload') . '" class="button editor-insert" name="' . $attrs['name'] . '"><span class="zotop-icon zotop-icon-imageuploader button-icon"></span><span class="button-text">插入图片</span></a>', 'file' => '<a href="' . zotop::url('system/file/upload') . '" class="button editor-insert" name="' . $attrs['name'] . '"><span class="zotop-icon zotop-icon-fileuploader button-icon"></span><span class="button-text">插入文件</span></a>', 'template' => '<a href="' . zotop::url('system/file/upload') . '" class="button editor-insert" name="' . $attrs['name'] . '"><span class="zotop-icon zotop-icon-template button-icon"></span><span class="button-text">插入模板</span></a>');
        $tools = zotop::filter('editor.tools', $tools);
        $tools = arr::take('tools', $attrs) === false ? array() : $tools;
        $url = zotop::module('xheditor', 'url');
        $html[] = html::script($url . '/editor/xheditor-zh-cn.min.js');
        $html[] = html::script($url . '/common/global.js');
        if (is_array($tools) && !empty($tools)) {
            $html[] = '<div class="field-toolbar">';
            foreach ($tools as $tool) {
                $html[] = ' ' . $tool;
            }
            $html[] = '</div>';
        }
        $html[] = '	' . field::textarea($attrs);
        return implode("\n", $html);
    }
}
コード例 #7
0
ファイル: file.php プロジェクト: dalinhuang/zotop
 public function __init()
 {
     field::set('source', array($this, 'source'));
 }
コード例 #8
0
ファイル: mine.php プロジェクト: dalinhuang/zotop
 public function __init()
 {
     field::set('image', array($this, 'image'));
 }