idx
int64
0
60.3k
question
stringlengths
92
4.62k
target
stringlengths
7
635
18,100
protected function daemonize ( ) { if ( $ this -> isActive ( ) ) { $ this -> getLogger ( ) -> emergency ( $ this -> name . ' daemon is still running. Exiting the application.' ) ; return false ; } $ this -> safeMode = ! ! @ ini_get ( 'safe_mode' ) ; $ this -> processId = 0 ; $ this -> running = false ; try { if ( ! $ t...
Method to put the application into the background .
18,101
public function getAlbum ( $ url ) { if ( $ this -> isAuthenticated ( ) ) { $ jdata = $ this -> query ( $ url , null , array ( 'GData-Version' => 2 ) ) ; $ xml = $ this -> safeXML ( $ jdata -> body ) ; return new Picasa \ Album ( $ xml , $ this -> options , $ this -> auth ) ; } else { return false ; } }
Get Picasa Album
18,102
public function limit ( $ limit = 0 ) { if ( is_null ( $ this -> limit ) ) { $ this -> limit = new QueryElement ( 'LIMIT' , ( int ) $ limit ) ; } return $ this ; }
Set the LIMIT clause to the query
18,103
public function stream_open ( $ path , $ mode , $ options , & $ opened_path ) { $ this -> currentString = & StringController :: getRef ( str_replace ( 'string://' , '' , $ path ) ) ; if ( $ this -> currentString ) { $ this -> len = strlen ( $ this -> currentString ) ; $ this -> pos = 0 ; $ this -> stat = $ this -> url_...
Method to open a file or URL .
18,104
public function createComment ( $ note , $ message ) { $ data = array ( ) ; $ data [ 'message' ] = $ message ; return $ this -> createConnection ( $ note , 'comments' , $ data ) ; }
Method to comment on a note . Requires authentication and publish_stream and user_notes or friends_notes permissions .
18,105
public function getChannel ( $ accountID , $ adclientID , $ channelID ) { if ( $ this -> isAuthenticated ( ) ) { $ url = 'https://www.googleapis.com/adsense/v1.1/accounts/' . urlencode ( $ accountID ) . '/adclients/' ; $ url .= urlencode ( $ adclientID ) . '/customchannels/' . urlencode ( $ channelID ) ; $ jdata = $ th...
Method to get an Adsense Channel
18,106
public function getList ( $ owner , $ repo ) { $ path = '/repos/' . $ owner . '/' . $ repo . '/downloads' ; return $ this -> processResponse ( $ this -> client -> get ( $ this -> fetchUrl ( $ path ) ) ) ; }
List downloads for a repository .
18,107
public function create ( $ owner , $ repo , $ content , $ encoding = 'utf-8' ) { $ path = '/repos/' . $ owner . '/' . $ repo . '/git/blobs' ; $ data = array ( 'content' => $ content , 'encoding' => $ encoding ) ; return $ this -> processResponse ( $ this -> client -> post ( $ this -> fetchUrl ( $ path ) , json_encode (...
Create a Blob .
18,108
public function getListRepository ( $ owner , $ repo , $ all = true , $ participating = true , Date $ since = null ) { $ path = '/repos/' . $ owner . '/' . $ repo . '/notifications?' ; $ path .= ( $ all ) ? '&all=1' : '' ; $ path .= ( $ participating ) ? '&participating=1' : '' ; $ path .= ( $ since ) ? '&since=' . $ s...
List your notifications in a repository .
18,109
public function listActivities ( $ userId , $ collection , $ fields = null , $ max = 10 , $ token = null , $ alt = null ) { if ( $ this -> isAuthenticated ( ) ) { $ url = $ this -> getOption ( 'api.url' ) . 'people/' . $ userId . '/activities/' . $ collection ; if ( $ fields ) { $ url .= '?fields=' . $ fields ; } if ( ...
List all of the activities in the specified collection for a particular user .
18,110
public function getActivity ( $ id , $ fields = null , $ alt = null ) { if ( $ this -> isAuthenticated ( ) ) { $ url = $ this -> getOption ( 'api.url' ) . 'activities/' . $ id ; if ( $ fields ) { $ url .= '?fields=' . $ fields ; } if ( $ alt ) { $ url .= ( strpos ( $ url , '?' ) === false ) ? '?alt=' : '&alt=' ; $ url ...
Get an activity .
18,111
public static function getImageFileProperties ( $ path ) { if ( ! file_exists ( $ path ) ) { throw new \ InvalidArgumentException ( 'The image file does not exist.' ) ; } $ info = getimagesize ( $ path ) ; if ( ! $ info ) { throw new \ RuntimeException ( 'Unable to get properties for the image.' ) ; } $ properties = ( ...
Method to return a properties object for an image given a filesystem path . The result object has values for image width height type attributes mime type bits and channels .
18,112
public function generateThumbs ( $ thumbSizes , $ creationMethod = self :: SCALE_INSIDE ) { if ( ! $ this -> isLoaded ( ) ) { throw new \ LogicException ( 'No valid image was loaded.' ) ; } if ( ! is_array ( $ thumbSizes ) ) { $ thumbSizes = array ( $ thumbSizes ) ; } $ generated = array ( ) ; if ( ! empty ( $ thumbSiz...
Method to generate thumbnails from the current image . It allows creation by resizing or cropping the original image .
18,113
protected function getFilterInstance ( $ type ) { $ type = strtolower ( preg_replace ( '#[^A-Z0-9_]#i' , '' , $ type ) ) ; $ className = 'Joomla\\Image\\Filter\\' . ucfirst ( $ type ) ; if ( ! class_exists ( $ className ) ) { $ this -> getLogger ( ) -> error ( 'The ' . ucfirst ( $ type ) . ' image filter is not availab...
Method to get an image filter instance of a specified type .
18,114
protected function prepareDimensions ( $ width , $ height , $ scaleMethod ) { $ dimensions = new \ stdClass ; switch ( $ scaleMethod ) { case self :: SCALE_FILL : $ dimensions -> width = ( int ) round ( $ width ) ; $ dimensions -> height = ( int ) round ( $ height ) ; break ; case self :: SCALE_INSIDE : case self :: SC...
Method to get the new dimensions for a resized image .
18,115
protected function sanitizeHeight ( $ height , $ width ) { $ height = ( $ height === null ) ? $ width : $ height ; if ( preg_match ( '/^[0-9]+(\.[0-9]+)?\%$/' , $ height ) ) { $ height = ( int ) round ( $ this -> getHeight ( ) * ( float ) str_replace ( '%' , '' , $ height ) / 100 ) ; } else { $ height = ( int ) round (...
Method to sanitize a height value .
18,116
public function addDecorator ( $ name , $ options = array ( ) ) { $ decorator = DecoratorFactory :: factoryHeader ( $ name , $ options ) ; $ this -> attachDecorator ( $ decorator ) ; $ decorator -> setHeader ( $ this ) ; return $ decorator ; }
Set options like title width order sortable
18,117
public function setOptions ( $ options ) { $ this -> title = ( isset ( $ options [ 'title' ] ) ) ? $ options [ 'title' ] : '' ; $ this -> width = ( isset ( $ options [ 'width' ] ) ) ? $ options [ 'width' ] : '' ; $ this -> order = ( isset ( $ options [ 'order' ] ) ) ? $ options [ 'order' ] : true ; $ this -> sortable =...
Set options like title width order
18,118
public function render ( ) { $ this -> initRendering ( ) ; $ render = $ this -> getTitle ( ) ; foreach ( $ this -> decorators as $ decorator ) { $ render = $ decorator -> render ( $ render ) ; } return sprintf ( '<th %s >%s</th>' , $ this -> getAttributes ( ) , $ render ) ; }
Rendering header element
18,119
public function filter ( $ data , $ group = null ) { if ( ! ( $ this -> xml instanceof \ SimpleXMLElement ) ) { return false ; } $ input = new Registry ( $ data ) ; $ output = new Registry ; $ fields = $ this -> findFieldsByGroup ( $ group ) ; if ( ! $ fields ) { return false ; } foreach ( $ fields as $ field ) { $ nam...
Method to filter the form data .
18,120
public function getField ( $ name , $ group = null , $ value = null ) { if ( ! ( $ this -> xml instanceof \ SimpleXMLElement ) ) { return false ; } $ element = $ this -> findField ( $ name , $ group ) ; if ( ! $ element ) { return false ; } return $ this -> loadField ( $ element , $ group , $ value ) ; }
Method to get a form field represented as a Field object .
18,121
public function getFieldsets ( $ group = null ) { $ fieldsets = array ( ) ; $ sets = array ( ) ; if ( ! ( $ this -> xml instanceof \ SimpleXMLElement ) ) { return $ fieldsets ; } if ( $ group ) { $ elements = & $ this -> findGroup ( $ group ) ; foreach ( $ elements as & $ element ) { if ( $ tmp = $ element -> xpath ( '...
Method to get an array of fieldset objects optionally filtered over a given field group .
18,122
public function load ( $ data , $ replace = true , $ xpath = false ) { if ( ( ! ( $ data instanceof \ SimpleXMLElement ) ) && ( ! is_string ( $ data ) ) ) { return false ; } if ( is_string ( $ data ) ) { try { $ data = new \ SimpleXMLElement ( $ data ) ; } catch ( \ Exception $ e ) { return false ; } if ( ! $ data ) { ...
Method to load the form description from an XML string or object .
18,123
protected static function addNode ( \ SimpleXMLElement $ source , \ SimpleXMLElement $ new ) { $ node = $ source -> addChild ( $ new -> getName ( ) , trim ( $ new ) ) ; foreach ( $ new -> attributes ( ) as $ name => $ value ) { $ node -> addAttribute ( $ name , $ value ) ; } foreach ( $ new -> children ( ) as $ child )...
Adds a new child SimpleXMLElement node to the source .
18,124
protected static function mergeNode ( \ SimpleXMLElement $ source , \ SimpleXMLElement $ new ) { foreach ( $ new -> attributes ( ) as $ name => $ value ) { if ( isset ( $ source [ $ name ] ) ) { $ source [ $ name ] = ( string ) $ value ; } else { $ source -> addAttribute ( $ name , $ value ) ; } } }
Update the attributes of a child node
18,125
public function get ( $ owner , $ repo , $ user ) { $ path = '/repos/' . $ owner . '/' . $ repo . '/collaborators/' . $ user ; $ response = $ this -> client -> get ( $ this -> fetchUrl ( $ path ) ) ; switch ( $ response -> code ) { case '204' ; return true ; break ; case '404' ; return false ; break ; default ; throw n...
Test if a user is a collaborator .
18,126
public function add ( $ owner , $ repo , $ user ) { $ path = '/repos/' . $ owner . '/' . $ repo . '/collaborators/' . $ user ; return $ this -> processResponse ( $ this -> client -> put ( $ this -> fetchUrl ( $ path ) , '' ) , 204 ) ; }
Add collaborator .
18,127
public function getData ( ) { $ this -> performGetRequest ( '/search.php?vpn=' . $ this -> plateNumber ) ; $ html = ( string ) $ this -> response -> getBody ( ) ; $ crawler = new Crawler ( $ html ) ; $ rawVehicleData = [ ] ; $ nodeValues = $ crawler -> filter ( 'table > tbody > tr' ) -> each ( function ( $ node , $ i )...
Get Raw Data
18,128
public function processData ( $ data ) { $ string = explode ( ' ' , $ data , 3 ) ; if ( substr_count ( $ data , ' ' ) > 1 ) { $ isModelPresent = ( $ string [ 0 ] == 'Model' ) ? true : false ; if ( $ isModelPresent ) { $ rawVehicleData [ $ string [ 0 ] ] = $ string [ 1 ] . ' ' . $ string [ 2 ] ; } else { $ string [ 0 ] ...
Process vehicle data to make it possible to store them as key - value pairs in an array .
18,129
public function getSection ( $ name , $ default = null ) { return isset ( $ this -> getSections ( ) [ $ name ] ) ? $ this -> getSections ( ) [ $ name ] : $ default ; }
Get the contents of a section .
18,130
public function deleteImage ( $ updateDb = false ) { $ owner = $ this -> owner ; $ DS = DIRECTORY_SEPARATOR ; $ image = str_replace ( '/' , $ DS , $ this -> _oldImage ) ; if ( ! empty ( $ image ) ) { $ dirName = Yii :: getAlias ( $ this -> _savePathAlias ) ; foreach ( $ this -> getImageSizes ( ) as $ prefix => $ size )...
Delete image file and set|save model image field to null
18,131
protected function getImageSizes ( ) { if ( is_callable ( $ this -> _imageSizes ) ) { return call_user_func ( $ this -> _imageSizes , $ this -> owner ) ; } else { return $ this -> _imageSizes ; } }
Get image sizes
18,132
protected function uploadImage ( UploadedFile $ image ) { $ DS = DIRECTORY_SEPARATOR ; $ maxWidth = 1500 ; $ namePart = uniqid ( ) ; $ name = $ namePart . '.' . $ image -> extension ; $ imageFolder = Yii :: getAlias ( $ this -> _savePathAlias ) ; $ rnddir = static :: getRandomDir ( $ imageFolder ) ; $ fullImagePath = $...
Save uploaded image
18,133
public function getImageSrc ( $ size = null ) { $ owner = $ this -> owner ; $ prefix = '' ; if ( Yii :: $ app -> request instanceof \ yii \ web \ Request ) { $ prefix = Yii :: $ app -> request -> baseUrl ; $ host = Yii :: $ app -> request -> hostInfo ; if ( ! empty ( $ this -> _backendSubdomain ) && strpos ( $ host , $...
Return image path for web
18,134
public static function resizeAndSave ( $ dir , $ fileName , $ resizeWidth ) { $ DS = DIRECTORY_SEPARATOR ; $ fullPath = $ dir . $ DS . $ fileName ; if ( ! @ file_exists ( $ fullPath ) ) { return false ; } try { $ imageComponent = static :: getImageComponent ( ) ; $ image_r = $ imageComponent -> load ( $ fullPath ) ; if...
Make resized images
18,135
public static function getImageComponent ( ) { if ( is_object ( static :: $ _imageComponent ) ) { $ imageComponent = static :: $ _imageComponent ; } else { $ imageComponent = Yii :: createObject ( [ 'class' => 'yii\image\ImageDriver' , ] ) ; static :: $ _imageComponent = $ imageComponent ; } return $ imageComponent ; }
Get image component
18,136
public function getOriginalImagePath ( ) { $ savePath = Yii :: getAlias ( $ this -> _savePathAlias ) ; $ image = $ this -> _oldImage ; return static :: addPostfixToFile ( $ savePath . DIRECTORY_SEPARATOR . $ image , '_original' ) ; }
Return server path to original image src
18,137
public function cropImage ( $ x , $ y , $ width , $ height , $ rotate ) { $ DS = DIRECTORY_SEPARATOR ; $ savePath = Yii :: getAlias ( $ this -> _savePathAlias ) ; $ imageSrc = $ this -> owner -> { $ this -> _imageAttribute } ; $ fullImagePath = $ savePath . $ DS . $ imageSrc ; $ imageComponent = static :: getImageCompo...
Crop original image and resave resized images
18,138
public function startTimer ( $ timer , $ startTime = null ) { $ this -> timers [ $ timer ] = new Timer ( $ startTime ) ; return $ this ; }
Start a timer .
18,139
public function endTimer ( $ timer , $ endTime = null ) { $ this -> timers [ $ timer ] -> end ( $ endTime ) ; return $ this ; }
End a timer .
18,140
public function getIncludedFiles ( ) { if ( empty ( $ this -> includedFiles ) ) { $ files = get_included_files ( ) ; foreach ( $ files as $ filePath ) { $ size = $ this -> readableSize ( filesize ( $ filePath ) ) ; $ this -> includedFiles [ ] = compact ( 'filePath' , 'size' ) ; } } return $ this -> includedFiles ; }
Get all of the files that have been included .
18,141
protected function readableSize ( $ size , $ format = null ) { $ sizes = array ( 'bytes' , 'kB' , 'MB' , 'GB' , 'TB' , 'PB' , 'EB' , 'ZB' , 'YB' ) ; if ( is_null ( $ format ) ) { $ format = '%01.2f %s' ; } $ lastsizestring = end ( $ sizes ) ; foreach ( $ sizes as $ sizestring ) { if ( $ size < 1024 ) { break ; } if ( $...
A helper to convert a size into a readable format
18,142
public function getLogs ( $ level = null ) { if ( is_null ( $ level ) ) { return $ this -> logs ; } else { if ( isset ( $ this -> logs [ $ level ] ) ) { return $ this -> logs [ $ level ] ; } } return array ( ) ; }
Retrieve the logs for the matching level .
18,143
public function registerProfiler ( ) { $ sessionHash = static :: SESSION_HASH ; $ this -> app [ 'profiler' ] = $ this -> app -> share ( function ( $ app ) use ( $ sessionHash ) { $ startTime = null ; $ enabled = false ; if ( defined ( 'LARAVEL_START' ) ) { $ startTime = LARAVEL_START ; } if ( $ app [ 'session' ] -> has...
Register the profiler .
18,144
public function registerProfilerLoggerEvent ( ) { $ app = $ this -> app ; $ app [ 'events' ] -> listen ( 'illuminate.log' , function ( $ level , $ message , $ context ) use ( $ app ) { if ( $ app [ 'profiler' ] -> isEnabled ( ) ) { $ app [ 'profiler' ] -> log -> log ( $ level , $ message , $ context ) ; } } ) ; }
Register an event to automatically fetch Laravel s logs .
18,145
public function registerProfilerQueryEvent ( ) { $ app = $ this -> app ; $ app [ 'events' ] -> listen ( 'illuminate.query' , function ( $ query , $ bindings , $ time , $ connectionName ) use ( $ app ) { if ( $ app [ 'profiler' ] -> isEnabled ( ) ) { if ( ! empty ( $ bindings ) ) { $ connection = $ app [ 'db' ] -> conne...
Register an event to automatically log database queries .
18,146
public function registerProfilerRouting ( ) { $ provider = $ this ; $ this -> app -> booting ( function ( $ app ) use ( $ provider ) { $ app [ 'router' ] -> get ( '/_profiler/enable/{password?}' , function ( $ password = null ) use ( $ app , $ provider ) { $ config = $ app [ 'config' ] ; $ passwordRequired = in_array (...
Register routes to enable or disable the profiler .
18,147
public function registerProfilerToOutput ( ) { $ app = $ this -> app ; $ sessionHash = static :: SESSION_HASH ; $ app [ 'router' ] -> after ( function ( $ request , $ response ) use ( $ app , $ sessionHash ) { $ profiler = $ app [ 'profiler' ] ; $ session = $ app [ 'session' ] ; if ( $ session -> has ( $ sessionHash ) ...
Register an after filter to automatically display the profiler .
18,148
protected function applySimpleFilter ( Filter $ filter ) { $ value = ( array ) $ filter -> getValue ( ) ; if ( count ( $ value ) > 1 ) { $ this -> query -> whereIn ( $ filter -> getField ( ) , $ value ) ; } else { $ this -> query -> where ( $ filter -> getField ( ) , $ filter -> getOperator ( ) , $ value [ 0 ] ) ; } }
Apply simple filter .
18,149
protected function applySimpleSort ( Sort $ sort ) { $ this -> query -> orderBy ( $ sort -> getField ( ) , $ sort -> getOrder ( ) ) ; }
Apply simple sort .
18,150
public function registerClientScript ( ) { $ view = $ this -> getView ( ) ; DualListboxAsset :: register ( $ view ) ; $ id = ( array_key_exists ( 'id' , $ this -> options ) ) ? $ this -> options [ 'id' ] : Html :: getInputId ( $ this -> model , $ this -> attribute ) ; $ options = empty ( $ this -> clientOptions ) ? '' ...
Registers the required JavaScript .
18,151
protected function uploadChunk ( $ model ) { $ result = [ "code" => 0 , "message" => "Unknown error." ] ; $ sid = $ model -> id ; $ model_subfolder = $ model -> category_id . '/' . $ sid ; $ model_tmp_folder = public_path ( ) . '/assets/medias/tmp/' . $ model_subfolder ; $ model_folder = public_path ( ) . '/assets/medi...
Upload file chunk
18,152
protected function checkRequest ( $ name , $ default = 0 ) { if ( $ name == 'name' ) { return ( isset ( $ _REQUEST [ $ name ] ) ? ( $ _REQUEST [ $ name ] ) : $ default ) ; } else { return ( isset ( $ _REQUEST [ $ name ] ) ? intval ( $ _REQUEST [ $ name ] ) : $ default ) ; } }
Get value by request name or return default
18,153
protected function saveMedia ( $ model , $ filePath ) { $ file = new FileInfo ( $ filePath ) ; $ model -> path = $ file -> getFilename ( ) ; $ model -> mimetype = $ file -> getMimeType ( ) ; $ playtime = $ file -> getPlaytime ( ) ; $ options = json_decode ( $ model -> options ) ; if ( ! is_array ( $ options ) ) { $ opt...
Save Media info into database
18,154
protected function populatePermission ( $ permission_inherit , $ permission_allow , $ permission_deny ) { $ permissions = [ ] ; $ permissions = $ this -> retreivePermission ( $ permissions , $ permission_deny , - 1 ) ; $ permissions = $ this -> retreivePermission ( $ permissions , $ permission_allow , 1 ) ; $ permissio...
Returns an array of permissions based on given inherit allow and deny list
18,155
protected function retreivePermission ( $ permissions , $ check_permissions , $ level ) { $ sorted_permissions = explode ( ',' , $ check_permissions ) ; ksort ( $ sorted_permissions ) ; foreach ( $ sorted_permissions as $ item ) { $ item = trim ( $ item ) ; if ( ! array_key_exists ( $ item , $ permissions ) && ! empty ...
Appends to an array of permissions based on given permission list and level
18,156
public function showAttribute ( ) { $ present_attribute = $ this -> attribute ; $ to_be_replaced = array ( "_" , "." ) ; $ present_attribute = str_replace ( $ to_be_replaced , ' ' , $ present_attribute ) ; return ucwords ( $ present_attribute ) ; }
Present attribute in a User friendly string
18,157
protected function doOnce ( string $ queueName , Envelope $ envelope ) : array { $ result = false ; $ message = $ envelope -> unwrap ( ) ; $ this -> getLogger ( ) -> debug ( 'Handling message {msg}' , [ 'msg' => self :: nameOf ( $ message ) ] ) ; try { $ result = $ this -> handleMessage ( $ message ) ; } catch ( Except...
Do the actual work for processing a single message .
18,158
protected function failed ( string $ queueName , Envelope $ env ) : bool { $ retry = $ this -> retries -> canRetry ( $ env ) ; if ( $ retry ) { $ delay = $ this -> retries -> retryDelay ( $ env ) ; $ this -> getDriver ( ) -> retry ( $ queueName , $ env -> retry ( $ delay ) ) ; } else { $ this -> getDriver ( ) -> fail (...
Fail the message . This will retry it if possible .
18,159
public function thumb ( $ url , $ width , $ height = null ) { return $ this -> resize ( $ url , $ width , $ height , true ) ; }
Helper for creating thumbs
18,160
public function upload ( $ file , $ dir = null , $ createDimensions = false , $ autonumber = true ) { if ( $ file ) { if ( ! $ dir ) { $ dir = str_random ( 8 ) ; } $ destination = Config :: get ( 'redminportal::image.upload_path' ) . $ dir ; if ( $ autonumber ) { $ filename = $ this -> autoNumberFile ( $ destination , ...
Upload an image to the public storage
18,161
private function autoNumberFile ( $ path , $ file ) { $ extension = $ file -> getClientOriginalExtension ( ) ; $ original_name = $ file -> getClientOriginalName ( ) ; $ filename = $ original_name ; $ counter = 1 ; while ( file_exists ( $ path . '/' . $ filename ) ) { $ filename = str_replace ( "." . $ extension , '_' ....
Automatically appends number if file already exists
18,162
public function createDimensions ( $ url , $ dimensions = array ( ) ) { $ defaultDimensions = Config :: get ( 'redminportal::image.dimensions' ) ; if ( is_array ( $ defaultDimensions ) ) { $ dimensions = array_merge ( $ defaultDimensions , $ dimensions ) ; } foreach ( $ dimensions as $ dimension ) { $ width = ( int ) $...
Creates image dimensions based on a configuration
18,163
public function getUrl ( $ url , $ size = "thumb" , $ fullUrl = false ) { $ defaultDimensions = Config :: get ( 'redminportal::image.dimensions' ) ; $ upload_path = Config :: get ( 'redminportal::image.upload_path' ) ; $ dimension = $ defaultDimensions [ $ size ] ; $ width = ( int ) $ dimension [ 0 ] ; $ height = isset...
Get URL of specified size
18,164
private function checkRouteAccess ( $ route , $ permissions ) { $ permission_level = 0 ; if ( array_key_exists ( $ route , $ permissions ) ) { $ permission_level = $ permissions -> $ route ; if ( gettype ( $ permission_level ) == 'boolean' ) { $ permission_level = ( $ permission_level ? 1 : 0 ) ; } } return $ permissio...
Check this route for permission
18,165
public function getSorts ( ) { $ sortInput = $ this -> request -> input ( $ this -> sortName , '' ) ; $ sortFields = $ this -> collection -> make ( is_array ( $ sortInput ) ? $ sortInput : explode ( $ this -> sortFieldsSeparator , $ sortInput ) ) ; $ sorts = $ this -> collection -> make ( ) ; $ sortFields -> each ( fun...
Get parameters for sorting .
18,166
protected function htmlOptionsExtraButton ( ) { return array_merge ( [ 'type' => 'button' ] , ! empty ( $ this -> extraButtonOptions ) && is_array ( $ this -> extraButtonOptions ) ? $ this -> extraButtonOptions : [ ] ) ; }
Sets extra button HTML options .
18,167
protected function htmlOptionsGroup ( ) { $ class = ! empty ( $ this -> defaults [ 'groupClass' ] ) ? $ this -> defaults [ 'groupClass' ] : '' ; $ style = ! empty ( $ this -> defaults [ 'groupStyle' ] ) ? $ this -> defaults [ 'groupStyle' ] : '' ; if ( ! empty ( $ this -> bootstrapDefaults [ 'groupClass' ] ) ) { $ clas...
Sets div container for input text field and buttons with dropdown menu HTML options .
18,168
protected function htmlOptionsInput ( $ disabled = false ) { $ options = [ 'id' => false ] ; if ( ! empty ( $ this -> inputOptions ) && is_array ( $ this -> inputOptions ) ) { $ options = $ this -> inputOptions ; } if ( $ disabled ) { $ options [ 'disabled' ] = true ; } return $ this -> htmlOptionsSet ( 'input' , $ opt...
Sets input text field HTML options .
18,169
protected function htmlOptionsResult ( $ value = '' ) { $ class = ! empty ( $ this -> defaults [ 'resultClass' ] ) ? $ this -> defaults [ 'resultClass' ] . $ value : '' ; $ style = ! empty ( $ this -> defaults [ 'resultStyle' ] ) ? $ this -> defaults [ 'resultStyle' ] : '' ; if ( ! empty ( $ this -> bootstrapDefaults [...
Sets preselected value HTML options .
18,170
protected function htmlOptionsSet ( $ name , $ additional = [ ] , $ appendStyle = '' ) { $ class = ! empty ( $ this -> defaults [ $ name . 'Class' ] ) ? $ this -> defaults [ $ name . 'Class' ] : '' ; $ style = ! empty ( $ this -> defaults [ $ name . 'Style' ] ) ? $ this -> defaults [ $ name . 'Style' ] : '' ; if ( ! em...
Sets HTML options for chosen element .
18,171
protected function prepareOption ( $ name ) { if ( ! empty ( $ this -> $ name ) && is_string ( $ this -> $ name ) ) { return $ this -> $ name ; } return ! empty ( $ this -> bootstrapDefaults [ $ name ] ) ? $ this -> bootstrapDefaults [ $ name ] : '' ; }
Sets JS option for chosen element .
18,172
protected function prepareOptionDelay ( ) { $ value = 0 ; if ( is_numeric ( $ this -> delay ) && $ this -> delay > 0 ) { $ value = ( int ) $ this -> delay ; } return $ value ; }
Sets delay JS option .
18,173
protected function prepareOptionLocal ( ) { $ local = $ this -> defaultLocal ; foreach ( $ local as $ key => $ value ) { if ( ! empty ( $ this -> local [ $ key ] ) && is_string ( $ this -> local [ $ key ] ) ) { $ value = $ this -> local [ $ key ] ; } $ local [ $ key ] = Yii :: t ( $ this -> translateCategory , $ value ...
Sets translations JS option .
18,174
protected function prepareOptionProgressBar ( ) { if ( ! empty ( $ this -> progressBar ) && is_string ( $ this -> progressBar ) ) { return strtr ( $ this -> progressBar , [ '{LOADING}' => Yii :: t ( $ this -> translateCategory , 'Loading' ) ] ) ; } return ! empty ( $ this -> bootstrapDefaults [ 'progressBar' ] ) ? strt...
Sets progress bar JS option .
18,175
protected function prepareOptions ( $ name ) { return [ 'addc' => $ this -> additionalCode , 'dely' => $ this -> prepareOptionDelay ( ) , 'ercl' => $ this -> prepareOption ( 'errorClass' ) , 'erst' => $ this -> prepareOption ( 'errorStyle' ) , 'hecl' => $ this -> prepareOption ( 'headerClass' ) , 'hest' => $ this -> pr...
Sets JS options .
18,176
public function registerScript ( $ id , $ name ) { $ view = $ this -> getView ( ) ; AjaxDropdownAsset :: register ( $ view ) ; $ options = Json :: encode ( $ this -> prepareOptions ( $ name ) ) ; $ view -> registerJs ( "jQuery('#$id').ajaxDropDown($options);" ) ; }
Registers assets and calls JS plugin .
18,177
protected function resolveNameID ( ) { if ( $ this -> name !== null ) { $ name = $ this -> name ; $ id = $ this -> name ; } elseif ( $ this -> hasModel ( ) ) { $ name = Html :: getInputName ( $ this -> model , $ this -> attribute ) ; $ id = Html :: getInputId ( $ this -> model , $ this -> attribute ) ; } else { throw n...
Resolves name and ID .
18,178
protected function results ( ) { $ results = [ ] ; if ( is_array ( $ this -> data ) ) { if ( $ this -> singleMode ) { if ( $ this -> singleModeBottom ) { if ( isset ( $ this -> data [ 0 ] ) ) { return [ $ this -> singleResult ( $ this -> data [ 0 ] , $ this -> singleMode ) ] ; } } } else { foreach ( $ this -> data as $...
Renders the preselected data values .
18,179
protected function singleResult ( $ data = [ ] , $ singleMode = false ) { $ result = $ data ; if ( empty ( $ result [ 'id' ] ) ) { $ result [ 'id' ] = uniqid ( ) ; } if ( empty ( $ result [ 'mark' ] ) || ! in_array ( $ result [ 'mark' ] , [ 0 , 1 ] ) ) { $ result [ 'mark' ] = 0 ; } if ( empty ( $ result [ 'value' ] ) |...
Renders single preselected value result .
18,180
private function addModelToArray ( $ models , $ model ) { $ apply_to_models = array ( ) ; if ( count ( $ models ) > 0 ) { foreach ( $ models as $ item_json ) { $ item = json_decode ( $ item_json ) ; $ object = $ model -> find ( $ item -> id ) ; if ( $ object != null ) { for ( $ count = 1 ; $ count <= $ item -> quantity...
Add model to array content is JSON string
18,181
private function addModelToArraySimpleMode ( $ models , $ model ) { $ apply_to_models = array ( ) ; if ( count ( $ models ) > 0 ) { foreach ( $ models as $ item ) { $ object = $ model -> find ( $ item ) ; if ( $ object != null ) { $ apply_to_models [ ] = $ object ; } } } return $ apply_to_models ; }
Add model to array simple mode content is NOT JSON string
18,182
private function addCouponToOrder ( $ coupons , $ new_order ) { $ errors = new \ Illuminate \ Support \ MessageBag ; if ( count ( $ coupons ) > 0 ) { foreach ( $ coupons as $ item ) { $ model = Coupon :: find ( $ item ) ; if ( $ model != null ) { try { $ new_order -> addCoupon ( $ model ) ; } catch ( Exception $ exp ) ...
Add coupons to order
18,183
private function validateStoreInputs ( $ inputs ) { $ rules = array ( 'selected_products' => 'required_without_all:selected_bundles,pricelist_id' , 'selected_bundles' => 'required_without_all:selected_products,pricelist_id' , 'pricelist_id' => 'required_without_all:selected_products,selected_bundles' , 'transaction_id'...
Validates inputs before storing data
18,184
public function up ( ) { if ( Schema :: hasTable ( 'products' ) ) { DB :: statement ( 'ALTER TABLE products ENGINE = InnoDB' ) ; } if ( Schema :: hasTable ( 'categories' ) ) { DB :: statement ( 'ALTER TABLE categories ENGINE = InnoDB' ) ; } if ( Schema :: hasTable ( 'pricelists' ) ) { DB :: statement ( 'ALTER TABLE pri...
Run the migrations . Upgrade tables with foreign keys to InnoDB type
18,185
public function getDelete ( $ sid ) { $ image = Image :: find ( $ sid ) ; if ( $ image == null ) { $ errors = new MessageBag ; $ errors -> add ( 'deleteError' , trans ( 'redminportal::messages.error_delete_image' ) ) ; return redirect ( ) -> back ( ) -> withErrors ( $ errors ) ; } $ image -> delete ( ) ; return redirec...
Delete Image by ID
18,186
public function getPlaytime ( ) { if ( file_exists ( $ this ) ) { $ ThisFileInfo = $ this -> getID3Info -> analyze ( $ this ) ; $ len = @ $ ThisFileInfo [ 'playtime_string' ] ; if ( $ len != null ) { return $ len ; } } return null ; }
Returns the playtime of the media .
18,187
public function create ( $ providerServiceKey ) { try { $ provider = $ this -> container -> get ( $ providerServiceKey ) ; } catch ( ServiceNotFoundException $ e ) { throw new \ InvalidArgumentException ( sprintf ( 'Provider "%s" should be defined as a service.' , $ providerServiceKey ) , $ e -> getCode ( ) , $ e ) ; }...
Get subscriber provider
18,188
public function synchronize ( SubscriberListInterface $ list ) { $ listData = $ this -> listRepository -> findById ( $ list -> getListId ( ) ) ; $ subscribers = $ list -> getProvider ( ) -> getSubscribers ( ) ; $ this -> unsubscribeDifference ( $ list -> getListId ( ) , $ subscribers ) ; return $ this -> batchSubscribe...
Synchronise user from provider with MailChimp List
18,189
protected function unsubscribeDifference ( $ listId , array $ subscribers ) { $ mailchimpEmails = $ this -> listRepository -> getSubscriberEmails ( $ listId ) ; $ internalEmails = array_map ( function ( Subscriber $ subscriber ) { return $ subscriber -> getEmail ( ) ; } , $ subscribers ) ; $ diffenceEmails = array_diff...
Unsubscribe the difference between the array subscriber an user
18,190
protected function tagExists ( $ tagName , array $ tags ) { foreach ( $ tags as $ tag ) { if ( $ tag [ 'tag' ] == $ tagName ) { if ( array_key_exists ( 'merge_id' , $ tag ) ) { return $ tag [ 'merge_id' ] ; } return true ; } } return false ; }
Test if the merge field Tag exists in an array
18,191
private function parseData ( $ obj ) { $ data = [ 'temperature' => [ 'now' => [ 'value' => $ obj -> temperature -> now -> getValue ( ) , 'unit' => $ obj -> temperature -> now -> getUnit ( ) ] , 'min' => [ 'value' => $ obj -> temperature -> min -> getValue ( ) , 'unit' => $ obj -> temperature -> min -> getUnit ( ) ] , '...
Helper function to parse data .
18,192
public function onSubscribe ( SubscriberEvent $ event ) { $ this -> listRepository -> subscribe ( $ event -> getListId ( ) , $ event -> getSubscriber ( ) ) ; }
Action when a User subscribe
18,193
public function onUnsubscribe ( SubscriberEvent $ event ) { $ this -> listRepository -> unsubscribe ( $ event -> getListId ( ) , $ event -> getSubscriber ( ) ) ; }
Action when a User unsubscribe
18,194
public function onPending ( SubscriberEvent $ event ) { $ this -> listRepository -> pending ( $ event -> getListId ( ) , $ event -> getSubscriber ( ) ) ; }
Action when a User is pending
18,195
public function onClean ( SubscriberEvent $ event ) { $ this -> listRepository -> clean ( $ event -> getListId ( ) , $ event -> getSubscriber ( ) ) ; }
Action when a User is cleaned
18,196
public function onUpdate ( SubscriberEvent $ event ) { $ this -> listRepository -> update ( $ event -> getListId ( ) , $ event -> getSubscriber ( ) ) ; }
Action when a User update its info
18,197
public function onChangeEmail ( SubscriberEvent $ event ) { $ this -> listRepository -> changeEmailAddress ( $ event -> getListId ( ) , $ event -> getSubscriber ( ) , $ event -> getOldEmail ( ) ) ; }
Action when a User change its email address
18,198
public function onDelete ( SubscriberEvent $ event ) { $ this -> listRepository -> delete ( $ event -> getListId ( ) , $ event -> getSubscriber ( ) ) ; }
Action when a User is deleted
18,199
public function findById ( $ listId ) { $ listData = $ this -> mailchimp -> get ( "lists/$listId" ) ; if ( ! $ this -> mailchimp -> success ( ) ) { $ this -> throwMailchimpError ( $ this -> mailchimp -> getLastResponse ( ) ) ; } return $ listData ; }
Find MailChimp List by list Id