Yii Framework v1.1.10 绫诲弬鑰

CJuiTabs

zii.widgets.jui
缁ф壙 class CJuiTabs » CJuiWidget » CWidget » CBaseController » CComponent
婧愯嚜 1.1
鐗堟湰 $Id: CJuiTabs.php 3400 2011-09-22 00:47:39Z sebathi $
婧愮爜 framework/zii/widgets/jui/CJuiTabs.php
CJuiTabs鏄剧ず涓涓夐」鍗¢儴浠躲

CJuiTabs灏佽浜JUI tabs 鎻掍欢銆

浣跨敤杩欎釜閮ㄤ欢锛屼綘鍙互鍦ㄨ鍥鹃噷闈㈡彃鍏ヤ互涓嬩唬鐮侊細
$this->widget('zii.widgets.jui.CJuiTabs', array(
    'tabs'=>array(
        'StaticTab 1'=>'Content for tab 1',
        'StaticTab 2'=>array('content'=>'Content for tab 2', 'id'=>'tab2'),
        // panel 3 contains the content rendered by a partial view
        'AjaxTab'=>array('ajax'=>$ajaxUrl),
    ),
    // additional javascript options for the tabs plugin
    'options'=>array(
        'collapsible'=>true,
    ),
));


閫氳繃閰嶇疆options灞炴э紝 浣犲彲浠ユ寚瀹氶渶瑕佷紶閫掔粰JUI tabs鎻掍欢鐨勯夐」銆 濡傛灉闇瑕侀夋嫨锛坣ame-value pairs锛夛紝 璇峰弬闃JUI tabs璇存槑銆

鍏叡灞炴

闅愯棌缁ф壙灞炴

灞炴绫诲瀷鎻忚堪瀹氫箟鍦
actionPrefix string actions鐨処D鐨勫墠缂銆 褰撳井浠跺湪CController::actions涓0鏄庝簡 鍔ㄤ綔鎻愪緵鑰咃紝鍙互涓哄叾鍔ㄤ綔鐨処D鎸囧畾鍓嶇紑浠ュ尯鍒 浜庡埆鐨勫井浠舵垨鎺у埗鍣ㄣ傚綋寰欢鐢ㄤ簬鎺у埗鍣 鐨勮鍥句腑鏃讹紝蹇呴』閰嶇疆鍚屾牱鐨勫墠缂銆 CWidget
contentTemplate string 鐢ㄦ潵浜х敓姣忎釜鏍囩鍐呭鐨勬ā鏉裤 鏍囪鈥渰content}鈥濆湪妯℃澘闈㈡澘鐨勫唴瀹瑰皢琚浛鎹紝 鍚屾椂鏍囪鈥渰id}鈥濇浛鎹负鏍囩ID. CJuiTabs
controller CController 杩斿洖姝ゅ井浠舵墍灞炵殑鎺у埗鍣ㄣ CWidget
cssFile mixed 涓婚鐨凜SS鏂囦欢鍚嶃傞粯璁ゆ槸鈥榡query-ui. CJuiWidget
headerTemplate string 鎵浣跨敤鐨勬瘡涓潰鏉跨殑鏍囬浜х敓鐨勬ā鏉裤 鏍囪鈥渰title}鈥濇ā鏉垮皢琚浛鎹㈤潰鏉跨殑鏍囬锛 骞朵笖鏍囪鈥渰url}鈥濆皢琚浛鎹㈢敤鈥#TabID鈥濇垨Ajax璇锋眰鐨刄RL銆 CJuiTabs
htmlOptions array JUI缁勪欢涓璈TML鏍囩鐨勫睘鎬ц缃 CJuiWidget
id string 杩斿洖姝ゅ井浠剁殑ID銆傚鏋滈渶瑕佺殑璇濓紝灏嗙敓浜т竴涓柊鐨処D骞跺皢鍏惰繑鍥炪 CWidget
options array the 鍒濆鐨凧avaScript闇瑕佷紶閫掔粰JUI鎻掍欢鐨勯夐」銆 CJuiWidget
owner CBaseController 杩斿洖姝ゅ井浠剁殑鎵鏈夎呮垨鍒涘缓鑰呫 CWidget
scriptFile mixed 涓昏JUI鐨凧avaScript鐨勬枃浠跺悕銆傞粯璁ゆ槸鈥榡query-ui. CJuiWidget
scriptUrl string 鍖呭惈鎵鏈塉UI JavaScript鏂囦欢鐨勬牴鐩綍銆 濡傛灉娌℃湁璁剧疆杩欎釜灞炴э紙榛樿锛夛紝Yii will publish the JUI package included in the zii release and use that to infer the root script URL. CJuiWidget
skin mixed 寰欢浣跨敤鐨勭毊鑲ょ殑鍚嶇О銆傞粯璁や负鈥渄efault鈥濄 濡傛灉姝ゅ睘鎬ц缃负false锛屽井浠跺皢涓嶄細鏈夌毊鑲よ浣跨敤銆 CWidget
tabs array 鏍囩鍒楄〃锛坱ab title=>tab content锛夈 闇瑕佹敞鎰忕殑鏄痶ab鐨勬爣棰樹笉浼氳HTML-encoded銆 tab鐨勫唴瀹瑰彲浠ユ槸涓涓瓧绗︿覆鎴栨暟缁勩 褰撳畠鏄竴涓暟缁勶紝瀹冨彲浠ュ湪浠ヤ笅涓ょ鏍煎紡涔嬩竴锛
array('id'=>'myTabID', 'content'=>'tab content')
array('id'=>'myTabID', 'ajax'=>URL)
鈥榠d鈥欑殑鍏冪礌鏄彲閫夌殑銆傜浜岀鏍煎紡鍏佽tab鐨勫唴瀹硅鍔ㄦ佸湴浠庢寚瀹氱殑URL閫氳繃AJAX鑾峰彇銆 璇RL鍙互鏄竴涓瓧绗︿覆鎴栦竴涓暟缁勩 濡傛灉涓涓暟缁勶紝灏嗗綊鍒颁竴涓娇鐢║RLCHtml::normalizeUrl.
CJuiTabs
tagName string 鎵鏈夐潰鏉跨殑瀹瑰櫒鍏冪礌鐨勫悕绉般傞粯璁や负鈥榙iv鈥欍 CJuiTabs
theme string JUI涓婚鐨勫悕瀛椼傞粯璁ゆ槸鈥榖ase鈥欍傜‘淇濆湪themeUrl涓嬫湁杩欐牱涓涓洰褰曪紝 鍏跺悕绉版槸杩欎釜灞炴х殑鍊肩浉鍚岋紙鍖哄垎澶у皬鍐欙級銆 CJuiWidget
themeUrl string 鍖呭惈鎵鏈塉UI鐨勪富棰樻枃浠跺す鐨勬牴鐩綍銆 濡傛灉娌℃湁璁剧疆杩欎釜灞炴э紙榛樿锛夛紝 Yii will publish the JUI package included in the zii release and use that to infer the root theme URL. CJuiWidget
viewPath string 杩斿洖鍖呭惈姝ゅ井浠舵墍闇鐨勮鍥炬枃浠剁殑璺緞銆 CWidget

鍏叡鏂规硶

闅愯棌缁ф壙鏂规硶

鏂规硶鎻忚堪瀹氫箟鍦
__call() 濡傛灉绫讳腑娌℃湁璋冪殑鏂规硶鍚嶏紝鍒欒皟鐢ㄨ繖涓柟娉曘 CComponent
__construct() 鏋勯犲櫒銆 CWidget
__get() 杩斿洖涓涓睘鎬у笺佷竴涓簨浠跺鐞嗙▼搴忓垪琛ㄦ垨涓涓涓哄悕绉般 CComponent
__isset() 妫鏌ヤ竴涓睘鎬ф槸鍚︿负null銆 CComponent
__set() 璁剧疆涓涓粍浠剁殑灞炴у笺 CComponent
__unset() 璁剧疆涓涓粍浠剁殑灞炴т负null銆 CComponent
actions() 杩斿洖姝idget浣跨敤鐨勫姩浣滅殑鍒楄〃銆 CWidget
asa() 杩斿洖杩欎釜鍚嶅瓧鐨勮涓哄璞° CComponent
attachBehavior() 闄勫姞涓涓涓哄埌缁勪欢銆 CComponent
attachBehaviors() 闄勫姞涓涓涓哄垪琛ㄥ埌缁勪欢銆 CComponent
attachEventHandler() 涓轰簨浠堕檮鍔犱竴涓簨浠跺鐞嗙▼搴忋 CComponent
beginCache() Begins fragment caching. CBaseController
beginClip() Begins recording a clip. CBaseController
beginContent() Begins the rendering of content that is to be decorated by the specified view. CBaseController
beginWidget() Creates a widget and executes it. CBaseController
canGetProperty() 纭畾灞炴ф槸鍚﹀彲璇汇 CComponent
canSetProperty() 纭畾灞炴ф槸鍚﹀彲鍐欍 CComponent
createWidget() Creates a widget and initializes it. CBaseController
detachBehavior() 浠庣粍浠朵腑鍒嗙涓涓涓恒 CComponent
detachBehaviors() 浠庣粍浠朵腑鍒嗙鎵鏈夎涓恒 CComponent
detachEventHandler() 鍒嗙涓涓瓨鍦ㄧ殑浜嬩欢澶勭悊绋嬪簭銆 CComponent
disableBehavior() 绂佺敤涓涓檮鍔犺涓恒 CComponent
disableBehaviors() 绂佺敤缁勪欢闄勫姞鐨勬墍鏈夎涓恒 CComponent
enableBehavior() 鍚敤涓涓檮鍔犺涓恒 CComponent
enableBehaviors() 鍚敤缁勪欢闄勫姞鐨勬墍鏈夎涓恒 CComponent
endCache() Ends fragment caching. CBaseController
endClip() Ends recording a clip. CBaseController
endContent() Ends the rendering of content. CBaseController
endWidget() Ends the execution of the named widget. CBaseController
evaluateExpression() 璁$畻涓涓狿HP琛ㄨ揪寮忥紝鎴栨牴鎹粍浠朵笂涓嬫枃鎵ц鍥炶皟銆 CComponent
getController() 杩斿洖姝ゅ井浠舵墍灞炵殑鎺у埗鍣ㄣ CWidget
getEventHandlers() 杩斿洖涓涓簨浠剁殑闄勫姞澶勭悊绋嬪簭鍒楄〃銆 CComponent
getId() 杩斿洖姝ゅ井浠剁殑ID銆傚鏋滈渶瑕佺殑璇濓紝灏嗙敓浜т竴涓柊鐨処D骞跺皢鍏惰繑鍥炪 CWidget
getOwner() 杩斿洖姝ゅ井浠剁殑鎵鏈夎呮垨鍒涘缓鑰呫 CWidget
getViewFile() 鏍规嵁瑙嗗浘鍚嶆煡鎵捐鍥炬枃浠躲 CWidget
getViewPath() 杩斿洖鍖呭惈姝ゅ井浠舵墍闇鐨勮鍥炬枃浠剁殑璺緞銆 CWidget
hasEvent() 纭畾涓涓簨浠舵槸鍚﹀畾涔夈 CComponent
hasEventHandler() 妫鏌ヤ簨浠舵槸鍚︽湁闄勫姞鐨勫鐞嗙▼搴忋 CComponent
hasProperty() 纭畾灞炴ф槸鍚﹁瀹氫箟銆 CComponent
init() 鍒濆鍖栬繖涓粍浠躲 CJuiWidget
raiseEvent() 鍙戣捣涓涓簨浠躲 CComponent
render() 娓叉煋涓涓鍥俱 CWidget
renderFile() Renders a view file. CBaseController
renderInternal() Renders a view file. CBaseController
run() 杩愯杩欎釜閮ㄤ欢銆 CJuiTabs
setId() 璁剧疆姝ゅ井浠剁殑ID銆 CWidget
widget() Creates a widget and executes it. CBaseController

鍙椾繚鎶ゆ柟娉

闅愯棌缁ф壙鏂规硶

鏂规硶鎻忚堪瀹氫箟鍦
registerCoreScripts() 娉ㄥ唽鏍稿績鐨勮剼鏈枃浠躲 CJuiTabs
registerScriptFile() 娉ㄥ唽涓涓狫avaScript鏂囦欢鍦scriptUrl涓嬨 CJuiWidget
resolvePackagePath() 纭畾JUI鍖呭畨瑁呰矾寰勩 CJuiWidget

灞炴ц缁

contentTemplate 灞炴
public string $contentTemplate;

鐢ㄦ潵浜х敓姣忎釜鏍囩鍐呭鐨勬ā鏉裤 鏍囪鈥渰content}鈥濆湪妯℃澘闈㈡澘鐨勫唴瀹瑰皢琚浛鎹紝 鍚屾椂鏍囪鈥渰id}鈥濇浛鎹负鏍囩ID.

headerTemplate 灞炴
public string $headerTemplate;

鎵浣跨敤鐨勬瘡涓潰鏉跨殑鏍囬浜х敓鐨勬ā鏉裤 鏍囪鈥渰title}鈥濇ā鏉垮皢琚浛鎹㈤潰鏉跨殑鏍囬锛 骞朵笖鏍囪鈥渰url}鈥濆皢琚浛鎹㈢敤鈥#TabID鈥濇垨Ajax璇锋眰鐨刄RL銆

tabs 灞炴
public array $tabs;

鏍囩鍒楄〃锛坱ab title=>tab content锛夈 闇瑕佹敞鎰忕殑鏄痶ab鐨勬爣棰樹笉浼氳HTML-encoded銆 tab鐨勫唴瀹瑰彲浠ユ槸涓涓瓧绗︿覆鎴栨暟缁勩 褰撳畠鏄竴涓暟缁勶紝瀹冨彲浠ュ湪浠ヤ笅涓ょ鏍煎紡涔嬩竴锛

array('id'=>'myTabID', 'content'=>'tab content')
array('id'=>'myTabID', 'ajax'=>URL)
鈥榠d鈥欑殑鍏冪礌鏄彲閫夌殑銆傜浜岀鏍煎紡鍏佽tab鐨勫唴瀹硅鍔ㄦ佸湴浠庢寚瀹氱殑URL閫氳繃AJAX鑾峰彇銆 璇RL鍙互鏄竴涓瓧绗︿覆鎴栦竴涓暟缁勩 濡傛灉涓涓暟缁勶紝灏嗗綊鍒颁竴涓娇鐢║RLCHtml::normalizeUrl.

tagName 灞炴
public string $tagName;

鎵鏈夐潰鏉跨殑瀹瑰櫒鍏冪礌鐨勫悕绉般傞粯璁や负鈥榙iv鈥欍

鏂规硶璇︾粏

registerCoreScripts() 鏂规硶
protected void registerCoreScripts()
婧愮爜锛 framework/zii/widgets/jui/CJuiTabs.php#129 (鏄剧ず)
protected function registerCoreScripts()
{
    
parent::registerCoreScripts();
    if(isset(
$this->options['cookie']))
        
Yii::app()->getClientScript()->registerCoreScript('cookie');
}

娉ㄥ唽鏍稿績鐨勮剼鏈枃浠躲 浣跨敤cookie閫夐」鏃舵鏂规硶閲嶅啓鐖舵柟娉曞疄鐜版敞鍐岀殑cookie鎻掍欢銆

run() 鏂规硶
public void run()
婧愮爜锛 framework/zii/widgets/jui/CJuiTabs.php#82 (鏄剧ず)
public function run()
{
    
$id=$this->getId();
    if (isset(
$this->htmlOptions['id']))
        
$id $this->htmlOptions['id'];
    else
        
$this->htmlOptions['id']=$id;

    echo 
CHtml::openTag($this->tagName,$this->htmlOptions)."\n";

    
$tabsOut "";
    
$contentOut "";
    
$tabCount 0;

    foreach(
$this->tabs as $title=>$content)
    {
        
$tabId = (is_array($content) && isset($content['id']))?$content['id']:$id.'_tab_'.$tabCount++;

        if (!
is_array($content))
        {
            
$tabsOut .= strtr($this->headerTemplate, array('{title}'=>$title'{url}'=>'#'.$tabId'{id}'=>'#' $tabId))."\n";
            
$contentOut .= strtr($this->contentTemplate, array('{content}'=>$content,'{id}'=>$tabId))."\n";
        }
        elseif (isset(
$content['ajax']))
        {
            
$tabsOut .= strtr($this->headerTemplate, array('{title}'=>$title'{url}'=>CHtml::normalizeUrl($content['ajax']), '{id}'=>'#' $tabId))."\n";
        }
        else
        {
            
$tabsOut .= strtr($this->headerTemplate, array('{title}'=>$title'{url}'=>'#'.$tabId'{id}'=>$tabId))."\n";
            if(isset(
$content['content']))
                
$contentOut .= strtr($this->contentTemplate, array('{content}'=>$content['content'],'{id}'=>$tabId))."\n";
        }
    }
    echo 
"<ul>\n" $tabsOut "</ul>\n";
    echo 
$contentOut;

    echo 
CHtml::closeTag($this->tagName)."\n";

    
$options=empty($this->options) ? '' CJavaScript::encode($this->options);
    
Yii::app()->getClientScript()->registerScript(__CLASS__.'#'.$id,"jQuery('#{$id}').tabs($options);");
}

杩愯杩欎釜閮ㄤ欢銆 杩欎釜鏂规硶娉ㄥ唽蹇呰鐨刯avascript骞舵覆鏌撶浉搴旂殑HTML浠g爜銆

Copyright © 2008-2011 by Yii Software LLC
All Rights Reserved.