开源 企业版 高校版 私有云 模力方舟 AI 队友
代码拉取完成,页面将自动刷新
捐赠
捐赠前请先登录
扫描微信二维码支付
取消
支付完成
支付提示
将跳转至支付宝完成支付
确定
取消
1 Star 0 Fork 921

张健(peter)/IBOS

加入 Gitee
与超过 1400万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
已有帐号? 立即登录
文件
master
分支 (2)
标签 (6)
master
develop
4.2
3.9
3.8
3.5
v3.5
3.3
master
分支 (2)
标签 (6)
master
develop
4.2
3.9
3.8
3.5
v3.5
3.3
克隆/下载
克隆/下载
提示
下载代码请复制以下命令到终端执行
为确保你提交的代码身份被 Gitee 正确识别,请执行以下命令完成配置
初次使用 SSH 协议进行代码克隆、推送等操作时,需按下述提示完成 SSH 配置
1 生成 RSA 密钥
2 获取 RSA 公钥内容,并配置到 SSH公钥
在 Gitee 上使用 SVN,请访问 使用指南
使用 HTTPS 协议时,命令行会出现如下账号密码验证步骤。基于安全考虑,Gitee 建议 配置并使用私人令牌 替代登录密码进行克隆、推送等操作
Username for 'https://gitee.com': userName
Password for 'https://userName@gitee.com': # 私人令牌
master
分支 (2)
标签 (6)
master
develop
4.2
3.9
3.8
3.5
v3.5
3.3
IBOS
/
library
/
web
/
CWidgetFactory.php
IBOS
/
library
/
web
/
CWidgetFactory.php
CWidgetFactory.php 7.38 KB
一键复制 编辑 原始数据 按行查看 历史
seekArt 提交于 2015年07月21日 17:24 +08:00 . 提交初始版本
<?php
/**
* CWidgetFactory class file.
*
* @author Qiang Xue <qiang.xue@gmail.com>
* @link http://www.yiiframework.com/
* @copyright 2008-2013 Yii Software LLC
* @license http://www.yiiframework.com/license/
*/
/**
* CWidgetFactory creates new widgets to be used in views.
*
* CWidgetFactory is used as the default "widgetFactory" application component.
*
* When calling {@link CBaseController::createWidget}, {@link CBaseController::widget}
* or {@link CBaseController::beginWidget}, if the "widgetFactory" component is installed,
* it will be used to create the requested widget. To install the "widgetFactory" component,
* we should have the following application configuration:
* <pre>
* return array(
* 'components'=>array(
* 'widgetFactory'=>array(
* 'class'=>'CWidgetFactory',
* ),
* ),
* )
* </pre>
*
* CWidgetFactory implements the "skin" feature, which allows a new widget to be created
* and initialized with a set of predefined property values (called skin).
*
* When CWidgetFactory is used to create a new widget, it will first instantiate the
* widget instance. It then checks if there is a skin available for this widget
* according to the widget class name and the widget {@link CWidget::skin} property.
* If a skin is found, it will be merged with the initial properties passed via
* {@link createWidget}. Then the merged initial properties will be used to initialize
* the newly created widget instance.
*
* As aforementioned, a skin is a set of initial property values for a widget.
* It is thus represented as an associative array of name-value pairs.
* Skins are stored in PHP scripts like other configurations. Each script file stores the skins
* for a particular widget type and is named as the widget class name (e.g. CLinkPager.php).
* Each widget type may have one or several skins, identified by the skin name set via
* {@link CWidget::skin} property. If the {@link CWidget::skin} property is not set for a given
* widget, it means the default skin would be used. The following shows the possible skins for
* the {@link CLinkPager} widget:
* <pre>
* return array(
* 'default'=>array(
* 'nextPageLabel'=>'&gt;&gt;',
* 'prevPageLabel'=>'&lt;&lt;',
* ),
* 'short'=>array(
* 'header'=>'',
* 'maxButtonCount'=>5,
* ),
* );
* </pre>
* In the above, there are two skins. The first one is the default skin which is indexed by the string "default".
* Note that {@link CWidget::skin} defaults to "default". Therefore, this is the skin that will be applied
* if we do not explicitly specify the {@link CWidget::skin} property.
* The second one is named as the "short" skin which will be used only when we set {@link CWidget::skin}
* to be "short".
*
* By default, CWidgetFactory looks for the skin of a widget under the "skins" directory
* of the current application's {@link CWebApplication::viewPath} (e.g. protected/views/skins).
* If a theme is being used, it will look for the skin under the "skins" directory of
* the theme's {@link CTheme::viewPath} (as well as the aforementioned skin directory).
* In case the specified skin is not found, a widget will still be created
* normally without causing any error.
*
* @author Qiang Xue <qiang.xue@gmail.com>
* @package system.web
* @since 1.1
*/
class CWidgetFactory extends CApplicationComponent implements IWidgetFactory
{
/**
* @var boolean whether to enable widget skinning. Defaults to false.
* @see skinnableWidgets
* @since 1.1.3
*/
public $enableSkin=false;
/**
* @var array widget initial property values. Each array key-value pair
* represents the initial property values for a single widget class, with
* the array key being the widget class name, and array value being the initial
* property value array. For example,
* <pre>
* array(
* 'CLinkPager'=>array(
* 'maxButtonCount'=>5,
* 'cssFile'=>false,
* ),
* 'CJuiDatePicker'=>array(
* 'language'=>'ru',
* ),
* )
* </pre>
*
* Note that the initial values specified here may be overridden by
* the values given in {@link CBaseController::createWidget} calls.
* They may also be overridden by widget skins, if {@link enableSkin} is true.
* @since 1.1.3
*/
public $widgets=array();
/**
* @var array list of widget class names that can be skinned.
* Because skinning widgets has performance impact, you may want to specify this property
* to limit skinning only to specific widgets. Any widgets that are not in this list
* will not be skinned. Defaults to null, meaning all widgets can be skinned.
* @since 1.1.3
*/
public $skinnableWidgets;
/**
* @var string the directory containing all the skin files. Defaults to null,
* meaning using the "skins" directory under the current application's {@link CWebApplication::viewPath}.
*/
public $skinPath;
private $_skins=array(); // class name, skin name, property name => value
/**
* Initializes the application component.
* This method overrides the parent implementation by resolving the skin path.
*/
public function init()
{
parent::init();
if($this->enableSkin && $this->skinPath===null)
$this->skinPath=Yii::app()->getViewPath().DIRECTORY_SEPARATOR.'skins';
}
/**
* Creates a new widget based on the given class name and initial properties.
* @param CBaseController $owner the owner of the new widget
* @param string $className the class name of the widget. This can also be a path alias (e.g. system.web.widgets.COutputCache)
* @param array $properties the initial property values (name=>value) of the widget.
* @return CWidget the newly created widget whose properties have been initialized with the given values.
*/
public function createWidget($owner,$className,$properties=array())
{
$className=Yii::import($className,true);
$widget=new $className($owner);
if(isset($this->widgets[$className]))
$properties=$properties===array() ? $this->widgets[$className] : CMap::mergeArray($this->widgets[$className],$properties);
if($this->enableSkin)
{
if($this->skinnableWidgets===null || in_array($className,$this->skinnableWidgets))
{
$skinName=isset($properties['skin']) ? $properties['skin'] : 'default';
if($skinName!==false && ($skin=$this->getSkin($className,$skinName))!==array())
$properties=$properties===array() ? $skin : CMap::mergeArray($skin,$properties);
}
}
foreach($properties as $name=>$value)
$widget->$name=$value;
return $widget;
}
/**
* Returns the skin for the specified widget class and skin name.
* @param string $className the widget class name
* @param string $skinName the widget skin name
* @return array the skin (name=>value) for the widget
*/
protected function getSkin($className,$skinName)
{
if(!isset($this->_skins[$className][$skinName]))
{
$skinFile=$this->skinPath.DIRECTORY_SEPARATOR.$className.'.php';
if(is_file($skinFile))
$this->_skins[$className]=require($skinFile);
else
$this->_skins[$className]=array();
if(($theme=Yii::app()->getTheme())!==null)
{
$skinFile=$theme->getSkinPath().DIRECTORY_SEPARATOR.$className.'.php';
if(is_file($skinFile))
{
$skins=require($skinFile);
foreach($skins as $name=>$skin)
$this->_skins[$className][$name]=$skin;
}
}
if(!isset($this->_skins[$className][$skinName]))
$this->_skins[$className][$skinName]=array();
}
return $this->_skins[$className][$skinName];
}
}
Loading...
举报
举报成功
我们将于2个工作日内通过站内信反馈结果给你!
请认真填写举报原因,尽可能描述详细。
请选择举报类型
取消
发送
误判申诉

此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。

如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。

取消
提交

简介

基于Yii和bootstrap的开源OA/协同办公平台,连接全平台覆盖的酷办公客户端(Win,IOS,Android,Mac,Linux),支撑您的企业管理二次开发--作为国内首家开源OA,有的不只是颜值
取消

发行版

暂无发行版

贡献者

全部

近期动态

不能加载更多了
编辑仓库简介
简介内容
主页
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
PHP
1
https://gitee.com/case-code/IBOS.git
git@gitee.com:case-code/IBOS.git
case-code
IBOS
IBOS
master
点此查找更多帮助

搜索帮助

评论
仓库举报
回到顶部
登录提示
该操作需登录 Gitee 帐号,请先登录后再操作。
立即登录
没有帐号,去注册

AltStyle によって変換されたページ (->オリジナル) /