一些插件的使用

 

**********************************

fckeditor使用:  

***********************************

复制fckeditor.php 到 app/control目录下

                         复制js文件夹及其内容fckeditor到js目录下

      配置要使用文件

~form:

  _subject: "添加任务"

  _tips: true 

subject:

  _ui: textbox

  _label: "任务主题"

  _req: true

description:

  _ui: fckeditor

  toolbar: Custom

  width: 80%

  height: 150px

  _label: "任务描述"

 

调用配置文件生成表单

class Form_Task extends QForm

{

    function __construct($action)

    {

        // 调用父类的构造函数

        parent::__construct('form_task', $action);

 

        // 从配置文件载入表单

        $config = Helper_YAML::loadCached(dirname(__FILE__) . '/task_form.yaml.php');

$this->loadFromConfig($config);

$this->addValidations(Task::meta());

    }

}

 

**************************************************************

、、、、、、、、、分页显示pagination的使用:

************************************************************

1 复制 pagination.php到control目录下

2 在查询时取得分页信息 controlter下写

// 分页查询

$page = intval($this->_context->page);

if ($page < 1) $page = 1;

 

// 构造查询对象

$select = Post::find()->limitPage($page, 10);

 

// 将分页信息和查询到的数据传递到视图

$this->_view['pagination'] = $select->getPagination();

$this->_view['posts']      = $select->getAll();

 

3 在视图中显示

<?php

$this->_control('pagination', 'my-pagination', array(

    'pagination' => $pagination,

));

?>

***********************************

表单视图的使用,简单表单视图formview_simple_element.php的使用

****************************************************************************

1 复制formview_simple_element.php到_code/app/view/_elements/下

2 在表单输出的地方

<?php $this->_element('formview_simple', array('form' => $form)); ?>

3 表单配置文件的配置

 

# ~form 开头的内容用于指定表单属性

~form:

  _subject: "注册新用户"

  _tips: true

# 指定字段及过滤器等信息

username:

  _ui: textbox

  _filters: ['trim', 'strtolower']

  _label: "用户名"

  _req: true

password:

  _ui: password

  _label: "密码"

  _req: true

4 表单文件调用配置文件

 

class Form_UserLogin extends QForm

{

    function __construct($action)

    {

        parent::__construct('form_userlogin', $action);

 

        $config = Helper_YAML::loadCached(dirname(__FILE__) . '/userlogin_form.yaml.php');

$this->loadFromConfig($config);

        $this->addValidations(User::meta());

    }

}

 

 

******************************************8

自带插件acluser使用

·密码属性的自动加密

·验证用户名和密码的正确性

·验证用户名的唯一性

·查询用户的基本属性和角色信息

****************************

使用acluser插件,1修改_define()方法

(在模型中修改)

// 指定该 ActiveRecord 要使用的行为插件

            'behaviors' => 'acluser',

 

            // 指定行为插件的配置

            'behaviors_settings' => array

            (

                # '插件名' => array('选项' => 设置),

                'acluser' => array(

                    'acl_data_props' => 'username',

                ),

            ),

 

可能有关联

/**

                 * 添加对象间的关联

                 */

                # 'other' => array('has_one' => 'Class'),

 

                'tasks' => array(QDB::HAS_MANY => 'Task', 'target_key' => 'owner_id'),

 

**************************************************************************88

访问控制:

 

# 访问规则示例

#

 

users:

  allow: ACL_HAS_ROLE

  actions:

    register:

      allow: ACL_NO_ROLE

    login:

      allow: ACL_NO_ROLE

 

tasks:

  allow: ACL_HAS_ROLE

 

default:

  allow: ACL_EVERYONE

 

ALL_CONTROLLERS:

  deny: ACL_EVERYONE


在文件 acl.yaml 中修改设置  快速入门72页

 

*****************************************

****************************************8

添加ckeditor使用

1.下载ckeditor ckfinder,ckeditor复制到根目录下,然后我这里把ckfinder放到ckeditor目录里面

2.在control里面添加ckeditor.php代码如下、class Control_CKEditor extends QUI_Control_Abstr

class Control_CKEditor extends QUI_Control_Abstract
{
    function render()
    {
        $base_dir = $this->get('base_dir', $this->_context->baseDir() . 'ckeditor/');
        $base_dir = h(rtrim($base_dir, '/\\') . '/');
        $width = $this->get('width', "100%");
            $height = $this->get('height', "250px");
            $toolbar = $this->get('toolbar', "Default");
        $id = $this->id();
        $value = $this->get('value', '');
        $config = $this->get('config');
        if (!is_array($config))
        {
            $config = array();
        }

            $out = Q::control('memo', $this->id(), array('value'=>$value))->render();

        $out .= <<<EOT
<script type="text/javascript" src="{$base_dir}ckeditor.js"></script>
<script type="text/javascript">
//<![CDATA[
                                        var editor=CKEDITOR.replace( '{$id}',
                                                {
                                                        skin : 'v2',
                            filebrowserBrowseUrl : '{$base_dir}ckfinder/ckfinder.html',
                            filebrowserImageBrowseUrl : '{$base_dir}ckfinder/ckfinder.html?Type=Images',
                            filebrowserFlashBrowseUrl : '{$base_dir}ckfinder/ckfinder.html?Type=Flash',
                            filebrowserUploadUrl : '{$base_dir}ckfinder/core/connector/php/connector.php?command=QuickUpload&type=Files',
                            filebrowserImageUploadUrl : '{$base_dir}ckfinder/core/connector/php/connector.php?command=QuickUpload&type=Images',
                            filebrowserFlashUploadUrl : '{$base_dir}ckfinder/core/connector/php/connector.php?command=QuickUpload&type=Flash',
                                              });

                                //]]>

</script>
EOT;
        return $out;
    }
}

 3.修改editor下config.js   可以添加以下代码,具体还有很多设置可以另外再找

 

CKEDITOR.config.width = 800;
	CKEDITOR.config.height = 360;
	
	config.toolbar=

		[

		['Source','-','Save','NewPage','Preview','-','Templates'],

		['Cut','Copy','Paste','PasteText'],

		['Undo','Redo','-','Find','Replace','-','SelectAll','RemoveFormat'],

		['Form','Checkbox','Radio','TextField','Textarea','Select','Button',

		'ImageButton','HiddenField'],

		'/',

		['Bold','Italic','Underline','Strike','-','Subscript','Superscript'],

		['NumberedList','BulletedList','-','Outdent','Indent','Blockquote'],

		['JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock'],

		['Link','Unlink','Anchor'],

		['Image','Flash','Table','HorizontalRule','Smiley','SpecialChar',

		'PageBreak'],

		'/',

		['Styles','Format','Font','FontSize'],

		['TextColor','BGColor'],

		['Maximize','ShowBlocks','-','About']

		];
	config.protectedSource.push( /<\s*iframe[\s\S]*?>/gi ) ; // <iframe> tags. 
	config.protectedSource.push( /<\s*frameset[\s\S]*?>/gi ) ; // <frameset> tags. 
	config.protectedSource.push( /<\s*frame[\s\S]*?>/gi ) ; // <frame> tags. 
	config.protectedSource.push( /<\s*script[\s\S]*?\/script\s*>/gi ) ; // <SCRIPT> tags. 
	config.protectedSource.push( /<%[\s\S]*?%>/g ) ; // ASP style server side code 
	config.protectedSource.push( /<\?[\s\S]*?\?>/g ) ; // PHP style server side code 
	config.protectedSource.push( /(<asp:[^\>] >[\s|\S]*?<\/asp:[^\>] >)|(<asp:[^\>] \/>)/gi ) ; 

 4.ckfinder 里修改config。php   其中主要修改上传文件的路径 $baseUrl = '/uniteone/public/upload';

这样目录就是项目uniteone下/public/upload

还可以设置在打开插入图片、链接、图片域、flash时浏览服务器文件的权限 代码如下:

 

$config['AccessControl'][] = Array(
		'role' => '*',
		'resourceType' => '*',
		'folder' => '/',

		'folderView' => true,
		'folderCreate' => true,
		'folderRename' => false,
		'folderDelete' => false,

		'fileView' => true,
		'fileUpload' => true,
		'fileRename' => false,
		'fileDelete' => false);

4.1修改链接上传附件(如果不行还要修改ckfinder.js里面的代码修改成和image一样格式)

$config['AccessControl'][] = Array(
		'role' => '*',
		'resourceType' => 'Files',
		'folder' => '/Logos',

		'fileUpload' => true,
		'fileRename' => false,
		'fileDelete' => false);

config.js:

editorObj.Config['LinkBrowserURL'] = url + qs + 'type=' + ( filesType || 'Files' ) ;
	editorObj.Config['ImageBrowserURL'] = url + qs + 'type=' + ( imageType || 'Images' ) ;
	editorObj.Config['FlashBrowserURL'] = url + qs + 'type=' + ( flashType || 'Flash' ) ;

	var dir = url.substring(0, 1 + url.lastIndexOf("/"));
	editorObj.Config['LinkUploadURL'] = dir + "core/connector/" + ckfinder.ConnectorLanguage + "/connector."
		+ ckfinder.ConnectorLanguage + "?command=QuickUpload&type=" + ( filesType || 'Files' ) ;
	editorObj.Config['ImageUploadURL'] = dir + "core/connector/" + ckfinder.ConnectorLanguage + "/connector."
		+ ckfinder.ConnectorLanguage + "?command=QuickUpload&type=" + ( imageType || 'Images' ) ;
	editorObj.Config['FlashUploadURL'] = dir + "core/connector/" + ckfinder.ConnectorLanguage + "/connector."
		+ ckfinder.ConnectorLanguage + "?command=QuickUpload&type=" + ( flashType || 'Flash' ) ;
 

5.在form配置文件中使用ckeditor的地方 _ui:ckeditor

6.从配置文件中调用表单 代码基本是固定的,上面其他插件使用有贴出来。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值