idx
int64
0
60.3k
question
stringlengths
64
4.24k
target
stringlengths
5
618
15,400
public static function execute ( $ sql , $ parameters = null , $ connection = null , $ fetchMode = \ PDO :: FETCH_ASSOC ) { self :: $ _statement = self :: createStatement ( $ sql , $ connection , $ fetchMode ) ; if ( empty ( $ parameters ) ) { return self :: $ _statement -> execute ( ) ; } return self :: $ _statement -> execute ( $ parameters ) ; }
Executes a SQL statement
15,401
public static function find ( $ sql , $ parameters = null , $ connection = null , $ fetchMode = \ PDO :: FETCH_ASSOC ) { if ( false === ( $ _reader = self :: query ( $ sql , $ parameters , $ connection , $ fetchMode ) ) ) { return null ; } return $ _reader -> fetch ( ) ; }
Executes a SQL query
15,402
public static function findAll ( $ sql , $ parameters = null , $ connection = null , $ fetchMode = \ PDO :: FETCH_ASSOC ) { if ( false === ( $ _reader = self :: query ( $ sql , $ parameters , $ connection , $ fetchMode ) ) ) { return null ; } return $ _reader -> fetchAll ( ) ; }
Executes the given sql statement and returns all results
15,403
public static function scalar ( $ sql , $ columnNumber = 0 , $ parameters = null , $ connection = null , $ fetchMode = \ PDO :: FETCH_ASSOC ) { if ( false === ( $ _reader = self :: query ( $ sql , $ parameters , $ connection , $ fetchMode ) ) ) { return null ; } return $ _reader -> fetchColumn ( $ columnNumber ) ; }
Returns the first column of the first row or null
15,404
protected function _setStateMachine ( $ stateMachine ) { if ( $ stateMachine !== null && ! ( $ stateMachine instanceof StateMachineInterface ) ) { throw $ this -> _createInvalidArgumentException ( $ this -> __ ( 'Argument is not a valid state machine instance' ) , null , null , $ stateMachine ) ; } $ this -> stateMachine = $ stateMachine ; }
Sets the state machine for this instance .
15,405
public function setEnv ( $ shortOptions = '' , array $ longOptions = array ( ) , array $ argv = array ( ) ) { if ( ! empty ( $ argv ) ) { $ this -> argv = $ argv ; $ this -> argc = count ( $ argv ) ; } $ this -> shortOptions = $ shortOptions ; $ this -> longOptions = $ longOptions ; $ this -> program = $ this -> argv [ 0 ] ; }
Sets the working environment for the program
15,406
public function options ( $ start = 1 ) { $ this -> optind = ( 0 == ( $ start ) ) ? 1 : ( int ) $ start ; do { $ nextOption = $ this -> getopt ( ) ; if ( null !== $ nextOption && - 1 !== $ nextOption ) { $ this -> options [ $ nextOption ] = ( null !== $ this -> optarg ) ? $ this -> optarg : true ; } } while ( $ nextOption !== - 1 ) ; return $ this -> options ; }
Return all the options in an associative array where the key is the option s name
15,407
public function arguments ( ) { if ( $ this -> optind < $ this -> argc ) { for ( $ i = $ this -> optind ; $ i < $ this -> argc ; $ i ++ ) { $ this -> arguments [ ] = $ this -> argv [ $ i ] ; } } return $ this -> arguments ; }
Returns program s arguments
15,408
private function getopt ( ) { $ this -> optarg = null ; if ( $ this -> optind >= $ this -> argc ) { return - 1 ; } $ arg = $ this -> argv [ $ this -> optind ] ; if ( $ this -> isLongOption ( $ arg ) ) { return $ this -> parseLongOption ( $ arg ) ; } if ( $ this -> isShortOption ( $ arg ) ) { return $ this -> parseShortOption ( $ arg ) ; } return - 1 ; }
Searches for a valid next option
15,409
private function getLongOptionKey ( $ arg ) { $ key = ( false !== ( $ eqPos = strpos ( $ arg , '=' ) ) ) ? substr ( $ arg , 2 , $ eqPos - 2 ) : substr ( $ arg , 2 ) ; return $ key ; }
Extracts the key from a long option
15,410
private function parseShortOptionGroup ( $ key ) { $ shortOptions = $ this -> shortOptions ; $ chars = str_split ( $ key ) ; foreach ( $ chars as $ char ) { $ cpos = strpos ( $ shortOptions , $ char ) ; if ( false === $ cpos ) { $ this -> optind ++ ; return null ; } $ option = $ char ; if ( isset ( $ shortOptions [ $ cpos + 1 ] ) && $ shortOptions [ $ cpos + 1 ] === ':' ) { if ( strpos ( $ key , $ char ) < ( strlen ( $ key ) - 1 ) ) { $ this -> optarg = false ; $ this -> argv [ $ this -> optind ] = str_replace ( $ char , '' , $ this -> argv [ $ this -> optind ] ) ; return $ option ; } if ( $ this -> optind < $ this -> argc - 1 ) { $ optarg = ( string ) $ this -> argv [ $ this -> optind + 1 ] ; if ( ! ( $ this -> isLongOption ( $ optarg ) ) && ! ( $ this -> isShortOption ( $ optarg ) ) ) { $ this -> optarg = $ optarg ; $ this -> optind += 2 ; return $ option ; } } $ this -> optarg = false ; $ this -> optind ++ ; return $ option ; } $ this -> optarg = true ; $ this -> argv [ $ this -> optind ] = str_replace ( $ char , '' , $ this -> argv [ $ this -> optind ] ) ; if ( strpos ( $ key , $ char ) == ( strlen ( $ key ) - 1 ) ) { $ this -> optind ++ ; } return $ option ; } if ( strpos ( $ key , $ char ) == ( strlen ( $ key ) - 1 ) ) { $ this -> optind ++ ; } return null ; }
Parse and extract the keys and values of a short options group
15,411
public function find ( $ basePath ) { if ( is_file ( $ basePath ) ) { $ basePath = dirname ( $ basePath ) ; } elseif ( ! is_dir ( $ basePath ) ) { throw new \ InvalidArgumentException ( 'Base path must be either a file path or directory' ) ; } $ basePath = realpath ( $ basePath ) ? : $ basePath ; do { $ autoloaderPath = $ this -> containsKnownAutoloader ( $ basePath ) ; if ( $ autoloaderPath !== '' ) { return $ autoloaderPath ; } $ basePath = dirname ( $ basePath ) ; } while ( $ basePath && $ basePath !== '/' ) ; return '' ; }
Find the best autoloader for the current project
15,412
public function setItemCountPerPage ( $ itemCountPerPage = - 1 ) { $ this -> itemCountPerPage = ( int ) $ itemCountPerPage ; if ( $ this -> itemCountPerPage < 1 ) { $ this -> itemCountPerPage = $ this -> getTotalItemCount ( ) ; } $ this -> pageCount = $ this -> _calculatePageCount ( ) ; $ this -> currentItems = null ; $ this -> currentItemCount = null ; return $ this ; }
Sets the number of items per page .
15,413
public function getPages ( $ scrollingStyle = null ) { if ( $ this -> pages === null ) { $ this -> pages = $ this -> _createPages ( $ scrollingStyle ) ; } return $ this -> pages ; }
Returns the page collection .
15,414
public function getPagesInRange ( $ lowerBound , $ upperBound ) { $ lowerBound = $ this -> normalizePageNumber ( $ lowerBound ) ; $ upperBound = $ this -> normalizePageNumber ( $ upperBound ) ; $ pages = array ( ) ; for ( $ pageNumber = $ lowerBound ; $ pageNumber <= $ upperBound ; $ pageNumber ++ ) { $ pages [ $ pageNumber ] = $ pageNumber ; } return $ pages ; }
Returns a subset of pages within a given range .
15,415
public function normalizeItemNumber ( $ itemNumber ) { $ itemNumber = ( int ) $ itemNumber ; if ( $ itemNumber < 1 ) { $ itemNumber = 1 ; } if ( $ itemNumber > $ this -> getItemCountPerPage ( ) ) { $ itemNumber = $ this -> getItemCountPerPage ( ) ; } return $ itemNumber ; }
Brings the item number in range of the page .
15,416
public function normalizePageNumber ( $ pageNumber ) { $ pageNumber = ( int ) $ pageNumber ; if ( $ pageNumber < 1 ) { $ pageNumber = 1 ; } $ pageCount = $ this -> count ( ) ; if ( $ pageCount > 0 && $ pageNumber > $ pageCount ) { $ pageNumber = $ pageCount ; } return $ pageNumber ; }
Brings the page number in range of the paginator .
15,417
protected function _createPages ( $ scrollingStyle = null ) { $ pageCount = $ this -> count ( ) ; $ currentPageNumber = $ this -> getCurrentPageNumber ( ) ; $ pages = array ( 'pageCount' => $ pageCount , 'itemCountPerPage' => $ this -> getItemCountPerPage ( ) , 'first' => 1 , 'current' => $ currentPageNumber , 'last' => $ pageCount ) ; if ( $ currentPageNumber - 1 > 0 ) { $ pages [ 'previous' ] = $ currentPageNumber - 1 ; } if ( $ currentPageNumber + 1 <= $ pageCount ) { $ pages [ 'next' ] = $ currentPageNumber + 1 ; } $ scrollingStyle = $ this -> _loadScrollingStyle ( $ scrollingStyle ) ; $ pages [ 'pagesInRange' ] = $ scrollingStyle -> getPages ( $ this ) ; $ pages [ 'firstPageInRange' ] = min ( $ pages [ 'pagesInRange' ] ) ; $ pages [ 'lastPageInRange' ] = max ( $ pages [ 'pagesInRange' ] ) ; return $ pages ; }
Creates the page collection .
15,418
public function resolveComposedTargetObject ( $ e ) { $ annotation = $ e -> getParam ( 'annotation' ) ; if ( ! $ annotation instanceof ComposedObject ) { return ; } $ formSpec = $ e -> getParam ( 'formSpec' ) ; if ( ! isset ( $ formSpec [ 'object' ] ) ) { return ; } $ metadata = $ this -> objectManager -> getClassMetadata ( $ formSpec [ 'object' ] ) ; $ fieldName = $ e -> getParam ( 'elementSpec' ) [ 'spec' ] [ 'name' ] ; if ( $ metadata -> hasAssociation ( $ fieldName ) ) { $ e -> setParam ( 'annotation' , new ComposedObject ( [ 'value' => [ 'target_object' => $ metadata -> getAssociationTargetClass ( $ fieldName ) , 'is_collection' => $ annotation -> isCollection ( ) , 'options' => $ annotation -> getOptions ( ) , ] , ] ) ) ; return ; } if ( ! empty ( $ metadata -> embeddedClasses [ $ fieldName ] ) ) { $ class = $ metadata -> embeddedClasses [ $ fieldName ] [ 'class' ] ; if ( ! is_object ( $ class ) ) { $ class = $ this -> objectManager -> getClassMetadata ( $ class ) -> getName ( ) ; } $ e -> setParam ( 'annotation' , new ComposedObject ( [ 'value' => [ 'target_object' => $ class , 'is_collection' => $ annotation -> isCollection ( ) , 'options' => $ annotation -> getOptions ( ) , ] , ] ) ) ; } }
ComposedObject target object resolver
15,419
public function handleHydratorAnnotation ( $ e ) { $ annotation = $ e -> getParam ( 'annotation' ) ; if ( ! ( $ annotation instanceof ComposedObject && $ annotation -> isCollection ( ) ) ) { return ; } $ elementSpec = $ e -> getParam ( 'elementSpec' ) ; if ( isset ( $ elementSpec [ 'spec' ] [ 'hydrator' ] ) ) { unset ( $ elementSpec [ 'spec' ] [ 'hydrator' ] ) ; } }
Handle the Hydrator annotation
15,420
public function resolveObjectSelectTargetClass ( $ e ) { $ elementSpec = $ e -> getParam ( 'elementSpec' ) ; if ( ! isset ( $ elementSpec [ 'spec' ] [ 'type' ] ) ) { return ; } $ type = $ elementSpec [ 'spec' ] [ 'type' ] ; if ( strtolower ( $ type ) !== 'objectselect' && ! $ type instanceof ObjectSelect ) { return ; } if ( isset ( $ elementSpec [ 'spec' ] [ 'options' ] [ 'target_class' ] ) && class_exists ( $ elementSpec [ 'spec' ] [ 'options' ] [ 'target_class' ] ) || empty ( $ formSpec [ 'object' ] ) ) { return ; } $ formSpec = $ e -> getParam ( 'formSpec' ) ; $ metadata = $ this -> objectManager -> getClassMetadata ( $ formSpec [ 'object' ] ) ; if ( $ metadata -> hasAssociation ( $ elementSpec [ 'spec' ] [ 'name' ] ) ) { $ elementSpec [ 'spec' ] [ 'options' ] [ 'target_class' ] = $ metadata -> getAssociationTargetClass ( $ elementSpec [ 'spec' ] [ 'name' ] ) ; } }
ObjectSelect target class resolver
15,421
public function newAction ( ) { $ entity = new Product ( ) ; $ entity = $ this -> addProductItemFieldData ( $ entity ) ; $ form = $ this -> createCreateForm ( $ entity ) ; return array ( 'entity' => $ entity , 'form' => $ form -> createView ( ) , ) ; }
Displays a form to create a new Product entity .
15,422
public function copyAction ( Product $ product ) { $ productCopy = new Product ( ) ; $ copyName = $ this -> get ( 'translator' ) -> trans ( 'Copy of' ) . " " . $ product -> getName ( ) ; $ productCopy -> setName ( $ copyName ) ; $ productCopy -> setCostPrice ( $ product -> getCostPrice ( ) ) ; $ productCopy -> setDescription ( $ product -> getDescription ( ) ?? $ copyName ) ; $ productCopy -> setCode ( $ product -> getCode ( ) ) ; $ productCopy -> setImage ( $ product -> getImage ( ) ) ; $ productCopy -> setPlace ( $ product -> getPlace ( ) ) ; $ productCopy -> setSalePrice ( $ product -> getSalePrice ( ) ) ; $ productCopy -> setSupplier ( $ product -> getSupplier ( ) ) ; $ productCopy -> setWarehouse ( $ product -> getWarehouse ( ) ) ; $ productCopy -> setEnabled ( $ product -> getEnabled ( ) ) ; $ productCopy -> setForSale ( $ product -> getForSale ( ) ) ; $ productCopy -> setCompositionOnDemand ( $ product -> isCompositionOnDemand ( ) ) ; $ productCopy -> setPack ( $ product -> isPack ( ) ) ; $ productCopy -> setManualPackPricing ( $ product -> isManualPackPricing ( ) ) ; $ productCopy -> setRawMaterial ( $ product -> getRawMaterial ( ) ) ; $ em = $ this -> getDoctrine ( ) -> getManager ( ) ; $ em -> persist ( $ productCopy ) ; foreach ( $ product -> getRawMaterials ( ) as $ rawMaterial ) { $ rawMaterialCopy = new ProductRawMaterial ( ) ; $ rawMaterialCopy -> setRawMaterial ( $ rawMaterial -> getRawMaterial ( ) ) ; $ rawMaterialCopy -> setProduct ( $ productCopy ) ; $ rawMaterialCopy -> setMeasureUnit ( $ rawMaterial -> getMeasureUnit ( ) ) ; $ rawMaterialCopy -> setQuantity ( $ rawMaterial -> getQuantity ( ) ) ; $ em -> persist ( $ rawMaterialCopy ) ; $ productCopy -> addRawMaterial ( $ rawMaterialCopy ) ; } foreach ( $ product -> getCategories ( ) as $ category ) { $ productCopy -> addCategory ( $ category ) ; } foreach ( $ product -> getCustomFields ( ) as $ customField ) { $ customFieldCopy = new ProductCustomField ( ) ; $ customFieldCopy -> setProduct ( $ productCopy ) ; $ customFieldCopy -> setSettingField ( $ customField -> getSettingField ( ) ) ; $ customFieldCopy -> setValue ( $ customField -> getValue ( ) ) ; $ em -> persist ( $ customFieldCopy ) ; $ productCopy -> addCustomField ( $ customFieldCopy ) ; } $ em -> flush ( ) ; return $ this -> redirect ( $ this -> generateUrl ( 'product_show' , array ( "id" => $ productCopy -> getId ( ) ) ) ) ; }
Displays a form to edit an existing CampaignMail entity .
15,423
public function updateAction ( Request $ request , Product $ entity ) { $ em = $ this -> getDoctrine ( ) -> getManager ( ) ; $ entity = $ this -> addProductItemFieldData ( $ entity ) ; if ( ! $ entity ) { throw $ this -> createNotFoundException ( 'Unable to find Product entity.' ) ; } $ deleteForm = $ this -> createDeleteForm ( $ entity -> getId ( ) ) ; $ editForm = $ this -> createEditForm ( $ entity ) ; $ editForm -> handleRequest ( $ request ) ; if ( $ editForm -> isValid ( ) ) { foreach ( $ entity -> getRawMaterials ( ) as $ productRawMaterial ) { $ productRawMaterial -> setProduct ( $ entity ) ; } $ em -> flush ( ) ; return $ this -> redirect ( $ this -> generateUrl ( 'admin_product_show' , array ( 'id' => $ entity -> getId ( ) ) ) ) ; } return array ( 'entity' => $ entity , 'edit_form' => $ editForm -> createView ( ) , 'delete_form' => $ deleteForm -> createView ( ) , ) ; }
Edits an existing Product entity .
15,424
public function showGalleryItemAction ( Product $ product ) { $ entity = $ product -> getMediaGallery ( ) ; if ( ! $ entity ) { throw $ this -> createNotFoundException ( 'Unable to find Gallery entity.' ) ; } $ deleteForm = $ this -> createDeleteForm ( $ product -> getId ( ) ) ; return array ( 'entity' => $ entity , 'product' => $ product , 'delete_form' => $ deleteForm -> createView ( ) , ) ; }
Finds and displays a Gallery entity .
15,425
public function deleteGalleryItemAction ( Request $ request , GalleryItem $ entity ) { $ form = $ this -> createDeleteForm ( $ entity -> getId ( ) ) ; $ form -> handleRequest ( $ request ) ; if ( $ form -> isValid ( ) ) { $ em = $ this -> getDoctrine ( ) -> getManager ( ) ; if ( ! $ entity ) { throw $ this -> createNotFoundException ( 'Unable to find GalleryItem entity.' ) ; } $ em -> remove ( $ entity ) ; $ em -> flush ( ) ; } return $ this -> redirect ( $ this -> generateUrl ( 'admin_product' ) ) ; }
Deletes a GalleryItem entity .
15,426
public function updateGalleryItemPosition ( Request $ request ) { $ em = $ this -> getDoctrine ( ) -> getManager ( ) ; $ posArray = $ request -> get ( 'data' ) ; $ i = 0 ; foreach ( $ posArray as $ item ) { $ entity = $ em -> getRepository ( 'AmulenMediaBundle:GalleryItem' ) -> find ( $ item ) ; $ entity -> setPosition ( $ i ) ; $ i ++ ; } $ em -> flush ( ) ; return new Response ( 'ok' ) ; }
Actualizar la posicion de cada imagen .
15,427
public function addMediaProductAction ( Product $ product , $ type = null ) { if ( $ type == 'type_image_file' ) { return $ this -> redirectToRoute ( 'admin_product_new_image' , array ( 'id' => $ product -> getId ( ) ) ) ; } $ entity = new Media ( ) ; $ entity -> setMediaType ( $ type ) ; $ form = $ this -> mediaCreateCreateForm ( $ entity , $ product ) ; return array ( 'type' => $ type , 'entity' => $ entity , 'product' => $ product , 'form' => $ form -> createView ( ) , ) ; }
Add media .
15,428
public function editMediaAction ( Product $ product , Media $ entity , $ type , Request $ request ) { if ( ! $ entity ) { throw $ this -> createNotFoundException ( 'Unable to find Media entity.' ) ; } $ editForm = $ this -> mediaCreateEditForm ( $ entity , $ product , $ type ) ; return array ( 'entity' => $ entity , 'type' => $ type , 'product' => $ product , 'edit_form' => $ editForm -> createView ( ) , ) ; }
Displays a form to edit an existing Media entity .
15,429
private function mediaCreateEditForm ( Media $ entity , $ product , $ type ) { $ types = $ this -> container -> getParameter ( 'flowcode_media.media_types' ) ; $ class = $ types [ $ entity -> getMediaType ( ) ] [ "class_type" ] ; $ form = $ this -> createForm ( new $ class ( ) , $ entity , array ( 'action' => $ this -> generateUrl ( 'admin_product_media_update' , array ( "product" => $ product -> getId ( ) , 'entity' => $ entity -> getId ( ) , "type" => $ entity -> getMediaType ( ) ) ) , 'method' => 'PUT' , ) ) ; $ form -> add ( 'submit' , 'submit' , array ( 'label' => 'Update' ) ) ; return $ form ; }
Creates a form to edit a Media entity .
15,430
public static function Rxpv ( array $ r , array $ pv , array & $ rpv ) { IAU :: Rxp ( $ r , $ pv [ 0 ] , $ rpv [ 0 ] ) ; IAU :: Rxp ( $ r , $ pv [ 1 ] , $ rpv [ 1 ] ) ; return ; }
- - - - - - - - i a u R x p v - - - - - - - -
15,431
public static function load ( array $ langs , $ lang = null ) { static :: $ langs = $ langs ; static :: $ lang = $ lang ? : key ( $ langs ) ; }
Load langs array
15,432
public function onBeforeNormalization ( BeforeNormalizationEvent $ event ) : void { $ resource = $ event -> getResource ( ) ; if ( ! $ resource instanceof ActionedResourceInterface ) { return ; } $ actions = $ resource -> getActions ( ) ; foreach ( $ actions as $ action ) { if ( ! $ action instanceof SymfonyGrantedAction ) { continue ; } if ( ! $ this -> authorizationChecker -> isGranted ( $ action -> getAttribute ( ) , $ action -> getObject ( ) ) ) { $ resource -> removeAction ( $ action ) ; } } }
Check the grants to actions
15,433
public function addError ( $ error , $ file = __FILE__ , $ line = __LINE__ , $ type = ERROR_INFORMATION , $ log = LOG_SYSTEM ) { if ( $ log != LOG_HISTORY && $ log != LOG_CRONS && $ log != LOG_EVENT ) { if ( Config :: config ( ) [ 'user' ] [ 'debug' ] [ 'log' ] ) { if ( $ log == LOG_SQL ) { $ error = preg_replace ( '#([\t]{2,})#isU' , "" , $ error ) ; } $ data = date ( "d/m/Y H:i:s : " , time ( ) ) . '[' . $ type . '] file ' . $ file . ' / line ' . $ line . ' / ' . $ error ; file_put_contents ( APP_LOG_PATH . $ log . '.log' , $ data . "\n" , FILE_APPEND | LOCK_EX ) ; if ( ( Config :: config ( ) [ 'user' ] [ 'debug' ] [ 'error' ] [ 'error' ] && $ type == ERROR_FATAL ) || ( Config :: config ( ) [ 'user' ] [ 'debug' ] [ 'error' ] [ 'exception' ] == true && $ type == ERROR_EXCEPTION ) || preg_match ( '#Exception#isU' , $ type ) || ( Config :: config ( ) [ 'user' ] [ 'debug' ] [ 'error' ] [ 'fatal' ] == true && $ type == ERROR_ERROR ) ) { if ( CONSOLE_ENABLED == MODE_HTTP ) { echo $ data . "\n<br />" ; } else { echo $ data . "\n" ; } } } } else { file_put_contents ( APP_LOG_PATH . $ log . '.log' , $ error . "\n" , FILE_APPEND | LOCK_EX ) ; } }
add an error in the log
15,434
public function addErrorHr ( $ log = LOG_SYSTEM ) { if ( Config :: config ( ) [ 'user' ] [ 'debug' ] [ 'log' ] ) { file_put_contents ( APP_LOG_PATH . $ log . '.log' , "#################### END OF EXECUTION OF http://" . $ _SERVER [ 'HTTP_HOST' ] . $ _SERVER [ 'REQUEST_URI' ] . " ####################\n" , FILE_APPEND | LOCK_EX ) ; } }
add an hr line in the log
15,435
public function removeUser ( $ user ) { $ username = ( $ user instanceof UserInformation ) ? $ user -> getUsername ( ) : ( string ) $ user ; $ this -> configSource -> set ( 'auth-password/' . $ username , null ) ; return $ this ; }
Add the passed credentials in the database .
15,436
public function parse ( $ data ) { if ( $ this -> state === self :: STATE_UNSENT ) { $ this -> state = self :: STATE_OPENED ; } if ( $ this -> isHeaderComplete ) { $ data = $ this -> parseData ( $ data ) ; } else { $ data = $ this -> parseHeader ( $ data ) ; } if ( $ this -> cursor == $ this -> getLength ( ) + $ this -> headerLength ) { $ this -> state = self :: STATE_DONE ; } return $ data ; }
Parses raw data for this frame
15,437
public function getLength ( ) { $ length = $ this -> length64 ; if ( $ length == 0 ) { $ length = $ this -> length16 ; } if ( $ length == 0 ) { $ length = $ this -> length ; } return $ length ; }
Gets the length of this frame s payload data in bytes
15,438
protected function getHeader ( ) { $ header = '' ; $ fin = $ this -> fin ? 0x80 : 0x00 ; $ rsv1 = $ this -> rsv1 ? 0x40 : 0x00 ; $ rsv2 = $ this -> rsv2 ? 0x20 : 0x00 ; $ rsv3 = $ this -> rsv3 ? 0x10 : 0x00 ; $ byte1 = $ fin | $ rsv1 | $ rsv2 | $ rsv3 | $ this -> opcode ; $ mask = $ this -> isMasked ? 0x80 : 0x00 ; $ byte2 = $ mask | $ this -> length ; $ header .= pack ( 'CC' , $ byte1 , $ byte2 ) ; if ( $ this -> length === 0x7e ) { $ header .= pack ( 's' , $ this -> length16 ) ; } if ( $ this -> length === 0x7f ) { } if ( $ this -> isMasked ) { $ header .= $ this -> mask ; } return $ header ; }
Gets this frame s header as a binary string
15,439
protected function getData ( ) { $ data = $ this -> unmaskedData ; if ( $ this -> isMasked ) { $ data = $ this -> mask ( $ data ) ; } return $ data ; }
Gets the data portion of this frame as a binary string
15,440
protected function parseData ( $ data ) { $ length = mb_strlen ( $ data , '8bit' ) ; if ( $ this -> cursor + $ length > $ this -> getLength ( ) + $ this -> headerLength ) { $ dataLength = $ this -> getLength ( ) - $ this -> cursor + $ this -> headerLength ; } else { $ dataLength = $ length ; } $ data = mb_substr ( $ data , 0 , $ dataLength , '8bit' ) ; $ leftover = mb_substr ( $ data , $ length , $ length - $ dataLength , '8bit' ) ; $ this -> data .= $ data ; if ( $ this -> isMasked ( ) ) { $ this -> unmaskedData .= $ this -> mask ( $ data ) ; } else { $ this -> unmaskedData .= $ data ; } $ this -> cursor += mb_strlen ( $ data , '8bit' ) ; return $ leftover ; }
Parses the data payload of this frame from a raw data stream
15,441
protected function mask ( $ data ) { $ out = '' ; $ length = mb_strlen ( $ data , '8bit' ) ; $ j = ( $ this -> cursor - $ this -> headerLength ) % 4 ; for ( $ i = 0 ; $ i < $ length ; $ i ++ ) { $ data_octet = $ this -> getChar ( $ data , $ i ) ; $ mask_octet = $ this -> getChar ( $ this -> mask , $ j ) ; $ out .= pack ( 'C' , ( $ data_octet ^ $ mask_octet ) ) ; $ j ++ ; if ( $ j >= 4 ) { $ j = 0 ; } } return $ out ; }
Masks data according the the algorithm described in RFC 6455 Section 5 . 3
15,442
public function setLocale ( $ locale ) { if ( $ locale instanceof Locale ) { $ this -> locale = $ locale ; return $ this ; } $ this -> locale = strtolower ( $ locale ) ; return $ this ; }
Sets a locale .
15,443
public function getLocale ( ) { if ( $ this -> locale instanceof Locale ) { return $ this -> locale ; } if ( ! isset ( $ this -> locales [ $ this -> locale ] ) ) { $ this -> locale = 'en' ; } if ( isset ( static :: $ localeInstances [ $ this -> locale ] ) ) { return static :: $ localeInstances [ $ this -> locale ] ; } return static :: $ localeInstances [ $ this -> locale ] = new $ this -> locales [ $ this -> locale ] ; }
Returns a locale instance .
15,444
public function getFormat ( $ name ) { if ( isset ( $ this -> formats [ $ name ] ) ) { return $ this -> formats [ $ name ] ; } return null ; }
Returns a format by name .
15,445
public function setFormatOptions ( array $ options ) { foreach ( $ options as $ name => $ handler ) { $ this -> setFormatOption ( $ name , $ handler ) ; } return $ this ; }
Adds a format options .
15,446
public function setFormatOption ( $ name , callable $ handler ) { if ( in_array ( $ name , static :: $ formatOptionsNames ) ) { return $ this ; } static :: $ formatOptionsNames [ ] = $ name ; static :: $ formatOptionsPlaceholders [ ] = '~' . count ( static :: $ formatOptionsPlaceholders ) . '~' ; static :: $ formatOptionsHandlers [ ] = $ handler ; return $ this ; }
Adds a format option .
15,447
public function format ( $ format = null ) { if ( empty ( $ format ) ) { $ format = $ this -> defaultFormat ; } return $ this -> formatDatetimeObject ( $ format ) ; }
Returns formatting date .
15,448
public static function is ( $ date ) { if ( is_bool ( $ date ) || empty ( $ date ) xor ( $ date === 0 || $ date === '0' ) ) { return false ; } $ date = static :: isTimestamp ( $ date ) ? '@' . ( string ) $ date : $ date ; return ( bool ) date_create ( $ date ) ; }
Validate is date .
15,449
public static function isTimestamp ( $ timestamp ) { if ( is_bool ( $ timestamp ) || ! is_scalar ( $ timestamp ) ) { return false ; } return ( ( string ) ( int ) $ timestamp === ( string ) $ timestamp ) && ( $ timestamp <= PHP_INT_MAX ) && ( $ timestamp >= ~ PHP_INT_MAX ) ; }
Validate is timestamp .
15,450
protected function generateNextMask ( ) { if ( is_null ( $ this -> mask ) ) { $ this -> generateFirstMask ( ) ; return TRUE ; } if ( ! $ this -> generateNextPermutation ( ) ) { return $ this -> addPositive ( ) ; } return TRUE ; }
Generates the next mask .
15,451
protected function generateNextPermutation ( ) { $ number = implode ( '' , $ this -> mask ) ; $ result = LexographicalPermutation :: getNextPermutation ( $ number ) ; if ( $ result !== FALSE ) { $ this -> mask = str_split ( $ result ) ; } return $ result !== FALSE ; }
Generates the next permutation of the current mask .
15,452
protected function generateFirstMask ( ) { $ this -> mask = array_fill ( 0 , $ this -> length , 0 ) ; for ( $ i = 0 ; $ i < $ this -> positivesAmount ; $ i ++ ) { $ this -> mask [ $ this -> length - $ i - 1 ] = 1 ; } }
Generates the very first mask .
15,453
protected function addPositive ( ) { if ( $ this -> positivesAmount >= $ this -> length ) { return FALSE ; } $ this -> positivesAmount ++ ; $ this -> generateFirstMask ( ) ; return TRUE ; }
Adds a positive marker to the mask .
15,454
public static function inArray ( $ needle , $ haystack , $ strict = NULL ) { return static :: is_array ( $ haystack ) && in_array ( $ needle , $ haystack , $ strict ) ; }
Checks if a value exists in an array
15,455
public function loaderModels ( ClassMetadata $ class , $ manager , array $ ids , \ Closure $ stacker ) { $ classOfManagerName = $ class -> getFieldMapping ( $ manager ) ; $ pool = $ this -> manager -> getPool ( ) ; $ methodFind = $ classOfManagerName -> getRepositoryMethod ( ) ; $ repository = $ pool -> getManager ( $ manager ) -> getRepository ( $ classOfManagerName -> getName ( ) ) ; if ( $ methodFind && method_exists ( $ repository , $ methodFind ) ) { foreach ( $ repository -> $ methodFind ( $ ids ) as $ object ) { $ id = $ class -> getIdentifierValue ( $ object ) ; $ stacker ( $ id , $ object ) ; } } else { trigger_error ( sprintf ( 'findOneBy in ModelPersister::loadAll context is depreciate. Define repository-method for "%s" manager model, see mapping for "%s".' , $ manager , $ class -> getName ( ) ) , E_USER_DEPRECATED ) ; $ repository = $ pool -> getManager ( $ manager ) -> getRepository ( $ classOfManagerName -> getName ( ) ) ; $ field = $ class -> getIdentifierReference ( $ manager ) -> field ; foreach ( $ ids as $ id ) { $ object = $ repository -> findOneBy ( array ( $ field => $ id ) ) ; if ( ! $ object ) { continue ; } $ id = $ class -> getIdentifierValue ( $ object , $ manager ) ; $ stacker ( $ id , $ object ) ; } } }
Performed research on the model via their repository .
15,456
protected function getManagersPerCollection ( array $ referenceModels , array $ fields = array ( ) ) { $ this -> collections -> clean ( ) ; if ( empty ( $ fields ) ) { return ; } foreach ( $ this -> class -> getAssociationDefinitions ( ) as $ assoc ) { $ compatible = $ assoc -> getCompatible ( ) ; if ( ! empty ( $ compatible ) && ! in_array ( $ this -> class -> getManagerIdentifier ( ) , $ compatible ) ) { continue ; } foreach ( $ referenceModels as $ referenceModel ) { $ property = $ assoc -> getReferenceField ( $ this -> class -> getManagerIdentifier ( ) ) ; if ( ! in_array ( $ property , $ fields ) ) { continue ; } $ coll = call_user_func ( array ( $ referenceModel , 'get' . ucfirst ( $ property ) ) ) ; if ( null === $ coll || $ assoc -> isMany ( ) && $ coll -> isEmpty ( ) ) { continue ; } $ this -> collections -> append ( new CollectionCenter ( $ assoc , $ this -> manager -> getClassMetadata ( $ assoc -> getTargetMultiModel ( ) ) , $ coll , $ this -> class -> getIdentifierValue ( $ referenceModel ) ) ) ; } } }
Returns list of collection .
15,457
protected function handleCharacter34 ( ) { if ( ! $ this -> inSingleQuotes && $ this -> lastCharacter != 92 ) { $ this -> inQuotes = ! $ this -> inQuotes ; } return true ; }
Handle unescaped double quotes
15,458
protected function handleCharacter39 ( ) { if ( ! $ this -> inQuotes && $ this -> lastCharacter != 92 ) { $ this -> inSingleQuotes = ! $ this -> inSingleQuotes ; } return true ; }
Handle unescaped single quotes
15,459
public function get ( $ key , $ default = null ) { if ( empty ( $ key ) ) { return $ default ; } $ parts = explode ( "." , $ key ) ; $ file = array_shift ( $ parts ) ; if ( ! isset ( $ this -> registry [ $ file ] ) ) { $ this -> registry [ $ file ] = $ this -> discover ( $ file ) ; } $ res = $ this -> parse ( $ key ) ; return is_null ( $ res ) ? $ default : $ res ; }
Returns loaded config option . If the key is not found it checks if registered loaders can find the key .
15,460
public function set ( $ key , $ value ) { if ( empty ( $ key ) ) { throw new Exception ( "Key must be set" ) ; } $ parts = array_reverse ( explode ( "." , $ key ) ) ; $ file = array_pop ( $ parts ) ; if ( ! isset ( $ this -> registry [ $ file ] ) ) { $ this -> registry [ $ file ] = $ this -> discover ( $ file ) ; } foreach ( $ parts as $ part ) { $ value = array ( $ part => $ value ) ; } if ( is_array ( $ this -> registry [ $ file ] ) && ( is_array ( $ value ) ) ) { $ this -> registry [ $ file ] = array_replace_recursive ( $ this -> registry [ $ file ] , $ value ) ; } else { $ this -> registry [ $ file ] = $ value ; } }
Registers a config variable
15,461
protected function discover ( $ resource ) { foreach ( $ this -> loaders as $ loader ) { $ res = $ loader -> load ( $ resource ) ; if ( ! is_null ( $ res ) ) { return $ res ; } } }
Tries to find needed resource by looping each of registered loaders .
15,462
protected function parse ( $ key ) { $ values = $ this -> registry ; $ parts = explode ( "." , $ key ) ; foreach ( $ parts as $ part ) { if ( $ part === "" ) { return $ values ; } if ( ! is_array ( $ values ) || ! array_key_exists ( $ part , $ values ) ) { return ; } $ values = $ values [ $ part ] ; } return $ values ; }
Search for a key with dot notation in the array . If the key is not found NULL is returned
15,463
public function first ( ) { $ path = $ this -> model -> getPath ( 'show' ) ; $ this -> query -> from ( $ path ) ; return $ this -> get ( ) -> first ( ) ; }
Execute a show on the API and get the first result .
15,464
public function get ( ) { $ hasFrom = ! is_null ( $ this -> query -> from ) ; if ( ! $ hasFrom ) { $ path = $ this -> model -> getPath ( 'index' ) ; $ this -> query -> from ( $ path ) ; } $ models = $ this -> getModels ( ) ; return $ this -> model -> newCollection ( $ models ) ; }
Execute an index on the API .
15,465
public function getModels ( ) { $ results = $ this -> query -> get ( ) ; $ connection = $ this -> model -> getConnectionName ( ) ; $ models = [ ] ; foreach ( $ results as $ result ) { $ models [ ] = $ model = $ this -> model -> newFromBuilder ( $ result ) ; $ model -> setConnection ( $ connection ) ; } return $ models ; }
Get the hydrated models .
15,466
public function applyVariables ( $ groups , $ separator = '_' ) { if ( ! is_array ( $ groups ) ) { $ groups = array ( $ groups ) ; } foreach ( $ groups as $ group ) { $ values = $ this -> getVariables ( $ group ) ; $ this -> setEnvironmentVariables ( $ values , $ group , $ separator ) ; } }
Apply group s values as individual plain environment variables .
15,467
public function getVariables ( $ group ) { $ encodedValues = $ this -> getEnvironmentVariable ( $ group ) ; if ( $ encodedValues === null ) { return null ; } return $ this -> decode ( $ encodedValues ) ; }
Decode and decrypt values from a previously set environment variable .
15,468
public function getVariable ( $ group , $ name ) { $ variables = $ this -> getVariables ( $ group ) ; return array_key_exists ( $ name , $ variables ) ? $ variables [ $ name ] : null ; }
Decode and decrypt a single value from a previously set environment variable .
15,469
public function encode ( $ values ) { $ json = json_encode ( $ values ) ; $ this -> handleJsonError ( 'Failed to encode group values to JSON' ) ; return parent :: encode ( $ json ) ; }
Encrypt and encode group values .
15,470
public function decode ( $ value ) { $ json = parent :: decode ( $ value ) ; $ values = json_decode ( $ json , true ) ; $ this -> handleJsonError ( 'Failed to decode group values from JSON' ) ; return $ values ; }
Decode and decrypt group values .
15,471
public function addStack ( StackInterface $ stack ) : ResultInterface { $ this -> stack -> addStack ( $ stack , false ) ; return $ this ; }
Add items to the stack
15,472
final public function process ( BuildInterface $ build ) { $ result = $ this -> checkModified ( $ build ) ; $ this -> frame -> addResult ( $ result ) ; }
abstract process of a modification set .
15,473
public function validate ( & $ msg = null ) { if ( $ this -> frame instanceof ModificationSetInterface ) { return true ; } throw new MalformedConfigException ( $ this -> getName ( ) . ' must be inside of a "modificationset".' ) ; }
Check necessary variables are set .
15,474
public static function date ( $ format = "Y-m-d H:i:s" , $ time = null ) { $ time = ( $ time !== null ? $ time : time ( ) ) ; if ( ! is_numeric ( $ time ) ) { $ time = static :: toUnix ( $ time ) ; } return date ( $ format , $ time ) ; }
Formats the date .
15,475
public static function toUnix ( $ original ) { if ( is_numeric ( $ original ) ) { return $ original ; } if ( preg_match ( "/(?P<year>\d+)-(?P<month>\d+)-(?P<day>\d+) (?P<hour>\d+):(?P<minute>\d+):(?P<second>\d+)/" , $ original , $ match ) ) { return mktime ( $ match [ 'hour' ] , $ match [ 'minute' ] , $ match [ 'second' ] , $ match [ 'month' ] , $ match [ 'day' ] , $ match [ 'year' ] ) ; } elseif ( preg_match ( "/(?P<year>\d+)-(?P<month>\d+)-(?P<day>\d+)/" , $ original , $ match ) ) { return mktime ( 0 , 0 , 0 , $ match [ 'month' ] , $ match [ 'day' ] , $ match [ 'year' ] ) ; } else { return strtotime ( $ original ) ; } }
Converts a datetime timestamp into a unix timestamp .
15,476
public static function agoInWords ( $ original , $ detailed = false ) { if ( ! is_numeric ( $ original ) ) { $ original = static :: toUnix ( $ original ) ; } $ now = time ( ) ; $ chunks = array ( array ( 60 * 60 * 24 * 365 , 'year' , 'years' ) , array ( 60 * 60 * 24 * 30 , 'month' , 'months' ) , array ( 60 * 60 * 24 * 7 , 'week' , 'weeks' ) , array ( 60 * 60 * 24 , 'day' , 'days' ) , array ( 60 * 60 , 'hour' , 'hours' ) , array ( 60 , 'minute' , 'minutes' ) , array ( 1 , 'second' , 'seconds' ) , ) ; $ difference = $ now > $ original ? ( $ now - $ original ) : ( $ original - $ now ) ; for ( $ i = 0 , $ c = count ( $ chunks ) ; $ i < $ c ; $ i ++ ) { $ seconds = $ chunks [ $ i ] [ 0 ] ; $ name = $ chunks [ $ i ] [ 1 ] ; $ names = $ chunks [ $ i ] [ 2 ] ; if ( 0 != $ count = floor ( $ difference / $ seconds ) ) break ; } $ from = Language :: current ( ) -> translate ( "time.x_{$name}" , array ( $ count ) ) ; if ( $ detailed && $ i + 1 < $ c ) { $ seconds2 = $ chunks [ $ i + 1 ] [ 0 ] ; $ name2 = $ chunks [ $ i + 1 ] [ 1 ] ; $ names2 = $ chunks [ $ i + 1 ] [ 2 ] ; if ( 0 != $ count2 = floor ( ( $ difference - $ seconds * $ count ) / $ seconds2 ) ) { $ from = Language :: current ( ) -> translate ( 'time.x_and_x' , $ from , Language :: current ( ) -> translate ( "time.x_{$name2}" , array ( $ count2 ) ) ) ; } } return $ from ; }
Returns time ago in words of the given date .
15,477
private function find ( $ locale , $ dictionary , $ keys ) { if ( ! isset ( $ this -> entries [ $ locale ] [ $ dictionary ] ) ) { if ( ! isset ( $ this -> entries [ $ locale ] ) ) { $ this -> entries [ $ locale ] = [ ] ; } $ file = $ this -> dictionaryFile ( $ dictionary , $ locale ) ; $ this -> entries [ $ locale ] [ $ dictionary ] = $ file !== null && file_exists ( $ file ) ? include $ file : [ ] ; } $ entries = $ this -> entries [ $ locale ] [ $ dictionary ] ; foreach ( $ keys as $ key ) { if ( ! isset ( $ entries [ $ key ] ) ) { return null ; } $ entries = $ entries [ $ key ] ; } return $ entries ; }
Find the translation .
15,478
private function dictionaryFile ( $ dictionary , $ locale ) { $ file = $ this -> languagePath . DIRECTORY_SEPARATOR . $ locale . DIRECTORY_SEPARATOR . $ dictionary . '.php' ; if ( file_exists ( $ file ) ) { return $ file ; } if ( $ this -> manifest === null ) { $ this -> manifest = file_exists ( $ this -> pluginManifestOfLanguages ) ? include $ this -> pluginManifestOfLanguages : [ ] ; } return isset ( $ this -> manifest [ $ locale ] [ $ dictionary ] ) ? base_path ( $ this -> manifest [ $ locale ] [ $ dictionary ] ) : null ; }
Get the full filename of the dictionary .
15,479
public function selectRenderer ( ViewEvent $ e ) { $ model = $ e -> getModel ( ) ; if ( $ model instanceof NewsletterViewModel ) { return $ this -> renderer ; } return false ; }
Detect if we should use the NewsletterRenderer based on model type
15,480
public function formatCode ( string $ code , $ enableColors ) : string { $ block = [ ] ; $ codeLines = explode ( "\n" , $ code ) ; $ this -> enableColors = ( bool ) $ enableColors ; $ this -> numberOfLines = count ( $ codeLines ) ; $ this -> gutterWidth = strlen ( ( string ) $ this -> numberOfLines ) + 1 ; $ i = 0 ; foreach ( $ codeLines as $ lineNumber => $ line ) { $ i += 1 ; $ this -> prepareCodeLine ( $ line , $ block , $ i ) ; } return "\n" . $ this -> colorize ( self :: NORMAL . self :: LIGHT_GRAY_BACKGROUND . self :: WHITE , implode ( "\n" , $ block ) , self :: RED ) ; }
Formats the given code
15,481
public function merge ( MetaData $ data ) : void { foreach ( $ data -> toArray ( ) as $ key => $ value ) { $ this -> set ( $ key , $ value ) ; } }
Merges the given meta data
15,482
protected function isValid ( $ value ) : bool { $ type = gettype ( $ value ) ; switch ( $ type ) { case 'string' : case 'integer' : case 'double' : case 'boolean' : case 'NULL' : return true ; break ; case 'array' : return ArrayCollection :: create ( $ value ) -> every ( function ( $ v ) { return $ this -> isValid ( $ v ) ; } ) ; break ; default : break ; } return false ; }
Checks if a value is valid
15,483
public function getConnection ( ) { if ( null === $ this -> connection ) { $ this -> setConnection ( \ Doctrine_Manager :: getInstance ( ) -> getCurrentConnection ( ) ) ; } return $ this -> connection ; }
Get doctrine connection
15,484
protected function prepeareQuery ( $ value ) { $ query = \ Doctrine_Query :: create ( $ this -> getConnection ( ) ) -> select ( $ this -> getField ( ) ) -> from ( $ this -> getTable ( ) ) -> where ( sprintf ( '%s = ?' , $ this -> getField ( ) ) , $ value ) ; foreach ( $ this -> getExclude ( ) as $ exclude => $ value ) { $ query -> andWhere ( sprintf ( '%s != ?' , $ exclude ) , $ value ) ; } foreach ( $ this -> getInclude ( ) as $ include => $ value ) { $ query -> andWhere ( sprintf ( '%s = ?' , $ include ) , $ value ) ; } return $ query ; }
Prepare validate query
15,485
public function passwordFieldRow ( $ model , $ property , $ htmlOptions = array ( ) , $ validators = NULL ) { $ htmlOptions [ 'value' ] = Cii :: decrypt ( $ model -> $ property ) ; $ htmlOptions [ 'type' ] = 'password' ; $ htmlOptions [ 'id' ] = get_class ( $ model ) . '_' . $ property ; $ htmlOptions [ 'name' ] = get_class ( $ model ) . '[' . $ property . ']' ; echo CHtml :: tag ( 'label' , array ( ) , $ model -> getAttributeLabel ( $ property ) . ( Cii :: get ( $ htmlOptions , 'required' , false ) ? CHtml :: tag ( 'span' , array ( 'class' => 'required' ) , ' *' ) : NULL ) ) ; echo CHtml :: tag ( 'input' , $ htmlOptions ) ; }
passwordFieldRow provides a password box that decrypts the database stored value since it will be encrypted in the db
15,486
public function numberFieldRow ( $ model , $ property , $ htmlOptions = array ( ) , $ validators = NULL ) { if ( $ validators !== NULL ) { foreach ( $ validators as $ k => $ v ) { if ( get_class ( $ v ) == "CNumberValidator" ) { $ htmlOptions [ 'min' ] = $ v -> min ; $ htmlOptions [ 'step' ] = 1 ; } if ( get_class ( $ v ) == "CRequiredValidator" ) $ htmlOptions [ 'required' ] = true ; } } $ htmlOptions [ 'value' ] = $ model -> $ property ; $ htmlOptions [ 'type' ] = 'number' ; $ htmlOptions [ 'id' ] = get_class ( $ model ) . '_' . $ property ; $ htmlOptions [ 'name' ] = get_class ( $ model ) . '[' . $ property . ']' ; echo CHtml :: tag ( 'label' , array ( ) , $ model -> getAttributeLabel ( $ property ) . ( Cii :: get ( $ htmlOptions , 'required' , false ) ? CHtml :: tag ( 'span' , array ( 'class' => 'required' ) , ' *' ) : NULL ) ) ; echo CHtml :: tag ( 'input' , $ htmlOptions ) ; }
numberRow HTML5 number elemtn to work with
15,487
public function rangeFieldRow ( $ model , $ property , $ htmlOptions = array ( ) , $ validators = NULL ) { if ( $ validators !== NULL ) { foreach ( $ validators as $ k => $ v ) { if ( get_class ( $ v ) == "CNumberValidator" ) { $ htmlOptions [ 'min' ] = $ v -> min ; $ htmlOptions [ 'max' ] = $ v -> max ; $ htmlOptions [ 'step' ] = 1 ; } if ( get_class ( $ v ) == "CRequiredValidator" ) $ htmlOptions [ 'required' ] = true ; } } echo CHtml :: tag ( 'label' , array ( ) , $ model -> getAttributeLabel ( $ property ) . ( Cii :: get ( $ htmlOptions , 'required' , false ) ? CHtml :: tag ( 'span' , array ( 'class' => 'required' ) , ' *' ) : NULL ) ) ; echo $ this -> rangeField ( $ model , $ property , $ htmlOptions ) ; echo CHtml :: tag ( 'div' , array ( 'class' => 'output' ) , NULL ) ; }
rangeRow provides a pretty ish range slider with view controls
15,488
private function checkPerfilExists ( $ perfilId ) { $ db = $ this -> db ; $ perfil = $ db -> fetchAssoc ( 'SELECT * FROM singular_perfil WHERE id = ' . $ perfilId ) ; return is_array ( $ perfil ) ? true : false ; }
Verifica se um perfil existe .
15,489
public function registerMinimal ( string $ filePath = null ) { is_file ( $ filePath ) || $ filePath = App :: getBasePath ( ) . $ filePath ; if ( is_file ( $ filePath ) ) { $ configItems = require_once $ filePath ; ! is_array ( $ configItems ) || Config :: items ( $ configItems ) ; ini_set ( 'error_reporting' , Config :: exists ( 'errors.error_reporting' , 0 ) ) ; ini_set ( 'display_errors' , Config :: exists ( 'errors.display_errors' , 0 ) ) ; Event :: dispatch ( 'minimal.loaded.minimal' , [ $ filePath , is_array ( $ configItems ) ? $ configItems : [ ] ] ) ; } }
Registers the minimal config file . It stores the array items from the minimal config file in the Config object and eventually sets the phpini error_reporting and display_errors .
15,490
public function registerConfig ( string $ filePath = null ) { is_file ( $ filePath ) || $ filePath = App :: getBasePath ( ) . $ filePath ; if ( is_file ( $ filePath ) ) { $ configItems = require_once $ filePath ; if ( is_array ( $ configItems ) ) { foreach ( $ configItems as $ key => $ value ) { if ( Config :: exists ( $ key ) ) { Config :: merge ( $ key , $ value ) ; } else { Config :: item ( $ key , $ value ) ; } } } if ( $ value = Config :: exists ( 'errors.error_reporting' , null ) ) { ini_set ( 'error_reporting' , $ value ) ; } if ( $ value = Config :: exists ( 'errors.display_errors' , null ) ) { ini_set ( 'display_errors' , $ value ) ; } Event :: dispatch ( 'minimal.loaded.config' , [ $ filePath , is_array ( $ configItems ) ? $ configItems : [ ] ] ) ; } }
Registers the main config file . It stores the array items from the main config file in the Config object . It will merge recursively with other items in the Config object . It eventually sets the phpini error_reporting and display_errors
15,491
public function get ( string $ key ) { $ result = $ this -> strings [ $ key ] ?? $ key ; if ( is_string ( $ result ) && substr ( $ result , 0 , 2 ) == '@@' ) { $ result = $ this -> get ( substr ( $ result , 2 ) ) ; } if ( $ result == $ key && isset ( $ this -> fallback_language ) ) { $ result = $ this -> fallback_language -> get ( $ key ) ; } return $ result ; }
Returns the string of string of a specific language key or an array of strings flagge as preserved
15,492
public static function create ( $ path = false , $ mode = 0777 ) { if ( $ path && ! self :: isFolder ( dirname ( $ path ) ) && self :: isWritable ( dirname ( $ path ) ) ) { mkdir ( $ path , $ mode ) ; if ( Folder :: isFolder ( $ path ) ) { return true ; } } return false ; }
Create an empty folder .
15,493
public static function find ( $ fileName = false , $ path = false ) { if ( $ fileName ) { if ( ! $ path ) { $ path = __DIR__ ; } if ( self :: isFolder ( $ path ) ) { $ dir = new \ RecursiveDirectoryIterator ( $ path ) ; foreach ( new \ RecursiveIteratorIterator ( $ dir ) as $ filePath ) { if ( $ fileName == basename ( $ filePath ) ) { return $ filePath ; } } } } return false ; }
Find file with a given name inside a given directory .
15,494
public static function get ( $ path = false ) { if ( $ path && self :: isFolder ( $ path ) ) { $ list = array ( ) ; $ tmpList = scandir ( $ path ) ; foreach ( $ tmpList as $ k => $ item ) { if ( $ item != '.' && $ item != '..' && $ item != '.DS_Store' ) { $ list [ ] = $ item ; } } return $ list ; } return false ; }
Get list of all files in a given directory .
15,495
public function getPeopleIdFromFullName ( $ fullName ) { $ result = DB :: table ( 'peoples' ) -> where ( 'first_name' , $ this -> getFirstName ( $ fullName ) ) -> where ( 'middle_name' , $ this -> getMiddleName ( $ fullName ) ) -> where ( 'surname' , $ this -> getLastName ( $ fullName ) ) -> first ( ) ; if ( count ( $ result ) > 0 ) { return $ result -> id ; } return 0 ; }
get the peoples ID from the full name
15,496
public function isAllowedPeopleIdSingleContactDisplay ( $ id ) { if ( $ id == 0 ) { return false ; } $ allowedIDs = Config :: get ( 'lasallecrmcontact.single_contact_display_people_id_allowed' ) ; foreach ( $ allowedIDs as $ allowedID ) { if ( $ allowedID == $ id ) { return true ; } } return false ; }
Is this people ID allowed to be displayed in the single contact display?
15,497
protected function _send ( ) { $ message = $ this -> build_message ( true ) ; if ( empty ( $ this -> config [ 'smtp' ] [ 'host' ] ) or empty ( $ this -> config [ 'smtp' ] [ 'port' ] ) ) { throw new \ FuelException ( 'Must supply a SMTP host and port, none given.' ) ; } $ authenticate = ( empty ( $ this -> smtp_connection ) and ! empty ( $ this -> config [ 'smtp' ] [ 'username' ] ) and ! empty ( $ this -> config [ 'smtp' ] [ 'password' ] ) ) ; $ this -> smtp_connect ( ) ; $ authenticate and $ this -> smtp_authenticate ( ) ; $ this -> smtp_send ( 'MAIL FROM:<' . $ this -> config [ 'from' ] [ 'email' ] . '>' , 250 ) ; foreach ( array ( 'to' , 'cc' , 'bcc' ) as $ list ) { foreach ( $ this -> { $ list } as $ recipient ) { $ this -> smtp_send ( 'RCPT TO:<' . $ recipient [ 'email' ] . '>' , array ( 250 , 251 ) ) ; } } $ this -> smtp_send ( 'DATA' , 354 ) ; $ lines = explode ( $ this -> config [ 'newline' ] , $ message [ 'header' ] . preg_replace ( '/^\./m' , '..$1' , $ message [ 'body' ] ) ) ; foreach ( $ lines as $ line ) { if ( substr ( $ line , 0 , 1 ) === '.' ) { $ line = '.' . $ line ; } fputs ( $ this -> smtp_connection , $ line . $ this -> config [ 'newline' ] ) ; } $ this -> smtp_send ( '.' , 250 ) ; $ this -> pipelining or $ this -> smtp_disconnect ( ) ; return true ; }
Initalted all needed for SMTP mailing .
15,498
protected function smtp_connect ( ) { if ( ! empty ( $ this -> smtp_connection ) ) { return ; } if ( strpos ( $ this -> config [ 'smtp' ] [ 'host' ] , '://' ) === false ) { $ this -> config [ 'smtp' ] [ 'host' ] = 'tcp://' . $ this -> config [ 'smtp' ] [ 'host' ] ; } $ this -> smtp_connection = stream_socket_client ( $ this -> config [ 'smtp' ] [ 'host' ] . ':' . $ this -> config [ 'smtp' ] [ 'port' ] , $ error_number , $ error_string , $ this -> config [ 'smtp' ] [ 'timeout' ] ) ; if ( empty ( $ this -> smtp_connection ) ) { throw new \ SmtpConnectionException ( 'Could not connect to SMTP: (' . $ error_number . ') ' . $ error_string ) ; } $ this -> smtp_get_response ( ) ; try { $ this -> smtp_send ( 'EHLO' . ' ' . \ Input :: server ( 'SERVER_NAME' , 'localhost.local' ) , 250 ) ; } catch ( \ SmtpCommandFailureException $ e ) { $ this -> smtp_send ( 'HELO' . ' ' . \ Input :: server ( 'SERVER_NAME' , 'localhost.local' ) , 250 ) ; } if ( \ Arr :: get ( $ this -> config , 'smtp.starttls' , false ) and strpos ( $ this -> config [ 'smtp' ] [ 'host' ] , 'tcp://' ) === 0 ) { try { $ this -> smtp_send ( 'STARTTLS' , 220 ) ; if ( ! stream_socket_enable_crypto ( $ this -> smtp_connection , true , STREAM_CRYPTO_METHOD_TLS_CLIENT ) ) { throw new \ SmtpConnectionException ( 'STARTTLS failed, Crypto client can not be enabled.' ) ; } } catch ( \ SmtpCommandFailureException $ e ) { throw new \ SmtpConnectionException ( 'STARTTLS failed, invalid return code received from server.' ) ; } try { $ this -> smtp_send ( 'EHLO' . ' ' . \ Input :: server ( 'SERVER_NAME' , 'localhost.local' ) , 250 ) ; } catch ( \ SmtpCommandFailureException $ e ) { $ this -> smtp_send ( 'HELO' . ' ' . \ Input :: server ( 'SERVER_NAME' , 'localhost.local' ) , 250 ) ; } } try { $ this -> smtp_send ( 'HELP' , 214 ) ; } catch ( \ SmtpCommandFailureException $ e ) { } }
Connects to the given smtp and says hello to the other server .
15,499
protected function smtp_authenticate ( ) { $ username = base64_encode ( $ this -> config [ 'smtp' ] [ 'username' ] ) ; $ password = base64_encode ( $ this -> config [ 'smtp' ] [ 'password' ] ) ; try { $ this -> smtp_send ( 'AUTH LOGIN' , 334 ) ; $ this -> smtp_send ( $ username , 334 ) ; $ this -> smtp_send ( $ password , 235 ) ; } catch ( \ SmtpCommandFailureException $ e ) { throw new \ SmtpAuthenticationFailedException ( 'Failed authentication.' ) ; } }
Performs authentication with the SMTP host