idx int64 0 241k | question stringlengths 64 6.21k | target stringlengths 5 803 |
|---|---|---|
6,000 | 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' , ... | The code diff action . This action shows up the difference between the newly generated code and the corresponding existing code . |
6,001 | public function getViewPath ( ) { if ( $ this -> _viewPath === null ) { $ class = new ReflectionClass ( get_class ( $ this ) ) ; $ this -> _viewPath = dirname ( $ class -> getFileName ( ) ) . DIRECTORY_SEPARATOR . 'views' ; } return $ this -> _viewPath ; } | Returns the view path of the generator . The views directory under the directory containing the generator class file will be returned . |
6,002 | protected function prepare ( ) { if ( $ this -> codeModel === null ) throw new CException ( get_class ( $ this ) . '.codeModel property must be specified.' ) ; $ modelClass = Yii :: import ( $ this -> codeModel , true ) ; $ model = new $ modelClass ; $ model -> loadStickyAttributes ( ) ; if ( isset ( $ _POST [ $ modelC... | Prepares the code model . |
6,003 | public static function format ( $ messages , $ number ) { $ n = preg_match_all ( '/\s*([^#]*)\s*#([^\|]*)\|/' , $ messages . '|' , $ matches ) ; if ( $ n === 0 ) return $ messages ; for ( $ i = 0 ; $ i < $ n ; ++ $ i ) { $ expression = $ matches [ 1 ] [ $ i ] ; $ message = $ matches [ 2 ] [ $ i ] ; if ( $ expression ==... | Formats a message according to the specified number value . |
6,004 | public function actionSuggestTags ( ) { if ( isset ( $ _GET [ 'q' ] ) && ( $ keyword = trim ( $ _GET [ 'q' ] ) ) !== '' ) { $ tags = Tag :: model ( ) -> suggestTags ( $ keyword ) ; if ( $ tags !== array ( ) ) echo implode ( "\n" , $ tags ) ; } } | Suggests tags based on the current user input . This is called via AJAX when the user is entering the tags input . |
6,005 | protected function newComment ( $ post ) { $ comment = new Comment ; if ( isset ( $ _POST [ 'ajax' ] ) && $ _POST [ 'ajax' ] === 'comment-form' ) { echo CActiveForm :: validate ( $ comment ) ; Yii :: app ( ) -> end ( ) ; } if ( isset ( $ _POST [ 'Comment' ] ) ) { $ comment -> attributes = $ _POST [ 'Comment' ] ; if ( $... | Creates a new comment . This method attempts to create a new comment based on the user input . If the comment is successfully created the browser will be redirected to show the created comment . |
6,006 | public function encrypt ( $ data , $ key = null ) { if ( $ key === null ) $ key = $ this -> getEncryptionKey ( ) ; $ this -> validateEncryptionKey ( $ key ) ; $ module = $ this -> openCryptModule ( ) ; srand ( ) ; $ iv = @ mcrypt_create_iv ( mcrypt_enc_get_iv_size ( $ module ) , MCRYPT_RAND ) ; @ mcrypt_generic_init ( ... | Encrypts data . |
6,007 | public function validateData ( $ data , $ key = null ) { if ( ! is_string ( $ data ) ) return false ; $ len = $ this -> strlen ( $ this -> computeHMAC ( 'test' ) ) ; if ( $ this -> strlen ( $ data ) >= $ len ) { $ hmac = $ this -> substr ( $ data , 0 , $ len ) ; $ data2 = $ this -> substr ( $ data , $ len , $ this -> s... | Validates if data is tampered . |
6,008 | public function generateRandomBytes ( $ length , $ cryptographicallyStrong = true ) { $ bytes = '' ; if ( function_exists ( 'openssl_random_pseudo_bytes' ) ) { $ bytes = openssl_random_pseudo_bytes ( $ length , $ strong ) ; if ( $ this -> strlen ( $ bytes ) >= $ length && ( $ strong || ! $ cryptographicallyStrong ) ) r... | Generates a string of random bytes . |
6,009 | public function generateSessionRandomBlock ( ) { ini_set ( 'session.entropy_length' , 20 ) ; if ( ini_get ( 'session.entropy_length' ) != 20 ) return false ; @ session_start ( ) ; @ session_regenerate_id ( ) ; $ bytes = session_id ( ) ; if ( ! $ bytes ) return false ; return sha1 ( $ bytes , true ) ; } | Get random bytes from the system entropy source via PHP session manager . |
6,010 | private function substr ( $ string , $ start , $ length ) { return $ this -> _mbstring ? mb_substr ( $ string , $ start , $ length , '8bit' ) : substr ( $ string , $ start , $ length ) ; } | Returns the portion of string specified by the start and length parameters . If available uses the multibyte string function mb_substr |
6,011 | public function unmaskToken ( $ maskedToken ) { $ decoded = base64_decode ( strtr ( $ maskedToken , '-_' , '+/' ) ) ; $ length = $ this -> strlen ( $ decoded ) / 2 ; if ( ! is_int ( $ length ) ) return '' ; return $ this -> substr ( $ decoded , $ length , $ length ) ^ $ this -> substr ( $ decoded , 0 , $ length ) ; } | Unmasks a token previously masked by maskToken . |
6,012 | public function load ( $ file , $ context ) { $ pattern = '/(msgctxt\s+"(.*?(?<!\\\\))")?\s+' . 'msgid\s+((?:".*(?<!\\\\)"\s*)+)\s+' . 'msgstr\s+((?:".*(?<!\\\\)"\s*)+)/' ; $ matches = array ( ) ; $ n = preg_match_all ( $ pattern , file_get_contents ( $ file ) , $ matches ) ; $ messages = array ( ) ; for ( $ i = 0 ; $ ... | Loads messages from a PO file . |
6,013 | protected function generateClassNames ( $ schema , $ pattern = null ) { $ this -> _tables = array ( ) ; foreach ( $ schema -> getTableNames ( ) as $ name ) { if ( $ pattern === null ) $ this -> _tables [ $ name ] = $ this -> generateClassName ( $ this -> removePrefix ( $ name ) ) ; elseif ( preg_match ( $ pattern , $ n... | Generates the mapping table between table names and class names . |
6,014 | public function init ( ) { parent :: init ( ) ; if ( $ this -> name === null ) $ this -> sortable = false ; if ( $ this -> name === null && $ this -> value === null ) throw new CException ( Yii :: t ( 'zii' , 'Either "name" or "value" must be specified for CDataColumn.' ) ) ; } | Initializes the column . |
6,015 | public function getHeaderCellContent ( ) { if ( $ this -> grid -> enableSorting && $ this -> sortable && $ this -> name !== null ) return $ this -> grid -> dataProvider -> getSort ( ) -> link ( $ this -> name , $ this -> header , array ( 'class' => 'sort-link' ) ) ; elseif ( $ this -> name !== null && $ this -> header ... | Returns the header cell content . This method will render a link that can trigger the sorting if the column is sortable . |
6,016 | protected function generateDependentData ( ) { if ( $ this -> directory !== null ) return $ this -> generateTimestamps ( $ this -> directory ) ; else throw new CException ( Yii :: t ( 'yii' , 'CDirectoryCacheDependency.directory cannot be empty.' ) ) ; } | Generates the data needed to determine if dependency has been changed . This method returns the modification timestamps for files under the directory . |
6,017 | public static function getInstance ( $ id ) { static $ locales = array ( ) ; if ( isset ( $ locales [ $ id ] ) ) return $ locales [ $ id ] ; else return $ locales [ $ id ] = new CLocale ( $ id ) ; } | Returns the instance of the specified locale . Since the constructor of CLocale is protected you can only use this method to obtain an instance of the specified locale . |
6,018 | public function getMonthNames ( $ width = 'wide' , $ standAlone = false ) { if ( $ standAlone ) return isset ( $ this -> _data [ 'monthNamesSA' ] [ $ width ] ) ? $ this -> _data [ 'monthNamesSA' ] [ $ width ] : $ this -> _data [ 'monthNames' ] [ $ width ] ; else return isset ( $ this -> _data [ 'monthNames' ] [ $ width... | Returns the month names in the specified width . |
6,019 | public function getWeekDayNames ( $ width = 'wide' , $ standAlone = false ) { if ( $ standAlone ) return isset ( $ this -> _data [ 'weekDayNamesSA' ] [ $ width ] ) ? $ this -> _data [ 'weekDayNamesSA' ] [ $ width ] : $ this -> _data [ 'weekDayNames' ] [ $ width ] ; else return isset ( $ this -> _data [ 'weekDayNames' ]... | Returns the week day names in the specified width . |
6,020 | public function getLanguageID ( $ id ) { $ id = $ this -> getCanonicalID ( $ id ) ; if ( ( $ underscorePosition = strpos ( $ id , '_' ) ) !== false ) { $ id = substr ( $ id , 0 , $ underscorePosition ) ; } return $ id ; } | Converts a locale ID to a language ID . A language ID consists of only the first group of letters before an underscore or dash . |
6,021 | public function getScriptID ( $ id ) { $ id = $ this -> getCanonicalID ( $ id ) ; if ( ( $ underscorePosition = strpos ( $ id , '_' ) ) !== false ) { $ subTag = explode ( '_' , $ id ) ; if ( strlen ( $ subTag [ 1 ] ) === 4 ) { $ id = $ subTag [ 1 ] ; } else { $ id = null ; } } else { $ id = null ; } return $ id ; } | Converts a locale ID to a script ID . A script ID consists of only the last four characters after an underscore or dash . |
6,022 | public function getTerritoryID ( $ id ) { $ id = $ this -> getCanonicalID ( $ id ) ; if ( ( $ underscorePosition = strpos ( $ id , '_' ) ) !== false ) { $ subTag = explode ( '_' , $ id ) ; if ( isset ( $ subTag [ 2 ] ) && strlen ( $ subTag [ 2 ] ) < 4 ) { $ id = $ subTag [ 2 ] ; } elseif ( strlen ( $ subTag [ 1 ] ) < 4... | Converts a locale ID to a territory ID . A territory ID consists of only the last two to three letter or digits after an underscore or dash . |
6,023 | public function __isset ( $ name ) { if ( $ this -> contains ( $ name ) ) return $ this -> itemAt ( $ name ) !== null ; else return parent :: __isset ( $ name ) ; } | Checks if a property value is null . This method overrides the parent implementation by checking if the key exists in the collection and contains a non - null value . |
6,024 | public function mergeWith ( $ data , $ recursive = true ) { if ( ! $ this -> caseSensitive && ( is_array ( $ data ) || $ data instanceof Traversable ) ) { $ d = array ( ) ; foreach ( $ data as $ key => $ value ) $ d [ strtolower ( $ key ) ] = $ value ; return parent :: mergeWith ( $ d , $ recursive ) ; } parent :: merg... | Merges iterable data into the map . |
6,025 | public function getPagination ( $ className = 'CPagination' ) { if ( $ this -> _pagination === null ) { $ this -> _pagination = new $ className ; if ( ( $ id = $ this -> getId ( ) ) != '' ) $ this -> _pagination -> pageVar = $ id . '_page' ; } return $ this -> _pagination ; } | Returns the pagination object . |
6,026 | public function getSort ( $ className = 'CSort' ) { if ( $ this -> _sort === null ) { $ this -> _sort = new $ className ; if ( ( $ id = $ this -> getId ( ) ) != '' ) $ this -> _sort -> sortVar = $ id . '_sort' ; } return $ this -> _sort ; } | Returns the sort object . |
6,027 | public function getData ( $ refresh = false ) { if ( $ this -> _data === null || $ refresh ) $ this -> _data = $ this -> fetchData ( ) ; return $ this -> _data ; } | Returns the data items currently available . |
6,028 | public function getKeys ( $ refresh = false ) { if ( $ this -> _keys === null || $ refresh ) $ this -> _keys = $ this -> fetchKeys ( ) ; return $ this -> _keys ; } | Returns the key values associated with the data items . |
6,029 | public function assign ( $ userId , $ bizRule = null , $ data = null ) { return $ this -> _auth -> assign ( $ this -> _name , $ userId , $ bizRule , $ data ) ; } | Assigns this item to a user . |
6,030 | public function actionLogin ( ) { $ user = new LoginForm ; if ( Yii :: app ( ) -> request -> isPostRequest ) { if ( isset ( $ _POST [ 'LoginForm' ] ) ) $ user -> setAttributes ( $ _POST [ 'LoginForm' ] ) ; if ( $ user -> validate ( ) ) $ this -> redirect ( Yii :: app ( ) -> user -> returnUrl ) ; } $ this -> render ( 'l... | Displays a login form to login a user . |
6,031 | public function hasItemChild ( $ itemName , $ childName ) { return $ this -> db -> createCommand ( ) -> select ( 'parent' ) -> from ( $ this -> itemChildTable ) -> where ( 'parent=:parent AND child=:child' , array ( ':parent' => $ itemName , ':child' => $ childName ) ) -> queryScalar ( ) !== false ; } | Returns a value indicating whether a child exists within a parent . |
6,032 | public function isAssigned ( $ itemName , $ userId ) { return $ this -> db -> createCommand ( ) -> select ( 'itemname' ) -> from ( $ this -> assignmentTable ) -> where ( 'itemname=:itemname AND userid=:userid' , array ( ':itemname' => $ itemName , ':userid' => $ userId ) ) -> queryScalar ( ) !== false ; } | Returns a value indicating whether the item has been assigned to the user . |
6,033 | public function getAuthAssignments ( $ userId ) { $ rows = $ this -> db -> createCommand ( ) -> select ( ) -> from ( $ this -> assignmentTable ) -> where ( 'userid=:userid' , array ( ':userid' => $ userId ) ) -> queryAll ( ) ; $ assignments = array ( ) ; foreach ( $ rows as $ row ) { if ( ( $ data = @ unserialize ( $ r... | Returns the item assignments for the specified user . |
6,034 | public function saveAuthAssignment ( $ assignment ) { $ this -> db -> createCommand ( ) -> update ( $ this -> assignmentTable , array ( 'bizrule' => $ assignment -> getBizRule ( ) , 'data' => serialize ( $ assignment -> getData ( ) ) , ) , 'itemname=:itemname AND userid=:userid' , array ( 'itemname' => $ assignment -> ... | Saves the changes to an authorization assignment . |
6,035 | public function clearAll ( ) { $ this -> clearAuthAssignments ( ) ; $ this -> db -> createCommand ( ) -> delete ( $ this -> itemChildTable ) ; $ this -> db -> createCommand ( ) -> delete ( $ this -> itemTable ) ; } | Removes all authorization data . |
6,036 | public function validateValue ( $ value ) { if ( is_string ( $ value ) && $ this -> validateIDN ) $ value = $ this -> encodeIDN ( $ value ) ; $ valid = is_string ( $ value ) && strlen ( $ value ) <= 254 && ( preg_match ( $ this -> pattern , $ value ) || $ this -> allowName && preg_match ( $ this -> fullPattern , $ valu... | Validates a static value to see if it is a valid email . This method is provided so that you can call it directly without going through the model validation rule mechanism . |
6,037 | public function validateValue ( $ value ) { if ( $ this -> strict ) return $ value === $ this -> trueValue || $ value === $ this -> falseValue ; else return $ value == $ this -> trueValue || $ value == $ this -> falseValue ; } | Validates a static value to see if it is a valid boolean . This method is provided so that you can call it directly without going through the model validation rule mechanism . |
6,038 | private function parseResponse ( ) { if ( ( $ line = fgets ( $ this -> _socket ) ) === false ) throw new CException ( 'Failed reading data from redis connection socket.' ) ; $ type = $ line [ 0 ] ; $ line = substr ( $ line , 1 , - 2 ) ; switch ( $ type ) { case '+' : return true ; case '-' : throw new CException ( 'Red... | Reads the result from socket and parses it |
6,039 | public static function item ( $ type , $ code ) { if ( ! isset ( self :: $ _items [ $ type ] ) ) self :: loadItems ( $ type ) ; return isset ( self :: $ _items [ $ type ] [ $ code ] ) ? self :: $ _items [ $ type ] [ $ code ] : false ; } | Returns the item name for the specified type and code . |
6,040 | private static function loadItems ( $ type ) { self :: $ _items [ $ type ] = array ( ) ; $ models = self :: model ( ) -> findAll ( array ( 'condition' => 'type=:type' , 'params' => array ( ':type' => $ type ) , 'order' => 'position' , ) ) ; foreach ( $ models as $ model ) self :: $ _items [ $ type ] [ $ model -> code ]... | Loads the lookup items for the specified type from the database . |
6,041 | private function getHash ( ) { if ( $ this -> _hash === null ) $ this -> _hash = sha1 ( serialize ( $ this ) ) ; return $ this -> _hash ; } | Generates a unique hash that identifies this cache dependency . |
6,042 | public function submitted ( $ buttonName = 'submit' , $ loadData = true ) { $ ret = $ this -> clicked ( $ this -> getUniqueId ( ) ) && $ this -> clicked ( $ buttonName ) ; if ( $ ret && $ loadData ) $ this -> loadData ( ) ; return $ ret ; } | Returns a value indicating whether this form is submitted . |
6,043 | public function clicked ( $ name ) { if ( strcasecmp ( $ this -> getRoot ( ) -> method , 'get' ) ) return isset ( $ _POST [ $ name ] ) ; else return isset ( $ _GET [ $ name ] ) ; } | Returns a value indicating whether the specified button is clicked . |
6,044 | public function getModel ( $ checkParent = true ) { if ( ! $ checkParent ) return $ this -> _model ; $ form = $ this ; while ( $ form -> _model === null && $ form -> getParent ( ) instanceof self ) $ form = $ form -> getParent ( ) ; return $ form -> _model ; } | Returns the model that this form is associated with . |
6,045 | public function getModels ( ) { $ models = array ( ) ; if ( $ this -> _model !== null ) $ models [ ] = $ this -> _model ; foreach ( $ this -> getElements ( ) as $ element ) { if ( $ element instanceof self ) $ models = array_merge ( $ models , $ element -> getModels ( ) ) ; } return $ models ; } | Returns all models that are associated with this form or its sub - forms . |
6,046 | protected function getUniqueId ( ) { if ( isset ( $ this -> attributes [ 'id' ] ) ) return 'yform_' . $ this -> attributes [ 'id' ] ; else return 'yform_' . sprintf ( '%x' , crc32 ( serialize ( array_keys ( $ this -> getElements ( ) -> toArray ( ) ) ) ) ) ; } | Returns a unique ID that identifies this form in the current page . |
6,047 | private function encodeIDN ( $ value ) { if ( preg_match_all ( '/^(.*):\/\/([^\/]+)(.*)$/' , $ value , $ matches ) ) { if ( function_exists ( 'idn_to_ascii' ) ) $ value = $ matches [ 1 ] [ 0 ] . '://' . idn_to_ascii ( $ matches [ 2 ] [ 0 ] ) . $ matches [ 3 ] [ 0 ] ; else { require_once ( Yii :: getPathOfAlias ( 'syste... | Converts given IDN to the punycode . |
6,048 | private function decodeIDN ( $ value ) { if ( preg_match_all ( '/^(.*):\/\/([^\/]+)(.*)$/' , $ value , $ matches ) ) { if ( function_exists ( 'idn_to_utf8' ) ) $ value = $ matches [ 1 ] [ 0 ] . '://' . idn_to_utf8 ( $ matches [ 2 ] [ 0 ] ) . $ matches [ 3 ] [ 0 ] ; else { require_once ( Yii :: getPathOfAlias ( 'system.... | Converts given punycode to the IDN . |
6,049 | 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 . |
6,050 | protected function renderMenuRecursive ( $ items ) { $ count = 0 ; $ n = count ( $ items ) ; foreach ( $ items as $ item ) { $ count ++ ; $ options = isset ( $ item [ 'itemOptions' ] ) ? $ item [ 'itemOptions' ] : array ( ) ; $ class = array ( ) ; if ( $ item [ 'active' ] && $ this -> activeCssClass != '' ) $ class [ ]... | Recursively renders the menu items . |
6,051 | public function applyJoin ( $ sql , $ join ) { if ( $ join == '' ) return $ sql ; if ( strpos ( $ sql , 'UPDATE' ) === 0 && ( $ pos = strpos ( $ sql , 'SET' ) ) !== false ) return substr ( $ sql , 0 , $ pos ) . $ join . ' ' . substr ( $ sql , $ pos ) ; elseif ( strpos ( $ sql , 'DELETE FROM ' ) === 0 ) { $ tableName = ... | Alters the SQL to apply JOIN clause . This method handles the mysql specific syntax where JOIN has to come before SET in UPDATE statement and for DELETE where JOIN has to be after FROM part . |
6,052 | protected function validateAttribute ( $ object , $ attribute ) { if ( ! $ this -> setOnEmpty ) $ object -> $ attribute = $ this -> value ; else { $ value = $ object -> $ attribute ; if ( $ value === null || $ value === '' ) $ object -> $ attribute = $ this -> value ; } } | Validates the attribute of the object . |
6,053 | public function getSort ( $ className = 'CSort' ) { if ( ( $ sort = parent :: getSort ( $ className ) ) !== false ) $ sort -> modelClass = $ this -> modelClass ; return $ sort ; } | Returns the sorting object . |
6,054 | protected function calculateTotalItemCount ( ) { $ baseCriteria = $ this -> model -> getDbCriteria ( false ) ; if ( $ baseCriteria !== null ) $ baseCriteria = clone $ baseCriteria ; $ count = $ this -> model -> count ( $ this -> getCountCriteria ( ) ) ; $ this -> model -> setDbCriteria ( $ baseCriteria ) ; return $ cou... | Calculates the total number of data items . |
6,055 | public function run ( $ args ) { $ this -> _scriptName = $ args [ 0 ] ; array_shift ( $ args ) ; if ( isset ( $ args [ 0 ] ) ) { $ name = $ args [ 0 ] ; array_shift ( $ args ) ; } else $ name = 'help' ; $ oldCommand = $ this -> _command ; if ( ( $ command = $ this -> createCommand ( $ name ) ) === null ) $ command = $ ... | Executes the requested command . |
6,056 | public function findCommands ( $ path ) { if ( ( $ dir = @ opendir ( $ path ) ) === false ) return array ( ) ; $ commands = array ( ) ; while ( ( $ name = readdir ( $ dir ) ) !== false ) { $ file = $ path . DIRECTORY_SEPARATOR . $ name ; if ( ! strcasecmp ( substr ( $ name , - 11 ) , 'Command.php' ) && is_file ( $ file... | Searches for commands under the specified directory . |
6,057 | public function addCommands ( $ path ) { if ( ( $ commands = $ this -> findCommands ( $ path ) ) !== array ( ) ) { foreach ( $ commands as $ name => $ file ) { if ( ! isset ( $ this -> commands [ $ name ] ) ) $ this -> commands [ $ name ] = $ file ; } } } | Adds commands from the specified command path . If a command already exists the new one will be ignored . |
6,058 | 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 ( ) -> registerScr... | Renders the open tag of the dialog . This method also registers the necessary javascript code . |
6,059 | public function getLastInsertID ( $ table ) { $ this -> ensureTable ( $ table ) ; if ( $ table -> sequenceName !== null ) return $ this -> _connection -> getLastInsertID ( $ table -> sequenceName ) ; else return null ; } | Returns the last insertion ID for the specified table . |
6,060 | public function createFindCommand ( $ table , $ criteria , $ alias = 't' ) { $ this -> ensureTable ( $ table ) ; $ select = is_array ( $ criteria -> select ) ? implode ( ', ' , $ criteria -> select ) : $ criteria -> select ; if ( $ criteria -> alias != '' ) $ alias = $ criteria -> alias ; $ alias = $ this -> _schema ->... | Creates a SELECT command for a single table . |
6,061 | public function createDeleteCommand ( $ table , $ criteria ) { $ this -> ensureTable ( $ table ) ; $ sql = "DELETE FROM {$table->rawName}" ; $ sql = $ this -> applyJoin ( $ sql , $ criteria -> join ) ; $ sql = $ this -> applyCondition ( $ sql , $ criteria -> condition ) ; $ sql = $ this -> applyGroup ( $ sql , $ criter... | Creates a DELETE command . |
6,062 | public function createSqlCommand ( $ sql , $ params = array ( ) ) { $ command = $ this -> _connection -> createCommand ( $ sql ) ; $ this -> bindValues ( $ command , $ params ) ; return $ command ; } | Creates a command based on a given SQL statement . |
6,063 | public function bindValues ( $ command , $ values ) { if ( ( $ n = count ( $ values ) ) === 0 ) return ; if ( isset ( $ values [ 0 ] ) ) { for ( $ i = 0 ; $ i < $ n ; ++ $ i ) $ command -> bindValue ( $ i + 1 , $ values [ $ i ] ) ; } else { foreach ( $ values as $ name => $ value ) { if ( $ name [ 0 ] !== ':' ) $ name ... | Binds parameter values for an SQL command . |
6,064 | public function createCriteria ( $ condition = '' , $ params = array ( ) ) { if ( is_array ( $ condition ) ) $ criteria = new CDbCriteria ( $ condition ) ; elseif ( $ condition instanceof CDbCriteria ) $ criteria = clone $ condition ; else { $ criteria = new CDbCriteria ; $ criteria -> condition = $ condition ; $ crite... | Creates a query criteria . |
6,065 | public function createPkCriteria ( $ table , $ pk , $ condition = '' , $ params = array ( ) , $ prefix = null ) { $ this -> ensureTable ( $ table ) ; $ criteria = $ this -> createCriteria ( $ condition , $ params ) ; if ( $ criteria -> alias != '' ) $ prefix = $ this -> _schema -> quoteTableName ( $ criteria -> alias )... | Creates a query criteria with the specified primary key . |
6,066 | public function createColumnCriteria ( $ table , $ columns , $ condition = '' , $ params = array ( ) , $ prefix = null ) { $ this -> ensureTable ( $ table ) ; $ criteria = $ this -> createCriteria ( $ condition , $ params ) ; if ( $ criteria -> alias != '' ) $ prefix = $ this -> _schema -> quoteTableName ( $ criteria -... | Creates a query criteria with the specified column values . |
6,067 | public function createSearchCondition ( $ table , $ columns , $ keywords , $ prefix = null , $ caseSensitive = true ) { $ this -> ensureTable ( $ table ) ; if ( ! is_array ( $ keywords ) ) $ keywords = preg_split ( '/\s+/u' , $ keywords , - 1 , PREG_SPLIT_NO_EMPTY ) ; if ( empty ( $ keywords ) ) return '' ; if ( $ pref... | Generates the expression for searching the specified keywords within a list of columns . The search expression is generated using the LIKE SQL syntax . Every word in the keywords must be present and appear in at least one of the columns . |
6,068 | protected function ensureTable ( & $ table ) { if ( is_string ( $ table ) && ( $ table = $ this -> _schema -> getTable ( $ tableName = $ table ) ) === null ) throw new CDbException ( Yii :: t ( 'yii' , 'Table "{table}" does not exist.' , array ( '{table}' => $ tableName ) ) ) ; } | Checks if the parameter is a valid table schema . If it is a string the corresponding table schema will be retrieved . |
6,069 | public function save ( $ state ) { $ command = $ this -> db -> createCommand ( ) ; if ( false === $ this -> exists ( ) ) return $ command -> insert ( $ this -> stateTableName , array ( $ this -> keyField => Yii :: app ( ) -> name , $ this -> valueField => serialize ( $ state ) ) ) ; else return $ command -> update ( $ ... | Saves application state in persistent storage . |
6,070 | protected function createTable ( ) { try { $ command = $ this -> db -> createCommand ( ) ; $ command -> createTable ( $ this -> stateTableName , array ( $ this -> keyField => 'string NOT NULL' , $ this -> valueField => 'text NOT NULL' , 'PRIMARY KEY (' . $ this -> db -> quoteColumnName ( $ this -> keyField ) . ')' ) ) ... | Creates state persister table |
6,071 | public function format ( $ pattern , $ time ) { if ( $ time === null ) return null ; if ( is_string ( $ time ) ) { if ( ctype_digit ( $ time ) || ( $ time { 0 } == '-' && ctype_digit ( substr ( $ time , 1 ) ) ) ) $ time = ( int ) $ time ; else $ time = strtotime ( $ time ) ; } $ date = CTimestamp :: getDate ( $ time , ... | Formats a date according to a customized pattern . |
6,072 | public function formatDateTime ( $ timestamp , $ dateWidth = 'medium' , $ timeWidth = 'medium' ) { if ( ! empty ( $ dateWidth ) ) $ date = $ this -> format ( $ this -> _locale -> getDateFormat ( $ dateWidth ) , $ timestamp ) ; if ( ! empty ( $ timeWidth ) ) $ time = $ this -> format ( $ this -> _locale -> getTimeFormat... | Formats a date according to a predefined pattern . The predefined pattern is determined based on the date pattern width and time pattern width . |
6,073 | protected function parseFormat ( $ pattern ) { static $ formats = array ( ) ; if ( isset ( $ formats [ $ pattern ] ) ) return $ formats [ $ pattern ] ; $ tokens = array ( ) ; $ n = strlen ( $ pattern ) ; $ isLiteral = false ; $ literal = '' ; for ( $ i = 0 ; $ i < $ n ; ++ $ i ) { $ c = $ pattern [ $ i ] ; if ( $ c ===... | Parses the datetime format pattern . |
6,074 | protected function formatMinutes ( $ pattern , $ date ) { $ minutes = $ date [ 'minutes' ] ; if ( $ pattern === 'm' ) return $ minutes ; elseif ( $ pattern === 'mm' ) return str_pad ( $ minutes , 2 , '0' , STR_PAD_LEFT ) ; else throw new CException ( Yii :: t ( 'yii' , 'The pattern for minutes must be "m" or "mm".' ) )... | Get the minutes . m for non - padding mm will always return 2 characters . |
6,075 | protected function formatSeconds ( $ pattern , $ date ) { $ seconds = $ date [ 'seconds' ] ; if ( $ pattern === 's' ) return $ seconds ; elseif ( $ pattern === 'ss' ) return str_pad ( $ seconds , 2 , '0' , STR_PAD_LEFT ) ; else throw new CException ( Yii :: t ( 'yii' , 'The pattern for seconds must be "s" or "ss".' ) )... | Get the seconds . s for non - padding ss will always return 2 characters . |
6,076 | protected function formatWeekInYear ( $ pattern , $ date ) { if ( $ pattern === 'w' ) return @ date ( 'W' , @ mktime ( 0 , 0 , 0 , $ date [ 'mon' ] , $ date [ 'mday' ] , $ date [ 'year' ] ) ) ; else throw new CException ( Yii :: t ( 'yii' , 'The pattern for week in year must be "w".' ) ) ; } | Get the week in the year . |
6,077 | protected function formatWeekInMonth ( $ pattern , $ date ) { if ( $ pattern === 'W' ) { $ weekDay = date ( 'N' , mktime ( 0 , 0 , 0 , $ date [ 'mon' ] , 1 , $ date [ 'year' ] ) ) ; return floor ( ( $ weekDay + $ date [ 'mday' ] - 2 ) / 7 ) + 1 ; } else throw new CException ( Yii :: t ( 'yii' , 'The pattern for week in... | Get week in the month . |
6,078 | protected function formatTimeZone ( $ pattern , $ date ) { if ( $ pattern [ 0 ] === 'z' || $ pattern [ 0 ] === 'v' ) return @ date ( 'T' , @ mktime ( $ date [ 'hours' ] , $ date [ 'minutes' ] , $ date [ 'seconds' ] , $ date [ 'mon' ] , $ date [ 'mday' ] , $ date [ 'year' ] ) ) ; elseif ( $ pattern [ 0 ] === 'Z' ) retur... | Get the timezone of the server machine . |
6,079 | protected function formatEra ( $ pattern , $ date ) { $ era = $ date [ 'year' ] > 0 ? 1 : 0 ; switch ( $ pattern ) { case 'G' : case 'GG' : case 'GGG' : return $ this -> _locale -> getEraName ( $ era , 'abbreviated' ) ; case 'GGGG' : return $ this -> _locale -> getEraName ( $ era , 'wide' ) ; case 'GGGGG' : return $ th... | Get the era . i . e . in gregorian year > 0 is AD else BC . |
6,080 | protected function processLogs ( $ logs ) { $ text = '' ; foreach ( $ logs as $ log ) $ text .= $ this -> formatLogMessage ( $ log [ 0 ] , $ log [ 1 ] , $ log [ 2 ] , $ log [ 3 ] ) ; $ logFile = $ this -> getLogPath ( ) . DIRECTORY_SEPARATOR . $ this -> getLogFile ( ) ; $ fp = @ fopen ( $ logFile , 'a' ) ; @ flock ( $ ... | Saves log messages in files . |
6,081 | public static function init ( $ apiKey = null ) { if ( $ apiKey === null ) return CHtml :: scriptFile ( self :: $ bootstrapUrl ) ; else return CHtml :: scriptFile ( self :: $ bootstrapUrl . '?key=' . $ apiKey ) ; } | Renders the jsapi script file . |
6,082 | public function findTagWeights ( $ limit = 20 ) { $ models = $ this -> findAll ( array ( 'order' => 'frequency DESC' , 'limit' => $ limit , ) ) ; $ total = 0 ; foreach ( $ models as $ model ) $ total += $ model -> frequency ; $ tags = array ( ) ; if ( $ total > 0 ) { foreach ( $ models as $ model ) $ tags [ $ model -> ... | Returns tag names and their corresponding weights . Only the tags with the top weights will be returned . |
6,083 | public function setBasePath ( $ value ) { if ( ( $ basePath = realpath ( $ value ) ) !== false && is_dir ( $ basePath ) && is_writable ( $ basePath ) ) $ this -> _basePath = $ basePath ; else throw new CException ( Yii :: t ( 'yii' , 'CAssetManager.basePath "{path}" is invalid. Please make sure the directory exists and... | Sets the root directory storing published asset files . |
6,084 | public function getPublishedUrl ( $ path , $ hashByName = false ) { if ( isset ( $ this -> _published [ $ path ] ) ) return $ this -> _published [ $ path ] ; if ( is_string ( $ path ) && ( $ path = realpath ( $ path ) ) !== false ) { $ base = $ this -> getBaseUrl ( ) . '/' . $ this -> generatePath ( $ path , $ hashByNa... | Returns the URL of a published file path . This method does not perform any publishing . It merely tells you if the file path is published what the URL will be to access it . |
6,085 | protected function generatePath ( $ file , $ hashByName = false ) { if ( is_file ( $ file ) ) $ pathForHashing = $ hashByName ? dirname ( $ file ) : dirname ( $ file ) . filemtime ( $ file ) ; else $ pathForHashing = $ hashByName ? $ file : $ file . filemtime ( $ file ) ; return $ this -> hash ( $ pathForHashing ) ; } | Generates path segments relative to basePath . |
6,086 | 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 . |
6,087 | 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 ) {... | Loads sticky attributes from a file and populates them into the model . |
6,088 | 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 . |
6,089 | 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 . |
6,090 | 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 . |
6,091 | public static function validate ( $ models , $ attributes = null , $ loadInput = true ) { $ result = array ( ) ; if ( ! is_array ( $ models ) ) $ models = array ( $ models ) ; foreach ( $ models as $ model ) { $ modelName = CHtml :: modelName ( $ model ) ; if ( $ loadInput && isset ( $ _POST [ $ modelName ] ) ) $ model... | Validates one or several models and returns the results in JSON format . This is a helper method that simplifies the way of writing AJAX validation code . |
6,092 | public function registerClientScript ( ) { $ cs = Yii :: app ( ) -> clientScript ; $ id = $ this -> imageOptions [ 'id' ] ; $ url = $ this -> getController ( ) -> createUrl ( $ this -> captchaAction , array ( CCaptchaAction :: REFRESH_GET_VAR => true ) ) ; $ js = "" ; if ( $ this -> showRefreshButton ) { $ cs -> regist... | Registers the needed client scripts . |
6,093 | public static function checkRequirements ( $ extension = null ) { if ( extension_loaded ( 'imagick' ) ) { $ imagick = new Imagick ( ) ; $ imagickFormats = $ imagick -> queryFormats ( 'PNG' ) ; } if ( extension_loaded ( 'gd' ) ) { $ gdInfo = gd_info ( ) ; } if ( $ extension === null ) { if ( isset ( $ imagickFormats ) &... | Checks if specified graphic extension support is loaded . |
6,094 | public function jsonSerialize ( ) { return array_filter ( [ 'enable' => $ this -> getEnable ( ) , 'threshold' => $ this -> getThreshold ( ) , 'post_to_url' => $ this -> getPostToUrl ( ) ] , function ( $ value ) { return $ value !== null ; } ) ? : null ; } | Return an array representing a SpamCheck object for the Twilio SendGrid API |
6,095 | public function setGanalytics ( $ enable , $ utm_source = null , $ utm_medium = null , $ utm_term = null , $ utm_content = null , $ utm_campaign = null ) { if ( $ enable instanceof Ganalytics ) { $ ganalytics = $ enable ; $ this -> ganalytics = $ ganalytics ; return ; } $ this -> ganalytics = new Ganalytics ( $ enable ... | Set the Google analytics settings on a TrackingSettings object |
6,096 | public function jsonSerialize ( ) { return array_filter ( [ 'click_tracking' => $ this -> getClickTracking ( ) , 'open_tracking' => $ this -> getOpenTracking ( ) , 'subscription_tracking' => $ this -> getSubscriptionTracking ( ) , 'ganalytics' => $ this -> getGanalytics ( ) ] , function ( $ value ) { return $ value !==... | Return an array representing a TrackingSettings object for the Twilio SendGrid API |
6,097 | public function jsonSerialize ( ) { return array_filter ( [ 'enable' => $ this -> getEnable ( ) , 'enable_text' => $ this -> getEnableText ( ) ] , function ( $ value ) { return $ value !== null ; } ) ? : null ; } | Return an array representing a ClickTracking object for the Twilio SendGrid API |
6,098 | public function jsonSerialize ( ) { return array_filter ( [ 'enable' => $ this -> getEnable ( ) , 'text' => $ this -> getText ( ) , 'html' => $ this -> getHtml ( ) ] , function ( $ value ) { return $ value !== null ; } ) ? : null ; } | Return an array representing a Footer object for the Twilio SendGrid API |
6,099 | public function jsonSerialize ( ) { return array_filter ( [ 'key' => $ this -> getKey ( ) , 'value' => $ this -> getValue ( ) ] , function ( $ value ) { return $ value !== null ; } ) ? : null ; } | Return an array representing a Header object for the Twilio SendGrid API |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.