idx int64 0 60.3k | question stringlengths 64 4.24k | target stringlengths 5 618 |
|---|---|---|
24,100 | public static function exponent ( $ value , $ scale = null ) { if ( ! extension_loaded ( 'bcmath' ) ) { return $ value ; } $ split = explode ( 'e' , $ value ) ; if ( count ( $ split ) == 1 ) { $ split = explode ( 'E' , $ value ) ; } if ( count ( $ split ) > 1 ) { $ value = bcmul ( $ split [ 0 ] , bcpow ( 10 , $ split [ 1 ] , $ scale ) , $ scale ) ; } return $ value ; } | Changes exponential numbers to plain string numbers Fixes a problem of BCMath with numbers containing exponents |
24,101 | public static function Add ( $ op1 , $ op2 , $ scale = null ) { $ op1 = self :: exponent ( $ op1 , $ scale ) ; $ op2 = self :: exponent ( $ op2 , $ scale ) ; return bcadd ( $ op1 , $ op2 , $ scale ) ; } | BCAdd - fixes a problem of BCMath and exponential numbers |
24,102 | public static function Sub ( $ op1 , $ op2 , $ scale = null ) { $ op1 = self :: exponent ( $ op1 , $ scale ) ; $ op2 = self :: exponent ( $ op2 , $ scale ) ; return bcsub ( $ op1 , $ op2 , $ scale ) ; } | BCSub - fixes a problem of BCMath and exponential numbers |
24,103 | public static function Pow ( $ op1 , $ op2 , $ scale = null ) { $ op1 = self :: exponent ( $ op1 , $ scale ) ; $ op2 = self :: exponent ( $ op2 , $ scale ) ; return bcpow ( $ op1 , $ op2 , $ scale ) ; } | BCPow - fixes a problem of BCMath and exponential numbers |
24,104 | public static function Mul ( $ op1 , $ op2 , $ scale = null ) { $ op1 = self :: exponent ( $ op1 , $ scale ) ; $ op2 = self :: exponent ( $ op2 , $ scale ) ; return bcmul ( $ op1 , $ op2 , $ scale ) ; } | BCMul - fixes a problem of BCMath and exponential numbers |
24,105 | public static function Div ( $ op1 , $ op2 , $ scale = null ) { $ op1 = self :: exponent ( $ op1 , $ scale ) ; $ op2 = self :: exponent ( $ op2 , $ scale ) ; return bcdiv ( $ op1 , $ op2 , $ scale ) ; } | BCDiv - fixes a problem of BCMath and exponential numbers |
24,106 | public static function Sqrt ( $ op1 , $ scale = null ) { $ op1 = self :: exponent ( $ op1 , $ scale ) ; return bcsqrt ( $ op1 , $ scale ) ; } | BCSqrt - fixes a problem of BCMath and exponential numbers |
24,107 | public static function Mod ( $ op1 , $ op2 ) { $ op1 = self :: exponent ( $ op1 ) ; $ op2 = self :: exponent ( $ op2 ) ; return bcmod ( $ op1 , $ op2 ) ; } | BCMod - fixes a problem of BCMath and exponential numbers |
24,108 | public static function Comp ( $ op1 , $ op2 , $ scale = null ) { $ op1 = self :: exponent ( $ op1 , $ scale ) ; $ op2 = self :: exponent ( $ op2 , $ scale ) ; return bccomp ( $ op1 , $ op2 , $ scale ) ; } | BCComp - fixes a problem of BCMath and exponential numbers |
24,109 | public function qbr ( $ table , $ mixed = array ( ) ) { $ mixed [ "Limit" ] = 1 ; $ res = $ this -> qb ( $ table , $ mixed ) ; while ( $ row = DB :: f ( $ res ) ) { return $ row ; } return false ; } | Returns one row from Query Builder |
24,110 | public function get ( $ table , $ where = array ( ) , $ offset = null , $ count = null , $ time = null , $ order = array ( ) , $ od = "ValidFrom" , $ do = "ValidUntil" , $ id2 = "ID" , $ cols = array ( ) , $ groupby = array ( ) , $ having = array ( ) , $ distinct = false , $ fast = false ) { $ data = array ( "QueryBuilder" => array ( "Where" => $ where , "Offset" => $ offset , "Limit" => $ count , "Time" => $ time , "Sort" => $ order , "Cols" => $ cols , "GroupBy" => $ groupby , "Having" => $ having , "Distinct" => $ distinct ) ) ; $ data [ "ApiKeySession" ] = $ this -> Session ; $ data [ "CRC" ] = Client :: MakeCRC ( $ data , $ this -> ApiPass ) ; try { $ results = Client :: Call ( $ this -> Server . "/" . $ table . "/Request" , $ data ) ; return new APIResult ( $ results ) ; } catch ( \ Exception $ exc ) { $ this -> lastError = $ exc -> getMessage ( ) ; if ( self :: $ DEBUG_CRC ) { if ( strpos ( $ this -> lastError , "CRC does not match" ) ) { $ add = "Request failed! Client data: " ; $ add .= \ AsyncWeb \ Api \ REST \ Client :: MakeHashString ( $ data ) ; $ add .= " CRC: " . Client :: MakeCRC ( $ data , $ this -> ApiPass ) ; $ this -> lastError .= "<br>\n" . $ add ; } } return false ; } } | Returns the resource object for the result . Please use fetch method to get the result for each row . |
24,111 | public function save ( AggregateRoot $ root ) { $ snapshot = new Snapshot ( $ root , $ root -> getVersion ( ) , new \ DateTime ) ; $ this -> snapshots [ ( string ) $ root -> getIdentity ( ) ] [ ] = $ snapshot ; } | Save given snapshot |
24,112 | public function createFolderIfNotExists ( $ folderPath ) { if ( file_exists ( $ folderPath ) && is_dir ( $ folderPath ) ) { return ; } $ arrFolder = explode ( DIRECTORY_SEPARATOR , $ folderPath ) ; $ fullPath = "" ; $ first = true ; foreach ( $ arrFolder as $ folder ) { if ( ! $ folder ) { continue ; } if ( ! $ first ) { $ fullPath .= DIRECTORY_SEPARATOR ; } else { $ first = false ; } $ fullPath .= $ folder ; try { $ this -> createSingleFolderIfNotExists ( $ fullPath ) ; } catch ( Exception $ e ) { $ msg = $ e -> getMessage ( ) ; echo "Could not generate folder '" . $ fullPath . "' <br />\n" . $ msg . "<br />" ; } } } | Creates a full folder path |
24,113 | protected function createSingleFolderIfNotExists ( $ fullPath ) { $ tempDir = codemonkey_pathTempDir ; if ( file_exists ( $ tempDir . $ fullPath ) && is_dir ( $ tempDir . $ fullPath ) ) { return ; } mkdir ( $ tempDir . $ fullPath ) ; chmod ( $ tempDir . $ fullPath , 0775 ) ; } | Creates a single folder |
24,114 | public function addExtension ( ExtensionInterface $ extension ) { if ( array_key_exists ( $ name = $ extension -> getName ( ) , $ this -> extensions ) ) { throw new \ RuntimeException ( sprintf ( 'UserExtension "%s" is already registered.' , $ name ) ) ; } $ this -> extensions [ $ name ] = $ extension ; } | Adds the extension . |
24,115 | public function getShowAdminTabs ( UserInterface $ user ) { $ tabs = [ ] ; foreach ( $ this -> extensions as $ name => $ extension ) { if ( null !== $ tab = $ extension -> getAdminShowTab ( $ user ) ) { $ tabs [ $ name ] = $ tab ; } } uasort ( $ tabs , function ( ShowTabInterface $ a , ShowTabInterface $ b ) { if ( $ a -> getPosition ( ) == $ b -> getPosition ( ) ) { return 0 ; } return $ a -> getPosition ( ) > $ b -> getPosition ( ) ? 1 : - 1 ; } ) ; return $ tabs ; } | Returns the show admin tabs . |
24,116 | public function getAccountEntries ( ) { $ entries = [ ] ; foreach ( $ this -> extensions as $ name => $ extension ) { if ( null !== $ e = $ extension -> getAccountMenuEntries ( ) ) { $ entries = array_merge ( $ entries , $ e ) ; } } return $ entries ; } | Returns the account entries . |
24,117 | public function writeContent ( $ content , $ overwrite = false ) { if ( $ overwrite ) { $ fh = fopen ( $ this -> getPath ( ) , 'w' ) ; } else { $ fh = fopen ( $ this -> getPath ( ) , 'w+' ) ; } fwrite ( $ fh , $ content ) ; fclose ( $ fh ) ; } | Writes content to harddrive . |
24,118 | public function set ( $ name , $ value ) { list ( $ group , $ name ) = explode ( '.' , $ name , 2 ) ; \ Kohana :: $ config -> load ( $ group ) -> set ( $ name , $ value ) ; } | Set a kohana config variable |
24,119 | public function getWebfilesAsStream ( ) { $ client = $ this -> getClientWithToken ( ) ; $ service = new Google_Service_Calendar ( $ client ) ; $ optParams = array ( 'maxResults' => 5 , 'orderBy' => 'startTime' , 'singleEvents' => TRUE , 'timeMin' => date ( 'c' ) , ) ; $ results = $ service -> events -> listEvents ( $ this -> m_sCalendarId , $ optParams ) ; $ webfiles = array ( ) ; foreach ( $ results -> getItems ( ) as $ event ) { $ webfile = $ this -> toWebfileEvent ( $ event ) ; array_push ( $ webfiles , $ webfile ) ; } return new MWebfileStream ( $ webfiles ) ; } | Returns a webfiles stream with all webfiles from the actual datastore . |
24,120 | public function query ( $ query , $ return_set = false , $ buffered = true ) { if ( strpos ( ltrim ( $ query ) , 'SELECT ' ) === 0 ) { return $ this -> _Reader -> query ( $ query , $ return_set , $ buffered ) ; } else { return $ this -> _Writer -> query ( $ query , $ return_set , $ buffered ) ; } } | Send a query to the correct SQLEngine |
24,121 | public static function setValue ( array & $ array , $ path , $ value ) { if ( $ path === null ) { $ array = $ value ; return ; } $ keys = \ is_array ( $ path ) ? $ path : \ explode ( '.' , $ path ) ; while ( \ count ( $ keys ) > 1 ) { $ key = \ array_shift ( $ keys ) ; if ( ! isset ( $ array [ $ key ] ) ) { $ array [ $ key ] = [ ] ; } if ( ! \ is_array ( $ array [ $ key ] ) ) { $ array [ $ key ] = [ $ array [ $ key ] ] ; } $ array = & $ array [ $ key ] ; } $ array [ \ array_shift ( $ keys ) ] = $ value ; } | Writes a value into an associative array at the key path specified . If there is no such key path yet it will be created recursively . If the key exists it will be overwritten . |
24,122 | public function verify ( $ content = null , $ refund = false ) : Collection { $ request = Request :: createFromGlobals ( ) ; $ data = $ request -> request -> count ( ) > 0 ? $ request -> request -> all ( ) : $ request -> query -> all ( ) ; $ data = Support :: encoding ( $ data , 'utf-8' , $ data [ 'charset' ] ?? 'gb2312' ) ; Log :: debug ( 'Receive Alipay Request:' , $ data ) ; if ( Support :: verifySign ( $ data , $ this -> config -> get ( 'ali_public_key' ) ) ) { return new Collection ( $ data ) ; } Log :: warning ( 'Alipay Sign Verify FAILED' , $ data ) ; throw new InvalidSignException ( 'Alipay Sign Verify FAILED' , $ data ) ; } | Verfiy sign . |
24,123 | public function removeItem ( ItemInterface $ item ) { foreach ( $ this -> feedItems as $ i => $ feedItem ) { if ( $ feedItem == $ item ) { unset ( $ this -> feedItems [ $ i ] ) ; } } $ this -> feedItems = array_values ( $ this -> feedItems ) ; return $ this ; } | Remove an item from the feed . |
24,124 | public function getUser ( ) { if ( $ this -> isSlave ( ) && ! $ this -> user ) { return $ this -> _master -> getUser ( ) ; } return $ this -> user ; } | Get user . |
24,125 | public function getPort ( ) { if ( $ this -> isSlave ( ) && ! $ this -> port ) { return $ this -> _master -> getPort ( ) ; } return $ this -> port ; } | Get port number . |
24,126 | public function getDatabaseName ( ) { if ( $ this -> isSlave ( ) && ! $ this -> database_name ) { return $ this -> _master -> getDatabaseName ( ) ; } if ( $ this -> driver instanceof SqliteDriver ) { if ( $ this -> isUseMemory ( ) ) { return ':memory:' ; } if ( $ this -> database_dir && $ this -> database_name [ 0 ] !== '/' ) { return $ this -> database_dir . '/' . $ this -> database_name ; } } return $ this -> database_name ; } | Get database name . |
24,127 | public function addSlave ( array $ setting ) { $ database = new Database ( $ setting ) ; $ database -> setMaster ( $ this ) ; $ this -> _slaves [ ] = $ database ; } | Add slave . |
24,128 | public static function IsSingleDepth ( array $ array ) : bool { if ( \ count ( $ array ) < 1 ) { return false ; } foreach ( $ array as $ v ) { if ( \ is_array ( $ v ) && \ count ( $ v ) > 0 ) { return false ; } } return true ; } | Returns if array has only a depth of 1 level . |
24,129 | public static function add ( & $ arr , $ obj , $ prepend = false ) { if ( $ prepend ) { array_unshift ( $ arr , $ obj ) ; } else { array_push ( $ arr , $ obj ) ; } return $ arr ; } | Appends or prepends an object into an array . |
24,130 | public static function fetch ( $ arr , $ descriptors ) { $ args = new ArrArguments ( $ arr ) ; foreach ( $ descriptors as $ name => $ descriptor ) { $ types = array ( ) ; $ default = null ; $ required = false ; if ( is_string ( $ descriptor ) ) { $ types = explode ( "|" , $ descriptor ) ; } elseif ( is_array ( $ descriptor ) ) { $ types = explode ( "|" , Arr :: get ( $ descriptor , "type" ) ) ; $ default = Arr :: get ( $ descriptor , "default" ) ; $ required = Arr :: get ( $ descriptor , "required" , ! Arr :: exist ( $ descriptor , "default" ) ) ; } $ desc = new ArrArgumentsDescriptor ( $ types , $ default , $ required ) ; $ args -> registerDescriptor ( $ name , $ desc ) ; } return $ args -> fetch ( ) ; } | Fetches elements from an array . |
24,131 | public function checkKeyExists ( $ key , $ group , $ allowempty = false ) { if ( ! $ this -> locale || $ this -> locale == '' ) { return false ; } $ data = $ this -> loadDataForGroup ( $ group , $ allowempty ) ; if ( isset ( $ data [ $ key ] ) ) { if ( strpos ( $ data [ $ key ] , 'file:' ) === 0 ) { $ filname = substr ( $ data [ $ key ] , 5 ) ; $ file_path = $ this -> localespath . $ this -> locale . '/files/' . $ filname ; if ( @ file_exists ( $ file_path ) ) { return true ; } return false ; } return true ; } return false ; } | Check if a key exists for a group . Is used for translations management |
24,132 | public function getAllGroups ( ) { if ( $ this -> locale == '' ) { throw new \ Exception ( 'Locale is not set' ) ; } $ folder_path = $ this -> localespath . $ this -> locale . '/' ; if ( ! is_dir ( $ folder_path ) ) { throw new \ Exception ( 'Locale folder not found' ) ; } $ files = @ scandir ( $ folder_path ) ; $ groups = array ( ) ; if ( is_array ( $ files ) ) { foreach ( $ files as $ file ) { if ( is_file ( $ folder_path . $ file ) && strtolower ( pathinfo ( $ folder_path . $ file , PATHINFO_EXTENSION ) ) == 'txt' ) { if ( preg_match ( '!^(.+)\\.txt!i' , $ file , $ m ) ) { $ groups [ ] = $ m [ 1 ] ; } } } } return $ groups ; } | Get array of all groups for current locale |
24,133 | public function getDataForGroup ( $ group , $ includeemptykeys = true ) { if ( $ this -> locale == '' ) { throw new \ Exception ( 'Locale is not set' ) ; } $ groupkeys = $ this -> loadDataForGroup ( $ group , $ includeemptykeys ) ; if ( ! $ groupkeys ) { throw new \ Exception ( 'Group is not found' ) ; } return $ groupkeys ; } | Return list of all keys for a group with values |
24,134 | static function select ( $ name , array $ values , $ val , $ text , $ selected , $ padrao = null , $ attr = array ( ) ) { $ html = '<select ' ; $ attr = array_merge ( array ( "name" => $ name ) , $ attr ) ; $ html .= self :: getAttributes ( $ attr ) ; $ html .= ">" ; if ( $ padrao != null ) $ html .= '<option value="">' . $ padrao . '</option>' ; foreach ( $ values as $ value ) { if ( isset ( $ value -> $ val ) and isset ( $ value -> $ text ) ) $ html .= '<option value="' . $ value -> $ val . '" ' . ( $ value -> $ val == $ selected ? " selected " : "" ) . '>' . $ value -> $ text . '</option>' ; } $ html .= "</select>" ; echo $ html ; } | Cria um select Html |
24,135 | static function ValidateSummary ( ) { $ erros = ModelState :: getErrors ( ) ; if ( count ( $ erros ) > 0 ) : $ html = '<ul class="validate-summary">' ; foreach ( $ erros as $ erro ) { $ html .= '<li>' . $ erro . '</li>' ; } $ html .= '</ul>' ; echo $ html ; endif ; } | ValidateSumary - Exibe os erros do modelstate na tela |
24,136 | private static function getAttributes ( $ attr ) { $ html = "" ; foreach ( $ attr as $ key => $ value ) { $ html .= $ key . '="' . $ value . '" ' ; } return $ html ; } | Pega os atributos |
24,137 | private static function input ( $ name , $ value , $ attr = array ( ) ) { $ html = '<input ' ; $ attr = array_merge ( array ( "value" => $ value , "name" => $ name ) , $ attr ) ; $ html .= self :: getAttributes ( $ attr ) ; $ html .= " />" ; echo $ html ; } | Cria os inputs |
24,138 | public function addEventListener ( EventListenerInterface $ eventListener , string $ payloadName ) : EventPublisher { $ this -> eventListeners [ $ payloadName ] [ ] = $ eventListener ; return $ this ; } | Add event listener . |
24,139 | public static function getEnvironment ( $ id ) { if ( ! array_key_exists ( $ id , self :: $ environments ) ) throw new \ InvalidArgumentException ( "Environment with ID $id does not exists" ) ; return self :: $ environments [ $ id ] ; } | Obtains a dynamic SQL environment instance by ID |
24,140 | public static function buildEnvironment ( $ id , $ classname ) { if ( ! is_string ( $ id ) || empty ( $ id ) ) throw new \ InvalidArgumentException ( "Environment id must be defined as a valid string" ) ; if ( ! is_string ( $ classname ) || empty ( $ classname ) ) throw new \ InvalidArgumentException ( "Parameter is not a valid environment class" ) ; elseif ( ! class_exists ( $ classname , true ) ) throw new \ InvalidArgumentException ( "Environment class $classname was not found" ) ; $ rc = new \ ReflectionClass ( $ classname ) ; if ( ! $ rc -> isSubclassOf ( 'eMapper\Dynamic\Environment\DynamicSQLEnvironment' ) && $ classname != 'eMapper\Dynamic\Environment\DynamicSQLEnvironment' ) throw new \ InvalidArgumentException ( "Class $classname is not a valid environment class" ) ; self :: $ environments [ $ id ] = new $ classname ( ) ; return true ; } | Generates a new environment |
24,141 | public static function parseGetterName ( $ getterName ) { if ( false !== $ pos = strpos ( $ getterName , 'get' ) ) $ getterName = substr ( $ getterName , 3 ) ; return strtolower ( $ getterName ) ; } | Returns name of getter without get |
24,142 | public function getRenderedPublished ( ) { $ rendered = $ this -> getRenderedContent ( ) ; if ( $ rendered instanceof Content ) { return DateTime :: max ( $ rendered -> publishedFrom , $ rendered -> created ) ; } return null ; } | Get published date |
24,143 | public function setRootCreated ( $ value ) { $ content = $ this -> getDependentContent ( ) ; if ( $ content ) { $ content -> created = $ value ; } return $ this ; } | Set root s created time |
24,144 | public function setRootUserId ( $ value ) { $ content = $ this -> getDependentContent ( ) ; if ( $ content ) { $ content -> userId = $ value ; } return $ this ; } | Set root s user - id |
24,145 | public static function _init ( ) { \ Config :: load ( 'session' , true ) ; if ( \ Config :: get ( 'session.auto_initialize' , true ) ) { static :: instance ( ) ; } if ( \ Config :: get ( 'session.native_emulation' , false ) ) { session_set_save_handler ( function ( $ savePath , $ sessionName ) { } , function ( ) { } , function ( $ sessionId ) { $ _SESSION = \ Session :: get ( ) ; $ _SESSION [ '__org' ] = $ _SESSION ; } , function ( $ sessionId , $ data ) { $ org = isset ( $ _SESSION [ '__org' ] ) ? $ _SESSION [ '__org' ] : array ( ) ; unset ( $ _SESSION [ '__org' ] ) ; if ( $ remove = array_diff_key ( $ org , $ _SESSION ) ) { \ Session :: delete ( array_keys ( $ remove ) ) ; } empty ( $ _SESSION ) or \ Session :: set ( $ _SESSION ) ; } , function ( $ sessionId ) { \ Session :: destroy ( ) ; } , function ( $ lifetime ) { } ) ; } } | Initialize by loading config & starting default session |
24,146 | public function setLayoutId ( $ layoutId ) { $ this -> _layout = null ; $ this -> layoutId = ( ( int ) $ layoutId ) ? : null ; return $ this ; } | Set layout - id |
24,147 | function getTags ( ) { if ( $ this -> getRenderedMetaContent ( ) instanceof TagsAwareInterface ) { return array_unique ( array_merge ( parent :: getTags ( ) , $ this -> getRenderedMetaContent ( ) -> getTags ( ) ) ) ; } return parent :: getTags ( ) ; } | Get tags of the paragraph |
24,148 | function getTagIds ( ) { if ( $ this -> getRenderedMetaContent ( ) instanceof TagsAwareInterface ) { return array_unique ( array_merge ( parent :: getTagIds ( ) , $ this -> getRenderedMetaContent ( ) -> getTagIds ( ) ) ) ; } return parent :: getTagIds ( ) ; } | Get tag ids of the paragraph |
24,149 | function getLocaleTags ( ) { if ( $ this -> getRenderedMetaContent ( ) instanceof TagsAwareInterface ) { return array_unique ( array_merge ( parent :: getLocaleTags ( ) , $ this -> getRenderedMetaContent ( ) -> getLocaleTags ( ) ) ) ; } return parent :: getLocaleTags ( ) ; } | Get locale - tags of the paragraph |
24,150 | public function populateBlockVariables ( ) { foreach ( $ this -> block -> getVariables ( ) as $ variable ) { $ this -> setBlockVariable ( $ variable -> getName ( ) , $ this -> methodService -> call ( $ variable -> getMethodArgument ( ) ) ) ; } } | Sets the blocks viewVariables where the keys are the BlockVariableDocument names and the values are the return of the associated method |
24,151 | public function getFilterBagFromExpression ( $ filtersExpression ) { $ parser = new Parser ( $ filtersExpression ) ; $ filtersAST = $ parser -> getAST ( ) ; $ filterBag = new FilterBag ( ) ; $ filterBag -> set ( 'filter_' . md5 ( $ filtersExpression ) , $ filtersAST ) ; return $ filterBag ; } | Build a FilterBag object by parsing the given filters expression |
24,152 | public static function textarea ( string $ name = '' , $ value = '' , array $ attributes = [ ] ) : string { $ defaultAttributes = [ 'method-get' => false , 'cols' => 20 , 'rows' => 40 , 'class' => 'form-textarea' ] ; $ userAttributes = \ array_merge ( $ defaultAttributes , $ attributes ) ; $ attributes = [ ] ; $ attributes [ 'name' ] = $ userAttributes [ 'method-get' ] === false ? \ sprintf ( 'MFVARS[%s]' , $ name ) : $ name ; $ attributes [ 'id' ] = isset ( $ userAttributes [ 'id' ] ) ? $ userAttributes [ 'id' ] : $ name ; $ userAttributes = static :: clearAttributes ( $ userAttributes , [ 'method-get' , 'id' ] ) ; return Tags :: textarea ( $ value , \ array_merge ( $ attributes , $ userAttributes ) ) ; } | This method returns textarea controll |
24,153 | private function pushEvent ( $ collection , $ eventDetails ) { $ event = new Event ( $ eventDetails ) ; return $ this -> client -> pushEvent ( $ collection , $ event -> getDetails ( ) ) ; } | Push an event to the API client . |
24,154 | public function add ( Money $ other ) : Money { $ this -> guardCurrency ( $ other ) ; $ amount = $ this -> amount + $ other -> amount ; $ this -> guardAmountInBounds ( $ amount ) ; return $ this -> withAmount ( $ amount ) ; } | Creates instance that adds the given monetary value |
24,155 | public function subtract ( Money $ other ) : Money { $ this -> guardCurrency ( $ other ) ; $ amount = $ this -> amount - $ other -> amount ; $ this -> guardAmountInBounds ( $ amount ) ; return $ this -> withAmount ( $ amount ) ; } | Creates instance that subtracts the given monetary value |
24,156 | public function multiply ( $ multiplier , ? RoundingMode $ mode = null ) : Money { if ( $ mode === null ) { $ mode = RoundingMode :: HALF_UP ( ) ; } $ this -> guardOperand ( $ multiplier ) ; $ amount = round ( $ this -> amount * $ multiplier , 0 , $ mode -> value ( ) ) ; $ amount = $ this -> castToInteger ( $ amount ) ; return $ this -> withAmount ( $ amount ) ; } | Creates instance that multiplies this value by the given value |
24,157 | public function divide ( $ divisor , ? RoundingMode $ mode = null ) : Money { if ( $ mode === null ) { $ mode = RoundingMode :: HALF_UP ( ) ; } $ this -> guardOperand ( $ divisor ) ; if ( $ divisor === 0 || $ divisor === 0.0 ) { throw new DomainException ( 'Division by zero' ) ; } $ amount = round ( $ this -> amount / $ divisor , 0 , $ mode -> value ( ) ) ; $ amount = $ this -> castToInteger ( $ amount ) ; return $ this -> withAmount ( $ amount ) ; } | Creates instance that divides this value by the given value |
24,158 | public function allocate ( array $ ratios ) : array { $ total = array_sum ( $ ratios ) ; $ remainder = $ this -> amount ; $ shares = [ ] ; foreach ( $ ratios as $ ratio ) { $ amount = $ this -> castToInteger ( $ this -> amount * $ ratio / $ total ) ; $ shares [ ] = $ this -> withAmount ( $ amount ) ; $ remainder -= $ amount ; } for ( $ i = 0 ; $ i < $ remainder ; $ i ++ ) { $ shares [ $ i ] = $ this -> withAmount ( $ shares [ $ i ] -> amount + 1 ) ; } return $ shares ; } | Allocates the money according to a list of ratios |
24,159 | public function split ( int $ num ) : array { if ( $ num <= 0 ) { $ message = sprintf ( '%s expects $num to be greater than zero' , __METHOD__ ) ; throw new DomainException ( $ message ) ; } $ amount = $ this -> castToInteger ( $ this -> amount / $ num ) ; $ remainder = $ this -> amount % $ num ; $ shares = [ ] ; for ( $ i = 0 ; $ i < $ num ; $ i ++ ) { $ shares [ ] = $ this -> withAmount ( $ amount ) ; } for ( $ i = 0 ; $ i < $ remainder ; $ i ++ ) { $ shares [ $ i ] = $ this -> withAmount ( $ shares [ $ i ] -> amount + 1 ) ; } return $ shares ; } | Allocates the money among a given number of targets |
24,160 | protected function guardOperand ( $ operand ) : void { if ( ! is_int ( $ operand ) && ! is_float ( $ operand ) ) { $ message = sprintf ( 'Operand must be an integer or float; received (%s) %s' , gettype ( $ operand ) , VarPrinter :: toString ( $ operand ) ) ; throw new DomainException ( $ message ) ; } } | Validates monetary operand is an integer or float |
24,161 | public function onBeforeInit ( ) { $ disallowed_controllers = [ DevelopmentAdmin :: class , DevBuildController :: class , DatabaseAdmin :: class ] ; if ( ! in_array ( get_class ( $ this -> owner ) , $ disallowed_controllers ) ) { $ config = SiteConfig :: current_site_config ( ) ; i18n :: set_locale ( $ config -> SiteLocale ) ; $ number_format = new NumberFormatter ( $ config -> SiteLocale , NumberFormatter :: CURRENCY ) ; $ symbol = $ number_format -> getSymbol ( NumberFormatter :: CURRENCY_SYMBOL ) ; DBCurrency :: config ( ) -> currency_symbol = $ symbol ; } } | Customise the default silverstripe locale config |
24,162 | public function getModule ( ) { $ method = ArrayHelper :: getValue ( $ this -> parentWidget -> settings , 'queryRole' , 'all' ) ; $ relationship = ArrayHelper :: getValue ( $ this -> parentWidget -> settings , 'relationship' , false ) ; if ( $ method === 'children' ) { return $ relationship -> child ; } elseif ( $ method === 'parents' ) { return $ relationship -> parent ; } return false ; } | Get module . |
24,163 | public function getChildren ( ) { if ( isset ( $ this -> relations [ 'children' ] ) ) { return $ this -> relations [ 'children' ] ; } $ children = $ this -> getAttribute ( 'children' ) ; return $ children === null ? [ ] : $ children ; } | Returns the childs of this node |
24,164 | public function getLevel ( ) { if ( $ this -> _level !== null ) { return $ this -> _level ; } if ( $ this -> isRoot ( ) ) { $ this -> _level = - 1 ; return $ this -> _level ; } $ parents = array ( $ this ) ; $ node = $ this ; while ( $ parent = $ node -> getParent ( ) ) { if ( ! $ parent -> isRoot ( ) ) { $ parents [ ] = $ parent ; } $ node = $ parent ; } $ this -> _level = count ( $ parents ) ; return $ this -> _level ; } | Returns the level of this node |
24,165 | public function convert ( $ markdown ) { $ root = new Container ( ) ; $ this -> inlineParser = new InlineParser ( $ this -> links , $ this -> titles ) ; $ parser = $ this -> buildParserStack ( ) ; $ text = new Text ( $ markdown ) ; $ this -> prepare ( $ text ) ; $ parser -> parseBlock ( $ text , $ root ) ; $ this -> inlineParser -> parse ( ) ; return $ root ; } | Parse the given Markdown text into a document tree . |
24,166 | protected function prepare ( Text $ text ) { $ text -> replaceString ( "\r\n" , "\n" ) ; $ text -> replaceString ( "\r" , "\n" ) ; $ text -> replace ( '/(.*?)\t/' , function ( Text $ whole , Text $ string ) { $ tabWidth = 4 ; return $ string . str_repeat ( ' ' , $ tabWidth - $ string -> getLength ( ) % $ tabWidth ) ; } ) ; } | Preprocess the text . |
24,167 | public function includeBlock ( $ blockName ) { $ blockName = str_replace ( '/' , DIRECTORY_SEPARATOR , $ blockName ) ; $ blockContent = '' ; $ blockFile = BASE_PATH . DIRECTORY_SEPARATOR . 'storage' . DIRECTORY_SEPARATOR . 'share' . DIRECTORY_SEPARATOR . 'layout' . DIRECTORY_SEPARATOR . $ blockName . '.' . $ this -> config [ 'templateExtension' ] ; if ( file_exists ( $ blockFile ) ) { $ templateTmp = file_get_contents ( $ blockFile ) ; preg_match_all ( "~\{\{\s*(.*?)\s*\}\}~" , $ templateTmp , $ block ) ; foreach ( $ block [ 1 ] as $ k => $ v ) { if ( $ v === 'php' ) { $ templateTmp = str_replace ( '{{php}}' , '<?php' , $ templateTmp ) ; } elseif ( $ v === '/php' ) { $ templateTmp = str_replace ( '{{/php}}' , '?>' , $ templateTmp ) ; } else { $ blockTemplate = $ this -> includeBlock ( $ v ) ; $ templateTmp = str_replace ( '{{' . $ v . '}}' , $ blockTemplate , $ templateTmp ) ; } } $ blockContent = $ templateTmp ; } else { $ blockContent = 'FILE NOT FOUND (' . $ blockFile . ')' ; } return $ blockContent ; } | Include Block Layout |
24,168 | public function includeFile ( $ templateFile = '' ) { if ( ! empty ( $ templateFile ) ) { str_replace ( '/' , DIRECTORY_SEPARATOR , $ templateFile ) ; if ( file_exists ( $ this -> appPath . DIRECTORY_SEPARATOR . $ templateFile ) ) { require_once $ this -> appPath . DIRECTORY_SEPARATOR . $ templateFile ; } } } | Include other file |
24,169 | protected static function bootTraits ( ) { foreach ( class_uses_recursive ( get_called_class ( ) ) as $ trait ) { if ( method_exists ( get_called_class ( ) , $ method = 'boot' . class_basename ( $ trait ) ) ) { forward_static_call ( [ get_called_class ( ) , $ method ] ) ; } } } | Boot all of the bootable traits on the ServiceProvider . |
24,170 | protected function getPageTitles ( $ SHDObject ) { $ titles = array ( ) ; foreach ( $ SHDObject -> find ( '.compTitle h3.title' ) as $ object ) { $ titleText = $ object -> innertext ; $ titles [ ] = $ this -> cleanText ( $ titleText ) ; } return $ this -> normalizeResult ( $ titles ) ; } | Get all titles for a given Yahoo SERP page . |
24,171 | protected function getPageSnippets ( $ SHDObject ) { $ snippets = array ( ) ; foreach ( $ SHDObject -> find ( '.aAbs' ) as $ object ) { $ snippetText = $ this -> cleanText ( $ object -> innertext ) ; $ snippets [ ] = $ this -> fixRepeatedSpace ( $ snippetText ) ; } return $ this -> normalizeResult ( $ snippets ) ; } | Get all snippets for a given Yahoo SERP page . |
24,172 | public function interpretAttribute ( $ attribute , $ index = null ) { if ( $ index ) { $ availables = $ this -> getInterpretations ( ) ; if ( isset ( $ availables [ $ index ] ) ) { return $ availables [ $ index ] -> { $ attribute } ; } } $ current = $ this -> getCurrentInterpretation ( ) ; if ( $ current ) { return $ current -> { $ attribute } ; } return null ; } | Retrieves attribute interpretation for current hasMany relation |
24,173 | public function getInterpretations ( $ data = null ) { $ condition = [ $ this -> relPrimaryKey => $ this -> owner -> primaryKey ] ; $ restriction = $ this -> _getRestriction ( $ data , $ this -> relSecondaryKey , false ) ; if ( $ restriction ) { $ condition = ArrayHelper :: merge ( $ condition , $ restriction ) ; } return ArrayHelper :: merge ( $ this -> viaModel -> find ( ) -> where ( $ condition ) -> andWhere ( [ 'not in' , $ this -> relSecondaryKey , array_keys ( $ this -> _relationsToSave ) ] ) -> indexBy ( $ this -> relSecondaryKey ) -> all ( ) , $ this -> _relationsToSave ) ; } | Retrieves interpretations based on gived data |
24,174 | public function setInterpretations ( $ data ) { if ( $ data && ArrayHelper :: getValue ( $ data , $ this -> viaModel -> formName ( ) , false ) ) { $ data = $ this -> pushSecondaryKeys ( $ data , $ this -> viaModel -> formName ( ) ) ; $ this -> _relationsToSave = $ this -> pushMissingInterpretations ( $ this -> getInterpretations ( $ data ) , $ data ) ; if ( $ this -> _relationsToSave ) { $ this -> viaModel -> loadMultiple ( $ this -> _relationsToSave , $ data , $ this -> viaModel -> formName ( ) ) ; $ this -> _removeDisabledRelations ( ) ; } } return $ this ; } | Sets specific model relations attributes |
24,175 | public function getAllInterpretations ( ) { $ hash = $ this -> _getInterpreterHash ( ) ; if ( ! $ this -> allowCache || empty ( $ this -> _allInterpretations [ $ hash ] ) ) { $ this -> _allInterpretations [ $ hash ] = $ this -> pushMissingInterpretations ( $ this -> getInterpretations ( ) ) ; } return $ this -> _allInterpretations [ $ hash ] ; } | Retrieves all possible hasMany relation models for owner . |
24,176 | public function setAllInterpretations ( $ data ) { $ model = $ this -> viaModel ; $ this -> _relationsToSave = $ this -> getAllInterpretations ( ) ; $ model :: loadMultiple ( $ this -> _relationsToSave , $ data ) ; return $ this ; } | Sets all model relations attributes |
24,177 | protected function pushSecondaryKeys ( $ data , $ form ) { if ( isset ( $ data [ $ form ] ) && is_array ( $ data [ $ form ] ) ) { foreach ( $ data [ $ form ] as $ secondaryKey => $ values ) { $ data [ $ form ] [ $ secondaryKey ] [ $ this -> relSecondaryKey ] = $ secondaryKey ; } } return $ data ; } | Pushes secondary keys to given data |
24,178 | protected function pushMissingInterpretations ( $ availables , $ data = null ) { $ secondaryModel = new $ this -> relSecondary -> modelClass ; $ queryModel = $ secondaryModel -> find ( ) ; $ restriction = $ this -> _getRestriction ( $ data , $ this -> _getPrimaryKeyName ( $ secondaryModel ) ) ; $ viaRestriction = ArrayHelper :: remove ( $ restriction , $ this -> relSecondaryKey , false ) ; if ( false !== $ viaRestriction ) { $ restriction [ $ this -> _getPrimaryKeyName ( $ secondaryModel ) ] = $ viaRestriction ; } if ( $ restriction ) { $ queryModel -> where ( $ restriction ) ; } foreach ( $ queryModel -> all ( ) as $ secondary ) { if ( ! isset ( $ availables [ $ secondary -> primaryKey ] ) ) { $ availables [ $ secondary -> primaryKey ] = $ this -> _createInterpretation ( $ secondary -> primaryKey ) ; } } ksort ( $ availables ) ; return $ availables ; } | Default method for getting all owner s possible hasMany relation models . This can be overloaded and changed in owner s model class . |
24,179 | private function _getRestriction ( $ data , $ secodaryKey , $ allowGlobal = true ) { $ restriction = [ ] ; if ( $ data ) { $ restriction [ $ secodaryKey ] = $ this -> _getSecondaryKeys ( $ data , $ this -> viaModel -> formName ( ) ) ; } if ( $ allowGlobal && $ this -> restriction ) { $ restriction = ArrayHelper :: merge ( $ restriction , $ this -> restriction ) ; } return $ restriction ; } | Parses and retrieves keys from given data |
24,180 | private function _getSecondaryKeys ( $ data , $ key = null ) { if ( $ key ) { $ data = ArrayHelper :: getValue ( $ data , $ key , [ ] ) ; } return ArrayHelper :: getColumn ( $ data , $ this -> relSecondaryKey ) ; } | Retrieves secondary keys |
24,181 | private function _getPrimaryKeyName ( \ yii \ db \ ActiveRecord $ model , $ composite = false ) { $ primaryKey = $ model -> primaryKey ( ) ; if ( ! $ composite && count ( $ primaryKey ) > 1 ) { throw new Exception ( 'Model has composit key which is not allowed. Relations cannot be established' ) ; } return array_shift ( $ primaryKey ) ; } | Retrieves primary key name |
24,182 | private function _createInterpretation ( $ secondaryKey ) { $ model = new $ this -> viaModel ; $ model -> { $ this -> relPrimaryKey } = $ this -> owner -> primaryKey ; $ model -> { $ this -> relSecondaryKey } = $ secondaryKey ; return $ model ; } | Creates new interpretation and assigns it with owner |
24,183 | private function _loadInterpreterConfig ( $ config ) { if ( count ( $ config ) < 3 ) { throw new \ yii \ base \ Exception ( \ Yii :: t ( 'ib' , 'Invalid config for interpreter. Missing required keys.' ) ) ; } $ this -> viaModel = new $ config [ self :: INDEX_VIA_CLASS ] ; if ( isset ( $ config [ self :: INDEX_VIA_CURRENT ] ) ) { $ this -> viaCurrent = $ config [ self :: INDEX_VIA_CURRENT ] ; } $ this -> relPrimary = $ this -> viaModel -> getRelation ( $ config [ self :: INDEX_REL_PRIMARY ] ) ; $ this -> relSecondary = $ this -> viaModel -> getRelation ( $ config [ self :: INDEX_REL_SECONDARY ] ) ; $ this -> relPrimaryKey = array_pop ( $ this -> relPrimary -> link ) ; $ this -> relSecondaryKey = array_pop ( $ this -> relSecondary -> link ) ; } | Loads interpreter config |
24,184 | private function _removeDisabledRelations ( ) { if ( ! $ this -> attrActive ) { return false ; } foreach ( $ this -> _relationsToSave as $ key => $ rel ) { if ( ! isset ( $ rel -> { $ this -> attrActive } ) ) { continue ; } if ( ! $ rel -> validate ( ) && ! $ rel -> { $ this -> attrActive } ) { ArrayHelper :: remove ( $ this -> _relationsToSave , $ key ) ; } } return true ; } | Removed disabled relations when are not valid |
24,185 | private function extractNumeroFromAdresseString ( $ strAdresse = "" ) { $ retour = "" ; for ( $ i = 0 ; $ i < pia_strlen ( $ strAdresse ) ; $ i ++ ) { if ( ! is_numeric ( pia_substr ( $ strAdresse , $ i , 1 ) ) ) { $ retour .= pia_substr ( $ strAdresse , $ i , 1 ) ; } } return $ retour ; } | fonction qui renvoi enleve les numeros de rue des chaines de caracteres d adresses |
24,186 | public function getUrlImageFrom ( $ idAdresse = 0 , $ format = 'mini' , $ sqlWhere = '' ) { $ url = "" ; $ dateUpload = "" ; $ idHistoriqueImage = "" ; $ string = new stringObject ( ) ; $ req = "SELECT hi1.idHistoriqueImage as idHistoriqueImage, hi1.dateUpload as dateUpload,ha1.idAdresse as idAdresse,ha1.numero as numero, r.nom as nomRue, sq.nom as nomSousQuartier, q.nom as nomQuartier, v.nom as nomVille, p.nom as nomPays, ha1.numero as numeroAdresse, ha1.idRue, r.prefixe as prefixeRue, IF (ha1.idSousQuartier != 0, ha1.idSousQuartier, r.idSousQuartier) AS idSousQuartier, IF (ha1.idQuartier != 0, ha1.idQuartier, sq.idQuartier) AS idQuartier, IF (ha1.idVille != 0, ha1.idVille, q.idVille) AS idVille, IF (ha1.idPays != 0, ha1.idPays, v.idPays) AS idPays FROM historiqueImage hi2, historiqueImage hi1 RIGHT JOIN _adresseEvenement ae ON ae.idAdresse = '" . $ idAdresse . "' RIGHT JOIN _evenementEvenement ee ON ee.idEvenement = ae.idEvenement RIGHT JOIN _evenementImage ei ON ei.idEvenement = ee.idEvenementAssocie RIGHT JOIN evenements he1 ON he1.idEvenement=ee.idEvenementAssocie RIGHT JOIN evenements he2 ON he2.idEvenement = he1.idEvenement RIGHT JOIN historiqueAdresse ha1 ON ha1.idAdresse = ae.idAdresse RIGHT JOIN historiqueAdresse ha2 ON ha2.idAdresse = ha1.idAdresse LEFT JOIN rue r ON r.idRue = ha1.idRue LEFT JOIN sousQuartier sq ON sq.idSousQuartier = IF(ha1.idRue='0' and ha1.idSousQuartier!='0' ,ha1.idSousQuartier ,r.idSousQuartier ) LEFT JOIN quartier q ON q.idQuartier = IF(ha1.idRue='0' and ha1.idSousQuartier='0' and ha1.idQuartier!='0' ,ha1.idQuartier ,sq.idQuartier ) LEFT JOIN ville v ON v.idVille = IF(ha1.idRue='0' and ha1.idSousQuartier='0' and ha1.idQuartier='0' and ha1.idVille!='0' ,ha1.idVille ,q.idVille ) LEFT JOIN pays p ON p.idPays = IF(ha1.idRue='0' and ha1.idSousQuartier='0' and ha1.idQuartier='0' and ha1.idVille='0' and ha1.idPays!='0' ,ha1.idPays ,v.idPays ) WHERE hi2.idImage = hi1.idImage AND hi1.idImage = ei.idImage " . $ sqlWhere . " GROUP BY hi1.idImage,he1.idEvenement,ha1.idAdresse, hi1.idHistoriqueImage, ha1.idHistoriqueAdresse HAVING hi1.idHistoriqueImage = max(hi2.idHistoriqueImage) AND ha1.idHistoriqueAdresse = max(ha2.idHistoriqueAdresse) LIMIT 1" ; $ res = $ this -> connexionBdd -> requete ( $ req ) ; $ url = '' ; $ dateUpload = '' ; $ idHistoriqueImage = 0 ; if ( mysql_num_rows ( $ res ) == 1 ) { $ fetchAdresse = mysql_fetch_assoc ( $ res ) ; $ url = 'photos-' . $ string -> convertStringToUrlRewrite ( $ this -> getIntituleAdresse ( $ fetchAdresse ) ) . '-' . $ fetchAdresse [ 'dateUpload' ] . '-' . $ fetchAdresse [ 'idHistoriqueImage' ] . '-' . $ format . '.jpg' ; $ dateUpload = $ fetchAdresse [ 'dateUpload' ] ; $ idHistoriqueImage = $ fetchAdresse [ 'idHistoriqueImage' ] ; } if ( $ url == '' ) { $ url = $ this -> getUrlImage ( ) . 'transparent.gif' ; } return array ( 'url' => $ url , 'dateUpload' => $ dateUpload , 'idHistoriqueImage' => $ idHistoriqueImage ) ; } | fonction recuperant l image de la demolition |
24,187 | public function getArrayAdresseFromIdAdresse ( $ idAdresse = 0 ) { $ req = " select ha.idAdresse as idAdresse, ha.date as date, ha.description as description, ha.nom as nom, ha.idHistoriqueAdresse as idHistoriqueAdresse, ha.numero as numero, IF(ha.idIndicatif='0','',i.nom) as nomIndicatif, ha.idRue, IF (ha.idSousQuartier != 0, ha.idSousQuartier, r.idSousQuartier) AS idSousQuartier, IF (ha.idQuartier != 0, ha.idQuartier, sq.idQuartier) AS idQuartier, IF (ha.idVille != 0, ha.idVille, q.idVille) AS idVille, IF (ha.idPays != 0, ha.idPays, v.idPays) AS idPays, r.prefixe as prefixeRue, r.nom as nomRue, sq.nom as nomSousQuartier, q.nom as nomQuartier, v.nom as nomVille, p.nom as nomPays from historiqueAdresse hab, historiqueAdresse ha LEFT JOIN rue r ON r.idRue = ha.idRue LEFT JOIN sousQuartier sq ON sq.idSousQuartier = IF(ha.idRue='0' and ha.idSousQuartier!='0' ,ha.idSousQuartier ,r.idSousQuartier ) LEFT JOIN quartier q ON q.idQuartier = IF(ha.idRue='0' and ha.idSousQuartier='0' and ha.idQuartier!='0' ,ha.idQuartier ,sq.idQuartier ) LEFT JOIN ville v ON v.idVille = IF(ha.idRue='0' and ha.idSousQuartier='0' and ha.idQuartier='0' and ha.idVille!='0' ,ha.idVille ,q.idVille ) LEFT JOIN indicatif i ON i.idIndicatif = ha.idIndicatif LEFT JOIN pays p ON p.idPays = IF(ha.idRue='0' and ha.idSousQuartier='0' and ha.idQuartier='0' and ha.idVille='0' and ha.idPays!='0' ,ha.idPays ,v.idPays ) where ha.idAdresse = '" . $ idAdresse . "' and hab.idAdresse = ha.idAdresse group by ha.idAdresse, ha.idHistoriqueAdresse having ha.idHistoriqueAdresse = max(hab.idHistoriqueAdresse) " ; $ res = $ this -> connexionBdd -> requete ( $ req ) ; return mysql_fetch_assoc ( $ res ) ; } | retourne un tableau contenant les infos de l adresse |
24,188 | public function afficheSelectVille ( $ params = array ( ) ) { $ html = "" ; $ t = new Template ( 'modules/archi/templates/' ) ; $ t -> set_filenames ( ( array ( 'listeVille' => 'listeVilleSelect.tpl' ) ) ) ; $ a = new archiAuthentification ( ) ; $ u = new archiUtilisateur ( ) ; $ sqlWhereVillesModerees = "" ; if ( $ a -> getIdProfil ( ) == 3 ) { $ arrayIdVilles = $ u -> getArrayVillesModereesPar ( $ a -> getIdUtilisateur ( ) ) ; if ( count ( $ arrayIdVilles ) > 0 ) { $ sqlWhereVillesModerees = " AND idVille IN (" . implode ( "," , $ arrayIdVilles ) . ") " ; } else { $ sqlWhereVillesModerees = " AND idVille =0 " ; } } $ wherePays = "" ; if ( isset ( $ params [ 'idPays' ] ) && $ params [ 'idPays' ] != '' ) { $ wherePays = " AND idPays = '" . $ params [ 'idPays' ] . "' " ; } if ( isset ( $ this -> variablesGet [ "idPays" ] ) && $ this -> variablesGet [ "idPays" ] != '' ) { $ wherePays = " AND idPays = '" . $ this -> variablesGet [ 'idPays' ] . "' " ; } $ javascriptQuartier = "" ; if ( ! isset ( $ params [ 'noQuartier' ] ) || $ params [ 'noQuartier' ] != true ) { $ javascriptQuartier = " document.getElementById('quartiers').innerHTML='<option value=0>Aucun</option>'; document.getElementById('quartiers').selectedIndex=0; appelAjax('?archiAffichage=afficheSelectQuartier&noHeaderNoFooter=1&idVille='+document.getElementById('ville').value,'champQuartier'); " ; } $ javascriptSousQuartier = "" ; if ( ! isset ( $ params [ 'noSousQuartier' ] ) || $ params [ 'noSousQuartier' ] != true ) { $ javascriptSousQuartier = " document.getElementById('sousQuartiers').innerHTML='<option value=0>Aucun</option>'; document.getElementById('sousQuartiers').selectedIndex=0; " ; } $ t -> assign_vars ( array ( 'javascript' => " function onChangeListeVille() { " . $ javascriptSousQuartier . " " . $ javascriptQuartier . " } " ) ) ; $ t -> assign_vars ( array ( 'onChangeListeVille' => "onChangeListeVille();" ) ) ; $ reqVille = "SELECT idVille, nom FROM ville WHERE 1=1 and nom<>'autre' " . $ sqlWhereVillesModerees . " " . $ wherePays ; $ resVille = $ this -> connexionBdd -> requete ( $ reqVille ) ; while ( $ fetchVille = mysql_fetch_assoc ( $ resVille ) ) { $ selected = "" ; if ( isset ( $ params [ 'idVille' ] ) && $ params [ 'idVille' ] != '' && $ params [ 'idVille' ] == $ fetchVille [ 'idVille' ] ) { $ selected = " selected " ; } $ t -> assign_block_vars ( 'villes' , array ( 'id' => $ fetchVille [ 'idVille' ] , 'nom' => $ fetchVille [ 'nom' ] , 'selected' => $ selected ) ) ; } ob_start ( ) ; $ t -> pparse ( 'listeVille' ) ; $ html = ob_get_contents ( ) ; ob_end_clean ( ) ; return $ html ; } | affichage de la liste des villes sous forme d un champ select |
24,189 | public function afficheSelectPays ( $ params = array ( ) ) { $ html = "" ; $ t = new Template ( 'modules/archi/templates/' ) ; $ t -> set_filenames ( ( array ( 'listePays' => 'listePaysSelect.tpl' ) ) ) ; $ a = new archiAuthentification ( ) ; $ u = new archiUtilisateur ( ) ; $ sqlWhereVillesModerees = "" ; if ( $ a -> getIdProfil ( ) == 3 ) { $ arrayIdVilles = $ u -> getArrayVillesModereesPar ( $ a -> getIdUtilisateur ( ) ) ; $ arrayIdPays = array ( ) ; $ reqPaysModeres = "SELECT distinct idPays FROM ville WHERE idVille IN (" . implode ( "," , $ arrayIdVilles ) . ") " ; $ resPaysModeres = $ this -> connexionBdd -> requete ( $ reqPaysModeres ) ; if ( mysql_num_rows ( $ resPaysModeres ) > 0 ) { while ( $ fetchPaysModeres = mysql_fetch_assoc ( $ resPaysModeres ) ) { $ arrayIdPays [ ] = $ fetchPaysModeres [ 'idPays' ] ; } $ sqlWhereVillesModerees = " AND idPays IN (" . implode ( "," , $ arrayIdPays ) . ") " ; } else { $ sqlWhereVillesModerees = " AND idPays = 0 " ; } } $ reqPays = "SELECT nom, idPays FROM pays WHERE 1=1 " . $ sqlWhereVillesModerees ; $ resPays = $ this -> connexionBdd -> requete ( $ reqPays ) ; $ javascriptVille = "" ; if ( ! isset ( $ params [ 'noVille' ] ) || $ params [ 'noVille' ] != true ) { $ javascriptVille = " document.getElementById('ville').innerHTML='<option value=0>Aucun</option>'; document.getElementById('ville').selectedIndex=0; appelAjax('?archiAffichage=afficheSelectVille&noHeaderNoFooter=1&idPays='+document.getElementById('pays').value,'champVille'); " ; } $ javascriptQuartier = "" ; if ( ! isset ( $ params [ 'noQuartier' ] ) || $ params [ 'noQuartier' ] != true ) { $ javascriptQuartier = " document.getElementById('quartiers').innerHTML='<option value=0>Aucun</option>'; document.getElementById('quartiers').selectedIndex=0; " ; } $ javascriptSousQuartier = "" ; if ( ! isset ( $ params [ 'noSousQuartier' ] ) || $ params [ 'noSousQuartier' ] != true ) { $ javascriptSousQuartier = " document.getElementById('sousQuartiers').innerHTML='<option value=0>Aucun</option>'; document.getElementById('sousQuartiers').selectedIndex=0; " ; } $ t -> assign_vars ( array ( 'javascript' => " function onChangeListePays() { " . $ javascriptSousQuartier . " " . $ javascriptQuartier . " " . $ javascriptVille . " } " ) ) ; $ t -> assign_vars ( array ( 'onChangeListePays' => "onChangeListePays();" ) ) ; while ( $ fetchPays = mysql_fetch_assoc ( $ resPays ) ) { $ selected = "" ; if ( isset ( $ params [ 'idPays' ] ) && $ params [ 'idPays' ] != '' && $ params [ 'idPays' ] == $ fetchPays [ 'idPays' ] ) { $ selected = " selected " ; } $ t -> assign_block_vars ( 'pays' , array ( 'id' => $ fetchPays [ 'idPays' ] , 'nom' => $ fetchPays [ 'nom' ] , 'selected' => $ selected ) ) ; } ob_start ( ) ; $ t -> pparse ( 'listePays' ) ; $ html = ob_get_contents ( ) ; ob_end_clean ( ) ; return $ html ; } | affichage de la liste des pays sous forme d un champ select |
24,190 | public function getFirstImageFromEvenement ( $ idEvenement = 0 ) { $ fetch = array ( ) ; $ reqVerifTri = " SELECT ei.idImage FROM _evenementImage ei WHERE ei.idEvenement = '" . $ idEvenement . "' AND position<>0 " ; $ resVerifTri = $ this -> connexionBdd -> requete ( $ reqVerifTri ) ; if ( mysql_num_rows ( $ resVerifTri ) > 0 ) { $ req = " SELECT hi1.idHistoriqueImage as idHistoriqueImage, hi1.dateUpload as dateUpload , hi1.idImage as idImage FROM historiqueImage hi2,historiqueImage hi1 RIGHT JOIN _evenementImage ei1 ON ei1.idEvenement ='" . $ idEvenement . "' RIGHT JOIN _evenementImage ei2 ON ei2.idEvenement = ei1.idEvenement WHERE hi1.idImage = ei1.idImage AND hi2.idImage = hi1.idImage AND ei1.position<>'0' AND ei2.position<>'0' GROUP BY hi1.idImage,ei1.position,hi1.idHistoriqueImage HAVING hi1.idHistoriqueImage = max(hi2.idHistoriqueImage) AND ei1.position = min(ei2.position) ORDER BY ei1.position ASC " ; $ res = $ this -> connexionBdd -> requete ( $ req ) ; $ fetch = mysql_fetch_assoc ( $ res ) ; } else { $ req = " SELECT hi1.idHistoriqueImage as idHistoriqueImage, hi1.dateUpload as dateUpload, hi1.idImage as idImage FROM historiqueImage hi2,historiqueImage hi1 RIGHT JOIN _evenementImage ei1 ON ei1.idEvenement ='" . $ idEvenement . "' WHERE hi1.idImage = ei1.idImage AND hi2.idImage = hi1.idImage GROUP BY hi1.idImage,hi1.idHistoriqueImage HAVING hi1.idHistoriqueImage = max(hi2.idHistoriqueImage) ORDER BY hi1.idHistoriqueImage " ; $ res = $ this -> connexionBdd -> requete ( $ req ) ; if ( mysql_num_rows ( $ res ) == 0 ) { $ req = " SELECT hi1.idHistoriqueImage as idHistoriqueImage, hi1.dateUpload as dateUpload,ei1.position as position , hi1.idImage as idImage FROM historiqueImage hi2,historiqueImage hi1 RIGHT JOIN _evenementEvenement ee ON ee.idEvenementAssocie = '" . $ idEvenement . "' LEFT JOIN _evenementEvenement ee2 ON ee2.idEvenement = ee.idEvenement RIGHT JOIN _evenementEvenement ee3 ON ee3.idEvenement = ee2.idEvenementAssocie RIGHT JOIN _evenementImage ei1 ON ei1.idEvenement = ee3.idEvenementAssocie WHERE hi1.idImage = ei1.idImage AND hi2.idImage = hi1.idImage GROUP BY hi1.idImage,hi1.idHistoriqueImage HAVING hi1.idHistoriqueImage = max(hi2.idHistoriqueImage) ORDER BY position, hi1.idHistoriqueImage " ; $ res = $ this -> connexionBdd -> requete ( $ req ) ; while ( $ fetchImagesAdresses = mysql_fetch_assoc ( $ res ) ) { if ( $ fetchImagesAdresses [ 'position' ] == '1' ) { $ fetch = $ fetchImagesAdresses ; break ; } else { $ fetch = $ fetchImagesAdresses ; } } } else { $ fetch = mysql_fetch_assoc ( $ res ) ; } } return $ fetch ; } | recupere la premiere image d un evenement en fonction de sa position |
24,191 | public function getInfosVille ( $ idVille = 0 , $ params = array ( ) ) { $ fieldList = " * " ; if ( isset ( $ params [ 'fieldList' ] ) && $ params [ 'fieldList' ] != '' ) { $ fieldList = $ params [ 'fieldList' ] ; } $ req = "SELECT $fieldList FROM ville v LEFT JOIN pays p ON p.idPays = v.idPays WHERE v.idVille = $idVille" ; $ res = $ this -> connexionBdd -> requete ( $ req ) ; return mysql_fetch_assoc ( $ res ) ; } | renvoi un tableau contenant des infos sur la ville en parametre |
24,192 | public function getIdVilleFromNomVille ( $ nomVille = '' ) { $ retour = 0 ; $ req = "SELECT idVille FROM ville WHERE nom LIKE \"%" . $ nomVille . "%\"" ; $ res = $ this -> connexionBdd -> requete ( $ req ) ; if ( mysql_num_rows ( $ res ) > 0 ) { $ fetch = mysql_fetch_assoc ( $ res ) ; $ retour = $ fetch [ 'idVille' ] ; } return $ retour ; } | renvoi l idVille a partir du nom de la ville en parametre |
24,193 | public function isParcoursActif ( $ params = array ( ) ) { $ retour = false ; if ( isset ( $ params [ 'idParcours' ] ) && $ params [ 'idParcours' ] != '' ) { $ req = "SELECT isActif FROM parcoursArt WHERE idParcours = '" . $ params [ 'idParcours' ] . "'" ; $ res = $ this -> connexionBdd -> requete ( $ req ) ; if ( mysql_num_rows ( $ res ) > 0 ) { $ fetch = mysql_fetch_assoc ( $ res ) ; if ( $ fetch [ 'isActif' ] == '1' ) { $ retour = true ; } } } else { $ req = "SELECT 0 FROM parcoursArt WHERE isActif='1'" ; $ res = $ this -> connexionBdd -> requete ( $ req ) ; if ( mysql_num_rows ( $ res ) > 0 ) { $ retour = true ; } } return $ retour ; } | si on precise un idParcours en parametre on regarde alors si ce parcours est actif |
24,194 | public function getPhotoFromEtape ( $ params = array ( ) ) { $ retour = array ( 'trouve' => false ) ; if ( isset ( $ params [ 'idEtape' ] ) && $ params [ 'idEtape' ] != '' && $ params [ 'idEtape' ] != '0' ) { $ req = "SELECT idEvenementGroupeAdresse FROM etapesParcoursArt WHERE idEtape='" . $ params [ 'idEtape' ] . "'" ; $ res = $ this -> connexionBdd -> requete ( $ req ) ; $ fetch = mysql_fetch_assoc ( $ res ) ; if ( isset ( $ fetch [ 'idEvenementGroupeAdresse' ] ) ) { $ i = new archiImage ( ) ; $ idAdresse = $ this -> getIdAdresseFromIdEvenementGroupeAdresse ( $ fetch [ 'idEvenementGroupeAdresse' ] ) ; $ idEvenementGroupeAdresse = $ fetch [ 'idEvenementGroupeAdresse' ] ; $ format = 'mini' ; if ( isset ( $ params [ 'format' ] ) && $ params [ 'format' ] != '' ) { $ format = $ params [ 'format' ] ; } $ illustration = $ this -> getUrlImageFromAdresse ( $ idAdresse , $ format , array ( 'idEvenementGroupeAdresse' => $ idEvenementGroupeAdresse ) ) ; $ retour = $ illustration ; } } return $ retour ; } | renvoie la photo courante de l adresse de l etape |
24,195 | public function getIdSousQuartier ( $ idRue = null ) { $ idSousQuartier = null ; if ( ! isset ( $ idRue ) && $ idRue != '' ) { echo "Error while getting sub neighborhood id, no street informations were specified for this request." ; } else { $ req = "SELECT idSousQuartier FROM rue WHERE idRue = " . $ idRue ; $ res = $ this -> connexionBdd -> requete ( $ req ) ; $ fetchSousQuartier = mysql_fetch_assoc ( $ res ) ; $ idSousQuartier = $ fetchSousQuartier [ 'idSousQuartier' ] ; } return $ idSousQuartier ; } | Get the id of a sub neighborhood from the id of a street |
24,196 | public function getIdQuartier ( $ idSousQuartier ) { $ idQuartier = null ; if ( ! isset ( $ idSousQuartier ) && $ idSousQuartier != '' ) { echo "Error while getting neighborhood id, no sub neighborhood informations were specified for this request." ; } else { $ req = " SELECT idQuartier FROM sousQuartier WHERE idSousQuartier = " . $ idSousQuartier . " " ; $ res = $ this -> connexionBdd -> requete ( $ req ) ; $ fetchQuartier = mysql_fetch_assoc ( $ res ) ; $ idQuartier = $ fetchQuartier [ 'idQuartier' ] ; } return $ idQuartier ; } | Get the id of a neighborhood from the id of a street |
24,197 | public function getIdVille ( $ idQuartier ) { $ idVille ; if ( ! isset ( $ idQuartier ) && $ idQuartier != '' ) { echo "Error while getting city id, no sub neighborhood informations were specified for this request." ; } else { $ req = " SELECT idVille FROM quartier WHERE idQuartier = " . $ idQuartier . " " ; $ res = $ this -> connexionBdd -> requete ( $ req ) ; $ fetch = mysql_fetch_assoc ( $ res ) ; $ idVille = $ fetch [ 'idVille' ] ; } return $ idVille ; } | Get the id of the city from neighborhood id |
24,198 | public function getIdPays ( $ idVille ) { $ idPays ; if ( ! isset ( $ idVille ) && $ idVille != '' ) { echo "Error while getting country id, no sub neighborhood informations were specified for this request." ; } else { $ req = " SELECT idPays FROM ville WHERE idVille = " . $ idVille . " " ; $ res = $ this -> connexionBdd -> requete ( $ req ) ; $ fetch = mysql_fetch_assoc ( $ res ) ; $ idPays = $ fetch [ 'idPays' ] ; } return $ idPays ; } | Get id of the country from city id |
24,199 | private function generatePaginationLinks ( $ options = array ( ) ) { $ nbResult = 0 ; $ nbPages = 0 ; $ currentPage = 0 ; $ nextPage = 0 ; $ previousPage = 0 ; $ nbResultPerPage = 10 ; $ offset = 4 ; $ url = array ( ) ; if ( isset ( $ options [ 'nbResult' ] ) ) { $ nbResult = $ options [ 'nbResult' ] ; } if ( isset ( $ options [ 'nbPages' ] ) ) { $ nbPages = $ options [ 'nbPages' ] ; } if ( isset ( $ options [ 'currentPage' ] ) ) { $ currentPage = $ options [ 'nbResult' ] ; } if ( isset ( $ options [ 'nextPage' ] ) ) { $ nextPage = $ options [ 'nextPage' ] ; } if ( isset ( $ options [ 'previousPage' ] ) ) { $ previousPage = $ options [ 'previousPage' ] ; } if ( isset ( $ options [ 'nbResultPerPage' ] ) ) { $ nbResultPerPage = $ options [ 'nbResultPerPage' ] ; } if ( isset ( $ options [ 'offset' ] ) ) { $ offset = $ options [ 'offset' ] ; } for ( $ i = 0 ; $ i < $ nbPages ; $ i ++ ) { $ paramCreerUrl = $ this -> variablesGet ; $ paramCreerUrl [ 'debut' ] = $ i * $ nbResultPerPage ; $ url [ ] = $ this -> creerUrl ( '' , '' , $ paramCreerUrl ) ; } return $ url ; } | Generate pagination links |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.