repo
stringlengths
6
63
path
stringlengths
5
140
func_name
stringlengths
3
151
original_string
stringlengths
84
13k
language
stringclasses
1 value
code
stringlengths
84
13k
code_tokens
list
docstring
stringlengths
3
47.2k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
91
247
partition
stringclasses
1 value
yiisoft/yii
framework/zii/widgets/grid/CLinkColumn.php
CLinkColumn.getDataCellContent
public function getDataCellContent($row) { $data=$this->grid->dataProvider->data[$row]; if($this->urlExpression!==null) $url=$this->evaluateExpression($this->urlExpression,array('data'=>$data,'row'=>$row)); else $url=$this->url; if($this->labelExpression!==null) $label=$this->evaluateExpression($this->labelExpression,array('data'=>$data,'row'=>$row)); else $label=$this->label; $options=$this->linkHtmlOptions; if(is_string($this->imageUrl)) return CHtml::link(CHtml::image($this->imageUrl,$label),$url,$options); else return CHtml::link($label,$url,$options); }
php
public function getDataCellContent($row) { $data=$this->grid->dataProvider->data[$row]; if($this->urlExpression!==null) $url=$this->evaluateExpression($this->urlExpression,array('data'=>$data,'row'=>$row)); else $url=$this->url; if($this->labelExpression!==null) $label=$this->evaluateExpression($this->labelExpression,array('data'=>$data,'row'=>$row)); else $label=$this->label; $options=$this->linkHtmlOptions; if(is_string($this->imageUrl)) return CHtml::link(CHtml::image($this->imageUrl,$label),$url,$options); else return CHtml::link($label,$url,$options); }
[ "public", "function", "getDataCellContent", "(", "$", "row", ")", "{", "$", "data", "=", "$", "this", "->", "grid", "->", "dataProvider", "->", "data", "[", "$", "row", "]", ";", "if", "(", "$", "this", "->", "urlExpression", "!==", "null", ")", "$", "url", "=", "$", "this", "->", "evaluateExpression", "(", "$", "this", "->", "urlExpression", ",", "array", "(", "'data'", "=>", "$", "data", ",", "'row'", "=>", "$", "row", ")", ")", ";", "else", "$", "url", "=", "$", "this", "->", "url", ";", "if", "(", "$", "this", "->", "labelExpression", "!==", "null", ")", "$", "label", "=", "$", "this", "->", "evaluateExpression", "(", "$", "this", "->", "labelExpression", ",", "array", "(", "'data'", "=>", "$", "data", ",", "'row'", "=>", "$", "row", ")", ")", ";", "else", "$", "label", "=", "$", "this", "->", "label", ";", "$", "options", "=", "$", "this", "->", "linkHtmlOptions", ";", "if", "(", "is_string", "(", "$", "this", "->", "imageUrl", ")", ")", "return", "CHtml", "::", "link", "(", "CHtml", "::", "image", "(", "$", "this", "->", "imageUrl", ",", "$", "label", ")", ",", "$", "url", ",", "$", "options", ")", ";", "else", "return", "CHtml", "::", "link", "(", "$", "label", ",", "$", "url", ",", "$", "options", ")", ";", "}" ]
Returns the data cell content. This method renders a hyperlink in the data cell. @param integer $row the row number (zero-based) @return string the data cell content. @since 1.1.16
[ "Returns", "the", "data", "cell", "content", ".", "This", "method", "renders", "a", "hyperlink", "in", "the", "data", "cell", "." ]
af3cbce71db83c4476c8a4289517b2984c740f31
https://github.com/yiisoft/yii/blob/af3cbce71db83c4476c8a4289517b2984c740f31/framework/zii/widgets/grid/CLinkColumn.php#L96-L112
train
yiisoft/yii
framework/zii/widgets/CBaseListView.php
CBaseListView.renderKeys
public function renderKeys() { echo CHtml::openTag('div',array( 'class'=>'keys', 'style'=>'display:none', 'title'=>Yii::app()->getRequest()->getUrl(), )); foreach($this->dataProvider->getKeys() as $key) echo "<span>".CHtml::encode($key)."</span>"; echo "</div>\n"; }
php
public function renderKeys() { echo CHtml::openTag('div',array( 'class'=>'keys', 'style'=>'display:none', 'title'=>Yii::app()->getRequest()->getUrl(), )); foreach($this->dataProvider->getKeys() as $key) echo "<span>".CHtml::encode($key)."</span>"; echo "</div>\n"; }
[ "public", "function", "renderKeys", "(", ")", "{", "echo", "CHtml", "::", "openTag", "(", "'div'", ",", "array", "(", "'class'", "=>", "'keys'", ",", "'style'", "=>", "'display:none'", ",", "'title'", "=>", "Yii", "::", "app", "(", ")", "->", "getRequest", "(", ")", "->", "getUrl", "(", ")", ",", ")", ")", ";", "foreach", "(", "$", "this", "->", "dataProvider", "->", "getKeys", "(", ")", "as", "$", "key", ")", "echo", "\"<span>\"", ".", "CHtml", "::", "encode", "(", "$", "key", ")", ".", "\"</span>\"", ";", "echo", "\"</div>\\n\"", ";", "}" ]
Renders the key values of the data in a hidden tag.
[ "Renders", "the", "key", "values", "of", "the", "data", "in", "a", "hidden", "tag", "." ]
af3cbce71db83c4476c8a4289517b2984c740f31
https://github.com/yiisoft/yii/blob/af3cbce71db83c4476c8a4289517b2984c740f31/framework/zii/widgets/CBaseListView.php#L202-L212
train
yiisoft/yii
framework/zii/widgets/CBaseListView.php
CBaseListView.renderSummary
public function renderSummary() { if(($count=$this->dataProvider->getItemCount())<=0) return; echo CHtml::openTag($this->summaryTagName, array('class'=>$this->summaryCssClass)); if($this->enablePagination) { $pagination=$this->dataProvider->getPagination(); $total=$this->dataProvider->getTotalItemCount(); $start=$pagination->currentPage*$pagination->pageSize+1; $end=$start+$count-1; if($end>$total) { $end=$total; $start=$end-$count+1; } if(($summaryText=$this->summaryText)===null) $summaryText=Yii::t('zii','Displaying {start}-{end} of 1 result.|Displaying {start}-{end} of {count} results.',$total); echo strtr($summaryText,array( '{start}'=>$start, '{end}'=>$end, '{count}'=>$total, '{page}'=>$pagination->currentPage+1, '{pages}'=>$pagination->pageCount, )); } else { if(($summaryText=$this->summaryText)===null) $summaryText=Yii::t('zii','Total 1 result.|Total {count} results.',$count); echo strtr($summaryText,array( '{count}'=>$count, '{start}'=>1, '{end}'=>$count, '{page}'=>1, '{pages}'=>1, )); } echo CHtml::closeTag($this->summaryTagName); }
php
public function renderSummary() { if(($count=$this->dataProvider->getItemCount())<=0) return; echo CHtml::openTag($this->summaryTagName, array('class'=>$this->summaryCssClass)); if($this->enablePagination) { $pagination=$this->dataProvider->getPagination(); $total=$this->dataProvider->getTotalItemCount(); $start=$pagination->currentPage*$pagination->pageSize+1; $end=$start+$count-1; if($end>$total) { $end=$total; $start=$end-$count+1; } if(($summaryText=$this->summaryText)===null) $summaryText=Yii::t('zii','Displaying {start}-{end} of 1 result.|Displaying {start}-{end} of {count} results.',$total); echo strtr($summaryText,array( '{start}'=>$start, '{end}'=>$end, '{count}'=>$total, '{page}'=>$pagination->currentPage+1, '{pages}'=>$pagination->pageCount, )); } else { if(($summaryText=$this->summaryText)===null) $summaryText=Yii::t('zii','Total 1 result.|Total {count} results.',$count); echo strtr($summaryText,array( '{count}'=>$count, '{start}'=>1, '{end}'=>$count, '{page}'=>1, '{pages}'=>1, )); } echo CHtml::closeTag($this->summaryTagName); }
[ "public", "function", "renderSummary", "(", ")", "{", "if", "(", "(", "$", "count", "=", "$", "this", "->", "dataProvider", "->", "getItemCount", "(", ")", ")", "<=", "0", ")", "return", ";", "echo", "CHtml", "::", "openTag", "(", "$", "this", "->", "summaryTagName", ",", "array", "(", "'class'", "=>", "$", "this", "->", "summaryCssClass", ")", ")", ";", "if", "(", "$", "this", "->", "enablePagination", ")", "{", "$", "pagination", "=", "$", "this", "->", "dataProvider", "->", "getPagination", "(", ")", ";", "$", "total", "=", "$", "this", "->", "dataProvider", "->", "getTotalItemCount", "(", ")", ";", "$", "start", "=", "$", "pagination", "->", "currentPage", "*", "$", "pagination", "->", "pageSize", "+", "1", ";", "$", "end", "=", "$", "start", "+", "$", "count", "-", "1", ";", "if", "(", "$", "end", ">", "$", "total", ")", "{", "$", "end", "=", "$", "total", ";", "$", "start", "=", "$", "end", "-", "$", "count", "+", "1", ";", "}", "if", "(", "(", "$", "summaryText", "=", "$", "this", "->", "summaryText", ")", "===", "null", ")", "$", "summaryText", "=", "Yii", "::", "t", "(", "'zii'", ",", "'Displaying {start}-{end} of 1 result.|Displaying {start}-{end} of {count} results.'", ",", "$", "total", ")", ";", "echo", "strtr", "(", "$", "summaryText", ",", "array", "(", "'{start}'", "=>", "$", "start", ",", "'{end}'", "=>", "$", "end", ",", "'{count}'", "=>", "$", "total", ",", "'{page}'", "=>", "$", "pagination", "->", "currentPage", "+", "1", ",", "'{pages}'", "=>", "$", "pagination", "->", "pageCount", ",", ")", ")", ";", "}", "else", "{", "if", "(", "(", "$", "summaryText", "=", "$", "this", "->", "summaryText", ")", "===", "null", ")", "$", "summaryText", "=", "Yii", "::", "t", "(", "'zii'", ",", "'Total 1 result.|Total {count} results.'", ",", "$", "count", ")", ";", "echo", "strtr", "(", "$", "summaryText", ",", "array", "(", "'{count}'", "=>", "$", "count", ",", "'{start}'", "=>", "1", ",", "'{end}'", "=>", "$", "count", ",", "'{page}'", "=>", "1", ",", "'{pages}'", "=>", "1", ",", ")", ")", ";", "}", "echo", "CHtml", "::", "closeTag", "(", "$", "this", "->", "summaryTagName", ")", ";", "}" ]
Renders the summary text.
[ "Renders", "the", "summary", "text", "." ]
af3cbce71db83c4476c8a4289517b2984c740f31
https://github.com/yiisoft/yii/blob/af3cbce71db83c4476c8a4289517b2984c740f31/framework/zii/widgets/CBaseListView.php#L217-L257
train
yiisoft/yii
framework/web/widgets/CHtmlPurifier.php
CHtmlPurifier.purify
public function purify($content) { if(is_array($content)) $content=array_map(array($this,'purify'),$content); else $content=$this->getPurifier()->purify($content); return $content; }
php
public function purify($content) { if(is_array($content)) $content=array_map(array($this,'purify'),$content); else $content=$this->getPurifier()->purify($content); return $content; }
[ "public", "function", "purify", "(", "$", "content", ")", "{", "if", "(", "is_array", "(", "$", "content", ")", ")", "$", "content", "=", "array_map", "(", "array", "(", "$", "this", ",", "'purify'", ")", ",", "$", "content", ")", ";", "else", "$", "content", "=", "$", "this", "->", "getPurifier", "(", ")", "->", "purify", "(", "$", "content", ")", ";", "return", "$", "content", ";", "}" ]
Purifies the HTML content by removing malicious code. @param mixed $content the content to be purified. @return mixed the purified content
[ "Purifies", "the", "HTML", "content", "by", "removing", "malicious", "code", "." ]
af3cbce71db83c4476c8a4289517b2984c740f31
https://github.com/yiisoft/yii/blob/af3cbce71db83c4476c8a4289517b2984c740f31/framework/web/widgets/CHtmlPurifier.php#L79-L86
train
yiisoft/yii
framework/web/widgets/CHtmlPurifier.php
CHtmlPurifier.createNewHtmlPurifierInstance
protected function createNewHtmlPurifierInstance() { $this->_purifier=new HTMLPurifier($this->getOptions()); $this->_purifier->config->set('Cache.SerializerPath',Yii::app()->getRuntimePath()); return $this->_purifier; }
php
protected function createNewHtmlPurifierInstance() { $this->_purifier=new HTMLPurifier($this->getOptions()); $this->_purifier->config->set('Cache.SerializerPath',Yii::app()->getRuntimePath()); return $this->_purifier; }
[ "protected", "function", "createNewHtmlPurifierInstance", "(", ")", "{", "$", "this", "->", "_purifier", "=", "new", "HTMLPurifier", "(", "$", "this", "->", "getOptions", "(", ")", ")", ";", "$", "this", "->", "_purifier", "->", "config", "->", "set", "(", "'Cache.SerializerPath'", ",", "Yii", "::", "app", "(", ")", "->", "getRuntimePath", "(", ")", ")", ";", "return", "$", "this", "->", "_purifier", ";", "}" ]
Create a new HTML Purifier instance. @return HTMLPurifier
[ "Create", "a", "new", "HTML", "Purifier", "instance", "." ]
af3cbce71db83c4476c8a4289517b2984c740f31
https://github.com/yiisoft/yii/blob/af3cbce71db83c4476c8a4289517b2984c740f31/framework/web/widgets/CHtmlPurifier.php#L124-L129
train
yiisoft/yii
framework/web/CUploadedFile.php
CUploadedFile.getInstancesByName
public static function getInstancesByName($name) { if(null===self::$_files) self::prefetchFiles(); $len=strlen($name); $results=array(); foreach(array_keys(self::$_files) as $key) if(0===strncmp($key, $name.'[', $len+1) && self::$_files[$key]->getError()!=UPLOAD_ERR_NO_FILE) $results[] = self::$_files[$key]; return $results; }
php
public static function getInstancesByName($name) { if(null===self::$_files) self::prefetchFiles(); $len=strlen($name); $results=array(); foreach(array_keys(self::$_files) as $key) if(0===strncmp($key, $name.'[', $len+1) && self::$_files[$key]->getError()!=UPLOAD_ERR_NO_FILE) $results[] = self::$_files[$key]; return $results; }
[ "public", "static", "function", "getInstancesByName", "(", "$", "name", ")", "{", "if", "(", "null", "===", "self", "::", "$", "_files", ")", "self", "::", "prefetchFiles", "(", ")", ";", "$", "len", "=", "strlen", "(", "$", "name", ")", ";", "$", "results", "=", "array", "(", ")", ";", "foreach", "(", "array_keys", "(", "self", "::", "$", "_files", ")", "as", "$", "key", ")", "if", "(", "0", "===", "strncmp", "(", "$", "key", ",", "$", "name", ".", "'['", ",", "$", "len", "+", "1", ")", "&&", "self", "::", "$", "_files", "[", "$", "key", "]", "->", "getError", "(", ")", "!=", "UPLOAD_ERR_NO_FILE", ")", "$", "results", "[", "]", "=", "self", "::", "$", "_files", "[", "$", "key", "]", ";", "return", "$", "results", ";", "}" ]
Returns an array of instances starting with specified array name. If multiple files were uploaded and saved as 'Files[0]', 'Files[1]', 'Files[n]'..., you can have them all by passing 'Files' as array name. @param string $name the name of the array of files @return CUploadedFile[] the array of CUploadedFile objects. Empty array is returned if no adequate upload was found. Please note that this array will contain all files from all subarrays regardless how deeply nested they are.
[ "Returns", "an", "array", "of", "instances", "starting", "with", "specified", "array", "name", "." ]
af3cbce71db83c4476c8a4289517b2984c740f31
https://github.com/yiisoft/yii/blob/af3cbce71db83c4476c8a4289517b2984c740f31/framework/web/CUploadedFile.php#L99-L110
train
yiisoft/yii
framework/cli/commands/WebAppCommand.php
WebAppCommand.setPermissions
protected function setPermissions($targetDir) { @chmod($targetDir.'/assets',0777); @chmod($targetDir.'/protected/runtime',0777); @chmod($targetDir.'/protected/data',0777); @chmod($targetDir.'/protected/data/testdrive.db',0777); @chmod($targetDir.'/protected/yiic',0755); }
php
protected function setPermissions($targetDir) { @chmod($targetDir.'/assets',0777); @chmod($targetDir.'/protected/runtime',0777); @chmod($targetDir.'/protected/data',0777); @chmod($targetDir.'/protected/data/testdrive.db',0777); @chmod($targetDir.'/protected/yiic',0755); }
[ "protected", "function", "setPermissions", "(", "$", "targetDir", ")", "{", "@", "chmod", "(", "$", "targetDir", ".", "'/assets'", ",", "0777", ")", ";", "@", "chmod", "(", "$", "targetDir", ".", "'/protected/runtime'", ",", "0777", ")", ";", "@", "chmod", "(", "$", "targetDir", ".", "'/protected/data'", ",", "0777", ")", ";", "@", "chmod", "(", "$", "targetDir", ".", "'/protected/data/testdrive.db'", ",", "0777", ")", ";", "@", "chmod", "(", "$", "targetDir", ".", "'/protected/yiic'", ",", "0755", ")", ";", "}" ]
Adjusts created application file and directory permissions @param string $targetDir path to created application
[ "Adjusts", "created", "application", "file", "and", "directory", "permissions" ]
af3cbce71db83c4476c8a4289517b2984c740f31
https://github.com/yiisoft/yii/blob/af3cbce71db83c4476c8a4289517b2984c740f31/framework/cli/commands/WebAppCommand.php#L105-L112
train
yiisoft/yii
framework/cli/commands/WebAppCommand.php
WebAppCommand.addFileModificationCallbacks
protected function addFileModificationCallbacks(&$fileList) { $fileList['index.php']['callback']=array($this,'generateIndex'); $fileList['index-test.php']['callback']=array($this,'generateIndex'); $fileList['protected/tests/bootstrap.php']['callback']=array($this,'generateTestBoostrap'); $fileList['protected/yiic.php']['callback']=array($this,'generateYiic'); }
php
protected function addFileModificationCallbacks(&$fileList) { $fileList['index.php']['callback']=array($this,'generateIndex'); $fileList['index-test.php']['callback']=array($this,'generateIndex'); $fileList['protected/tests/bootstrap.php']['callback']=array($this,'generateTestBoostrap'); $fileList['protected/yiic.php']['callback']=array($this,'generateYiic'); }
[ "protected", "function", "addFileModificationCallbacks", "(", "&", "$", "fileList", ")", "{", "$", "fileList", "[", "'index.php'", "]", "[", "'callback'", "]", "=", "array", "(", "$", "this", ",", "'generateIndex'", ")", ";", "$", "fileList", "[", "'index-test.php'", "]", "[", "'callback'", "]", "=", "array", "(", "$", "this", ",", "'generateIndex'", ")", ";", "$", "fileList", "[", "'protected/tests/bootstrap.php'", "]", "[", "'callback'", "]", "=", "array", "(", "$", "this", ",", "'generateTestBoostrap'", ")", ";", "$", "fileList", "[", "'protected/yiic.php'", "]", "[", "'callback'", "]", "=", "array", "(", "$", "this", ",", "'generateYiic'", ")", ";", "}" ]
Adds callbacks that will modify source files @param array $fileList
[ "Adds", "callbacks", "that", "will", "modify", "source", "files" ]
af3cbce71db83c4476c8a4289517b2984c740f31
https://github.com/yiisoft/yii/blob/af3cbce71db83c4476c8a4289517b2984c740f31/framework/cli/commands/WebAppCommand.php#L127-L133
train
yiisoft/yii
framework/cli/commands/WebAppCommand.php
WebAppCommand.generateIndex
public function generateIndex($source,$params) { $content=file_get_contents($source); $yii=realpath(dirname(__FILE__).'/../../yii.php'); $yii=$this->getRelativePath($yii,$this->_rootPath.DIRECTORY_SEPARATOR.'index.php'); $yii=str_replace('\\','\\\\',$yii); return preg_replace('/\$yii\s*=(.*?);/',"\$yii=$yii;",$content); }
php
public function generateIndex($source,$params) { $content=file_get_contents($source); $yii=realpath(dirname(__FILE__).'/../../yii.php'); $yii=$this->getRelativePath($yii,$this->_rootPath.DIRECTORY_SEPARATOR.'index.php'); $yii=str_replace('\\','\\\\',$yii); return preg_replace('/\$yii\s*=(.*?);/',"\$yii=$yii;",$content); }
[ "public", "function", "generateIndex", "(", "$", "source", ",", "$", "params", ")", "{", "$", "content", "=", "file_get_contents", "(", "$", "source", ")", ";", "$", "yii", "=", "realpath", "(", "dirname", "(", "__FILE__", ")", ".", "'/../../yii.php'", ")", ";", "$", "yii", "=", "$", "this", "->", "getRelativePath", "(", "$", "yii", ",", "$", "this", "->", "_rootPath", ".", "DIRECTORY_SEPARATOR", ".", "'index.php'", ")", ";", "$", "yii", "=", "str_replace", "(", "'\\\\'", ",", "'\\\\\\\\'", ",", "$", "yii", ")", ";", "return", "preg_replace", "(", "'/\\$yii\\s*=(.*?);/'", ",", "\"\\$yii=$yii;\"", ",", "$", "content", ")", ";", "}" ]
Inserts path to framework's yii.php into application's index.php @param string $source source file path @param array $params @return string modified source file content
[ "Inserts", "path", "to", "framework", "s", "yii", ".", "php", "into", "application", "s", "index", ".", "php" ]
af3cbce71db83c4476c8a4289517b2984c740f31
https://github.com/yiisoft/yii/blob/af3cbce71db83c4476c8a4289517b2984c740f31/framework/cli/commands/WebAppCommand.php#L142-L149
train
yiisoft/yii
framework/cli/commands/WebAppCommand.php
WebAppCommand.generateYiic
public function generateYiic($source,$params) { $content=file_get_contents($source); $yiic=realpath(dirname(__FILE__).'/../../yiic.php'); $yiic=$this->getRelativePath($yiic,$this->_rootPath.DIRECTORY_SEPARATOR.'protected'.DIRECTORY_SEPARATOR.'yiic.php'); $yiic=str_replace('\\','\\\\',$yiic); return preg_replace('/\$yiic\s*=(.*?);/',"\$yiic=$yiic;",$content); }
php
public function generateYiic($source,$params) { $content=file_get_contents($source); $yiic=realpath(dirname(__FILE__).'/../../yiic.php'); $yiic=$this->getRelativePath($yiic,$this->_rootPath.DIRECTORY_SEPARATOR.'protected'.DIRECTORY_SEPARATOR.'yiic.php'); $yiic=str_replace('\\','\\\\',$yiic); return preg_replace('/\$yiic\s*=(.*?);/',"\$yiic=$yiic;",$content); }
[ "public", "function", "generateYiic", "(", "$", "source", ",", "$", "params", ")", "{", "$", "content", "=", "file_get_contents", "(", "$", "source", ")", ";", "$", "yiic", "=", "realpath", "(", "dirname", "(", "__FILE__", ")", ".", "'/../../yiic.php'", ")", ";", "$", "yiic", "=", "$", "this", "->", "getRelativePath", "(", "$", "yiic", ",", "$", "this", "->", "_rootPath", ".", "DIRECTORY_SEPARATOR", ".", "'protected'", ".", "DIRECTORY_SEPARATOR", ".", "'yiic.php'", ")", ";", "$", "yiic", "=", "str_replace", "(", "'\\\\'", ",", "'\\\\\\\\'", ",", "$", "yiic", ")", ";", "return", "preg_replace", "(", "'/\\$yiic\\s*=(.*?);/'", ",", "\"\\$yiic=$yiic;\"", ",", "$", "content", ")", ";", "}" ]
Inserts path to framework's yiic.php into application's yiic.php @param string $source source file path @param array $params @return string modified source file content
[ "Inserts", "path", "to", "framework", "s", "yiic", ".", "php", "into", "application", "s", "yiic", ".", "php" ]
af3cbce71db83c4476c8a4289517b2984c740f31
https://github.com/yiisoft/yii/blob/af3cbce71db83c4476c8a4289517b2984c740f31/framework/cli/commands/WebAppCommand.php#L174-L181
train
yiisoft/yii
framework/logging/CProfileLogRoute.php
CProfileLogRoute.processLogs
public function processLogs($logs) { $app=Yii::app(); if(!($app instanceof CWebApplication) || $app->getRequest()->getIsAjaxRequest()) return; if($this->getReport()==='summary') $this->displaySummary($logs); else $this->displayCallstack($logs); }
php
public function processLogs($logs) { $app=Yii::app(); if(!($app instanceof CWebApplication) || $app->getRequest()->getIsAjaxRequest()) return; if($this->getReport()==='summary') $this->displaySummary($logs); else $this->displayCallstack($logs); }
[ "public", "function", "processLogs", "(", "$", "logs", ")", "{", "$", "app", "=", "Yii", "::", "app", "(", ")", ";", "if", "(", "!", "(", "$", "app", "instanceof", "CWebApplication", ")", "||", "$", "app", "->", "getRequest", "(", ")", "->", "getIsAjaxRequest", "(", ")", ")", "return", ";", "if", "(", "$", "this", "->", "getReport", "(", ")", "===", "'summary'", ")", "$", "this", "->", "displaySummary", "(", "$", "logs", ")", ";", "else", "$", "this", "->", "displayCallstack", "(", "$", "logs", ")", ";", "}" ]
Displays the log messages. @param array $logs list of log messages
[ "Displays", "the", "log", "messages", "." ]
af3cbce71db83c4476c8a4289517b2984c740f31
https://github.com/yiisoft/yii/blob/af3cbce71db83c4476c8a4289517b2984c740f31/framework/logging/CProfileLogRoute.php#L77-L87
train
yiisoft/yii
framework/logging/CProfileLogRoute.php
CProfileLogRoute.displayCallstack
protected function displayCallstack($logs) { $stack=array(); $results=array(); $n=0; foreach($logs as $log) { if($log[1]!==CLogger::LEVEL_PROFILE) continue; $message=$log[0]; if(!strncasecmp($message,'begin:',6)) { $log[0]=substr($message,6); $log[4]=$n; $stack[]=$log; $n++; } elseif(!strncasecmp($message,'end:',4)) { $token=substr($message,4); if(($last=array_pop($stack))!==null && $last[0]===$token) { $delta=$log[3]-$last[3]; $results[$last[4]]=array($token,$delta,count($stack)); } else throw new CException(Yii::t('yii','CProfileLogRoute found a mismatching code block "{token}". Make sure the calls to Yii::beginProfile() and Yii::endProfile() be properly nested.', array('{token}'=>$token))); } } // remaining entries should be closed here $now=microtime(true); while(($last=array_pop($stack))!==null) $results[$last[4]]=array($last[0],$now-$last[3],count($stack)); ksort($results); $this->render('profile-callstack',$results); }
php
protected function displayCallstack($logs) { $stack=array(); $results=array(); $n=0; foreach($logs as $log) { if($log[1]!==CLogger::LEVEL_PROFILE) continue; $message=$log[0]; if(!strncasecmp($message,'begin:',6)) { $log[0]=substr($message,6); $log[4]=$n; $stack[]=$log; $n++; } elseif(!strncasecmp($message,'end:',4)) { $token=substr($message,4); if(($last=array_pop($stack))!==null && $last[0]===$token) { $delta=$log[3]-$last[3]; $results[$last[4]]=array($token,$delta,count($stack)); } else throw new CException(Yii::t('yii','CProfileLogRoute found a mismatching code block "{token}". Make sure the calls to Yii::beginProfile() and Yii::endProfile() be properly nested.', array('{token}'=>$token))); } } // remaining entries should be closed here $now=microtime(true); while(($last=array_pop($stack))!==null) $results[$last[4]]=array($last[0],$now-$last[3],count($stack)); ksort($results); $this->render('profile-callstack',$results); }
[ "protected", "function", "displayCallstack", "(", "$", "logs", ")", "{", "$", "stack", "=", "array", "(", ")", ";", "$", "results", "=", "array", "(", ")", ";", "$", "n", "=", "0", ";", "foreach", "(", "$", "logs", "as", "$", "log", ")", "{", "if", "(", "$", "log", "[", "1", "]", "!==", "CLogger", "::", "LEVEL_PROFILE", ")", "continue", ";", "$", "message", "=", "$", "log", "[", "0", "]", ";", "if", "(", "!", "strncasecmp", "(", "$", "message", ",", "'begin:'", ",", "6", ")", ")", "{", "$", "log", "[", "0", "]", "=", "substr", "(", "$", "message", ",", "6", ")", ";", "$", "log", "[", "4", "]", "=", "$", "n", ";", "$", "stack", "[", "]", "=", "$", "log", ";", "$", "n", "++", ";", "}", "elseif", "(", "!", "strncasecmp", "(", "$", "message", ",", "'end:'", ",", "4", ")", ")", "{", "$", "token", "=", "substr", "(", "$", "message", ",", "4", ")", ";", "if", "(", "(", "$", "last", "=", "array_pop", "(", "$", "stack", ")", ")", "!==", "null", "&&", "$", "last", "[", "0", "]", "===", "$", "token", ")", "{", "$", "delta", "=", "$", "log", "[", "3", "]", "-", "$", "last", "[", "3", "]", ";", "$", "results", "[", "$", "last", "[", "4", "]", "]", "=", "array", "(", "$", "token", ",", "$", "delta", ",", "count", "(", "$", "stack", ")", ")", ";", "}", "else", "throw", "new", "CException", "(", "Yii", "::", "t", "(", "'yii'", ",", "'CProfileLogRoute found a mismatching code block \"{token}\". Make sure the calls to Yii::beginProfile() and Yii::endProfile() be properly nested.'", ",", "array", "(", "'{token}'", "=>", "$", "token", ")", ")", ")", ";", "}", "}", "// remaining entries should be closed here", "$", "now", "=", "microtime", "(", "true", ")", ";", "while", "(", "(", "$", "last", "=", "array_pop", "(", "$", "stack", ")", ")", "!==", "null", ")", "$", "results", "[", "$", "last", "[", "4", "]", "]", "=", "array", "(", "$", "last", "[", "0", "]", ",", "$", "now", "-", "$", "last", "[", "3", "]", ",", "count", "(", "$", "stack", ")", ")", ";", "ksort", "(", "$", "results", ")", ";", "$", "this", "->", "render", "(", "'profile-callstack'", ",", "$", "results", ")", ";", "}" ]
Displays the callstack of the profiling procedures for display. @param array $logs list of logs @throws CException if Yii::beginProfile() and Yii::endProfile() are not matching
[ "Displays", "the", "callstack", "of", "the", "profiling", "procedures", "for", "display", "." ]
af3cbce71db83c4476c8a4289517b2984c740f31
https://github.com/yiisoft/yii/blob/af3cbce71db83c4476c8a4289517b2984c740f31/framework/logging/CProfileLogRoute.php#L94-L130
train
yiisoft/yii
framework/logging/CProfileLogRoute.php
CProfileLogRoute.displaySummary
protected function displaySummary($logs) { $stack=array(); $results=array(); foreach($logs as $log) { if($log[1]!==CLogger::LEVEL_PROFILE) continue; $message=$log[0]; if(!strncasecmp($message,'begin:',6)) { $log[0]=substr($message,6); $stack[]=$log; } elseif(!strncasecmp($message,'end:',4)) { $token=substr($message,4); if(($last=array_pop($stack))!==null && $last[0]===$token) { $delta=$log[3]-$last[3]; if(!$this->groupByToken) $token=$log[2]; if(isset($results[$token])) $results[$token]=$this->aggregateResult($results[$token],$delta); else $results[$token]=array($token,1,$delta,$delta,$delta); } else throw new CException(Yii::t('yii','CProfileLogRoute found a mismatching code block "{token}". Make sure the calls to Yii::beginProfile() and Yii::endProfile() be properly nested.', array('{token}'=>$token))); } } $now=microtime(true); while(($last=array_pop($stack))!==null) { $delta=$now-$last[3]; $token=$this->groupByToken ? $last[0] : $last[2]; if(isset($results[$token])) $results[$token]=$this->aggregateResult($results[$token],$delta); else $results[$token]=array($token,1,$delta,$delta,$delta); } $entries=array_values($results); usort($entries, array($this, 'resultEntryCompare')); $this->render('profile-summary',$entries); }
php
protected function displaySummary($logs) { $stack=array(); $results=array(); foreach($logs as $log) { if($log[1]!==CLogger::LEVEL_PROFILE) continue; $message=$log[0]; if(!strncasecmp($message,'begin:',6)) { $log[0]=substr($message,6); $stack[]=$log; } elseif(!strncasecmp($message,'end:',4)) { $token=substr($message,4); if(($last=array_pop($stack))!==null && $last[0]===$token) { $delta=$log[3]-$last[3]; if(!$this->groupByToken) $token=$log[2]; if(isset($results[$token])) $results[$token]=$this->aggregateResult($results[$token],$delta); else $results[$token]=array($token,1,$delta,$delta,$delta); } else throw new CException(Yii::t('yii','CProfileLogRoute found a mismatching code block "{token}". Make sure the calls to Yii::beginProfile() and Yii::endProfile() be properly nested.', array('{token}'=>$token))); } } $now=microtime(true); while(($last=array_pop($stack))!==null) { $delta=$now-$last[3]; $token=$this->groupByToken ? $last[0] : $last[2]; if(isset($results[$token])) $results[$token]=$this->aggregateResult($results[$token],$delta); else $results[$token]=array($token,1,$delta,$delta,$delta); } $entries=array_values($results); usort($entries, array($this, 'resultEntryCompare')); $this->render('profile-summary',$entries); }
[ "protected", "function", "displaySummary", "(", "$", "logs", ")", "{", "$", "stack", "=", "array", "(", ")", ";", "$", "results", "=", "array", "(", ")", ";", "foreach", "(", "$", "logs", "as", "$", "log", ")", "{", "if", "(", "$", "log", "[", "1", "]", "!==", "CLogger", "::", "LEVEL_PROFILE", ")", "continue", ";", "$", "message", "=", "$", "log", "[", "0", "]", ";", "if", "(", "!", "strncasecmp", "(", "$", "message", ",", "'begin:'", ",", "6", ")", ")", "{", "$", "log", "[", "0", "]", "=", "substr", "(", "$", "message", ",", "6", ")", ";", "$", "stack", "[", "]", "=", "$", "log", ";", "}", "elseif", "(", "!", "strncasecmp", "(", "$", "message", ",", "'end:'", ",", "4", ")", ")", "{", "$", "token", "=", "substr", "(", "$", "message", ",", "4", ")", ";", "if", "(", "(", "$", "last", "=", "array_pop", "(", "$", "stack", ")", ")", "!==", "null", "&&", "$", "last", "[", "0", "]", "===", "$", "token", ")", "{", "$", "delta", "=", "$", "log", "[", "3", "]", "-", "$", "last", "[", "3", "]", ";", "if", "(", "!", "$", "this", "->", "groupByToken", ")", "$", "token", "=", "$", "log", "[", "2", "]", ";", "if", "(", "isset", "(", "$", "results", "[", "$", "token", "]", ")", ")", "$", "results", "[", "$", "token", "]", "=", "$", "this", "->", "aggregateResult", "(", "$", "results", "[", "$", "token", "]", ",", "$", "delta", ")", ";", "else", "$", "results", "[", "$", "token", "]", "=", "array", "(", "$", "token", ",", "1", ",", "$", "delta", ",", "$", "delta", ",", "$", "delta", ")", ";", "}", "else", "throw", "new", "CException", "(", "Yii", "::", "t", "(", "'yii'", ",", "'CProfileLogRoute found a mismatching code block \"{token}\". Make sure the calls to Yii::beginProfile() and Yii::endProfile() be properly nested.'", ",", "array", "(", "'{token}'", "=>", "$", "token", ")", ")", ")", ";", "}", "}", "$", "now", "=", "microtime", "(", "true", ")", ";", "while", "(", "(", "$", "last", "=", "array_pop", "(", "$", "stack", ")", ")", "!==", "null", ")", "{", "$", "delta", "=", "$", "now", "-", "$", "last", "[", "3", "]", ";", "$", "token", "=", "$", "this", "->", "groupByToken", "?", "$", "last", "[", "0", "]", ":", "$", "last", "[", "2", "]", ";", "if", "(", "isset", "(", "$", "results", "[", "$", "token", "]", ")", ")", "$", "results", "[", "$", "token", "]", "=", "$", "this", "->", "aggregateResult", "(", "$", "results", "[", "$", "token", "]", ",", "$", "delta", ")", ";", "else", "$", "results", "[", "$", "token", "]", "=", "array", "(", "$", "token", ",", "1", ",", "$", "delta", ",", "$", "delta", ",", "$", "delta", ")", ";", "}", "$", "entries", "=", "array_values", "(", "$", "results", ")", ";", "usort", "(", "$", "entries", ",", "array", "(", "$", "this", ",", "'resultEntryCompare'", ")", ")", ";", "$", "this", "->", "render", "(", "'profile-summary'", ",", "$", "entries", ")", ";", "}" ]
Displays the summary report of the profiling result. @param array $logs list of logs @throws CException if Yii::beginProfile() and Yii::endProfile() are not matching
[ "Displays", "the", "summary", "report", "of", "the", "profiling", "result", "." ]
af3cbce71db83c4476c8a4289517b2984c740f31
https://github.com/yiisoft/yii/blob/af3cbce71db83c4476c8a4289517b2984c740f31/framework/logging/CProfileLogRoute.php#L137-L185
train
yiisoft/yii
framework/logging/CProfileLogRoute.php
CProfileLogRoute.aggregateResult
protected function aggregateResult($result,$delta) { list($token,$calls,$min,$max,$total)=$result; if($delta<$min) $min=$delta; elseif($delta>$max) $max=$delta; $calls++; $total+=$delta; return array($token,$calls,$min,$max,$total); }
php
protected function aggregateResult($result,$delta) { list($token,$calls,$min,$max,$total)=$result; if($delta<$min) $min=$delta; elseif($delta>$max) $max=$delta; $calls++; $total+=$delta; return array($token,$calls,$min,$max,$total); }
[ "protected", "function", "aggregateResult", "(", "$", "result", ",", "$", "delta", ")", "{", "list", "(", "$", "token", ",", "$", "calls", ",", "$", "min", ",", "$", "max", ",", "$", "total", ")", "=", "$", "result", ";", "if", "(", "$", "delta", "<", "$", "min", ")", "$", "min", "=", "$", "delta", ";", "elseif", "(", "$", "delta", ">", "$", "max", ")", "$", "max", "=", "$", "delta", ";", "$", "calls", "++", ";", "$", "total", "+=", "$", "delta", ";", "return", "array", "(", "$", "token", ",", "$", "calls", ",", "$", "min", ",", "$", "max", ",", "$", "total", ")", ";", "}" ]
Aggregates the report result. @param array $result log result for this code block @param float $delta time spent for this code block @return array
[ "Aggregates", "the", "report", "result", "." ]
af3cbce71db83c4476c8a4289517b2984c740f31
https://github.com/yiisoft/yii/blob/af3cbce71db83c4476c8a4289517b2984c740f31/framework/logging/CProfileLogRoute.php#L205-L215
train
yiisoft/yii
framework/db/ar/CActiveRecord.php
CActiveRecord.delete
public function delete() { if(!$this->getIsNewRecord()) { Yii::trace(get_class($this).'.delete()','system.db.ar.CActiveRecord'); if($this->beforeDelete()) { $result=$this->deleteByPk($this->getPrimaryKey())>0; $this->afterDelete(); return $result; } else return false; } else throw new CDbException(Yii::t('yii','The active record cannot be deleted because it is new.')); }
php
public function delete() { if(!$this->getIsNewRecord()) { Yii::trace(get_class($this).'.delete()','system.db.ar.CActiveRecord'); if($this->beforeDelete()) { $result=$this->deleteByPk($this->getPrimaryKey())>0; $this->afterDelete(); return $result; } else return false; } else throw new CDbException(Yii::t('yii','The active record cannot be deleted because it is new.')); }
[ "public", "function", "delete", "(", ")", "{", "if", "(", "!", "$", "this", "->", "getIsNewRecord", "(", ")", ")", "{", "Yii", "::", "trace", "(", "get_class", "(", "$", "this", ")", ".", "'.delete()'", ",", "'system.db.ar.CActiveRecord'", ")", ";", "if", "(", "$", "this", "->", "beforeDelete", "(", ")", ")", "{", "$", "result", "=", "$", "this", "->", "deleteByPk", "(", "$", "this", "->", "getPrimaryKey", "(", ")", ")", ">", "0", ";", "$", "this", "->", "afterDelete", "(", ")", ";", "return", "$", "result", ";", "}", "else", "return", "false", ";", "}", "else", "throw", "new", "CDbException", "(", "Yii", "::", "t", "(", "'yii'", ",", "'The active record cannot be deleted because it is new.'", ")", ")", ";", "}" ]
Deletes the row corresponding to this active record. @throws CDbException if the record is new @return boolean whether the deletion is successful.
[ "Deletes", "the", "row", "corresponding", "to", "this", "active", "record", "." ]
af3cbce71db83c4476c8a4289517b2984c740f31
https://github.com/yiisoft/yii/blob/af3cbce71db83c4476c8a4289517b2984c740f31/framework/db/ar/CActiveRecord.php#L1223-L1239
train
yiisoft/yii
framework/db/ar/CActiveRecord.php
CActiveRecord.find
public function find($condition='',$params=array()) { Yii::trace(get_class($this).'.find()','system.db.ar.CActiveRecord'); $criteria=$this->getCommandBuilder()->createCriteria($condition,$params); return $this->query($criteria); }
php
public function find($condition='',$params=array()) { Yii::trace(get_class($this).'.find()','system.db.ar.CActiveRecord'); $criteria=$this->getCommandBuilder()->createCriteria($condition,$params); return $this->query($criteria); }
[ "public", "function", "find", "(", "$", "condition", "=", "''", ",", "$", "params", "=", "array", "(", ")", ")", "{", "Yii", "::", "trace", "(", "get_class", "(", "$", "this", ")", ".", "'.find()'", ",", "'system.db.ar.CActiveRecord'", ")", ";", "$", "criteria", "=", "$", "this", "->", "getCommandBuilder", "(", ")", "->", "createCriteria", "(", "$", "condition", ",", "$", "params", ")", ";", "return", "$", "this", "->", "query", "(", "$", "criteria", ")", ";", "}" ]
Finds a single active record with the specified condition. @param mixed $condition query condition or criteria. If a string, it is treated as query condition (the WHERE clause); If an array, it is treated as the initial values for constructing a {@link CDbCriteria} object; Otherwise, it should be an instance of {@link CDbCriteria}. @param array $params parameters to be bound to an SQL statement. This is only used when the first parameter is a string (query condition). In other cases, please use {@link CDbCriteria::params} to set parameters. @return static|null the record found. Null if no record is found.
[ "Finds", "a", "single", "active", "record", "with", "the", "specified", "condition", "." ]
af3cbce71db83c4476c8a4289517b2984c740f31
https://github.com/yiisoft/yii/blob/af3cbce71db83c4476c8a4289517b2984c740f31/framework/db/ar/CActiveRecord.php#L1460-L1465
train
yiisoft/yii
framework/db/ar/CActiveRecord.php
CActiveRecord.findBySql
public function findBySql($sql,$params=array()) { Yii::trace(get_class($this).'.findBySql()','system.db.ar.CActiveRecord'); $this->beforeFind(); if(($criteria=$this->getDbCriteria(false))!==null && !empty($criteria->with)) { $this->resetScope(false); $finder=$this->getActiveFinder($criteria->with); return $finder->findBySql($sql,$params); } else { $command=$this->getCommandBuilder()->createSqlCommand($sql,$params); return $this->populateRecord($command->queryRow()); } }
php
public function findBySql($sql,$params=array()) { Yii::trace(get_class($this).'.findBySql()','system.db.ar.CActiveRecord'); $this->beforeFind(); if(($criteria=$this->getDbCriteria(false))!==null && !empty($criteria->with)) { $this->resetScope(false); $finder=$this->getActiveFinder($criteria->with); return $finder->findBySql($sql,$params); } else { $command=$this->getCommandBuilder()->createSqlCommand($sql,$params); return $this->populateRecord($command->queryRow()); } }
[ "public", "function", "findBySql", "(", "$", "sql", ",", "$", "params", "=", "array", "(", ")", ")", "{", "Yii", "::", "trace", "(", "get_class", "(", "$", "this", ")", ".", "'.findBySql()'", ",", "'system.db.ar.CActiveRecord'", ")", ";", "$", "this", "->", "beforeFind", "(", ")", ";", "if", "(", "(", "$", "criteria", "=", "$", "this", "->", "getDbCriteria", "(", "false", ")", ")", "!==", "null", "&&", "!", "empty", "(", "$", "criteria", "->", "with", ")", ")", "{", "$", "this", "->", "resetScope", "(", "false", ")", ";", "$", "finder", "=", "$", "this", "->", "getActiveFinder", "(", "$", "criteria", "->", "with", ")", ";", "return", "$", "finder", "->", "findBySql", "(", "$", "sql", ",", "$", "params", ")", ";", "}", "else", "{", "$", "command", "=", "$", "this", "->", "getCommandBuilder", "(", ")", "->", "createSqlCommand", "(", "$", "sql", ",", "$", "params", ")", ";", "return", "$", "this", "->", "populateRecord", "(", "$", "command", "->", "queryRow", "(", ")", ")", ";", "}", "}" ]
Finds a single active record with the specified SQL statement. @param string $sql the SQL statement @param array $params parameters to be bound to the SQL statement @return static|null the record found. Null if none is found.
[ "Finds", "a", "single", "active", "record", "with", "the", "specified", "SQL", "statement", "." ]
af3cbce71db83c4476c8a4289517b2984c740f31
https://github.com/yiisoft/yii/blob/af3cbce71db83c4476c8a4289517b2984c740f31/framework/db/ar/CActiveRecord.php#L1553-L1568
train
yiisoft/yii
framework/db/ar/CActiveRecord.php
CActiveRecord.findAllBySql
public function findAllBySql($sql,$params=array()) { Yii::trace(get_class($this).'.findAllBySql()','system.db.ar.CActiveRecord'); $this->beforeFind(); if(($criteria=$this->getDbCriteria(false))!==null && !empty($criteria->with)) { $this->resetScope(false); $finder=$this->getActiveFinder($criteria->with); return $finder->findAllBySql($sql,$params); } else { $command=$this->getCommandBuilder()->createSqlCommand($sql,$params); return $this->populateRecords($command->queryAll()); } }
php
public function findAllBySql($sql,$params=array()) { Yii::trace(get_class($this).'.findAllBySql()','system.db.ar.CActiveRecord'); $this->beforeFind(); if(($criteria=$this->getDbCriteria(false))!==null && !empty($criteria->with)) { $this->resetScope(false); $finder=$this->getActiveFinder($criteria->with); return $finder->findAllBySql($sql,$params); } else { $command=$this->getCommandBuilder()->createSqlCommand($sql,$params); return $this->populateRecords($command->queryAll()); } }
[ "public", "function", "findAllBySql", "(", "$", "sql", ",", "$", "params", "=", "array", "(", ")", ")", "{", "Yii", "::", "trace", "(", "get_class", "(", "$", "this", ")", ".", "'.findAllBySql()'", ",", "'system.db.ar.CActiveRecord'", ")", ";", "$", "this", "->", "beforeFind", "(", ")", ";", "if", "(", "(", "$", "criteria", "=", "$", "this", "->", "getDbCriteria", "(", "false", ")", ")", "!==", "null", "&&", "!", "empty", "(", "$", "criteria", "->", "with", ")", ")", "{", "$", "this", "->", "resetScope", "(", "false", ")", ";", "$", "finder", "=", "$", "this", "->", "getActiveFinder", "(", "$", "criteria", "->", "with", ")", ";", "return", "$", "finder", "->", "findAllBySql", "(", "$", "sql", ",", "$", "params", ")", ";", "}", "else", "{", "$", "command", "=", "$", "this", "->", "getCommandBuilder", "(", ")", "->", "createSqlCommand", "(", "$", "sql", ",", "$", "params", ")", ";", "return", "$", "this", "->", "populateRecords", "(", "$", "command", "->", "queryAll", "(", ")", ")", ";", "}", "}" ]
Finds all active records using the specified SQL statement. @param string $sql the SQL statement @param array $params parameters to be bound to the SQL statement @return static[] the records found. An empty array is returned if none is found.
[ "Finds", "all", "active", "records", "using", "the", "specified", "SQL", "statement", "." ]
af3cbce71db83c4476c8a4289517b2984c740f31
https://github.com/yiisoft/yii/blob/af3cbce71db83c4476c8a4289517b2984c740f31/framework/db/ar/CActiveRecord.php#L1576-L1591
train
yiisoft/yii
framework/web/CDataProviderIterator.php
CDataProviderIterator.loadPage
protected function loadPage() { $this->_dataProvider->getPagination()->setCurrentPage($this->_currentPage); return $this->_items=$this->dataProvider->getData(true); }
php
protected function loadPage() { $this->_dataProvider->getPagination()->setCurrentPage($this->_currentPage); return $this->_items=$this->dataProvider->getData(true); }
[ "protected", "function", "loadPage", "(", ")", "{", "$", "this", "->", "_dataProvider", "->", "getPagination", "(", ")", "->", "setCurrentPage", "(", "$", "this", "->", "_currentPage", ")", ";", "return", "$", "this", "->", "_items", "=", "$", "this", "->", "dataProvider", "->", "getData", "(", "true", ")", ";", "}" ]
Loads a page of items @return array the items from the next page of results
[ "Loads", "a", "page", "of", "items" ]
af3cbce71db83c4476c8a4289517b2984c740f31
https://github.com/yiisoft/yii/blob/af3cbce71db83c4476c8a4289517b2984c740f31/framework/web/CDataProviderIterator.php#L82-L86
train
yiisoft/yii
framework/web/CDataProviderIterator.php
CDataProviderIterator.key
public function key() { $pageSize=$this->_dataProvider->getPagination()->getPageSize(); return $this->_currentPage*$pageSize+$this->_currentIndex; }
php
public function key() { $pageSize=$this->_dataProvider->getPagination()->getPageSize(); return $this->_currentPage*$pageSize+$this->_currentIndex; }
[ "public", "function", "key", "(", ")", "{", "$", "pageSize", "=", "$", "this", "->", "_dataProvider", "->", "getPagination", "(", ")", "->", "getPageSize", "(", ")", ";", "return", "$", "this", "->", "_currentPage", "*", "$", "pageSize", "+", "$", "this", "->", "_currentIndex", ";", "}" ]
Gets the key of the current item. This method is required by the Iterator interface. @return integer the key of the current item
[ "Gets", "the", "key", "of", "the", "current", "item", ".", "This", "method", "is", "required", "by", "the", "Iterator", "interface", "." ]
af3cbce71db83c4476c8a4289517b2984c740f31
https://github.com/yiisoft/yii/blob/af3cbce71db83c4476c8a4289517b2984c740f31/framework/web/CDataProviderIterator.php#L103-L107
train
yiisoft/yii
framework/web/CDataProviderIterator.php
CDataProviderIterator.next
public function next() { $pageSize=$this->_dataProvider->getPagination()->getPageSize(); $this->_currentIndex++; if($this->_currentIndex >= $pageSize) { $this->_currentPage++; $this->_currentIndex=0; $this->loadPage(); } }
php
public function next() { $pageSize=$this->_dataProvider->getPagination()->getPageSize(); $this->_currentIndex++; if($this->_currentIndex >= $pageSize) { $this->_currentPage++; $this->_currentIndex=0; $this->loadPage(); } }
[ "public", "function", "next", "(", ")", "{", "$", "pageSize", "=", "$", "this", "->", "_dataProvider", "->", "getPagination", "(", ")", "->", "getPageSize", "(", ")", ";", "$", "this", "->", "_currentIndex", "++", ";", "if", "(", "$", "this", "->", "_currentIndex", ">=", "$", "pageSize", ")", "{", "$", "this", "->", "_currentPage", "++", ";", "$", "this", "->", "_currentIndex", "=", "0", ";", "$", "this", "->", "loadPage", "(", ")", ";", "}", "}" ]
Moves the pointer to the next item in the list. This method is required by the Iterator interface.
[ "Moves", "the", "pointer", "to", "the", "next", "item", "in", "the", "list", ".", "This", "method", "is", "required", "by", "the", "Iterator", "interface", "." ]
af3cbce71db83c4476c8a4289517b2984c740f31
https://github.com/yiisoft/yii/blob/af3cbce71db83c4476c8a4289517b2984c740f31/framework/web/CDataProviderIterator.php#L113-L123
train
yiisoft/yii
framework/caching/CDbCache.php
CDbCache.createCacheTable
protected function createCacheTable($db,$tableName) { $driver=$db->getDriverName(); if($driver==='mysql') $blob='LONGBLOB'; elseif($driver==='pgsql') $blob='BYTEA'; else $blob='BLOB'; $sql=<<<EOD CREATE TABLE $tableName ( id CHAR(128) PRIMARY KEY, expire INTEGER, value $blob ) EOD; $db->createCommand($sql)->execute(); }
php
protected function createCacheTable($db,$tableName) { $driver=$db->getDriverName(); if($driver==='mysql') $blob='LONGBLOB'; elseif($driver==='pgsql') $blob='BYTEA'; else $blob='BLOB'; $sql=<<<EOD CREATE TABLE $tableName ( id CHAR(128) PRIMARY KEY, expire INTEGER, value $blob ) EOD; $db->createCommand($sql)->execute(); }
[ "protected", "function", "createCacheTable", "(", "$", "db", ",", "$", "tableName", ")", "{", "$", "driver", "=", "$", "db", "->", "getDriverName", "(", ")", ";", "if", "(", "$", "driver", "===", "'mysql'", ")", "$", "blob", "=", "'LONGBLOB'", ";", "elseif", "(", "$", "driver", "===", "'pgsql'", ")", "$", "blob", "=", "'BYTEA'", ";", "else", "$", "blob", "=", "'BLOB'", ";", "$", "sql", "=", "<<<EOD\nCREATE TABLE $tableName\n(\n\tid CHAR(128) PRIMARY KEY,\n\texpire INTEGER,\n\tvalue $blob\n)\nEOD", ";", "$", "db", "->", "createCommand", "(", "$", "sql", ")", "->", "execute", "(", ")", ";", "}" ]
Creates the cache DB table. @param CDbConnection $db the database connection @param string $tableName the name of the table to be created
[ "Creates", "the", "cache", "DB", "table", "." ]
af3cbce71db83c4476c8a4289517b2984c740f31
https://github.com/yiisoft/yii/blob/af3cbce71db83c4476c8a4289517b2984c740f31/framework/caching/CDbCache.php#L122-L140
train
yiisoft/yii
framework/utils/CTimestamp.php
CTimestamp.isLeapYear
public static function isLeapYear($year) { $year = self::digitCheck($year); if ($year % 4 != 0) return false; if ($year % 400 == 0) return true; // if gregorian calendar (>1582), century not-divisible by 400 is not leap elseif ($year > 1582 && $year % 100 == 0 ) return false; return true; }
php
public static function isLeapYear($year) { $year = self::digitCheck($year); if ($year % 4 != 0) return false; if ($year % 400 == 0) return true; // if gregorian calendar (>1582), century not-divisible by 400 is not leap elseif ($year > 1582 && $year % 100 == 0 ) return false; return true; }
[ "public", "static", "function", "isLeapYear", "(", "$", "year", ")", "{", "$", "year", "=", "self", "::", "digitCheck", "(", "$", "year", ")", ";", "if", "(", "$", "year", "%", "4", "!=", "0", ")", "return", "false", ";", "if", "(", "$", "year", "%", "400", "==", "0", ")", "return", "true", ";", "// if gregorian calendar (>1582), century not-divisible by 400 is not leap", "elseif", "(", "$", "year", ">", "1582", "&&", "$", "year", "%", "100", "==", "0", ")", "return", "false", ";", "return", "true", ";", "}" ]
Checks for leap year, returns true if it is. No 2-digit year check. Also handles julian calendar correctly. @param integer $year year to check @return boolean true if is leap year
[ "Checks", "for", "leap", "year", "returns", "true", "if", "it", "is", ".", "No", "2", "-", "digit", "year", "check", ".", "Also", "handles", "julian", "calendar", "correctly", "." ]
af3cbce71db83c4476c8a4289517b2984c740f31
https://github.com/yiisoft/yii/blob/af3cbce71db83c4476c8a4289517b2984c740f31/framework/utils/CTimestamp.php#L92-L104
train
yiisoft/yii
framework/utils/CTimestamp.php
CTimestamp.digitCheck
protected static function digitCheck($y) { if ($y < 100){ $yr = (integer) date("Y"); $century = (integer) ($yr /100); if ($yr%100 > 50) { $c1 = $century + 1; $c0 = $century; } else { $c1 = $century; $c0 = $century - 1; } $c1 *= 100; // if 2-digit year is less than 30 years in future, set it to this century // otherwise if more than 30 years in future, then we set 2-digit year to the prev century. if (($y + $c1) < $yr+30) $y = $y + $c1; else $y = $y + $c0*100; } return $y; }
php
protected static function digitCheck($y) { if ($y < 100){ $yr = (integer) date("Y"); $century = (integer) ($yr /100); if ($yr%100 > 50) { $c1 = $century + 1; $c0 = $century; } else { $c1 = $century; $c0 = $century - 1; } $c1 *= 100; // if 2-digit year is less than 30 years in future, set it to this century // otherwise if more than 30 years in future, then we set 2-digit year to the prev century. if (($y + $c1) < $yr+30) $y = $y + $c1; else $y = $y + $c0*100; } return $y; }
[ "protected", "static", "function", "digitCheck", "(", "$", "y", ")", "{", "if", "(", "$", "y", "<", "100", ")", "{", "$", "yr", "=", "(", "integer", ")", "date", "(", "\"Y\"", ")", ";", "$", "century", "=", "(", "integer", ")", "(", "$", "yr", "/", "100", ")", ";", "if", "(", "$", "yr", "%", "100", ">", "50", ")", "{", "$", "c1", "=", "$", "century", "+", "1", ";", "$", "c0", "=", "$", "century", ";", "}", "else", "{", "$", "c1", "=", "$", "century", ";", "$", "c0", "=", "$", "century", "-", "1", ";", "}", "$", "c1", "*=", "100", ";", "// if 2-digit year is less than 30 years in future, set it to this century", "// otherwise if more than 30 years in future, then we set 2-digit year to the prev century.", "if", "(", "(", "$", "y", "+", "$", "c1", ")", "<", "$", "yr", "+", "30", ")", "$", "y", "=", "$", "y", "+", "$", "c1", ";", "else", "$", "y", "=", "$", "y", "+", "$", "c0", "*", "100", ";", "}", "return", "$", "y", ";", "}" ]
Fix 2-digit years. Works for any century. Assumes that if 2-digit is more than 30 years in future, then previous century. @param integer $y year @return integer change two digit year into multiple digits
[ "Fix", "2", "-", "digit", "years", ".", "Works", "for", "any", "century", ".", "Assumes", "that", "if", "2", "-", "digit", "is", "more", "than", "30", "years", "in", "future", "then", "previous", "century", "." ]
af3cbce71db83c4476c8a4289517b2984c740f31
https://github.com/yiisoft/yii/blob/af3cbce71db83c4476c8a4289517b2984c740f31/framework/utils/CTimestamp.php#L112-L132
train
yiisoft/yii
framework/utils/CTimestamp.php
CTimestamp.isValidTime
public static function isValidTime($h,$m,$s,$hs24=true) { if($hs24 && ($h < 0 || $h > 23) || !$hs24 && ($h < 1 || $h > 12)) return false; if($m > 59 || $m < 0) return false; if($s > 59 || $s < 0) return false; return true; }
php
public static function isValidTime($h,$m,$s,$hs24=true) { if($hs24 && ($h < 0 || $h > 23) || !$hs24 && ($h < 1 || $h > 12)) return false; if($m > 59 || $m < 0) return false; if($s > 59 || $s < 0) return false; return true; }
[ "public", "static", "function", "isValidTime", "(", "$", "h", ",", "$", "m", ",", "$", "s", ",", "$", "hs24", "=", "true", ")", "{", "if", "(", "$", "hs24", "&&", "(", "$", "h", "<", "0", "||", "$", "h", ">", "23", ")", "||", "!", "$", "hs24", "&&", "(", "$", "h", "<", "1", "||", "$", "h", ">", "12", ")", ")", "return", "false", ";", "if", "(", "$", "m", ">", "59", "||", "$", "m", "<", "0", ")", "return", "false", ";", "if", "(", "$", "s", ">", "59", "||", "$", "s", "<", "0", ")", "return", "false", ";", "return", "true", ";", "}" ]
Checks to see if the hour, minute and second are valid. @param integer $h hour @param integer $m minute @param integer $s second @param boolean $hs24 whether the hours should be 0 through 23 (default) or 1 through 12. @return boolean true if valid date, semantic check only.
[ "Checks", "to", "see", "if", "the", "hour", "minute", "and", "second", "are", "valid", "." ]
af3cbce71db83c4476c8a4289517b2984c740f31
https://github.com/yiisoft/yii/blob/af3cbce71db83c4476c8a4289517b2984c740f31/framework/utils/CTimestamp.php#L201-L207
train
yiisoft/yii
framework/web/CArrayDataProvider.php
CArrayDataProvider.getSortingFieldValue
protected function getSortingFieldValue($data, $fields) { if(is_object($data)) { foreach($fields as $field) $data=isset($data->$field) ? $data->$field : null; } else { foreach($fields as $field) $data=isset($data[$field]) ? $data[$field] : null; } return $this->caseSensitiveSort ? $data : mb_strtolower($data,Yii::app()->charset); }
php
protected function getSortingFieldValue($data, $fields) { if(is_object($data)) { foreach($fields as $field) $data=isset($data->$field) ? $data->$field : null; } else { foreach($fields as $field) $data=isset($data[$field]) ? $data[$field] : null; } return $this->caseSensitiveSort ? $data : mb_strtolower($data,Yii::app()->charset); }
[ "protected", "function", "getSortingFieldValue", "(", "$", "data", ",", "$", "fields", ")", "{", "if", "(", "is_object", "(", "$", "data", ")", ")", "{", "foreach", "(", "$", "fields", "as", "$", "field", ")", "$", "data", "=", "isset", "(", "$", "data", "->", "$", "field", ")", "?", "$", "data", "->", "$", "field", ":", "null", ";", "}", "else", "{", "foreach", "(", "$", "fields", "as", "$", "field", ")", "$", "data", "=", "isset", "(", "$", "data", "[", "$", "field", "]", ")", "?", "$", "data", "[", "$", "field", "]", ":", "null", ";", "}", "return", "$", "this", "->", "caseSensitiveSort", "?", "$", "data", ":", "mb_strtolower", "(", "$", "data", ",", "Yii", "::", "app", "(", ")", "->", "charset", ")", ";", "}" ]
Get field for sorting, using dot like delimiter in query. @param mixed $data array or object @param array $fields sorting fields in $data @return mixed $data sorting field value
[ "Get", "field", "for", "sorting", "using", "dot", "like", "delimiter", "in", "query", "." ]
af3cbce71db83c4476c8a4289517b2984c740f31
https://github.com/yiisoft/yii/blob/af3cbce71db83c4476c8a4289517b2984c740f31/framework/web/CArrayDataProvider.php#L167-L180
train
yiisoft/yii
framework/web/CArrayDataProvider.php
CArrayDataProvider.getSortDirections
protected function getSortDirections($order) { $segs=explode(',',$order); $directions=array(); foreach($segs as $seg) { if(preg_match('/(.*?)(\s+(desc|asc))?$/i',trim($seg),$matches)) $directions[$matches[1]]=isset($matches[3]) && !strcasecmp($matches[3],'desc'); else $directions[trim($seg)]=false; } return $directions; }
php
protected function getSortDirections($order) { $segs=explode(',',$order); $directions=array(); foreach($segs as $seg) { if(preg_match('/(.*?)(\s+(desc|asc))?$/i',trim($seg),$matches)) $directions[$matches[1]]=isset($matches[3]) && !strcasecmp($matches[3],'desc'); else $directions[trim($seg)]=false; } return $directions; }
[ "protected", "function", "getSortDirections", "(", "$", "order", ")", "{", "$", "segs", "=", "explode", "(", "','", ",", "$", "order", ")", ";", "$", "directions", "=", "array", "(", ")", ";", "foreach", "(", "$", "segs", "as", "$", "seg", ")", "{", "if", "(", "preg_match", "(", "'/(.*?)(\\s+(desc|asc))?$/i'", ",", "trim", "(", "$", "seg", ")", ",", "$", "matches", ")", ")", "$", "directions", "[", "$", "matches", "[", "1", "]", "]", "=", "isset", "(", "$", "matches", "[", "3", "]", ")", "&&", "!", "strcasecmp", "(", "$", "matches", "[", "3", "]", ",", "'desc'", ")", ";", "else", "$", "directions", "[", "trim", "(", "$", "seg", ")", "]", "=", "false", ";", "}", "return", "$", "directions", ";", "}" ]
Converts the "ORDER BY" clause into an array representing the sorting directions. @param string $order the "ORDER BY" clause. @return array the sorting directions (field name => whether it is descending sort)
[ "Converts", "the", "ORDER", "BY", "clause", "into", "an", "array", "representing", "the", "sorting", "directions", "." ]
af3cbce71db83c4476c8a4289517b2984c740f31
https://github.com/yiisoft/yii/blob/af3cbce71db83c4476c8a4289517b2984c740f31/framework/web/CArrayDataProvider.php#L187-L199
train
yiisoft/yii
framework/cli/views/webapp/protected/controllers/SiteController.php
SiteController.actionError
public function actionError() { if($error=Yii::app()->errorHandler->error) { if(Yii::app()->request->isAjaxRequest) echo $error['message']; else $this->render('error', $error); } }
php
public function actionError() { if($error=Yii::app()->errorHandler->error) { if(Yii::app()->request->isAjaxRequest) echo $error['message']; else $this->render('error', $error); } }
[ "public", "function", "actionError", "(", ")", "{", "if", "(", "$", "error", "=", "Yii", "::", "app", "(", ")", "->", "errorHandler", "->", "error", ")", "{", "if", "(", "Yii", "::", "app", "(", ")", "->", "request", "->", "isAjaxRequest", ")", "echo", "$", "error", "[", "'message'", "]", ";", "else", "$", "this", "->", "render", "(", "'error'", ",", "$", "error", ")", ";", "}", "}" ]
This is the action to handle external exceptions.
[ "This", "is", "the", "action", "to", "handle", "external", "exceptions", "." ]
af3cbce71db83c4476c8a4289517b2984c740f31
https://github.com/yiisoft/yii/blob/af3cbce71db83c4476c8a4289517b2984c740f31/framework/cli/views/webapp/protected/controllers/SiteController.php#L38-L47
train
yiisoft/yii
framework/cli/views/webapp/protected/controllers/SiteController.php
SiteController.actionContact
public function actionContact() { $model=new ContactForm; if(isset($_POST['ContactForm'])) { $model->attributes=$_POST['ContactForm']; if($model->validate()) { $name='=?UTF-8?B?'.base64_encode($model->name).'?='; $subject='=?UTF-8?B?'.base64_encode($model->subject).'?='; $headers="From: $name <{$model->email}>\r\n". "Reply-To: {$model->email}\r\n". "MIME-Version: 1.0\r\n". "Content-Type: text/plain; charset=UTF-8"; mail(Yii::app()->params['adminEmail'],$subject,$model->body,$headers); Yii::app()->user->setFlash('contact','Thank you for contacting us. We will respond to you as soon as possible.'); $this->refresh(); } } $this->render('contact',array('model'=>$model)); }
php
public function actionContact() { $model=new ContactForm; if(isset($_POST['ContactForm'])) { $model->attributes=$_POST['ContactForm']; if($model->validate()) { $name='=?UTF-8?B?'.base64_encode($model->name).'?='; $subject='=?UTF-8?B?'.base64_encode($model->subject).'?='; $headers="From: $name <{$model->email}>\r\n". "Reply-To: {$model->email}\r\n". "MIME-Version: 1.0\r\n". "Content-Type: text/plain; charset=UTF-8"; mail(Yii::app()->params['adminEmail'],$subject,$model->body,$headers); Yii::app()->user->setFlash('contact','Thank you for contacting us. We will respond to you as soon as possible.'); $this->refresh(); } } $this->render('contact',array('model'=>$model)); }
[ "public", "function", "actionContact", "(", ")", "{", "$", "model", "=", "new", "ContactForm", ";", "if", "(", "isset", "(", "$", "_POST", "[", "'ContactForm'", "]", ")", ")", "{", "$", "model", "->", "attributes", "=", "$", "_POST", "[", "'ContactForm'", "]", ";", "if", "(", "$", "model", "->", "validate", "(", ")", ")", "{", "$", "name", "=", "'=?UTF-8?B?'", ".", "base64_encode", "(", "$", "model", "->", "name", ")", ".", "'?='", ";", "$", "subject", "=", "'=?UTF-8?B?'", ".", "base64_encode", "(", "$", "model", "->", "subject", ")", ".", "'?='", ";", "$", "headers", "=", "\"From: $name <{$model->email}>\\r\\n\"", ".", "\"Reply-To: {$model->email}\\r\\n\"", ".", "\"MIME-Version: 1.0\\r\\n\"", ".", "\"Content-Type: text/plain; charset=UTF-8\"", ";", "mail", "(", "Yii", "::", "app", "(", ")", "->", "params", "[", "'adminEmail'", "]", ",", "$", "subject", ",", "$", "model", "->", "body", ",", "$", "headers", ")", ";", "Yii", "::", "app", "(", ")", "->", "user", "->", "setFlash", "(", "'contact'", ",", "'Thank you for contacting us. We will respond to you as soon as possible.'", ")", ";", "$", "this", "->", "refresh", "(", ")", ";", "}", "}", "$", "this", "->", "render", "(", "'contact'", ",", "array", "(", "'model'", "=>", "$", "model", ")", ")", ";", "}" ]
Displays the contact page
[ "Displays", "the", "contact", "page" ]
af3cbce71db83c4476c8a4289517b2984c740f31
https://github.com/yiisoft/yii/blob/af3cbce71db83c4476c8a4289517b2984c740f31/framework/cli/views/webapp/protected/controllers/SiteController.php#L52-L73
train
yiisoft/yii
framework/web/actions/CViewAction.php
CViewAction.resolveView
protected function resolveView($viewPath) { // start with a word char and have word chars, dots and dashes only if(preg_match('/^\w[\w\.\-]*$/',$viewPath)) { $view=strtr($viewPath,'.','/'); if(!empty($this->basePath)) $view=$this->basePath.'/'.$view; if($this->getController()->getViewFile($view)!==false) { $this->view=$view; return; } } throw new CHttpException(404,Yii::t('yii','The requested view "{name}" was not found.', array('{name}'=>$viewPath))); }
php
protected function resolveView($viewPath) { // start with a word char and have word chars, dots and dashes only if(preg_match('/^\w[\w\.\-]*$/',$viewPath)) { $view=strtr($viewPath,'.','/'); if(!empty($this->basePath)) $view=$this->basePath.'/'.$view; if($this->getController()->getViewFile($view)!==false) { $this->view=$view; return; } } throw new CHttpException(404,Yii::t('yii','The requested view "{name}" was not found.', array('{name}'=>$viewPath))); }
[ "protected", "function", "resolveView", "(", "$", "viewPath", ")", "{", "// start with a word char and have word chars, dots and dashes only", "if", "(", "preg_match", "(", "'/^\\w[\\w\\.\\-]*$/'", ",", "$", "viewPath", ")", ")", "{", "$", "view", "=", "strtr", "(", "$", "viewPath", ",", "'.'", ",", "'/'", ")", ";", "if", "(", "!", "empty", "(", "$", "this", "->", "basePath", ")", ")", "$", "view", "=", "$", "this", "->", "basePath", ".", "'/'", ".", "$", "view", ";", "if", "(", "$", "this", "->", "getController", "(", ")", "->", "getViewFile", "(", "$", "view", ")", "!==", "false", ")", "{", "$", "this", "->", "view", "=", "$", "view", ";", "return", ";", "}", "}", "throw", "new", "CHttpException", "(", "404", ",", "Yii", "::", "t", "(", "'yii'", ",", "'The requested view \"{name}\" was not found.'", ",", "array", "(", "'{name}'", "=>", "$", "viewPath", ")", ")", ")", ";", "}" ]
Resolves the user-specified view into a valid view name. @param string $viewPath user-specified view in the format of 'path.to.view'. @return string fully resolved view in the format of 'path/to/view'. @throws CHttpException if the user-specified view is invalid
[ "Resolves", "the", "user", "-", "specified", "view", "into", "a", "valid", "view", "name", "." ]
af3cbce71db83c4476c8a4289517b2984c740f31
https://github.com/yiisoft/yii/blob/af3cbce71db83c4476c8a4289517b2984c740f31/framework/web/actions/CViewAction.php#L98-L114
train
yiisoft/yii
framework/logging/CLogFilter.php
CLogFilter.filter
public function filter(&$logs) { if (!empty($logs)) { if(($message=$this->getContext())!=='') array_unshift($logs,array($message,CLogger::LEVEL_INFO,'application',YII_BEGIN_TIME)); $this->format($logs); } return $logs; }
php
public function filter(&$logs) { if (!empty($logs)) { if(($message=$this->getContext())!=='') array_unshift($logs,array($message,CLogger::LEVEL_INFO,'application',YII_BEGIN_TIME)); $this->format($logs); } return $logs; }
[ "public", "function", "filter", "(", "&", "$", "logs", ")", "{", "if", "(", "!", "empty", "(", "$", "logs", ")", ")", "{", "if", "(", "(", "$", "message", "=", "$", "this", "->", "getContext", "(", ")", ")", "!==", "''", ")", "array_unshift", "(", "$", "logs", ",", "array", "(", "$", "message", ",", "CLogger", "::", "LEVEL_INFO", ",", "'application'", ",", "YII_BEGIN_TIME", ")", ")", ";", "$", "this", "->", "format", "(", "$", "logs", ")", ";", "}", "return", "$", "logs", ";", "}" ]
Filters the given log messages. This is the main method of CLogFilter. It processes the log messages by adding context information, etc. @param array $logs the log messages @return array
[ "Filters", "the", "given", "log", "messages", ".", "This", "is", "the", "main", "method", "of", "CLogFilter", ".", "It", "processes", "the", "log", "messages", "by", "adding", "context", "information", "etc", "." ]
af3cbce71db83c4476c8a4289517b2984c740f31
https://github.com/yiisoft/yii/blob/af3cbce71db83c4476c8a4289517b2984c740f31/framework/logging/CLogFilter.php#L62-L71
train
yiisoft/yii
framework/logging/CDbLogRoute.php
CDbLogRoute.processLogs
protected function processLogs($logs) { $command=$this->getDbConnection()->createCommand(); foreach($logs as $log) { $command->insert($this->logTableName,array( 'level'=>$log[1], 'category'=>$log[2], 'logtime'=>(int)$log[3], 'message'=>$log[0], )); } }
php
protected function processLogs($logs) { $command=$this->getDbConnection()->createCommand(); foreach($logs as $log) { $command->insert($this->logTableName,array( 'level'=>$log[1], 'category'=>$log[2], 'logtime'=>(int)$log[3], 'message'=>$log[0], )); } }
[ "protected", "function", "processLogs", "(", "$", "logs", ")", "{", "$", "command", "=", "$", "this", "->", "getDbConnection", "(", ")", "->", "createCommand", "(", ")", ";", "foreach", "(", "$", "logs", "as", "$", "log", ")", "{", "$", "command", "->", "insert", "(", "$", "this", "->", "logTableName", ",", "array", "(", "'level'", "=>", "$", "log", "[", "1", "]", ",", "'category'", "=>", "$", "log", "[", "2", "]", ",", "'logtime'", "=>", "(", "int", ")", "$", "log", "[", "3", "]", ",", "'message'", "=>", "$", "log", "[", "0", "]", ",", ")", ")", ";", "}", "}" ]
Stores log messages into database. @param array $logs list of log messages
[ "Stores", "log", "messages", "into", "database", "." ]
af3cbce71db83c4476c8a4289517b2984c740f31
https://github.com/yiisoft/yii/blob/af3cbce71db83c4476c8a4289517b2984c740f31/framework/logging/CDbLogRoute.php#L126-L138
train
yiisoft/yii
framework/web/widgets/pagers/CBasePager.php
CBasePager.getPages
public function getPages() { if($this->_pages===null) $this->_pages=$this->createPages(); return $this->_pages; }
php
public function getPages() { if($this->_pages===null) $this->_pages=$this->createPages(); return $this->_pages; }
[ "public", "function", "getPages", "(", ")", "{", "if", "(", "$", "this", "->", "_pages", "===", "null", ")", "$", "this", "->", "_pages", "=", "$", "this", "->", "createPages", "(", ")", ";", "return", "$", "this", "->", "_pages", ";", "}" ]
Returns the pagination information used by this pager. @return CPagination the pagination information
[ "Returns", "the", "pagination", "information", "used", "by", "this", "pager", "." ]
af3cbce71db83c4476c8a4289517b2984c740f31
https://github.com/yiisoft/yii/blob/af3cbce71db83c4476c8a4289517b2984c740f31/framework/web/widgets/pagers/CBasePager.php#L34-L39
train
yiisoft/yii
framework/db/schema/cubrid/CCubridSchema.php
CCubridSchema.loadTable
protected function loadTable($name) { $table=new CCubridTableSchema; $this->resolveTableNames($table,$name); if($this->findColumns($table)) { $this->findPrimaryKeys($table); $this->findConstraints($table); return $table; } else return null; }
php
protected function loadTable($name) { $table=new CCubridTableSchema; $this->resolveTableNames($table,$name); if($this->findColumns($table)) { $this->findPrimaryKeys($table); $this->findConstraints($table); return $table; } else return null; }
[ "protected", "function", "loadTable", "(", "$", "name", ")", "{", "$", "table", "=", "new", "CCubridTableSchema", ";", "$", "this", "->", "resolveTableNames", "(", "$", "table", ",", "$", "name", ")", ";", "if", "(", "$", "this", "->", "findColumns", "(", "$", "table", ")", ")", "{", "$", "this", "->", "findPrimaryKeys", "(", "$", "table", ")", ";", "$", "this", "->", "findConstraints", "(", "$", "table", ")", ";", "return", "$", "table", ";", "}", "else", "return", "null", ";", "}" ]
Creates a table instance representing the metadata for the named table. @param string $name table name @return CCubridTableSchema driver dependent table metadata. Null if the table does not exist.
[ "Creates", "a", "table", "instance", "representing", "the", "metadata", "for", "the", "named", "table", "." ]
af3cbce71db83c4476c8a4289517b2984c740f31
https://github.com/yiisoft/yii/blob/af3cbce71db83c4476c8a4289517b2984c740f31/framework/db/schema/cubrid/CCubridSchema.php#L99-L112
train
yiisoft/yii
framework/db/schema/cubrid/CCubridSchema.php
CCubridSchema.findPrimaryKeys
protected function findPrimaryKeys($table) { $pks=$this->getDbConnection()->getPdoInstance()->cubrid_schema(PDO::CUBRID_SCH_PRIMARY_KEY,$table->name); foreach($pks as $pk) { $c = $table->columns[$pk['ATTR_NAME']]; $c->isPrimaryKey = true; if($table->primaryKey===null) $table->primaryKey=$c->name; elseif(is_string($table->primaryKey)) $table->primaryKey=array($table->primaryKey,$c->name); else $table->primaryKey[]=$c->name; if($c->autoIncrement) $table->sequenceName=''; } }
php
protected function findPrimaryKeys($table) { $pks=$this->getDbConnection()->getPdoInstance()->cubrid_schema(PDO::CUBRID_SCH_PRIMARY_KEY,$table->name); foreach($pks as $pk) { $c = $table->columns[$pk['ATTR_NAME']]; $c->isPrimaryKey = true; if($table->primaryKey===null) $table->primaryKey=$c->name; elseif(is_string($table->primaryKey)) $table->primaryKey=array($table->primaryKey,$c->name); else $table->primaryKey[]=$c->name; if($c->autoIncrement) $table->sequenceName=''; } }
[ "protected", "function", "findPrimaryKeys", "(", "$", "table", ")", "{", "$", "pks", "=", "$", "this", "->", "getDbConnection", "(", ")", "->", "getPdoInstance", "(", ")", "->", "cubrid_schema", "(", "PDO", "::", "CUBRID_SCH_PRIMARY_KEY", ",", "$", "table", "->", "name", ")", ";", "foreach", "(", "$", "pks", "as", "$", "pk", ")", "{", "$", "c", "=", "$", "table", "->", "columns", "[", "$", "pk", "[", "'ATTR_NAME'", "]", "]", ";", "$", "c", "->", "isPrimaryKey", "=", "true", ";", "if", "(", "$", "table", "->", "primaryKey", "===", "null", ")", "$", "table", "->", "primaryKey", "=", "$", "c", "->", "name", ";", "elseif", "(", "is_string", "(", "$", "table", "->", "primaryKey", ")", ")", "$", "table", "->", "primaryKey", "=", "array", "(", "$", "table", "->", "primaryKey", ",", "$", "c", "->", "name", ")", ";", "else", "$", "table", "->", "primaryKey", "[", "]", "=", "$", "c", "->", "name", ";", "if", "(", "$", "c", "->", "autoIncrement", ")", "$", "table", "->", "sequenceName", "=", "''", ";", "}", "}" ]
Collects the primary key column details for the given table. @param CCubridTableSchema $table the table metadata
[ "Collects", "the", "primary", "key", "column", "details", "for", "the", "given", "table", "." ]
af3cbce71db83c4476c8a4289517b2984c740f31
https://github.com/yiisoft/yii/blob/af3cbce71db83c4476c8a4289517b2984c740f31/framework/db/schema/cubrid/CCubridSchema.php#L210-L228
train
yiisoft/yii
framework/web/form/CFormInputElement.php
CFormInputElement.renderInput
public function renderInput() { if(isset(self::$coreTypes[$this->type])) { $method=self::$coreTypes[$this->type]; if(strpos($method,'List')!==false) return CHtml::$method($this->getParent()->getModel(), $this->name, $this->items, $this->attributes); else return CHtml::$method($this->getParent()->getModel(), $this->name, $this->attributes); } else { $attributes=$this->attributes; $attributes['model']=$this->getParent()->getModel(); $attributes['attribute']=$this->name; ob_start(); $this->getParent()->getOwner()->widget($this->type, $attributes); return ob_get_clean(); } }
php
public function renderInput() { if(isset(self::$coreTypes[$this->type])) { $method=self::$coreTypes[$this->type]; if(strpos($method,'List')!==false) return CHtml::$method($this->getParent()->getModel(), $this->name, $this->items, $this->attributes); else return CHtml::$method($this->getParent()->getModel(), $this->name, $this->attributes); } else { $attributes=$this->attributes; $attributes['model']=$this->getParent()->getModel(); $attributes['attribute']=$this->name; ob_start(); $this->getParent()->getOwner()->widget($this->type, $attributes); return ob_get_clean(); } }
[ "public", "function", "renderInput", "(", ")", "{", "if", "(", "isset", "(", "self", "::", "$", "coreTypes", "[", "$", "this", "->", "type", "]", ")", ")", "{", "$", "method", "=", "self", "::", "$", "coreTypes", "[", "$", "this", "->", "type", "]", ";", "if", "(", "strpos", "(", "$", "method", ",", "'List'", ")", "!==", "false", ")", "return", "CHtml", "::", "$", "method", "(", "$", "this", "->", "getParent", "(", ")", "->", "getModel", "(", ")", ",", "$", "this", "->", "name", ",", "$", "this", "->", "items", ",", "$", "this", "->", "attributes", ")", ";", "else", "return", "CHtml", "::", "$", "method", "(", "$", "this", "->", "getParent", "(", ")", "->", "getModel", "(", ")", ",", "$", "this", "->", "name", ",", "$", "this", "->", "attributes", ")", ";", "}", "else", "{", "$", "attributes", "=", "$", "this", "->", "attributes", ";", "$", "attributes", "[", "'model'", "]", "=", "$", "this", "->", "getParent", "(", ")", "->", "getModel", "(", ")", ";", "$", "attributes", "[", "'attribute'", "]", "=", "$", "this", "->", "name", ";", "ob_start", "(", ")", ";", "$", "this", "->", "getParent", "(", ")", "->", "getOwner", "(", ")", "->", "widget", "(", "$", "this", "->", "type", ",", "$", "attributes", ")", ";", "return", "ob_get_clean", "(", ")", ";", "}", "}" ]
Renders the input field. The default implementation returns the result of the appropriate CHtml method or the widget. @return string the rendering result
[ "Renders", "the", "input", "field", ".", "The", "default", "implementation", "returns", "the", "result", "of", "the", "appropriate", "CHtml", "method", "or", "the", "widget", "." ]
af3cbce71db83c4476c8a4289517b2984c740f31
https://github.com/yiisoft/yii/blob/af3cbce71db83c4476c8a4289517b2984c740f31/framework/web/form/CFormInputElement.php#L224-L243
train
yiisoft/yii
framework/utils/CPasswordHelper.php
CPasswordHelper.hashPassword
public static function hashPassword($password,$cost=13) { self::checkBlowfish(); $salt=self::generateSalt($cost); $hash=crypt($password,$salt); if(!is_string($hash) || (function_exists('mb_strlen') ? mb_strlen($hash, '8bit') : strlen($hash))<32) throw new CException(Yii::t('yii','Internal error while generating hash.')); return $hash; }
php
public static function hashPassword($password,$cost=13) { self::checkBlowfish(); $salt=self::generateSalt($cost); $hash=crypt($password,$salt); if(!is_string($hash) || (function_exists('mb_strlen') ? mb_strlen($hash, '8bit') : strlen($hash))<32) throw new CException(Yii::t('yii','Internal error while generating hash.')); return $hash; }
[ "public", "static", "function", "hashPassword", "(", "$", "password", ",", "$", "cost", "=", "13", ")", "{", "self", "::", "checkBlowfish", "(", ")", ";", "$", "salt", "=", "self", "::", "generateSalt", "(", "$", "cost", ")", ";", "$", "hash", "=", "crypt", "(", "$", "password", ",", "$", "salt", ")", ";", "if", "(", "!", "is_string", "(", "$", "hash", ")", "||", "(", "function_exists", "(", "'mb_strlen'", ")", "?", "mb_strlen", "(", "$", "hash", ",", "'8bit'", ")", ":", "strlen", "(", "$", "hash", ")", ")", "<", "32", ")", "throw", "new", "CException", "(", "Yii", "::", "t", "(", "'yii'", ",", "'Internal error while generating hash.'", ")", ")", ";", "return", "$", "hash", ";", "}" ]
Generate a secure hash from a password and a random salt. Uses the PHP {@link http://php.net/manual/en/function.crypt.php crypt()} built-in function with the Blowfish hash option. @param string $password The password to be hashed. @param int $cost Cost parameter used by the Blowfish hash algorithm. The higher the value of cost, the longer it takes to generate the hash and to verify a password against it. Higher cost therefore slows down a brute-force attack. For best protection against brute for attacks, set it to the highest value that is tolerable on production servers. The time taken to compute the hash doubles for every increment by one of $cost. So, for example, if the hash takes 1 second to compute when $cost is 14 then then the compute time varies as 2^($cost - 14) seconds. @return string The password hash string, always 60 ASCII characters. @throws CException on bad password parameter or if crypt() with Blowfish hash is not available.
[ "Generate", "a", "secure", "hash", "from", "a", "password", "and", "a", "random", "salt", "." ]
af3cbce71db83c4476c8a4289517b2984c740f31
https://github.com/yiisoft/yii/blob/af3cbce71db83c4476c8a4289517b2984c740f31/framework/utils/CPasswordHelper.php#L92-L102
train
yiisoft/yii
framework/utils/CPasswordHelper.php
CPasswordHelper.verifyPassword
public static function verifyPassword($password, $hash) { self::checkBlowfish(); if(!is_string($password) || $password==='') return false; if (!$password || !preg_match('{^\$2[axy]\$(\d\d)\$[\./0-9A-Za-z]{22}}',$hash,$matches) || $matches[1]<4 || $matches[1]>31) return false; $test=crypt($password,$hash); if(!is_string($test) || strlen($test)<32) return false; return self::same($test, $hash); }
php
public static function verifyPassword($password, $hash) { self::checkBlowfish(); if(!is_string($password) || $password==='') return false; if (!$password || !preg_match('{^\$2[axy]\$(\d\d)\$[\./0-9A-Za-z]{22}}',$hash,$matches) || $matches[1]<4 || $matches[1]>31) return false; $test=crypt($password,$hash); if(!is_string($test) || strlen($test)<32) return false; return self::same($test, $hash); }
[ "public", "static", "function", "verifyPassword", "(", "$", "password", ",", "$", "hash", ")", "{", "self", "::", "checkBlowfish", "(", ")", ";", "if", "(", "!", "is_string", "(", "$", "password", ")", "||", "$", "password", "===", "''", ")", "return", "false", ";", "if", "(", "!", "$", "password", "||", "!", "preg_match", "(", "'{^\\$2[axy]\\$(\\d\\d)\\$[\\./0-9A-Za-z]{22}}'", ",", "$", "hash", ",", "$", "matches", ")", "||", "$", "matches", "[", "1", "]", "<", "4", "||", "$", "matches", "[", "1", "]", ">", "31", ")", "return", "false", ";", "$", "test", "=", "crypt", "(", "$", "password", ",", "$", "hash", ")", ";", "if", "(", "!", "is_string", "(", "$", "test", ")", "||", "strlen", "(", "$", "test", ")", "<", "32", ")", "return", "false", ";", "return", "self", "::", "same", "(", "$", "test", ",", "$", "hash", ")", ";", "}" ]
Verify a password against a hash. @param string $password The password to verify. If password is empty or not a string, method will return false. @param string $hash The hash to verify the password against. @return bool True if the password matches the hash. @throws CException on bad password or hash parameters or if crypt() with Blowfish hash is not available.
[ "Verify", "a", "password", "against", "a", "hash", "." ]
af3cbce71db83c4476c8a4289517b2984c740f31
https://github.com/yiisoft/yii/blob/af3cbce71db83c4476c8a4289517b2984c740f31/framework/utils/CPasswordHelper.php#L112-L127
train
yiisoft/yii
framework/utils/CPasswordHelper.php
CPasswordHelper.same
public static function same($a,$b) { if(!is_string($a) || !is_string($b)) return false; $mb=function_exists('mb_strlen'); $length=$mb ? mb_strlen($a,'8bit') : strlen($a); if($length!==($mb ? mb_strlen($b,'8bit') : strlen($b))) return false; $check=0; for($i=0;$i<$length;$i+=1) $check|=(ord($a[$i])^ord($b[$i])); return $check===0; }
php
public static function same($a,$b) { if(!is_string($a) || !is_string($b)) return false; $mb=function_exists('mb_strlen'); $length=$mb ? mb_strlen($a,'8bit') : strlen($a); if($length!==($mb ? mb_strlen($b,'8bit') : strlen($b))) return false; $check=0; for($i=0;$i<$length;$i+=1) $check|=(ord($a[$i])^ord($b[$i])); return $check===0; }
[ "public", "static", "function", "same", "(", "$", "a", ",", "$", "b", ")", "{", "if", "(", "!", "is_string", "(", "$", "a", ")", "||", "!", "is_string", "(", "$", "b", ")", ")", "return", "false", ";", "$", "mb", "=", "function_exists", "(", "'mb_strlen'", ")", ";", "$", "length", "=", "$", "mb", "?", "mb_strlen", "(", "$", "a", ",", "'8bit'", ")", ":", "strlen", "(", "$", "a", ")", ";", "if", "(", "$", "length", "!==", "(", "$", "mb", "?", "mb_strlen", "(", "$", "b", ",", "'8bit'", ")", ":", "strlen", "(", "$", "b", ")", ")", ")", "return", "false", ";", "$", "check", "=", "0", ";", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<", "$", "length", ";", "$", "i", "+=", "1", ")", "$", "check", "|=", "(", "ord", "(", "$", "a", "[", "$", "i", "]", ")", "^", "ord", "(", "$", "b", "[", "$", "i", "]", ")", ")", ";", "return", "$", "check", "===", "0", ";", "}" ]
Check for sameness of two strings using an algorithm with timing independent of the string values if the subject strings are of equal length. The function can be useful to prevent timing attacks. For example, if $a and $b are both hash values from the same algorithm, then the timing of this function does not reveal whether or not there is a match. NOTE: timing is affected if $a and $b are different lengths or either is not a string. For the purpose of checking password hash this does not reveal information useful to an attacker. @see http://blog.astrumfutura.com/2010/10/nanosecond-scale-remote-timing-attacks-on-php-applications-time-to-take-them-seriously/ @see http://codereview.stackexchange.com/questions/13512 @see https://github.com/ircmaxell/password_compat/blob/master/lib/password.php @param string $a First subject string to compare. @param string $b Second subject string to compare. @return bool true if the strings are the same, false if they are different or if either is not a string.
[ "Check", "for", "sameness", "of", "two", "strings", "using", "an", "algorithm", "with", "timing", "independent", "of", "the", "string", "values", "if", "the", "subject", "strings", "are", "of", "equal", "length", "." ]
af3cbce71db83c4476c8a4289517b2984c740f31
https://github.com/yiisoft/yii/blob/af3cbce71db83c4476c8a4289517b2984c740f31/framework/utils/CPasswordHelper.php#L150-L165
train
yiisoft/yii
framework/gii/components/Pear/Text/Diff/Engine/shell.php
Text_Diff_Engine_shell._getLines
function _getLines(&$text_lines, &$line_no, $end = false) { if (!empty($end)) { $lines = array(); // We can shift even more while ($line_no <= $end) { array_push($lines, array_shift($text_lines)); $line_no++; } } else { $lines = array(array_shift($text_lines)); $line_no++; } return $lines; }
php
function _getLines(&$text_lines, &$line_no, $end = false) { if (!empty($end)) { $lines = array(); // We can shift even more while ($line_no <= $end) { array_push($lines, array_shift($text_lines)); $line_no++; } } else { $lines = array(array_shift($text_lines)); $line_no++; } return $lines; }
[ "function", "_getLines", "(", "&", "$", "text_lines", ",", "&", "$", "line_no", ",", "$", "end", "=", "false", ")", "{", "if", "(", "!", "empty", "(", "$", "end", ")", ")", "{", "$", "lines", "=", "array", "(", ")", ";", "// We can shift even more", "while", "(", "$", "line_no", "<=", "$", "end", ")", "{", "array_push", "(", "$", "lines", ",", "array_shift", "(", "$", "text_lines", ")", ")", ";", "$", "line_no", "++", ";", "}", "}", "else", "{", "$", "lines", "=", "array", "(", "array_shift", "(", "$", "text_lines", ")", ")", ";", "$", "line_no", "++", ";", "}", "return", "$", "lines", ";", "}" ]
Get lines from either the old or new text @access private @param array &$text_lines Either $from_lines or $to_lines @param int &$line_no Current line number @param int $end Optional end line, when we want to chop more than one line. @return array The chopped lines
[ "Get", "lines", "from", "either", "the", "old", "or", "new", "text" ]
af3cbce71db83c4476c8a4289517b2984c740f31
https://github.com/yiisoft/yii/blob/af3cbce71db83c4476c8a4289517b2984c740f31/framework/gii/components/Pear/Text/Diff/Engine/shell.php#L147-L162
train
yiisoft/yii
framework/web/CCacheHttpSession.php
CCacheHttpSession.init
public function init() { $this->_cache=Yii::app()->getComponent($this->cacheID); if(!($this->_cache instanceof ICache)) throw new CException(Yii::t('yii','CCacheHttpSession.cacheID is invalid. Please make sure "{id}" refers to a valid cache application component.', array('{id}'=>$this->cacheID))); parent::init(); }
php
public function init() { $this->_cache=Yii::app()->getComponent($this->cacheID); if(!($this->_cache instanceof ICache)) throw new CException(Yii::t('yii','CCacheHttpSession.cacheID is invalid. Please make sure "{id}" refers to a valid cache application component.', array('{id}'=>$this->cacheID))); parent::init(); }
[ "public", "function", "init", "(", ")", "{", "$", "this", "->", "_cache", "=", "Yii", "::", "app", "(", ")", "->", "getComponent", "(", "$", "this", "->", "cacheID", ")", ";", "if", "(", "!", "(", "$", "this", "->", "_cache", "instanceof", "ICache", ")", ")", "throw", "new", "CException", "(", "Yii", "::", "t", "(", "'yii'", ",", "'CCacheHttpSession.cacheID is invalid. Please make sure \"{id}\" refers to a valid cache application component.'", ",", "array", "(", "'{id}'", "=>", "$", "this", "->", "cacheID", ")", ")", ")", ";", "parent", "::", "init", "(", ")", ";", "}" ]
Initializes the application component. This method overrides the parent implementation by checking if cache is available.
[ "Initializes", "the", "application", "component", ".", "This", "method", "overrides", "the", "parent", "implementation", "by", "checking", "if", "cache", "is", "available", "." ]
af3cbce71db83c4476c8a4289517b2984c740f31
https://github.com/yiisoft/yii/blob/af3cbce71db83c4476c8a4289517b2984c740f31/framework/web/CCacheHttpSession.php#L49-L56
train
yiisoft/yii
framework/web/widgets/COutputCache.php
COutputCache.checkContentCache
protected function checkContentCache() { if((empty($this->requestTypes) || in_array(Yii::app()->getRequest()->getRequestType(),$this->requestTypes)) && ($this->_cache=$this->getCache())!==null) { if($this->duration>0 && ($data=$this->_cache->get($this->getCacheKey()))!==false) { $this->_content=$data[0]; $this->_actions=$data[1]; return true; } if($this->duration==0) $this->_cache->delete($this->getCacheKey()); if($this->duration<=0) $this->_cache=null; } return false; }
php
protected function checkContentCache() { if((empty($this->requestTypes) || in_array(Yii::app()->getRequest()->getRequestType(),$this->requestTypes)) && ($this->_cache=$this->getCache())!==null) { if($this->duration>0 && ($data=$this->_cache->get($this->getCacheKey()))!==false) { $this->_content=$data[0]; $this->_actions=$data[1]; return true; } if($this->duration==0) $this->_cache->delete($this->getCacheKey()); if($this->duration<=0) $this->_cache=null; } return false; }
[ "protected", "function", "checkContentCache", "(", ")", "{", "if", "(", "(", "empty", "(", "$", "this", "->", "requestTypes", ")", "||", "in_array", "(", "Yii", "::", "app", "(", ")", "->", "getRequest", "(", ")", "->", "getRequestType", "(", ")", ",", "$", "this", "->", "requestTypes", ")", ")", "&&", "(", "$", "this", "->", "_cache", "=", "$", "this", "->", "getCache", "(", ")", ")", "!==", "null", ")", "{", "if", "(", "$", "this", "->", "duration", ">", "0", "&&", "(", "$", "data", "=", "$", "this", "->", "_cache", "->", "get", "(", "$", "this", "->", "getCacheKey", "(", ")", ")", ")", "!==", "false", ")", "{", "$", "this", "->", "_content", "=", "$", "data", "[", "0", "]", ";", "$", "this", "->", "_actions", "=", "$", "data", "[", "1", "]", ";", "return", "true", ";", "}", "if", "(", "$", "this", "->", "duration", "==", "0", ")", "$", "this", "->", "_cache", "->", "delete", "(", "$", "this", "->", "getCacheKey", "(", ")", ")", ";", "if", "(", "$", "this", "->", "duration", "<=", "0", ")", "$", "this", "->", "_cache", "=", "null", ";", "}", "return", "false", ";", "}" ]
Looks for content in cache. @return boolean whether the content is found in cache.
[ "Looks", "for", "content", "in", "cache", "." ]
af3cbce71db83c4476c8a4289517b2984c740f31
https://github.com/yiisoft/yii/blob/af3cbce71db83c4476c8a4289517b2984c740f31/framework/web/widgets/COutputCache.php#L233-L250
train
yiisoft/yii
framework/web/widgets/COutputCache.php
COutputCache.replayActions
protected function replayActions() { if(empty($this->_actions)) return; $controller=$this->getController(); $cs=Yii::app()->getClientScript(); foreach($this->_actions as $action) { if($action[0]==='clientScript') $object=$cs; elseif($action[0]==='') $object=$controller; else $object=$controller->{$action[0]}; if(method_exists($object,$action[1])) call_user_func_array(array($object,$action[1]),$action[2]); elseif($action[0]==='' && function_exists($action[1])) call_user_func_array($action[1],$action[2]); else throw new CException(Yii::t('yii','Unable to replay the action "{object}.{method}". The method does not exist.', array('object'=>$action[0], 'method'=>$action[1]))); } }
php
protected function replayActions() { if(empty($this->_actions)) return; $controller=$this->getController(); $cs=Yii::app()->getClientScript(); foreach($this->_actions as $action) { if($action[0]==='clientScript') $object=$cs; elseif($action[0]==='') $object=$controller; else $object=$controller->{$action[0]}; if(method_exists($object,$action[1])) call_user_func_array(array($object,$action[1]),$action[2]); elseif($action[0]==='' && function_exists($action[1])) call_user_func_array($action[1],$action[2]); else throw new CException(Yii::t('yii','Unable to replay the action "{object}.{method}". The method does not exist.', array('object'=>$action[0], 'method'=>$action[1]))); } }
[ "protected", "function", "replayActions", "(", ")", "{", "if", "(", "empty", "(", "$", "this", "->", "_actions", ")", ")", "return", ";", "$", "controller", "=", "$", "this", "->", "getController", "(", ")", ";", "$", "cs", "=", "Yii", "::", "app", "(", ")", "->", "getClientScript", "(", ")", ";", "foreach", "(", "$", "this", "->", "_actions", "as", "$", "action", ")", "{", "if", "(", "$", "action", "[", "0", "]", "===", "'clientScript'", ")", "$", "object", "=", "$", "cs", ";", "elseif", "(", "$", "action", "[", "0", "]", "===", "''", ")", "$", "object", "=", "$", "controller", ";", "else", "$", "object", "=", "$", "controller", "->", "{", "$", "action", "[", "0", "]", "}", ";", "if", "(", "method_exists", "(", "$", "object", ",", "$", "action", "[", "1", "]", ")", ")", "call_user_func_array", "(", "array", "(", "$", "object", ",", "$", "action", "[", "1", "]", ")", ",", "$", "action", "[", "2", "]", ")", ";", "elseif", "(", "$", "action", "[", "0", "]", "===", "''", "&&", "function_exists", "(", "$", "action", "[", "1", "]", ")", ")", "call_user_func_array", "(", "$", "action", "[", "1", "]", ",", "$", "action", "[", "2", "]", ")", ";", "else", "throw", "new", "CException", "(", "Yii", "::", "t", "(", "'yii'", ",", "'Unable to replay the action \"{object}.{method}\". The method does not exist.'", ",", "array", "(", "'object'", "=>", "$", "action", "[", "0", "]", ",", "'method'", "=>", "$", "action", "[", "1", "]", ")", ")", ")", ";", "}", "}" ]
Replays the recorded method calls.
[ "Replays", "the", "recorded", "method", "calls", "." ]
af3cbce71db83c4476c8a4289517b2984c740f31
https://github.com/yiisoft/yii/blob/af3cbce71db83c4476c8a4289517b2984c740f31/framework/web/widgets/COutputCache.php#L340-L363
train
yiisoft/yii
framework/web/CDbHttpSession.php
CDbHttpSession.createSessionTable
protected function createSessionTable($db,$tableName) { switch($db->getDriverName()) { case 'mysql': $blob='LONGBLOB'; break; case 'pgsql': $blob='BYTEA'; break; case 'sqlsrv': case 'mssql': case 'dblib': $blob='VARBINARY(MAX)'; break; default: $blob='BLOB'; break; } $db->createCommand()->createTable($tableName,array( 'id'=>'CHAR(32) PRIMARY KEY', 'expire'=>'integer', 'data'=>$blob, )); }
php
protected function createSessionTable($db,$tableName) { switch($db->getDriverName()) { case 'mysql': $blob='LONGBLOB'; break; case 'pgsql': $blob='BYTEA'; break; case 'sqlsrv': case 'mssql': case 'dblib': $blob='VARBINARY(MAX)'; break; default: $blob='BLOB'; break; } $db->createCommand()->createTable($tableName,array( 'id'=>'CHAR(32) PRIMARY KEY', 'expire'=>'integer', 'data'=>$blob, )); }
[ "protected", "function", "createSessionTable", "(", "$", "db", ",", "$", "tableName", ")", "{", "switch", "(", "$", "db", "->", "getDriverName", "(", ")", ")", "{", "case", "'mysql'", ":", "$", "blob", "=", "'LONGBLOB'", ";", "break", ";", "case", "'pgsql'", ":", "$", "blob", "=", "'BYTEA'", ";", "break", ";", "case", "'sqlsrv'", ":", "case", "'mssql'", ":", "case", "'dblib'", ":", "$", "blob", "=", "'VARBINARY(MAX)'", ";", "break", ";", "default", ":", "$", "blob", "=", "'BLOB'", ";", "break", ";", "}", "$", "db", "->", "createCommand", "(", ")", "->", "createTable", "(", "$", "tableName", ",", "array", "(", "'id'", "=>", "'CHAR(32) PRIMARY KEY'", ",", "'expire'", "=>", "'integer'", ",", "'data'", "=>", "$", "blob", ",", ")", ")", ";", "}" ]
Creates the session DB table. @param CDbConnection $db the database connection @param string $tableName the name of the table to be created
[ "Creates", "the", "session", "DB", "table", "." ]
af3cbce71db83c4476c8a4289517b2984c740f31
https://github.com/yiisoft/yii/blob/af3cbce71db83c4476c8a4289517b2984c740f31/framework/web/CDbHttpSession.php#L139-L163
train
yiisoft/yii
framework/web/CDbHttpSession.php
CDbHttpSession.openSession
public function openSession($savePath,$sessionName) { if($this->autoCreateSessionTable) { $db=$this->getDbConnection(); $db->setActive(true); try { $db->createCommand()->delete($this->sessionTableName,'expire<:expire',array(':expire'=>time())); } catch(Exception $e) { $this->createSessionTable($db,$this->sessionTableName); } } return true; }
php
public function openSession($savePath,$sessionName) { if($this->autoCreateSessionTable) { $db=$this->getDbConnection(); $db->setActive(true); try { $db->createCommand()->delete($this->sessionTableName,'expire<:expire',array(':expire'=>time())); } catch(Exception $e) { $this->createSessionTable($db,$this->sessionTableName); } } return true; }
[ "public", "function", "openSession", "(", "$", "savePath", ",", "$", "sessionName", ")", "{", "if", "(", "$", "this", "->", "autoCreateSessionTable", ")", "{", "$", "db", "=", "$", "this", "->", "getDbConnection", "(", ")", ";", "$", "db", "->", "setActive", "(", "true", ")", ";", "try", "{", "$", "db", "->", "createCommand", "(", ")", "->", "delete", "(", "$", "this", "->", "sessionTableName", ",", "'expire<:expire'", ",", "array", "(", "':expire'", "=>", "time", "(", ")", ")", ")", ";", "}", "catch", "(", "Exception", "$", "e", ")", "{", "$", "this", "->", "createSessionTable", "(", "$", "db", ",", "$", "this", "->", "sessionTableName", ")", ";", "}", "}", "return", "true", ";", "}" ]
Session open handler. Do not call this method directly. @param string $savePath session save path @param string $sessionName session name @return boolean whether session is opened successfully
[ "Session", "open", "handler", ".", "Do", "not", "call", "this", "method", "directly", "." ]
af3cbce71db83c4476c8a4289517b2984c740f31
https://github.com/yiisoft/yii/blob/af3cbce71db83c4476c8a4289517b2984c740f31/framework/web/CDbHttpSession.php#L195-L211
train
yiisoft/yii
framework/web/widgets/captcha/CCaptchaAction.php
CCaptchaAction.getSessionKey
protected function getSessionKey() { return self::SESSION_VAR_PREFIX . Yii::app()->getId() . '.' . $this->getController()->getUniqueId() . '.' . $this->getId(); }
php
protected function getSessionKey() { return self::SESSION_VAR_PREFIX . Yii::app()->getId() . '.' . $this->getController()->getUniqueId() . '.' . $this->getId(); }
[ "protected", "function", "getSessionKey", "(", ")", "{", "return", "self", "::", "SESSION_VAR_PREFIX", ".", "Yii", "::", "app", "(", ")", "->", "getId", "(", ")", ".", "'.'", ".", "$", "this", "->", "getController", "(", ")", "->", "getUniqueId", "(", ")", ".", "'.'", ".", "$", "this", "->", "getId", "(", ")", ";", "}" ]
Returns the session variable name used to store verification code. @return string the session variable name
[ "Returns", "the", "session", "variable", "name", "used", "to", "store", "verification", "code", "." ]
af3cbce71db83c4476c8a4289517b2984c740f31
https://github.com/yiisoft/yii/blob/af3cbce71db83c4476c8a4289517b2984c740f31/framework/web/widgets/captcha/CCaptchaAction.php#L219-L222
train
yiisoft/yii
build/commands/TranslationsCommand.php
TranslationsCommand.checkFiles
protected function checkFiles($translatedFilePath = null, $sourceFilePath = null) { $errors = array(); if($translatedFilePath!==null && !file_exists($translatedFilePath)) { $errors[] = 'Translation does not exist.'; } if($sourceFilePath!==null && !file_exists($sourceFilePath)) { $errors[] = 'Source does not exist.'; } return $errors; }
php
protected function checkFiles($translatedFilePath = null, $sourceFilePath = null) { $errors = array(); if($translatedFilePath!==null && !file_exists($translatedFilePath)) { $errors[] = 'Translation does not exist.'; } if($sourceFilePath!==null && !file_exists($sourceFilePath)) { $errors[] = 'Source does not exist.'; } return $errors; }
[ "protected", "function", "checkFiles", "(", "$", "translatedFilePath", "=", "null", ",", "$", "sourceFilePath", "=", "null", ")", "{", "$", "errors", "=", "array", "(", ")", ";", "if", "(", "$", "translatedFilePath", "!==", "null", "&&", "!", "file_exists", "(", "$", "translatedFilePath", ")", ")", "{", "$", "errors", "[", "]", "=", "'Translation does not exist.'", ";", "}", "if", "(", "$", "sourceFilePath", "!==", "null", "&&", "!", "file_exists", "(", "$", "sourceFilePath", ")", ")", "{", "$", "errors", "[", "]", "=", "'Source does not exist.'", ";", "}", "return", "$", "errors", ";", "}" ]
Checks for files existence @param string $translatedFilePath @param string $sourceFilePath @return array errors
[ "Checks", "for", "files", "existence" ]
af3cbce71db83c4476c8a4289517b2984c740f31
https://github.com/yiisoft/yii/blob/af3cbce71db83c4476c8a4289517b2984c740f31/build/commands/TranslationsCommand.php#L109-L121
train
yiisoft/yii
build/commands/TranslationsCommand.php
TranslationsCommand.highlightDiff
protected function highlightDiff($diff) { $lines = explode("\n", $diff); foreach ($lines as $key => $val) { if (mb_substr($val,0,1,'utf-8') === '@') { $lines[$key] = '<span class="info">'.CHtml::encode($val).'</span>'; } else if (mb_substr($val,0,1,'utf-8') === '+') { $lines[$key] = '<ins>'.CHtml::encode($val).'</ins>'; } else if (mb_substr($val,0,1,'utf-8') === '-') { $lines[$key] = '<del>'.CHtml::encode($val).'</del>'; } else { $lines[$key] = CHtml::encode($val); } } return implode("\n", $lines); }
php
protected function highlightDiff($diff) { $lines = explode("\n", $diff); foreach ($lines as $key => $val) { if (mb_substr($val,0,1,'utf-8') === '@') { $lines[$key] = '<span class="info">'.CHtml::encode($val).'</span>'; } else if (mb_substr($val,0,1,'utf-8') === '+') { $lines[$key] = '<ins>'.CHtml::encode($val).'</ins>'; } else if (mb_substr($val,0,1,'utf-8') === '-') { $lines[$key] = '<del>'.CHtml::encode($val).'</del>'; } else { $lines[$key] = CHtml::encode($val); } } return implode("\n", $lines); }
[ "protected", "function", "highlightDiff", "(", "$", "diff", ")", "{", "$", "lines", "=", "explode", "(", "\"\\n\"", ",", "$", "diff", ")", ";", "foreach", "(", "$", "lines", "as", "$", "key", "=>", "$", "val", ")", "{", "if", "(", "mb_substr", "(", "$", "val", ",", "0", ",", "1", ",", "'utf-8'", ")", "===", "'@'", ")", "{", "$", "lines", "[", "$", "key", "]", "=", "'<span class=\"info\">'", ".", "CHtml", "::", "encode", "(", "$", "val", ")", ".", "'</span>'", ";", "}", "else", "if", "(", "mb_substr", "(", "$", "val", ",", "0", ",", "1", ",", "'utf-8'", ")", "===", "'+'", ")", "{", "$", "lines", "[", "$", "key", "]", "=", "'<ins>'", ".", "CHtml", "::", "encode", "(", "$", "val", ")", ".", "'</ins>'", ";", "}", "else", "if", "(", "mb_substr", "(", "$", "val", ",", "0", ",", "1", ",", "'utf-8'", ")", "===", "'-'", ")", "{", "$", "lines", "[", "$", "key", "]", "=", "'<del>'", ".", "CHtml", "::", "encode", "(", "$", "val", ")", ".", "'</del>'", ";", "}", "else", "{", "$", "lines", "[", "$", "key", "]", "=", "CHtml", "::", "encode", "(", "$", "val", ")", ";", "}", "}", "return", "implode", "(", "\"\\n\"", ",", "$", "lines", ")", ";", "}" ]
Adds all necessary HTML tags and classes to diff output @param string $diff DIFF @return string highlighted DIFF
[ "Adds", "all", "necessary", "HTML", "tags", "and", "classes", "to", "diff", "output" ]
af3cbce71db83c4476c8a4289517b2984c740f31
https://github.com/yiisoft/yii/blob/af3cbce71db83c4476c8a4289517b2984c740f31/build/commands/TranslationsCommand.php#L142-L161
train
yiisoft/yii
framework/web/form/CFormElement.php
CFormElement.configure
public function configure($config) { if(is_string($config)) $config=require(Yii::getPathOfAlias($config).'.php'); if(is_array($config)) { foreach($config as $name=>$value) $this->$name=$value; } }
php
public function configure($config) { if(is_string($config)) $config=require(Yii::getPathOfAlias($config).'.php'); if(is_array($config)) { foreach($config as $name=>$value) $this->$name=$value; } }
[ "public", "function", "configure", "(", "$", "config", ")", "{", "if", "(", "is_string", "(", "$", "config", ")", ")", "$", "config", "=", "require", "(", "Yii", "::", "getPathOfAlias", "(", "$", "config", ")", ".", "'.php'", ")", ";", "if", "(", "is_array", "(", "$", "config", ")", ")", "{", "foreach", "(", "$", "config", "as", "$", "name", "=>", "$", "value", ")", "$", "this", "->", "$", "name", "=", "$", "value", ";", "}", "}" ]
Configures this object with property initial values. @param mixed $config the configuration for this object. This can be an array representing the property names and their initial values. It can also be a string representing the file name of the PHP script that returns a configuration array.
[ "Configures", "this", "object", "with", "property", "initial", "values", "." ]
af3cbce71db83c4476c8a4289517b2984c740f31
https://github.com/yiisoft/yii/blob/af3cbce71db83c4476c8a4289517b2984c740f31/framework/web/form/CFormElement.php#L138-L147
train
yiisoft/yii
framework/web/auth/CPhpAuthManager.php
CPhpAuthManager.init
public function init() { parent::init(); if($this->authFile===null) $this->authFile=Yii::getPathOfAlias('application.data.auth').'.php'; $this->load(); }
php
public function init() { parent::init(); if($this->authFile===null) $this->authFile=Yii::getPathOfAlias('application.data.auth').'.php'; $this->load(); }
[ "public", "function", "init", "(", ")", "{", "parent", "::", "init", "(", ")", ";", "if", "(", "$", "this", "->", "authFile", "===", "null", ")", "$", "this", "->", "authFile", "=", "Yii", "::", "getPathOfAlias", "(", "'application.data.auth'", ")", ".", "'.php'", ";", "$", "this", "->", "load", "(", ")", ";", "}" ]
Initializes the application component. This method overrides parent implementation by loading the authorization data from PHP script.
[ "Initializes", "the", "application", "component", ".", "This", "method", "overrides", "parent", "implementation", "by", "loading", "the", "authorization", "data", "from", "PHP", "script", "." ]
af3cbce71db83c4476c8a4289517b2984c740f31
https://github.com/yiisoft/yii/blob/af3cbce71db83c4476c8a4289517b2984c740f31/framework/web/auth/CPhpAuthManager.php#L48-L54
train
yiisoft/yii
framework/web/auth/CPhpAuthManager.php
CPhpAuthManager.save
public function save() { $items=array(); foreach($this->_items as $name=>$item) { $items[$name]=array( 'type'=>$item->getType(), 'description'=>$item->getDescription(), 'bizRule'=>$item->getBizRule(), 'data'=>$item->getData(), ); if(isset($this->_children[$name])) { foreach($this->_children[$name] as $child) $items[$name]['children'][]=$child->getName(); } } foreach($this->_assignments as $userId=>$assignments) { foreach($assignments as $name=>$assignment) { if(isset($items[$name])) { $items[$name]['assignments'][$userId]=array( 'bizRule'=>$assignment->getBizRule(), 'data'=>$assignment->getData(), ); } } } $this->saveToFile($items,$this->authFile); }
php
public function save() { $items=array(); foreach($this->_items as $name=>$item) { $items[$name]=array( 'type'=>$item->getType(), 'description'=>$item->getDescription(), 'bizRule'=>$item->getBizRule(), 'data'=>$item->getData(), ); if(isset($this->_children[$name])) { foreach($this->_children[$name] as $child) $items[$name]['children'][]=$child->getName(); } } foreach($this->_assignments as $userId=>$assignments) { foreach($assignments as $name=>$assignment) { if(isset($items[$name])) { $items[$name]['assignments'][$userId]=array( 'bizRule'=>$assignment->getBizRule(), 'data'=>$assignment->getData(), ); } } } $this->saveToFile($items,$this->authFile); }
[ "public", "function", "save", "(", ")", "{", "$", "items", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "_items", "as", "$", "name", "=>", "$", "item", ")", "{", "$", "items", "[", "$", "name", "]", "=", "array", "(", "'type'", "=>", "$", "item", "->", "getType", "(", ")", ",", "'description'", "=>", "$", "item", "->", "getDescription", "(", ")", ",", "'bizRule'", "=>", "$", "item", "->", "getBizRule", "(", ")", ",", "'data'", "=>", "$", "item", "->", "getData", "(", ")", ",", ")", ";", "if", "(", "isset", "(", "$", "this", "->", "_children", "[", "$", "name", "]", ")", ")", "{", "foreach", "(", "$", "this", "->", "_children", "[", "$", "name", "]", "as", "$", "child", ")", "$", "items", "[", "$", "name", "]", "[", "'children'", "]", "[", "]", "=", "$", "child", "->", "getName", "(", ")", ";", "}", "}", "foreach", "(", "$", "this", "->", "_assignments", "as", "$", "userId", "=>", "$", "assignments", ")", "{", "foreach", "(", "$", "assignments", "as", "$", "name", "=>", "$", "assignment", ")", "{", "if", "(", "isset", "(", "$", "items", "[", "$", "name", "]", ")", ")", "{", "$", "items", "[", "$", "name", "]", "[", "'assignments'", "]", "[", "$", "userId", "]", "=", "array", "(", "'bizRule'", "=>", "$", "assignment", "->", "getBizRule", "(", ")", ",", "'data'", "=>", "$", "assignment", "->", "getData", "(", ")", ",", ")", ";", "}", "}", "}", "$", "this", "->", "saveToFile", "(", "$", "items", ",", "$", "this", "->", "authFile", ")", ";", "}" ]
Saves authorization data into persistent storage. If any change is made to the authorization data, please make sure you call this method to save the changed data into persistent storage.
[ "Saves", "authorization", "data", "into", "persistent", "storage", ".", "If", "any", "change", "is", "made", "to", "the", "authorization", "data", "please", "make", "sure", "you", "call", "this", "method", "to", "save", "the", "changed", "data", "into", "persistent", "storage", "." ]
af3cbce71db83c4476c8a4289517b2984c740f31
https://github.com/yiisoft/yii/blob/af3cbce71db83c4476c8a4289517b2984c740f31/framework/web/auth/CPhpAuthManager.php#L377-L410
train
yiisoft/yii
framework/web/auth/CPhpAuthManager.php
CPhpAuthManager.load
public function load() { $this->clearAll(); $items=$this->loadFromFile($this->authFile); foreach($items as $name=>$item) $this->_items[$name]=new CAuthItem($this,$name,$item['type'],$item['description'],$item['bizRule'],$item['data']); foreach($items as $name=>$item) { if(isset($item['children'])) { foreach($item['children'] as $childName) { if(isset($this->_items[$childName])) $this->_children[$name][$childName]=$this->_items[$childName]; } } if(isset($item['assignments'])) { foreach($item['assignments'] as $userId=>$assignment) { $this->_assignments[$userId][$name]=new CAuthAssignment($this,$name,$userId,$assignment['bizRule'],$assignment['data']); } } } }
php
public function load() { $this->clearAll(); $items=$this->loadFromFile($this->authFile); foreach($items as $name=>$item) $this->_items[$name]=new CAuthItem($this,$name,$item['type'],$item['description'],$item['bizRule'],$item['data']); foreach($items as $name=>$item) { if(isset($item['children'])) { foreach($item['children'] as $childName) { if(isset($this->_items[$childName])) $this->_children[$name][$childName]=$this->_items[$childName]; } } if(isset($item['assignments'])) { foreach($item['assignments'] as $userId=>$assignment) { $this->_assignments[$userId][$name]=new CAuthAssignment($this,$name,$userId,$assignment['bizRule'],$assignment['data']); } } } }
[ "public", "function", "load", "(", ")", "{", "$", "this", "->", "clearAll", "(", ")", ";", "$", "items", "=", "$", "this", "->", "loadFromFile", "(", "$", "this", "->", "authFile", ")", ";", "foreach", "(", "$", "items", "as", "$", "name", "=>", "$", "item", ")", "$", "this", "->", "_items", "[", "$", "name", "]", "=", "new", "CAuthItem", "(", "$", "this", ",", "$", "name", ",", "$", "item", "[", "'type'", "]", ",", "$", "item", "[", "'description'", "]", ",", "$", "item", "[", "'bizRule'", "]", ",", "$", "item", "[", "'data'", "]", ")", ";", "foreach", "(", "$", "items", "as", "$", "name", "=>", "$", "item", ")", "{", "if", "(", "isset", "(", "$", "item", "[", "'children'", "]", ")", ")", "{", "foreach", "(", "$", "item", "[", "'children'", "]", "as", "$", "childName", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "_items", "[", "$", "childName", "]", ")", ")", "$", "this", "->", "_children", "[", "$", "name", "]", "[", "$", "childName", "]", "=", "$", "this", "->", "_items", "[", "$", "childName", "]", ";", "}", "}", "if", "(", "isset", "(", "$", "item", "[", "'assignments'", "]", ")", ")", "{", "foreach", "(", "$", "item", "[", "'assignments'", "]", "as", "$", "userId", "=>", "$", "assignment", ")", "{", "$", "this", "->", "_assignments", "[", "$", "userId", "]", "[", "$", "name", "]", "=", "new", "CAuthAssignment", "(", "$", "this", ",", "$", "name", ",", "$", "userId", ",", "$", "assignment", "[", "'bizRule'", "]", ",", "$", "assignment", "[", "'data'", "]", ")", ";", "}", "}", "}", "}" ]
Loads authorization data.
[ "Loads", "authorization", "data", "." ]
af3cbce71db83c4476c8a4289517b2984c740f31
https://github.com/yiisoft/yii/blob/af3cbce71db83c4476c8a4289517b2984c740f31/framework/web/auth/CPhpAuthManager.php#L415-L442
train
yiisoft/yii
demos/phonebook/protected/controllers/SiteController.php
SiteController.beforeWebMethod
public function beforeWebMethod($service) { $safeMethods=array( 'login', 'getContacts', ); $pattern='/^('.implode('|',$safeMethods).')$/i'; if(!Yii::app()->user->isGuest || preg_match($pattern,$service->methodName)) return true; else throw new CException('Login required.'); }
php
public function beforeWebMethod($service) { $safeMethods=array( 'login', 'getContacts', ); $pattern='/^('.implode('|',$safeMethods).')$/i'; if(!Yii::app()->user->isGuest || preg_match($pattern,$service->methodName)) return true; else throw new CException('Login required.'); }
[ "public", "function", "beforeWebMethod", "(", "$", "service", ")", "{", "$", "safeMethods", "=", "array", "(", "'login'", ",", "'getContacts'", ",", ")", ";", "$", "pattern", "=", "'/^('", ".", "implode", "(", "'|'", ",", "$", "safeMethods", ")", ".", "')$/i'", ";", "if", "(", "!", "Yii", "::", "app", "(", ")", "->", "user", "->", "isGuest", "||", "preg_match", "(", "$", "pattern", ",", "$", "service", "->", "methodName", ")", ")", "return", "true", ";", "else", "throw", "new", "CException", "(", "'Login required.'", ")", ";", "}" ]
This method is required by IWebServiceProvider. It makes sure the user is logged in before making changes to data. @param CWebService the currently requested Web service. @return boolean whether the remote method should be executed.
[ "This", "method", "is", "required", "by", "IWebServiceProvider", ".", "It", "makes", "sure", "the", "user", "is", "logged", "in", "before", "making", "changes", "to", "data", "." ]
af3cbce71db83c4476c8a4289517b2984c740f31
https://github.com/yiisoft/yii/blob/af3cbce71db83c4476c8a4289517b2984c740f31/demos/phonebook/protected/controllers/SiteController.php#L57-L68
train
yiisoft/yii
demos/phonebook/protected/controllers/SiteController.php
SiteController.saveContact
public function saveContact($contact) { if($contact->id > 0) // update { $contact->isNewRecord=false; if(($oldContact=Contact::model()->findByPk($contact->id))!==null) { $oldContact->attributes=$contact->attributes; return $oldContact->save(); } else return false; } else // insert { $contact->isNewRecord=true; $contact->id=null; return $contact->save(); } }
php
public function saveContact($contact) { if($contact->id > 0) // update { $contact->isNewRecord=false; if(($oldContact=Contact::model()->findByPk($contact->id))!==null) { $oldContact->attributes=$contact->attributes; return $oldContact->save(); } else return false; } else // insert { $contact->isNewRecord=true; $contact->id=null; return $contact->save(); } }
[ "public", "function", "saveContact", "(", "$", "contact", ")", "{", "if", "(", "$", "contact", "->", "id", ">", "0", ")", "// update", "{", "$", "contact", "->", "isNewRecord", "=", "false", ";", "if", "(", "(", "$", "oldContact", "=", "Contact", "::", "model", "(", ")", "->", "findByPk", "(", "$", "contact", "->", "id", ")", ")", "!==", "null", ")", "{", "$", "oldContact", "->", "attributes", "=", "$", "contact", "->", "attributes", ";", "return", "$", "oldContact", "->", "save", "(", ")", ";", "}", "else", "return", "false", ";", "}", "else", "// insert", "{", "$", "contact", "->", "isNewRecord", "=", "true", ";", "$", "contact", "->", "id", "=", "null", ";", "return", "$", "contact", "->", "save", "(", ")", ";", "}", "}" ]
Updates or inserts a contact. If the ID is null, an insertion will be performed; Otherwise it updates the existing one. @param Contact contact model @return boolean whether saving is successful @soap
[ "Updates", "or", "inserts", "a", "contact", ".", "If", "the", "ID", "is", "null", "an", "insertion", "will", "be", "performed", ";", "Otherwise", "it", "updates", "the", "existing", "one", "." ]
af3cbce71db83c4476c8a4289517b2984c740f31
https://github.com/yiisoft/yii/blob/af3cbce71db83c4476c8a4289517b2984c740f31/demos/phonebook/protected/controllers/SiteController.php#L112-L131
train
yiisoft/yii
framework/gii/components/Pear/Text/Diff/Renderer.php
Text_Diff_Renderer.getParams
function getParams() { $params = array(); foreach (get_object_vars($this) as $k => $v) { if ($k[0] == '_') { $params[substr($k, 1)] = $v; } } return $params; }
php
function getParams() { $params = array(); foreach (get_object_vars($this) as $k => $v) { if ($k[0] == '_') { $params[substr($k, 1)] = $v; } } return $params; }
[ "function", "getParams", "(", ")", "{", "$", "params", "=", "array", "(", ")", ";", "foreach", "(", "get_object_vars", "(", "$", "this", ")", "as", "$", "k", "=>", "$", "v", ")", "{", "if", "(", "$", "k", "[", "0", "]", "==", "'_'", ")", "{", "$", "params", "[", "substr", "(", "$", "k", ",", "1", ")", "]", "=", "$", "v", ";", "}", "}", "return", "$", "params", ";", "}" ]
Get any renderer parameters. @return array All parameters of this renderer object.
[ "Get", "any", "renderer", "parameters", "." ]
af3cbce71db83c4476c8a4289517b2984c740f31
https://github.com/yiisoft/yii/blob/af3cbce71db83c4476c8a4289517b2984c740f31/framework/gii/components/Pear/Text/Diff/Renderer.php#L53-L63
train
yiisoft/yii
framework/gii/components/Pear/Text/Diff/Renderer.php
Text_Diff_Renderer.render
function render($diff) { $xi = $yi = 1; $block = false; $context = array(); $nlead = $this->_leading_context_lines; $ntrail = $this->_trailing_context_lines; $output = $this->_startDiff(); $diffs = $diff->getDiff(); foreach ($diffs as $i => $edit) { /* If these are unchanged (copied) lines, and we want to keep * leading or trailing context lines, extract them from the copy * block. */ if (is_a($edit, 'Text_Diff_Op_copy')) { /* Do we have any diff blocks yet? */ if (is_array($block)) { /* How many lines to keep as context from the copy * block. */ $keep = $i == count($diffs) - 1 ? $ntrail : $nlead + $ntrail; if (count($edit->orig) <= $keep) { /* We have less lines in the block than we want for * context => keep the whole block. */ $block[] = $edit; } else { if ($ntrail) { /* Create a new block with as many lines as we need * for the trailing context. */ $context = array_slice($edit->orig, 0, $ntrail); $block[] = new Text_Diff_Op_copy($context); } /* @todo */ $output .= $this->_block($x0, $ntrail + $xi - $x0, $y0, $ntrail + $yi - $y0, $block); $block = false; } } /* Keep the copy block as the context for the next block. */ $context = $edit->orig; } else { /* Don't we have any diff blocks yet? */ if (!is_array($block)) { /* Extract context lines from the preceding copy block. */ $context = array_slice($context, count($context) - $nlead); $x0 = $xi - count($context); $y0 = $yi - count($context); $block = array(); if ($context) { $block[] = new Text_Diff_Op_copy($context); } } $block[] = $edit; } if ($edit->orig) { $xi += count($edit->orig); } if ($edit->final) { $yi += count($edit->final); } } if (is_array($block)) { $output .= $this->_block($x0, $xi - $x0, $y0, $yi - $y0, $block); } return $output . $this->_endDiff(); }
php
function render($diff) { $xi = $yi = 1; $block = false; $context = array(); $nlead = $this->_leading_context_lines; $ntrail = $this->_trailing_context_lines; $output = $this->_startDiff(); $diffs = $diff->getDiff(); foreach ($diffs as $i => $edit) { /* If these are unchanged (copied) lines, and we want to keep * leading or trailing context lines, extract them from the copy * block. */ if (is_a($edit, 'Text_Diff_Op_copy')) { /* Do we have any diff blocks yet? */ if (is_array($block)) { /* How many lines to keep as context from the copy * block. */ $keep = $i == count($diffs) - 1 ? $ntrail : $nlead + $ntrail; if (count($edit->orig) <= $keep) { /* We have less lines in the block than we want for * context => keep the whole block. */ $block[] = $edit; } else { if ($ntrail) { /* Create a new block with as many lines as we need * for the trailing context. */ $context = array_slice($edit->orig, 0, $ntrail); $block[] = new Text_Diff_Op_copy($context); } /* @todo */ $output .= $this->_block($x0, $ntrail + $xi - $x0, $y0, $ntrail + $yi - $y0, $block); $block = false; } } /* Keep the copy block as the context for the next block. */ $context = $edit->orig; } else { /* Don't we have any diff blocks yet? */ if (!is_array($block)) { /* Extract context lines from the preceding copy block. */ $context = array_slice($context, count($context) - $nlead); $x0 = $xi - count($context); $y0 = $yi - count($context); $block = array(); if ($context) { $block[] = new Text_Diff_Op_copy($context); } } $block[] = $edit; } if ($edit->orig) { $xi += count($edit->orig); } if ($edit->final) { $yi += count($edit->final); } } if (is_array($block)) { $output .= $this->_block($x0, $xi - $x0, $y0, $yi - $y0, $block); } return $output . $this->_endDiff(); }
[ "function", "render", "(", "$", "diff", ")", "{", "$", "xi", "=", "$", "yi", "=", "1", ";", "$", "block", "=", "false", ";", "$", "context", "=", "array", "(", ")", ";", "$", "nlead", "=", "$", "this", "->", "_leading_context_lines", ";", "$", "ntrail", "=", "$", "this", "->", "_trailing_context_lines", ";", "$", "output", "=", "$", "this", "->", "_startDiff", "(", ")", ";", "$", "diffs", "=", "$", "diff", "->", "getDiff", "(", ")", ";", "foreach", "(", "$", "diffs", "as", "$", "i", "=>", "$", "edit", ")", "{", "/* If these are unchanged (copied) lines, and we want to keep\n * leading or trailing context lines, extract them from the copy\n * block. */", "if", "(", "is_a", "(", "$", "edit", ",", "'Text_Diff_Op_copy'", ")", ")", "{", "/* Do we have any diff blocks yet? */", "if", "(", "is_array", "(", "$", "block", ")", ")", "{", "/* How many lines to keep as context from the copy\n * block. */", "$", "keep", "=", "$", "i", "==", "count", "(", "$", "diffs", ")", "-", "1", "?", "$", "ntrail", ":", "$", "nlead", "+", "$", "ntrail", ";", "if", "(", "count", "(", "$", "edit", "->", "orig", ")", "<=", "$", "keep", ")", "{", "/* We have less lines in the block than we want for\n * context => keep the whole block. */", "$", "block", "[", "]", "=", "$", "edit", ";", "}", "else", "{", "if", "(", "$", "ntrail", ")", "{", "/* Create a new block with as many lines as we need\n * for the trailing context. */", "$", "context", "=", "array_slice", "(", "$", "edit", "->", "orig", ",", "0", ",", "$", "ntrail", ")", ";", "$", "block", "[", "]", "=", "new", "Text_Diff_Op_copy", "(", "$", "context", ")", ";", "}", "/* @todo */", "$", "output", ".=", "$", "this", "->", "_block", "(", "$", "x0", ",", "$", "ntrail", "+", "$", "xi", "-", "$", "x0", ",", "$", "y0", ",", "$", "ntrail", "+", "$", "yi", "-", "$", "y0", ",", "$", "block", ")", ";", "$", "block", "=", "false", ";", "}", "}", "/* Keep the copy block as the context for the next block. */", "$", "context", "=", "$", "edit", "->", "orig", ";", "}", "else", "{", "/* Don't we have any diff blocks yet? */", "if", "(", "!", "is_array", "(", "$", "block", ")", ")", "{", "/* Extract context lines from the preceding copy block. */", "$", "context", "=", "array_slice", "(", "$", "context", ",", "count", "(", "$", "context", ")", "-", "$", "nlead", ")", ";", "$", "x0", "=", "$", "xi", "-", "count", "(", "$", "context", ")", ";", "$", "y0", "=", "$", "yi", "-", "count", "(", "$", "context", ")", ";", "$", "block", "=", "array", "(", ")", ";", "if", "(", "$", "context", ")", "{", "$", "block", "[", "]", "=", "new", "Text_Diff_Op_copy", "(", "$", "context", ")", ";", "}", "}", "$", "block", "[", "]", "=", "$", "edit", ";", "}", "if", "(", "$", "edit", "->", "orig", ")", "{", "$", "xi", "+=", "count", "(", "$", "edit", "->", "orig", ")", ";", "}", "if", "(", "$", "edit", "->", "final", ")", "{", "$", "yi", "+=", "count", "(", "$", "edit", "->", "final", ")", ";", "}", "}", "if", "(", "is_array", "(", "$", "block", ")", ")", "{", "$", "output", ".=", "$", "this", "->", "_block", "(", "$", "x0", ",", "$", "xi", "-", "$", "x0", ",", "$", "y0", ",", "$", "yi", "-", "$", "y0", ",", "$", "block", ")", ";", "}", "return", "$", "output", ".", "$", "this", "->", "_endDiff", "(", ")", ";", "}" ]
Renders a diff. @param Text_Diff $diff A Text_Diff object. @return string The formatted output.
[ "Renders", "a", "diff", "." ]
af3cbce71db83c4476c8a4289517b2984c740f31
https://github.com/yiisoft/yii/blob/af3cbce71db83c4476c8a4289517b2984c740f31/framework/gii/components/Pear/Text/Diff/Renderer.php#L72-L144
train
yiisoft/yii
framework/web/widgets/CTextHighlighter.php
CTextHighlighter.highlight
public function highlight($content) { $this->registerClientScript(); $options['use_language']=true; $options['tabsize']=$this->tabSize; if($this->showLineNumbers) $options['numbers']=($this->lineNumberStyle==='list')?HL_NUMBERS_LI:HL_NUMBERS_TABLE; $highlighter=empty($this->language)?false:Text_Highlighter::factory($this->language); if($highlighter===false) $o='<pre>'.CHtml::encode($content).'</pre>'; else { $highlighter->setRenderer(new Text_Highlighter_Renderer_Html($options)); $o=preg_replace('/<span\s+[^>]*>(\s*)<\/span>/','\1',$highlighter->highlight($content)); } return CHtml::tag('div',$this->containerOptions,$o); }
php
public function highlight($content) { $this->registerClientScript(); $options['use_language']=true; $options['tabsize']=$this->tabSize; if($this->showLineNumbers) $options['numbers']=($this->lineNumberStyle==='list')?HL_NUMBERS_LI:HL_NUMBERS_TABLE; $highlighter=empty($this->language)?false:Text_Highlighter::factory($this->language); if($highlighter===false) $o='<pre>'.CHtml::encode($content).'</pre>'; else { $highlighter->setRenderer(new Text_Highlighter_Renderer_Html($options)); $o=preg_replace('/<span\s+[^>]*>(\s*)<\/span>/','\1',$highlighter->highlight($content)); } return CHtml::tag('div',$this->containerOptions,$o); }
[ "public", "function", "highlight", "(", "$", "content", ")", "{", "$", "this", "->", "registerClientScript", "(", ")", ";", "$", "options", "[", "'use_language'", "]", "=", "true", ";", "$", "options", "[", "'tabsize'", "]", "=", "$", "this", "->", "tabSize", ";", "if", "(", "$", "this", "->", "showLineNumbers", ")", "$", "options", "[", "'numbers'", "]", "=", "(", "$", "this", "->", "lineNumberStyle", "===", "'list'", ")", "?", "HL_NUMBERS_LI", ":", "HL_NUMBERS_TABLE", ";", "$", "highlighter", "=", "empty", "(", "$", "this", "->", "language", ")", "?", "false", ":", "Text_Highlighter", "::", "factory", "(", "$", "this", "->", "language", ")", ";", "if", "(", "$", "highlighter", "===", "false", ")", "$", "o", "=", "'<pre>'", ".", "CHtml", "::", "encode", "(", "$", "content", ")", ".", "'</pre>'", ";", "else", "{", "$", "highlighter", "->", "setRenderer", "(", "new", "Text_Highlighter_Renderer_Html", "(", "$", "options", ")", ")", ";", "$", "o", "=", "preg_replace", "(", "'/<span\\s+[^>]*>(\\s*)<\\/span>/'", ",", "'\\1'", ",", "$", "highlighter", "->", "highlight", "(", "$", "content", ")", ")", ";", "}", "return", "CHtml", "::", "tag", "(", "'div'", ",", "$", "this", "->", "containerOptions", ",", "$", "o", ")", ";", "}" ]
Highlights the content by the syntax of the specified language. @param string $content the content to be highlighted. @return string the highlighted content
[ "Highlights", "the", "content", "by", "the", "syntax", "of", "the", "specified", "language", "." ]
af3cbce71db83c4476c8a4289517b2984c740f31
https://github.com/yiisoft/yii/blob/af3cbce71db83c4476c8a4289517b2984c740f31/framework/web/widgets/CTextHighlighter.php#L84-L103
train
yiisoft/yii
framework/base/CErrorHandler.php
CErrorHandler.handleException
protected function handleException($exception) { $app=Yii::app(); if($app instanceof CWebApplication) { if(($trace=$this->getExactTrace($exception))===null) { $fileName=$exception->getFile(); $errorLine=$exception->getLine(); } else { $fileName=$trace['file']; $errorLine=$trace['line']; } $trace = $exception->getTrace(); foreach($trace as $i=>$t) { if(!isset($t['file'])) $trace[$i]['file']='unknown'; if(!isset($t['line'])) $trace[$i]['line']=0; if(!isset($t['function'])) $trace[$i]['function']='unknown'; unset($trace[$i]['object']); } $this->_exception=$exception; $this->_error=$data=array( 'code'=>($exception instanceof CHttpException)?$exception->statusCode:500, 'type'=>get_class($exception), 'errorCode'=>$exception->getCode(), 'message'=>$exception->getMessage(), 'file'=>$fileName, 'line'=>$errorLine, 'trace'=>$exception->getTraceAsString(), 'traces'=>$trace, ); if(!headers_sent()) { $httpVersion=Yii::app()->request->getHttpVersion(); header("HTTP/$httpVersion {$data['code']} ".$this->getHttpHeader($data['code'], get_class($exception))); } $this->renderException(); } else $app->displayException($exception); }
php
protected function handleException($exception) { $app=Yii::app(); if($app instanceof CWebApplication) { if(($trace=$this->getExactTrace($exception))===null) { $fileName=$exception->getFile(); $errorLine=$exception->getLine(); } else { $fileName=$trace['file']; $errorLine=$trace['line']; } $trace = $exception->getTrace(); foreach($trace as $i=>$t) { if(!isset($t['file'])) $trace[$i]['file']='unknown'; if(!isset($t['line'])) $trace[$i]['line']=0; if(!isset($t['function'])) $trace[$i]['function']='unknown'; unset($trace[$i]['object']); } $this->_exception=$exception; $this->_error=$data=array( 'code'=>($exception instanceof CHttpException)?$exception->statusCode:500, 'type'=>get_class($exception), 'errorCode'=>$exception->getCode(), 'message'=>$exception->getMessage(), 'file'=>$fileName, 'line'=>$errorLine, 'trace'=>$exception->getTraceAsString(), 'traces'=>$trace, ); if(!headers_sent()) { $httpVersion=Yii::app()->request->getHttpVersion(); header("HTTP/$httpVersion {$data['code']} ".$this->getHttpHeader($data['code'], get_class($exception))); } $this->renderException(); } else $app->displayException($exception); }
[ "protected", "function", "handleException", "(", "$", "exception", ")", "{", "$", "app", "=", "Yii", "::", "app", "(", ")", ";", "if", "(", "$", "app", "instanceof", "CWebApplication", ")", "{", "if", "(", "(", "$", "trace", "=", "$", "this", "->", "getExactTrace", "(", "$", "exception", ")", ")", "===", "null", ")", "{", "$", "fileName", "=", "$", "exception", "->", "getFile", "(", ")", ";", "$", "errorLine", "=", "$", "exception", "->", "getLine", "(", ")", ";", "}", "else", "{", "$", "fileName", "=", "$", "trace", "[", "'file'", "]", ";", "$", "errorLine", "=", "$", "trace", "[", "'line'", "]", ";", "}", "$", "trace", "=", "$", "exception", "->", "getTrace", "(", ")", ";", "foreach", "(", "$", "trace", "as", "$", "i", "=>", "$", "t", ")", "{", "if", "(", "!", "isset", "(", "$", "t", "[", "'file'", "]", ")", ")", "$", "trace", "[", "$", "i", "]", "[", "'file'", "]", "=", "'unknown'", ";", "if", "(", "!", "isset", "(", "$", "t", "[", "'line'", "]", ")", ")", "$", "trace", "[", "$", "i", "]", "[", "'line'", "]", "=", "0", ";", "if", "(", "!", "isset", "(", "$", "t", "[", "'function'", "]", ")", ")", "$", "trace", "[", "$", "i", "]", "[", "'function'", "]", "=", "'unknown'", ";", "unset", "(", "$", "trace", "[", "$", "i", "]", "[", "'object'", "]", ")", ";", "}", "$", "this", "->", "_exception", "=", "$", "exception", ";", "$", "this", "->", "_error", "=", "$", "data", "=", "array", "(", "'code'", "=>", "(", "$", "exception", "instanceof", "CHttpException", ")", "?", "$", "exception", "->", "statusCode", ":", "500", ",", "'type'", "=>", "get_class", "(", "$", "exception", ")", ",", "'errorCode'", "=>", "$", "exception", "->", "getCode", "(", ")", ",", "'message'", "=>", "$", "exception", "->", "getMessage", "(", ")", ",", "'file'", "=>", "$", "fileName", ",", "'line'", "=>", "$", "errorLine", ",", "'trace'", "=>", "$", "exception", "->", "getTraceAsString", "(", ")", ",", "'traces'", "=>", "$", "trace", ",", ")", ";", "if", "(", "!", "headers_sent", "(", ")", ")", "{", "$", "httpVersion", "=", "Yii", "::", "app", "(", ")", "->", "request", "->", "getHttpVersion", "(", ")", ";", "header", "(", "\"HTTP/$httpVersion {$data['code']} \"", ".", "$", "this", "->", "getHttpHeader", "(", "$", "data", "[", "'code'", "]", ",", "get_class", "(", "$", "exception", ")", ")", ")", ";", "}", "$", "this", "->", "renderException", "(", ")", ";", "}", "else", "$", "app", "->", "displayException", "(", "$", "exception", ")", ";", "}" ]
Handles the exception. @param Exception $exception the exception captured
[ "Handles", "the", "exception", "." ]
af3cbce71db83c4476c8a4289517b2984c740f31
https://github.com/yiisoft/yii/blob/af3cbce71db83c4476c8a4289517b2984c740f31/framework/base/CErrorHandler.php#L168-L222
train
yiisoft/yii
framework/base/CErrorHandler.php
CErrorHandler.getExactTrace
protected function getExactTrace($exception) { $traces=$exception->getTrace(); foreach($traces as $trace) { // property access exception if(isset($trace['function']) && ($trace['function']==='__get' || $trace['function']==='__set')) return $trace; } return null; }
php
protected function getExactTrace($exception) { $traces=$exception->getTrace(); foreach($traces as $trace) { // property access exception if(isset($trace['function']) && ($trace['function']==='__get' || $trace['function']==='__set')) return $trace; } return null; }
[ "protected", "function", "getExactTrace", "(", "$", "exception", ")", "{", "$", "traces", "=", "$", "exception", "->", "getTrace", "(", ")", ";", "foreach", "(", "$", "traces", "as", "$", "trace", ")", "{", "// property access exception", "if", "(", "isset", "(", "$", "trace", "[", "'function'", "]", ")", "&&", "(", "$", "trace", "[", "'function'", "]", "===", "'__get'", "||", "$", "trace", "[", "'function'", "]", "===", "'__set'", ")", ")", "return", "$", "trace", ";", "}", "return", "null", ";", "}" ]
Returns the exact trace where the problem occurs. @param Exception $exception the uncaught exception @return array the exact trace where the problem occurs
[ "Returns", "the", "exact", "trace", "where", "the", "problem", "occurs", "." ]
af3cbce71db83c4476c8a4289517b2984c740f31
https://github.com/yiisoft/yii/blob/af3cbce71db83c4476c8a4289517b2984c740f31/framework/base/CErrorHandler.php#L316-L327
train
yiisoft/yii
framework/base/CErrorHandler.php
CErrorHandler.getViewFile
protected function getViewFile($view,$code) { $viewPaths=array( Yii::app()->getTheme()===null ? null : Yii::app()->getTheme()->getSystemViewPath(), Yii::app() instanceof CWebApplication ? Yii::app()->getSystemViewPath() : null, YII_PATH.DIRECTORY_SEPARATOR.'views', ); foreach($viewPaths as $i=>$viewPath) { if($viewPath!==null) { $viewFile=$this->getViewFileInternal($viewPath,$view,$code,$i===2?'en_us':null); if(is_file($viewFile)) return $viewFile; } } }
php
protected function getViewFile($view,$code) { $viewPaths=array( Yii::app()->getTheme()===null ? null : Yii::app()->getTheme()->getSystemViewPath(), Yii::app() instanceof CWebApplication ? Yii::app()->getSystemViewPath() : null, YII_PATH.DIRECTORY_SEPARATOR.'views', ); foreach($viewPaths as $i=>$viewPath) { if($viewPath!==null) { $viewFile=$this->getViewFileInternal($viewPath,$view,$code,$i===2?'en_us':null); if(is_file($viewFile)) return $viewFile; } } }
[ "protected", "function", "getViewFile", "(", "$", "view", ",", "$", "code", ")", "{", "$", "viewPaths", "=", "array", "(", "Yii", "::", "app", "(", ")", "->", "getTheme", "(", ")", "===", "null", "?", "null", ":", "Yii", "::", "app", "(", ")", "->", "getTheme", "(", ")", "->", "getSystemViewPath", "(", ")", ",", "Yii", "::", "app", "(", ")", "instanceof", "CWebApplication", "?", "Yii", "::", "app", "(", ")", "->", "getSystemViewPath", "(", ")", ":", "null", ",", "YII_PATH", ".", "DIRECTORY_SEPARATOR", ".", "'views'", ",", ")", ";", "foreach", "(", "$", "viewPaths", "as", "$", "i", "=>", "$", "viewPath", ")", "{", "if", "(", "$", "viewPath", "!==", "null", ")", "{", "$", "viewFile", "=", "$", "this", "->", "getViewFileInternal", "(", "$", "viewPath", ",", "$", "view", ",", "$", "code", ",", "$", "i", "===", "2", "?", "'en_us'", ":", "null", ")", ";", "if", "(", "is_file", "(", "$", "viewFile", ")", ")", "return", "$", "viewFile", ";", "}", "}", "}" ]
Determines which view file should be used. @param string $view view name (either 'exception' or 'error') @param integer $code HTTP status code @return string view file path
[ "Determines", "which", "view", "file", "should", "be", "used", "." ]
af3cbce71db83c4476c8a4289517b2984c740f31
https://github.com/yiisoft/yii/blob/af3cbce71db83c4476c8a4289517b2984c740f31/framework/base/CErrorHandler.php#L387-L404
train
yiisoft/yii
framework/base/CErrorHandler.php
CErrorHandler.getViewFileInternal
protected function getViewFileInternal($viewPath,$view,$code,$srcLanguage=null) { $app=Yii::app(); if($view==='error') { $viewFile=$app->findLocalizedFile($viewPath.DIRECTORY_SEPARATOR."error{$code}.php",$srcLanguage); if(!is_file($viewFile)) $viewFile=$app->findLocalizedFile($viewPath.DIRECTORY_SEPARATOR.'error.php',$srcLanguage); } else $viewFile=$viewPath.DIRECTORY_SEPARATOR."exception.php"; return $viewFile; }
php
protected function getViewFileInternal($viewPath,$view,$code,$srcLanguage=null) { $app=Yii::app(); if($view==='error') { $viewFile=$app->findLocalizedFile($viewPath.DIRECTORY_SEPARATOR."error{$code}.php",$srcLanguage); if(!is_file($viewFile)) $viewFile=$app->findLocalizedFile($viewPath.DIRECTORY_SEPARATOR.'error.php',$srcLanguage); } else $viewFile=$viewPath.DIRECTORY_SEPARATOR."exception.php"; return $viewFile; }
[ "protected", "function", "getViewFileInternal", "(", "$", "viewPath", ",", "$", "view", ",", "$", "code", ",", "$", "srcLanguage", "=", "null", ")", "{", "$", "app", "=", "Yii", "::", "app", "(", ")", ";", "if", "(", "$", "view", "===", "'error'", ")", "{", "$", "viewFile", "=", "$", "app", "->", "findLocalizedFile", "(", "$", "viewPath", ".", "DIRECTORY_SEPARATOR", ".", "\"error{$code}.php\"", ",", "$", "srcLanguage", ")", ";", "if", "(", "!", "is_file", "(", "$", "viewFile", ")", ")", "$", "viewFile", "=", "$", "app", "->", "findLocalizedFile", "(", "$", "viewPath", ".", "DIRECTORY_SEPARATOR", ".", "'error.php'", ",", "$", "srcLanguage", ")", ";", "}", "else", "$", "viewFile", "=", "$", "viewPath", ".", "DIRECTORY_SEPARATOR", ".", "\"exception.php\"", ";", "return", "$", "viewFile", ";", "}" ]
Looks for the view under the specified directory. @param string $viewPath the directory containing the views @param string $view view name (either 'exception' or 'error') @param integer $code HTTP status code @param string $srcLanguage the language that the view file is in @return string view file path
[ "Looks", "for", "the", "view", "under", "the", "specified", "directory", "." ]
af3cbce71db83c4476c8a4289517b2984c740f31
https://github.com/yiisoft/yii/blob/af3cbce71db83c4476c8a4289517b2984c740f31/framework/base/CErrorHandler.php#L414-L426
train
yiisoft/yii
framework/base/CErrorHandler.php
CErrorHandler.getVersionInfo
protected function getVersionInfo() { if(YII_DEBUG) { $version='<a href="http://www.yiiframework.com/">Yii Framework</a>/'.Yii::getVersion(); if(isset($_SERVER['SERVER_SOFTWARE'])) $version=$_SERVER['SERVER_SOFTWARE'].' '.$version; } else $version=''; return $version; }
php
protected function getVersionInfo() { if(YII_DEBUG) { $version='<a href="http://www.yiiframework.com/">Yii Framework</a>/'.Yii::getVersion(); if(isset($_SERVER['SERVER_SOFTWARE'])) $version=$_SERVER['SERVER_SOFTWARE'].' '.$version; } else $version=''; return $version; }
[ "protected", "function", "getVersionInfo", "(", ")", "{", "if", "(", "YII_DEBUG", ")", "{", "$", "version", "=", "'<a href=\"http://www.yiiframework.com/\">Yii Framework</a>/'", ".", "Yii", "::", "getVersion", "(", ")", ";", "if", "(", "isset", "(", "$", "_SERVER", "[", "'SERVER_SOFTWARE'", "]", ")", ")", "$", "version", "=", "$", "_SERVER", "[", "'SERVER_SOFTWARE'", "]", ".", "' '", ".", "$", "version", ";", "}", "else", "$", "version", "=", "''", ";", "return", "$", "version", ";", "}" ]
Returns server version information. If the application is in production mode, empty string is returned. @return string server version information. Empty if in production mode.
[ "Returns", "server", "version", "information", ".", "If", "the", "application", "is", "in", "production", "mode", "empty", "string", "is", "returned", "." ]
af3cbce71db83c4476c8a4289517b2984c740f31
https://github.com/yiisoft/yii/blob/af3cbce71db83c4476c8a4289517b2984c740f31/framework/base/CErrorHandler.php#L433-L444
train
yiisoft/yii
framework/base/CErrorHandler.php
CErrorHandler.isCoreCode
protected function isCoreCode($trace) { if(isset($trace['file'])) { $systemPath=realpath(dirname(__FILE__).'/..'); return $trace['file']==='unknown' || strpos(realpath($trace['file']),$systemPath.DIRECTORY_SEPARATOR)===0; } return false; }
php
protected function isCoreCode($trace) { if(isset($trace['file'])) { $systemPath=realpath(dirname(__FILE__).'/..'); return $trace['file']==='unknown' || strpos(realpath($trace['file']),$systemPath.DIRECTORY_SEPARATOR)===0; } return false; }
[ "protected", "function", "isCoreCode", "(", "$", "trace", ")", "{", "if", "(", "isset", "(", "$", "trace", "[", "'file'", "]", ")", ")", "{", "$", "systemPath", "=", "realpath", "(", "dirname", "(", "__FILE__", ")", ".", "'/..'", ")", ";", "return", "$", "trace", "[", "'file'", "]", "===", "'unknown'", "||", "strpos", "(", "realpath", "(", "$", "trace", "[", "'file'", "]", ")", ",", "$", "systemPath", ".", "DIRECTORY_SEPARATOR", ")", "===", "0", ";", "}", "return", "false", ";", "}" ]
Returns a value indicating whether the call stack is from application code. @param array $trace the trace data @return boolean whether the call stack is from application code.
[ "Returns", "a", "value", "indicating", "whether", "the", "call", "stack", "is", "from", "application", "code", "." ]
af3cbce71db83c4476c8a4289517b2984c740f31
https://github.com/yiisoft/yii/blob/af3cbce71db83c4476c8a4289517b2984c740f31/framework/base/CErrorHandler.php#L507-L515
train
yiisoft/yii
framework/base/CErrorHandler.php
CErrorHandler.renderSourceCode
protected function renderSourceCode($file,$errorLine,$maxLines) { $errorLine--; // adjust line number to 0-based from 1-based if($errorLine<0 || ($lines=@file($file))===false || ($lineCount=count($lines))<=$errorLine) return ''; $halfLines=(int)($maxLines/2); $beginLine=$errorLine-$halfLines>0 ? $errorLine-$halfLines:0; $endLine=$errorLine+$halfLines<$lineCount?$errorLine+$halfLines:$lineCount-1; $lineNumberWidth=strlen($endLine+1); $output=''; for($i=$beginLine;$i<=$endLine;++$i) { $isErrorLine = $i===$errorLine; $code=sprintf("<span class=\"ln".($isErrorLine?' error-ln':'')."\">%0{$lineNumberWidth}d</span> %s",$i+1,CHtml::encode(str_replace("\t",' ',$lines[$i]))); if(!$isErrorLine) $output.=$code; else $output.='<span class="error">'.$code.'</span>'; } return '<div class="code"><pre>'.$output.'</pre></div>'; }
php
protected function renderSourceCode($file,$errorLine,$maxLines) { $errorLine--; // adjust line number to 0-based from 1-based if($errorLine<0 || ($lines=@file($file))===false || ($lineCount=count($lines))<=$errorLine) return ''; $halfLines=(int)($maxLines/2); $beginLine=$errorLine-$halfLines>0 ? $errorLine-$halfLines:0; $endLine=$errorLine+$halfLines<$lineCount?$errorLine+$halfLines:$lineCount-1; $lineNumberWidth=strlen($endLine+1); $output=''; for($i=$beginLine;$i<=$endLine;++$i) { $isErrorLine = $i===$errorLine; $code=sprintf("<span class=\"ln".($isErrorLine?' error-ln':'')."\">%0{$lineNumberWidth}d</span> %s",$i+1,CHtml::encode(str_replace("\t",' ',$lines[$i]))); if(!$isErrorLine) $output.=$code; else $output.='<span class="error">'.$code.'</span>'; } return '<div class="code"><pre>'.$output.'</pre></div>'; }
[ "protected", "function", "renderSourceCode", "(", "$", "file", ",", "$", "errorLine", ",", "$", "maxLines", ")", "{", "$", "errorLine", "--", ";", "// adjust line number to 0-based from 1-based", "if", "(", "$", "errorLine", "<", "0", "||", "(", "$", "lines", "=", "@", "file", "(", "$", "file", ")", ")", "===", "false", "||", "(", "$", "lineCount", "=", "count", "(", "$", "lines", ")", ")", "<=", "$", "errorLine", ")", "return", "''", ";", "$", "halfLines", "=", "(", "int", ")", "(", "$", "maxLines", "/", "2", ")", ";", "$", "beginLine", "=", "$", "errorLine", "-", "$", "halfLines", ">", "0", "?", "$", "errorLine", "-", "$", "halfLines", ":", "0", ";", "$", "endLine", "=", "$", "errorLine", "+", "$", "halfLines", "<", "$", "lineCount", "?", "$", "errorLine", "+", "$", "halfLines", ":", "$", "lineCount", "-", "1", ";", "$", "lineNumberWidth", "=", "strlen", "(", "$", "endLine", "+", "1", ")", ";", "$", "output", "=", "''", ";", "for", "(", "$", "i", "=", "$", "beginLine", ";", "$", "i", "<=", "$", "endLine", ";", "++", "$", "i", ")", "{", "$", "isErrorLine", "=", "$", "i", "===", "$", "errorLine", ";", "$", "code", "=", "sprintf", "(", "\"<span class=\\\"ln\"", ".", "(", "$", "isErrorLine", "?", "' error-ln'", ":", "''", ")", ".", "\"\\\">%0{$lineNumberWidth}d</span> %s\"", ",", "$", "i", "+", "1", ",", "CHtml", "::", "encode", "(", "str_replace", "(", "\"\\t\"", ",", "' '", ",", "$", "lines", "[", "$", "i", "]", ")", ")", ")", ";", "if", "(", "!", "$", "isErrorLine", ")", "$", "output", ".=", "$", "code", ";", "else", "$", "output", ".=", "'<span class=\"error\">'", ".", "$", "code", ".", "'</span>'", ";", "}", "return", "'<div class=\"code\"><pre>'", ".", "$", "output", ".", "'</pre></div>'", ";", "}" ]
Renders the source code around the error line. @param string $file source file path @param integer $errorLine the error line number @param integer $maxLines maximum number of lines to display @return string the rendering result
[ "Renders", "the", "source", "code", "around", "the", "error", "line", "." ]
af3cbce71db83c4476c8a4289517b2984c740f31
https://github.com/yiisoft/yii/blob/af3cbce71db83c4476c8a4289517b2984c740f31/framework/base/CErrorHandler.php#L524-L546
train
yiisoft/yii
framework/web/widgets/CMultiFileUpload.php
CMultiFileUpload.run
public function run() { list($name,$id)=$this->resolveNameID(); if(substr($name,-2)!=='[]') $name.='[]'; if(isset($this->htmlOptions['id'])) $id=$this->htmlOptions['id']; else $this->htmlOptions['id']=$id; $this->registerClientScript(); echo CHtml::fileField($name,'',$this->htmlOptions); }
php
public function run() { list($name,$id)=$this->resolveNameID(); if(substr($name,-2)!=='[]') $name.='[]'; if(isset($this->htmlOptions['id'])) $id=$this->htmlOptions['id']; else $this->htmlOptions['id']=$id; $this->registerClientScript(); echo CHtml::fileField($name,'',$this->htmlOptions); }
[ "public", "function", "run", "(", ")", "{", "list", "(", "$", "name", ",", "$", "id", ")", "=", "$", "this", "->", "resolveNameID", "(", ")", ";", "if", "(", "substr", "(", "$", "name", ",", "-", "2", ")", "!==", "'[]'", ")", "$", "name", ".=", "'[]'", ";", "if", "(", "isset", "(", "$", "this", "->", "htmlOptions", "[", "'id'", "]", ")", ")", "$", "id", "=", "$", "this", "->", "htmlOptions", "[", "'id'", "]", ";", "else", "$", "this", "->", "htmlOptions", "[", "'id'", "]", "=", "$", "id", ";", "$", "this", "->", "registerClientScript", "(", ")", ";", "echo", "CHtml", "::", "fileField", "(", "$", "name", ",", "''", ",", "$", "this", "->", "htmlOptions", ")", ";", "}" ]
Runs the widget. This method registers all needed client scripts and renders the multiple file uploader.
[ "Runs", "the", "widget", ".", "This", "method", "registers", "all", "needed", "client", "scripts", "and", "renders", "the", "multiple", "file", "uploader", "." ]
af3cbce71db83c4476c8a4289517b2984c740f31
https://github.com/yiisoft/yii/blob/af3cbce71db83c4476c8a4289517b2984c740f31/framework/web/widgets/CMultiFileUpload.php#L85-L96
train
yiisoft/yii
framework/zii/widgets/CListView.php
CListView.renderItems
public function renderItems() { echo CHtml::openTag($this->itemsTagName,array('class'=>$this->itemsCssClass))."\n"; $data=$this->dataProvider->getData(); if(($n=count($data))>0) { $owner=$this->getOwner(); $viewFile=$owner->getViewFile($this->itemView); $j=0; foreach($data as $i=>$item) { $data=$this->viewData; $data['index']=$i; $data['data']=$item; $data['widget']=$this; $owner->renderFile($viewFile,$data); if($j++ < $n-1) echo $this->separator; } } else $this->renderEmptyText(); echo CHtml::closeTag($this->itemsTagName); }
php
public function renderItems() { echo CHtml::openTag($this->itemsTagName,array('class'=>$this->itemsCssClass))."\n"; $data=$this->dataProvider->getData(); if(($n=count($data))>0) { $owner=$this->getOwner(); $viewFile=$owner->getViewFile($this->itemView); $j=0; foreach($data as $i=>$item) { $data=$this->viewData; $data['index']=$i; $data['data']=$item; $data['widget']=$this; $owner->renderFile($viewFile,$data); if($j++ < $n-1) echo $this->separator; } } else $this->renderEmptyText(); echo CHtml::closeTag($this->itemsTagName); }
[ "public", "function", "renderItems", "(", ")", "{", "echo", "CHtml", "::", "openTag", "(", "$", "this", "->", "itemsTagName", ",", "array", "(", "'class'", "=>", "$", "this", "->", "itemsCssClass", ")", ")", ".", "\"\\n\"", ";", "$", "data", "=", "$", "this", "->", "dataProvider", "->", "getData", "(", ")", ";", "if", "(", "(", "$", "n", "=", "count", "(", "$", "data", ")", ")", ">", "0", ")", "{", "$", "owner", "=", "$", "this", "->", "getOwner", "(", ")", ";", "$", "viewFile", "=", "$", "owner", "->", "getViewFile", "(", "$", "this", "->", "itemView", ")", ";", "$", "j", "=", "0", ";", "foreach", "(", "$", "data", "as", "$", "i", "=>", "$", "item", ")", "{", "$", "data", "=", "$", "this", "->", "viewData", ";", "$", "data", "[", "'index'", "]", "=", "$", "i", ";", "$", "data", "[", "'data'", "]", "=", "$", "item", ";", "$", "data", "[", "'widget'", "]", "=", "$", "this", ";", "$", "owner", "->", "renderFile", "(", "$", "viewFile", ",", "$", "data", ")", ";", "if", "(", "$", "j", "++", "<", "$", "n", "-", "1", ")", "echo", "$", "this", "->", "separator", ";", "}", "}", "else", "$", "this", "->", "renderEmptyText", "(", ")", ";", "echo", "CHtml", "::", "closeTag", "(", "$", "this", "->", "itemsTagName", ")", ";", "}" ]
Renders the data item list.
[ "Renders", "the", "data", "item", "list", "." ]
af3cbce71db83c4476c8a4289517b2984c740f31
https://github.com/yiisoft/yii/blob/af3cbce71db83c4476c8a4289517b2984c740f31/framework/zii/widgets/CListView.php#L276-L299
train
yiisoft/yii
framework/zii/widgets/CListView.php
CListView.renderSorter
public function renderSorter() { if($this->dataProvider->getItemCount()<=0 || !$this->enableSorting || empty($this->sortableAttributes)) return; echo CHtml::openTag('div',array('class'=>$this->sorterCssClass))."\n"; echo $this->sorterHeader===null ? Yii::t('zii','Sort by: ') : $this->sorterHeader; echo "<ul>\n"; $sort=$this->dataProvider->getSort(); foreach($this->sortableAttributes as $name=>$label) { echo "<li>"; if(is_integer($name)) echo $sort->link($label); else echo $sort->link($name,$label); echo "</li>\n"; } echo "</ul>"; echo $this->sorterFooter; echo CHtml::closeTag('div'); }
php
public function renderSorter() { if($this->dataProvider->getItemCount()<=0 || !$this->enableSorting || empty($this->sortableAttributes)) return; echo CHtml::openTag('div',array('class'=>$this->sorterCssClass))."\n"; echo $this->sorterHeader===null ? Yii::t('zii','Sort by: ') : $this->sorterHeader; echo "<ul>\n"; $sort=$this->dataProvider->getSort(); foreach($this->sortableAttributes as $name=>$label) { echo "<li>"; if(is_integer($name)) echo $sort->link($label); else echo $sort->link($name,$label); echo "</li>\n"; } echo "</ul>"; echo $this->sorterFooter; echo CHtml::closeTag('div'); }
[ "public", "function", "renderSorter", "(", ")", "{", "if", "(", "$", "this", "->", "dataProvider", "->", "getItemCount", "(", ")", "<=", "0", "||", "!", "$", "this", "->", "enableSorting", "||", "empty", "(", "$", "this", "->", "sortableAttributes", ")", ")", "return", ";", "echo", "CHtml", "::", "openTag", "(", "'div'", ",", "array", "(", "'class'", "=>", "$", "this", "->", "sorterCssClass", ")", ")", ".", "\"\\n\"", ";", "echo", "$", "this", "->", "sorterHeader", "===", "null", "?", "Yii", "::", "t", "(", "'zii'", ",", "'Sort by: '", ")", ":", "$", "this", "->", "sorterHeader", ";", "echo", "\"<ul>\\n\"", ";", "$", "sort", "=", "$", "this", "->", "dataProvider", "->", "getSort", "(", ")", ";", "foreach", "(", "$", "this", "->", "sortableAttributes", "as", "$", "name", "=>", "$", "label", ")", "{", "echo", "\"<li>\"", ";", "if", "(", "is_integer", "(", "$", "name", ")", ")", "echo", "$", "sort", "->", "link", "(", "$", "label", ")", ";", "else", "echo", "$", "sort", "->", "link", "(", "$", "name", ",", "$", "label", ")", ";", "echo", "\"</li>\\n\"", ";", "}", "echo", "\"</ul>\"", ";", "echo", "$", "this", "->", "sorterFooter", ";", "echo", "CHtml", "::", "closeTag", "(", "'div'", ")", ";", "}" ]
Renders the sorter.
[ "Renders", "the", "sorter", "." ]
af3cbce71db83c4476c8a4289517b2984c740f31
https://github.com/yiisoft/yii/blob/af3cbce71db83c4476c8a4289517b2984c740f31/framework/zii/widgets/CListView.php#L304-L324
train
yiisoft/yii
build/commands/lite/protected/components/UserIdentity.php
UserIdentity.authenticate
public function authenticate() { if($this->username==='demo' && $this->password==='demo') $this->errorCode=self::ERROR_NONE; else $this->errorCode=self::ERROR_PASSWORD_INVALID; return !$this->errorCode; }
php
public function authenticate() { if($this->username==='demo' && $this->password==='demo') $this->errorCode=self::ERROR_NONE; else $this->errorCode=self::ERROR_PASSWORD_INVALID; return !$this->errorCode; }
[ "public", "function", "authenticate", "(", ")", "{", "if", "(", "$", "this", "->", "username", "===", "'demo'", "&&", "$", "this", "->", "password", "===", "'demo'", ")", "$", "this", "->", "errorCode", "=", "self", "::", "ERROR_NONE", ";", "else", "$", "this", "->", "errorCode", "=", "self", "::", "ERROR_PASSWORD_INVALID", ";", "return", "!", "$", "this", "->", "errorCode", ";", "}" ]
Validates the username and password. This method should check the validity of the provided username and password in some way. In case of any authentication failure, set errorCode and errorMessage with appropriate values and return false. @param string username @param string password @return boolean whether the username and password are valid
[ "Validates", "the", "username", "and", "password", ".", "This", "method", "should", "check", "the", "validity", "of", "the", "provided", "username", "and", "password", "in", "some", "way", ".", "In", "case", "of", "any", "authentication", "failure", "set", "errorCode", "and", "errorMessage", "with", "appropriate", "values", "and", "return", "false", "." ]
af3cbce71db83c4476c8a4289517b2984c740f31
https://github.com/yiisoft/yii/blob/af3cbce71db83c4476c8a4289517b2984c740f31/build/commands/lite/protected/components/UserIdentity.php#L19-L26
train
yiisoft/yii
framework/web/widgets/CAutoComplete.php
CAutoComplete.init
public function init() { list($name,$id)=$this->resolveNameID(); if(isset($this->htmlOptions['id'])) $id=$this->htmlOptions['id']; else $this->htmlOptions['id']=$id; if(isset($this->htmlOptions['name'])) $name=$this->htmlOptions['name']; $this->registerClientScript(); if($this->hasModel()) { $field=$this->textArea ? 'activeTextArea' : 'activeTextField'; echo CHtml::$field($this->model,$this->attribute,$this->htmlOptions); } else { $field=$this->textArea ? 'textArea' : 'textField'; echo CHtml::$field($name,$this->value,$this->htmlOptions); } }
php
public function init() { list($name,$id)=$this->resolveNameID(); if(isset($this->htmlOptions['id'])) $id=$this->htmlOptions['id']; else $this->htmlOptions['id']=$id; if(isset($this->htmlOptions['name'])) $name=$this->htmlOptions['name']; $this->registerClientScript(); if($this->hasModel()) { $field=$this->textArea ? 'activeTextArea' : 'activeTextField'; echo CHtml::$field($this->model,$this->attribute,$this->htmlOptions); } else { $field=$this->textArea ? 'textArea' : 'textField'; echo CHtml::$field($name,$this->value,$this->htmlOptions); } }
[ "public", "function", "init", "(", ")", "{", "list", "(", "$", "name", ",", "$", "id", ")", "=", "$", "this", "->", "resolveNameID", "(", ")", ";", "if", "(", "isset", "(", "$", "this", "->", "htmlOptions", "[", "'id'", "]", ")", ")", "$", "id", "=", "$", "this", "->", "htmlOptions", "[", "'id'", "]", ";", "else", "$", "this", "->", "htmlOptions", "[", "'id'", "]", "=", "$", "id", ";", "if", "(", "isset", "(", "$", "this", "->", "htmlOptions", "[", "'name'", "]", ")", ")", "$", "name", "=", "$", "this", "->", "htmlOptions", "[", "'name'", "]", ";", "$", "this", "->", "registerClientScript", "(", ")", ";", "if", "(", "$", "this", "->", "hasModel", "(", ")", ")", "{", "$", "field", "=", "$", "this", "->", "textArea", "?", "'activeTextArea'", ":", "'activeTextField'", ";", "echo", "CHtml", "::", "$", "field", "(", "$", "this", "->", "model", ",", "$", "this", "->", "attribute", ",", "$", "this", "->", "htmlOptions", ")", ";", "}", "else", "{", "$", "field", "=", "$", "this", "->", "textArea", "?", "'textArea'", ":", "'textField'", ";", "echo", "CHtml", "::", "$", "field", "(", "$", "name", ",", "$", "this", "->", "value", ",", "$", "this", "->", "htmlOptions", ")", ";", "}", "}" ]
Initializes the widget. This method registers all needed client scripts and renders the autocomplete input.
[ "Initializes", "the", "widget", ".", "This", "method", "registers", "all", "needed", "client", "scripts", "and", "renders", "the", "autocomplete", "input", "." ]
af3cbce71db83c4476c8a4289517b2984c740f31
https://github.com/yiisoft/yii/blob/af3cbce71db83c4476c8a4289517b2984c740f31/framework/web/widgets/CAutoComplete.php#L201-L223
train
yiisoft/yii
framework/i18n/gettext/CGettextMoFile.php
CGettextMoFile.save
public function save($file,$messages) { if(!($fw=@fopen($file,'wb'))) throw new CException(Yii::t('yii','Unable to write file "{file}".', array('{file}'=>$file))); if(!@flock($fw,LOCK_EX)) throw new CException(Yii::t('yii','Unable to lock file "{file}" for writing.', array('{file}'=>$file))); // magic if($this->useBigEndian) $this->writeByte($fw,pack('c*', 0x95, 0x04, 0x12, 0xde)); else $this->writeByte($fw,pack('c*', 0xde, 0x12, 0x04, 0x95)); // revision $this->writeInteger($fw,0); // message count $n=count($messages); $this->writeInteger($fw,$n); // offset of source message table $offset=28; $this->writeInteger($fw,$offset); $offset+=($n*8); $this->writeInteger($fw,$offset); // hashtable size, omitted $this->writeInteger($fw,0); $offset+=($n*8); $this->writeInteger($fw,$offset); // length and offsets for source messagess foreach(array_keys($messages) as $id) { $len=strlen($id); $this->writeInteger($fw,$len); $this->writeInteger($fw,$offset); $offset+=$len+1; } // length and offsets for target messagess foreach($messages as $message) { $len=strlen($message); $this->writeInteger($fw,$len); $this->writeInteger($fw,$offset); $offset+=$len+1; } // source messages foreach(array_keys($messages) as $id) $this->writeString($fw,$id); // target messages foreach($messages as $message) $this->writeString($fw,$message); @flock($fw,LOCK_UN); @fclose($fw); }
php
public function save($file,$messages) { if(!($fw=@fopen($file,'wb'))) throw new CException(Yii::t('yii','Unable to write file "{file}".', array('{file}'=>$file))); if(!@flock($fw,LOCK_EX)) throw new CException(Yii::t('yii','Unable to lock file "{file}" for writing.', array('{file}'=>$file))); // magic if($this->useBigEndian) $this->writeByte($fw,pack('c*', 0x95, 0x04, 0x12, 0xde)); else $this->writeByte($fw,pack('c*', 0xde, 0x12, 0x04, 0x95)); // revision $this->writeInteger($fw,0); // message count $n=count($messages); $this->writeInteger($fw,$n); // offset of source message table $offset=28; $this->writeInteger($fw,$offset); $offset+=($n*8); $this->writeInteger($fw,$offset); // hashtable size, omitted $this->writeInteger($fw,0); $offset+=($n*8); $this->writeInteger($fw,$offset); // length and offsets for source messagess foreach(array_keys($messages) as $id) { $len=strlen($id); $this->writeInteger($fw,$len); $this->writeInteger($fw,$offset); $offset+=$len+1; } // length and offsets for target messagess foreach($messages as $message) { $len=strlen($message); $this->writeInteger($fw,$len); $this->writeInteger($fw,$offset); $offset+=$len+1; } // source messages foreach(array_keys($messages) as $id) $this->writeString($fw,$id); // target messages foreach($messages as $message) $this->writeString($fw,$message); @flock($fw,LOCK_UN); @fclose($fw); }
[ "public", "function", "save", "(", "$", "file", ",", "$", "messages", ")", "{", "if", "(", "!", "(", "$", "fw", "=", "@", "fopen", "(", "$", "file", ",", "'wb'", ")", ")", ")", "throw", "new", "CException", "(", "Yii", "::", "t", "(", "'yii'", ",", "'Unable to write file \"{file}\".'", ",", "array", "(", "'{file}'", "=>", "$", "file", ")", ")", ")", ";", "if", "(", "!", "@", "flock", "(", "$", "fw", ",", "LOCK_EX", ")", ")", "throw", "new", "CException", "(", "Yii", "::", "t", "(", "'yii'", ",", "'Unable to lock file \"{file}\" for writing.'", ",", "array", "(", "'{file}'", "=>", "$", "file", ")", ")", ")", ";", "// magic", "if", "(", "$", "this", "->", "useBigEndian", ")", "$", "this", "->", "writeByte", "(", "$", "fw", ",", "pack", "(", "'c*'", ",", "0x95", ",", "0x04", ",", "0x12", ",", "0xde", ")", ")", ";", "else", "$", "this", "->", "writeByte", "(", "$", "fw", ",", "pack", "(", "'c*'", ",", "0xde", ",", "0x12", ",", "0x04", ",", "0x95", ")", ")", ";", "// revision", "$", "this", "->", "writeInteger", "(", "$", "fw", ",", "0", ")", ";", "// message count", "$", "n", "=", "count", "(", "$", "messages", ")", ";", "$", "this", "->", "writeInteger", "(", "$", "fw", ",", "$", "n", ")", ";", "// offset of source message table", "$", "offset", "=", "28", ";", "$", "this", "->", "writeInteger", "(", "$", "fw", ",", "$", "offset", ")", ";", "$", "offset", "+=", "(", "$", "n", "*", "8", ")", ";", "$", "this", "->", "writeInteger", "(", "$", "fw", ",", "$", "offset", ")", ";", "// hashtable size, omitted", "$", "this", "->", "writeInteger", "(", "$", "fw", ",", "0", ")", ";", "$", "offset", "+=", "(", "$", "n", "*", "8", ")", ";", "$", "this", "->", "writeInteger", "(", "$", "fw", ",", "$", "offset", ")", ";", "// length and offsets for source messagess", "foreach", "(", "array_keys", "(", "$", "messages", ")", "as", "$", "id", ")", "{", "$", "len", "=", "strlen", "(", "$", "id", ")", ";", "$", "this", "->", "writeInteger", "(", "$", "fw", ",", "$", "len", ")", ";", "$", "this", "->", "writeInteger", "(", "$", "fw", ",", "$", "offset", ")", ";", "$", "offset", "+=", "$", "len", "+", "1", ";", "}", "// length and offsets for target messagess", "foreach", "(", "$", "messages", "as", "$", "message", ")", "{", "$", "len", "=", "strlen", "(", "$", "message", ")", ";", "$", "this", "->", "writeInteger", "(", "$", "fw", ",", "$", "len", ")", ";", "$", "this", "->", "writeInteger", "(", "$", "fw", ",", "$", "offset", ")", ";", "$", "offset", "+=", "$", "len", "+", "1", ";", "}", "// source messages", "foreach", "(", "array_keys", "(", "$", "messages", ")", "as", "$", "id", ")", "$", "this", "->", "writeString", "(", "$", "fw", ",", "$", "id", ")", ";", "// target messages", "foreach", "(", "$", "messages", "as", "$", "message", ")", "$", "this", "->", "writeString", "(", "$", "fw", ",", "$", "message", ")", ";", "@", "flock", "(", "$", "fw", ",", "LOCK_UN", ")", ";", "@", "fclose", "(", "$", "fw", ")", ";", "}" ]
Saves messages to an MO file. @param string $file file path @param array $messages message translations (message id => translated message). Note if the message has a context, the message id must be prefixed with the context with chr(4) as the separator. @throws CException
[ "Saves", "messages", "to", "an", "MO", "file", "." ]
af3cbce71db83c4476c8a4289517b2984c740f31
https://github.com/yiisoft/yii/blob/af3cbce71db83c4476c8a4289517b2984c740f31/framework/i18n/gettext/CGettextMoFile.php#L143-L204
train
yiisoft/yii
framework/i18n/gettext/CGettextMoFile.php
CGettextMoFile.writeInteger
protected function writeInteger($fw,$data) { return $this->writeByte($fw,pack($this->useBigEndian ? 'N' : 'V', (int)$data)); }
php
protected function writeInteger($fw,$data) { return $this->writeByte($fw,pack($this->useBigEndian ? 'N' : 'V', (int)$data)); }
[ "protected", "function", "writeInteger", "(", "$", "fw", ",", "$", "data", ")", "{", "return", "$", "this", "->", "writeByte", "(", "$", "fw", ",", "pack", "(", "$", "this", "->", "useBigEndian", "?", "'N'", ":", "'V'", ",", "(", "int", ")", "$", "data", ")", ")", ";", "}" ]
Writes a 4-byte integer. @param resource $fw file handle @param integer $data the data @return integer how many bytes are written
[ "Writes", "a", "4", "-", "byte", "integer", "." ]
af3cbce71db83c4476c8a4289517b2984c740f31
https://github.com/yiisoft/yii/blob/af3cbce71db83c4476c8a4289517b2984c740f31/framework/i18n/gettext/CGettextMoFile.php#L247-L250
train
yiisoft/yii
framework/i18n/gettext/CGettextMoFile.php
CGettextMoFile.readString
protected function readString($fr,$length,$offset=null) { if($offset!==null) fseek($fr,$offset); return $this->readByte($fr,$length); }
php
protected function readString($fr,$length,$offset=null) { if($offset!==null) fseek($fr,$offset); return $this->readByte($fr,$length); }
[ "protected", "function", "readString", "(", "$", "fr", ",", "$", "length", ",", "$", "offset", "=", "null", ")", "{", "if", "(", "$", "offset", "!==", "null", ")", "fseek", "(", "$", "fr", ",", "$", "offset", ")", ";", "return", "$", "this", "->", "readByte", "(", "$", "fr", ",", "$", "length", ")", ";", "}" ]
Reads a string. @param resource $fr file handle @param integer $length string length @param integer $offset offset of the string in the file. If null, it reads from the current position. @return string the result
[ "Reads", "a", "string", "." ]
af3cbce71db83c4476c8a4289517b2984c740f31
https://github.com/yiisoft/yii/blob/af3cbce71db83c4476c8a4289517b2984c740f31/framework/i18n/gettext/CGettextMoFile.php#L259-L264
train
yiisoft/yii
framework/utils/CPropertyValue.php
CPropertyValue.ensureArray
public static function ensureArray($value) { if(is_string($value)) { $value = trim($value); $len = strlen($value); if ($len >= 2 && $value[0] == '(' && $value[$len-1] == ')') { try { return eval('return array' . $value . ';'); } catch (ParseError $e) { return array(); } } else return $len>0?array($value):array(); } else return (array)$value; }
php
public static function ensureArray($value) { if(is_string($value)) { $value = trim($value); $len = strlen($value); if ($len >= 2 && $value[0] == '(' && $value[$len-1] == ')') { try { return eval('return array' . $value . ';'); } catch (ParseError $e) { return array(); } } else return $len>0?array($value):array(); } else return (array)$value; }
[ "public", "static", "function", "ensureArray", "(", "$", "value", ")", "{", "if", "(", "is_string", "(", "$", "value", ")", ")", "{", "$", "value", "=", "trim", "(", "$", "value", ")", ";", "$", "len", "=", "strlen", "(", "$", "value", ")", ";", "if", "(", "$", "len", ">=", "2", "&&", "$", "value", "[", "0", "]", "==", "'('", "&&", "$", "value", "[", "$", "len", "-", "1", "]", "==", "')'", ")", "{", "try", "{", "return", "eval", "(", "'return array'", ".", "$", "value", ".", "';'", ")", ";", "}", "catch", "(", "ParseError", "$", "e", ")", "{", "return", "array", "(", ")", ";", "}", "}", "else", "return", "$", "len", ">", "0", "?", "array", "(", "$", "value", ")", ":", "array", "(", ")", ";", "}", "else", "return", "(", "array", ")", "$", "value", ";", "}" ]
Converts a value to array type. If the value is a string and it is in the form (a,b,c) then an array consisting of each of the elements will be returned. If the value is a string and it is not in this form then an array consisting of just the string will be returned, if the string is empty an empty array will be returned. If the value is not a string then it will return an array containing that value or the same value in case it is already an array. @param mixed $value the value to be converted. @return array
[ "Converts", "a", "value", "to", "array", "type", "." ]
af3cbce71db83c4476c8a4289517b2984c740f31
https://github.com/yiisoft/yii/blob/af3cbce71db83c4476c8a4289517b2984c740f31/framework/utils/CPropertyValue.php#L108-L130
train
yiisoft/yii
framework/utils/CPropertyValue.php
CPropertyValue.ensureEnum
public static function ensureEnum($value,$enumType) { static $types=array(); if(!isset($types[$enumType])) $types[$enumType]=new ReflectionClass($enumType); if($types[$enumType]->hasConstant($value)) return $value; else throw new CException(Yii::t('yii','Invalid enumerable value "{value}". Please make sure it is among ({enum}).', array('{value}'=>$value, '{enum}'=>implode(', ',$types[$enumType]->getConstants())))); }
php
public static function ensureEnum($value,$enumType) { static $types=array(); if(!isset($types[$enumType])) $types[$enumType]=new ReflectionClass($enumType); if($types[$enumType]->hasConstant($value)) return $value; else throw new CException(Yii::t('yii','Invalid enumerable value "{value}". Please make sure it is among ({enum}).', array('{value}'=>$value, '{enum}'=>implode(', ',$types[$enumType]->getConstants())))); }
[ "public", "static", "function", "ensureEnum", "(", "$", "value", ",", "$", "enumType", ")", "{", "static", "$", "types", "=", "array", "(", ")", ";", "if", "(", "!", "isset", "(", "$", "types", "[", "$", "enumType", "]", ")", ")", "$", "types", "[", "$", "enumType", "]", "=", "new", "ReflectionClass", "(", "$", "enumType", ")", ";", "if", "(", "$", "types", "[", "$", "enumType", "]", "->", "hasConstant", "(", "$", "value", ")", ")", "return", "$", "value", ";", "else", "throw", "new", "CException", "(", "Yii", "::", "t", "(", "'yii'", ",", "'Invalid enumerable value \"{value}\". Please make sure it is among ({enum}).'", ",", "array", "(", "'{value}'", "=>", "$", "value", ",", "'{enum}'", "=>", "implode", "(", "', '", ",", "$", "types", "[", "$", "enumType", "]", "->", "getConstants", "(", ")", ")", ")", ")", ")", ";", "}" ]
Converts a value to enum type. This method checks if the value is of the specified enumerable type. A value is a valid enumerable value if it is equal to the name of a constant in the specified enumerable type (class). For more details about enumerable, see {@link CEnumerable}. @param string $value the enumerable value to be checked. @param string $enumType the enumerable class name (make sure it is included before calling this function). @return string the valid enumeration value @throws CException if the value is not a valid enumerable value
[ "Converts", "a", "value", "to", "enum", "type", "." ]
af3cbce71db83c4476c8a4289517b2984c740f31
https://github.com/yiisoft/yii/blob/af3cbce71db83c4476c8a4289517b2984c740f31/framework/utils/CPropertyValue.php#L155-L165
train
yiisoft/yii
framework/gii/generators/model/ModelCode.php
ModelCode.isRelationTable
protected function isRelationTable($table) { $pk=$table->primaryKey; $count=is_array($pk) ? count($pk) : 1; return ($count === 2 // we want 2 columns && isset($table->foreignKeys[$pk[0]]) // pk column 1 is also a foreign key && isset($table->foreignKeys[$pk[1]]) // pk column 2 is also a foriegn key && $table->foreignKeys[$pk[0]][0] !== $table->foreignKeys[$pk[1]][0]); // and the foreign keys point different tables }
php
protected function isRelationTable($table) { $pk=$table->primaryKey; $count=is_array($pk) ? count($pk) : 1; return ($count === 2 // we want 2 columns && isset($table->foreignKeys[$pk[0]]) // pk column 1 is also a foreign key && isset($table->foreignKeys[$pk[1]]) // pk column 2 is also a foriegn key && $table->foreignKeys[$pk[0]][0] !== $table->foreignKeys[$pk[1]][0]); // and the foreign keys point different tables }
[ "protected", "function", "isRelationTable", "(", "$", "table", ")", "{", "$", "pk", "=", "$", "table", "->", "primaryKey", ";", "$", "count", "=", "is_array", "(", "$", "pk", ")", "?", "count", "(", "$", "pk", ")", ":", "1", ";", "return", "(", "$", "count", "===", "2", "// we want 2 columns", "&&", "isset", "(", "$", "table", "->", "foreignKeys", "[", "$", "pk", "[", "0", "]", "]", ")", "// pk column 1 is also a foreign key", "&&", "isset", "(", "$", "table", "->", "foreignKeys", "[", "$", "pk", "[", "1", "]", "]", ")", "// pk column 2 is also a foriegn key", "&&", "$", "table", "->", "foreignKeys", "[", "$", "pk", "[", "0", "]", "]", "[", "0", "]", "!==", "$", "table", "->", "foreignKeys", "[", "$", "pk", "[", "1", "]", "]", "[", "0", "]", ")", ";", "// and the foreign keys point different tables", "}" ]
Checks if the given table is a "many to many" pivot table. Their PK has 2 fields, and both of those fields are also FK to other separate tables. @param CDbTableSchema table to inspect @return boolean true if table matches description of helper table.
[ "Checks", "if", "the", "given", "table", "is", "a", "many", "to", "many", "pivot", "table", ".", "Their", "PK", "has", "2", "fields", "and", "both", "of", "those", "fields", "are", "also", "FK", "to", "other", "separate", "tables", "." ]
af3cbce71db83c4476c8a4289517b2984c740f31
https://github.com/yiisoft/yii/blob/af3cbce71db83c4476c8a4289517b2984c740f31/framework/gii/generators/model/ModelCode.php#L368-L376
train
yiisoft/yii
framework/web/auth/CAuthManager.php
CAuthManager.executeBizRule
public function executeBizRule($bizRule,$params,$data) { if($bizRule==='' || $bizRule===null) return true; if ($this->showErrors) return eval($bizRule)!=0; else { try { return @eval($bizRule)!=0; } catch (ParseError $e) { return false; } } }
php
public function executeBizRule($bizRule,$params,$data) { if($bizRule==='' || $bizRule===null) return true; if ($this->showErrors) return eval($bizRule)!=0; else { try { return @eval($bizRule)!=0; } catch (ParseError $e) { return false; } } }
[ "public", "function", "executeBizRule", "(", "$", "bizRule", ",", "$", "params", ",", "$", "data", ")", "{", "if", "(", "$", "bizRule", "===", "''", "||", "$", "bizRule", "===", "null", ")", "return", "true", ";", "if", "(", "$", "this", "->", "showErrors", ")", "return", "eval", "(", "$", "bizRule", ")", "!=", "0", ";", "else", "{", "try", "{", "return", "@", "eval", "(", "$", "bizRule", ")", "!=", "0", ";", "}", "catch", "(", "ParseError", "$", "e", ")", "{", "return", "false", ";", "}", "}", "}" ]
Executes the specified business rule. @param string $bizRule the business rule to be executed. @param array $params parameters passed to {@link IAuthManager::checkAccess}. @param mixed $data additional data associated with the authorization item or assignment. @return boolean whether the business rule returns true. If the business rule is empty, it will still return true.
[ "Executes", "the", "specified", "business", "rule", "." ]
af3cbce71db83c4476c8a4289517b2984c740f31
https://github.com/yiisoft/yii/blob/af3cbce71db83c4476c8a4289517b2984c740f31/framework/web/auth/CAuthManager.php#L147-L164
train
yiisoft/yii
framework/web/auth/CAuthManager.php
CAuthManager.checkItemChildType
protected function checkItemChildType($parentType,$childType) { static $types=array('operation','task','role'); if($parentType < $childType) throw new CException(Yii::t('yii','Cannot add an item of type "{child}" to an item of type "{parent}".', array('{child}'=>$types[$childType], '{parent}'=>$types[$parentType]))); }
php
protected function checkItemChildType($parentType,$childType) { static $types=array('operation','task','role'); if($parentType < $childType) throw new CException(Yii::t('yii','Cannot add an item of type "{child}" to an item of type "{parent}".', array('{child}'=>$types[$childType], '{parent}'=>$types[$parentType]))); }
[ "protected", "function", "checkItemChildType", "(", "$", "parentType", ",", "$", "childType", ")", "{", "static", "$", "types", "=", "array", "(", "'operation'", ",", "'task'", ",", "'role'", ")", ";", "if", "(", "$", "parentType", "<", "$", "childType", ")", "throw", "new", "CException", "(", "Yii", "::", "t", "(", "'yii'", ",", "'Cannot add an item of type \"{child}\" to an item of type \"{parent}\".'", ",", "array", "(", "'{child}'", "=>", "$", "types", "[", "$", "childType", "]", ",", "'{parent}'", "=>", "$", "types", "[", "$", "parentType", "]", ")", ")", ")", ";", "}" ]
Checks the item types to make sure a child can be added to a parent. @param integer $parentType parent item type @param integer $childType child item type @throws CException if the item cannot be added as a child due to its incompatible type.
[ "Checks", "the", "item", "types", "to", "make", "sure", "a", "child", "can", "be", "added", "to", "a", "parent", "." ]
af3cbce71db83c4476c8a4289517b2984c740f31
https://github.com/yiisoft/yii/blob/af3cbce71db83c4476c8a4289517b2984c740f31/framework/web/auth/CAuthManager.php#L172-L178
train
yiisoft/yii
framework/i18n/CNumberFormatter.php
CNumberFormatter.formatCurrency
public function formatCurrency($value,$currency) { return $this->format($this->_locale->getCurrencyFormat(),$value,$currency); }
php
public function formatCurrency($value,$currency) { return $this->format($this->_locale->getCurrencyFormat(),$value,$currency); }
[ "public", "function", "formatCurrency", "(", "$", "value", ",", "$", "currency", ")", "{", "return", "$", "this", "->", "format", "(", "$", "this", "->", "_locale", "->", "getCurrencyFormat", "(", ")", ",", "$", "value", ",", "$", "currency", ")", ";", "}" ]
Formats a number using the currency format defined in the locale. @param mixed $value the number to be formatted @param string $currency 3-letter ISO 4217 code. For example, the code "USD" represents the US Dollar and "EUR" represents the Euro currency. The currency placeholder in the pattern will be replaced with the currency symbol. @return string the formatting result.
[ "Formats", "a", "number", "using", "the", "currency", "format", "defined", "in", "the", "locale", "." ]
af3cbce71db83c4476c8a4289517b2984c740f31
https://github.com/yiisoft/yii/blob/af3cbce71db83c4476c8a4289517b2984c740f31/framework/i18n/CNumberFormatter.php#L108-L111
train
yiisoft/yii
framework/validators/CFileValidator.php
CFileValidator.emptyAttribute
protected function emptyAttribute($object, $attribute) { if($this->safe) $object->$attribute=null; if(!$this->allowEmpty) { $message=$this->message!==null?$this->message : Yii::t('yii','{attribute} cannot be blank.'); $this->addError($object,$attribute,$message); } }
php
protected function emptyAttribute($object, $attribute) { if($this->safe) $object->$attribute=null; if(!$this->allowEmpty) { $message=$this->message!==null?$this->message : Yii::t('yii','{attribute} cannot be blank.'); $this->addError($object,$attribute,$message); } }
[ "protected", "function", "emptyAttribute", "(", "$", "object", ",", "$", "attribute", ")", "{", "if", "(", "$", "this", "->", "safe", ")", "$", "object", "->", "$", "attribute", "=", "null", ";", "if", "(", "!", "$", "this", "->", "allowEmpty", ")", "{", "$", "message", "=", "$", "this", "->", "message", "!==", "null", "?", "$", "this", "->", "message", ":", "Yii", "::", "t", "(", "'yii'", ",", "'{attribute} cannot be blank.'", ")", ";", "$", "this", "->", "addError", "(", "$", "object", ",", "$", "attribute", ",", "$", "message", ")", ";", "}", "}" ]
Raises an error to inform end user about blank attribute. Sets the owner attribute to null to prevent setting arbitrary values. @param CModel $object the object being validated @param string $attribute the attribute being validated
[ "Raises", "an", "error", "to", "inform", "end", "user", "about", "blank", "attribute", ".", "Sets", "the", "owner", "attribute", "to", "null", "to", "prevent", "setting", "arbitrary", "values", "." ]
af3cbce71db83c4476c8a4289517b2984c740f31
https://github.com/yiisoft/yii/blob/af3cbce71db83c4476c8a4289517b2984c740f31/framework/validators/CFileValidator.php#L269-L279
train
yiisoft/yii
framework/gii/components/Pear/Text/Diff.php
Text_Diff.reverse
function reverse() { if (version_compare(zend_version(), '2', '>')) { $rev = clone($this); } else { $rev = $this; } $rev->_edits = array(); foreach ($this->_edits as $edit) { $rev->_edits[] = $edit->reverse(); } return $rev; }
php
function reverse() { if (version_compare(zend_version(), '2', '>')) { $rev = clone($this); } else { $rev = $this; } $rev->_edits = array(); foreach ($this->_edits as $edit) { $rev->_edits[] = $edit->reverse(); } return $rev; }
[ "function", "reverse", "(", ")", "{", "if", "(", "version_compare", "(", "zend_version", "(", ")", ",", "'2'", ",", "'>'", ")", ")", "{", "$", "rev", "=", "clone", "(", "$", "this", ")", ";", "}", "else", "{", "$", "rev", "=", "$", "this", ";", "}", "$", "rev", "->", "_edits", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "_edits", "as", "$", "edit", ")", "{", "$", "rev", "->", "_edits", "[", "]", "=", "$", "edit", "->", "reverse", "(", ")", ";", "}", "return", "$", "rev", ";", "}" ]
Computes a reversed diff. Example: <code> $diff = new Text_Diff($lines1, $lines2); $rev = $diff->reverse(); </code> @return Text_Diff A Diff object representing the inverse of the original diff. Note that we purposely don't return a reference here, since this essentially is a clone() method.
[ "Computes", "a", "reversed", "diff", "." ]
af3cbce71db83c4476c8a4289517b2984c740f31
https://github.com/yiisoft/yii/blob/af3cbce71db83c4476c8a4289517b2984c740f31/framework/gii/components/Pear/Text/Diff.php#L121-L133
train
yiisoft/yii
framework/gii/components/Pear/Text/Diff.php
Text_Diff.getOriginal
function getOriginal() { $lines = array(); foreach ($this->_edits as $edit) { if ($edit->orig) { array_splice($lines, count($lines), 0, $edit->orig); } } return $lines; }
php
function getOriginal() { $lines = array(); foreach ($this->_edits as $edit) { if ($edit->orig) { array_splice($lines, count($lines), 0, $edit->orig); } } return $lines; }
[ "function", "getOriginal", "(", ")", "{", "$", "lines", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "_edits", "as", "$", "edit", ")", "{", "if", "(", "$", "edit", "->", "orig", ")", "{", "array_splice", "(", "$", "lines", ",", "count", "(", "$", "lines", ")", ",", "0", ",", "$", "edit", "->", "orig", ")", ";", "}", "}", "return", "$", "lines", ";", "}" ]
Gets the original set of lines. This reconstructs the $from_lines parameter passed to the constructor. @return array The original sequence of strings.
[ "Gets", "the", "original", "set", "of", "lines", "." ]
af3cbce71db83c4476c8a4289517b2984c740f31
https://github.com/yiisoft/yii/blob/af3cbce71db83c4476c8a4289517b2984c740f31/framework/gii/components/Pear/Text/Diff.php#L175-L184
train
yiisoft/yii
framework/gii/components/Pear/Text/Diff.php
Text_Diff.getFinal
function getFinal() { $lines = array(); foreach ($this->_edits as $edit) { if ($edit->final) { array_splice($lines, count($lines), 0, $edit->final); } } return $lines; }
php
function getFinal() { $lines = array(); foreach ($this->_edits as $edit) { if ($edit->final) { array_splice($lines, count($lines), 0, $edit->final); } } return $lines; }
[ "function", "getFinal", "(", ")", "{", "$", "lines", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "_edits", "as", "$", "edit", ")", "{", "if", "(", "$", "edit", "->", "final", ")", "{", "array_splice", "(", "$", "lines", ",", "count", "(", "$", "lines", ")", ",", "0", ",", "$", "edit", "->", "final", ")", ";", "}", "}", "return", "$", "lines", ";", "}" ]
Gets the final set of lines. This reconstructs the $to_lines parameter passed to the constructor. @return array The sequence of strings.
[ "Gets", "the", "final", "set", "of", "lines", "." ]
af3cbce71db83c4476c8a4289517b2984c740f31
https://github.com/yiisoft/yii/blob/af3cbce71db83c4476c8a4289517b2984c740f31/framework/gii/components/Pear/Text/Diff.php#L193-L202
train
yiisoft/yii
framework/gii/components/Pear/Text/Diff.php
Text_Diff._getTempDir
function _getTempDir() { $tmp_locations = array('/tmp', '/var/tmp', 'c:\WUTemp', 'c:\temp', 'c:\windows\temp', 'c:\winnt\temp'); /* Try PHP's upload_tmp_dir directive. */ $tmp = ini_get('upload_tmp_dir'); /* Otherwise, try to determine the TMPDIR environment variable. */ if (!strlen($tmp)) { $tmp = getenv('TMPDIR'); } /* If we still cannot determine a value, then cycle through a list of * preset possibilities. */ while (!strlen($tmp) && count($tmp_locations)) { $tmp_check = array_shift($tmp_locations); if (@is_dir($tmp_check)) { $tmp = $tmp_check; } } /* If it is still empty, we have failed, so return false; otherwise * return the directory determined. */ return strlen($tmp) ? $tmp : false; }
php
function _getTempDir() { $tmp_locations = array('/tmp', '/var/tmp', 'c:\WUTemp', 'c:\temp', 'c:\windows\temp', 'c:\winnt\temp'); /* Try PHP's upload_tmp_dir directive. */ $tmp = ini_get('upload_tmp_dir'); /* Otherwise, try to determine the TMPDIR environment variable. */ if (!strlen($tmp)) { $tmp = getenv('TMPDIR'); } /* If we still cannot determine a value, then cycle through a list of * preset possibilities. */ while (!strlen($tmp) && count($tmp_locations)) { $tmp_check = array_shift($tmp_locations); if (@is_dir($tmp_check)) { $tmp = $tmp_check; } } /* If it is still empty, we have failed, so return false; otherwise * return the directory determined. */ return strlen($tmp) ? $tmp : false; }
[ "function", "_getTempDir", "(", ")", "{", "$", "tmp_locations", "=", "array", "(", "'/tmp'", ",", "'/var/tmp'", ",", "'c:\\WUTemp'", ",", "'c:\\temp'", ",", "'c:\\windows\\temp'", ",", "'c:\\winnt\\temp'", ")", ";", "/* Try PHP's upload_tmp_dir directive. */", "$", "tmp", "=", "ini_get", "(", "'upload_tmp_dir'", ")", ";", "/* Otherwise, try to determine the TMPDIR environment variable. */", "if", "(", "!", "strlen", "(", "$", "tmp", ")", ")", "{", "$", "tmp", "=", "getenv", "(", "'TMPDIR'", ")", ";", "}", "/* If we still cannot determine a value, then cycle through a list of\n * preset possibilities. */", "while", "(", "!", "strlen", "(", "$", "tmp", ")", "&&", "count", "(", "$", "tmp_locations", ")", ")", "{", "$", "tmp_check", "=", "array_shift", "(", "$", "tmp_locations", ")", ";", "if", "(", "@", "is_dir", "(", "$", "tmp_check", ")", ")", "{", "$", "tmp", "=", "$", "tmp_check", ";", "}", "}", "/* If it is still empty, we have failed, so return false; otherwise\n * return the directory determined. */", "return", "strlen", "(", "$", "tmp", ")", "?", "$", "tmp", ":", "false", ";", "}" ]
Determines the location of the system temporary directory. @static @access protected @return string A directory name which can be used for temp files. Returns false if one could not be found.
[ "Determines", "the", "location", "of", "the", "system", "temporary", "directory", "." ]
af3cbce71db83c4476c8a4289517b2984c740f31
https://github.com/yiisoft/yii/blob/af3cbce71db83c4476c8a4289517b2984c740f31/framework/gii/components/Pear/Text/Diff.php#L226-L251
train
yiisoft/yii
framework/gii/components/Pear/Text/Diff.php
Text_Diff._check
function _check($from_lines, $to_lines) { if (serialize($from_lines) != serialize($this->getOriginal())) { trigger_error("Reconstructed original doesn't match", E_USER_ERROR); } if (serialize($to_lines) != serialize($this->getFinal())) { trigger_error("Reconstructed final doesn't match", E_USER_ERROR); } $rev = $this->reverse(); if (serialize($to_lines) != serialize($rev->getOriginal())) { trigger_error("Reversed original doesn't match", E_USER_ERROR); } if (serialize($from_lines) != serialize($rev->getFinal())) { trigger_error("Reversed final doesn't match", E_USER_ERROR); } $prevtype = null; foreach ($this->_edits as $edit) { if ($prevtype == get_class($edit)) { trigger_error("Edit sequence is non-optimal", E_USER_ERROR); } $prevtype = get_class($edit); } return true; }
php
function _check($from_lines, $to_lines) { if (serialize($from_lines) != serialize($this->getOriginal())) { trigger_error("Reconstructed original doesn't match", E_USER_ERROR); } if (serialize($to_lines) != serialize($this->getFinal())) { trigger_error("Reconstructed final doesn't match", E_USER_ERROR); } $rev = $this->reverse(); if (serialize($to_lines) != serialize($rev->getOriginal())) { trigger_error("Reversed original doesn't match", E_USER_ERROR); } if (serialize($from_lines) != serialize($rev->getFinal())) { trigger_error("Reversed final doesn't match", E_USER_ERROR); } $prevtype = null; foreach ($this->_edits as $edit) { if ($prevtype == get_class($edit)) { trigger_error("Edit sequence is non-optimal", E_USER_ERROR); } $prevtype = get_class($edit); } return true; }
[ "function", "_check", "(", "$", "from_lines", ",", "$", "to_lines", ")", "{", "if", "(", "serialize", "(", "$", "from_lines", ")", "!=", "serialize", "(", "$", "this", "->", "getOriginal", "(", ")", ")", ")", "{", "trigger_error", "(", "\"Reconstructed original doesn't match\"", ",", "E_USER_ERROR", ")", ";", "}", "if", "(", "serialize", "(", "$", "to_lines", ")", "!=", "serialize", "(", "$", "this", "->", "getFinal", "(", ")", ")", ")", "{", "trigger_error", "(", "\"Reconstructed final doesn't match\"", ",", "E_USER_ERROR", ")", ";", "}", "$", "rev", "=", "$", "this", "->", "reverse", "(", ")", ";", "if", "(", "serialize", "(", "$", "to_lines", ")", "!=", "serialize", "(", "$", "rev", "->", "getOriginal", "(", ")", ")", ")", "{", "trigger_error", "(", "\"Reversed original doesn't match\"", ",", "E_USER_ERROR", ")", ";", "}", "if", "(", "serialize", "(", "$", "from_lines", ")", "!=", "serialize", "(", "$", "rev", "->", "getFinal", "(", ")", ")", ")", "{", "trigger_error", "(", "\"Reversed final doesn't match\"", ",", "E_USER_ERROR", ")", ";", "}", "$", "prevtype", "=", "null", ";", "foreach", "(", "$", "this", "->", "_edits", "as", "$", "edit", ")", "{", "if", "(", "$", "prevtype", "==", "get_class", "(", "$", "edit", ")", ")", "{", "trigger_error", "(", "\"Edit sequence is non-optimal\"", ",", "E_USER_ERROR", ")", ";", "}", "$", "prevtype", "=", "get_class", "(", "$", "edit", ")", ";", "}", "return", "true", ";", "}" ]
Checks a diff for validity. This is here only for debugging purposes.
[ "Checks", "a", "diff", "for", "validity", "." ]
af3cbce71db83c4476c8a4289517b2984c740f31
https://github.com/yiisoft/yii/blob/af3cbce71db83c4476c8a4289517b2984c740f31/framework/gii/components/Pear/Text/Diff.php#L258-L284
train
yiisoft/yii
framework/db/schema/mssql/CMssqlColumnSchema.php
CMssqlColumnSchema.init
public function init($dbType, $defaultValue) { if ($defaultValue=='(NULL)') { $defaultValue=null; } parent::init($dbType, $defaultValue); }
php
public function init($dbType, $defaultValue) { if ($defaultValue=='(NULL)') { $defaultValue=null; } parent::init($dbType, $defaultValue); }
[ "public", "function", "init", "(", "$", "dbType", ",", "$", "defaultValue", ")", "{", "if", "(", "$", "defaultValue", "==", "'(NULL)'", ")", "{", "$", "defaultValue", "=", "null", ";", "}", "parent", "::", "init", "(", "$", "dbType", ",", "$", "defaultValue", ")", ";", "}" ]
Initializes the column with its DB type and default value. This sets up the column's PHP type, size, precision, scale as well as default value. @param string $dbType the column's DB type @param mixed $defaultValue the default value
[ "Initializes", "the", "column", "with", "its", "DB", "type", "and", "default", "value", ".", "This", "sets", "up", "the", "column", "s", "PHP", "type", "size", "precision", "scale", "as", "well", "as", "default", "value", "." ]
af3cbce71db83c4476c8a4289517b2984c740f31
https://github.com/yiisoft/yii/blob/af3cbce71db83c4476c8a4289517b2984c740f31/framework/db/schema/mssql/CMssqlColumnSchema.php#L28-L35
train
yiisoft/yii
framework/gii/GiiModule.php
GiiModule.init
public function init() { parent::init(); Yii::setPathOfAlias('gii',dirname(__FILE__)); Yii::app()->setComponents(array( 'errorHandler'=>array( 'class'=>'CErrorHandler', 'errorAction'=>$this->getId().'/default/error', ), 'user'=>array( 'class'=>'CWebUser', 'stateKeyPrefix'=>'gii', 'loginUrl'=>Yii::app()->createUrl($this->getId().'/default/login'), ), 'widgetFactory' => array( 'class'=>'CWidgetFactory', 'widgets' => array() ) ), false); $this->generatorPaths[]='gii.generators'; $this->controllerMap=$this->findGenerators(); }
php
public function init() { parent::init(); Yii::setPathOfAlias('gii',dirname(__FILE__)); Yii::app()->setComponents(array( 'errorHandler'=>array( 'class'=>'CErrorHandler', 'errorAction'=>$this->getId().'/default/error', ), 'user'=>array( 'class'=>'CWebUser', 'stateKeyPrefix'=>'gii', 'loginUrl'=>Yii::app()->createUrl($this->getId().'/default/login'), ), 'widgetFactory' => array( 'class'=>'CWidgetFactory', 'widgets' => array() ) ), false); $this->generatorPaths[]='gii.generators'; $this->controllerMap=$this->findGenerators(); }
[ "public", "function", "init", "(", ")", "{", "parent", "::", "init", "(", ")", ";", "Yii", "::", "setPathOfAlias", "(", "'gii'", ",", "dirname", "(", "__FILE__", ")", ")", ";", "Yii", "::", "app", "(", ")", "->", "setComponents", "(", "array", "(", "'errorHandler'", "=>", "array", "(", "'class'", "=>", "'CErrorHandler'", ",", "'errorAction'", "=>", "$", "this", "->", "getId", "(", ")", ".", "'/default/error'", ",", ")", ",", "'user'", "=>", "array", "(", "'class'", "=>", "'CWebUser'", ",", "'stateKeyPrefix'", "=>", "'gii'", ",", "'loginUrl'", "=>", "Yii", "::", "app", "(", ")", "->", "createUrl", "(", "$", "this", "->", "getId", "(", ")", ".", "'/default/login'", ")", ",", ")", ",", "'widgetFactory'", "=>", "array", "(", "'class'", "=>", "'CWidgetFactory'", ",", "'widgets'", "=>", "array", "(", ")", ")", ")", ",", "false", ")", ";", "$", "this", "->", "generatorPaths", "[", "]", "=", "'gii.generators'", ";", "$", "this", "->", "controllerMap", "=", "$", "this", "->", "findGenerators", "(", ")", ";", "}" ]
Initializes the gii module.
[ "Initializes", "the", "gii", "module", "." ]
af3cbce71db83c4476c8a4289517b2984c740f31
https://github.com/yiisoft/yii/blob/af3cbce71db83c4476c8a4289517b2984c740f31/framework/gii/GiiModule.php#L114-L135
train
yiisoft/yii
framework/gii/GiiModule.php
GiiModule.findGenerators
protected function findGenerators() { $generators=array(); $n=count($this->generatorPaths); for($i=$n-1;$i>=0;--$i) { $alias=$this->generatorPaths[$i]; $path=Yii::getPathOfAlias($alias); if($path===false || !is_dir($path)) continue; $names=scandir($path); foreach($names as $name) { if($name[0]!=='.' && is_dir($path.'/'.$name)) { $className=ucfirst($name).'Generator'; if(is_file("$path/$name/$className.php")) { $generators[$name]=array( 'class'=>"$alias.$name.$className", ); } if(isset($generators[$name]) && is_dir("$path/$name/templates")) { $templatePath="$path/$name/templates"; $dirs=scandir($templatePath); foreach($dirs as $dir) { if($dir[0]!=='.' && is_dir($templatePath.'/'.$dir)) $generators[$name]['templates'][$dir]=strtr($templatePath.'/'.$dir,array('/'=>DIRECTORY_SEPARATOR,'\\'=>DIRECTORY_SEPARATOR)); } } } } } return $generators; }
php
protected function findGenerators() { $generators=array(); $n=count($this->generatorPaths); for($i=$n-1;$i>=0;--$i) { $alias=$this->generatorPaths[$i]; $path=Yii::getPathOfAlias($alias); if($path===false || !is_dir($path)) continue; $names=scandir($path); foreach($names as $name) { if($name[0]!=='.' && is_dir($path.'/'.$name)) { $className=ucfirst($name).'Generator'; if(is_file("$path/$name/$className.php")) { $generators[$name]=array( 'class'=>"$alias.$name.$className", ); } if(isset($generators[$name]) && is_dir("$path/$name/templates")) { $templatePath="$path/$name/templates"; $dirs=scandir($templatePath); foreach($dirs as $dir) { if($dir[0]!=='.' && is_dir($templatePath.'/'.$dir)) $generators[$name]['templates'][$dir]=strtr($templatePath.'/'.$dir,array('/'=>DIRECTORY_SEPARATOR,'\\'=>DIRECTORY_SEPARATOR)); } } } } } return $generators; }
[ "protected", "function", "findGenerators", "(", ")", "{", "$", "generators", "=", "array", "(", ")", ";", "$", "n", "=", "count", "(", "$", "this", "->", "generatorPaths", ")", ";", "for", "(", "$", "i", "=", "$", "n", "-", "1", ";", "$", "i", ">=", "0", ";", "--", "$", "i", ")", "{", "$", "alias", "=", "$", "this", "->", "generatorPaths", "[", "$", "i", "]", ";", "$", "path", "=", "Yii", "::", "getPathOfAlias", "(", "$", "alias", ")", ";", "if", "(", "$", "path", "===", "false", "||", "!", "is_dir", "(", "$", "path", ")", ")", "continue", ";", "$", "names", "=", "scandir", "(", "$", "path", ")", ";", "foreach", "(", "$", "names", "as", "$", "name", ")", "{", "if", "(", "$", "name", "[", "0", "]", "!==", "'.'", "&&", "is_dir", "(", "$", "path", ".", "'/'", ".", "$", "name", ")", ")", "{", "$", "className", "=", "ucfirst", "(", "$", "name", ")", ".", "'Generator'", ";", "if", "(", "is_file", "(", "\"$path/$name/$className.php\"", ")", ")", "{", "$", "generators", "[", "$", "name", "]", "=", "array", "(", "'class'", "=>", "\"$alias.$name.$className\"", ",", ")", ";", "}", "if", "(", "isset", "(", "$", "generators", "[", "$", "name", "]", ")", "&&", "is_dir", "(", "\"$path/$name/templates\"", ")", ")", "{", "$", "templatePath", "=", "\"$path/$name/templates\"", ";", "$", "dirs", "=", "scandir", "(", "$", "templatePath", ")", ";", "foreach", "(", "$", "dirs", "as", "$", "dir", ")", "{", "if", "(", "$", "dir", "[", "0", "]", "!==", "'.'", "&&", "is_dir", "(", "$", "templatePath", ".", "'/'", ".", "$", "dir", ")", ")", "$", "generators", "[", "$", "name", "]", "[", "'templates'", "]", "[", "$", "dir", "]", "=", "strtr", "(", "$", "templatePath", ".", "'/'", ".", "$", "dir", ",", "array", "(", "'/'", "=>", "DIRECTORY_SEPARATOR", ",", "'\\\\'", "=>", "DIRECTORY_SEPARATOR", ")", ")", ";", "}", "}", "}", "}", "}", "return", "$", "generators", ";", "}" ]
Finds all available code generators and their code templates. @return array
[ "Finds", "all", "available", "code", "generators", "and", "their", "code", "templates", "." ]
af3cbce71db83c4476c8a4289517b2984c740f31
https://github.com/yiisoft/yii/blob/af3cbce71db83c4476c8a4289517b2984c740f31/framework/gii/GiiModule.php#L205-L243
train
yiisoft/yii
framework/gii/generators/model/ModelGenerator.php
ModelGenerator.actionGetTableNames
public function actionGetTableNames($db) { if(Yii::app()->getRequest()->getIsAjaxRequest()) { $all = array(); if(!empty($db) && Yii::app()->hasComponent($db)!==false && (Yii::app()->getComponent($db) instanceof CDbConnection)) $all=array_keys(Yii::app()->{$db}->schema->getTables()); echo json_encode($all); } else throw new CHttpException(404,'The requested page does not exist.'); }
php
public function actionGetTableNames($db) { if(Yii::app()->getRequest()->getIsAjaxRequest()) { $all = array(); if(!empty($db) && Yii::app()->hasComponent($db)!==false && (Yii::app()->getComponent($db) instanceof CDbConnection)) $all=array_keys(Yii::app()->{$db}->schema->getTables()); echo json_encode($all); } else throw new CHttpException(404,'The requested page does not exist.'); }
[ "public", "function", "actionGetTableNames", "(", "$", "db", ")", "{", "if", "(", "Yii", "::", "app", "(", ")", "->", "getRequest", "(", ")", "->", "getIsAjaxRequest", "(", ")", ")", "{", "$", "all", "=", "array", "(", ")", ";", "if", "(", "!", "empty", "(", "$", "db", ")", "&&", "Yii", "::", "app", "(", ")", "->", "hasComponent", "(", "$", "db", ")", "!==", "false", "&&", "(", "Yii", "::", "app", "(", ")", "->", "getComponent", "(", "$", "db", ")", "instanceof", "CDbConnection", ")", ")", "$", "all", "=", "array_keys", "(", "Yii", "::", "app", "(", ")", "->", "{", "$", "db", "}", "->", "schema", "->", "getTables", "(", ")", ")", ";", "echo", "json_encode", "(", "$", "all", ")", ";", "}", "else", "throw", "new", "CHttpException", "(", "404", ",", "'The requested page does not exist.'", ")", ";", "}" ]
Provides autocomplete table names @param string $db the database connection component id @return string the json array of tablenames that contains the entered term $q
[ "Provides", "autocomplete", "table", "names" ]
af3cbce71db83c4476c8a4289517b2984c740f31
https://github.com/yiisoft/yii/blob/af3cbce71db83c4476c8a4289517b2984c740f31/framework/gii/generators/model/ModelGenerator.php#L12-L24
train
yiisoft/yii
framework/logging/CLogRoute.php
CLogRoute.collectLogs
public function collectLogs($logger, $processLogs=false) { $logs=$logger->getLogs($this->levels,$this->categories,$this->except); $this->logs=empty($this->logs) ? $logs : array_merge($this->logs,$logs); if($processLogs && !empty($this->logs)) { if($this->filter!==null) Yii::createComponent($this->filter)->filter($this->logs); if($this->logs!==array()) $this->processLogs($this->logs); $this->logs=array(); } }
php
public function collectLogs($logger, $processLogs=false) { $logs=$logger->getLogs($this->levels,$this->categories,$this->except); $this->logs=empty($this->logs) ? $logs : array_merge($this->logs,$logs); if($processLogs && !empty($this->logs)) { if($this->filter!==null) Yii::createComponent($this->filter)->filter($this->logs); if($this->logs!==array()) $this->processLogs($this->logs); $this->logs=array(); } }
[ "public", "function", "collectLogs", "(", "$", "logger", ",", "$", "processLogs", "=", "false", ")", "{", "$", "logs", "=", "$", "logger", "->", "getLogs", "(", "$", "this", "->", "levels", ",", "$", "this", "->", "categories", ",", "$", "this", "->", "except", ")", ";", "$", "this", "->", "logs", "=", "empty", "(", "$", "this", "->", "logs", ")", "?", "$", "logs", ":", "array_merge", "(", "$", "this", "->", "logs", ",", "$", "logs", ")", ";", "if", "(", "$", "processLogs", "&&", "!", "empty", "(", "$", "this", "->", "logs", ")", ")", "{", "if", "(", "$", "this", "->", "filter", "!==", "null", ")", "Yii", "::", "createComponent", "(", "$", "this", "->", "filter", ")", "->", "filter", "(", "$", "this", "->", "logs", ")", ";", "if", "(", "$", "this", "->", "logs", "!==", "array", "(", ")", ")", "$", "this", "->", "processLogs", "(", "$", "this", "->", "logs", ")", ";", "$", "this", "->", "logs", "=", "array", "(", ")", ";", "}", "}" ]
Retrieves filtered log messages from logger for further processing. @param CLogger $logger logger instance @param boolean $processLogs whether to process the logs after they are collected from the logger
[ "Retrieves", "filtered", "log", "messages", "from", "logger", "for", "further", "processing", "." ]
af3cbce71db83c4476c8a4289517b2984c740f31
https://github.com/yiisoft/yii/blob/af3cbce71db83c4476c8a4289517b2984c740f31/framework/logging/CLogRoute.php#L95-L107
train
yiisoft/yii
framework/db/schema/mssql/CMssqlSchema.php
CMssqlSchema.compareTableNames
public function compareTableNames($name1,$name2) { $name1=str_replace(array('[',']'),'',$name1); $name2=str_replace(array('[',']'),'',$name2); return parent::compareTableNames(strtolower($name1),strtolower($name2)); }
php
public function compareTableNames($name1,$name2) { $name1=str_replace(array('[',']'),'',$name1); $name2=str_replace(array('[',']'),'',$name2); return parent::compareTableNames(strtolower($name1),strtolower($name2)); }
[ "public", "function", "compareTableNames", "(", "$", "name1", ",", "$", "name2", ")", "{", "$", "name1", "=", "str_replace", "(", "array", "(", "'['", ",", "']'", ")", ",", "''", ",", "$", "name1", ")", ";", "$", "name2", "=", "str_replace", "(", "array", "(", "'['", ",", "']'", ")", ",", "''", ",", "$", "name2", ")", ";", "return", "parent", "::", "compareTableNames", "(", "strtolower", "(", "$", "name1", ")", ",", "strtolower", "(", "$", "name2", ")", ")", ";", "}" ]
Compares two table names. The table names can be either quoted or unquoted. This method will consider both cases. @param string $name1 table name 1 @param string $name2 table name 2 @return boolean whether the two table names refer to the same table.
[ "Compares", "two", "table", "names", ".", "The", "table", "names", "can", "be", "either", "quoted", "or", "unquoted", ".", "This", "method", "will", "consider", "both", "cases", "." ]
af3cbce71db83c4476c8a4289517b2984c740f31
https://github.com/yiisoft/yii/blob/af3cbce71db83c4476c8a4289517b2984c740f31/framework/db/schema/mssql/CMssqlSchema.php#L76-L81
train
yiisoft/yii
framework/db/schema/mssql/CMssqlSchema.php
CMssqlSchema.findForeignKeys
protected function findForeignKeys($table) { $rc='INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS'; $kcu='INFORMATION_SCHEMA.KEY_COLUMN_USAGE'; if (isset($table->catalogName)) { $kcu=$table->catalogName.'.'.$kcu; $rc=$table->catalogName.'.'.$rc; } //From http://msdn2.microsoft.com/en-us/library/aa175805(SQL.80).aspx $sql = <<<EOD SELECT KCU1.CONSTRAINT_NAME AS 'FK_CONSTRAINT_NAME' , KCU1.TABLE_NAME AS 'FK_TABLE_NAME' , KCU1.COLUMN_NAME AS 'FK_COLUMN_NAME' , KCU1.ORDINAL_POSITION AS 'FK_ORDINAL_POSITION' , KCU2.CONSTRAINT_NAME AS 'UQ_CONSTRAINT_NAME' , KCU2.TABLE_NAME AS 'UQ_TABLE_NAME' , KCU2.COLUMN_NAME AS 'UQ_COLUMN_NAME' , KCU2.ORDINAL_POSITION AS 'UQ_ORDINAL_POSITION' FROM {$this->quoteTableName($rc)} RC JOIN {$this->quoteTableName($kcu)} KCU1 ON KCU1.CONSTRAINT_CATALOG = RC.CONSTRAINT_CATALOG AND KCU1.CONSTRAINT_SCHEMA = RC.CONSTRAINT_SCHEMA AND KCU1.CONSTRAINT_NAME = RC.CONSTRAINT_NAME JOIN {$this->quoteTableName($kcu)} KCU2 ON KCU2.CONSTRAINT_CATALOG = RC.UNIQUE_CONSTRAINT_CATALOG AND KCU2.CONSTRAINT_SCHEMA = RC.UNIQUE_CONSTRAINT_SCHEMA AND KCU2.CONSTRAINT_NAME = RC.UNIQUE_CONSTRAINT_NAME AND KCU2.ORDINAL_POSITION = KCU1.ORDINAL_POSITION WHERE KCU1.TABLE_NAME = :table EOD; $command = $this->getDbConnection()->createCommand($sql); $command->bindValue(':table', $table->name); $fkeys=array(); foreach($command->queryAll() as $info) { $fkeys[$info['FK_COLUMN_NAME']]=array($info['UQ_TABLE_NAME'],$info['UQ_COLUMN_NAME'],); } return $fkeys; }
php
protected function findForeignKeys($table) { $rc='INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS'; $kcu='INFORMATION_SCHEMA.KEY_COLUMN_USAGE'; if (isset($table->catalogName)) { $kcu=$table->catalogName.'.'.$kcu; $rc=$table->catalogName.'.'.$rc; } //From http://msdn2.microsoft.com/en-us/library/aa175805(SQL.80).aspx $sql = <<<EOD SELECT KCU1.CONSTRAINT_NAME AS 'FK_CONSTRAINT_NAME' , KCU1.TABLE_NAME AS 'FK_TABLE_NAME' , KCU1.COLUMN_NAME AS 'FK_COLUMN_NAME' , KCU1.ORDINAL_POSITION AS 'FK_ORDINAL_POSITION' , KCU2.CONSTRAINT_NAME AS 'UQ_CONSTRAINT_NAME' , KCU2.TABLE_NAME AS 'UQ_TABLE_NAME' , KCU2.COLUMN_NAME AS 'UQ_COLUMN_NAME' , KCU2.ORDINAL_POSITION AS 'UQ_ORDINAL_POSITION' FROM {$this->quoteTableName($rc)} RC JOIN {$this->quoteTableName($kcu)} KCU1 ON KCU1.CONSTRAINT_CATALOG = RC.CONSTRAINT_CATALOG AND KCU1.CONSTRAINT_SCHEMA = RC.CONSTRAINT_SCHEMA AND KCU1.CONSTRAINT_NAME = RC.CONSTRAINT_NAME JOIN {$this->quoteTableName($kcu)} KCU2 ON KCU2.CONSTRAINT_CATALOG = RC.UNIQUE_CONSTRAINT_CATALOG AND KCU2.CONSTRAINT_SCHEMA = RC.UNIQUE_CONSTRAINT_SCHEMA AND KCU2.CONSTRAINT_NAME = RC.UNIQUE_CONSTRAINT_NAME AND KCU2.ORDINAL_POSITION = KCU1.ORDINAL_POSITION WHERE KCU1.TABLE_NAME = :table EOD; $command = $this->getDbConnection()->createCommand($sql); $command->bindValue(':table', $table->name); $fkeys=array(); foreach($command->queryAll() as $info) { $fkeys[$info['FK_COLUMN_NAME']]=array($info['UQ_TABLE_NAME'],$info['UQ_COLUMN_NAME'],); } return $fkeys; }
[ "protected", "function", "findForeignKeys", "(", "$", "table", ")", "{", "$", "rc", "=", "'INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS'", ";", "$", "kcu", "=", "'INFORMATION_SCHEMA.KEY_COLUMN_USAGE'", ";", "if", "(", "isset", "(", "$", "table", "->", "catalogName", ")", ")", "{", "$", "kcu", "=", "$", "table", "->", "catalogName", ".", "'.'", ".", "$", "kcu", ";", "$", "rc", "=", "$", "table", "->", "catalogName", ".", "'.'", ".", "$", "rc", ";", "}", "//From http://msdn2.microsoft.com/en-us/library/aa175805(SQL.80).aspx", "$", "sql", "=", " <<<EOD\n\t\tSELECT\n\t\t KCU1.CONSTRAINT_NAME AS 'FK_CONSTRAINT_NAME'\n\t\t , KCU1.TABLE_NAME AS 'FK_TABLE_NAME'\n\t\t , KCU1.COLUMN_NAME AS 'FK_COLUMN_NAME'\n\t\t , KCU1.ORDINAL_POSITION AS 'FK_ORDINAL_POSITION'\n\t\t , KCU2.CONSTRAINT_NAME AS 'UQ_CONSTRAINT_NAME'\n\t\t , KCU2.TABLE_NAME AS 'UQ_TABLE_NAME'\n\t\t , KCU2.COLUMN_NAME AS 'UQ_COLUMN_NAME'\n\t\t , KCU2.ORDINAL_POSITION AS 'UQ_ORDINAL_POSITION'\n\t\tFROM {$this->quoteTableName($rc)} RC\n\t\tJOIN {$this->quoteTableName($kcu)} KCU1\n\t\tON KCU1.CONSTRAINT_CATALOG = RC.CONSTRAINT_CATALOG\n\t\t AND KCU1.CONSTRAINT_SCHEMA = RC.CONSTRAINT_SCHEMA\n\t\t AND KCU1.CONSTRAINT_NAME = RC.CONSTRAINT_NAME\n\t\tJOIN {$this->quoteTableName($kcu)} KCU2\n\t\tON KCU2.CONSTRAINT_CATALOG =\n\t\tRC.UNIQUE_CONSTRAINT_CATALOG\n\t\t AND KCU2.CONSTRAINT_SCHEMA =\n\t\tRC.UNIQUE_CONSTRAINT_SCHEMA\n\t\t AND KCU2.CONSTRAINT_NAME =\n\t\tRC.UNIQUE_CONSTRAINT_NAME\n\t\t AND KCU2.ORDINAL_POSITION = KCU1.ORDINAL_POSITION\n\t\tWHERE KCU1.TABLE_NAME = :table\nEOD", ";", "$", "command", "=", "$", "this", "->", "getDbConnection", "(", ")", "->", "createCommand", "(", "$", "sql", ")", ";", "$", "command", "->", "bindValue", "(", "':table'", ",", "$", "table", "->", "name", ")", ";", "$", "fkeys", "=", "array", "(", ")", ";", "foreach", "(", "$", "command", "->", "queryAll", "(", ")", "as", "$", "info", ")", "{", "$", "fkeys", "[", "$", "info", "[", "'FK_COLUMN_NAME'", "]", "]", "=", "array", "(", "$", "info", "[", "'UQ_TABLE_NAME'", "]", ",", "$", "info", "[", "'UQ_COLUMN_NAME'", "]", ",", ")", ";", "}", "return", "$", "fkeys", ";", "}" ]
Gets foreign relationship constraint keys and table name @param CMssqlTableSchema $table table @return array foreign relationship table name and keys.
[ "Gets", "foreign", "relationship", "constraint", "keys", "and", "table", "name" ]
af3cbce71db83c4476c8a4289517b2984c740f31
https://github.com/yiisoft/yii/blob/af3cbce71db83c4476c8a4289517b2984c740f31/framework/db/schema/mssql/CMssqlSchema.php#L228-L273
train
yiisoft/yii
framework/web/services/CWsdlGenerator.php
CWsdlGenerator.generateWsdl
public function generateWsdl($className, $serviceUrl, $encoding='UTF-8') { $this->operations=array(); $this->types=array(); $this->elements=array(); $this->messages=array(); if($this->serviceName===null) $this->serviceName=$className; if($this->namespace===null) $this->namespace='urn:'.str_replace('\\','/',$className).'wsdl'; $reflection=new ReflectionClass($className); foreach($reflection->getMethods() as $method) { if($method->isPublic()) $this->processMethod($method); } $wsdl=$this->buildDOM($serviceUrl,$encoding)->saveXML(); if(isset($_GET['makedoc'])) $this->buildHtmlDocs(); return $wsdl; }
php
public function generateWsdl($className, $serviceUrl, $encoding='UTF-8') { $this->operations=array(); $this->types=array(); $this->elements=array(); $this->messages=array(); if($this->serviceName===null) $this->serviceName=$className; if($this->namespace===null) $this->namespace='urn:'.str_replace('\\','/',$className).'wsdl'; $reflection=new ReflectionClass($className); foreach($reflection->getMethods() as $method) { if($method->isPublic()) $this->processMethod($method); } $wsdl=$this->buildDOM($serviceUrl,$encoding)->saveXML(); if(isset($_GET['makedoc'])) $this->buildHtmlDocs(); return $wsdl; }
[ "public", "function", "generateWsdl", "(", "$", "className", ",", "$", "serviceUrl", ",", "$", "encoding", "=", "'UTF-8'", ")", "{", "$", "this", "->", "operations", "=", "array", "(", ")", ";", "$", "this", "->", "types", "=", "array", "(", ")", ";", "$", "this", "->", "elements", "=", "array", "(", ")", ";", "$", "this", "->", "messages", "=", "array", "(", ")", ";", "if", "(", "$", "this", "->", "serviceName", "===", "null", ")", "$", "this", "->", "serviceName", "=", "$", "className", ";", "if", "(", "$", "this", "->", "namespace", "===", "null", ")", "$", "this", "->", "namespace", "=", "'urn:'", ".", "str_replace", "(", "'\\\\'", ",", "'/'", ",", "$", "className", ")", ".", "'wsdl'", ";", "$", "reflection", "=", "new", "ReflectionClass", "(", "$", "className", ")", ";", "foreach", "(", "$", "reflection", "->", "getMethods", "(", ")", "as", "$", "method", ")", "{", "if", "(", "$", "method", "->", "isPublic", "(", ")", ")", "$", "this", "->", "processMethod", "(", "$", "method", ")", ";", "}", "$", "wsdl", "=", "$", "this", "->", "buildDOM", "(", "$", "serviceUrl", ",", "$", "encoding", ")", "->", "saveXML", "(", ")", ";", "if", "(", "isset", "(", "$", "_GET", "[", "'makedoc'", "]", ")", ")", "$", "this", "->", "buildHtmlDocs", "(", ")", ";", "return", "$", "wsdl", ";", "}" ]
Generates the WSDL for the given class. @param string $className class name @param string $serviceUrl Web service URL @param string $encoding encoding of the WSDL. Defaults to 'UTF-8'. @return string the generated WSDL
[ "Generates", "the", "WSDL", "for", "the", "given", "class", "." ]
af3cbce71db83c4476c8a4289517b2984c740f31
https://github.com/yiisoft/yii/blob/af3cbce71db83c4476c8a4289517b2984c740f31/framework/web/services/CWsdlGenerator.php#L236-L260
train
yiisoft/yii
framework/cli/commands/ShellCommand.php
ShellCommand.addCommands
protected function addCommands(CConsoleCommandRunner $runner) { $runner->addCommands(Yii::getPathOfAlias('system.cli.commands.shell')); $runner->addCommands(Yii::getPathOfAlias('application.commands.shell')); if(($_path_=@getenv('YIIC_SHELL_COMMAND_PATH'))!==false) $runner->addCommands($_path_); }
php
protected function addCommands(CConsoleCommandRunner $runner) { $runner->addCommands(Yii::getPathOfAlias('system.cli.commands.shell')); $runner->addCommands(Yii::getPathOfAlias('application.commands.shell')); if(($_path_=@getenv('YIIC_SHELL_COMMAND_PATH'))!==false) $runner->addCommands($_path_); }
[ "protected", "function", "addCommands", "(", "CConsoleCommandRunner", "$", "runner", ")", "{", "$", "runner", "->", "addCommands", "(", "Yii", "::", "getPathOfAlias", "(", "'system.cli.commands.shell'", ")", ")", ";", "$", "runner", "->", "addCommands", "(", "Yii", "::", "getPathOfAlias", "(", "'application.commands.shell'", ")", ")", ";", "if", "(", "(", "$", "_path_", "=", "@", "getenv", "(", "'YIIC_SHELL_COMMAND_PATH'", ")", ")", "!==", "false", ")", "$", "runner", "->", "addCommands", "(", "$", "_path_", ")", ";", "}" ]
Adds commands to runner @param CConsoleCommandRunner $runner @since 1.1.16
[ "Adds", "commands", "to", "runner" ]
af3cbce71db83c4476c8a4289517b2984c740f31
https://github.com/yiisoft/yii/blob/af3cbce71db83c4476c8a4289517b2984c740f31/framework/cli/commands/ShellCommand.php#L166-L172
train
yiisoft/yii
framework/console/CConsoleApplication.php
CConsoleApplication.init
protected function init() { parent::init(); if(empty($_SERVER['argv'])) die('This script must be run from the command line.'); $this->_runner=$this->createCommandRunner(); $this->_runner->commands=$this->commandMap; $this->_runner->addCommands($this->getCommandPath()); }
php
protected function init() { parent::init(); if(empty($_SERVER['argv'])) die('This script must be run from the command line.'); $this->_runner=$this->createCommandRunner(); $this->_runner->commands=$this->commandMap; $this->_runner->addCommands($this->getCommandPath()); }
[ "protected", "function", "init", "(", ")", "{", "parent", "::", "init", "(", ")", ";", "if", "(", "empty", "(", "$", "_SERVER", "[", "'argv'", "]", ")", ")", "die", "(", "'This script must be run from the command line.'", ")", ";", "$", "this", "->", "_runner", "=", "$", "this", "->", "createCommandRunner", "(", ")", ";", "$", "this", "->", "_runner", "->", "commands", "=", "$", "this", "->", "commandMap", ";", "$", "this", "->", "_runner", "->", "addCommands", "(", "$", "this", "->", "getCommandPath", "(", ")", ")", ";", "}" ]
Initializes the application by creating the command runner.
[ "Initializes", "the", "application", "by", "creating", "the", "command", "runner", "." ]
af3cbce71db83c4476c8a4289517b2984c740f31
https://github.com/yiisoft/yii/blob/af3cbce71db83c4476c8a4289517b2984c740f31/framework/console/CConsoleApplication.php#L75-L83
train
yiisoft/yii
framework/console/CConsoleApplication.php
CConsoleApplication.processRequest
public function processRequest() { $exitCode=$this->_runner->run($_SERVER['argv']); if(is_int($exitCode)) $this->end($exitCode); }
php
public function processRequest() { $exitCode=$this->_runner->run($_SERVER['argv']); if(is_int($exitCode)) $this->end($exitCode); }
[ "public", "function", "processRequest", "(", ")", "{", "$", "exitCode", "=", "$", "this", "->", "_runner", "->", "run", "(", "$", "_SERVER", "[", "'argv'", "]", ")", ";", "if", "(", "is_int", "(", "$", "exitCode", ")", ")", "$", "this", "->", "end", "(", "$", "exitCode", ")", ";", "}" ]
Processes the user request. This method uses a console command runner to handle the particular user command. Since version 1.1.11 this method will exit application with an exit code if one is returned by the user command.
[ "Processes", "the", "user", "request", ".", "This", "method", "uses", "a", "console", "command", "runner", "to", "handle", "the", "particular", "user", "command", ".", "Since", "version", "1", ".", "1", ".", "11", "this", "method", "will", "exit", "application", "with", "an", "exit", "code", "if", "one", "is", "returned", "by", "the", "user", "command", "." ]
af3cbce71db83c4476c8a4289517b2984c740f31
https://github.com/yiisoft/yii/blob/af3cbce71db83c4476c8a4289517b2984c740f31/framework/console/CConsoleApplication.php#L90-L95
train
yiisoft/yii
framework/web/CTheme.php
CTheme.getViewFile
public function getViewFile($controller,$viewName) { $moduleViewPath=$this->getViewPath(); if(($module=$controller->getModule())!==null) $moduleViewPath.='/'.$module->getId(); return $controller->resolveViewFile($viewName,$this->getViewPath().'/'.$controller->getUniqueId(),$this->getViewPath(),$moduleViewPath); }
php
public function getViewFile($controller,$viewName) { $moduleViewPath=$this->getViewPath(); if(($module=$controller->getModule())!==null) $moduleViewPath.='/'.$module->getId(); return $controller->resolveViewFile($viewName,$this->getViewPath().'/'.$controller->getUniqueId(),$this->getViewPath(),$moduleViewPath); }
[ "public", "function", "getViewFile", "(", "$", "controller", ",", "$", "viewName", ")", "{", "$", "moduleViewPath", "=", "$", "this", "->", "getViewPath", "(", ")", ";", "if", "(", "(", "$", "module", "=", "$", "controller", "->", "getModule", "(", ")", ")", "!==", "null", ")", "$", "moduleViewPath", ".=", "'/'", ".", "$", "module", "->", "getId", "(", ")", ";", "return", "$", "controller", "->", "resolveViewFile", "(", "$", "viewName", ",", "$", "this", "->", "getViewPath", "(", ")", ".", "'/'", ".", "$", "controller", "->", "getUniqueId", "(", ")", ",", "$", "this", "->", "getViewPath", "(", ")", ",", "$", "moduleViewPath", ")", ";", "}" ]
Finds the view file for the specified controller's view. @param CController $controller the controller @param string $viewName the view name @return string the view file path. False if the file does not exist.
[ "Finds", "the", "view", "file", "for", "the", "specified", "controller", "s", "view", "." ]
af3cbce71db83c4476c8a4289517b2984c740f31
https://github.com/yiisoft/yii/blob/af3cbce71db83c4476c8a4289517b2984c740f31/framework/web/CTheme.php#L99-L105
train
yiisoft/yii
framework/web/CTheme.php
CTheme.getLayoutFile
public function getLayoutFile($controller,$layoutName) { $moduleViewPath=$basePath=$this->getViewPath(); $module=$controller->getModule(); if(empty($layoutName)) { while($module!==null) { if($module->layout===false) return false; if(!empty($module->layout)) break; $module=$module->getParentModule(); } if($module===null) $layoutName=Yii::app()->layout; else { $layoutName=$module->layout; $moduleViewPath.='/'.$module->getId(); } } elseif($module!==null) $moduleViewPath.='/'.$module->getId(); return $controller->resolveViewFile($layoutName,$moduleViewPath.'/layouts',$basePath,$moduleViewPath); }
php
public function getLayoutFile($controller,$layoutName) { $moduleViewPath=$basePath=$this->getViewPath(); $module=$controller->getModule(); if(empty($layoutName)) { while($module!==null) { if($module->layout===false) return false; if(!empty($module->layout)) break; $module=$module->getParentModule(); } if($module===null) $layoutName=Yii::app()->layout; else { $layoutName=$module->layout; $moduleViewPath.='/'.$module->getId(); } } elseif($module!==null) $moduleViewPath.='/'.$module->getId(); return $controller->resolveViewFile($layoutName,$moduleViewPath.'/layouts',$basePath,$moduleViewPath); }
[ "public", "function", "getLayoutFile", "(", "$", "controller", ",", "$", "layoutName", ")", "{", "$", "moduleViewPath", "=", "$", "basePath", "=", "$", "this", "->", "getViewPath", "(", ")", ";", "$", "module", "=", "$", "controller", "->", "getModule", "(", ")", ";", "if", "(", "empty", "(", "$", "layoutName", ")", ")", "{", "while", "(", "$", "module", "!==", "null", ")", "{", "if", "(", "$", "module", "->", "layout", "===", "false", ")", "return", "false", ";", "if", "(", "!", "empty", "(", "$", "module", "->", "layout", ")", ")", "break", ";", "$", "module", "=", "$", "module", "->", "getParentModule", "(", ")", ";", "}", "if", "(", "$", "module", "===", "null", ")", "$", "layoutName", "=", "Yii", "::", "app", "(", ")", "->", "layout", ";", "else", "{", "$", "layoutName", "=", "$", "module", "->", "layout", ";", "$", "moduleViewPath", ".=", "'/'", ".", "$", "module", "->", "getId", "(", ")", ";", "}", "}", "elseif", "(", "$", "module", "!==", "null", ")", "$", "moduleViewPath", ".=", "'/'", ".", "$", "module", "->", "getId", "(", ")", ";", "return", "$", "controller", "->", "resolveViewFile", "(", "$", "layoutName", ",", "$", "moduleViewPath", ".", "'/layouts'", ",", "$", "basePath", ",", "$", "moduleViewPath", ")", ";", "}" ]
Finds the layout file for the specified controller's layout. @param CController $controller the controller @param string $layoutName the layout name @return string the layout file path. False if the file does not exist.
[ "Finds", "the", "layout", "file", "for", "the", "specified", "controller", "s", "layout", "." ]
af3cbce71db83c4476c8a4289517b2984c740f31
https://github.com/yiisoft/yii/blob/af3cbce71db83c4476c8a4289517b2984c740f31/framework/web/CTheme.php#L113-L139
train
yiisoft/yii
framework/gii/models/LoginForm.php
LoginForm.login
public function login() { if($this->_identity===null) { $this->_identity=new UserIdentity('yiier',$this->password); $this->_identity->authenticate(); } if($this->_identity->errorCode===UserIdentity::ERROR_NONE) { Yii::app()->user->login($this->_identity); return true; } else return false; }
php
public function login() { if($this->_identity===null) { $this->_identity=new UserIdentity('yiier',$this->password); $this->_identity->authenticate(); } if($this->_identity->errorCode===UserIdentity::ERROR_NONE) { Yii::app()->user->login($this->_identity); return true; } else return false; }
[ "public", "function", "login", "(", ")", "{", "if", "(", "$", "this", "->", "_identity", "===", "null", ")", "{", "$", "this", "->", "_identity", "=", "new", "UserIdentity", "(", "'yiier'", ",", "$", "this", "->", "password", ")", ";", "$", "this", "->", "_identity", "->", "authenticate", "(", ")", ";", "}", "if", "(", "$", "this", "->", "_identity", "->", "errorCode", "===", "UserIdentity", "::", "ERROR_NONE", ")", "{", "Yii", "::", "app", "(", ")", "->", "user", "->", "login", "(", "$", "this", "->", "_identity", ")", ";", "return", "true", ";", "}", "else", "return", "false", ";", "}" ]
Logs in the user using the given password in the model. @return boolean whether login is successful
[ "Logs", "in", "the", "user", "using", "the", "given", "password", "in", "the", "model", "." ]
af3cbce71db83c4476c8a4289517b2984c740f31
https://github.com/yiisoft/yii/blob/af3cbce71db83c4476c8a4289517b2984c740f31/framework/gii/models/LoginForm.php#L36-L50
train
yiisoft/yii
framework/gii/CCodeGenerator.php
CCodeGenerator.actionIndex
public function actionIndex() { $model=$this->prepare(); if($model->files!=array() && isset($_POST['generate'], $_POST['answers'])) { $model->answers=$_POST['answers']; $model->status=$model->save() ? CCodeModel::STATUS_SUCCESS : CCodeModel::STATUS_ERROR; } $this->render('index',array( 'model'=>$model, )); }
php
public function actionIndex() { $model=$this->prepare(); if($model->files!=array() && isset($_POST['generate'], $_POST['answers'])) { $model->answers=$_POST['answers']; $model->status=$model->save() ? CCodeModel::STATUS_SUCCESS : CCodeModel::STATUS_ERROR; } $this->render('index',array( 'model'=>$model, )); }
[ "public", "function", "actionIndex", "(", ")", "{", "$", "model", "=", "$", "this", "->", "prepare", "(", ")", ";", "if", "(", "$", "model", "->", "files", "!=", "array", "(", ")", "&&", "isset", "(", "$", "_POST", "[", "'generate'", "]", ",", "$", "_POST", "[", "'answers'", "]", ")", ")", "{", "$", "model", "->", "answers", "=", "$", "_POST", "[", "'answers'", "]", ";", "$", "model", "->", "status", "=", "$", "model", "->", "save", "(", ")", "?", "CCodeModel", "::", "STATUS_SUCCESS", ":", "CCodeModel", "::", "STATUS_ERROR", ";", "}", "$", "this", "->", "render", "(", "'index'", ",", "array", "(", "'model'", "=>", "$", "model", ",", ")", ")", ";", "}" ]
The code generation action. This is the action that displays the code generation interface. Child classes mainly need to provide the 'index' view for collecting user parameters for code generation.
[ "The", "code", "generation", "action", ".", "This", "is", "the", "action", "that", "displays", "the", "code", "generation", "interface", ".", "Child", "classes", "mainly", "need", "to", "provide", "the", "index", "view", "for", "collecting", "user", "parameters", "for", "code", "generation", "." ]
af3cbce71db83c4476c8a4289517b2984c740f31
https://github.com/yiisoft/yii/blob/af3cbce71db83c4476c8a4289517b2984c740f31/framework/gii/CCodeGenerator.php#L61-L73
train
yiisoft/yii
framework/gii/CCodeGenerator.php
CCodeGenerator.actionCode
public function actionCode() { $model=$this->prepare(); if(isset($_GET['id']) && isset($model->files[$_GET['id']])) { $this->renderPartial('/common/code', array( 'file'=>$model->files[$_GET['id']], )); } else throw new CHttpException(404,'Unable to find the code you requested.'); }
php
public function actionCode() { $model=$this->prepare(); if(isset($_GET['id']) && isset($model->files[$_GET['id']])) { $this->renderPartial('/common/code', array( 'file'=>$model->files[$_GET['id']], )); } else throw new CHttpException(404,'Unable to find the code you requested.'); }
[ "public", "function", "actionCode", "(", ")", "{", "$", "model", "=", "$", "this", "->", "prepare", "(", ")", ";", "if", "(", "isset", "(", "$", "_GET", "[", "'id'", "]", ")", "&&", "isset", "(", "$", "model", "->", "files", "[", "$", "_GET", "[", "'id'", "]", "]", ")", ")", "{", "$", "this", "->", "renderPartial", "(", "'/common/code'", ",", "array", "(", "'file'", "=>", "$", "model", "->", "files", "[", "$", "_GET", "[", "'id'", "]", "]", ",", ")", ")", ";", "}", "else", "throw", "new", "CHttpException", "(", "404", ",", "'Unable to find the code you requested.'", ")", ";", "}" ]
The code preview action. This action shows up the specified generated code. @throws CHttpException if unable to find code generated.
[ "The", "code", "preview", "action", ".", "This", "action", "shows", "up", "the", "specified", "generated", "code", "." ]
af3cbce71db83c4476c8a4289517b2984c740f31
https://github.com/yiisoft/yii/blob/af3cbce71db83c4476c8a4289517b2984c740f31/framework/gii/CCodeGenerator.php#L80-L91
train