Skip to content

Commit

Permalink
change strncmp with strpos
Browse files Browse the repository at this point in the history
  • Loading branch information
mdomba committed Aug 7, 2012
1 parent df54c65 commit 524475f
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 39 deletions.
2 changes: 1 addition & 1 deletion framework/web/widgets/CAutoComplete.php
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ protected function getClientOptions()
}
foreach($functions as $func)
{
if(!($this->$func instanceof CJavaScriptExpression) && is_string($this->$func) && strncmp($this->$func,'js:',3))
if(!($this->$func instanceof CJavaScriptExpression) && is_string($this->$func) && strpos($this->$func,'js:')!==0)
$options[$func]=new CJavaScriptExpression($this->$func);
}

Expand Down
6 changes: 3 additions & 3 deletions framework/web/widgets/CStarRating.php
Original file line number Diff line number Diff line change
Expand Up @@ -193,21 +193,21 @@ protected function getClientOptions()
$options['readOnly']=true;
if($this->focus!==null)
{
if(!($this->focus instanceof CJavaScriptExpression) && strncmp($this->focus,'js:',3))
if(!($this->focus instanceof CJavaScriptExpression) && strpos($this->focus,'js:')!==0)
$options['focus']=new CJavaScriptExpression($this->focus);
else
$options['focus']=$this->focus;
}
if($this->blur!==null)
{
if(!($this->blur instanceof CJavaScriptExpression) && strncmp($this->blur,'js:',3))
if(!($this->blur instanceof CJavaScriptExpression) && strpos($this->blur,'js:')!==0)
$options['blur']=new CJavaScriptExpression($this->blur);
else
$options['blur']=$this->blur;
}
if($this->callback!==null)
{
if(!($this->callback instanceof CJavaScriptExpression) && strncmp($this->callback,'js:',3))
if(!($this->callback instanceof CJavaScriptExpression) && strpos($this->callback,'js:')!==0)
$options['callback']=new CJavaScriptExpression($this->callback);
else
$options['callback']=$this->callback;
Expand Down
30 changes: 11 additions & 19 deletions framework/zii/widgets/CListView.php
Original file line number Diff line number Diff line change
Expand Up @@ -162,14 +162,14 @@ class CListView extends CBaseListView
*/
public $itemsTagName='div';

/**
* @var boolean whether to leverage the {@link https://developer.mozilla.org/en/DOM/window.history DOM history object}. Set this property to true
* to persist state of list across page revisits. Note, there are two limitations for this feature:
* - this feature is only compatible with browsers that support HTML5.
* - expect unexpected functionality (e.g. multiple ajax calls) if there is more than one grid/list on a single page with enableHistory turned on.
* @since 1.1.11
*/
public $enableHistory=false;
/**
* @var boolean whether to leverage the {@link https://developer.mozilla.org/en/DOM/window.history DOM history object}. Set this property to true
* to persist state of list across page revisits. Note, there are two limitations for this feature:
* - this feature is only compatible with browsers that support HTML5.
* - expect unexpected functionality (e.g. multiple ajax calls) if there is more than one grid/list on a single page with enableHistory turned on.
* @since 1.1.11
*/
public $enableHistory=false;

/**
* Initializes the list view.
Expand Down Expand Up @@ -212,7 +212,7 @@ public function registerClientScript()
'pagerClass'=>$this->pagerCssClass,
'loadingClass'=>$this->loadingCssClass,
'sorterClass'=>$this->sorterCssClass,
'enableHistory'=>$this->enableHistory
'enableHistory'=>$this->enableHistory
);
if($this->ajaxUrl!==null)
$options['url']=CHtml::normalizeUrl($this->ajaxUrl);
Expand All @@ -222,32 +222,24 @@ public function registerClientScript()
{

if(!($this->beforeAjaxUpdate instanceof CJavaScriptExpression) && strpos($this->beforeAjaxUpdate,'js:')!==0)
{
$options['beforeAjaxUpdate']=new CJavaScriptExpression($this->beforeAjaxUpdate);
}
else
{
$options['beforeAjaxUpdate']=$this->beforeAjaxUpdate;
}
}
if($this->afterAjaxUpdate!==null)
{
if(!($this->afterAjaxUpdate instanceof CJavaScriptExpression) && strpos($this->afterAjaxUpdate,'js:')!==0)
{
$options['afterAjaxUpdate']=new CJavaScriptExpression($this->afterAjaxUpdate);
}
else
{
$options['afterAjaxUpdate']=$this->afterAjaxUpdate;
}
}

$options=CJavaScript::encode($options);
$cs=Yii::app()->getClientScript();
$cs->registerCoreScript('jquery');
$cs->registerCoreScript('bbq');
if($this->enableHistory)
$cs->registerCoreScript('history');
if($this->enableHistory)
$cs->registerCoreScript('history');
$cs->registerScriptFile($this->baseScriptUrl.'/jquery.yiilistview.js',CClientScript::POS_END);
$cs->registerScript(__CLASS__.'#'.$id,"jQuery('#$id').yiiListView($options);");
}
Expand Down
16 changes: 0 additions & 16 deletions framework/zii/widgets/grid/CGridView.php
Original file line number Diff line number Diff line change
Expand Up @@ -396,46 +396,30 @@ public function registerClientScript()
if($this->beforeAjaxUpdate!==null)
{
if((!$this->beforeAjaxUpdate instanceof CJavaScriptExpression) && strpos($this->beforeAjaxUpdate,'js:')!==0)
{
$options['beforeAjaxUpdate']=new CJavaScriptExpression($this->beforeAjaxUpdate);
}
else
{
$options['beforeAjaxUpdate']=$this->beforeAjaxUpdate;
}
}
if($this->afterAjaxUpdate!==null)
{
if((!$this->afterAjaxUpdate instanceof CJavaScriptExpression) && strpos($this->afterAjaxUpdate,'js:')!==0)
{
$options['afterAjaxUpdate']=new CJavaScriptExpression($this->afterAjaxUpdate);
}
else
{
$options['afterAjaxUpdate']=$this->afterAjaxUpdate;
}
}
if($this->ajaxUpdateError!==null)
{
if((!$this->ajaxUpdateError instanceof CJavaScriptExpression) && strpos($this->ajaxUpdateError,'js:')!==0)
{
$options['ajaxUpdateError']=new CJavaScriptExpression($this->ajaxUpdateError);
}
else
{
$options['ajaxUpdateError']=$this->ajaxUpdateError;
}
}
if($this->selectionChanged!==null)
{
if((!$this->ajaxUpdateError instanceof CJavaScriptExpression) && strpos($this->selectionChanged,'js:')!==0)
{
$options['selectionChanged']=new CJavaScriptExpression($this->selectionChanged);
}
else
{
$options['selectionChanged']=$this->selectionChanged;
}
}

$options=CJavaScript::encode($options);
Expand Down

0 comments on commit 524475f

Please sign in to comment.