idx
int64
0
60.3k
question
stringlengths
101
6.21k
target
stringlengths
7
803
50,600
private function setupLeftToAct ( ) { if ( $ this -> players ( ) -> count ( ) === 2 ) { $ this -> leftToAct = $ this -> leftToAct ( ) -> setup ( $ this -> players ( ) ) ; return ; } $ this -> leftToAct = $ this -> leftToAct -> setup ( $ this -> players ( ) ) -> resetPlayerListFromSeat ( $ this -> table ( ) -> button ( ) + 1 ) ; }
Reset the leftToAct collection .
50,601
public function moveButton ( ) { $ this -> button = $ this -> button + 1 ; if ( $ this -> button >= $ this -> playersSatDown ( ) -> count ( ) ) { $ this -> button = 0 ; } }
Moves the button along the table seats .
50,602
public function process ( $ value ) { if ( $ this -> isMandatory ( ) && ! $ value ) { throw new Exception ( $ this -> getMessage ( self :: IS_MISSING , [ 'param' , $ this -> reference ] ) ) ; } $ dataProcessor = $ this -> getDataProcessor ( ) ; if ( $ dataProcessor instanceof ApplicationAwareInterface ) { $ dataProcessor -> setApplication ( $ this -> getApplication ( ) ) ; } $ processedValue = $ dataProcessor -> process ( $ value ) ; if ( $ this -> isMandatory ( ) && is_null ( $ processedValue ) ) { throw new Exception ( $ this -> getMessage ( self :: IS_MISSING , [ 'param' , $ this -> reference ] ) ) ; } return $ processedValue ; }
Process a value
50,603
public function init ( ) { $ this -> path = $ this -> config ( 'path' ) ; $ this -> baseURL = $ this -> config ( 'baseURL' ) ; $ this -> errorsHandle ( ) ; $ this -> autoloads ( ) ; }
Application Initialization method
50,604
public function dbConnection ( array $ configs = null , $ name = 'default' , $ enableQueryLog = true ) { $ db = new DB ( ) ; $ db -> addConnection ( ( $ configs ) ? $ configs : $ this -> config ( 'db' ) , $ name ) ; $ db -> setEventDispatcher ( new Dispatcher ( new Container ) ) ; $ db -> setAsGlobal ( ) ; $ db -> bootEloquent ( ) ; if ( $ enableQueryLog ) { DB :: connection ( ) -> enableQueryLog ( ) ; } $ this -> db = $ db ; return $ db ; }
Configure the database and boot Eloquent
50,605
public function autoRoute ( $ stop = false ) { if ( $ stop ) { return $ this ; } $ app = self :: getInstance ( ) ; $ app -> get ( '(/)' , 'IndexController:index' ) ; $ app -> get ( '/:action' , function ( $ action = 'index' ) use ( $ app ) { if ( ! class_exists ( 'IndexController' ) ) { $ app -> notFound ( ) ; return ; } $ this -> controllerName = 'index' ; $ this -> actionName = $ action ; $ controller = new \ IndexController ; if ( ! method_exists ( $ controller , $ action ) ) { $ app -> notFound ( ) ; return ; } $ controller -> $ action ( ) ; } ) ; $ app -> get ( '/:controller/:action' , function ( $ controller = 'index' , $ action = 'index' ) use ( $ app ) { $ this -> controllerName = $ controller ; $ this -> actionName = $ action ; $ controller = ucwords ( $ controller ) . 'Controller' ; if ( ! class_exists ( $ controller ) ) { $ app -> notFound ( ) ; return ; } $ controller = new $ controller ( ) ; if ( ! method_exists ( $ controller , $ action ) ) { $ app -> notFound ( ) ; return ; } $ controller -> $ action ( ) ; } ) ; $ app -> get ( '/:module/:controller/:action' , function ( $ module , $ controller = 'index' , $ action = 'index' ) use ( $ app ) { $ this -> moduleName = $ module ; $ this -> controllerName = $ controller ; $ this -> actionName = $ action ; $ controller = ucwords ( $ module ) . '\Controllers\\' . ucwords ( $ controller ) . 'Controller' ; if ( ! class_exists ( $ controller ) ) { $ app -> notFound ( ) ; return ; } $ controller = new $ controller ( ) ; if ( ! method_exists ( $ controller , $ action ) ) { $ app -> notFound ( ) ; return ; } $ controller -> $ action ( ) ; } ) ; }
Auto router method
50,606
protected function __autoload ( $ className ) { foreach ( $ this -> config ( 'defaultAutoloads' ) as $ key => $ dir ) { $ fileName = $ dir . DIRECTORY_SEPARATOR . $ className . '.php' ; $ fileName = str_replace ( '\\' , DIRECTORY_SEPARATOR , $ fileName ) ; if ( file_exists ( $ fileName ) && ! class_exists ( $ className ) ) { $ this -> loadFiles [ $ className ] = $ fileName ; require $ fileName ; } } $ modules = array_merge ( [ ] , $ this -> config ( 'modules' ) ) ; foreach ( $ modules as $ key => $ module ) { $ module = ( $ module == '' ) ? $ module : $ module . DIRECTORY_SEPARATOR ; foreach ( $ this -> config ( 'mvcDirs' ) as $ k => $ mvc ) { $ phpFile = explode ( "\\" , $ className ) ; $ phpFile = $ phpFile [ count ( $ phpFile ) - 1 ] ; $ fileName = $ this -> path . str_replace ( '\\' , DIRECTORY_SEPARATOR , strtolower ( str_replace ( $ phpFile , '' , $ className ) ) ) . $ phpFile . '.php' ; if ( file_exists ( $ fileName ) && ! class_exists ( $ className ) ) { $ this -> loadFiles [ $ className ] = $ fileName ; require $ fileName ; } } } foreach ( $ this -> config ( 'autoloads' ) as $ key => $ dir ) { $ fileName = realpath ( $ dir ) . DIRECTORY_SEPARATOR . $ className . '.php' ; $ fileName = str_replace ( '\\' , DIRECTORY_SEPARATOR , $ fileName ) ; if ( file_exists ( $ fileName ) && ! class_exists ( $ className ) ) { $ this -> loadFiles [ $ className ] = $ fileName ; require $ fileName ; } } }
Autoload callable method
50,607
public function timeStart ( ) { $ now = explode ( " " , microtime ( ) ) ; $ this -> startTime = $ now [ 1 ] + $ now [ 0 ] ; return $ this -> startTime ; }
Run time start
50,608
public function timeEnd ( $ decimal = 6 ) { $ now = explode ( " " , microtime ( ) ) ; $ end = $ now [ 1 ] + $ now [ 0 ] ; $ total = ( $ end - $ this -> startTime ) ; return number_format ( $ total , $ decimal ) ; }
Run end time
50,609
public function setCompileFile ( $ filename ) { $ filename = ( ( $ this -> compileFileNameMd5 ) ? md5 ( md5 ( $ filename ) ) : $ filename ) ; $ this -> templateCompileFile = $ this -> compilePath . $ filename . $ this -> compileFileSuffix ; }
Set template compile file path
50,610
public static function mkdir ( $ dir ) { if ( file_exists ( $ dir ) ) { return $ dir ; } mkdir ( $ dir , 0777 , true ) ; chmod ( $ dir , 0777 ) ; return $ dir ; }
Create template compile directory
50,611
public static function includeFile ( $ file ) { $ data = static :: $ properties [ 'data' ] ; $ templatePath = static :: $ properties [ 'templatePath' ] ; $ compilePath = static :: $ properties [ 'compilePath' ] ; $ compileCached = static :: $ properties [ 'compileCached' ] ; $ compileFileNameMd5 = static :: $ properties [ 'compileFileNameMd5' ] ; $ compileFileSuffix = static :: $ properties [ 'compileFileSuffix' ] ; $ templateFile = $ templatePath . $ file ; if ( ! file_exists ( $ templateFile ) ) { throw new \ InvalidArgumentException ( 'included template file ' . $ file . ' not found.' ) ; } $ pathInfo = pathinfo ( $ file ) ; $ filename = $ pathInfo [ 'filename' ] ; if ( ! $ compileFileNameMd5 && ! file_exists ( $ compilePath . $ pathInfo [ 'dirname' ] ) ) { static :: mkdir ( $ compilePath . $ pathInfo [ 'dirname' ] ) ; } $ filenameMd5 = ( ( $ compileFileNameMd5 ) ? md5 ( md5 ( $ filename ) ) : $ pathInfo [ 'dirname' ] . DIRECTORY_SEPARATOR . $ filename ) ; $ compileFile = $ compilePath . $ filenameMd5 . $ compileFileSuffix ; if ( $ compileCached ) { if ( ! file_exists ( $ compileFile ) || ( filemtime ( $ templateFile ) > filemtime ( $ compileFile ) ) ) { $ tpl = file_get_contents ( $ templateFile ) ; $ tpl = static :: parser ( $ tpl ) ; file_put_contents ( $ compileFile , $ tpl ) ; } } else { $ tpl = file_get_contents ( $ templateFile ) ; $ tpl = static :: parser ( $ tpl ) ; file_put_contents ( $ compileFile , $ tpl ) ; } return $ compileFile ; }
Parse & require included template file
50,612
public function view ( UserPolicy $ user , Gallery $ gallery ) { if ( $ user -> canDo ( 'gallery.gallery.view' ) && $ user -> isAdmin ( ) ) { return true ; } return $ gallery -> user_id == user_id ( ) && $ gallery -> user_type == user_type ( ) ; }
Determine if the given user can view the gallery .
50,613
public function destroy ( UserPolicy $ user , Gallery $ gallery ) { return $ gallery -> user_id == user_id ( ) && $ gallery -> user_type == user_type ( ) ; }
Determine if the given user can delete the given gallery .
50,614
public static function isNotPubliclyRoutable ( UriInterface $ url ) : bool { $ host = $ url -> getHost ( ) ; if ( '' === $ host ) { return true ; } $ hostObject = new Host ( $ host ) ; if ( ! $ hostObject -> isPubliclyRoutable ( ) ) { return true ; } $ hostContainsDots = substr_count ( $ host , '.' ) ; if ( ! $ hostContainsDots ) { return true ; } if ( '.' === $ host [ 0 ] || '.' === $ host [ - 1 ] ) { return true ; } return false ; }
Can a URL fail to be accessed over the public internet?
50,615
public function getImageInfo ( $ image ) { if ( empty ( $ image ) || ! file_exists ( $ image ) ) { throw new \ InvalidArgumentException ( 'Image file not found.' ) ; } $ pathInfo = pathinfo ( $ image ) ; $ info = getimagesize ( $ image ) ; if ( ! in_array ( $ pathInfo [ 'extension' ] , $ this -> types ) ) { throw new \ InvalidArgumentException ( 'Unsupported image file extension.' ) ; } $ info [ 'width' ] = $ info [ 0 ] ; $ info [ 'height' ] = $ info [ 1 ] ; $ info [ 'ext' ] = $ info [ 'type' ] = $ pathInfo [ 'extension' ] ; $ info [ 'size' ] = filesize ( $ image ) ; $ info [ 'dir' ] = $ pathInfo [ 'dirname' ] ; $ info [ 'path' ] = str_replace ( '/' , DIRECTORY_SEPARATOR , $ image ) ; $ info [ 'fullname' ] = $ pathInfo [ 'basename' ] ; $ info [ 'filename' ] = $ pathInfo [ 'filename' ] ; $ info [ 'type' ] = ( $ info [ 'type' ] == 'jpg' ) ? 'jpeg' : $ info [ 'type' ] ; return $ info ; }
Get image info array
50,616
public function source ( $ src ) { $ this -> source = $ this -> getImageInfo ( $ src ) ; $ type = $ this -> source [ 'type' ] ; $ createFrom = 'ImageCreateFrom' . $ type ; $ this -> sourceImage = $ createFrom ( $ src ) ; return $ this ; }
Set local image source
50,617
public function create ( $ width , $ height , $ type = null ) { if ( ! is_numeric ( $ width ) ) { throw new \ InvalidArgumentException ( 'Image create failed, width must be numeric' ) ; } if ( ! is_numeric ( $ height ) ) { throw new \ InvalidArgumentException ( 'Image create failed, height must be numeric' ) ; } $ type = $ this -> getType ( $ type ) ; if ( $ type !== 'gif' && function_exists ( 'imagecreatetruecolor' ) ) { $ newImage = imagecreatetruecolor ( $ width , $ height ) ; } else { $ newImage = imagecreate ( $ width , $ height ) ; } imagealphablending ( $ newImage , true ) ; $ transparent = imagecolorallocatealpha ( $ newImage , 255 , 255 , 255 , 0 ) ; imagefilledrectangle ( $ newImage , 0 , 0 , imagesx ( $ newImage ) , imagesy ( $ newImage ) , $ transparent ) ; imagefill ( $ newImage , 0 , 0 , $ transparent ) ; imagesavealpha ( $ newImage , true ) ; $ this -> newImage = $ newImage ; return $ this ; }
Create new canvas image
50,618
public function createFrom ( $ image ) { $ type = pathinfo ( $ image , PATHINFO_EXTENSION ) ; $ type = ( $ type === 'jpg' ) ? 'jpeg' : $ type ; $ createFrom = 'ImageCreateFrom' . $ type ; return $ createFrom ( $ image ) ; }
Create image from type
50,619
public function crop ( $ width , $ height , $ mode = 'tl' ) { if ( ! is_numeric ( $ width ) ) { throw new \ InvalidArgumentException ( '$width must be numeric' ) ; } if ( ! is_numeric ( $ height ) ) { throw new \ InvalidArgumentException ( '$height must be numeric' ) ; } if ( $ this -> newImage ) { $ this -> sourceImage = $ this -> newImage ; } $ oldWidth = ( $ this -> newImage ) ? imagesx ( $ this -> newImage ) : $ this -> source [ 'width' ] ; $ oldHeight = ( $ this -> newImage ) ? imagesy ( $ this -> newImage ) : $ this -> source [ 'height' ] ; $ this -> create ( $ width , $ height ) ; $ startX = $ startY = 0 ; $ cropWidth = $ sourceWidth = $ width ; $ cropHeight = $ sourceHeight = $ height ; if ( is_array ( $ mode ) ) { $ startX = $ mode [ 0 ] ; $ startY = $ mode [ 1 ] ; } if ( $ mode === self :: CROP_TOP_CENTER ) { $ startX = ( $ oldWidth - $ cropWidth ) / 2 ; } else if ( $ mode === self :: CROP_TOP_RIGHT ) { $ startX = $ oldWidth - $ cropWidth ; } else if ( $ mode === self :: CROP_CENTER_LEFT ) { $ startY = ( $ oldHeight - $ cropHeight ) / 2 ; } else if ( $ mode === self :: CROP_CENTER_CENTER ) { $ startX = ( $ oldWidth - $ cropWidth ) / 2 ; $ startY = ( $ oldHeight - $ cropHeight ) / 2 ; } else if ( $ mode === self :: CROP_CENTER_RIGHT ) { $ startX = $ oldWidth - $ cropWidth ; $ startY = ( $ oldHeight - $ cropHeight ) / 2 ; } else if ( $ mode === self :: CROP_BOTTOM_LEFT ) { $ startY = $ oldHeight - $ cropHeight ; } else if ( $ mode === self :: CROP_BOTTOM_CENTER ) { $ startX = ( $ oldWidth - $ cropWidth ) / 2 ; $ startY = $ oldHeight - $ cropHeight ; } else if ( $ mode === self :: CROP_BOTTOM_RIGHT ) { $ startX = $ oldWidth - $ cropWidth ; $ startY = $ oldHeight - $ cropHeight ; } else { } imagecopyresampled ( $ this -> newImage , $ this -> sourceImage , 0 , 0 , $ startX , $ startY , $ cropWidth , $ cropHeight , $ sourceWidth , $ sourceHeight ) ; return $ this ; }
Crop image file
50,620
public function resizePercent ( $ percent = 50 ) { if ( $ percent < 1 ) { throw new \ InvalidArgumentException ( 'percent must be >= 1' ) ; } $ this -> resize ( $ this -> source [ 'width' ] * ( $ percent / 100 ) , $ this -> source [ 'height' ] * ( $ percent / 100 ) ) ; return $ this ; }
Image resize by percent
50,621
public function watermarkText ( $ text , $ pos = 0 , $ fontSize = 14 , array $ color = null , $ font = null , $ shadow = true ) { if ( ! $ color ) { $ color = [ 255 , 255 , 255 , 0 , 0 , 0 ] ; } $ font = ( ! $ font ) ? $ this -> fontFile : $ font ; if ( ! $ this -> newImage || ! is_resource ( $ this -> newImage ) ) { $ this -> newImage = $ this -> sourceImage ; $ sourceWidth = $ this -> source [ 'width' ] ; $ sourceHeight = $ this -> source [ 'height' ] ; } else { $ sourceWidth = imagesx ( $ this -> newImage ) ; $ sourceHeight = imagesy ( $ this -> newImage ) ; } $ textImage = imagecreatetruecolor ( $ sourceWidth , $ sourceHeight ) ; $ textColor = imagecolorallocate ( $ textImage , $ color [ 0 ] , $ color [ 1 ] , $ color [ 2 ] ) ; $ shadowColor = imagecolorallocate ( $ textImage , $ color [ 3 ] , $ color [ 4 ] , $ color [ 5 ] ) ; $ size = imagettfbbox ( $ fontSize , 0 , $ font , $ text ) ; $ textWidth = $ size [ 4 ] ; $ textHeight = abs ( $ size [ 7 ] ) ; $ position = $ this -> position ( $ pos , $ sourceWidth , $ sourceHeight , $ textWidth + 4 , $ textHeight , true , $ fontSize ) ; $ posX = $ position [ 'x' ] ; $ posY = $ position [ 'y' ] ; imagealphablending ( $ textImage , true ) ; imagesavealpha ( $ textImage , true ) ; imagecopymerge ( $ textImage , $ this -> newImage , 0 , 0 , 0 , 0 , $ sourceWidth , $ sourceHeight , 100 ) ; if ( $ shadow ) { imagettftext ( $ textImage , $ fontSize , 0 , $ posX + 1 , $ posY + 1 , $ shadowColor , $ font , $ text ) ; } imagettftext ( $ textImage , $ fontSize , 0 , $ posX , $ posY , $ textColor , $ font , $ text ) ; $ this -> newImage = $ textImage ; return $ this ; }
Text watermark for image
50,622
public function display ( $ type = 'jpeg' ) { $ type = $ this -> getType ( $ type ) ; header ( 'Content-Type: image/' . $ type ) ; if ( $ type === 'jpeg' ) { imageinterlace ( $ this -> newImage , true ) ; } $ imageFunc = 'image' . $ type ; $ imageFunc ( $ this -> newImage ) ; $ this -> destroyAll ( ) ; return $ this ; }
Display on browser
50,623
public function save ( $ saveName , $ quality = 80 ) { $ type = $ this -> getType ( pathinfo ( $ saveName , PATHINFO_EXTENSION ) ) ; $ imageFunc = 'image' . $ type ; $ errorMessage = 'Image saved is failed! Check the directory is can write?' ; if ( $ type === 'jpeg' ) { imageinterlace ( $ this -> newImage , true ) ; if ( ! $ imageFunc ( $ this -> newImage , $ saveName , $ quality ) ) { throw new \ ErrorException ( $ errorMessage ) ; } } else { if ( ! $ imageFunc ( $ this -> newImage , $ saveName ) ) { throw new \ ErrorException ( $ errorMessage ) ; } } $ this -> destroyAll ( ) ; return $ this ; }
Saved image file
50,624
public function dataUrl ( $ type = 'jpeg' ) { $ type = $ this -> getType ( $ type ) ; $ imageFunc = 'image' . $ type ; ob_start ( ) ; $ imageFunc ( $ this -> newImage ) ; $ data = ob_get_contents ( ) ; ob_end_clean ( ) ; $ this -> destroyAll ( ) ; $ dataUrl = 'data:image/' . $ type . ';base64,' . base64_encode ( $ data ) ; return $ dataUrl ; }
Image to data url base64
50,625
public function destroyAll ( ) { if ( $ this -> newImage ) { $ this -> destroy ( $ this -> newImage ) ; } if ( $ this -> sourceImage ) { $ this -> destroy ( $ this -> sourceImage ) ; } }
Destroy all image resource
50,626
public static function Compactar ( $ b , $ bolean ) { if ( $ bolean == false ) { return $ b ; } ob_start ( "compactar" ) ; $ b = preg_replace ( '!/\*[^*]*\*+([^/][^*]*\*+)*/!' , '' , $ b ) ; $ b = str_replace ( array ( "\r\n" , "\r" , "\n" , "\t" , ' ' , ' ' , ' ' ) , '' , $ b ) ; return $ b ; }
compacta codigo HTML
50,627
public static function dttm2br ( $ var , $ separador = "/" ) { if ( preg_match ( '/([0-9]{4})\-([0-9]{2})\-([012][0-9]|3[01])[ ]([0-9]{2}):([0-9]{2}):([0-9]{2})/' , $ var , $ array ) ) { $ dt = self :: checkDtbr ( $ array [ 3 ] , $ array [ 2 ] , $ array [ 1 ] , $ separador ) ; if ( $ dt && ( $ array [ 4 ] != '00' || $ array [ 5 ] != '00' ) ) $ dt .= ' ' . $ array [ 4 ] . ':' . $ array [ 5 ] ; return $ dt ; } }
transforma datetime do servidor US para data e hora BR
50,628
public function getImageType ( ) { $ this -> imageType = ( $ this -> imageType === 'jpg' ) ? 'jpeg' : $ this -> imageType ; $ this -> imageType = ( in_array ( $ this -> imageType , $ this -> imageTypes ) ) ? $ this -> imageType : 'png' ; return $ this -> imageType ; }
Get image type
50,629
public function create ( $ width = null , $ height = null ) { $ this -> width = ( $ width ) ? $ width : $ this -> width ; $ this -> height = ( $ height ) ? $ height : $ this -> height ; $ imageType = $ this -> getImageType ( ) ; $ createFunc = ( $ imageType === 'gif' ) ? 'imagecreate' : 'imagecreatetruecolor' ; $ this -> image = $ createFunc ( $ this -> width , $ this -> height ) ; $ bgColor = $ this -> backgroundColor ; $ backgroundColor = imagecolorallocate ( $ this -> image , $ bgColor [ 0 ] , $ bgColor [ 1 ] , $ bgColor [ 2 ] ) ; imagefilledrectangle ( $ this -> image , 0 , 0 , $ this -> width , $ this -> height , $ backgroundColor ) ; $ this -> drawText ( ) ; if ( $ this -> drawBorder ) { $ this -> drawBorder ( ) ; } if ( $ this -> drawLine ) { $ this -> drawLine ( ) ; } if ( $ this -> drawPixel ) { $ this -> drawPixel ( ) ; } return $ this ; }
Captcha image creator
50,630
protected function randomLetters ( ) { for ( $ i = 0 ; $ i < $ this -> length ; $ i ++ ) { $ letters = $ this -> letters [ mt_rand ( 0 , count ( $ this -> letters ) - 1 ) ] ; $ this -> code .= $ letters [ mt_rand ( 0 , strlen ( $ letters ) - 1 ) ] ; } }
Random generation English & Numbers letters
50,631
protected function randomChinese ( ) { if ( function_exists ( 'mb_substr' ) ) { $ len = mb_strlen ( $ this -> chineseCharacters , 'utf-8' ) ; for ( $ i = 0 ; $ i < $ this -> length ; $ i ++ ) { $ this -> code .= mb_substr ( $ this -> chineseCharacters , mt_rand ( 0 , $ len - 1 ) , 1 , 'utf-8' ) ; } } }
Random generation chinese characters
50,632
protected function randomMixed ( ) { $ characters = implode ( '' , $ this -> letters ) . $ this -> chineseCharacters ; if ( function_exists ( 'mb_substr' ) ) { $ len = mb_strlen ( $ characters , 'utf-8' ) ; for ( $ i = 0 ; $ i < $ this -> length ; $ i ++ ) { $ this -> code .= mb_substr ( $ characters , mt_rand ( 0 , $ len - 1 ) , 1 , 'utf-8' ) ; } } }
Random generation mixed characters
50,633
protected function drawText ( ) { switch ( $ this -> randomType ) { case 0 : $ this -> randomNumbers ( ) ; break ; case 1 : $ this -> randomPureLetters ( ) ; break ; case 3 : $ this -> randomChinese ( ) ; break ; case 4 : $ this -> randomMixed ( ) ; break ; case 2 : default : $ this -> randomLetters ( ) ; break ; } if ( ! $ this -> fontFile ) { $ this -> fontFile = __DIR__ . '../../Fonts/verdana.ttf' ; } if ( ! file_exists ( $ this -> fontFile ) ) { throw new \ InvalidArgumentException ( 'Font file ' . $ this -> fontFile . ' not found.' ) ; } $ textColor = imagecolorallocate ( $ this -> image , mt_rand ( 0 , 255 ) , mt_rand ( 0 , 255 ) , mt_rand ( 0 , 255 ) ) ; $ x = ( $ this -> width - ( $ this -> fontSize * $ this -> length ) ) / 2 ; $ y = $ this -> fontSize + ( $ this -> height - $ this -> fontSize ) / 2 ; $ fontFile = ( is_array ( $ this -> fontFile ) ) ? $ this -> fontFile [ array_rand ( $ this -> fontFile ) ] : $ this -> fontFile ; imagettftext ( $ this -> image , $ this -> fontSize , mt_rand ( - 8 , 8 ) , $ x , $ y , $ textColor , $ fontFile , $ this -> code ) ; }
Draw text characters to image
50,634
protected function drawPixel ( ) { $ pixelColor = imagecolorallocate ( $ this -> image , mt_rand ( 0 , 255 ) , mt_rand ( 100 , 255 ) , mt_rand ( 50 , 255 ) ) ; for ( $ i = 0 ; $ i < mt_rand ( 1000 , 1800 ) ; $ i ++ ) { imagesetpixel ( $ this -> image , mt_rand ( ) % $ this -> width , mt_rand ( ) % $ this -> height , $ pixelColor ) ; } }
Draw pixel points
50,635
public function display ( ) { $ imageType = $ this -> getImageType ( ) ; header ( 'Content-type: image/' . $ imageType ) ; $ imageFunc = 'image' . $ imageType ; $ imageFunc ( $ this -> image ) ; $ this -> destroy ( $ this -> image ) ; return $ this ; }
Display captcha image in page
50,636
public function save ( $ filename ) { $ type = pathinfo ( $ filename , PATHINFO_EXTENSION ) ; $ type = ( $ type === 'jpg' ) ? 'jpeg' : $ type ; $ type = ( in_array ( $ type , $ this -> imageTypes ) ) ? $ type : 'png' ; header ( 'Content-type: image/' . $ type ) ; $ imageFunc = 'image' . $ type ; $ imageFunc ( $ this -> image , $ filename ) ; $ this -> destroy ( $ this -> image ) ; return $ this ; }
Save captcha image file
50,637
public function gotoURL ( $ url , $ base = true ) { if ( $ base ) { $ url = $ this -> app -> baseURL . $ url ; } $ this -> js ( 'location.href="' . $ url . '";' ) ; }
Using javascript location . href go to url
50,638
protected function getFilePath ( ) { $ path = $ this -> cachePath . DIRECTORY_SEPARATOR . $ this -> cacheDirectory . DIRECTORY_SEPARATOR ; $ path = str_replace ( [ '\\\\' , '//' ] , [ DIRECTORY_SEPARATOR , DIRECTORY_SEPARATOR ] , $ path ) ; return $ path ; }
Get cache file path
50,639
protected function getFileName ( $ key ) { $ file = $ this -> getFilePath ( ) . $ this -> encrypt ( $ key ) . $ this -> fileExtension ; return $ file ; }
Get cache filename
50,640
public function set ( $ key , $ value , $ expireTime = null ) { if ( $ expireTime && ! is_int ( $ expireTime ) ) { throw new \ InvalidArgumentException ( 'cache expire time must be integer.' ) ; } $ this -> expireTime = ( $ expireTime ) ? $ expireTime : $ this -> expireTime ; return $ this -> write ( $ key , $ value ) ; }
Set cache key and write to cache file
50,641
protected function read ( $ file ) { $ data = null ; $ key = $ file ; $ file = $ this -> getFileName ( $ file ) ; if ( file_exists ( $ file ) ) { if ( filemtime ( $ file ) >= time ( ) ) { echo "read cache<br/>" ; $ data = file_get_contents ( $ file ) ; $ data = ( $ this -> base64Encode ) ? base64_decode ( $ data ) : $ data ; $ data = unserialize ( $ data ) ; static :: $ keys [ $ key ] = true ; } else { unset ( static :: $ keys [ $ key ] ) ; unlink ( $ file ) ; } } return $ data ; }
Read cache file
50,642
public function has ( $ key ) { $ file = $ this -> getFileName ( $ key ) ; if ( ! file_exists ( $ file ) ) { return false ; } if ( filemtime ( $ file ) >= time ( ) ) { static :: $ keys [ $ key ] = true ; return true ; } else { unset ( static :: $ keys [ $ key ] ) ; unlink ( $ file ) ; return false ; } }
Check has cache key
50,643
public function remove ( $ key ) { $ file = $ this -> getFileName ( $ key ) ; if ( ! file_exists ( $ file ) ) { return false ; } unset ( static :: $ keys [ $ key ] ) ; return ( unlink ( $ file ) ) ? true : false ; }
Remove cache key
50,644
public function clear ( ) { echo $ path = $ this -> getFilePath ( ) ; $ files = glob ( $ path . '*' . $ this -> fileExtension ) ; foreach ( $ files as $ file ) { if ( time ( ) > filemtime ( $ file ) ) { @ unlink ( $ file ) ; } } }
Clear expire cache file
50,645
public function clearAll ( ) { $ path = $ this -> getFilePath ( ) ; $ files = glob ( $ path . '*' . $ this -> fileExtension ) ; foreach ( $ files as $ file ) { @ unlink ( $ file ) ; } static :: $ keys = [ ] ; }
Delete all cache files
50,646
public function setDefaultOptions ( ) { curl_setopt_array ( $ this -> curl , [ CURLOPT_TIMEOUT => $ this -> timeout , CURLOPT_NOSIGNAL => $ this -> nosignal , CURLOPT_FILETIME => $ this -> fileTime , CURLOPT_USERAGENT => $ this -> userAgent , CURLOPT_HEADER => $ this -> header , CURLOPT_HTTPHEADER => $ this -> headers , CURLOPT_RETURNTRANSFER => $ this -> returnTransfer , CURLOPT_SSL_VERIFYPEER => $ this -> sslVerifyPeer , CURLOPT_SSL_VERIFYHOST => $ this -> sslVerifyHost , CURLOPT_FRESH_CONNECT => $ this -> freshConnect ] ) ; }
Default cURL options
50,647
public function method ( $ method ) { $ this -> headers = array_merge ( $ this -> headers , array ( 'X-HTTP-Method-Override: ' . $ method ) ) ; $ this -> setOption ( CURLOPT_CUSTOMREQUEST , $ method ) ; $ this -> setOption ( CURLOPT_HTTPHEADER , $ this -> headers ) ; }
Set cURL method
50,648
public function error ( ) { $ this -> errors = [ 'code' => curl_errno ( $ this -> curl ) , 'message' => curl_error ( $ this -> curl ) ] ; return $ this -> error ( ) ; }
Get cURL errors
50,649
public function send ( $ url , $ method = 'GET' , $ data = null , callable $ callback = null ) { $ this -> curl ( $ url ) ; $ this -> setDefaultOptions ( ) ; if ( is_array ( $ this -> options ) ) { if ( count ( $ this -> options ) > 0 ) { foreach ( $ this -> options as $ key => $ value ) { $ this -> setOption ( $ key , $ value ) ; } } } if ( $ method !== self :: GET ) { $ this -> method ( $ method ) ; } if ( $ method === self :: POST || $ method === self :: PUT || $ method === self :: DELETE ) { $ this -> setOption ( CURLOPT_POSTFIELDS , $ data ) ; } $ response = $ this -> execute ( ) ; if ( ! $ response ) { $ this -> error ( ) ; } $ this -> getInfo ( ) ; $ this -> close ( ) ; if ( is_callable ( $ callback ) ) { $ callback ( $ this -> response , $ this -> info , $ this -> errors ) ; } return $ response ; }
Send Http query
50,650
protected function mapWebRoutes ( ) { if ( request ( ) -> segment ( 1 ) == 'api' || request ( ) -> segment ( 2 ) == 'api' ) { return ; } Route :: group ( [ 'middleware' => 'web' , 'namespace' => $ this -> namespace , 'prefix' => trans_setlocale ( ) , ] , function ( $ router ) { require ( __DIR__ . '/../../routes/web.php' ) ; } ) ; }
Define the web routes for the package .
50,651
public function make ( ) { $ this -> pageTotal = ceil ( $ this -> total / $ this -> num ) ; $ this -> page = ( $ this -> page > $ this -> pageTotal ) ? $ this -> pageTotal : $ this -> page ; $ this -> offset = ( $ this -> page == 1 ) ? 0 : ( ( $ this -> page - 1 ) * $ this -> num ) ; $ this -> prev = ( $ this -> page == 1 ) ? 1 : $ this -> page - 1 ; $ this -> next = ( $ this -> page == $ this -> pageTotal ) ? $ this -> pageTotal : $ this -> page + 1 ; $ this -> last = $ this -> pageTotal ; $ this -> range ( ) ; }
Make paginator params
50,652
public function isInScope ( UriInterface $ source , UriInterface $ comparator ) : bool { $ source = $ this -> removeIgnoredComponents ( $ source ) ; $ comparator = $ this -> removeIgnoredComponents ( $ comparator ) ; $ sourceString = ( string ) $ source ; $ comparatorString = ( string ) $ comparator ; if ( $ sourceString === $ comparatorString ) { return true ; } if ( $ this -> isSourceUrlSubstringOfComparatorUrl ( $ sourceString , $ comparatorString ) ) { return true ; } if ( ! $ this -> areSchemesEquivalent ( $ source -> getScheme ( ) , $ comparator -> getScheme ( ) ) ) { return false ; } if ( ! $ this -> areHostsEquivalent ( $ source -> getHost ( ) , $ comparator -> getHost ( ) ) ) { return false ; } return $ this -> isSourcePathSubstringOfComparatorPath ( $ source -> getPath ( ) , $ comparator -> getPath ( ) ) ; }
Is the given comparator url in the scope of the source url?
50,653
public function setPath ( $ path ) { if ( ! file_exists ( $ path ) ) { mkdir ( $ path , 0777 , true ) ; } $ this -> path = $ path ; }
Setting logs path
50,654
protected function defaultMessageFormatReplaces ( ) { $ this -> messageFormatReplaces = [ $ this -> label , str_repeat ( ' ' , 9 - strlen ( $ this -> label ) ) , date ( 'Y-m-d H:i:s e O' ) , $ this -> message ] ; }
Default log message format replaces
50,655
protected function messageFormatParser ( ) { $ this -> label = $ this -> levels [ $ this -> level ] ; $ this -> messageOutput = str_replace ( $ this -> getMessageFormatSearchs ( ) , $ this -> getMessageFormatReplaces ( ) , $ this -> getMessageFormat ( ) ) ; }
Log message format parser
50,656
private function moveFile ( ) { $ this -> setSeveName ( ) ; $ files = $ this -> files ; if ( $ this -> formats != "" && ! in_array ( $ this -> fileExt , $ this -> formats ) ) { $ formats = implode ( ',' , $ this -> formats ) ; $ message = "Your upload file " . $ files [ "name" ] . " is " . $ this -> fileExt ; $ message .= " format, The system is not allowed to upload, you can only upload " . $ formats . " format's file." ; $ this -> error ( $ message , 0 , true ) ; return false ; } if ( $ files [ "size" ] / 1024 > $ this -> maxSize ) { $ message = "Your upload file " . $ files [ "name" ] . " The file size exceeds of the system limit size " . $ this -> maxSize . " KB." ; $ this -> error ( $ message , 0 , true ) ; return false ; } if ( ! $ this -> cover ) { if ( file_exists ( $ this -> savePath . $ this -> saveName ) ) { $ this -> error ( $ this -> saveName . $ this -> errors [ 'same_file' ] , 0 , true ) ; return false ; } } if ( ! @ move_uploaded_file ( $ files [ "tmp_name" ] , iconv ( "utf-8" , "gbk" , $ this -> savePath . $ this -> saveName ) ) ) { switch ( $ files [ "error" ] ) { case '0' : $ message = "File upload successfully." ; break ; case '1' : $ message = "The uploaded file exceeds the value of the upload_max_filesize option in php.ini." ; break ; case '2' : $ message = "The size of the upload file exceeds the value specified by the MAX_FILE_SIZE option in the HTML form." ; break ; case '3' : $ message = "Only part of the file is uploaded." ; break ; case '4' : $ message = "No file is uploaded." ; break ; case '6' : $ message = "Can't find upload temp directory." ; break ; case '7' : $ message = "Error writing file to hard drive" ; break ; case '8' : $ message = "An extension has stopped the upload of the file." ; break ; case '999' : default : $ message = "Unknown error, please check the file is damaged, whether the oversized and other reasons." ; break ; } $ this -> error ( $ message , 0 , true ) ; return false ; } @ unlink ( $ files [ "tmp_name" ] ) ; return true ; }
Check and move the upload file
50,657
private function randomFileName ( ) { $ fileName = '' ; if ( $ this -> randomNameType == 1 ) { date_default_timezone_set ( $ this -> timezone ) ; $ date = date ( $ this -> randomLength ) ; echo $ dir = $ this -> savePath . $ date ; if ( ! file_exists ( $ dir ) ) { mkdir ( $ dir , $ this -> mode , true ) ; } $ fileName = $ date . '/' . time ( ) ; } elseif ( $ this -> randomNameType == 2 ) { $ chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz' ; $ max = strlen ( $ chars ) - 1 ; mt_srand ( ( double ) microtime ( ) * 1000000 ) ; for ( $ i = 0 ; $ i < $ this -> randomLength ; $ i ++ ) { $ fileName .= $ chars [ mt_rand ( 0 , $ max ) ] ; } } else { } $ this -> fileExt = $ this -> getFileExt ( $ this -> files [ "name" ] ) ; $ fileName = $ fileName . '.' . $ this -> fileExt ; return $ fileName ; }
Generate random file name
50,658
private function setSeveName ( ) { $ this -> saveName = $ this -> randomFileName ( ) ; if ( $ this -> saveName == '' ) { $ this -> saveName = $ this -> files [ 'name' ] ; } }
Set Saved filename for database
50,659
public function message ( $ message , $ success = 0 , $ return = false ) { $ array = array ( 'success' => $ success , 'message' => $ message ) ; $ url = $ this -> saveURL . $ this -> saveName ; if ( $ this -> redirect ) { $ this -> redirectURL .= '&success=' . $ success . '&message=' . $ message ; if ( $ success == 1 ) { $ this -> redirectURL .= '&url=' . $ url ; } $ this -> redirect ( ) ; } else { echo "success =>" . $ success ; if ( $ success == 1 ) { $ array [ 'url' ] = $ url ; } $ this -> message = $ array = json_encode ( $ array ) ; if ( $ return ) { return $ array ; } else { echo $ array ; } } }
Errors message handle
50,660
public function index ( GalleryRequest $ request ) { $ view = $ this -> response -> theme -> listView ( ) ; if ( $ this -> response -> typeIs ( 'json' ) ) { $ function = camel_case ( 'get-' . $ view ) ; return $ this -> repository -> setPresenter ( \ Litecms \ Gallery \ Repositories \ Presenter \ GalleryPresenter :: class ) -> $ function ( ) ; } $ galleries = $ this -> repository -> paginate ( ) ; return $ this -> response -> title ( trans ( 'gallery::gallery.names' ) ) -> view ( 'gallery::gallery.index' , true ) -> data ( compact ( 'galleries' ) ) -> output ( ) ; }
Display a list of gallery .
50,661
public function show ( GalleryRequest $ request , Gallery $ gallery ) { if ( $ gallery -> exists ) { $ view = 'gallery::gallery.show' ; } else { $ view = 'gallery::gallery.new' ; } return $ this -> response -> title ( trans ( 'app.view' ) . ' ' . trans ( 'gallery::gallery.name' ) ) -> data ( compact ( 'gallery' ) ) -> view ( $ view , true ) -> output ( ) ; }
Display gallery .
50,662
public function edit ( GalleryRequest $ request , Gallery $ gallery ) { return $ this -> response -> title ( trans ( 'app.edit' ) . ' ' . trans ( 'gallery::gallery.name' ) ) -> view ( 'gallery::gallery.edit' , true ) -> data ( compact ( 'gallery' ) ) -> output ( ) ; }
Show gallery for editing .
50,663
public function update ( GalleryRequest $ request , Gallery $ gallery ) { try { $ attributes = $ request -> all ( ) ; $ gallery -> update ( $ attributes ) ; return $ this -> response -> message ( trans ( 'messages.success.updated' , [ 'Module' => trans ( 'gallery::gallery.name' ) ] ) ) -> code ( 204 ) -> status ( 'success' ) -> url ( guard_url ( 'gallery/gallery/' . $ gallery -> getRouteKey ( ) ) ) -> redirect ( ) ; } catch ( Exception $ e ) { return $ this -> response -> message ( $ e -> getMessage ( ) ) -> code ( 400 ) -> status ( 'error' ) -> url ( guard_url ( 'gallery/gallery/' . $ gallery -> getRouteKey ( ) ) ) -> redirect ( ) ; } }
Update the gallery .
50,664
public function destroy ( GalleryRequest $ request , Gallery $ gallery ) { try { $ gallery -> delete ( ) ; return $ this -> response -> message ( trans ( 'messages.success.deleted' , [ 'Module' => trans ( 'gallery::gallery.name' ) ] ) ) -> code ( 202 ) -> status ( 'success' ) -> url ( guard_url ( 'gallery/gallery/0' ) ) -> redirect ( ) ; } catch ( Exception $ e ) { return $ this -> response -> message ( $ e -> getMessage ( ) ) -> code ( 400 ) -> status ( 'error' ) -> url ( guard_url ( 'gallery/gallery/' . $ gallery -> getRouteKey ( ) ) ) -> redirect ( ) ; } }
Remove the gallery .
50,665
public function clear ( ) { $ this -> setFields ( '' ) ; $ this -> setSet ( '' ) ; $ this -> setLimit ( '' ) ; $ this -> setWhere ( '' ) ; $ this -> setOrderBy ( '' ) ; $ this -> setGroupBy ( '' ) ; $ this -> setRecords ( '' ) ; $ this -> setQuery ( '' ) ; }
Limpa variaveis para novas consultas
50,666
public function getRow ( ) { if ( $ GLOBALS [ 'CONN' ] -> _connectionID == false ) { return false ; } $ s = $ this -> getQuery ( ) ; return $ s -> FetchRow ( ) ; }
CONTROLE DE TABLE
50,667
public function setSet ( $ v = '' ) { if ( is_array ( $ v ) ) { $ q = '' ; if ( count ( $ v ) > 0 ) { foreach ( $ v as $ key => $ value ) { $ q .= "`{$key}` = '{$value}', " ; } $ q = substr ( $ q , 0 , - 2 ) ; } $ this -> set = $ q ; } else { $ this -> set = $ v ; } }
CONTROLE DE SET
50,668
public function setWhere ( $ v = '' ) { if ( is_array ( $ v ) ) { $ q = '' ; if ( count ( $ v ) > 0 ) { foreach ( $ v as $ key => $ value ) { $ q .= " {$key}= '{$value}' AND" ; } $ q = substr ( $ q , 0 , - 3 ) ; } $ this -> where = $ q ; } else { $ this -> where = $ v ; } }
CONTROLE DE WHERE
50,669
public function setApplication ( $ a = '' , $ l = '' ) { if ( is_string ( $ a ) ) { $ this -> application [ $ a ] = $ l ; } else if ( is_array ( $ a ) ) { foreach ( $ a as $ key => & $ value ) { $ this -> application [ $ key ] = $ value ; } } }
Set applications of system
50,670
public function requireModels ( $ file = '' ) { $ d = PATH_ROOT . '/app/' . $ this -> getEnvironmentStatus ( ) . '/models' . ( $ file != '' ? '/' . $ file : '' ) ; if ( file_exists ( $ d ) && is_file ( $ d ) ) { require_once $ d ; } }
GETTERS AND SETTERES
50,671
public function get ( $ file ) { $ path = $ this -> getPath ( $ file ) ; if ( ! file_exists ( $ path ) ) { throw new FileDoesNotExists ; } return file_get_contents ( $ path ) ; }
Get file contents .
50,672
public function put ( $ file , $ content , $ flag = null , $ recursive = false ) { if ( $ recursive ) { $ this -> createParentFolder ( $ file ) ; } return file_put_contents ( $ this -> getPath ( $ file ) , $ content , $ flag ) ; }
Put content in file .
50,673
public function getBundleConfigs ( bool $ development , string $ cacheFile = null ) : array { if ( null !== $ cacheFile ) { return $ this -> loadFromCache ( $ development , $ cacheFile ) ; } return $ this -> loadFromPlugins ( $ development , $ cacheFile ) ; }
Returns an ordered bundles map .
50,674
private function loadFromCache ( bool $ development , string $ cacheFile = null ) : array { $ bundleConfigs = is_file ( $ cacheFile ) ? include $ cacheFile : null ; if ( ! \ is_array ( $ bundleConfigs ) || 0 === \ count ( $ bundleConfigs ) ) { $ bundleConfigs = $ this -> loadFromPlugins ( $ development , $ cacheFile ) ; } return $ bundleConfigs ; }
Loads the bundles map from cache .
50,675
private function loadFromPlugins ( bool $ development , string $ cacheFile = null ) : array { $ resolver = $ this -> resolverFactory -> create ( ) ; $ plugins = $ this -> pluginLoader -> getInstancesOf ( PluginLoader :: BUNDLE_PLUGINS ) ; foreach ( $ plugins as $ plugin ) { foreach ( $ plugin -> getBundles ( $ this -> parser ) as $ config ) { $ resolver -> add ( $ config ) ; } } $ bundleConfigs = $ resolver -> getBundleConfigs ( $ development ) ; if ( null !== $ cacheFile ) { $ this -> filesystem -> dumpFile ( $ cacheFile , sprintf ( '<?php return %s;' , var_export ( $ bundleConfigs , true ) ) ) ; } return $ bundleConfigs ; }
Generates the bundles map .
50,676
public function make ( ) { $ this -> rawColumns = $ this -> getRawColumns ( $ this -> columns ) ; $ this -> columnNames = $ this -> getColumnNames ( ) ; $ this -> addSelect ( ) ; $ this -> total = $ this -> count ( ) ; if ( static :: $ versionTransformer === null ) { static :: $ versionTransformer = new Version110Transformer ( ) ; } $ this -> addFilters ( ) ; $ this -> filtered = $ this -> count ( ) ; $ this -> addOrderBy ( ) ; $ this -> addLimits ( ) ; $ this -> rows = $ this -> builder -> get ( ) ; $ rows = [ ] ; foreach ( $ this -> rows as $ row ) { $ rows [ ] = $ this -> formatRow ( $ row ) ; } return [ static :: $ versionTransformer -> transform ( 'draw' ) => ( isset ( $ _POST [ static :: $ versionTransformer -> transform ( 'draw' ) ] ) ? ( int ) $ _POST [ static :: $ versionTransformer -> transform ( 'draw' ) ] : 0 ) , static :: $ versionTransformer -> transform ( 'recordsTotal' ) => $ this -> total , static :: $ versionTransformer -> transform ( 'recordsFiltered' ) => $ this -> filtered , static :: $ versionTransformer -> transform ( 'data' ) => $ rows ] ; }
Make the datatable response .
50,677
protected function addFilters ( ) { $ search = static :: $ versionTransformer -> getSearchValue ( ) ; if ( $ search != '' ) { $ this -> addAllFilter ( $ search ) ; } $ this -> addColumnFilters ( ) ; return $ this ; }
Add the filters based on the search value given .
50,678
protected function addAllFilter ( $ search ) { $ this -> builder = $ this -> builder -> where ( function ( $ query ) use ( $ search ) { foreach ( $ this -> columns as $ column ) { $ query -> orWhere ( new raw ( $ this -> getRawColumnQuery ( $ column ) ) , 'like' , '%' . $ search . '%' ) ; } } ) ; }
Searches in all the columns .
50,679
protected function addColumnFilters ( ) { foreach ( $ this -> columns as $ i => $ column ) { if ( static :: $ versionTransformer -> isColumnSearched ( $ i ) ) { $ this -> builder -> where ( new raw ( $ this -> getRawColumnQuery ( $ column ) ) , 'like' , '%' . static :: $ versionTransformer -> getColumnSearchValue ( $ i ) . '%' ) ; } } }
Add column specific filters .
50,680
protected function addOrderBy ( ) { if ( static :: $ versionTransformer -> isOrdered ( ) ) { foreach ( static :: $ versionTransformer -> getOrderedColumns ( ) as $ index => $ direction ) { if ( isset ( $ this -> columnNames [ $ index ] ) ) { $ this -> builder -> orderBy ( $ this -> columnNames [ $ index ] , $ direction ) ; } } } }
Depending on the sorted column this will add orderBy to the builder .
50,681
protected function addLimits ( ) { if ( isset ( $ _POST [ static :: $ versionTransformer -> transform ( 'start' ) ] ) && $ _POST [ static :: $ versionTransformer -> transform ( 'length' ) ] != '-1' ) { $ this -> builder -> skip ( ( int ) $ _POST [ static :: $ versionTransformer -> transform ( 'start' ) ] ) -> take ( ( int ) $ _POST [ static :: $ versionTransformer -> transform ( 'length' ) ] ) ; } }
Adds the pagination limits to the builder
50,682
public function resizeAction ( $ imageName ) { try { $ imageOptimizer = $ this -> get ( 'harentius_blog.image_optimizer' ) ; $ imagePath = $ imageOptimizer -> createPreviewIfNotExists ( $ imageName ) ; return new BinaryFileResponse ( $ imagePath ) ; } catch ( \ Exception $ e ) { throw new NotFoundHttpException ( sprintf ( 'File %s not found' , $ imageName ) ) ; } }
For optimization try_files should be set in nginx Then BinaryFileResponse only once when crete cache preview .
50,683
private function parseBundles ( array $ bundles , array & $ configs ) : void { foreach ( $ bundles as $ options ) { if ( ! \ is_array ( $ options ) ) { $ options = [ 'bundle' => $ options ] ; } if ( ! isset ( $ options [ 'bundle' ] ) ) { throw new \ RuntimeException ( sprintf ( 'Missing class name for bundle config (%s)' , json_encode ( $ options ) ) ) ; } if ( ! empty ( $ options [ 'optional' ] ) && ! class_exists ( $ options [ 'bundle' ] ) ) { continue ; } $ config = new BundleConfig ( $ options [ 'bundle' ] ) ; if ( isset ( $ options [ 'replace' ] ) ) { $ config -> setReplace ( $ options [ 'replace' ] ) ; } if ( isset ( $ options [ 'development' ] ) ) { if ( true === $ options [ 'development' ] ) { $ config -> setLoadInProduction ( false ) ; } elseif ( false === $ options [ 'development' ] ) { $ config -> setLoadInDevelopment ( false ) ; } } if ( isset ( $ options [ 'load-after' ] ) ) { $ config -> setLoadAfter ( $ options [ 'load-after' ] ) ; } $ configs [ ] = $ config ; } }
Parses the bundle array and generates config objects .
50,684
protected function orderByDependencies ( array $ dependencies ) : array { $ ordered = [ ] ; $ available = array_keys ( $ dependencies ) ; while ( 0 !== \ count ( $ dependencies ) ) { $ success = $ this -> doResolve ( $ dependencies , $ ordered , $ available ) ; if ( false === $ success ) { throw new UnresolvableDependenciesException ( "The dependencies order could not be resolved.\n" . print_r ( $ dependencies , true ) ) ; } } return $ ordered ; }
Returns a list of array keys ordered by their dependencies .
50,685
private function doResolve ( array & $ dependencies , array & $ ordered , array $ available ) : bool { $ failed = true ; foreach ( $ dependencies as $ name => $ requires ) { if ( true === $ this -> canBeResolved ( $ requires , $ available , $ ordered ) ) { $ failed = false ; $ ordered [ ] = $ name ; unset ( $ dependencies [ $ name ] ) ; } } return ! $ failed ; }
Resolves the dependency order .
50,686
private function canBeResolved ( array $ requires , array $ available , array $ ordered ) : bool { if ( 0 === \ count ( $ requires ) ) { return true ; } return 0 === \ count ( array_diff ( array_intersect ( $ requires , $ available ) , $ ordered ) ) ; }
Checks whether the requirements can be resolved .
50,687
private function setLoadAfterLegacyModules ( ) : void { static $ legacy = [ 'core' , 'calendar' , 'comments' , 'faq' , 'listing' , 'news' , 'newsletter' , ] ; $ modules = array_merge ( $ legacy , [ $ this -> getName ( ) ] ) ; sort ( $ modules ) ; $ modules = array_values ( $ modules ) ; array_splice ( $ modules , array_search ( $ this -> getName ( ) , $ modules , true ) ) ; if ( ! \ in_array ( 'core' , $ modules , true ) ) { $ modules [ ] = 'core' ; } $ this -> setLoadAfter ( $ modules ) ; }
Adjusts the configuration so the module is loaded after the legacy modules .
50,688
private function copyConfigFile ( ) { $ path = $ this -> getConfigPath ( ) ; if ( $ this -> files -> exists ( $ path ) && $ this -> option ( 'force' ) === false ) { $ this -> error ( "{$path} already exists! Run 'generate:publish-stubs --force' to override the config file." ) ; die ; } File :: copy ( __DIR__ . '/../config/config.php' , $ path ) ; }
Copy the config file to the default config folder
50,689
private function copyStubsDirectory ( ) { $ path = $ this -> option ( 'path' ) ; if ( $ this -> files -> exists ( $ path . DIRECTORY_SEPARATOR . 'controller.stub' ) && $ this -> option ( 'force' ) === false ) { $ this -> error ( "Stubs already exists! Run 'generate:publish-stubs --force' to override the stubs." ) ; die ; } File :: copyDirectory ( __DIR__ . '/../../resources/stubs' , $ path ) ; }
Copy the stubs directory
50,690
private function updateStubsPathsInConfigFile ( ) { $ updated = str_replace ( 'vendor/bpocallaghan/generators/' , '' , File :: get ( $ this -> getConfigPath ( ) ) ) ; File :: put ( $ this -> getConfigPath ( ) , $ updated ) ; }
Update stubs path in the new published config file
50,691
public function getStatus ( $ ruc , $ tipo , $ serie , $ numero ) { return $ this -> getStatusResult ( 'getStatus' , 'status' , $ ruc , $ tipo , $ serie , $ numero ) ; }
Obtiene el estado del comprobante .
50,692
public function getStatusCdr ( $ ruc , $ tipo , $ serie , $ numero ) { return $ this -> getStatusResult ( 'getStatusCdr' , 'statusCdr' , $ ruc , $ tipo , $ serie , $ numero ) ; }
Obtiene el CDR del comprobante .
50,693
public function add ( $ group_id , $ phone , $ params = array ( ) ) { $ params = array_merge ( array ( 'group_id' => $ group_id , 'phone' => $ phone , ) , $ params ) ; return $ this -> master -> call ( 'contacts/add' , $ params ) ; }
Add new contact
50,694
public function index ( $ group_id = null , $ search = null , $ params = array ( ) ) { $ params = array_merge ( array ( 'group_id' => $ group_id , 'search' => $ search ) , $ params ) ; return $ this -> master -> call ( 'contacts/index' , $ params ) ; }
List of contacts
50,695
public function edit ( $ id , $ group_id , $ phone , $ params = array ( ) ) { $ params = array_merge ( array ( 'id' => $ id , 'group_id' => $ group_id , 'phone' => $ phone ) , $ params ) ; return $ this -> master -> call ( 'contacts/edit' , $ params ) ; }
Editing a contact
50,696
public function import ( $ group_name , $ contact ) { $ params = array ( 'group_name' => $ group_name , 'contact' => $ contact ) ; return $ this -> master -> call ( 'contacts/import' , $ params ) ; }
Import contact list
50,697
public function expectExplicit ( $ expectedTag = null ) : ExplicitTagging { $ el = $ this ; if ( ! $ el instanceof ExplicitTagging ) { throw new \ UnexpectedValueException ( "Element doesn't implement explicit tagging." ) ; } if ( isset ( $ expectedTag ) ) { $ el -> expectTagged ( $ expectedTag ) ; } return $ el ; }
Check whether element supports explicit tagging .
50,698
public function expectImplicit ( $ expectedTag = null ) : ImplicitTagging { $ el = $ this ; if ( ! $ el instanceof ImplicitTagging ) { throw new \ UnexpectedValueException ( "Element doesn't implement implicit tagging." ) ; } if ( isset ( $ expectedTag ) ) { $ el -> expectTagged ( $ expectedTag ) ; } return $ el ; }
Check whether element supports implicit tagging .
50,699
public function asImplicit ( int $ tag , $ expectedTag = null , int $ expectedClass = Identifier :: CLASS_UNIVERSAL ) : UnspecifiedType { return $ this -> expectImplicit ( $ expectedTag ) -> implicit ( $ tag , $ expectedClass ) ; }
Get the wrapped inner element employing implicit tagging .