idx int64 0 60.3k | question stringlengths 99 4.85k | target stringlengths 5 718 |
|---|---|---|
54,700 | private function setComplement ( $ complement ) { $ this -> getStates ( ) ; $ this -> setComplementParams ( $ complement ) ; $ state = $ this -> getState ( ) ; $ action = $ this -> getAction ( $ state ) ; $ this -> setAction ( $ action ) ; $ this -> setState ( $ state ) ; $ this -> getSettings ( ) ; $ states = [ 'activ... | Set complement . |
54,701 | private function setComplementParams ( $ complement ) { $ params = array_intersect_key ( array_flip ( self :: $ required ) , $ complement ) ; $ slug = explode ( '.' , basename ( $ complement [ 'config-file' ] ) ) ; $ default [ 'slug' ] = $ slug [ 0 ] ; $ complementType = self :: getType ( 'strtoupper' ) ; $ path = App ... | Check required params and set complement params . |
54,702 | private function getLanguage ( ) { $ wpLang = ( function_exists ( 'get_locale' ) ) ? get_locale ( ) : null ; $ browserLang = null ; if ( isset ( $ _SERVER [ 'HTTP_ACCEPT_LANGUAGE' ] ) ) { $ browserLang = $ _SERVER [ 'HTTP_ACCEPT_LANGUAGE' ] ; } return substr ( $ wpLang ? : $ browserLang ? : 'en' , 0 , 2 ) ; } | Gets the current locale . |
54,703 | private function setImage ( ) { $ slug = $ this -> complement [ 'slug' ] ; $ complementType = self :: getType ( 'strtoupper' ) ; $ complementPath = App :: $ complementType ( ) ; $ complementUrl = $ complementType . '_URL' ; $ complementUrl = App :: $ complementUrl ( ) ; $ file = 'public/images/' . $ slug . '.png' ; $ f... | Set image url . |
54,704 | private static function getType ( $ mode = 'strtolower' , $ plural = true ) { $ namespace = get_called_class ( ) ; $ class = explode ( '\\' , $ namespace ) ; $ complement = strtolower ( array_pop ( $ class ) . ( $ plural ? 's' : '' ) ) ; switch ( $ mode ) { case 'ucfirst' : return ucfirst ( $ complement ) ; case 'strto... | Get complement type . |
54,705 | private function addRoutes ( ) { if ( class_exists ( $ Router = 'Josantonius\Router\Router' ) ) { if ( isset ( $ this -> complement [ 'routes' ] ) ) { $ Router :: add ( $ this -> complement [ 'routes' ] ) ; } } } | Add complement routes if exists . |
54,706 | public function refreshAccessToken ( ) { $ newToken = $ this -> http -> requestAccessToken ( ) ; if ( ! is_null ( $ newToken ) ) { $ this -> config -> setAccessToken ( $ newToken ) ; $ this -> http = new Request ( $ this -> guzzle , $ this -> config , $ this -> climate ) ; if ( $ this -> config -> shouldStoreToken ( ) ... | Get a new access token |
54,707 | public static function wait ( string $ args ) : ? SymfonyProcess { $ process = new SymfonyProcess ( 'php ' . Accessor :: $ appRoot . 'craftsman ' . $ args ) ; $ process -> start ( ) ; $ process -> wait ( ) ; $ process -> stop ( ) ; return $ process ; } | Run and wait |
54,708 | public function createModule ( Module $ module ) { $ dst = $ this -> rootDir . '/../src/Terrific/Module/' . StringUtils :: camelize ( $ module -> getName ( ) ) ; if ( $ this -> toolbarMode === ToolbarListener :: DEMO ) { throw new \ Exception ( 'This action is not supported in demo mode' ) ; } else { if ( $ this -> mod... | Creates a Terrific Module |
54,709 | public function createSkin ( Skin $ skin ) { $ module = new Module ( ) ; $ module -> setName ( $ skin -> getModule ( ) ) ; $ module -> addSkin ( $ skin ) ; $ dst = $ this -> rootDir . '/../src/Terrific/Module/' . StringUtils :: camelize ( $ module -> getName ( ) ) ; if ( $ this -> toolbarMode === ToolbarListener :: DEM... | Creates a Terrific Skin |
54,710 | public function getModules ( ) { $ modules = array ( ) ; $ dir = $ this -> rootDir . '/../src/Terrific/Module/' ; $ finder = new Finder ( ) ; $ finder -> directories ( ) -> in ( $ dir ) -> depth ( '== 0' ) ; foreach ( $ finder as $ file ) { $ module = $ file -> getFilename ( ) ; $ modules [ $ module ] = $ this -> getMo... | Gets all existing Modules |
54,711 | public function getCount ( $ where = '' , $ variables = null ) { $ where = $ this -> formatWhereClause ( $ where ) ; $ response = $ this -> driver -> query ( "select count(*) as numberOfItems from " . $ this -> getTable ( ) . ' ' . $ where . ";" , $ variables ) ; if ( ! $ response -> count ( ) ) return 0 ; $ response =... | Return the number of items available in the table |
54,712 | protected function formatWhereClause ( $ where ) { if ( ! empty ( $ where ) ) { if ( stripos ( $ where , 'where' ) === false || stripos ( $ where , 'select' ) !== false ) { $ where = ' where ' . $ where ; } } return $ where ; } | Some simple checks for a where clause |
54,713 | public function fetchAll ( $ page , $ pagination , $ where ) { $ index = ceil ( ( $ page - 1 ) * $ pagination ) ; $ where = $ this -> formatWhereClause ( $ where ) ; $ sql = " select " . $ this -> getMappingAsSQL ( ) . " from " . $ this -> getTable ( ) . " " . $ where . " limit " . $ index . ',' . intval ( $ pa... | Actually fetch all the items with the given params |
54,714 | protected function fetchByColumn ( $ column , $ value ) { $ response = $ this -> driver -> query ( "select " . $ this -> getMappingAsSQL ( ) . " from " . $ this -> getTable ( ) . " where `" . $ column . "` = ? limit 1;" , array ( $ value ) , static :: DATA_OBJECT_CLASS ) ; return $ response -> row ( ) ; } | Do actual mysql query by specific criteria |
54,715 | public function getPrimaryKey ( $ tableAlias = '' ) { $ output = '' ; if ( ! empty ( $ tableAlias ) ) { $ output .= '`' . $ tableAlias . '`.' ; } $ output .= '`' . static :: ID_COLUMN . '`' ; return $ output ; } | Return primary key qualified or not |
54,716 | public function getColumnsAsSQL ( $ tableAlias = '' , $ columnPrefix = '' ) { if ( empty ( $ this -> mapping ) ) { return '*' ; } $ output = '' ; foreach ( $ this -> mapping as $ column => $ mappingField ) { if ( ! empty ( $ output ) ) { $ output .= ',' ; } if ( ! empty ( $ tableAlias ) ) { $ output .= '`' . $ tableAli... | Get raw columns as SQL with some prefix options |
54,717 | protected function resetMappingOptions ( ) { $ this -> mappingOptions = new \ stdClass ( ) ; $ this -> mappingOptions -> destructiveMapping = false ; $ this -> mappingOptions -> assignNonMappedColumns = true ; $ this -> mappingOptions -> fieldPrefix = '' ; $ this -> mappingOptions -> throwOnEmptyId = false ; $ this -> ... | Reset mapping options |
54,718 | public function setDestructiveMapping ( $ destructiveMapping ) { if ( empty ( $ this -> mappingOptions ) ) $ this -> resetMappingOptions ( ) ; $ this -> mappingOptions -> destructiveMapping = $ destructiveMapping ; return $ this ; } | Set destructive mapping option |
54,719 | public function setAssignNonMappedColumns ( $ assignNonMappedColumns ) { if ( empty ( $ this -> mappingOptions ) ) $ this -> resetMappingOptions ( ) ; $ this -> mappingOptions -> assignNonMappedColumns = $ assignNonMappedColumns ; return $ this ; } | Set flag for assigning non - mapped columns |
54,720 | public function setFieldPrefix ( $ fieldPrefix ) { if ( empty ( $ this -> mappingOptions ) ) $ this -> resetMappingOptions ( ) ; $ this -> mappingOptions -> fieldPrefix = $ fieldPrefix ; return $ this ; } | Set mapping option field prefix |
54,721 | public function setThrowIfEmptyId ( $ throwOnEmptyId ) { if ( empty ( $ this -> mappingOptions ) ) $ this -> resetMappingOptions ( ) ; $ this -> mappingOptions -> throwOnEmptyId = $ throwOnEmptyId ; return $ this ; } | Throw an exception if the main id doesn t get mapped? |
54,722 | protected function mapObject ( $ databaseResult ) { foreach ( $ databaseResult as $ column => $ value ) { if ( ! empty ( $ this -> mapping [ $ column ] ) ) { list ( $ variable , $ modifier ) = $ this -> splitVariableWithModifier ( $ this -> mapping [ $ column ] ) ; $ this -> $ variable = $ this -> getMappedValue ( $ da... | Map a single object to this instance |
54,723 | protected function splitVariableWithModifier ( $ column ) { $ modifier = false ; if ( strpos ( $ column , ':' ) !== false ) { return explode ( ':' , $ column ) ; } return [ $ column , false ] ; } | Splits variable with a modifier |
54,724 | protected function modifierDate ( $ input ) { if ( empty ( $ input ) ) return NULL ; if ( $ input instanceof \ DateTime ) return $ input ; try { $ output = new \ DateTime ( $ input ) ; $ output -> setTimeZone ( new \ DateTimeZone ( 'America/New_York' ) ) ; return $ output ; } catch ( \ Exception $ exception ) { if ( ! ... | Return a date time modified input |
54,725 | protected function modifierTimezone ( $ input ) { if ( $ input instanceof \ DateTimeZone ) return $ input ; try { $ output = new \ DateTimeZone ( $ input ) ; return $ output ; } catch ( \ Exception $ exception ) { if ( ! empty ( $ this -> log ) ) $ this -> log -> error ( "Failed to convert \\DateTimeZone object from st... | Return a timezone modified input |
54,726 | public function buildModel ( $ databaseResult = null ) { $ this -> resetMappingOptions ( ) ; if ( empty ( $ databaseResult ) ) return ; $ this -> mapObject ( $ databaseResult ) ; } | Map the object to itself |
54,727 | public function performMappingOnObject ( DataObject $ object ) { foreach ( $ this -> mapping as $ field => $ variable ) { $ modifier = false ; $ newField = $ variable ; if ( strpos ( $ variable , ':' ) !== false ) { list ( $ newField , $ modifier ) = explode ( ':' , $ variable ) ; $ object -> $ newField = $ this -> get... | Array walk function overridable |
54,728 | public function insertObject ( DataObject $ object , $ skipID = true ) { $ data = [ ] ; foreach ( $ this -> mapping as $ column => $ local ) { if ( $ skipID && ( $ column == static :: ID_COLUMN ) ) continue ; $ modifier = false ; if ( strpos ( $ local , ':' ) !== false ) { list ( $ local , $ modifier ) = explode ( ':' ... | Attempts to insert the object into the table |
54,729 | public function getUnmappedArray ( DataObject $ object ) { $ output = [ ] ; foreach ( $ this -> mapping as $ unmappedField => $ mappedField ) { if ( strpos ( $ mappedField , ':' ) !== false ) { list ( $ mappedField , $ modifier ) = explode ( ':' , $ mappedField ) ; } $ output [ $ unmappedField ] = $ object -> { $ mappe... | Return an array of an object as an unmapped aray useful for dumping defaults |
54,730 | public function findFilename ( $ name ) { $ logicalName = ( string ) $ name ; if ( isset ( $ this -> cache [ $ logicalName ] ) ) { return $ this -> cache [ $ logicalName ] ; } try { $ template = $ this -> parser -> parse ( $ name ) ; $ file = $ this -> locator -> locate ( $ template ) ; } catch ( \ Exception $ e ) { th... | Helper function for getting a template file name . |
54,731 | public function decryptMessage ( $ message ) { $ calgo = $ this -> config -> getCipherAlgorithm ( ) ; $ cmode = $ this -> config -> getCipherMode ( ) ; $ malgo = $ this -> config -> getHmacAlgorithm ( ) ; $ size = mcrypt_get_iv_size ( $ calgo , $ cmode ) ; $ keySize = mcrypt_get_key_size ( $ calgo , $ cmode ) ; $ hmacS... | Decrypts a message with auhtenticity check . |
54,732 | public function encryptMessage ( $ input ) { $ input = ( string ) $ input ; $ calgo = $ this -> config -> getCipherAlgorithm ( ) ; $ cmode = $ this -> config -> getCipherMode ( ) ; $ malgo = $ this -> config -> getHmacAlgorithm ( ) ; $ size = mcrypt_get_iv_size ( $ calgo , $ cmode ) ; $ keySize = mcrypt_get_key_size ( ... | Encrypts the given message and adds an authenticity code . |
54,733 | public function getColumnResult ( string $ columnName ) : FieldSearchResult { if ( ! $ this -> hasColumnResult ( $ columnName ) ) { throw new \ RuntimeException ( 'Could not find changed column named "' . $ columnName . '"' ) ; } return $ this -> fieldMatchList [ $ columnName ] ; } | Returns the column result matching the passed name . |
54,734 | public function load ( array $ configs , ContainerBuilder $ container ) { $ configuration = new Configuration ( ) ; $ processor = new Processor ( ) ; $ config = $ processor -> processConfiguration ( $ configuration , $ configs ) ; $ container -> setParameter ( 'white_october_pagerfanta.default_view' , $ config [ 'defau... | Responds to the white_october_pagerfanta configuration parameter . |
54,735 | public function getAttributeConditions ( $ attributeName , $ unindexablePredicates = false ) { return array_filter ( $ this -> parts , function ( Condition $ part ) use ( $ attributeName , $ unindexablePredicates ) { if ( $ part instanceof self ) { return $ part -> getAttributeConditions ( $ attributeName , $ unindexab... | Return all conditions of the specified type in this expression which use the indicated attribute as an operand . |
54,736 | public function boot ( ) { $ this -> loadConfig ( ) ; $ this -> registerExceptionHandler ( ) ; $ this -> registerProviders ( ) ; $ this -> registerAliases ( ) ; $ this -> registerScaraMasterSessionToken ( ) ; } | Handles registering Scara s pre - execution status . |
54,737 | private function loadConfig ( ) { $ this -> _config = new Configuration ( ) ; $ this -> _config -> from ( 'app' ) ; date_default_timezone_set ( $ this -> _config -> get ( 'timezone' ) ) ; } | Loads the application s main configuration . |
54,738 | private function registerControllers ( ) { $ this -> _controller = new Controller ( ) ; $ this -> _controller -> load ( $ this -> _router , $ this -> _config -> get ( 'basepath' ) ) ; } | Responsible for registering the app controllers . |
54,739 | private function registerScaraMasterSessionToken ( ) { $ s = SessionInitializer :: init ( ) ; $ h = new OpenSslHasher ( ) ; if ( ! $ s -> has ( 'SCARA_SESSION_TOKEN' ) ) { $ token = substr ( $ h -> tokenize ( $ h -> random_string ( 16 ) , time ( ) ) , 0 , 16 ) ; $ session = $ h -> tokenize ( $ token , hash ( 'sha256' ,... | Registers Scara s master session . |
54,740 | private function setUp ( $ class , Run $ run ) { if ( ! $ class ) { $ run -> writeOutput ( "Missing `class` parameter on {$this->jobModel->id} job" ) -> setResult ( Run :: RESULT_FAILED ) ; return false ; } if ( ! class_exists ( $ class ) ) { $ run -> writeOutput ( "$class does not exist" ) -> setResult ( Run :: RESULT... | Sets up an invokable class for a scheduled job run . |
54,741 | private function invoke ( callable $ job , Run $ run ) { try { ob_start ( ) ; $ ret = call_user_func ( $ job , $ run ) ; $ result = Run :: RESULT_SUCCEEDED ; if ( false === $ ret ) { $ result = Run :: RESULT_FAILED ; } return $ run -> writeOutput ( ob_get_clean ( ) ) -> setResult ( $ result ) ; } catch ( Exception $ e ... | Executes the actual job . |
54,742 | private function saveRun ( Run $ run ) { $ this -> jobModel -> last_ran = time ( ) ; $ this -> jobModel -> last_run_succeeded = $ run -> succeeded ( ) ; $ this -> jobModel -> last_run_output = $ run -> getOutput ( ) ; $ this -> jobModel -> save ( ) ; } | Saves the run attempt . |
54,743 | public static function format_backtrace ( $ backtrace ) { global $ CFG ; $ html = '' ; $ i = count ( $ backtrace ) ; foreach ( $ backtrace as $ trace ) { $ file = ( isset ( $ trace [ 'file' ] ) ) ? str_replace ( $ CFG -> base_absroot , '' , $ trace [ 'file' ] ) : 'unknown' ; $ line = 'Line: ' . ( ( isset ( $ trace [ 'l... | Format a backtrace for better display . |
54,744 | public static function error_handler ( $ errcode , $ errstr , $ errfile , $ errline , $ errcontext ) { throw new \ Exception ( $ errstr . ' in ' . $ errfile . ' on line ' . $ errline , $ errcode ) ; } | Handle PHP errors . |
54,745 | public static function write_error_html ( $ errtitle , $ errdetails , $ errcode , $ backtrace = null ) { global $ USR ; ?> <!DOCTYPE HTML> <html xmlns="http://www.w3.org/1999/xhtml" lang="en"> <head> <meta charset="UTF-8" /> <meta http-equiv="Content-Type" content="text/html;charset=utf-8" /> <title> <?php ... | For handle - able errors print out our custom error screen . |
54,746 | public function getDailyMotionId ( $ url ) { if ( preg_match ( '!^.+dailymotion\.com/(video|hub)/([^_]+)[^#]*(#video=([^_&]+))?|(dai\.ly/([^_]+))!' , $ url , $ m ) ) { if ( isset ( $ m [ 6 ] ) ) { return $ m [ 6 ] ; } if ( isset ( $ m [ 4 ] ) ) { return $ m [ 4 ] ; } return $ m [ 2 ] ; } return false ; } | Extracts the daily motion id from a daily motion url . Returns false if the url is not recognized as a daily motion url . |
54,747 | public static function display_debug ( $ obj ) { $ ptr = self :: get_debug_vars ( $ obj ) ; if ( $ obj instanceof Smarty ) { $ smarty = clone $ obj ; } else { $ smarty = clone $ obj -> smarty ; } $ _assigned_vars = $ ptr -> tpl_vars ; ksort ( $ _assigned_vars ) ; $ _config_vars = $ ptr -> config_vars ; ksort ( $ _confi... | Opens a window for the Smarty Debugging Consol and display the data |
54,748 | public function getDriver ( array $ mappingSource ) : DriverInterface { if ( \ array_key_exists ( 'driver' , $ mappingSource ) ) { $ driver = $ mappingSource [ 'driver' ] ; if ( ! $ driver instanceof DriverInterface ) { throw new DriverException ( \ sprintf ( 'Metadata mapping driver should be of the type %s, %s given'... | Get mapping driver . |
54,749 | protected function getDriverImplementation ( string $ type , array $ paths ) : DriverInterface { switch ( $ type ) { case DriverFactoryInterface :: DRIVER_ANNOTATION : return $ this -> getAnnotationDriver ( $ paths ) ; case DriverFactoryInterface :: DRIVER_PHP : return $ this -> getPhpDriver ( $ paths ) ; case DriverFa... | Get mapping driver implementation . |
54,750 | private static function _write ( $ type , $ message ) { $ log_path = Config :: get ( 'log.folder' , LOLLIPOP_STORAGE_LOG ) ; $ log_enable = Config :: get ( 'log.enable' , true ) ; $ log_hourly = Config :: get ( 'log.hourly' , false ) ; if ( ! is_dir ( $ log_path ) ) throw new \ Lollipop \ Exception \ Runtime ( 'Log fol... | Append to log file |
54,751 | public static function loadCsvToArray ( $ field , $ firstRowLabels = true ) { $ result = false ; if ( ! empty ( $ _FILES [ $ field ] [ 'tmp_name' ] ) ) { $ csv = fopen ( $ _FILES [ $ field ] [ 'tmp_name' ] , 'r' ) ; $ result = array ( ) ; if ( $ firstRowLabels ) { $ fields = fgetcsv ( $ csv ) ; } while ( $ csvRow = fge... | Load an uploaded CSV file into an associative array |
54,752 | public static function URLfromPath ( $ path , array $ vars = null , $ basePath = false ) { if ( $ vars === null ) { if ( php_sapi_name ( ) != 'cli' ) { $ vars = $ _SERVER ; } else { return false ; } } if ( $ basePath !== false && substr ( $ path , 0 , 1 ) !== '/' ) { $ basePath = rtrim ( $ basePath , '/' ) ; $ path = r... | Generate a URL from a path |
54,753 | public function invoke ( $ name , array $ args ) { $ signature = $ name . ':' . serialize ( $ args ) ; if ( ! isset ( $ this -> cache [ $ signature ] ) ) { $ this -> cache [ $ signature ] = call_user_func_array ( array ( $ this -> repository , $ name ) , $ args ) ; } return $ this -> cache [ $ signature ] ; } | Read results from cache or proxy to wrapped doctrine repository . |
54,754 | public function choice ( FormView $ choice ) { $ that = $ this ; if ( $ choice -> vars [ 'compound' ] ) { usort ( $ choice -> children , function ( FormView $ a , FormView $ b ) use ( $ that ) { return $ that -> compare ( $ a -> vars [ 'label' ] ? : $ a -> vars [ 'value' ] , $ b -> vars [ 'label' ] ? : $ b -> vars [ 'v... | Sort choice . |
54,755 | private function updateCheck ( $ name ) { $ filePath = Yii :: getPathOfAlias ( 'base.themes' ) . DS . $ name ; $ details = $ this -> actionDetails ( $ name ) ; if ( file_exists ( $ filePath . DS . 'VERSION' ) ) { $ version = file_get_contents ( $ filePath . DS . 'VERSION' ) ; if ( $ version != $ details [ 'latest-versi... | Checks if an update is necessary |
54,756 | public function actionUpdateCheck ( $ name = false ) { if ( $ name == false ) return false ; if ( defined ( 'CII_CONFIG' ) ) return $ this -> returnError ( 200 , Yii :: t ( 'Api.main' , 'Update is not required' ) , false ) ; if ( $ this -> updateCheck ( $ name ) ) return $ this -> returnError ( 200 , Yii :: t ( 'Api.ma... | Exposed action to check for an update |
54,757 | public function actionUpdate ( $ name = false ) { if ( $ name == false || defined ( 'CII_CONFIG' ) ) return false ; if ( $ this -> updateCheck ( $ name ) ) { if ( ! $ this -> actionInstall ( $ name ) ) return $ this -> returnError ( 500 , Yii :: t ( 'Api.main' , 'Update failed' ) , false ) ; } return $ this -> actionDe... | Performs an update |
54,758 | public function actionInstall ( $ name = false ) { if ( $ name == false || defined ( 'CII_CONFIG' ) ) return false ; $ filePath = Yii :: getPathOfAlias ( 'base.themes' ) . DS . $ name ; $ details = $ this -> actionDetails ( $ name ) ; if ( $ this -> actionIsInstalled ( $ name , true ) ) { if ( file_exists ( $ filePath ... | Installs and or updates a theme using the provided name |
54,759 | public function actionUninstall ( $ name = false ) { if ( $ name == false ) return false ; if ( $ name == 'default' ) throw new CHttpException ( 400 , Yii :: t ( 'Api.theme' , 'You cannot uninstall the default theme.' ) ) ; if ( ! $ this -> actionIsInstalled ( $ name ) ) return false ; $ installedThemes = $ this -> act... | Uninstalls a theme by name |
54,760 | public function actionList ( ) { if ( defined ( 'CII_CONFIG' ) ) return false ; $ response = Yii :: app ( ) -> cache -> get ( 'CiiMS::API::Themes::Available' ) ; if ( $ response === false ) { $ url = 'https://themes.ciims.io/index.json' ; $ curl = new \ Curl \ Curl ; $ response = $ curl -> get ( $ url ) ; if ( $ curl -... | Lists ciims - themes that are available for download via |
54,761 | public function actionDetails ( $ name = false ) { if ( $ name == false ) throw new CHttpException ( 400 , Yii :: t ( 'Api.Theme' , 'Missing theme name' ) ) ; $ data = Yii :: app ( ) -> cache -> get ( 'CiiMS::API::Themes::' . $ name ) ; if ( $ data === false ) { $ url = 'https://packagist.org/packages/ciims-themes/' . ... | Retrieves the details about a particular theme |
54,762 | public function actionCallbackPost ( $ theme = NULL , $ method = NULL ) { $ this -> callback ( $ theme , $ method , $ _POST ) ; } | Allows themes to have their own dedicated callback resources for POST |
54,763 | private function callback ( $ theme , $ method , $ data ) { if ( $ theme == NULL ) throw new CHttpException ( 400 , Yii :: t ( 'Api.Theme' , 'Missing Theme' ) ) ; if ( $ method == NULL ) throw new CHttpException ( 400 , Yii :: t ( 'Api.Theme' , 'Method name is missing' ) ) ; Yii :: import ( 'base.themes.' . $ theme . '... | Callback method for actionCallback and actionCallbackPost |
54,764 | public function save ( $ name , Config $ config ) { $ path = $ this -> _getPath ( $ name ) ; $ data = $ config -> valueOf ( ) ; file_put_contents ( $ path , serialize ( $ data ) ) ; return true ; } | Save config data |
54,765 | public function delete ( $ name ) { $ path = $ this -> _getPath ( $ name ) ; if ( file_exists ( $ path ) ) { $ result = @ unlink ( $ path ) ; } else { $ result = false ; } return $ result ; } | Delete config data |
54,766 | public static function encode ( $ data , $ forceObject = false ) { return @ json_encode ( $ data , JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE | ( $ forceObject ? JSON_FORCE_OBJECT : 0 ) ) ; } | Encode the given data into a JSON string . |
54,767 | public static function decode ( $ json , $ assoc = false , $ maxDepth = 512 ) { $ result = @ json_decode ( $ json , $ assoc , $ maxDepth ) ; if ( $ result === NULL ) { switch ( $ error = json_last_error ( ) ) { case JSON_ERROR_NONE : return NULL ; case JSON_ERROR_CTRL_CHAR : throw new JsonUnserializationException ( 'An... | Decode the given JSON string into a PHP data structure . |
54,768 | public function get ( $ index ) { return array_slice ( $ this -> items , $ index * $ this -> itemsPerPage , $ this -> itemsPerPage ) ; } | Returns the items on the given page number . |
54,769 | public function useName ( $ name ) { if ( empty ( $ name ) ) { throw new \ Exception ( 'Given name is empty!' ) ; } if ( ! isset ( $ _FILES [ $ name ] ) ) { throw new \ Exception ( 'Given name not exists in $_FILES var!' ) ; } $ this -> data = $ _FILES [ $ name ] ; return $ this ; } | Use name as default in File s methods . |
54,770 | public function move ( $ toDir , $ fileName = null , $ mode = 0775 ) { if ( $ this -> hasError ( ) ) { throw new \ Exception ( 'Cannot move file, the file has not been correctly uploaded!' ) ; } $ fileName = ( empty ( $ fileName ) ? $ this -> get ( 'name' ) : $ fileName ) ; if ( ! file_exists ( $ toDir ) && ! mkdir ( $... | Move uploaded file . |
54,771 | public function actionView ( $ id ) { if ( ! empty ( $ id ) ) { $ model = Order :: findOne ( $ id ) ; if ( empty ( $ model ) ) { $ model = new Order ( ) ; } if ( Yii :: $ app -> user -> can ( 'changeOrderStatus' ) ) { if ( $ model -> load ( Yii :: $ app -> request -> post ( ) ) ) { $ this -> trigger ( self :: EVENT_BEF... | Displays a single Order model and changes status for this model . |
54,772 | public function actionDeleteProduct ( $ id ) { if ( ( $ model = OrderProduct :: findOne ( $ id ) ) !== null ) { $ model -> delete ( ) ; } else { throw new NotFoundHttpException ( 'The requested page does not exist.' ) ; } return $ this -> redirect ( \ Yii :: $ app -> request -> referrer ) ; } | Deletes product from existing Order model . If deletion is successful the browser will be redirected to the view page . |
54,773 | private function calculateSelectOptionsSize ( $ aElements , $ aFeatures = [ ] ) { $ selectSize = $ this -> calculateSelectOptionsSizeForced ( $ aElements , $ aFeatures ) ; if ( ( in_array ( 'include_null' , $ aFeatures ) ) && ( $ selectSize != '1' ) ) { $ selectSize ++ ; } return $ selectSize ; } | Calculate the optimal for all options within a select tag |
54,774 | private function setOptionsForSelect ( $ aElements , $ sDefaultValue , $ featArray = null ) { if ( is_null ( $ featArray ) ) { $ featArray = [ ] ; } $ sReturn = [ ] ; $ crtGroup = null ; foreach ( $ aElements as $ key => $ value ) { $ aFH = $ this -> setOptionGroupFooterHeader ( $ featArray , $ value , $ crtGroup ) ; $... | Creates all the child tags required to populate a SELECT tag |
54,775 | public static function getValueByPath ( $ dataTree , $ path ) { $ pathParts = explode ( "." , $ path ) ; foreach ( $ pathParts as $ name ) { if ( ! isset ( $ dataTree -> { $ name } ) ) { return null ; } $ dataTree = $ dataTree -> { $ name } ; } return $ dataTree ; } | Get the value of the property in the data tree specified by the dotted path . |
54,776 | public static function setValueByPath ( $ dataTree , $ path , $ value , $ add ) { $ pathParts = explode ( "." , $ path ) ; $ name = $ pathParts [ 0 ] ; if ( ! $ add and ! isset ( $ dataTree -> { $ name } ) ) { return false ; } if ( count ( $ pathParts ) == 1 ) { $ dataTree -> { $ name } = $ value ; return true ; } if (... | Set the value of the property specified by the given path in the data tree . |
54,777 | public static function removeValueByPath ( $ dataTree , $ path ) { $ pathParts = explode ( "." , $ path ) ; $ name = $ pathParts [ 0 ] ; if ( ! isset ( $ dataTree -> { $ name } ) ) { return false ; } if ( count ( $ pathParts ) == 1 ) { unset ( $ dataTree -> { $ name } ) ; return true ; } return ValueByPath :: removeVal... | Remove the value of the property specified by the given path in the data tree . |
54,778 | public function getDriver ( $ libraryName , array $ parameters = null , array $ directory = null , $ newInstance = false ) { if ( empty ( $ libraryName ) ) { throw new LibraryException ( "Could not load driver. No name provided" , 1 ) ; } if ( ! class_exists ( 'FuzeWorks\FW_Driver_Library' , false ) ) { require_once ( ... | Driver Library Loader |
54,779 | protected function loadLibrary ( $ libraryName , $ parameters = null , array $ directory = null , $ newInstance = false ) { $ directories = ( is_null ( $ directory ) ? $ this -> libraryPaths : $ directory ) ; $ class = trim ( $ libraryName , '/' ) ; if ( ( $ last_slash = strrpos ( $ class , '/' ) ) !== FALSE ) { $ subd... | Internal Library Loader |
54,780 | protected function loadAppLibrary ( $ class , $ subdir , array $ parameters = null , array $ directories , $ newInstance = false ) { if ( ! is_array ( $ directories ) ) { throw new LibraryException ( "Could not load library. \$directory variable was not an array" , 1 ) ; } foreach ( $ directories as $ directory ) { if ... | Application Library Loader |
54,781 | public function removeLibraryPath ( $ directory ) { if ( ( $ key = array_search ( $ directory , $ this -> libraryPaths ) ) !== false ) { unset ( $ this -> libraryPaths [ $ key ] ) ; } } | Remove a path where libraries can be found |
54,782 | function find ( array $ logic = null ) { $ logic != null or $ logic = [ ] ; $ opt = [ ] ; foreach ( [ '%fields' , '%order_by' , '%limit' , '%offset' ] as $ key ) { if ( isset ( $ logic [ $ key ] ) ) { $ opt [ $ key ] = $ logic [ $ key ] ; unset ( $ logic [ $ key ] ) ; } else { $ opt [ $ key ] = [ ] ; } } $ entries = $ ... | You can specify fields via %fields You can specify limit via %limit and offset via %offset You can specify order rules via %order_by |
54,783 | protected function sqlinsert ( array $ fields , array $ nums = null , array $ bools = null ) { $ db = $ this -> db ; $ nums != null or $ nums = [ ] ; $ bools != null or $ bools = [ ] ; $ keys = array_keys ( $ fields ) ; $ strs = array_diff ( $ keys , $ bools , $ nums ) ; $ key_fields = \ hlin \ Arr :: join ( ', ' , $ k... | Inserts fields if bools or nums are specified the fields mentioned are treated as strings . |
54,784 | protected function sqlupdate ( array $ fields , array $ nums = null , array $ bools = null ) { $ db = $ this -> db ; $ idfield = $ this -> idfield ( ) ; $ nums != null or $ nums = [ ] ; $ bools != null or $ bools = [ ] ; $ keys = array_diff ( array_keys ( $ fields ) , [ $ idfield ] ) ; $ strs = array_diff ( array_keys ... | Update fields if bools or nums are specified the fields mentioned are treated as strings |
54,785 | protected function sqlentry ( $ entry_id ) { $ res = $ this -> sqlfind ( [ $ this -> idfield ( ) => $ entry_id ] , null , null , 1 ) ; if ( empty ( $ res ) ) { return null ; } else { return $ res [ 0 ] ; } } | Mostly an alias to sqlsearch on id with limit of 1 . |
54,786 | public static function factory ( $ config = array ( ) ) { $ default = array ( 'base_url' => 'https://api.runkeeper.com' , 'logger' => FALSE , ) ; $ required = array ( 'base_url' ) ; $ config = Collection :: fromConfig ( $ config , $ default , $ required ) ; $ client = new self ( $ config -> get ( 'base_url' ) ) ; $ cli... | Factory method to create a new HealthGraphClient |
54,787 | public function headers ( ) : array { return collect ( $ this -> request -> getHeaders ( ) ) -> mapWithKeys ( function ( $ values , $ header ) { return [ $ header => $ values [ 0 ] ] ; } ) -> all ( ) ; } | Gets all header values . |
54,788 | public function build ( ) : string { if ( count ( $ this -> parameters ) === 0 ) { return '' ; } $ queryString = '' ; foreach ( $ this -> parameters as $ name => $ value ) { $ queryString .= $ this -> buildQuery ( $ name , $ value ) ; } return substr ( $ queryString , 1 ) ; } | build the query from parameters |
54,789 | protected function buildQuery ( string $ name , $ value , string $ postfix = '' ) : string { $ query = '' ; if ( is_array ( $ value ) ) { foreach ( $ value as $ k => $ v ) { if ( is_int ( $ k ) ) { $ query .= $ this -> buildQuery ( '' , $ v , $ postfix . $ name . '[]' ) ; } else { $ query .= $ this -> buildQuery ( '' ,... | Calculates query string |
54,790 | public function addParam ( string $ name , $ value ) : self { if ( ! is_array ( $ value ) && ! is_scalar ( $ value ) && null !== $ value ) { if ( is_object ( $ value ) && method_exists ( $ value , '__toString' ) ) { $ value = ( string ) $ value ; } else { throw new \ InvalidArgumentException ( 'Argument 2 passed to ' .... | add a parameter |
54,791 | public function removeParam ( string $ name ) : self { if ( array_key_exists ( $ name , $ this -> parameters ) ) { unset ( $ this -> parameters [ $ name ] ) ; } return $ this ; } | remove a param |
54,792 | final public function __isset ( $ prop ) { $ this -> magicPropConvert ( $ prop ) ; return is_array ( $ this -> { $ this :: MAGIC_PROPERTY } ) ? array_key_exists ( $ prop , $ this -> { $ this :: MAGIC_PROPERTY } ) : isset ( $ this -> { $ this :: MAGIC_PROPERTY } -> $ prop ) ; } | Magic isset metod . |
54,793 | public function next ( ) { $ this -> valid = ! $ this -> inputStream -> eof ( ) ; $ this -> currentLine = $ this -> inputStream -> readLine ( ) ; $ this -> lineNumber ++ ; } | moves forward to next line |
54,794 | public function rewind ( ) { if ( ! ( $ this -> inputStream instanceof Seekable ) ) { return ; } $ this -> inputStream -> seek ( 0 , Seekable :: SET ) ; $ this -> lineNumber = 0 ; $ this -> currentLine = null ; $ this -> next ( ) ; } | rewinds to first line |
54,795 | public function addDebug ( $ message , array $ context = array ( ) ) { return $ this -> _instance -> addRecord ( \ Monolog \ Logger :: DEBUG , $ message , $ context ) ; } | Adds a log record at the DEBUG level . |
54,796 | public function addInfo ( $ message , array $ context = array ( ) ) { return $ this -> _instance -> addRecord ( \ Monolog \ Logger :: INFO , $ message , $ context ) ; } | Adds a log record at the INFO level . |
54,797 | public function addNotice ( $ message , array $ context = array ( ) ) { return $ this -> _instance -> addRecord ( \ Monolog \ Logger :: NOTICE , $ message , $ context ) ; } | Adds a log record at the NOTICE level . |
54,798 | public function addCritical ( $ message , array $ context = array ( ) ) { return $ this -> _instance -> addRecord ( \ Monolog \ Logger :: CRITICAL , $ message , $ context ) ; } | Adds a log record at the CRITICAL level . |
54,799 | public function addAlert ( $ message , array $ context = array ( ) ) { return $ this -> _instance -> addRecord ( \ Monolog \ Logger :: ALERT , $ message , $ context ) ; } | Adds a log record at the ALERT level . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.