Dotclear

Changeset 2097


Ignore:
Timestamp:
03/04/10 23:34:40 (14 years ago)
Author:
Oaz
Message:

Implemented tickets 413 (definition of field inside block) and 414 (WidgetTextIf?, WidgetTextLike?, WidgetTextMatch?, WidgetTextNotLike?)

Location:
plugins/templateWidget/trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • plugins/templateWidget/trunk/_public.php

    r932 r2097  
    3333 
    3434$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')); 
    3539$core->tpl->addBlock('WidgetCheckboxIf',array('templateWidgetBlocksAndValues','CheckboxIf')); 
    3640$core->tpl->addBlock('WidgetComboIf',array('templateWidgetBlocksAndValues','ComboIf')); 
     
    111115    return '<?php print html::escapeHTML($_ctx->widget->'.$attr['name'].'); ?>'.CRLF; 
    112116  } 
    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  
    114148  // Widget checkbox field 
    115149  public static function CheckboxIf($attr,$content) { 
  • plugins/templateWidget/trunk/default-templates/demo.widget.html

    r1815 r2097  
    44<div> 
    55<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> 
    615 
    716<tpl:WidgetDefineBlock name="DemoBlock"> 
    817{{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"}} 
    1019<tpl:WidgetComboIf name="choice" value="green"> 
    1120--This is green 
     
    1322</tpl:WidgetDefineBlock> 
    1423 
    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"> 
    1625<h3>CheckMe is checked !</h3> 
    1726{{tpl:WidgetUseBlock name="DemoBlock"}} 
     
    2130</tpl:WidgetCheckboxIf> 
    2231 
    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"> 
    2433<h3>UncheckMe is not checked!</h3> 
    2534{{tpl:WidgetUseBlock name="DemoBlock"}} 
  • plugins/templateWidget/trunk/inc/class.SettingsList.php

    r931 r2097  
    2121  private $items; 
    2222  private $namespace; 
     23  private $settingsNamespace; 
    2324  private $listKey; 
    2425  private $class; 
     
    3031    global $core; 
    3132    $this->namespace = $namespace; 
     33    $this->settingsNamespace = $core->blog->settings->addNamespace($namespace); 
    3234    $this->listKey = $listKey; 
    3335    $this->itemKey = $itemKey; 
    3436    $this->httpTypes = $httpTypes; 
    3537    $this->class = new ReflectionClass($class); 
    36     $core->blog->settings->setNameSpace($namespace); 
    37     if( $core->blog->settings->$listKey === null ) { 
     38    if( $this->settingsNamespace->$listKey === null ) { 
    3839      $this->items = array(); 
    3940    } else { 
    40       $this->items = @unserialize(base64_decode($core->blog->settings->$listKey)); 
     41      $this->items = @unserialize(base64_decode($this->settingsNamespace->$listKey)); 
    4142    } 
    4243  } 
    4344     
    4445  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 
    4847  } 
    4948  
  • plugins/templateWidget/trunk/inc/class.WidgetBuilder.php

    r932 r2097  
    4343 
    4444    $this->setPath( 
    45       $core->blog->themes_path.'/'.$core->blog->settings->theme.'/tpl', 
     45      $core->blog->themes_path.'/'.$core->blog->settings->system->theme.'/tpl', 
    4646      $core->blog->themes_path.'/default/tpl', 
    4747      path::real(dirname(__FILE__).'/../default-templates'), 
     
    4949    ); 
    5050           
    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; 
    5353 
    5454    $this->addBlock('WidgetName',array($this,'Name')); 
     
    6161 
    6262    $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')); 
    6367    $this->addBlock('WidgetCheckboxIf',array($this,'CheckboxIf')); 
    6468    $this->addBlock('WidgetComboIf',array($this,'ComboIf')); 
     
    8185  // Define a block to be reused 
    8286  public function DefineBlock($attr,$content) { 
    83     return ''; 
     87    return $content; 
    8488  } 
    8589 
     
    9195  // Test page type - useful to display a widget on home page only 
    9296  public function PageTypeIf($attr,$content) { 
    93     return ''; 
     97    return $content; 
    9498  } 
    9599 
    96100  public function Substring($attr,$content) { 
    97     return ''; 
     101    return $content; 
    98102  } 
    99103 
     
    127131  } 
    128132   
     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  
    129153  // Widget checkbox field 
    130154  public function CheckboxIf($attr,$content) { 
Note: See TracChangeset for help on using the changeset viewer.

Sites map