Changeset 2097
- Timestamp:
- 03/04/10 23:34:40 (14 years ago)
- Location:
- plugins/templateWidget/trunk
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
plugins/templateWidget/trunk/_public.php
r932 r2097 33 33 34 34 $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')); 35 39 $core->tpl->addBlock('WidgetCheckboxIf',array('templateWidgetBlocksAndValues','CheckboxIf')); 36 40 $core->tpl->addBlock('WidgetComboIf',array('templateWidgetBlocksAndValues','ComboIf')); … … 111 115 return '<?php print html::escapeHTML($_ctx->widget->'.$attr['name'].'); ?>'.CRLF; 112 116 } 113 117 118 // Widget text field : testing text value 119 public static function TextIf($attr,$content) { 120 return 121 '<?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 pattern 127 public static function TextLike($attr,$content) { 128 return 129 '<?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 135 // Widget text field : displaying part of matched pattern 136 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 pattern 141 public static function TextNotLike($attr,$content) { 142 return 143 '<?php if( !preg_match( "'.addslashes($attr['pattern']).'", $_ctx->widget->'.$attr['name'].' ) ) : ?>'.CRLF. 144 $content. 145 '<?php endif; ?>'.CRLF; 146 } 147 114 148 // Widget checkbox field 115 149 public static function CheckboxIf($attr,$content) { -
plugins/templateWidget/trunk/default-templates/demo.widget.html
r1815 r2097 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> 6 15 7 16 <tpl:WidgetDefineBlock name="DemoBlock"> 8 17 {{tpl:WidgetText name="desc" title="Description:" default="Blah blah..." type="textarea" order="5"}} 9 {{tpl:WidgetCombo name="choice" title="Choose:" default="blue" options="red:green:blue" order=" 4"}}18 {{tpl:WidgetCombo name="choice" title="Choose:" default="blue" options="red:green:blue" order="6"}} 10 19 <tpl:WidgetComboIf name="choice" value="green"> 11 20 --This is green … … 13 22 </tpl:WidgetDefineBlock> 14 23 15 <tpl:WidgetCheckboxIf name="checkme" value="1" title="Check me" default="0" order=" 2">24 <tpl:WidgetCheckboxIf name="checkme" value="1" title="Check me" default="0" order="3"> 16 25 <h3>CheckMe is checked !</h3> 17 26 {{tpl:WidgetUseBlock name="DemoBlock"}} … … 21 30 </tpl:WidgetCheckboxIf> 22 31 23 <tpl:WidgetCheckboxIf name="uncheckme" value="0" title="Uncheck me" default="1" order=" 3">32 <tpl:WidgetCheckboxIf name="uncheckme" value="0" title="Uncheck me" default="1" order="4"> 24 33 <h3>UncheckMe is not checked!</h3> 25 34 {{tpl:WidgetUseBlock name="DemoBlock"}} -
plugins/templateWidget/trunk/inc/class.SettingsList.php
r931 r2097 21 21 private $items; 22 22 private $namespace; 23 private $settingsNamespace; 23 24 private $listKey; 24 25 private $class; … … 30 31 global $core; 31 32 $this->namespace = $namespace; 33 $this->settingsNamespace = $core->blog->settings->addNamespace($namespace); 32 34 $this->listKey = $listKey; 33 35 $this->itemKey = $itemKey; 34 36 $this->httpTypes = $httpTypes; 35 37 $this->class = new ReflectionClass($class); 36 $core->blog->settings->setNameSpace($namespace); 37 if( $core->blog->settings->$listKey === null ) { 38 if( $this->settingsNamespace->$listKey === null ) { 38 39 $this->items = array(); 39 40 } else { 40 $this->items = @unserialize(base64_decode($ core->blog->settings->$listKey));41 $this->items = @unserialize(base64_decode($this->settingsNamespace->$listKey)); 41 42 } 42 43 } 43 44 44 45 public function Store() { 45 global $core; 46 $core->blog->settings->setNameSpace($this->namespace); 47 $core->blog->settings->put($this->listKey,base64_encode(serialize($this->items))); // put in blog local settings 46 $this->settingsNamespace->put($this->listKey,base64_encode(serialize($this->items))); // put in blog local settings 48 47 } 49 48 -
plugins/templateWidget/trunk/inc/class.WidgetBuilder.php
r932 r2097 43 43 44 44 $this->setPath( 45 $core->blog->themes_path.'/'.$core->blog->settings-> theme.'/tpl',45 $core->blog->themes_path.'/'.$core->blog->settings->system->theme.'/tpl', 46 46 $core->blog->themes_path.'/default/tpl', 47 47 path::real(dirname(__FILE__).'/../default-templates'), … … 49 49 ); 50 50 51 $this->remove_php = !$core->blog->settings-> tpl_allow_php;52 $this->use_cache = $core->blog->settings-> tpl_use_cache;51 $this->remove_php = !$core->blog->settings->system->tpl_allow_php; 52 $this->use_cache = $core->blog->settings->system->tpl_use_cache; 53 53 54 54 $this->addBlock('WidgetName',array($this,'Name')); … … 61 61 62 62 $this->addValue('WidgetText',array($this,'Text')); 63 $this->addBlock('WidgetTextIf',array($this,'TextIf')); 64 $this->addBlock('WidgetTextLike',array($this,'TextLike')); 65 $this->addValue('WidgetTextMatch',array($this,'TextMatch')); 66 $this->addBlock('WidgetTextNotLike',array($this,'TextNotLike')); 63 67 $this->addBlock('WidgetCheckboxIf',array($this,'CheckboxIf')); 64 68 $this->addBlock('WidgetComboIf',array($this,'ComboIf')); … … 81 85 // Define a block to be reused 82 86 public function DefineBlock($attr,$content) { 83 return '';87 return $content; 84 88 } 85 89 … … 91 95 // Test page type - useful to display a widget on home page only 92 96 public function PageTypeIf($attr,$content) { 93 return '';97 return $content; 94 98 } 95 99 96 100 public function Substring($attr,$content) { 97 return '';101 return $content; 98 102 } 99 103 … … 127 131 } 128 132 133 // Widget text field 134 public function TextIf($attr,$content) { 135 return $this->Text($attr).$content; 136 } 137 138 // Widget text field 139 public function TextLike($attr,$content) { 140 return $this->Text($attr).$content; 141 } 142 143 // Widget text field 144 public function TextMatch($attr) { 145 return ''; 146 } 147 148 // Widget text field 149 public function TextNotLike($attr,$content) { 150 return $this->Text($attr).$content; 151 } 152 129 153 // Widget checkbox field 130 154 public function CheckboxIf($attr,$content) {
Note: See TracChangeset
for help on using the changeset viewer.