code
stringlengths
17
247k
docstring
stringlengths
30
30.3k
func_name
stringlengths
1
89
language
stringclasses
1 value
repo
stringlengths
7
63
path
stringlengths
7
153
url
stringlengths
51
209
license
stringclasses
4 values
public function isAssigned($userId) { return $this->_auth->isAssigned($this->_name,$userId); }
Returns a value indicating whether this item has been assigned to the user. @param mixed $userId the user ID (see {@link IWebUser::getId}) @return boolean whether the item has been assigned to the user. @see IAuthManager::isAssigned
isAssigned
php
yiisoft/yii
framework/web/auth/CAuthItem.php
https://github.com/yiisoft/yii/blob/master/framework/web/auth/CAuthItem.php
BSD-3-Clause
public function getAssignment($userId) { return $this->_auth->getAuthAssignment($this->_name,$userId); }
Returns the item assignment information. @param mixed $userId the user ID (see {@link IWebUser::getId}) @return CAuthAssignment the item assignment information. Null is returned if this item is not assigned to the user. @see IAuthManager::getAuthAssignment
getAssignment
php
yiisoft/yii
framework/web/auth/CAuthItem.php
https://github.com/yiisoft/yii/blob/master/framework/web/auth/CAuthItem.php
BSD-3-Clause
public function renderFile($context,$sourceFile,$data,$return) { if(!is_file($sourceFile) || ($file=realpath($sourceFile))===false) throw new CException(Yii::t('yii','View file "{file}" does not exist.',array('{file}'=>$sourceFile))); $viewFile=$this->getViewFile($sourceFile); if(@filemtime($sourceFile)>@filemtime($viewFile)) { $this->generateViewFile($sourceFile,$viewFile); @chmod($viewFile,$this->filePermission); } return $context->renderInternal($viewFile,$data,$return); }
Renders a view file. This method is required by {@link IViewRenderer}. @param CBaseController $context the controller or widget who is rendering the view file. @param string $sourceFile the view file path @param mixed $data the data to be passed to the view @param boolean $return whether the rendering result should be returned @return mixed the rendering result, or null if the rendering result is not needed. @throws CException
renderFile
php
yiisoft/yii
framework/web/renderers/CViewRenderer.php
https://github.com/yiisoft/yii/blob/master/framework/web/renderers/CViewRenderer.php
BSD-3-Clause
protected function getViewFile($file) { if($this->useRuntimePath) { $crc=sprintf('%x', crc32(get_class($this).Yii::getVersion().dirname($file))); $viewFile=Yii::app()->getRuntimePath().DIRECTORY_SEPARATOR.'views'.DIRECTORY_SEPARATOR.$crc.DIRECTORY_SEPARATOR.basename($file); if(!is_file($viewFile)) @mkdir(dirname($viewFile),$this->filePermission,true); return $viewFile; } else return $file.'c'; }
Generates the resulting view file path. @param string $file source view file path @return string resulting view file path
getViewFile
php
yiisoft/yii
framework/web/renderers/CViewRenderer.php
https://github.com/yiisoft/yii/blob/master/framework/web/renderers/CViewRenderer.php
BSD-3-Clause
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
setPermissions
php
yiisoft/yii
framework/cli/commands/WebAppCommand.php
https://github.com/yiisoft/yii/blob/master/framework/cli/commands/WebAppCommand.php
BSD-3-Clause
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
addFileModificationCallbacks
php
yiisoft/yii
framework/cli/commands/WebAppCommand.php
https://github.com/yiisoft/yii/blob/master/framework/cli/commands/WebAppCommand.php
BSD-3-Clause
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
generateIndex
php
yiisoft/yii
framework/cli/commands/WebAppCommand.php
https://github.com/yiisoft/yii/blob/master/framework/cli/commands/WebAppCommand.php
BSD-3-Clause
public function generateTestBoostrap($source,$params) { $content=file_get_contents($source); $yii=realpath(dirname(__FILE__).'/../../yiit.php'); $yii=$this->getRelativePath($yii,$this->_rootPath.DIRECTORY_SEPARATOR.'protected'.DIRECTORY_SEPARATOR.'tests'.DIRECTORY_SEPARATOR.'bootstrap.php'); $yii=str_replace('\\','\\\\',$yii); return preg_replace('/\$yiit\s*=(.*?);/',"\$yiit=$yii;",$content); }
Inserts path to framework's yiit.php into application's index-test.php @param string $source source file path @param array $params @return string modified source file content
generateTestBoostrap
php
yiisoft/yii
framework/cli/commands/WebAppCommand.php
https://github.com/yiisoft/yii/blob/master/framework/cli/commands/WebAppCommand.php
BSD-3-Clause
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
generateYiic
php
yiisoft/yii
framework/cli/commands/WebAppCommand.php
https://github.com/yiisoft/yii/blob/master/framework/cli/commands/WebAppCommand.php
BSD-3-Clause
protected function getRelativePath($path1,$path2) { $segs1=explode(DIRECTORY_SEPARATOR,$path1); $segs2=explode(DIRECTORY_SEPARATOR,$path2); $n1=count($segs1); $n2=count($segs2); for($i=0;$i<$n1 && $i<$n2;++$i) { if($segs1[$i]!==$segs2[$i]) break; } if($i===0) return "'".$path1."'"; $up=''; for($j=$i;$j<$n2-1;++$j) $up.='/..'; for(;$i<$n1-1;++$i) $up.='/'.$segs1[$i]; return 'dirname(__FILE__).\''.$up.'/'.basename($path1).'\''; }
Returns variant of $path1 relative to $path2 @param string $path1 @param string $path2 @return string $path1 relative to $path2
getRelativePath
php
yiisoft/yii
framework/cli/commands/WebAppCommand.php
https://github.com/yiisoft/yii/blob/master/framework/cli/commands/WebAppCommand.php
BSD-3-Clause
protected function isRelationTable($table) { $pk=$table->primaryKey; return (count($pk) === 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 foreign 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" helper table. Their PK has 2 fields, and both of those fields are also FK to other separate tables. @param CDbTableSchema $table table to inspect @return boolean true if table matches description of helper table.
isRelationTable
php
yiisoft/yii
framework/cli/commands/shell/ModelCommand.php
https://github.com/yiisoft/yii/blob/master/framework/cli/commands/shell/ModelCommand.php
BSD-3-Clause
protected function generateClassName($tableName) { return str_replace(' ','', ucwords( trim( strtolower( str_replace(array('-','_'),' ', preg_replace('/(?<![A-Z])[A-Z]/', ' \0', $tableName)))))); }
Generates model class name based on a table name @param string $tableName the table name @return string the generated model class name
generateClassName
php
yiisoft/yii
framework/cli/commands/shell/ModelCommand.php
https://github.com/yiisoft/yii/blob/master/framework/cli/commands/shell/ModelCommand.php
BSD-3-Clause
public function getHelp() { return <<<EOD USAGE help [command-name] DESCRIPTION Display the help information for the specified command. If the command name is not given, all commands will be listed. PARAMETERS * command-name: optional, the name of the command to show help information. EOD; }
Provides the command description. @return string the command description.
getHelp
php
yiisoft/yii
framework/cli/commands/shell/HelpCommand.php
https://github.com/yiisoft/yii/blob/master/framework/cli/commands/shell/HelpCommand.php
BSD-3-Clause
public function authenticate() { $users=array( // username => password 'demo'=>'demo', 'admin'=>'admin', ); if(!isset($users[$this->username])) $this->errorCode=self::ERROR_USERNAME_INVALID; elseif($users[$this->username]!==$this->password) $this->errorCode=self::ERROR_PASSWORD_INVALID; else $this->errorCode=self::ERROR_NONE; return !$this->errorCode; }
Authenticates a user. The example implementation makes sure if the username and password are both 'demo'. In practical applications, this should be changed to authenticate against some persistent user identity storage (e.g. database). @return boolean whether authentication succeeds.
authenticate
php
yiisoft/yii
framework/cli/views/webapp/protected/components/UserIdentity.php
https://github.com/yiisoft/yii/blob/master/framework/cli/views/webapp/protected/components/UserIdentity.php
BSD-3-Clause
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
filter
php
yiisoft/yii
framework/logging/CLogFilter.php
https://github.com/yiisoft/yii/blob/master/framework/logging/CLogFilter.php
BSD-3-Clause
protected function format(&$logs) { $prefix=''; if($this->prefixSession && ($id=session_id())!=='') $prefix.="[$id]"; if($this->prefixUser && ($user=Yii::app()->getComponent('user',false))!==null) $prefix.='['.$user->getName().']['.$user->getId().']'; if($prefix!=='') { foreach($logs as &$log) $log[0]=$prefix.' '.$log[0]; } }
Formats the log messages. The default implementation will prefix each message with session ID if {@link prefixSession} is set true. It may also prefix each message with the current user's name and ID if {@link prefixUser} is true. @param array $logs the log messages
format
php
yiisoft/yii
framework/logging/CLogFilter.php
https://github.com/yiisoft/yii/blob/master/framework/logging/CLogFilter.php
BSD-3-Clause
protected function getContext() { $context=array(); if($this->logUser && ($user=Yii::app()->getComponent('user',false))!==null) $context[]='User: '.$user->getName().' (ID: '.$user->getId().')'; if($this->dumper==='var_export' || $this->dumper==='print_r') { foreach($this->logVars as $name) if(($value=$this->getGlobalsValue($name))!==null) $context[]="\${$name}=".call_user_func($this->dumper,$value,true); } else { foreach($this->logVars as $name) if(($value=$this->getGlobalsValue($name))!==null) $context[]="\${$name}=".call_user_func($this->dumper,$value); } return implode("\n\n",$context); }
Generates the context information to be logged. The default implementation will dump user information, system variables, etc. @return string the context information. If an empty string, it means no context information.
getContext
php
yiisoft/yii
framework/logging/CLogFilter.php
https://github.com/yiisoft/yii/blob/master/framework/logging/CLogFilter.php
BSD-3-Clause
public function log($message,$level='info',$category='application') { $this->_logs[]=array($message,$level,$category,microtime(true)); $this->_logCount++; if($this->autoFlush>0 && $this->_logCount>=$this->autoFlush && !$this->_processing) { $this->_processing=true; $this->flush($this->autoDump); $this->_processing=false; } }
Logs a message. Messages logged by this method may be retrieved back via {@link getLogs}. @param string $message message to be logged @param string $level level of the message (e.g. 'Trace', 'Warning', 'Error'). It is case-insensitive. @param string $category category of the message (e.g. 'system.web'). It is case-insensitive. @see getLogs
log
php
yiisoft/yii
framework/logging/CLogger.php
https://github.com/yiisoft/yii/blob/master/framework/logging/CLogger.php
BSD-3-Clause
private function filterAllCategories($value, $index) { $cat=strtolower($value[$index]); $ret=empty($this->_categories); foreach($this->_categories as $category) { if($cat===$category || (($c=rtrim($category,'.*'))!==$category && strpos($cat,$c)===0)) $ret=true; } if($ret) { foreach($this->_except as $category) { if($cat===$category || (($c=rtrim($category,'.*'))!==$category && strpos($cat,$c)===0)) $ret=false; } } return $ret; }
Filter function used to filter included and excluded categories @param array $value element to be filtered @param integer $index index of the values array to be used for check @return boolean true if valid timing entry, false if not.
filterAllCategories
php
yiisoft/yii
framework/logging/CLogger.php
https://github.com/yiisoft/yii/blob/master/framework/logging/CLogger.php
BSD-3-Clause
public function getExecutionTime() { return microtime(true)-YII_BEGIN_TIME; }
Returns the total time for serving the current request. This method calculates the difference between now and the timestamp defined by constant YII_BEGIN_TIME. To estimate the execution time more accurately, the constant should be defined as early as possible (best at the beginning of the entry script.) @return float the total time for serving the current request.
getExecutionTime
php
yiisoft/yii
framework/logging/CLogger.php
https://github.com/yiisoft/yii/blob/master/framework/logging/CLogger.php
BSD-3-Clause
public function getMemoryUsage() { if(function_exists('memory_get_usage')) return memory_get_usage(); else { $output=array(); if(strncmp(PHP_OS,'WIN',3)===0) { exec('tasklist /FI "PID eq ' . getmypid() . '" /FO LIST',$output); return isset($output[5])?preg_replace('/[\D]/','',$output[5])*1024 : 0; } else { $pid=getmypid(); exec("ps -eo%mem,rss,pid | grep $pid", $output); $output=explode(" ",$output[0]); return isset($output[1]) ? $output[1]*1024 : 0; } } }
Returns the memory usage of the current application. This method relies on the PHP function memory_get_usage(). If it is not available, the method will attempt to use OS programs to determine the memory usage. A value 0 will be returned if the memory usage can still not be determined. @return integer memory usage of the application (in bytes).
getMemoryUsage
php
yiisoft/yii
framework/logging/CLogger.php
https://github.com/yiisoft/yii/blob/master/framework/logging/CLogger.php
BSD-3-Clause
public function getProfilingResults($token=null,$categories=null,$refresh=false) { if($this->_timings===null || $refresh) $this->calculateTimings(); if($token===null && $categories===null) return $this->_timings; $timings = $this->_timings; if($categories!==null) { $this->_categories=preg_split('/[\s,]+/',strtolower($categories),-1,PREG_SPLIT_NO_EMPTY); $timings=array_filter($timings,array($this,'filterTimingByCategory')); } $results=array(); foreach($timings as $timing) { if($token===null || $timing[0]===$token) $results[]=$timing[2]; } return $results; }
Returns the profiling results. The results may be filtered by token and/or category. If no filter is specified, the returned results would be an array with each element being array($token,$category,$time). If a filter is specified, the results would be an array of timings. Since 1.1.11, filtering results by category supports the same format used for filtering logs in {@link getLogs}, and similarly supports filtering by multiple categories and wildcard. @param string $token token filter. Defaults to null, meaning not filtered by token. @param string $categories category filter. Defaults to null, meaning not filtered by category. @param boolean $refresh whether to refresh the internal timing calculations. If false, only the first time calling this method will the timings be calculated internally. @return array the profiling results.
getProfilingResults
php
yiisoft/yii
framework/logging/CLogger.php
https://github.com/yiisoft/yii/blob/master/framework/logging/CLogger.php
BSD-3-Clause
public function flush($dumpLogs=false) { $this->onFlush(new CEvent($this, array('dumpLogs'=>$dumpLogs))); $this->_logs=array(); $this->_logCount=0; }
Removes all recorded messages from the memory. This method will raise an {@link onFlush} event. The attached event handlers can process the log messages before they are removed. @param boolean $dumpLogs whether to process the logs immediately as they are passed to log route @since 1.1.0
flush
php
yiisoft/yii
framework/logging/CLogger.php
https://github.com/yiisoft/yii/blob/master/framework/logging/CLogger.php
BSD-3-Clause
public function onFlush($event) { $this->raiseEvent('onFlush', $event); }
Raises an <code>onFlush</code> event. @param CEvent $event the event parameter @since 1.1.0
onFlush
php
yiisoft/yii
framework/logging/CLogger.php
https://github.com/yiisoft/yii/blob/master/framework/logging/CLogger.php
BSD-3-Clause
public function init() { parent::init(); if($this->getLogPath()===null) $this->setLogPath(Yii::app()->getRuntimePath()); }
Initializes the route. This method is invoked after the route is created by the route manager.
init
php
yiisoft/yii
framework/logging/CFileLogRoute.php
https://github.com/yiisoft/yii/blob/master/framework/logging/CFileLogRoute.php
BSD-3-Clause
private function resultEntryCompare($a, $b) { return ($a[4] < $b[4]) ? 1 : 0; }
Result entry compare function used by usort. Included to circumvent the use of closures (not supported by PHP 5.2) and create_function (deprecated since PHP 7.2.0) @param array $a @param array $b @return int 0 (a>=b), 1 (a<b)
resultEntryCompare
php
yiisoft/yii
framework/logging/CProfileLogRoute.php
https://github.com/yiisoft/yii/blob/master/framework/logging/CProfileLogRoute.php
BSD-3-Clause
public function setRoutes($config) { foreach($config as $name=>$route) $this->_routes[$name]=$route; }
@param array $config list of route configurations. Each array element represents the configuration for a single route and has the following array structure: <ul> <li>class: specifies the class name or alias for the route class.</li> <li>name-value pairs: configure the initial property values of the route.</li> </ul>
setRoutes
php
yiisoft/yii
framework/logging/CLogRouter.php
https://github.com/yiisoft/yii/blob/master/framework/logging/CLogRouter.php
BSD-3-Clause
public function processLogs() { $logger=Yii::getLogger(); $logger->flush(true); }
Collects and processes log messages from a logger. This method is an event handler to the {@link CApplication::onEndRequest} event. @since 1.1.0
processLogs
php
yiisoft/yii
framework/logging/CLogRouter.php
https://github.com/yiisoft/yii/blob/master/framework/logging/CLogRouter.php
BSD-3-Clause
protected function createLogTable($db,$tableName) { $db->createCommand()->createTable($tableName, array( 'id'=>'pk', 'level'=>'varchar(128)', 'category'=>'varchar(128)', 'logtime'=>'integer', 'message'=>'text', )); }
Creates the DB table for storing log messages. @param CDbConnection $db the database connection @param string $tableName the name of the table to be created
createLogTable
php
yiisoft/yii
framework/logging/CDbLogRoute.php
https://github.com/yiisoft/yii/blob/master/framework/logging/CDbLogRoute.php
BSD-3-Clause
protected function processLogs($logs) { $message=''; foreach($logs as $log) $message.=$this->formatLogMessage($log[0],$log[1],$log[2],$log[3]); $message=wordwrap($message,70); $subject=$this->getSubject(); if($subject===null) $subject=Yii::t('yii','Application Log'); foreach($this->getEmails() as $email) $this->sendEmail($email,$subject,$message); }
Sends log messages to specified email addresses. @param array $logs list of log messages
processLogs
php
yiisoft/yii
framework/logging/CEmailLogRoute.php
https://github.com/yiisoft/yii/blob/master/framework/logging/CEmailLogRoute.php
BSD-3-Clause
public function setEmails($value) { if(is_array($value)) $this->_email=$value; else $this->_email=preg_split('/[\s,]+/',$value,-1,PREG_SPLIT_NO_EMPTY); }
@param mixed $value list of destination email addresses. If the value is a string, it is assumed to be comma-separated email addresses.
setEmails
php
yiisoft/yii
framework/logging/CEmailLogRoute.php
https://github.com/yiisoft/yii/blob/master/framework/logging/CEmailLogRoute.php
BSD-3-Clause
public function setHeaders($value) { if (is_array($value)) $this->_headers=$value; else $this->_headers=preg_split('/\r\n|\n/',$value,-1,PREG_SPLIT_NO_EMPTY); }
@param mixed $value list of additional headers to use when sending an email. If the value is a string, it is assumed to be line break separated headers. @since 1.1.4
setHeaders
php
yiisoft/yii
framework/logging/CEmailLogRoute.php
https://github.com/yiisoft/yii/blob/master/framework/logging/CEmailLogRoute.php
BSD-3-Clause
protected function formatLogMessage($message,$level,$category,$time) { return @date('Y/m/d H:i:s',(int)$time)." [$level] [$category] $message\n"; }
Formats a log message given different fields. @param string $message message content @param integer $level message level @param string $category message category @param integer $time timestamp @return string formatted message
formatLogMessage
php
yiisoft/yii
framework/logging/CLogRoute.php
https://github.com/yiisoft/yii/blob/master/framework/logging/CLogRoute.php
BSD-3-Clause
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
collectLogs
php
yiisoft/yii
framework/logging/CLogRoute.php
https://github.com/yiisoft/yii/blob/master/framework/logging/CLogRoute.php
BSD-3-Clause
public function init() { echo <<<EOD <div class="form gii"> <p class="note"> Fields with <span class="required">*</span> are required. Click on the <span class="sticky">highlighted fields</span> to edit them. </p> EOD; parent::init(); }
Initializes the widget. This renders the form open tag.
init
php
yiisoft/yii
framework/gii/CCodeForm.php
https://github.com/yiisoft/yii/blob/master/framework/gii/CCodeForm.php
BSD-3-Clause
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.
actionIndex
php
yiisoft/yii
framework/gii/CCodeGenerator.php
https://github.com/yiisoft/yii/blob/master/framework/gii/CCodeGenerator.php
BSD-3-Clause
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.
actionCode
php
yiisoft/yii
framework/gii/CCodeGenerator.php
https://github.com/yiisoft/yii/blob/master/framework/gii/CCodeGenerator.php
BSD-3-Clause
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===CCodeFile::OP_OVERWRITE) $diff=TextDiff::compare(file_get_contents($file->path), $file->content); else $diff=''; $this->renderPartial('/common/diff',array( 'file'=>$file, 'diff'=>$diff, )); } else throw new CHttpException(404,'Unable to find the code you requested.'); }
The code diff action. This action shows up the difference between the newly generated code and the corresponding existing code. @throws CHttpException if unable to find code generated.
actionDiff
php
yiisoft/yii
framework/gii/CCodeGenerator.php
https://github.com/yiisoft/yii/blob/master/framework/gii/CCodeGenerator.php
BSD-3-Clause
public function classExists($name) { return class_exists($name,false) && in_array($name, get_declared_classes()); }
Checks if the named class exists (in a case sensitive manner). @param string $name class name to be checked @return boolean whether the class exists
classExists
php
yiisoft/yii
framework/gii/CCodeModel.php
https://github.com/yiisoft/yii/blob/master/framework/gii/CCodeModel.php
BSD-3-Clause
public function requiredTemplates() { return array(); }
Returns a list of code templates that are required. Derived classes usually should override this method. @return array list of code templates that are required. They should be file paths relative to {@link templatePath}.
requiredTemplates
php
yiisoft/yii
framework/gii/CCodeModel.php
https://github.com/yiisoft/yii/blob/master/framework/gii/CCodeModel.php
BSD-3-Clause
public function successMessage() { return 'The code has been generated successfully.'; }
Returns the message to be displayed when the newly generated code is saved successfully. Child classes should override this method if the message needs to be customized. @return string the message to be displayed when the newly generated code is saved successfully.
successMessage
php
yiisoft/yii
framework/gii/CCodeModel.php
https://github.com/yiisoft/yii/blob/master/framework/gii/CCodeModel.php
BSD-3-Clause
public function errorMessage() { return 'There was some error when generating the code. Please check the following messages.'; }
Returns the message to be displayed when some error occurred during code file saving. Child classes should override this method if the message needs to be customized. @return string the message to be displayed when some error occurred during code file saving.
errorMessage
php
yiisoft/yii
framework/gii/CCodeModel.php
https://github.com/yiisoft/yii/blob/master/framework/gii/CCodeModel.php
BSD-3-Clause
public function getTemplates() { return Yii::app()->controller->templates; }
Returns a list of available code templates (name=>directory). This method simply returns the {@link CCodeGenerator::templates} property value. @return array a list of available code templates (name=>directory).
getTemplates
php
yiisoft/yii
framework/gii/CCodeModel.php
https://github.com/yiisoft/yii/blob/master/framework/gii/CCodeModel.php
BSD-3-Clause
public function render($templateFile,$_params_=null) { if(!is_file($templateFile)) throw new CException("The template file '$templateFile' does not exist."); if(is_array($_params_)) extract($_params_,EXTR_PREFIX_SAME,'params'); else $params=$_params_; ob_start(); ob_implicit_flush(false); require($templateFile); return ob_get_clean(); }
Generates the code using the specified code template file. This method is manly used in {@link generate} to generate code. @param string $templateFile the code template file path @param array $_params_ a set of parameters to be extracted and made available in the code template @throws CException is template file does not exist @return string the generated code
render
php
yiisoft/yii
framework/gii/CCodeModel.php
https://github.com/yiisoft/yii/blob/master/framework/gii/CCodeModel.php
BSD-3-Clause
public function sticky($attribute,$params) { if(!$this->hasErrors()) $this->_stickyAttributes[$attribute]=$this->$attribute; }
The "sticky" validator. This validator does not really validate the attributes. It actually saves the attribute value in a file to make it sticky. @param string $attribute the attribute to be validated @param array $params the validation parameters
sticky
php
yiisoft/yii
framework/gii/CCodeModel.php
https://github.com/yiisoft/yii/blob/master/framework/gii/CCodeModel.php
BSD-3-Clause
public function loadStickyAttributes() { $this->_stickyAttributes=array(); $path=$this->getStickyFile(); if(is_file($path)) { $result=@include($path); if(is_array($result)) { $this->_stickyAttributes=$result; foreach($this->_stickyAttributes as $name=>$value) { if(property_exists($this,$name) || $this->canSetProperty($name)) $this->$name=$value; } } } }
Loads sticky attributes from a file and populates them into the model.
loadStickyAttributes
php
yiisoft/yii
framework/gii/CCodeModel.php
https://github.com/yiisoft/yii/blob/master/framework/gii/CCodeModel.php
BSD-3-Clause
public function saveStickyAttributes() { $path=$this->getStickyFile(); @mkdir(dirname($path),0755,true); file_put_contents($path,"<?php\nreturn ".var_export($this->_stickyAttributes,true).";\n"); }
Saves sticky attributes into a file.
saveStickyAttributes
php
yiisoft/yii
framework/gii/CCodeModel.php
https://github.com/yiisoft/yii/blob/master/framework/gii/CCodeModel.php
BSD-3-Clause
public function class2id($name) { return trim(strtolower(str_replace('_','-',preg_replace('/(?<![A-Z])[A-Z]/', '-\0', $name))),'-'); }
Converts a class name into a HTML ID. For example, 'PostTag' will be converted as 'post-tag'. @param string $name the string to be converted @return string the resulting ID
class2id
php
yiisoft/yii
framework/gii/CCodeModel.php
https://github.com/yiisoft/yii/blob/master/framework/gii/CCodeModel.php
BSD-3-Clause
public function class2name($name,$ucwords=true) { $result=trim(strtolower(str_replace('_',' ',preg_replace('/(?<![A-Z])[A-Z]/', ' \0', $name)))); return $ucwords ? ucwords($result) : $result; }
Converts a class name into space-separated words. For example, 'PostTag' will be converted as 'Post Tag'. @param string $name the string to be converted @param boolean $ucwords whether to capitalize the first letter in each word @return string the resulting words
class2name
php
yiisoft/yii
framework/gii/CCodeModel.php
https://github.com/yiisoft/yii/blob/master/framework/gii/CCodeModel.php
BSD-3-Clause
public function class2var($name) { $name[0]=strtolower($name[0]); return $name; }
Converts a class name into a variable name with the first letter in lower case. This method is provided because lcfirst() PHP function is only available for PHP 5.3+. @param string $name the class name @return string the variable name converted from the class name @since 1.1.4
class2var
php
yiisoft/yii
framework/gii/CCodeModel.php
https://github.com/yiisoft/yii/blob/master/framework/gii/CCodeModel.php
BSD-3-Clause
public function validateReservedWord($attribute,$params) { $value=$this->$attribute; if(in_array(strtolower($value),self::$keywords)) $this->addError($attribute, $this->getAttributeLabel($attribute).' cannot take a reserved PHP keyword.'); }
Validates an attribute to make sure it is not taking a PHP reserved keyword. @param string $attribute the attribute to be validated @param array $params validation parameters
validateReservedWord
php
yiisoft/yii
framework/gii/CCodeModel.php
https://github.com/yiisoft/yii/blob/master/framework/gii/CCodeModel.php
BSD-3-Clause
public function beforeControllerAction($controller, $action) { if(parent::beforeControllerAction($controller, $action)) { $route=$controller->id.'/'.$action->id; if(!$this->allowIp(Yii::app()->request->userHostAddress) && $route!=='default/error') throw new CHttpException(403,"You are not allowed to access this page."); $publicPages=array( 'default/login', 'default/error', ); if($this->password!==false && Yii::app()->user->isGuest && !in_array($route,$publicPages)) Yii::app()->user->loginRequired(); else return true; } return false; }
Performs access check to gii. This method will check to see if user IP and password are correct if they attempt to access actions other than "default/login" and "default/error". @param CController $controller the controller to be accessed. @param CAction $action the action to be accessed. @throws CHttpException if access denied @return boolean whether the action should be executed.
beforeControllerAction
php
yiisoft/yii
framework/gii/GiiModule.php
https://github.com/yiisoft/yii/blob/master/framework/gii/GiiModule.php
BSD-3-Clause
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
login
php
yiisoft/yii
framework/gii/models/LoginForm.php
https://github.com/yiisoft/yii/blob/master/framework/gii/models/LoginForm.php
BSD-3-Clause
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
actionGetTableNames
php
yiisoft/yii
framework/gii/generators/model/ModelGenerator.php
https://github.com/yiisoft/yii/blob/master/framework/gii/generators/model/ModelGenerator.php
BSD-3-Clause
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 table to inspect @return boolean true if table matches description of helper table.
isRelationTable
php
yiisoft/yii
framework/gii/generators/model/ModelCode.php
https://github.com/yiisoft/yii/blob/master/framework/gii/generators/model/ModelCode.php
BSD-3-Clause
function __construct($orig, $final1, $final2) { if (extension_loaded('xdiff')) { $engine = new Text_Diff_Engine_xdiff(); } else { $engine = new Text_Diff_Engine_native(); } $this->_edits = $this->_diff3($engine->diff($orig, $final1), $engine->diff($orig, $final2)); }
Computes diff between 3 sequences of strings. @param array $orig The original lines to use. @param array $final1 The first version to compare to. @param array $final2 The second version to compare to.
__construct
php
yiisoft/yii
framework/gii/components/Pear/Text/Diff3.php
https://github.com/yiisoft/yii/blob/master/framework/gii/components/Pear/Text/Diff3.php
BSD-3-Clause
function __construct($engine, $params) { // Backward compatibility workaround. if (!is_string($engine)) { $params = array($engine, $params); $engine = 'auto'; } if ($engine == 'auto') { $engine = extension_loaded('xdiff') ? 'xdiff' : 'native'; } else { $engine = basename($engine); } require_once 'Text/Diff/Engine/' . $engine . '.php'; $class = 'Text_Diff_Engine_' . $engine; $diff_engine = new $class(); $this->_edits = call_user_func_array(array($diff_engine, 'diff'), $params); }
Computes diffs between sequences of strings. @param string $engine Name of the diffing engine to use. 'auto' will automatically select the best. @param array $params Parameters to pass to the diffing engine. Normally an array of two arrays, each containing the lines from a file.
__construct
php
yiisoft/yii
framework/gii/components/Pear/Text/Diff.php
https://github.com/yiisoft/yii/blob/master/framework/gii/components/Pear/Text/Diff.php
BSD-3-Clause
function getDiff() { return $this->_edits; }
Returns the array of differences.
getDiff
php
yiisoft/yii
framework/gii/components/Pear/Text/Diff.php
https://github.com/yiisoft/yii/blob/master/framework/gii/components/Pear/Text/Diff.php
BSD-3-Clause
function countAddedLines() { $count = 0; foreach ($this->_edits as $edit) { if (is_a($edit, 'Text_Diff_Op_add') || is_a($edit, 'Text_Diff_Op_change')) { $count += $edit->nfinal(); } } return $count; }
returns the number of new (added) lines in a given diff. @since Text_Diff 1.1.0 @since Horde 3.2 @return integer The number of new lines
countAddedLines
php
yiisoft/yii
framework/gii/components/Pear/Text/Diff.php
https://github.com/yiisoft/yii/blob/master/framework/gii/components/Pear/Text/Diff.php
BSD-3-Clause
function countDeletedLines() { $count = 0; foreach ($this->_edits as $edit) { if (is_a($edit, 'Text_Diff_Op_delete') || is_a($edit, 'Text_Diff_Op_change')) { $count += $edit->norig(); } } return $count; }
Returns the number of deleted (removed) lines in a given diff. @since Text_Diff 1.1.0 @since Horde 3.2 @return integer The number of deleted lines
countDeletedLines
php
yiisoft/yii
framework/gii/components/Pear/Text/Diff.php
https://github.com/yiisoft/yii/blob/master/framework/gii/components/Pear/Text/Diff.php
BSD-3-Clause
function lcs() { $lcs = 0; foreach ($this->_edits as $edit) { if (is_a($edit, 'Text_Diff_Op_copy')) { $lcs += count($edit->orig); } } return $lcs; }
Computes the length of the Longest Common Subsequence (LCS). This is mostly for diagnostic purposes. @return integer The length of the LCS.
lcs
php
yiisoft/yii
framework/gii/components/Pear/Text/Diff.php
https://github.com/yiisoft/yii/blob/master/framework/gii/components/Pear/Text/Diff.php
BSD-3-Clause
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.
getOriginal
php
yiisoft/yii
framework/gii/components/Pear/Text/Diff.php
https://github.com/yiisoft/yii/blob/master/framework/gii/components/Pear/Text/Diff.php
BSD-3-Clause
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.
getFinal
php
yiisoft/yii
framework/gii/components/Pear/Text/Diff.php
https://github.com/yiisoft/yii/blob/master/framework/gii/components/Pear/Text/Diff.php
BSD-3-Clause
static function trimNewlines(&$line, $key) { $line = str_replace(array("\n", "\r"), '', $line); }
Removes trailing newlines from a line of text. This is meant to be used with array_walk(). @param string $line The line to trim. @param integer $key The index of the line in the array. Not used.
trimNewlines
php
yiisoft/yii
framework/gii/components/Pear/Text/Diff.php
https://github.com/yiisoft/yii/blob/master/framework/gii/components/Pear/Text/Diff.php
BSD-3-Clause
static 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; }
Determines the location of the system temporary directory. @access protected @return string A directory name which can be used for temp files. Returns false if one could not be found.
_getTempDir
php
yiisoft/yii
framework/gii/components/Pear/Text/Diff.php
https://github.com/yiisoft/yii/blob/master/framework/gii/components/Pear/Text/Diff.php
BSD-3-Clause
function __construct($from_lines, $to_lines, $mapped_from_lines, $mapped_to_lines) { assert(count($from_lines) == count($mapped_from_lines)); assert(count($to_lines) == count($mapped_to_lines)); parent::__construct($mapped_from_lines, $mapped_to_lines); $xi = $yi = 0; for ($i = 0; $i < count($this->_edits); $i++) { $orig = &$this->_edits[$i]->orig; if (is_array($orig)) { $orig = array_slice($from_lines, $xi, count($orig)); $xi += count($orig); } $final = &$this->_edits[$i]->final; if (is_array($final)) { $final = array_slice($to_lines, $yi, count($final)); $yi += count($final); } } }
Computes a diff between sequences of strings. This can be used to compute things like case-insensitive diffs, or diffs which ignore changes in white-space. @param array $from_lines An array of strings. @param array $to_lines An array of strings. @param array $mapped_from_lines This array should have the same size number of elements as $from_lines. The elements in $mapped_from_lines and $mapped_to_lines are what is actually compared when computing the diff. @param array $mapped_to_lines This array should have the same number of elements as $to_lines.
__construct
php
yiisoft/yii
framework/gii/components/Pear/Text/Diff.php
https://github.com/yiisoft/yii/blob/master/framework/gii/components/Pear/Text/Diff.php
BSD-3-Clause
function __construct($from_lines, $to_lines, $mapped_from_lines, $mapped_to_lines) { assert(count($from_lines) == count($mapped_from_lines)); assert(count($to_lines) == count($mapped_to_lines)); parent::__construct($mapped_from_lines, $mapped_to_lines); $xi = $yi = 0; for ($i = 0; $i < count($this->_edits); $i++) { $orig = &$this->_edits[$i]->orig; if (is_array($orig)) { $orig = array_slice($from_lines, $xi, count($orig)); $xi += count($orig); } $final = &$this->_edits[$i]->final; if (is_array($final)) { $final = array_slice($to_lines, $yi, count($final)); $yi += count($final); } } }
Computes a diff between sequences of strings. This can be used to compute things like case-insensitve diffs, or diffs which ignore changes in white-space. @param array $from_lines An array of strings. @param array $to_lines An array of strings. @param array $mapped_from_lines This array should have the same size number of elements as $from_lines. The elements in $mapped_from_lines and $mapped_to_lines are what is actually compared when computing the diff. @param array $mapped_to_lines This array should have the same number of elements as $to_lines.
__construct
php
yiisoft/yii
framework/gii/components/Pear/Text/Diff/Mapped.php
https://github.com/yiisoft/yii/blob/master/framework/gii/components/Pear/Text/Diff/Mapped.php
BSD-3-Clause
function diff($diff, $mode = 'autodetect') { // Detect line breaks. $lnbr = "\n"; if (strpos($diff, "\r\n") !== false) { $lnbr = "\r\n"; } elseif (strpos($diff, "\r") !== false) { $lnbr = "\r"; } // Make sure we have a line break at the EOF. if (substr($diff, -strlen($lnbr)) != $lnbr) { $diff .= $lnbr; } if ($mode != 'autodetect' && $mode != 'context' && $mode != 'unified') { return PEAR::raiseError('Type of diff is unsupported'); } if ($mode == 'autodetect') { $context = strpos($diff, '***'); $unified = strpos($diff, '---'); if ($context === $unified) { return PEAR::raiseError('Type of diff could not be detected'); } elseif ($context === false || $unified === false) { $mode = $context !== false ? 'context' : 'unified'; } else { $mode = $context < $unified ? 'context' : 'unified'; } } // Split by new line and remove the diff header, if there is one. $diff = explode($lnbr, $diff); if (($mode == 'context' && strpos($diff[0], '***') === 0) || ($mode == 'unified' && strpos($diff[0], '---') === 0)) { array_shift($diff); array_shift($diff); } if ($mode == 'context') { return $this->parseContextDiff($diff); } else { return $this->parseUnifiedDiff($diff); } }
Parses a unified or context diff. First param contains the whole diff and the second can be used to force a specific diff type. If the second parameter is 'autodetect', the diff will be examined to find out which type of diff this is. @param string $diff The diff content. @param string $mode The diff mode of the content in $diff. One of 'context', 'unified', or 'autodetect'. @return array List of all diff operations.
diff
php
yiisoft/yii
framework/gii/components/Pear/Text/Diff/Engine/string.php
https://github.com/yiisoft/yii/blob/master/framework/gii/components/Pear/Text/Diff/Engine/string.php
BSD-3-Clause
function parseUnifiedDiff($diff) { $edits = array(); $end = count($diff) - 1; for ($i = 0; $i < $end;) { $diff1 = array(); switch (substr($diff[$i], 0, 1)) { case ' ': do { $diff1[] = substr($diff[$i], 1); } while (++$i < $end && substr($diff[$i], 0, 1) == ' '); $edits[] = new Text_Diff_Op_copy($diff1); break; case '+': // get all new lines do { $diff1[] = substr($diff[$i], 1); } while (++$i < $end && substr($diff[$i], 0, 1) == '+'); $edits[] = new Text_Diff_Op_add($diff1); break; case '-': // get changed or removed lines $diff2 = array(); do { $diff1[] = substr($diff[$i], 1); } while (++$i < $end && substr($diff[$i], 0, 1) == '-'); while ($i < $end && substr($diff[$i], 0, 1) == '+') { $diff2[] = substr($diff[$i++], 1); } if (count($diff2) == 0) { $edits[] = new Text_Diff_Op_delete($diff1); } else { $edits[] = new Text_Diff_Op_change($diff1, $diff2); } break; default: $i++; break; } } return $edits; }
Parses an array containing the unified diff. @param array $diff Array of lines. @return array List of all diff operations.
parseUnifiedDiff
php
yiisoft/yii
framework/gii/components/Pear/Text/Diff/Engine/string.php
https://github.com/yiisoft/yii/blob/master/framework/gii/components/Pear/Text/Diff/Engine/string.php
BSD-3-Clause
function parseContextDiff(&$diff) { $edits = array(); $i = $max_i = $j = $max_j = 0; $end = count($diff) - 1; while ($i < $end && $j < $end) { while ($i >= $max_i && $j >= $max_j) { // Find the boundaries of the diff output of the two files for ($i = $j; $i < $end && substr($diff[$i], 0, 3) == '***'; $i++); for ($max_i = $i; $max_i < $end && substr($diff[$max_i], 0, 3) != '---'; $max_i++); for ($j = $max_i; $j < $end && substr($diff[$j], 0, 3) == '---'; $j++); for ($max_j = $j; $max_j < $end && substr($diff[$max_j], 0, 3) != '***'; $max_j++); } // find what hasn't been changed $array = array(); while ($i < $max_i && $j < $max_j && strcmp($diff[$i], $diff[$j]) == 0) { $array[] = substr($diff[$i], 2); $i++; $j++; } while ($i < $max_i && ($max_j-$j) <= 1) { if ($diff[$i] != '' && substr($diff[$i], 0, 1) != ' ') { break; } $array[] = substr($diff[$i++], 2); } while ($j < $max_j && ($max_i-$i) <= 1) { if ($diff[$j] != '' && substr($diff[$j], 0, 1) != ' ') { break; } $array[] = substr($diff[$j++], 2); } if (count($array) > 0) { $edits[] = new Text_Diff_Op_copy($array); } if ($i < $max_i) { $diff1 = array(); switch (substr($diff[$i], 0, 1)) { case '!': $diff2 = array(); do { $diff1[] = substr($diff[$i], 2); if ($j < $max_j && substr($diff[$j], 0, 1) == '!') { $diff2[] = substr($diff[$j++], 2); } } while (++$i < $max_i && substr($diff[$i], 0, 1) == '!'); $edits[] = new Text_Diff_Op_change($diff1, $diff2); break; case '+': do { $diff1[] = substr($diff[$i], 2); } while (++$i < $max_i && substr($diff[$i], 0, 1) == '+'); $edits[] = new Text_Diff_Op_add($diff1); break; case '-': do { $diff1[] = substr($diff[$i], 2); } while (++$i < $max_i && substr($diff[$i], 0, 1) == '-'); $edits[] = new Text_Diff_Op_delete($diff1); break; } } if ($j < $max_j) { $diff2 = array(); switch (substr($diff[$j], 0, 1)) { case '+': do { $diff2[] = substr($diff[$j++], 2); } while ($j < $max_j && substr($diff[$j], 0, 1) == '+'); $edits[] = new Text_Diff_Op_add($diff2); break; case '-': do { $diff2[] = substr($diff[$j++], 2); } while ($j < $max_j && substr($diff[$j], 0, 1) == '-'); $edits[] = new Text_Diff_Op_delete($diff2); break; } } } return $edits; }
Parses an array containing the context diff. @param array $diff Array of lines. @return array List of all diff operations.
parseContextDiff
php
yiisoft/yii
framework/gii/components/Pear/Text/Diff/Engine/string.php
https://github.com/yiisoft/yii/blob/master/framework/gii/components/Pear/Text/Diff/Engine/string.php
BSD-3-Clause
function _compareseq ($xoff, $xlim, $yoff, $ylim) { /* Slide down the bottom initial diagonal. */ while ($xoff < $xlim && $yoff < $ylim && $this->xv[$xoff] == $this->yv[$yoff]) { ++$xoff; ++$yoff; } /* Slide up the top initial diagonal. */ while ($xlim > $xoff && $ylim > $yoff && $this->xv[$xlim - 1] == $this->yv[$ylim - 1]) { --$xlim; --$ylim; } if ($xoff == $xlim || $yoff == $ylim) { $lcs = 0; } else { /* This is ad hoc but seems to work well. $nchunks = * sqrt(min($xlim - $xoff, $ylim - $yoff) / 2.5); $nchunks = * max(2,min(8,(int)$nchunks)); */ $nchunks = min(7, $xlim - $xoff, $ylim - $yoff) + 1; list($lcs, $seps) = $this->_diag($xoff, $xlim, $yoff, $ylim, $nchunks); } if ($lcs == 0) { /* X and Y sequences have no common subsequence: mark all * changed. */ while ($yoff < $ylim) { $this->ychanged[$this->yind[$yoff++]] = 1; } while ($xoff < $xlim) { $this->xchanged[$this->xind[$xoff++]] = 1; } } else { /* Use the partitions to split this problem into subproblems. */ reset($seps); $pt1 = $seps[0]; while ($pt2 = next($seps)) { $this->_compareseq ($pt1[0], $pt2[0], $pt1[1], $pt2[1]); $pt1 = $pt2; } } }
Finds LCS of two sequences. The results are recorded in the vectors $this->{x,y}changed[], by storing a 1 in the element for each line that is an insertion or deletion (ie. is not in the LCS). The subsequence of file 0 is (XOFF, XLIM) and likewise for file 1. Note that XLIM, YLIM are exclusive bounds. All line numbers are origin-0 and discarded lines are not counted.
_compareseq
php
yiisoft/yii
framework/gii/components/Pear/Text/Diff/Engine/native.php
https://github.com/yiisoft/yii/blob/master/framework/gii/components/Pear/Text/Diff/Engine/native.php
BSD-3-Clause
function _shiftBoundaries($lines, &$changed, $other_changed) { $i = 0; $j = 0; assert(count($lines) == count($changed)); $len = count($lines); $other_len = count($other_changed); while (1) { /* Scan forward to find the beginning of another run of * changes. Also keep track of the corresponding point in the * other file. * * Throughout this code, $i and $j are adjusted together so that * the first $i elements of $changed and the first $j elements of * $other_changed both contain the same number of zeros (unchanged * lines). * * Furthermore, $j is always kept so that $j == $other_len or * $other_changed[$j] == false. */ while ($j < $other_len && $other_changed[$j]) { $j++; } while ($i < $len && ! $changed[$i]) { assert($j < $other_len && ! $other_changed[$j]); $i++; $j++; while ($j < $other_len && $other_changed[$j]) { $j++; } } if ($i == $len) { break; } $start = $i; /* Find the end of this run of changes. */ while (++$i < $len && $changed[$i]) { continue; } do { /* Record the length of this run of changes, so that we can * later determine whether the run has grown. */ $runlength = $i - $start; /* Move the changed region back, so long as the previous * unchanged line matches the last changed one. This merges * with previous changed regions. */ while ($start > 0 && $lines[$start - 1] == $lines[$i - 1]) { $changed[--$start] = 1; $changed[--$i] = false; while ($start > 0 && $changed[$start - 1]) { $start--; } assert($j > 0); while ($other_changed[--$j]) { continue; } assert($j >= 0 && !$other_changed[$j]); } /* Set CORRESPONDING to the end of the changed run, at the * last point where it corresponds to a changed run in the * other file. CORRESPONDING == LEN means no such point has * been found. */ $corresponding = $j < $other_len ? $i : $len; /* Move the changed region forward, so long as the first * changed line matches the following unchanged one. This * merges with following changed regions. Do this second, so * that if there are no merges, the changed region is moved * forward as far as possible. */ while ($i < $len && $lines[$start] == $lines[$i]) { $changed[$start++] = false; $changed[$i++] = 1; while ($i < $len && $changed[$i]) { $i++; } assert($j < $other_len && ! $other_changed[$j]); $j++; if ($j < $other_len && $other_changed[$j]) { $corresponding = $i; while ($j < $other_len && $other_changed[$j]) { $j++; } } } } while ($runlength != $i - $start); /* If possible, move the fully-merged run of changes back to a * corresponding run in the other file. */ while ($corresponding < $i) { $changed[--$start] = 1; $changed[--$i] = 0; assert($j > 0); while ($other_changed[--$j]) { continue; } assert($j >= 0 && !$other_changed[$j]); } } }
Adjusts inserts/deletes of identical lines to join changes as much as possible. We do something when a run of changed lines include a line at one end and has an excluded, identical line at the other. We are free to choose which identical line is included. `compareseq' usually chooses the one at the beginning, but usually it is cleaner to consider the following identical line to be the "change". This is extracted verbatim from analyze.c (GNU diffutils-2.7).
_shiftBoundaries
php
yiisoft/yii
framework/gii/components/Pear/Text/Diff/Engine/native.php
https://github.com/yiisoft/yii/blob/master/framework/gii/components/Pear/Text/Diff/Engine/native.php
BSD-3-Clause
function diff($from_lines, $to_lines) { array_walk($from_lines, array('Text_Diff', 'trimNewlines')); array_walk($to_lines, array('Text_Diff', 'trimNewlines')); $temp_dir = Text_Diff::_getTempDir(); // Execute gnu diff or similar to get a standard diff file. $from_file = tempnam($temp_dir, 'Text_Diff'); $to_file = tempnam($temp_dir, 'Text_Diff'); $fp = fopen($from_file, 'w'); fwrite($fp, implode("\n", $from_lines)); fclose($fp); $fp = fopen($to_file, 'w'); fwrite($fp, implode("\n", $to_lines)); fclose($fp); $diff = shell_exec($this->_diffCommand . ' ' . $from_file . ' ' . $to_file); unlink($from_file); unlink($to_file); if (is_null($diff)) { // No changes were made return array(new Text_Diff_Op_copy($from_lines)); } $from_line_no = 1; $to_line_no = 1; $edits = array(); // Get changed lines by parsing something like: // 0a1,2 // 1,2c4,6 // 1,5d6 preg_match_all('#^(\d+)(?:,(\d+))?([adc])(\d+)(?:,(\d+))?$#m', $diff, $matches, PREG_SET_ORDER); foreach ($matches as $match) { if (!isset($match[5])) { // This paren is not set every time (see regex). $match[5] = false; } if ($match[3] == 'a') { $from_line_no--; } if ($match[3] == 'd') { $to_line_no--; } if ($from_line_no < $match[1] || $to_line_no < $match[4]) { // copied lines assert($match[1] - $from_line_no == $match[4] - $to_line_no); array_push($edits, new Text_Diff_Op_copy( $this->_getLines($from_lines, $from_line_no, $match[1] - 1), $this->_getLines($to_lines, $to_line_no, $match[4] - 1))); } switch ($match[3]) { case 'd': // deleted lines array_push($edits, new Text_Diff_Op_delete( $this->_getLines($from_lines, $from_line_no, $match[2]))); $to_line_no++; break; case 'c': // changed lines array_push($edits, new Text_Diff_Op_change( $this->_getLines($from_lines, $from_line_no, $match[2]), $this->_getLines($to_lines, $to_line_no, $match[5]))); break; case 'a': // added lines array_push($edits, new Text_Diff_Op_add( $this->_getLines($to_lines, $to_line_no, $match[5]))); $from_line_no++; break; } } if (!empty($from_lines)) { // Some lines might still be pending. Add them as copied array_push($edits, new Text_Diff_Op_copy( $this->_getLines($from_lines, $from_line_no, $from_line_no + count($from_lines) - 1), $this->_getLines($to_lines, $to_line_no, $to_line_no + count($to_lines) - 1))); } return $edits; }
Returns the array of differences. @param array $from_lines lines of text from old file @param array $to_lines lines of text from new file @return array all changes made (array with Text_Diff_Op_* objects)
diff
php
yiisoft/yii
framework/gii/components/Pear/Text/Diff/Engine/shell.php
https://github.com/yiisoft/yii/blob/master/framework/gii/components/Pear/Text/Diff/Engine/shell.php
BSD-3-Clause
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
_getLines
php
yiisoft/yii
framework/gii/components/Pear/Text/Diff/Engine/shell.php
https://github.com/yiisoft/yii/blob/master/framework/gii/components/Pear/Text/Diff/Engine/shell.php
BSD-3-Clause
public function beforeSave($event) { if ($this->getOwner()->getIsNewRecord() && ($this->createAttribute !== null)) { $this->getOwner()->{$this->createAttribute} = $this->getTimestampByAttribute($this->createAttribute); } if ((!$this->getOwner()->getIsNewRecord() || $this->setUpdateOnCreate) && ($this->updateAttribute !== null)) { $this->getOwner()->{$this->updateAttribute} = $this->getTimestampByAttribute($this->updateAttribute); } }
Responds to {@link CModel::onBeforeSave} event. Sets the values of the creation or modified attributes as configured @param CModelEvent $event event parameter
beforeSave
php
yiisoft/yii
framework/zii/behaviors/CTimestampBehavior.php
https://github.com/yiisoft/yii/blob/master/framework/zii/behaviors/CTimestampBehavior.php
BSD-3-Clause
protected function getTimestampByAttribute($attribute) { if ($this->timestampExpression instanceof CDbExpression) return $this->timestampExpression; elseif ($this->timestampExpression !== null) { try { return @eval('return '.$this->timestampExpression.';'); } catch (ParseError $e) { return false; } } $columnType = $this->getOwner()->getTableSchema()->getColumn($attribute)->dbType; return $this->getTimestampByColumnType($columnType); }
Gets the appropriate timestamp depending on the column type $attribute is @param string $attribute $attribute @return mixed timestamp (eg unix timestamp or a mysql function)
getTimestampByAttribute
php
yiisoft/yii
framework/zii/behaviors/CTimestampBehavior.php
https://github.com/yiisoft/yii/blob/master/framework/zii/behaviors/CTimestampBehavior.php
BSD-3-Clause
protected function getTimestampByColumnType($columnType) { return isset(self::$map[$columnType]) ? new CDbExpression(self::$map[$columnType]) : time(); }
Returns the appropriate timestamp depending on $columnType @param string $columnType $columnType @return mixed timestamp (eg unix timestamp or a mysql function)
getTimestampByColumnType
php
yiisoft/yii
framework/zii/behaviors/CTimestampBehavior.php
https://github.com/yiisoft/yii/blob/master/framework/zii/behaviors/CTimestampBehavior.php
BSD-3-Clause
public function init() { if($this->itemView===null) throw new CException(Yii::t('zii','The property "itemView" cannot be empty.')); parent::init(); if(!isset($this->htmlOptions['class'])) $this->htmlOptions['class']='list-view'; if($this->baseScriptUrl===null) $this->baseScriptUrl=Yii::app()->getAssetManager()->publish(Yii::getPathOfAlias('zii.widgets.assets')).'/listview'; if($this->cssFile!==false) { if($this->cssFile===null) $this->cssFile=$this->baseScriptUrl.'/styles.css'; Yii::app()->getClientScript()->registerCssFile($this->cssFile); } }
Initializes the list view. This method will initialize required property values and instantiate {@link columns} objects.
init
php
yiisoft/yii
framework/zii/widgets/CListView.php
https://github.com/yiisoft/yii/blob/master/framework/zii/widgets/CListView.php
BSD-3-Clause
public function registerClientScript() { $id=$this->getId(); if($this->ajaxUpdate===false) $ajaxUpdate=array(); else $ajaxUpdate=array_unique(preg_split('/\s*,\s*/',$this->ajaxUpdate.','.$id,-1,PREG_SPLIT_NO_EMPTY)); $options=array( 'ajaxUpdate'=>$ajaxUpdate, 'ajaxVar'=>$this->ajaxVar, 'pagerClass'=>$this->pagerCssClass, 'loadingClass'=>$this->loadingCssClass, 'sorterClass'=>$this->sorterCssClass, 'enableHistory'=>$this->enableHistory ); if($this->ajaxUrl!==null) $options['url']=CHtml::normalizeUrl($this->ajaxUrl); if($this->ajaxType!==null) $options['ajaxType']=strtoupper($this->ajaxType); if($this->updateSelector!==null) $options['updateSelector']=$this->updateSelector; foreach(array('beforeAjaxUpdate', 'afterAjaxUpdate', 'ajaxUpdateError') as $event) { if($this->$event!==null) { if($this->$event instanceof CJavaScriptExpression) $options[$event]=$this->$event; else $options[$event]=new CJavaScriptExpression($this->$event); } } $options=CJavaScript::encode($options); $cs=Yii::app()->getClientScript(); $cs->registerCoreScript('jquery'); $cs->registerCoreScript('bbq'); if($this->enableHistory) $cs->registerCoreScript('history'); $cs->registerScriptFile($this->baseScriptUrl.'/jquery.yiilistview.js',CClientScript::POS_END); $cs->registerScript(__CLASS__.'#'.$id,"jQuery('#$id').yiiListView($options);"); }
Registers necessary client scripts.
registerClientScript
php
yiisoft/yii
framework/zii/widgets/CListView.php
https://github.com/yiisoft/yii/blob/master/framework/zii/widgets/CListView.php
BSD-3-Clause
public function init() { if(isset($this->htmlOptions['id'])) $this->id=$this->htmlOptions['id']; else $this->htmlOptions['id']=$this->id; $route=$this->getController()->getRoute(); $this->items=$this->normalizeItems($this->items,$route,$hasActiveChild); }
Initializes the menu widget. This method mainly normalizes the {@link items} property. If this method is overridden, make sure the parent implementation is invoked.
init
php
yiisoft/yii
framework/zii/widgets/CMenu.php
https://github.com/yiisoft/yii/blob/master/framework/zii/widgets/CMenu.php
BSD-3-Clause
protected function renderMenu($items) { if(count($items)) { echo CHtml::openTag('ul',$this->htmlOptions)."\n"; $this->renderMenuRecursive($items); echo CHtml::closeTag('ul'); } }
Renders the menu items. @param array $items menu items. Each menu item will be an array with at least two elements: 'label' and 'active'. It may have three other optional elements: 'items', 'linkOptions' and 'itemOptions'.
renderMenu
php
yiisoft/yii
framework/zii/widgets/CMenu.php
https://github.com/yiisoft/yii/blob/master/framework/zii/widgets/CMenu.php
BSD-3-Clause
protected function renderMenuItem($item) { if(isset($item['url'])) { $label=$this->linkLabelWrapper===null ? $item['label'] : CHtml::tag($this->linkLabelWrapper, $this->linkLabelWrapperHtmlOptions, $item['label']); return CHtml::link($label,$item['url'],isset($item['linkOptions']) ? $item['linkOptions'] : array()); } else return CHtml::tag('span',isset($item['linkOptions']) ? $item['linkOptions'] : array(), $item['label']); }
Renders the content of a menu item. Note that the container and the sub-menus are not rendered here. @param array $item the menu item to be rendered. Please see {@link items} on what data might be in the item. @return string @since 1.1.6
renderMenuItem
php
yiisoft/yii
framework/zii/widgets/CMenu.php
https://github.com/yiisoft/yii/blob/master/framework/zii/widgets/CMenu.php
BSD-3-Clause
protected function isItemActive($item,$route) { if(isset($item['url']) && is_array($item['url']) && !strcasecmp(trim($item['url'][0],'/'),$route)) { unset($item['url']['#']); if(count($item['url'])>1) { foreach(array_splice($item['url'],1) as $name=>$value) { if(!isset($_GET[$name]) || $_GET[$name]!=$value) return false; } } return true; } return false; }
Checks whether a menu item is active. This is done by checking if the currently requested URL is generated by the 'url' option of the menu item. Note that the GET parameters not specified in the 'url' option will be ignored. @param array $item the menu item to be checked @param string $route the route of the current request @return boolean whether the menu item is active
isItemActive
php
yiisoft/yii
framework/zii/widgets/CMenu.php
https://github.com/yiisoft/yii/blob/master/framework/zii/widgets/CMenu.php
BSD-3-Clause
public function init() { if($this->dataProvider===null) throw new CException(Yii::t('zii','The "dataProvider" property cannot be empty.')); $this->dataProvider->getData(); if(isset($this->htmlOptions['id'])) $this->id=$this->htmlOptions['id']; else $this->htmlOptions['id']=$this->id; if($this->enableSorting && $this->dataProvider->getSort()===false) $this->enableSorting=false; if($this->enablePagination && $this->dataProvider->getPagination()===false) $this->enablePagination=false; }
Initializes the view. This method will initialize required property values and instantiate {@link columns} objects.
init
php
yiisoft/yii
framework/zii/widgets/CBaseListView.php
https://github.com/yiisoft/yii/blob/master/framework/zii/widgets/CBaseListView.php
BSD-3-Clause
public function run() { $this->registerClientScript(); echo CHtml::openTag($this->tagName,$this->htmlOptions)."\n"; $this->renderContent(); $this->renderKeys(); echo CHtml::closeTag($this->tagName); }
Renders the view. This is the main entry of the whole view rendering. Child classes should mainly override {@link renderContent} method.
run
php
yiisoft/yii
framework/zii/widgets/CBaseListView.php
https://github.com/yiisoft/yii/blob/master/framework/zii/widgets/CBaseListView.php
BSD-3-Clause
public function renderContent() { ob_start(); echo preg_replace_callback("/{(\w+)}/",array($this,'renderSection'),$this->template); ob_end_flush(); }
Renders the main content of the view. The content is divided into sections, such as summary, items, pager. Each section is rendered by a method named as "renderXyz", where "Xyz" is the section name. The rendering results will replace the corresponding placeholders in {@link template}.
renderContent
php
yiisoft/yii
framework/zii/widgets/CBaseListView.php
https://github.com/yiisoft/yii/blob/master/framework/zii/widgets/CBaseListView.php
BSD-3-Clause
protected function renderSection($matches) { $method='render'.$matches[1]; if(method_exists($this,$method)) { $this->$method(); $html=ob_get_contents(); ob_clean(); return $html; } else return $matches[0]; }
Renders a section. This method is invoked by {@link renderContent} for every placeholder found in {@link template}. It should return the rendering result that would replace the placeholder. @param array $matches the matches, where $matches[0] represents the whole placeholder, while $matches[1] contains the name of the matched placeholder. @return string the rendering result of the section
renderSection
php
yiisoft/yii
framework/zii/widgets/CBaseListView.php
https://github.com/yiisoft/yii/blob/master/framework/zii/widgets/CBaseListView.php
BSD-3-Clause
public function renderEmptyText() { $emptyText=$this->emptyText===null ? Yii::t('zii','No results found.') : $this->emptyText; echo CHtml::tag($this->emptyTagName, array('class'=>$this->emptyCssClass), $emptyText); }
Renders the empty message when there is no data.
renderEmptyText
php
yiisoft/yii
framework/zii/widgets/CBaseListView.php
https://github.com/yiisoft/yii/blob/master/framework/zii/widgets/CBaseListView.php
BSD-3-Clause
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.
renderKeys
php
yiisoft/yii
framework/zii/widgets/CBaseListView.php
https://github.com/yiisoft/yii/blob/master/framework/zii/widgets/CBaseListView.php
BSD-3-Clause
public function registerClientScript() { }
Registers necessary client scripts. This method is invoked by {@link run}. Child classes may override this method to register customized client scripts.
registerClientScript
php
yiisoft/yii
framework/zii/widgets/CBaseListView.php
https://github.com/yiisoft/yii/blob/master/framework/zii/widgets/CBaseListView.php
BSD-3-Clause
public function init() { if($this->data===null) throw new CException(Yii::t('zii','Please specify the "data" property.')); if($this->attributes===null) { if($this->data instanceof CModel) $this->attributes=$this->data->attributeNames(); elseif(is_array($this->data)) $this->attributes=array_keys($this->data); else throw new CException(Yii::t('zii','Please specify the "attributes" property.')); } if($this->nullDisplay===null) $this->nullDisplay='<span class="null">'.Yii::t('zii','Not set').'</span>'; if(isset($this->htmlOptions['id'])) $this->id=$this->htmlOptions['id']; else $this->htmlOptions['id']=$this->id; if($this->baseScriptUrl===null) $this->baseScriptUrl=Yii::app()->getAssetManager()->publish(Yii::getPathOfAlias('zii.widgets.assets')).'/detailview'; if($this->cssFile!==false) { if($this->cssFile===null) $this->cssFile=$this->baseScriptUrl.'/styles.css'; Yii::app()->getClientScript()->registerCssFile($this->cssFile); } }
Initializes the detail view. This method will initialize required property values.
init
php
yiisoft/yii
framework/zii/widgets/CDetailView.php
https://github.com/yiisoft/yii/blob/master/framework/zii/widgets/CDetailView.php
BSD-3-Clause
public function run() { $id=$this->getId(); if(isset($this->htmlOptions['id'])) $id=$this->htmlOptions['id']; else $this->htmlOptions['id']=$id; echo CHtml::tag($this->tagName,$this->htmlOptions,''); if($this->value!==null) $this->options['value']=$this->value; $options=CJavaScript::encode($this->options); Yii::app()->getClientScript()->registerScript(__CLASS__.'#'.$id,"jQuery('#{$id}').slider($options);"); }
Run this widget. This method registers necessary javascript and renders the needed HTML code.
run
php
yiisoft/yii
framework/zii/widgets/jui/CJuiSlider.php
https://github.com/yiisoft/yii/blob/master/framework/zii/widgets/jui/CJuiSlider.php
BSD-3-Clause
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); Yii::app()->getClientScript()->registerScript(__CLASS__.'#'.$id,"jQuery('#{$id}').resizable($options);"); echo CHtml::openTag($this->tagName,$this->htmlOptions)."\n"; }
Renders the open tag of the resizable element. This method also registers the necessary javascript code.
init
php
yiisoft/yii
framework/zii/widgets/jui/CJuiResizable.php
https://github.com/yiisoft/yii/blob/master/framework/zii/widgets/jui/CJuiResizable.php
BSD-3-Clause
public function run() { echo CHtml::closeTag($this->tagName); }
Renders the close tag of the resizable element.
run
php
yiisoft/yii
framework/zii/widgets/jui/CJuiResizable.php
https://github.com/yiisoft/yii/blob/master/framework/zii/widgets/jui/CJuiResizable.php
BSD-3-Clause
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); Yii::app()->getClientScript()->registerScript(__CLASS__.'#'.$id,"jQuery('#{$id}').droppable($options);"); echo CHtml::openTag($this->tagName,$this->htmlOptions)."\n"; }
Renders the open tag of the droppable element. This method also registers the necessary javascript code.
init
php
yiisoft/yii
framework/zii/widgets/jui/CJuiDroppable.php
https://github.com/yiisoft/yii/blob/master/framework/zii/widgets/jui/CJuiDroppable.php
BSD-3-Clause
public function init() { $this->resolvePackagePath(); $this->registerCoreScripts(); parent::init(); }
Initializes the widget. This method will publish JUI assets if necessary. It will also register jquery and JUI JavaScript files and the theme CSS file. If you override this method, make sure you call the parent implementation first.
init
php
yiisoft/yii
framework/zii/widgets/jui/CJuiWidget.php
https://github.com/yiisoft/yii/blob/master/framework/zii/widgets/jui/CJuiWidget.php
BSD-3-Clause
protected function resolvePackagePath() { if($this->scriptUrl===null || $this->themeUrl===null) { $cs=Yii::app()->getClientScript(); if($this->scriptUrl===null) $this->scriptUrl=$cs->getCoreScriptUrl().'/jui/js'; if($this->themeUrl===null) $this->themeUrl=$cs->getCoreScriptUrl().'/jui/css'; } }
Determine the JUI package installation path. This method will identify the JavaScript root URL and theme root URL. If they are not explicitly specified, it will publish the included JUI package and use that to resolve the needed paths.
resolvePackagePath
php
yiisoft/yii
framework/zii/widgets/jui/CJuiWidget.php
https://github.com/yiisoft/yii/blob/master/framework/zii/widgets/jui/CJuiWidget.php
BSD-3-Clause
protected function registerScriptFile($fileName,$position=CClientScript::POS_END) { Yii::app()->getClientScript()->registerScriptFile($this->scriptUrl.'/'.$fileName,$position); }
Registers a JavaScript file under {@link scriptUrl}. Note that by default, the script file will be rendered at the end of a page to improve page loading speed. @param string $fileName JavaScript file name @param integer $position the position of the JavaScript file. Valid values include the following: <ul> <li>CClientScript::POS_HEAD : the script is inserted in the head section right before the title element.</li> <li>CClientScript::POS_BEGIN : the script is inserted at the beginning of the body section.</li> <li>CClientScript::POS_END : the script is inserted at the end of the body section.</li> </ul>
registerScriptFile
php
yiisoft/yii
framework/zii/widgets/jui/CJuiWidget.php
https://github.com/yiisoft/yii/blob/master/framework/zii/widgets/jui/CJuiWidget.php
BSD-3-Clause
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); Yii::app()->getClientScript()->registerScript(__CLASS__.'#'.$id,"jQuery('#{$id}').dialog($options);"); echo CHtml::openTag($this->tagName,$this->htmlOptions)."\n"; }
Renders the open tag of the dialog. This method also registers the necessary javascript code.
init
php
yiisoft/yii
framework/zii/widgets/jui/CJuiDialog.php
https://github.com/yiisoft/yii/blob/master/framework/zii/widgets/jui/CJuiDialog.php
BSD-3-Clause
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); Yii::app()->getClientScript()->registerScript(__CLASS__.'#'.$id,"jQuery('#{$id}').draggable($options);"); echo CHtml::openTag($this->tagName,$this->htmlOptions)."\n"; }
Renders the open tag of the draggable element. This method also registers the necessary javascript code.
init
php
yiisoft/yii
framework/zii/widgets/jui/CJuiDraggable.php
https://github.com/yiisoft/yii/blob/master/framework/zii/widgets/jui/CJuiDraggable.php
BSD-3-Clause