idx int64 0 241k | question stringlengths 64 6.21k | target stringlengths 5 803 |
|---|---|---|
5,900 | public function getDataCellContent ( $ row ) { $ data = $ this -> grid -> dataProvider -> data [ $ row ] ; if ( $ this -> urlExpression !== null ) $ url = $ this -> evaluateExpression ( $ this -> urlExpression , array ( 'data' => $ data , 'row' => $ row ) ) ; else $ url = $ this -> url ; if ( $ this -> labelExpression ... | Returns the data cell content . This method renders a hyperlink in the data cell . |
5,901 | 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 . |
5,902 | public function renderSummary ( ) { if ( ( $ count = $ this -> dataProvider -> getItemCount ( ) ) <= 0 ) return ; echo CHtml :: openTag ( $ this -> summaryTagName , array ( 'class' => $ this -> summaryCssClass ) ) ; if ( $ this -> enablePagination ) { $ pagination = $ this -> dataProvider -> getPagination ( ) ; $ total... | Renders the summary text . |
5,903 | public function purify ( $ content ) { if ( is_array ( $ content ) ) $ content = array_map ( array ( $ this , 'purify' ) , $ content ) ; else $ content = $ this -> getPurifier ( ) -> purify ( $ content ) ; return $ content ; } | Purifies the HTML content by removing malicious code . |
5,904 | protected function createNewHtmlPurifierInstance ( ) { $ this -> _purifier = new HTMLPurifier ( $ this -> getOptions ( ) ) ; $ this -> _purifier -> config -> set ( 'Cache.SerializerPath' , Yii :: app ( ) -> getRuntimePath ( ) ) ; return $ this -> _purifier ; } | Create a new HTML Purifier instance . |
5,905 | public static function getInstancesByName ( $ name ) { if ( null === self :: $ _files ) self :: prefetchFiles ( ) ; $ len = strlen ( $ name ) ; $ results = array ( ) ; foreach ( array_keys ( self :: $ _files ) as $ key ) if ( 0 === strncmp ( $ key , $ name . '[' , $ len + 1 ) && self :: $ _files [ $ key ] -> getError (... | Returns an array of instances starting with specified array name . |
5,906 | 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 |
5,907 | 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 , 'gene... | Adds callbacks that will modify source files |
5,908 | 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 ) ; retu... | Inserts path to framework s yii . php into application s index . php |
5,909 | 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_r... | Inserts path to framework s yiic . php into application s yiic . php |
5,910 | public function processLogs ( $ logs ) { $ app = Yii :: app ( ) ; if ( ! ( $ app instanceof CWebApplication ) || $ app -> getRequest ( ) -> getIsAjaxRequest ( ) ) return ; if ( $ this -> getReport ( ) === 'summary' ) $ this -> displaySummary ( $ logs ) ; else $ this -> displayCallstack ( $ logs ) ; } | Displays the log messages . |
5,911 | protected function displayCallstack ( $ logs ) { $ stack = array ( ) ; $ results = array ( ) ; $ n = 0 ; foreach ( $ logs as $ log ) { if ( $ log [ 1 ] !== CLogger :: LEVEL_PROFILE ) continue ; $ message = $ log [ 0 ] ; if ( ! strncasecmp ( $ message , 'begin:' , 6 ) ) { $ log [ 0 ] = substr ( $ message , 6 ) ; $ log [... | Displays the callstack of the profiling procedures for display . |
5,912 | protected function displaySummary ( $ logs ) { $ stack = array ( ) ; $ results = array ( ) ; foreach ( $ logs as $ log ) { if ( $ log [ 1 ] !== CLogger :: LEVEL_PROFILE ) continue ; $ message = $ log [ 0 ] ; if ( ! strncasecmp ( $ message , 'begin:' , 6 ) ) { $ log [ 0 ] = substr ( $ message , 6 ) ; $ stack [ ] = $ log... | Displays the summary report of the profiling result . |
5,913 | protected function aggregateResult ( $ result , $ delta ) { list ( $ token , $ calls , $ min , $ max , $ total ) = $ result ; if ( $ delta < $ min ) $ min = $ delta ; elseif ( $ delta > $ max ) $ max = $ delta ; $ calls ++ ; $ total += $ delta ; return array ( $ token , $ calls , $ min , $ max , $ total ) ; } | Aggregates the report result . |
5,914 | public function delete ( ) { if ( ! $ this -> getIsNewRecord ( ) ) { Yii :: trace ( get_class ( $ this ) . '.delete()' , 'system.db.ar.CActiveRecord' ) ; if ( $ this -> beforeDelete ( ) ) { $ result = $ this -> deleteByPk ( $ this -> getPrimaryKey ( ) ) > 0 ; $ this -> afterDelete ( ) ; return $ result ; } else return ... | Deletes the row corresponding to this active record . |
5,915 | public function find ( $ condition = '' , $ params = array ( ) ) { Yii :: trace ( get_class ( $ this ) . '.find()' , 'system.db.ar.CActiveRecord' ) ; $ criteria = $ this -> getCommandBuilder ( ) -> createCriteria ( $ condition , $ params ) ; return $ this -> query ( $ criteria ) ; } | Finds a single active record with the specified condition . |
5,916 | public function findBySql ( $ sql , $ params = array ( ) ) { Yii :: trace ( get_class ( $ this ) . '.findBySql()' , 'system.db.ar.CActiveRecord' ) ; $ this -> beforeFind ( ) ; if ( ( $ criteria = $ this -> getDbCriteria ( false ) ) !== null && ! empty ( $ criteria -> with ) ) { $ this -> resetScope ( false ) ; $ finder... | Finds a single active record with the specified SQL statement . |
5,917 | public function findAllBySql ( $ sql , $ params = array ( ) ) { Yii :: trace ( get_class ( $ this ) . '.findAllBySql()' , 'system.db.ar.CActiveRecord' ) ; $ this -> beforeFind ( ) ; if ( ( $ criteria = $ this -> getDbCriteria ( false ) ) !== null && ! empty ( $ criteria -> with ) ) { $ this -> resetScope ( false ) ; $ ... | Finds all active records using the specified SQL statement . |
5,918 | protected function loadPage ( ) { $ this -> _dataProvider -> getPagination ( ) -> setCurrentPage ( $ this -> _currentPage ) ; return $ this -> _items = $ this -> dataProvider -> getData ( true ) ; } | Loads a page of items |
5,919 | public function key ( ) { $ pageSize = $ this -> _dataProvider -> getPagination ( ) -> getPageSize ( ) ; return $ this -> _currentPage * $ pageSize + $ this -> _currentIndex ; } | Gets the key of the current item . This method is required by the Iterator interface . |
5,920 | public function next ( ) { $ pageSize = $ this -> _dataProvider -> getPagination ( ) -> getPageSize ( ) ; $ this -> _currentIndex ++ ; if ( $ this -> _currentIndex >= $ pageSize ) { $ this -> _currentPage ++ ; $ this -> _currentIndex = 0 ; $ this -> loadPage ( ) ; } } | Moves the pointer to the next item in the list . This method is required by the Iterator interface . |
5,921 | protected function createCacheTable ( $ db , $ tableName ) { $ driver = $ db -> getDriverName ( ) ; if ( $ driver === 'mysql' ) $ blob = 'LONGBLOB' ; elseif ( $ driver === 'pgsql' ) $ blob = 'BYTEA' ; else $ blob = 'BLOB' ; $ sql = <<<EODCREATE TABLE $tableName( id CHAR(128) PRIMARY KEY, expire INTEGER, value $blob)EOD... | Creates the cache DB table . |
5,922 | public static function isLeapYear ( $ year ) { $ year = self :: digitCheck ( $ year ) ; if ( $ year % 4 != 0 ) return false ; if ( $ year % 400 == 0 ) return true ; elseif ( $ year > 1582 && $ year % 100 == 0 ) return false ; return true ; } | Checks for leap year returns true if it is . No 2 - digit year check . Also handles julian calendar correctly . |
5,923 | protected static function digitCheck ( $ y ) { if ( $ y < 100 ) { $ yr = ( integer ) date ( "Y" ) ; $ century = ( integer ) ( $ yr / 100 ) ; if ( $ yr % 100 > 50 ) { $ c1 = $ century + 1 ; $ c0 = $ century ; } else { $ c1 = $ century ; $ c0 = $ century - 1 ; } $ c1 *= 100 ; if ( ( $ y + $ c1 ) < $ yr + 30 ) $ y = $ y +... | Fix 2 - digit years . Works for any century . Assumes that if 2 - digit is more than 30 years in future then previous century . |
5,924 | public static function isValidTime ( $ h , $ m , $ s , $ hs24 = true ) { if ( $ hs24 && ( $ h < 0 || $ h > 23 ) || ! $ hs24 && ( $ h < 1 || $ h > 12 ) ) return false ; if ( $ m > 59 || $ m < 0 ) return false ; if ( $ s > 59 || $ s < 0 ) return false ; return true ; } | Checks to see if the hour minute and second are valid . |
5,925 | protected function getSortingFieldValue ( $ data , $ fields ) { if ( is_object ( $ data ) ) { foreach ( $ fields as $ field ) $ data = isset ( $ data -> $ field ) ? $ data -> $ field : null ; } else { foreach ( $ fields as $ field ) $ data = isset ( $ data [ $ field ] ) ? $ data [ $ field ] : null ; } return $ this -> ... | Get field for sorting using dot like delimiter in query . |
5,926 | protected function getSortDirections ( $ order ) { $ segs = explode ( ',' , $ order ) ; $ directions = array ( ) ; foreach ( $ segs as $ seg ) { if ( preg_match ( '/(.*?)(\s+(desc|asc))?$/i' , trim ( $ seg ) , $ matches ) ) $ directions [ $ matches [ 1 ] ] = isset ( $ matches [ 3 ] ) && ! strcasecmp ( $ matches [ 3 ] ,... | Converts the ORDER BY clause into an array representing the sorting directions . |
5,927 | public function actionError ( ) { if ( $ error = Yii :: app ( ) -> errorHandler -> error ) { if ( Yii :: app ( ) -> request -> isAjaxRequest ) echo $ error [ 'message' ] ; else $ this -> render ( 'error' , $ error ) ; } } | This is the action to handle external exceptions . |
5,928 | public function actionContact ( ) { $ model = new ContactForm ; if ( isset ( $ _POST [ 'ContactForm' ] ) ) { $ model -> attributes = $ _POST [ 'ContactForm' ] ; if ( $ model -> validate ( ) ) { $ name = '=?UTF-8?B?' . base64_encode ( $ model -> name ) . '?=' ; $ subject = '=?UTF-8?B?' . base64_encode ( $ model -> subje... | Displays the contact page |
5,929 | protected function resolveView ( $ viewPath ) { if ( preg_match ( '/^\w[\w\.\-]*$/' , $ viewPath ) ) { $ view = strtr ( $ viewPath , '.' , '/' ) ; if ( ! empty ( $ this -> basePath ) ) $ view = $ this -> basePath . '/' . $ view ; if ( $ this -> getController ( ) -> getViewFile ( $ view ) !== false ) { $ this -> view = ... | Resolves the user - specified view into a valid view name . |
5,930 | 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 . |
5,931 | protected function processLogs ( $ logs ) { $ command = $ this -> getDbConnection ( ) -> createCommand ( ) ; foreach ( $ logs as $ log ) { $ command -> insert ( $ this -> logTableName , array ( 'level' => $ log [ 1 ] , 'category' => $ log [ 2 ] , 'logtime' => ( int ) $ log [ 3 ] , 'message' => $ log [ 0 ] , ) ) ; } } | Stores log messages into database . |
5,932 | public function getPages ( ) { if ( $ this -> _pages === null ) $ this -> _pages = $ this -> createPages ( ) ; return $ this -> _pages ; } | Returns the pagination information used by this pager . |
5,933 | protected function loadTable ( $ name ) { $ table = new CCubridTableSchema ; $ this -> resolveTableNames ( $ table , $ name ) ; if ( $ this -> findColumns ( $ table ) ) { $ this -> findPrimaryKeys ( $ table ) ; $ this -> findConstraints ( $ table ) ; return $ table ; } else return null ; } | Creates a table instance representing the metadata for the named table . |
5,934 | protected function findPrimaryKeys ( $ table ) { $ pks = $ this -> getDbConnection ( ) -> getPdoInstance ( ) -> cubrid_schema ( PDO :: CUBRID_SCH_PRIMARY_KEY , $ table -> name ) ; foreach ( $ pks as $ pk ) { $ c = $ table -> columns [ $ pk [ 'ATTR_NAME' ] ] ; $ c -> isPrimaryKey = true ; if ( $ table -> primaryKey === ... | Collects the primary key column details for the given table . |
5,935 | public function renderInput ( ) { if ( isset ( self :: $ coreTypes [ $ this -> type ] ) ) { $ method = self :: $ coreTypes [ $ this -> type ] ; if ( strpos ( $ method , 'List' ) !== false ) return CHtml :: $ method ( $ this -> getParent ( ) -> getModel ( ) , $ this -> name , $ this -> items , $ this -> attributes ) ; e... | Renders the input field . The default implementation returns the result of the appropriate CHtml method or the widget . |
5,936 | public static function hashPassword ( $ password , $ cost = 13 ) { self :: checkBlowfish ( ) ; $ salt = self :: generateSalt ( $ cost ) ; $ hash = crypt ( $ password , $ salt ) ; if ( ! is_string ( $ hash ) || ( function_exists ( 'mb_strlen' ) ? mb_strlen ( $ hash , '8bit' ) : strlen ( $ hash ) ) < 32 ) throw new CExce... | Generate a secure hash from a password and a random salt . |
5,937 | public static function verifyPassword ( $ password , $ hash ) { self :: checkBlowfish ( ) ; if ( ! is_string ( $ password ) || $ password === '' ) return false ; if ( ! $ password || ! preg_match ( '{^\$2[axy]\$(\d\d)\$[\./0-9A-Za-z]{22}}' , $ hash , $ matches ) || $ matches [ 1 ] < 4 || $ matches [ 1 ] > 31 ) return f... | Verify a password against a hash . |
5,938 | public static function same ( $ a , $ b ) { if ( ! is_string ( $ a ) || ! is_string ( $ b ) ) return false ; $ mb = function_exists ( 'mb_strlen' ) ; $ length = $ mb ? mb_strlen ( $ a , '8bit' ) : strlen ( $ a ) ; if ( $ length !== ( $ mb ? mb_strlen ( $ b , '8bit' ) : strlen ( $ b ) ) ) return false ; $ check = 0 ; fo... | Check for sameness of two strings using an algorithm with timing independent of the string values if the subject strings are of equal length . |
5,939 | function _getLines ( & $ text_lines , & $ line_no , $ end = false ) { if ( ! empty ( $ end ) ) { $ lines = array ( ) ; 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 |
5,940 | public function init ( ) { $ this -> _cache = Yii :: app ( ) -> getComponent ( $ this -> cacheID ) ; if ( ! ( $ this -> _cache instanceof ICache ) ) throw new CException ( Yii :: t ( 'yii' , 'CCacheHttpSession.cacheID is invalid. Please make sure "{id}" refers to a valid cache application component.' , array ( '{id}' =... | Initializes the application component . This method overrides the parent implementation by checking if cache is available . |
5,941 | protected function checkContentCache ( ) { if ( ( empty ( $ this -> requestTypes ) || in_array ( Yii :: app ( ) -> getRequest ( ) -> getRequestType ( ) , $ this -> requestTypes ) ) && ( $ this -> _cache = $ this -> getCache ( ) ) !== null ) { if ( $ this -> duration > 0 && ( $ data = $ this -> _cache -> get ( $ this ->... | Looks for content in cache . |
5,942 | protected function replayActions ( ) { if ( empty ( $ this -> _actions ) ) return ; $ controller = $ this -> getController ( ) ; $ cs = Yii :: app ( ) -> getClientScript ( ) ; foreach ( $ this -> _actions as $ action ) { if ( $ action [ 0 ] === 'clientScript' ) $ object = $ cs ; elseif ( $ action [ 0 ] === '' ) $ objec... | Replays the recorded method calls . |
5,943 | protected function createSessionTable ( $ db , $ tableName ) { switch ( $ db -> getDriverName ( ) ) { case 'mysql' : $ blob = 'LONGBLOB' ; break ; case 'pgsql' : $ blob = 'BYTEA' ; break ; case 'sqlsrv' : case 'mssql' : case 'dblib' : $ blob = 'VARBINARY(MAX)' ; break ; default : $ blob = 'BLOB' ; break ; } $ db -> cre... | Creates the session DB table . |
5,944 | public function openSession ( $ savePath , $ sessionName ) { if ( $ this -> autoCreateSessionTable ) { $ db = $ this -> getDbConnection ( ) ; $ db -> setActive ( true ) ; try { $ db -> createCommand ( ) -> delete ( $ this -> sessionTableName , 'expire<:expire' , array ( ':expire' => time ( ) ) ) ; } catch ( Exception $... | Session open handler . Do not call this method directly . |
5,945 | protected function getSessionKey ( ) { return self :: SESSION_VAR_PREFIX . Yii :: app ( ) -> getId ( ) . '.' . $ this -> getController ( ) -> getUniqueId ( ) . '.' . $ this -> getId ( ) ; } | Returns the session variable name used to store verification code . |
5,946 | protected function checkFiles ( $ translatedFilePath = null , $ sourceFilePath = null ) { $ errors = array ( ) ; if ( $ translatedFilePath !== null && ! file_exists ( $ translatedFilePath ) ) { $ errors [ ] = 'Translation does not exist.' ; } if ( $ sourceFilePath !== null && ! file_exists ( $ sourceFilePath ) ) { $ er... | Checks for files existence |
5,947 | protected function highlightDiff ( $ diff ) { $ lines = explode ( "\n" , $ diff ) ; foreach ( $ lines as $ key => $ val ) { if ( mb_substr ( $ val , 0 , 1 , 'utf-8' ) === '@' ) { $ lines [ $ key ] = '<span class="info">' . CHtml :: encode ( $ val ) . '</span>' ; } else if ( mb_substr ( $ val , 0 , 1 , 'utf-8' ) === '+'... | Adds all necessary HTML tags and classes to diff output |
5,948 | public function configure ( $ config ) { if ( is_string ( $ config ) ) $ config = require ( Yii :: getPathOfAlias ( $ config ) . '.php' ) ; if ( is_array ( $ config ) ) { foreach ( $ config as $ name => $ value ) $ this -> $ name = $ value ; } } | Configures this object with property initial values . |
5,949 | public function init ( ) { parent :: init ( ) ; if ( $ this -> authFile === null ) $ this -> authFile = Yii :: getPathOfAlias ( 'application.data.auth' ) . '.php' ; $ this -> load ( ) ; } | Initializes the application component . This method overrides parent implementation by loading the authorization data from PHP script . |
5,950 | public function save ( ) { $ items = array ( ) ; foreach ( $ this -> _items as $ name => $ item ) { $ items [ $ name ] = array ( 'type' => $ item -> getType ( ) , 'description' => $ item -> getDescription ( ) , 'bizRule' => $ item -> getBizRule ( ) , 'data' => $ item -> getData ( ) , ) ; if ( isset ( $ this -> _childre... | Saves authorization data into persistent storage . If any change is made to the authorization data please make sure you call this method to save the changed data into persistent storage . |
5,951 | public function load ( ) { $ this -> clearAll ( ) ; $ items = $ this -> loadFromFile ( $ this -> authFile ) ; foreach ( $ items as $ name => $ item ) $ this -> _items [ $ name ] = new CAuthItem ( $ this , $ name , $ item [ 'type' ] , $ item [ 'description' ] , $ item [ 'bizRule' ] , $ item [ 'data' ] ) ; foreach ( $ it... | Loads authorization data . |
5,952 | public function beforeWebMethod ( $ service ) { $ safeMethods = array ( 'login' , 'getContacts' , ) ; $ pattern = '/^(' . implode ( '|' , $ safeMethods ) . ')$/i' ; if ( ! Yii :: app ( ) -> user -> isGuest || preg_match ( $ pattern , $ service -> methodName ) ) return true ; else throw new CException ( 'Login required.... | This method is required by IWebServiceProvider . It makes sure the user is logged in before making changes to data . |
5,953 | public function saveContact ( $ contact ) { if ( $ contact -> id > 0 ) { $ contact -> isNewRecord = false ; if ( ( $ oldContact = Contact :: model ( ) -> findByPk ( $ contact -> id ) ) !== null ) { $ oldContact -> attributes = $ contact -> attributes ; return $ oldContact -> save ( ) ; } else return false ; } else { $ ... | Updates or inserts a contact . If the ID is null an insertion will be performed ; Otherwise it updates the existing one . |
5,954 | function getParams ( ) { $ params = array ( ) ; foreach ( get_object_vars ( $ this ) as $ k => $ v ) { if ( $ k [ 0 ] == '_' ) { $ params [ substr ( $ k , 1 ) ] = $ v ; } } return $ params ; } | Get any renderer parameters . |
5,955 | function render ( $ diff ) { $ xi = $ yi = 1 ; $ block = false ; $ context = array ( ) ; $ nlead = $ this -> _leading_context_lines ; $ ntrail = $ this -> _trailing_context_lines ; $ output = $ this -> _startDiff ( ) ; $ diffs = $ diff -> getDiff ( ) ; foreach ( $ diffs as $ i => $ edit ) { if ( is_a ( $ edit , 'Text_D... | Renders a diff . |
5,956 | public function highlight ( $ content ) { $ this -> registerClientScript ( ) ; $ options [ 'use_language' ] = true ; $ options [ 'tabsize' ] = $ this -> tabSize ; if ( $ this -> showLineNumbers ) $ options [ 'numbers' ] = ( $ this -> lineNumberStyle === 'list' ) ? HL_NUMBERS_LI : HL_NUMBERS_TABLE ; $ highlighter = empt... | Highlights the content by the syntax of the specified language . |
5,957 | protected function handleException ( $ exception ) { $ app = Yii :: app ( ) ; if ( $ app instanceof CWebApplication ) { if ( ( $ trace = $ this -> getExactTrace ( $ exception ) ) === null ) { $ fileName = $ exception -> getFile ( ) ; $ errorLine = $ exception -> getLine ( ) ; } else { $ fileName = $ trace [ 'file' ] ; ... | Handles the exception . |
5,958 | protected function getExactTrace ( $ exception ) { $ traces = $ exception -> getTrace ( ) ; foreach ( $ traces as $ trace ) { if ( isset ( $ trace [ 'function' ] ) && ( $ trace [ 'function' ] === '__get' || $ trace [ 'function' ] === '__set' ) ) return $ trace ; } return null ; } | Returns the exact trace where the problem occurs . |
5,959 | protected function getViewFile ( $ view , $ code ) { $ viewPaths = array ( Yii :: app ( ) -> getTheme ( ) === null ? null : Yii :: app ( ) -> getTheme ( ) -> getSystemViewPath ( ) , Yii :: app ( ) instanceof CWebApplication ? Yii :: app ( ) -> getSystemViewPath ( ) : null , YII_PATH . DIRECTORY_SEPARATOR . 'views' , ) ... | Determines which view file should be used . |
5,960 | protected function getViewFileInternal ( $ viewPath , $ view , $ code , $ srcLanguage = null ) { $ app = Yii :: app ( ) ; if ( $ view === 'error' ) { $ viewFile = $ app -> findLocalizedFile ( $ viewPath . DIRECTORY_SEPARATOR . "error{$code}.php" , $ srcLanguage ) ; if ( ! is_file ( $ viewFile ) ) $ viewFile = $ app -> ... | Looks for the view under the specified directory . |
5,961 | protected function getVersionInfo ( ) { if ( YII_DEBUG ) { $ version = '<a href="http://www.yiiframework.com/">Yii Framework</a>/' . Yii :: getVersion ( ) ; if ( isset ( $ _SERVER [ 'SERVER_SOFTWARE' ] ) ) $ version = $ _SERVER [ 'SERVER_SOFTWARE' ] . ' ' . $ version ; } else $ version = '' ; return $ version ; } | Returns server version information . If the application is in production mode empty string is returned . |
5,962 | protected function isCoreCode ( $ trace ) { if ( isset ( $ trace [ 'file' ] ) ) { $ systemPath = realpath ( dirname ( __FILE__ ) . '/..' ) ; return $ trace [ 'file' ] === 'unknown' || strpos ( realpath ( $ trace [ 'file' ] ) , $ systemPath . DIRECTORY_SEPARATOR ) === 0 ; } return false ; } | Returns a value indicating whether the call stack is from application code . |
5,963 | protected function renderSourceCode ( $ file , $ errorLine , $ maxLines ) { $ errorLine -- ; if ( $ errorLine < 0 || ( $ lines = @ file ( $ file ) ) === false || ( $ lineCount = count ( $ lines ) ) <= $ errorLine ) return '' ; $ halfLines = ( int ) ( $ maxLines / 2 ) ; $ beginLine = $ errorLine - $ halfLines > 0 ? $ er... | Renders the source code around the error line . |
5,964 | public function run ( ) { list ( $ name , $ id ) = $ this -> resolveNameID ( ) ; if ( substr ( $ name , - 2 ) !== '[]' ) $ name .= '[]' ; if ( isset ( $ this -> htmlOptions [ 'id' ] ) ) $ id = $ this -> htmlOptions [ 'id' ] ; else $ this -> htmlOptions [ 'id' ] = $ id ; $ this -> registerClientScript ( ) ; echo CHtml :... | Runs the widget . This method registers all needed client scripts and renders the multiple file uploader . |
5,965 | public function renderItems ( ) { echo CHtml :: openTag ( $ this -> itemsTagName , array ( 'class' => $ this -> itemsCssClass ) ) . "\n" ; $ data = $ this -> dataProvider -> getData ( ) ; if ( ( $ n = count ( $ data ) ) > 0 ) { $ owner = $ this -> getOwner ( ) ; $ viewFile = $ owner -> getViewFile ( $ this -> itemView ... | Renders the data item list . |
5,966 | public function renderSorter ( ) { if ( $ this -> dataProvider -> getItemCount ( ) <= 0 || ! $ this -> enableSorting || empty ( $ this -> sortableAttributes ) ) return ; echo CHtml :: openTag ( 'div' , array ( 'class' => $ this -> sorterCssClass ) ) . "\n" ; echo $ this -> sorterHeader === null ? Yii :: t ( 'zii' , 'So... | Renders the sorter . |
5,967 | public function authenticate ( ) { if ( $ this -> username === 'demo' && $ this -> password === 'demo' ) $ this -> errorCode = self :: ERROR_NONE ; else $ this -> errorCode = self :: ERROR_PASSWORD_INVALID ; return ! $ this -> errorCode ; } | Validates the username and password . This method should check the validity of the provided username and password in some way . In case of any authentication failure set errorCode and errorMessage with appropriate values and return false . |
5,968 | public function init ( ) { list ( $ name , $ id ) = $ this -> resolveNameID ( ) ; if ( isset ( $ this -> htmlOptions [ 'id' ] ) ) $ id = $ this -> htmlOptions [ 'id' ] ; else $ this -> htmlOptions [ 'id' ] = $ id ; if ( isset ( $ this -> htmlOptions [ 'name' ] ) ) $ name = $ this -> htmlOptions [ 'name' ] ; $ this -> r... | Initializes the widget . This method registers all needed client scripts and renders the autocomplete input . |
5,969 | public function save ( $ file , $ messages ) { if ( ! ( $ fw = @ fopen ( $ file , 'wb' ) ) ) throw new CException ( Yii :: t ( 'yii' , 'Unable to write file "{file}".' , array ( '{file}' => $ file ) ) ) ; if ( ! @ flock ( $ fw , LOCK_EX ) ) throw new CException ( Yii :: t ( 'yii' , 'Unable to lock file "{file}" for wri... | Saves messages to an MO file . |
5,970 | protected function writeInteger ( $ fw , $ data ) { return $ this -> writeByte ( $ fw , pack ( $ this -> useBigEndian ? 'N' : 'V' , ( int ) $ data ) ) ; } | Writes a 4 - byte integer . |
5,971 | protected function readString ( $ fr , $ length , $ offset = null ) { if ( $ offset !== null ) fseek ( $ fr , $ offset ) ; return $ this -> readByte ( $ fr , $ length ) ; } | Reads a string . |
5,972 | public static function ensureArray ( $ value ) { if ( is_string ( $ value ) ) { $ value = trim ( $ value ) ; $ len = strlen ( $ value ) ; if ( $ len >= 2 && $ value [ 0 ] == '(' && $ value [ $ len - 1 ] == ')' ) { try { return eval ( 'return array' . $ value . ';' ) ; } catch ( ParseError $ e ) { return array ( ) ; } }... | Converts a value to array type . |
5,973 | public static function ensureEnum ( $ value , $ enumType ) { static $ types = array ( ) ; if ( ! isset ( $ types [ $ enumType ] ) ) $ types [ $ enumType ] = new ReflectionClass ( $ enumType ) ; if ( $ types [ $ enumType ] -> hasConstant ( $ value ) ) return $ value ; else throw new CException ( Yii :: t ( 'yii' , 'Inva... | Converts a value to enum type . |
5,974 | protected function isRelationTable ( $ table ) { $ pk = $ table -> primaryKey ; $ count = is_array ( $ pk ) ? count ( $ pk ) : 1 ; return ( $ count === 2 && isset ( $ table -> foreignKeys [ $ pk [ 0 ] ] ) && isset ( $ table -> foreignKeys [ $ pk [ 1 ] ] ) && $ table -> foreignKeys [ $ pk [ 0 ] ] [ 0 ] !== $ table -> fo... | 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 . |
5,975 | public function executeBizRule ( $ bizRule , $ params , $ data ) { if ( $ bizRule === '' || $ bizRule === null ) return true ; if ( $ this -> showErrors ) return eval ( $ bizRule ) != 0 ; else { try { return @ eval ( $ bizRule ) != 0 ; } catch ( ParseError $ e ) { return false ; } } } | Executes the specified business rule . |
5,976 | protected function checkItemChildType ( $ parentType , $ childType ) { static $ types = array ( 'operation' , 'task' , 'role' ) ; if ( $ parentType < $ childType ) throw new CException ( Yii :: t ( 'yii' , 'Cannot add an item of type "{child}" to an item of type "{parent}".' , array ( '{child}' => $ types [ $ childType... | Checks the item types to make sure a child can be added to a parent . |
5,977 | public function formatCurrency ( $ value , $ currency ) { return $ this -> format ( $ this -> _locale -> getCurrencyFormat ( ) , $ value , $ currency ) ; } | Formats a number using the currency format defined in the locale . |
5,978 | protected function emptyAttribute ( $ object , $ attribute ) { if ( $ this -> safe ) $ object -> $ attribute = null ; if ( ! $ this -> allowEmpty ) { $ message = $ this -> message !== null ? $ this -> message : Yii :: t ( 'yii' , '{attribute} cannot be blank.' ) ; $ this -> addError ( $ object , $ attribute , $ message... | Raises an error to inform end user about blank attribute . Sets the owner attribute to null to prevent setting arbitrary values . |
5,979 | function reverse ( ) { if ( version_compare ( zend_version ( ) , '2' , '>' ) ) { $ rev = clone ( $ this ) ; } else { $ rev = $ this ; } $ rev -> _edits = array ( ) ; foreach ( $ this -> _edits as $ edit ) { $ rev -> _edits [ ] = $ edit -> reverse ( ) ; } return $ rev ; } | Computes a reversed diff . |
5,980 | 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 . |
5,981 | 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 . |
5,982 | function _getTempDir ( ) { $ tmp_locations = array ( '/tmp' , '/var/tmp' , 'c:\WUTemp' , 'c:\temp' , 'c:\windows\temp' , 'c:\winnt\temp' ) ; $ tmp = ini_get ( 'upload_tmp_dir' ) ; if ( ! strlen ( $ tmp ) ) { $ tmp = getenv ( 'TMPDIR' ) ; } while ( ! strlen ( $ tmp ) && count ( $ tmp_locations ) ) { $ tmp_check = array_... | Determines the location of the system temporary directory . |
5,983 | function _check ( $ from_lines , $ to_lines ) { if ( serialize ( $ from_lines ) != serialize ( $ this -> getOriginal ( ) ) ) { trigger_error ( "Reconstructed original doesn't match" , E_USER_ERROR ) ; } if ( serialize ( $ to_lines ) != serialize ( $ this -> getFinal ( ) ) ) { trigger_error ( "Reconstructed final doesn'... | Checks a diff for validity . |
5,984 | public function init ( $ dbType , $ defaultValue ) { if ( $ defaultValue == '(NULL)' ) { $ defaultValue = null ; } parent :: init ( $ dbType , $ defaultValue ) ; } | Initializes the column with its DB type and default value . This sets up the column s PHP type size precision scale as well as default value . |
5,985 | public function init ( ) { parent :: init ( ) ; Yii :: setPathOfAlias ( 'gii' , dirname ( __FILE__ ) ) ; Yii :: app ( ) -> setComponents ( array ( 'errorHandler' => array ( 'class' => 'CErrorHandler' , 'errorAction' => $ this -> getId ( ) . '/default/error' , ) , 'user' => array ( 'class' => 'CWebUser' , 'stateKeyPrefi... | Initializes the gii module . |
5,986 | 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 ... | Finds all available code generators and their code templates . |
5,987 | 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 ( ) ->... | Provides autocomplete table names |
5,988 | 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... | Retrieves filtered log messages from logger for further processing . |
5,989 | public function compareTableNames ( $ name1 , $ name2 ) { $ name1 = str_replace ( array ( '[' , ']' ) , '' , $ name1 ) ; $ name2 = str_replace ( array ( '[' , ']' ) , '' , $ name2 ) ; return parent :: compareTableNames ( strtolower ( $ name1 ) , strtolower ( $ name2 ) ) ; } | Compares two table names . The table names can be either quoted or unquoted . This method will consider both cases . |
5,990 | 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 ; } $ sql = <<<EOD SELECT KCU... | Gets foreign relationship constraint keys and table name |
5,991 | 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 ===... | Generates the WSDL for the given class . |
5,992 | protected function addCommands ( CConsoleCommandRunner $ runner ) { $ runner -> addCommands ( Yii :: getPathOfAlias ( 'system.cli.commands.shell' ) ) ; $ runner -> addCommands ( Yii :: getPathOfAlias ( 'application.commands.shell' ) ) ; if ( ( $ _path_ = @ getenv ( 'YIIC_SHELL_COMMAND_PATH' ) ) !== false ) $ runner -> ... | Adds commands to runner |
5,993 | protected function init ( ) { parent :: init ( ) ; if ( empty ( $ _SERVER [ 'argv' ] ) ) die ( 'This script must be run from the command line.' ) ; $ this -> _runner = $ this -> createCommandRunner ( ) ; $ this -> _runner -> commands = $ this -> commandMap ; $ this -> _runner -> addCommands ( $ this -> getCommandPath (... | Initializes the application by creating the command runner . |
5,994 | public function processRequest ( ) { $ exitCode = $ this -> _runner -> run ( $ _SERVER [ 'argv' ] ) ; if ( is_int ( $ exitCode ) ) $ this -> end ( $ exitCode ) ; } | Processes the user request . This method uses a console command runner to handle the particular user command . Since version 1 . 1 . 11 this method will exit application with an exit code if one is returned by the user command . |
5,995 | public function getViewFile ( $ controller , $ viewName ) { $ moduleViewPath = $ this -> getViewPath ( ) ; if ( ( $ module = $ controller -> getModule ( ) ) !== null ) $ moduleViewPath .= '/' . $ module -> getId ( ) ; return $ controller -> resolveViewFile ( $ viewName , $ this -> getViewPath ( ) . '/' . $ controller -... | Finds the view file for the specified controller s view . |
5,996 | 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 ) ) br... | Finds the layout file for the specified controller s layout . |
5,997 | 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 ) ; retur... | Logs in the user using the given password in the model . |
5,998 | 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 ; } $ th... | 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 . |
5,999 | 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 co... | The code preview action . This action shows up the specified generated code . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.