Changeset 3147
- Timestamp:
- 08/01/13 01:30:24 (10 years ago)
- Location:
- plugins/templateWidget/trunk
- Files:
-
- 4 added
- 2 deleted
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
plugins/templateWidget/trunk/_admin.php
r931 r3147 24 24 if (!defined('DC_CONTEXT_ADMIN')) { return; } 25 25 26 require_once(dirname(__FILE__).'/ inc/class.WidgetAdmin.php');26 require_once(dirname(__FILE__).'/WidgetAdmin.php'); 27 27 $core->addBehavior('initWidgets',array('templateWidgetAdmin','InitWidgets')); 28 28 -
plugins/templateWidget/trunk/_define.php
r931 r3147 28 28 /* Description*/ "Define widgets using template file only", 29 29 /* Author */ "Olivier Azeau", 30 /* Version */ '1.4 a',30 /* Version */ '1.4.2', 31 31 /* Permissions */ null 32 32 ); -
plugins/templateWidget/trunk/_public.php
r2097 r3147 24 24 if (!defined('DC_RC_PATH')) { return; } 25 25 26 require_once(dirname(__FILE__).'/WidgetAdmin.php'); 27 $core->addBehavior('initWidgets',array('templateWidgetAdmin','InitWidgets')); 28 26 29 $core->tpl->addBlock('WidgetName',array('templateWidgetBlocksAndValues','Name')); 27 30 $core->tpl->addBlock('WidgetDescription',array('templateWidgetBlocksAndValues','Description')); … … 33 36 34 37 $core->tpl->addValue('WidgetText',array('templateWidgetBlocksAndValues','Text')); 35 $core->tpl->addBlock('WidgetTextIf',array('templateWidgetBlocksAndValues','TextIf'));36 $core->tpl->addBlock('WidgetTextLike',array('templateWidgetBlocksAndValues','TextLike'));37 $core->tpl->addValue('WidgetTextMatch',array('templateWidgetBlocksAndValues','TextMatch'));38 $core->tpl->addBlock('WidgetTextNotLike',array('templateWidgetBlocksAndValues','TextNotLike'));39 38 $core->tpl->addBlock('WidgetCheckboxIf',array('templateWidgetBlocksAndValues','CheckboxIf')); 40 39 $core->tpl->addBlock('WidgetComboIf',array('templateWidgetBlocksAndValues','ComboIf')); … … 52 51 { 53 52 // widget display only consists in displaying the corresponding template file 54 public static function WidgetCore( &$widget)53 public static function WidgetCore($widget) 55 54 { 56 55 global $core, $_ctx; 57 56 $_ctx->widget = $widget; 58 $core->tpl->setPath( 59 $core->tpl->getPath(), 60 path::real(dirname(__FILE__).'/default-templates') 61 ); 62 $core->callBehavior('publicTemplateWidgetBeforeLoad',$core->tpl,$widget); 57 $core->tpl->setPath(array_merge($core->tpl->getPath(),array(dirname(__FILE__).'/default-templates'))); 63 58 $code = $core->tpl->getData($widget->id().'.widget.html'); 64 59 $_ctx->widget = null; … … 115 110 return '<?php print html::escapeHTML($_ctx->widget->'.$attr['name'].'); ?>'.CRLF; 116 111 } 117 118 // Widget text field : testing text value119 public static function TextIf($attr,$content) {120 return121 '<?php if ($_ctx->widget->'.$attr['name'].' == "'.addslashes($attr['value']).'") : ?>'.CRLF.122 $content.123 '<?php endif; ?>'.CRLF;124 }125 126 // Widget text field : matching text value against pattern127 public static function TextLike($attr,$content) {128 return129 '<?php if( preg_match( "'.addslashes($attr['pattern']).'", $_ctx->widget->'.$attr['name'].', $widgetTextMatches ) ) : ?>'.CRLF.130 '<?php $_ctx->widgetTextMatches=$widgetTextMatches; ?>'.CRLF.131 $content.132 '<?php endif; ?>'.CRLF;133 }134 112 135 // Widget text field : displaying part of matched pattern136 public static function TextMatch($attr) {137 return '<?php print html::escapeHTML($_ctx->widgetTextMatches['.$attr['index'].']); ?>'.CRLF;138 }139 140 // Widget text field : matching text value against pattern141 public static function TextNotLike($attr,$content) {142 return143 '<?php if( !preg_match( "'.addslashes($attr['pattern']).'", $_ctx->widget->'.$attr['name'].' ) ) : ?>'.CRLF.144 $content.145 '<?php endif; ?>'.CRLF;146 }147 148 113 // Widget checkbox field 149 114 public static function CheckboxIf($attr,$content) { … … 181 146 class templateWidgetBehaviors 182 147 { 183 public static function loadVisitorCookie( &$core)148 public static function loadVisitorCookie($core) 184 149 { 185 150 global $_ctx; … … 188 153 if (empty($_COOKIE['comment_info'])) 189 154 return; 190 $visitorInfos = split("\n",$_COOKIE['comment_info']);155 $visitorInfos = explode("\n",$_COOKIE['comment_info']); 191 156 $_ctx->comment_preview = new ArrayObject(); 192 157 $_ctx->comment_preview['name'] = @$_ctx->comment_preview['name'] ? $_ctx->comment_preview['name'] : $visitorInfos[0]; … … 200 165 } 201 166 202 203 167 ?> -
plugins/templateWidget/trunk/default-templates/demo.widget.html
r2097 r3147 4 4 <div> 5 5 <h2>{{tpl:WidgetText name="title" title="Title:" default="Default Title" order="1"}}</h2> 6 <tpl:WidgetTextLike name="subtitle" title="Subtitle:" order="2" pattern="/---+/">7 <hr/>8 </tpl:WidgetTextLike>9 <tpl:WidgetTextLike name="subtitle" pattern="/bold:(.+)/">10 <b>{{tpl:WidgetTextMatch index="1"}}</b>11 </tpl:WidgetTextLike>12 <tpl:WidgetTextNotLike name="subtitle" pattern="/(---+|bold:(.+))/">13 {{tpl:WidgetText name="subtitle"}}14 </tpl:WidgetTextNotLike>15 6 16 7 <tpl:WidgetDefineBlock name="DemoBlock"> 17 8 {{tpl:WidgetText name="desc" title="Description:" default="Blah blah..." type="textarea" order="5"}} 18 {{tpl:WidgetCombo name="choice" title="Choose:" default="blue" options="red:green:blue" order=" 6"}}9 {{tpl:WidgetCombo name="choice" title="Choose:" default="blue" options="red:green:blue" order="4"}} 19 10 <tpl:WidgetComboIf name="choice" value="green"> 20 11 --This is green … … 22 13 </tpl:WidgetDefineBlock> 23 14 24 <tpl:WidgetCheckboxIf name="checkme" value="1" title="Check me" default="0" order=" 3">15 <tpl:WidgetCheckboxIf name="checkme" value="1" title="Check me" default="0" order="2"> 25 16 <h3>CheckMe is checked !</h3> 26 17 {{tpl:WidgetUseBlock name="DemoBlock"}} 27 18 </tpl:WidgetCheckboxIf> 28 19 <tpl:WidgetCheckboxIf name="checkme" value="0"> 29 <h3>CheckMe is not checked ! Please Check it!</h3>20 <h3>CheckMe is not checked ! Please Check it !</h3> 30 21 </tpl:WidgetCheckboxIf> 31 22 32 <tpl:WidgetCheckboxIf name="uncheckme" value="0" title="Uncheck me" default="1" order=" 4">33 <h3>UncheckMe is not checked !</h3>23 <tpl:WidgetCheckboxIf name="uncheckme" value="0" title="Uncheck me" default="1" order="3"> 24 <h3>UncheckMe is not checked !</h3> 34 25 {{tpl:WidgetUseBlock name="DemoBlock"}} 35 26 </tpl:WidgetCheckboxIf> 36 27 <tpl:WidgetCheckboxIf name="uncheckme" value="1"> 37 <h3>UncheckMe is checked ! Please Uncheck it!</h3>28 <h3>UncheckMe is checked ! Please Uncheck it !</h3> 38 29 </tpl:WidgetCheckboxIf> 39 30 -
plugins/templateWidget/trunk/index.php
r931 r3147 26 26 dcPage::check('usage,contentadmin'); 27 27 28 require_once(dirname(__FILE__).'/ inc/class.Settings.php');28 require_once(dirname(__FILE__).'/Settings.php'); 29 29 30 30 try
Note: See TracChangeset
for help on using the changeset viewer.