_id stringlengths 2 7 | title stringlengths 3 151 | partition stringclasses 3
values | text stringlengths 33 8k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q19400 | GiiModule.findGenerators | train | 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)
{
i... | php | {
"resource": ""
} |
q19401 | ModelGenerator.actionGetTableNames | train | public function actionGetTableNames($db)
{
if(Yii::app()->getRequest()->getIsAjaxRequest())
{
$all = array();
if(!empty($db) && Yii::app()->hasComponent($db)!==false | php | {
"resource": ""
} |
q19402 | CLogRoute.collectLogs | train | 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);
| php | {
"resource": ""
} |
q19403 | CMssqlSchema.compareTableNames | train | public function compareTableNames($name1,$name2)
{
$name1=str_replace(array('[',']'),'',$name1);
$name2=str_replace(array('[',']'),'',$name2);
| php | {
"resource": ""
} |
q19404 | CMssqlSchema.findForeignKeys | train | 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(... | php | {
"resource": ""
} |
q19405 | CWsdlGenerator.generateWsdl | train | 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('\... | php | {
"resource": ""
} |
q19406 | ShellCommand.addCommands | train | protected function addCommands(CConsoleCommandRunner $runner)
{
$runner->addCommands(Yii::getPathOfAlias('system.cli.commands.shell'));
$runner->addCommands(Yii::getPathOfAlias('application.commands.shell'));
| php | {
"resource": ""
} |
q19407 | CConsoleApplication.init | train | protected function init()
{
parent::init();
if(empty($_SERVER['argv']))
die('This script must be run from the | php | {
"resource": ""
} |
q19408 | CConsoleApplication.processRequest | train | public function processRequest()
{
$exitCode=$this->_runner->run($_SERVER['argv']);
| php | {
"resource": ""
} |
q19409 | CTheme.getViewFile | train | public function getViewFile($controller,$viewName)
{
$moduleViewPath=$this->getViewPath();
if(($module=$controller->getModule())!==null) | php | {
"resource": ""
} |
q19410 | CTheme.getLayoutFile | train | 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->g... | php | {
"resource": ""
} |
q19411 | LoginForm.login | train | public function login()
{
if($this->_identity===null)
{
$this->_identity=new UserIdentity('yiier',$this->password);
$this->_identity->authenticate();
}
| php | {
"resource": ""
} |
q19412 | CCodeGenerator.actionIndex | train | public function actionIndex()
{
$model=$this->prepare();
if($model->files!=array() && isset($_POST['generate'], $_POST['answers']))
{
$model->answers=$_POST['answers'];
| php | {
"resource": ""
} |
q19413 | CCodeGenerator.actionCode | train | public function actionCode()
{
$model=$this->prepare();
if(isset($_GET['id']) && isset($model->files[$_GET['id']]))
{
$this->renderPartial('/common/code', array(
| php | {
"resource": ""
} |
q19414 | CCodeGenerator.actionDiff | train | public function actionDiff()
{
Yii::import('gii.components.TextDiff');
$model=$this->prepare();
if(isset($_GET['id']) && isset($model->files[$_GET['id']]))
{
$file=$model->files[$_GET['id']];
if(!in_array($file->type,array('php', 'txt','js','css','sql')))
$diff=false;
elseif($file->operation===CC... | php | {
"resource": ""
} |
q19415 | CCodeGenerator.getViewPath | train | public function getViewPath()
{
if($this->_viewPath===null)
{
$class=new ReflectionClass(get_class($this)); | php | {
"resource": ""
} |
q19416 | CCodeGenerator.prepare | train | protected function prepare()
{
if($this->codeModel===null)
throw new CException(get_class($this).'.codeModel property must be specified.');
$modelClass=Yii::import($this->codeModel,true);
$model=new $modelClass; | php | {
"resource": ""
} |
q19417 | CChoiceFormat.format | train | public static function format($messages, $number)
{
$n=preg_match_all('/\s*([^#]*)\s*#([^\|]*)\|/',$messages.'|',$matches);
if($n===0)
return $messages;
for($i=0;$i<$n;++$i)
{
$expression=$matches[1][$i];
$message=$matches[2][$i];
if($expression===(string)(int)$expression)
{
if($expression==... | php | {
"resource": ""
} |
q19418 | PostController.actionSuggestTags | train | public function actionSuggestTags()
{
if(isset($_GET['q']) && ($keyword=trim($_GET['q']))!=='')
{
| php | {
"resource": ""
} |
q19419 | PostController.newComment | train | protected function newComment($post)
{
$comment=new Comment;
if(isset($_POST['ajax']) && $_POST['ajax']==='comment-form')
{
echo CActiveForm::validate($comment);
Yii::app()->end();
}
if(isset($_POST['Comment']))
{
$comment->attributes=$_POST['Comment'];
if($post->addComment($comment))
{
| php | {
"resource": ""
} |
q19420 | CSecurityManager.encrypt | train | public function encrypt($data,$key=null)
{
if($key===null)
$key=$this->getEncryptionKey();
$this->validateEncryptionKey($key);
$module=$this->openCryptModule();
srand();
$iv=@mcrypt_create_iv(mcrypt_enc_get_iv_size($module), MCRYPT_RAND);
@mcrypt_generic_init($module,$key,$iv);
| php | {
"resource": ""
} |
q19421 | CSecurityManager.validateData | train | public function validateData($data,$key=null)
{
if (!is_string($data))
return false;
$len=$this->strlen($this->computeHMAC('test'));
if($this->strlen($data)>=$len)
{
$hmac=$this->substr($data,0,$len);
| php | {
"resource": ""
} |
q19422 | CSecurityManager.generateRandomBytes | train | public function generateRandomBytes($length,$cryptographicallyStrong=true)
{
$bytes='';
if(function_exists('openssl_random_pseudo_bytes'))
{
$bytes=openssl_random_pseudo_bytes($length,$strong);
if($this->strlen($bytes)>=$length && ($strong || !$cryptographicallyStrong))
return $this->substr($bytes,0,$l... | php | {
"resource": ""
} |
q19423 | CSecurityManager.generateSessionRandomBlock | train | public function generateSessionRandomBlock()
{
ini_set('session.entropy_length',20);
if(ini_get('session.entropy_length')!=20)
return false;
// These calls are (supposed to be, according to PHP manual) safe even if
// there is already an active session for the calling script.
@session_start();
@session... | php | {
"resource": ""
} |
q19424 | CSecurityManager.substr | train | private function substr($string,$start,$length)
{
return $this->_mbstring | php | {
"resource": ""
} |
q19425 | CSecurityManager.unmaskToken | train | public function unmaskToken($maskedToken)
{
$decoded=base64_decode(strtr($maskedToken,'-_','+/'));
$length=$this->strlen($decoded)/2;
// Check if the masked token has an even length.
if(!is_int($length))
| php | {
"resource": ""
} |
q19426 | CGettextPoFile.load | train | public function load($file,$context)
{
$pattern='/(msgctxt\s+"(.*?(?<!\\\\))")?\s+'
.'msgid\s+((?:".*(?<!\\\\)"\s*)+)\s+'
.'msgstr\s+((?:".*(?<!\\\\)"\s*)+)/';
$matches=array();
$n=preg_match_all($pattern,file_get_contents($file),$matches);
$messages=array();
for($i=0; $i<$n; $i++)
{
if($matches[... | php | {
"resource": ""
} |
q19427 | ModelCommand.generateClassNames | train | protected function generateClassNames($schema,$pattern=null)
{
$this->_tables=array();
foreach($schema->getTableNames() as $name)
{
if($pattern===null)
$this->_tables[$name]=$this->generateClassName($this->removePrefix($name));
elseif(preg_match($pattern,$name,$matches))
{
if(count($matches)>1 &... | php | {
"resource": ""
} |
q19428 | CDataColumn.init | train | public function init()
{
parent::init();
if($this->name===null)
$this->sortable=false;
if($this->name===null | php | {
"resource": ""
} |
q19429 | CDataColumn.getHeaderCellContent | train | public function getHeaderCellContent()
{
if($this->grid->enableSorting && $this->sortable && $this->name!==null)
return $this->grid->dataProvider->getSort()->link($this->name,$this->header,array('class'=>'sort-link'));
elseif($this->name!==null && $this->header===null)
{
if($this->grid->dataProvider instan... | php | {
"resource": ""
} |
q19430 | CDirectoryCacheDependency.generateDependentData | train | protected function generateDependentData()
{
if($this->directory!==null)
return $this->generateTimestamps($this->directory); | php | {
"resource": ""
} |
q19431 | CLocale.getInstance | train | public static function getInstance($id)
{
static $locales=array(); | php | {
"resource": ""
} |
q19432 | CLocale.getMonthNames | train | public function getMonthNames($width='wide',$standAlone=false)
{
if($standAlone)
return isset($this->_data['monthNamesSA'][$width]) ? $this->_data['monthNamesSA'][$width] : $this->_data['monthNames'][$width];
else
return | php | {
"resource": ""
} |
q19433 | CLocale.getWeekDayNames | train | public function getWeekDayNames($width='wide',$standAlone=false)
{
if($standAlone)
return isset($this->_data['weekDayNamesSA'][$width]) ? $this->_data['weekDayNamesSA'][$width] : $this->_data['weekDayNames'][$width];
else
return | php | {
"resource": ""
} |
q19434 | CLocale.getLanguageID | train | public function getLanguageID($id)
{
// normalize id
$id = $this->getCanonicalID($id);
// | php | {
"resource": ""
} |
q19435 | CLocale.getScriptID | train | public function getScriptID($id)
{
// normalize id
$id = $this->getCanonicalID($id);
// find sub tags
if(($underscorePosition=strpos($id, '_'))!==false)
{
$subTag = explode('_', $id);
// script sub tags can be distinguished from territory sub tags | php | {
"resource": ""
} |
q19436 | CLocale.getTerritoryID | train | public function getTerritoryID($id)
{
// normalize id
$id = $this->getCanonicalID($id);
// find sub tags
if (($underscorePosition=strpos($id, '_'))!== false)
{
$subTag = explode('_', $id);
// | php | {
"resource": ""
} |
q19437 | CAttributeCollection.__isset | train | public function __isset($name)
{
if($this->contains($name))
return | php | {
"resource": ""
} |
q19438 | CAttributeCollection.mergeWith | train | public function mergeWith($data,$recursive=true)
{
if(!$this->caseSensitive && (is_array($data) || $data instanceof Traversable))
| php | {
"resource": ""
} |
q19439 | CDataProvider.getPagination | train | public function getPagination($className='CPagination')
{
if($this->_pagination===null)
{
$this->_pagination=new $className;
if(($id=$this->getId())!='')
| php | {
"resource": ""
} |
q19440 | CDataProvider.getSort | train | public function getSort($className='CSort')
{
if($this->_sort===null)
{
$this->_sort=new $className;
if(($id=$this->getId())!='')
| php | {
"resource": ""
} |
q19441 | CDataProvider.getData | train | public function getData($refresh=false)
{
if($this->_data===null || $refresh)
| php | {
"resource": ""
} |
q19442 | CDataProvider.getKeys | train | public function getKeys($refresh=false)
{
if($this->_keys===null || $refresh)
| php | {
"resource": ""
} |
q19443 | CAuthItem.assign | train | public function assign($userId,$bizRule=null,$data=null)
{
| php | {
"resource": ""
} |
q19444 | SiteController.actionLogin | train | public function actionLogin()
{
$user=new LoginForm;
if(Yii::app()->request->isPostRequest)
{
// collect user input data
if(isset($_POST['LoginForm']))
$user->setAttributes($_POST['LoginForm']);
// validate user input and redirect to previous page if valid
if($user->validate()) | php | {
"resource": ""
} |
q19445 | CDbAuthManager.hasItemChild | train | public function hasItemChild($itemName,$childName)
{
return $this->db->createCommand()
->select('parent')
->from($this->itemChildTable)
->where('parent=:parent AND child=:child', array( | php | {
"resource": ""
} |
q19446 | CDbAuthManager.isAssigned | train | public function isAssigned($itemName,$userId)
{
return $this->db->createCommand()
->select('itemname')
->from($this->assignmentTable)
->where('itemname=:itemname | php | {
"resource": ""
} |
q19447 | CDbAuthManager.getAuthAssignments | train | public function getAuthAssignments($userId)
{
$rows=$this->db->createCommand()
->select()
->from($this->assignmentTable)
->where('userid=:userid', array(':userid'=>$userId))
->queryAll();
$assignments=array();
foreach($rows as $row)
{
if(($data=@unserialize($row['data']))===false) | php | {
"resource": ""
} |
q19448 | CDbAuthManager.saveAuthAssignment | train | public function saveAuthAssignment($assignment)
{
$this->db->createCommand()
->update($this->assignmentTable, array(
'bizrule'=>$assignment->getBizRule(),
'data'=>serialize($assignment->getData()),
), | php | {
"resource": ""
} |
q19449 | CDbAuthManager.clearAll | train | public function clearAll()
{
$this->clearAuthAssignments();
$this->db->createCommand()->delete($this->itemChildTable);
| php | {
"resource": ""
} |
q19450 | CEmailValidator.validateValue | train | public function validateValue($value)
{
if(is_string($value) && $this->validateIDN)
$value=$this->encodeIDN($value);
// make sure string length is limited to avoid DOS attacks
$valid=is_string($value) && strlen($value)<=254 && (preg_match($this->pattern,$value) || | php | {
"resource": ""
} |
q19451 | CBooleanValidator.validateValue | train | public function validateValue($value)
{
if ($this->strict)
return $value===$this->trueValue | php | {
"resource": ""
} |
q19452 | CRedisCache.parseResponse | train | private function parseResponse()
{
if(($line=fgets($this->_socket))===false)
throw new CException('Failed reading data from redis connection socket.');
$type=$line[0];
$line=substr($line,1,-2);
switch($type)
{
case '+': // Status reply
return true;
case '-': // Error reply
throw new CExcepti... | php | {
"resource": ""
} |
q19453 | Lookup.item | train | public static function item($type,$code)
{
if(!isset(self::$_items[$type])) | php | {
"resource": ""
} |
q19454 | Lookup.loadItems | train | private static function loadItems($type)
{
self::$_items[$type]=array();
$models=self::model()->findAll(array(
'condition'=>'type=:type',
'params'=>array(':type'=>$type),
'order'=>'position', | php | {
"resource": ""
} |
q19455 | CCacheDependency.getHash | train | private function getHash()
{
if($this->_hash===null) | php | {
"resource": ""
} |
q19456 | CForm.submitted | train | public function submitted($buttonName='submit',$loadData=true)
{
$ret=$this->clicked($this->getUniqueId()) && $this->clicked($buttonName);
| php | {
"resource": ""
} |
q19457 | CForm.clicked | train | public function clicked($name)
{
if(strcasecmp($this->getRoot()->method,'get'))
return | php | {
"resource": ""
} |
q19458 | CForm.getModel | train | public function getModel($checkParent=true)
{
if(!$checkParent)
return $this->_model;
| php | {
"resource": ""
} |
q19459 | CForm.getModels | train | public function getModels()
{
$models=array();
if($this->_model!==null)
$models[]=$this->_model;
foreach($this->getElements() as $element)
{
| php | {
"resource": ""
} |
q19460 | CForm.getUniqueId | train | protected function getUniqueId()
{
if(isset($this->attributes['id']))
return 'yform_'.$this->attributes['id']; | php | {
"resource": ""
} |
q19461 | CUrlValidator.encodeIDN | train | private function encodeIDN($value)
{
if(preg_match_all('/^(.*):\/\/([^\/]+)(.*)$/',$value,$matches))
{
if(function_exists('idn_to_ascii'))
$value=$matches[1][0].'://'.idn_to_ascii($matches[2][0]).$matches[3][0];
else
{
| php | {
"resource": ""
} |
q19462 | CUrlValidator.decodeIDN | train | private function decodeIDN($value)
{
if(preg_match_all('/^(.*):\/\/([^\/]+)(.*)$/',$value,$matches))
{
if(function_exists('idn_to_utf8'))
$value=$matches[1][0].'://'.idn_to_utf8($matches[2][0]).$matches[3][0];
else
{
| php | {
"resource": ""
} |
q19463 | CMenu.renderMenu | train | protected function renderMenu($items)
{
if(count($items))
{
echo CHtml::openTag('ul',$this->htmlOptions)."\n"; | php | {
"resource": ""
} |
q19464 | CMenu.renderMenuRecursive | train | protected function renderMenuRecursive($items)
{
$count=0;
$n=count($items);
foreach($items as $item)
{
$count++;
$options=isset($item['itemOptions']) ? $item['itemOptions'] : array();
$class=array();
if($item['active'] && $this->activeCssClass!='')
$class[]=$this->activeCssClass;
if($count=... | php | {
"resource": ""
} |
q19465 | CMysqlCommandBuilder.applyJoin | train | public function applyJoin($sql,$join)
{
if($join=='')
return $sql;
if(strpos($sql,'UPDATE')===0 && ($pos=strpos($sql,'SET'))!==false)
return substr($sql,0,$pos).$join.' '.substr($sql,$pos);
elseif(strpos($sql,'DELETE FROM ')===0)
| php | {
"resource": ""
} |
q19466 | CDefaultValueValidator.validateAttribute | train | protected function validateAttribute($object,$attribute)
{
if(!$this->setOnEmpty)
$object->$attribute=$this->value;
else
{
| php | {
"resource": ""
} |
q19467 | CActiveDataProvider.getSort | train | public function getSort($className='CSort')
{
if(($sort=parent::getSort($className))!==false) | php | {
"resource": ""
} |
q19468 | CActiveDataProvider.calculateTotalItemCount | train | protected function calculateTotalItemCount()
{
$baseCriteria=$this->model->getDbCriteria(false);
if($baseCriteria!==null) | php | {
"resource": ""
} |
q19469 | CConsoleCommandRunner.run | train | public function run($args)
{
$this->_scriptName=$args[0];
array_shift($args);
if(isset($args[0]))
{
$name=$args[0];
array_shift($args);
}
else
$name='help';
$oldCommand=$this->_command;
if(($command=$this->createCommand($name))===null)
| php | {
"resource": ""
} |
q19470 | CConsoleCommandRunner.findCommands | train | public function findCommands($path)
{
if(($dir=@opendir($path))===false)
return array();
$commands=array();
while(($name=readdir($dir))!==false)
{
$file=$path.DIRECTORY_SEPARATOR.$name;
| php | {
"resource": ""
} |
q19471 | CConsoleCommandRunner.addCommands | train | public function addCommands($path)
{
if(($commands=$this->findCommands($path))!==array())
| php | {
"resource": ""
} |
q19472 | CJuiDialog.init | train | public function init()
{
parent::init();
$id=$this->getId();
if(isset($this->htmlOptions['id']))
$id=$this->htmlOptions['id'];
else
$this->htmlOptions['id']=$id;
$options=CJavaScript::encode($this->options); | php | {
"resource": ""
} |
q19473 | CDbCommandBuilder.getLastInsertID | train | public function getLastInsertID($table)
{
$this->ensureTable($table);
if($table->sequenceName!==null)
return | php | {
"resource": ""
} |
q19474 | CDbCommandBuilder.createFindCommand | train | public function createFindCommand($table,$criteria,$alias='t')
{
$this->ensureTable($table);
$select=is_array($criteria->select) ? implode(', ',$criteria->select) : $criteria->select;
if($criteria->alias!='')
$alias=$criteria->alias;
$alias=$this->_schema->quoteTableName($alias);
// issue 1432: need to e... | php | {
"resource": ""
} |
q19475 | CDbCommandBuilder.createDeleteCommand | train | public function createDeleteCommand($table,$criteria)
{
$this->ensureTable($table);
$sql="DELETE FROM {$table->rawName}";
$sql=$this->applyJoin($sql,$criteria->join);
$sql=$this->applyCondition($sql,$criteria->condition);
$sql=$this->applyGroup($sql,$criteria->group);
$sql=$this->applyHaving($sql,$criteria... | php | {
"resource": ""
} |
q19476 | CDbCommandBuilder.createSqlCommand | train | public function createSqlCommand($sql,$params=array())
{
$command=$this->_connection->createCommand($sql);
| php | {
"resource": ""
} |
q19477 | CDbCommandBuilder.bindValues | train | public function bindValues($command, $values)
{
if(($n=count($values))===0)
return;
if(isset($values[0])) // question mark placeholders
{
for($i=0;$i<$n;++$i)
$command->bindValue($i+1,$values[$i]);
}
else // named placeholders
{
| php | {
"resource": ""
} |
q19478 | CDbCommandBuilder.createCriteria | train | public function createCriteria($condition='',$params=array())
{
if(is_array($condition))
$criteria=new CDbCriteria($condition);
elseif($condition instanceof | php | {
"resource": ""
} |
q19479 | CDbCommandBuilder.createPkCriteria | train | public function createPkCriteria($table,$pk,$condition='',$params=array(),$prefix=null)
{
$this->ensureTable($table);
$criteria=$this->createCriteria($condition,$params);
if($criteria->alias!='')
$prefix=$this->_schema->quoteTableName($criteria->alias).'.';
if(!is_array($pk)) // single key
$pk=array($pk)... | php | {
"resource": ""
} |
q19480 | CDbCommandBuilder.createColumnCriteria | train | public function createColumnCriteria($table,$columns,$condition='',$params=array(),$prefix=null)
{
$this->ensureTable($table);
$criteria=$this->createCriteria($condition,$params);
if($criteria->alias!='')
$prefix=$this->_schema->quoteTableName($criteria->alias).'.';
$bindByPosition=isset($criteria->params[0... | php | {
"resource": ""
} |
q19481 | CDbCommandBuilder.createSearchCondition | train | public function createSearchCondition($table,$columns,$keywords,$prefix=null,$caseSensitive=true)
{
$this->ensureTable($table);
if(!is_array($keywords))
$keywords=preg_split('/\s+/u',$keywords,-1,PREG_SPLIT_NO_EMPTY);
if(empty($keywords))
return '';
if($prefix===null)
$prefix=$table->rawName.'.';
$c... | php | {
"resource": ""
} |
q19482 | CDbCommandBuilder.ensureTable | train | protected function ensureTable(&$table)
{
if(is_string($table) && ($table=$this->_schema->getTable($tableName=$table))===null)
throw | php | {
"resource": ""
} |
q19483 | CDbStatePersister.save | train | public function save($state)
{
$command=$this->db->createCommand();
if(false===$this->exists())
return $command->insert($this->stateTableName,array(
$this->keyField=>Yii::app()->name,
| php | {
"resource": ""
} |
q19484 | CDbStatePersister.createTable | train | protected function createTable()
{
try
{
$command=$this->db->createCommand();
$command->createTable($this->stateTableName,array(
$this->keyField=>'string NOT NULL',
$this->valueField=>'text NOT NULL',
'PRIMARY KEY ('.$this->db->quoteColumnName($this->keyField).')'
));
}
catch (CDbException... | php | {
"resource": ""
} |
q19485 | CDateFormatter.format | train | public function format($pattern,$time)
{
if($time===null)
return null;
if(is_string($time))
{
if(ctype_digit($time) || ($time{0}=='-' && ctype_digit(substr($time, 1))))
$time=(int)$time;
else
$time=strtotime($time);
}
$date=CTimestamp::getDate($time,false,false);
$tokens=$this->parseForma... | php | {
"resource": ""
} |
q19486 | CDateFormatter.formatDateTime | train | public function formatDateTime($timestamp,$dateWidth='medium',$timeWidth='medium')
{
if(!empty($dateWidth))
$date=$this->format($this->_locale->getDateFormat($dateWidth),$timestamp);
if(!empty($timeWidth))
$time=$this->format($this->_locale->getTimeFormat($timeWidth),$timestamp);
if(isset($date) && isset... | php | {
"resource": ""
} |
q19487 | CDateFormatter.parseFormat | train | protected function parseFormat($pattern)
{
static $formats=array(); // cache
if(isset($formats[$pattern]))
return $formats[$pattern];
$tokens=array();
$n=strlen($pattern);
$isLiteral=false;
$literal='';
for($i=0;$i<$n;++$i)
{
$c=$pattern[$i];
if($c==="'")
{
if($i<$n-1 && $pattern[$i+1]... | php | {
"resource": ""
} |
q19488 | CDateFormatter.formatMinutes | train | protected function formatMinutes($pattern,$date)
{
$minutes=$date['minutes'];
if($pattern==='m')
return $minutes;
elseif($pattern==='mm')
return str_pad($minutes,2,'0',STR_PAD_LEFT);
| php | {
"resource": ""
} |
q19489 | CDateFormatter.formatSeconds | train | protected function formatSeconds($pattern,$date)
{
$seconds=$date['seconds'];
if($pattern==='s')
return $seconds;
elseif($pattern==='ss')
return str_pad($seconds,2,'0',STR_PAD_LEFT);
| php | {
"resource": ""
} |
q19490 | CDateFormatter.formatWeekInYear | train | protected function formatWeekInYear($pattern,$date)
{
if($pattern==='w')
return @date('W',@mktime(0,0,0,$date['mon'],$date['mday'],$date['year'])); | php | {
"resource": ""
} |
q19491 | CDateFormatter.formatWeekInMonth | train | protected function formatWeekInMonth($pattern,$date)
{
if($pattern==='W')
{
$weekDay=date('N',mktime(0,0,0,$date['mon'],1,$date['year']));
return floor(($weekDay+$date['mday']-2)/7)+1;
}
| php | {
"resource": ""
} |
q19492 | CDateFormatter.formatTimeZone | train | protected function formatTimeZone($pattern,$date)
{
if($pattern[0]==='z' || $pattern[0]==='v')
return @date('T', @mktime($date['hours'], $date['minutes'], $date['seconds'], $date['mon'], $date['mday'], $date['year']));
elseif($pattern[0]==='Z')
return | php | {
"resource": ""
} |
q19493 | CDateFormatter.formatEra | train | protected function formatEra($pattern,$date)
{
$era=$date['year']>0 ? 1 : 0;
switch($pattern)
{
case 'G':
case 'GG':
case 'GGG':
return $this->_locale->getEraName($era,'abbreviated');
case 'GGGG':
return $this->_locale->getEraName($era,'wide');
case 'GGGGG':
| php | {
"resource": ""
} |
q19494 | CFileLogRoute.processLogs | train | protected function processLogs($logs)
{
$text='';
foreach($logs as $log)
$text.=$this->formatLogMessage($log[0],$log[1],$log[2],$log[3]);
$logFile=$this->getLogPath().DIRECTORY_SEPARATOR.$this->getLogFile();
$fp=@fopen($logFile,'a');
@flock($fp,LOCK_EX);
if(@filesize($logFile)>$this->getMaxFileSize()*1... | php | {
"resource": ""
} |
q19495 | CGoogleApi.init | train | public static function init($apiKey=null)
{
if($apiKey===null)
return CHtml::scriptFile(self::$bootstrapUrl); | php | {
"resource": ""
} |
q19496 | Tag.findTagWeights | train | public function findTagWeights($limit=20)
{
$models=$this->findAll(array(
'order'=>'frequency DESC',
'limit'=>$limit,
));
$total=0;
foreach($models as $model)
$total+=$model->frequency;
$tags=array();
if($total>0)
{
| php | {
"resource": ""
} |
q19497 | CAssetManager.setBasePath | train | public function setBasePath($value)
{
if(($basePath=realpath($value))!==false && is_dir($basePath) && is_writable($basePath))
$this->_basePath=$basePath;
else
throw new CException(Yii::t('yii','CAssetManager.basePath | php | {
"resource": ""
} |
q19498 | CAssetManager.getPublishedUrl | train | public function getPublishedUrl($path,$hashByName=false)
{
if(isset($this->_published[$path]))
return $this->_published[$path];
if(is_string($path) | php | {
"resource": ""
} |
q19499 | CAssetManager.generatePath | train | protected function generatePath($file,$hashByName=false)
{
if (is_file($file))
$pathForHashing=$hashByName ? dirname($file) : dirname($file).filemtime($file);
else
| php | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.