idx int64 0 60.3k | question stringlengths 64 4.24k | target stringlengths 5 618 |
|---|---|---|
29,700 | public static function factory ( $ config = array ( ) ) { $ default = array ( 'base_url' => 'https://my.rightscale.com/' , 'version' => '1.0' , 'curl.CURLOPT_FOLLOWLOCATION' => false , 'curl.CURLOPT_RETURNTRANSFER' => true ) ; $ required = array ( 'acct_num' , 'base_url' , 'version' ) ; $ config = Inspector :: prepareConfig ( $ config , $ default , $ required ) ; $ client = new self ( $ config -> get ( 'base_url' ) , $ config -> get ( 'acct_num' ) , $ config -> get ( 'oauth_refresh_token' ) , $ config -> get ( 'email' ) , $ config -> get ( 'password' ) , $ config -> get ( 'version' ) ) ; $ client -> setConfig ( $ config ) ; $ path = __DIR__ . DIRECTORY_SEPARATOR . 'rs_guzzle_client_v' . $ client -> getVersion ( ) . '.xml' ; $ client -> setDescription ( ServiceDescription :: factory ( $ path ) ) ; $ client -> cookieJar = new IndiscriminateArrayCookieJar ( ) ; $ client -> getEventDispatcher ( ) -> addSubscriber ( new CookiePlugin ( $ client -> cookieJar ) ) ; $ client -> getEventDispatcher ( ) -> addSubscriber ( new HttpAuthenticationPlugin ( $ client ) ) ; $ client -> getEventDispatcher ( ) -> addSubscriber ( new ShardAwarenessPlugin ( $ client ) ) ; return $ client ; } | Factory method to create a new RightScaleClient |
29,701 | public function newModel ( $ modelName , $ mixed = null ) { if ( substr_count ( "\\" , $ modelName ) > 0 ) { throw new InvalidArgumentException ( "Do not provide the full namespace plus classname of the desired model. Only the model classname is required. E.G. Cloud" ) ; } $ prefix = $ this -> version == '1.0' ? 'Ec2\\' : 'Mc\\' ; $ modelName = "\\RGeyer\\Guzzle\\Rs\\Model\\" . $ prefix . $ modelName ; if ( ! class_exists ( $ modelName ) ) { throw new \ InvalidArgumentException ( "The model $modelName does not exist" ) ; } $ model = new $ modelName ( $ mixed ) ; $ model -> setClient ( $ this ) ; return $ model ; } | Returns a new model of the specified type which will use this client for making API calls |
29,702 | public static function getIdFromHref ( $ basename , $ href ) { $ regex = ',https://.+/api/acct/[0-9]+/' . $ basename . '/([0-9]+),' ; $ matches = array ( ) ; preg_match ( $ regex , $ href , $ matches ) ; return count ( $ matches ) > 0 ? $ matches [ 1 ] : 0 ; } | Returns the object id when given the objects basename and it s href . |
29,703 | public static function getIdFromRelativeHref ( $ relative_href ) { $ regex = ',.+/([0-9A-Z]+)$,' ; $ matches = array ( ) ; preg_match ( $ regex , $ relative_href , $ matches ) ; return count ( $ matches ) > 0 ? $ matches [ 1 ] : 0 ; } | Returns the object id when given the objects relative href . |
29,704 | public function parseFromArray ( array $ configuration ) { $ this -> validateInput ( $ configuration ) ; $ this -> setInput ( $ configuration ) ; $ this -> parse ( $ configuration ) ; $ this -> setId ( $ this -> getHash ( ) ) ; return $ this ; } | Parses a configuration from an array to provide access via object . |
29,705 | protected function validateInput ( $ input ) { $ keys = [ 'form' , 'elements' , ] ; switch ( gettype ( $ input ) ) { case 'array' : foreach ( $ keys as $ key ) { if ( array_key_exists ( $ key , $ input ) === false ) { throw new \ Exception ( 'Input invalid! Please make sure that input array contains keys (form, elements).' ) ; } } break ; } return true ; } | Validates the input passed to parser . |
29,706 | protected function getMethodByKey ( $ key ) { $ method = explode ( '-' , str_replace ( self :: DOOZR_COMMAND_PREFIX , '' , $ key ) ) ; foreach ( $ method as $ key => $ node ) { $ method [ $ key ] = ucfirst ( $ node ) ; } return 'set' . implode ( '' , $ method ) ; } | Returns the method name of a Doozr function by passed key . |
29,707 | protected function parse ( $ configuration ) { $ result = [ ] ; foreach ( $ configuration as $ root => $ children ) { foreach ( $ children as $ key => $ values ) { foreach ( $ values as $ node => $ value ) { $ dom = [ ] ; $ doozr = [ ] ; switch ( $ node ) { case 'tag' : $ tag = $ value ; break ; case 'properties' : $ properties = $ value ; foreach ( $ properties as $ property => $ value ) { if ( $ this -> containsCommand ( $ property ) === true ) { $ doozr [ ] = [ 'method' => $ this -> getMethodByKey ( $ property ) , 'value' => $ value , ] ; } else { $ dom [ $ property ] = $ value ; } } break ; } } if ( isset ( $ result [ $ root ] ) === false ) { $ result [ $ root ] = [ ] ; } $ result [ $ root ] [ ] = [ 'dom' => $ dom , 'doozr' => $ doozr , ] ; } } $ result [ 'form' ] = $ result [ 'form' ] [ 0 ] ; $ this -> setConfiguration ( array_to_object ( $ result ) ) ; } | Parses a configuration . |
29,708 | protected function setConfiguration ( \ stdClass $ configuration ) { $ this -> configuration = $ configuration ; $ this -> updateHash ( ) ; $ this -> setDirty ( true ) ; } | Setter for configuration . |
29,709 | final public function check ( string $ addr , int $ port = 0 , int $ timeout = 3 , int $ ttl = 30 ) : Result { $ key = sprintf ( "%s::%s:%d" , static :: class , $ addr , $ port ) ; $ result = $ this -> cache ( ) -> get ( $ key ) ; if ( empty ( $ result ) ) { $ result = $ this -> checkAtOnce ( $ addr , $ port , $ timeout ) ; if ( false === $ this -> cache ( ) -> set ( $ key , $ result , $ ttl ) ) { throw new \ Exception ( 'set cache error: checker(' . static :: class . '), key(' . $ key . '), result(' . $ result . ').' ) ; } } return $ result ; } | Check the health of the service with cache . |
29,710 | public function hasAccess ( $ accessKey , User $ user = null ) { if ( $ user === null ) { $ user = $ this -> currentUser ( ) ; } if ( is_array ( $ accessKey ) ) { return $ user -> hasAnyAccess ( $ accessKey ) ; } else { return $ user -> hasAccess ( $ accessKey ) ; } } | Check to see if a user has the access . |
29,711 | public function searchBy ( $ searchQuery , array $ options = array ( ) , $ statementsType = null ) { $ query = $ this -> newSearchQuery ( $ searchQuery , array ( 'first_name' , 'last_name' , 'email' , 'id' , ) , $ statementsType , $ options ) ; return new Collection ( $ query ) ; } | Search a User by options . |
29,712 | public function delete ( $ user ) { if ( ! is_object ( $ user ) ) { $ user = $ this -> find ( $ user ) ; } if ( $ user instanceof User ) { if ( $ this -> fireEvent ( 'deleting' , array ( $ user ) ) === false ) { return false ; } $ user -> delete ( $ this ) ; $ this -> fireEvent ( 'deleted' , array ( $ user ) ) ; } } | Delete a User . |
29,713 | function Select ( $ distinct , SelectList $ selectList , Source $ source , Condition $ condition = null , OrderList $ orderList = null , GroupList $ groupList = null , $ offset = 0 , $ count = 0 ) { return parent :: CreateSelect ( $ distinct , $ selectList , $ source , $ condition , $ orderList , $ groupList , $ offset , $ count ) ; } | Creates a sql select object |
29,714 | protected function filterFields ( array $ data ) : array { $ fields = $ this -> getFilterFields ( ) ; if ( $ fields === null ) { return $ data ; } return array_intersect_key ( $ data , array_flip ( iterator_to_array ( $ fields ) ) ) ; } | Filter the provided data with the requested filter fields for the scope resource |
29,715 | public function getAvailableTimesets ( ) { if ( ! isset ( self :: $ timesetNames ) ) { self :: $ timesetNames = [ $ this -> translator -> _ ( 'standard_time' ) , $ this -> translator -> _ ( 'swatch_time' ) , $ this -> translator -> _ ( 'iso_time' ) , ] ; } return self :: $ timesetNames ; } | This method is intend to return a list of available timesets . |
29,716 | public function isValid ( ) { if ( ! isset ( $ this -> rules ) || ! is_array ( $ this -> rules ) || empty ( $ this -> rules ) ) { return true ; } $ rules = array ( ) ; $ replacements = array ( ) ; foreach ( $ this -> attributes as $ k => $ v ) { $ replacements [ '{{self_' . $ k . '}}' ] = $ v ; } foreach ( $ this -> rules as $ k => $ v ) { $ rules [ $ k ] = str_replace ( array_keys ( $ replacements ) , array_values ( $ replacements ) , $ v ) ; } $ v = Validator :: make ( $ this -> attributes , $ rules ) ; if ( $ v -> fails ( ) ) { $ this -> errorMessages = $ v -> messages ( ) ; return false ; } return true ; } | Is model valid . |
29,717 | public function bindPropertiesFromFile ( string $ propertiesFile , string $ environment ) : Properties { return $ this -> bindProperties ( Properties :: fromFile ( $ propertiesFile ) , $ environment ) ; } | binds properties from given properties file |
29,718 | public function bindMap ( string $ name ) : MapBinding { if ( ! isset ( $ this -> mapBindings [ $ name ] ) ) { $ this -> mapBindings [ $ name ] = $ this -> addBinding ( new MapBinding ( $ name ) ) ; } return $ this -> mapBindings [ $ name ] ; } | bind to a map |
29,719 | protected function start ( ) { $ controllerClass = $ this -> calculateControllerClassFromRights ( ) ; $ controller = $ this -> loadController ( $ controllerClass ) ; if ( ! $ controller ) { if ( $ this -> logMissingPages ) { $ this -> alert ( 'Invalid controller ' . $ controllerClass . '!' ) ; } return ; } $ controller -> setActiveAction ( $ this -> request ( ) -> getAction ( ) ) ; if ( ! method_exists ( $ controller , 'action' . ucfirst ( $ controller -> getActiveAction ( ) ) ) ) { if ( $ this -> logMissingPages ) { $ this -> alert ( 'Action ' . $ this -> request ( ) -> getAction ( ) . ' not found!' , array ( 'requestedController' => $ this -> request ( ) -> getController ( ) , 'requestedModule' => $ this -> request ( ) -> getModule ( ) ) ) ; } $ controller = $ this -> loadController ( $ this -> getPageNotFound ( ) ) ; if ( ! $ controller ) { $ this -> alert ( 'Invalid controller ' . $ controllerClass . '!' ) ; return ; } } $ controller -> setActiveAction ( $ this -> request ( ) -> getAction ( ) ) -> setRequest ( $ this -> request ( ) ) ; if ( ! $ controller -> canRun ( ) ) { $ controller = $ this -> loadController ( $ this -> getPageNotFound ( ) ) ; if ( ! $ controller ) { $ this -> alert ( 'Invalid controller ' . $ controllerClass . '!' ) ; return ; } $ controller -> setActiveAction ( $ this -> request ( ) -> getAction ( ) ) -> setRequest ( $ this -> request ( ) ) ; } $ this -> _controller = $ controller ; $ path = dirname ( dirname ( $ this -> autoload ( ) -> findFile ( get_class ( $ controller ) ) ) ) . DIRECTORY_SEPARATOR ; if ( $ path != $ this -> request ( ) -> getModulePath ( ) ) { $ this -> request ( ) -> setModulePath ( $ path ) ; } $ controller -> run ( ) ; } | This method will load the controller based on the Request and execute it ; |
29,720 | protected function calculateControllerClassFromRights ( ) { $ this -> user ( ) ; $ controllerClass = $ this -> getControllerClassFromNameAndModule ( $ this -> request ( ) -> getController ( ) , $ this -> request ( ) -> getModule ( ) ) ; if ( ! trim ( $ this -> request ( ) -> getAction ( ) ) ) { $ ctrl = new $ controllerClass ; $ this -> request ( ) -> setAction ( $ ctrl -> defaultAction ) ; } if ( ! class_exists ( $ controllerClass ) ) { if ( $ this -> logMissingPages ) { $ this -> alert ( 'Controller ' . $ controllerClass . ' not found!' , array ( 'requestedController' => $ this -> request ( ) -> getController ( ) , 'requestedModule' => $ this -> request ( ) -> getModule ( ) ) ) ; } $ controllerClass = $ this -> getPageNotFound ( ) ; } elseif ( $ this -> accessMap && ( ! $ this -> accessMap -> canAccess ( $ this -> request ( ) -> getController ( ) , $ this -> request ( ) -> getAction ( ) , $ this -> request ( ) -> getModule ( ) ) ) ) { if ( $ this -> user ( ) -> isGuest ( ) ) { $ controllerClass = $ this -> getPageLogin ( ) ; } else { $ controllerClass = $ this -> getPageAccessDenied ( ) ; } } return $ controllerClass ; } | Get controller class by checking if user has rights to access current controller or not . |
29,721 | private function loadController ( $ class ) { $ controller = new $ class ( $ this -> currentControllerAliasConfig ) ; if ( ! is_a ( $ controller , '\\mpf\\web\\Controller' ) ) { $ this -> critical ( 'Controller `' . $ class . '` must extend \\mpf\\web\\Controller!' , array ( 'requestedController' => $ this -> request ( ) -> getController ( ) , 'requestedModule' => $ this -> request ( ) -> getModule ( ) ) ) ; return null ; } return $ controller ; } | Instantiate controller and check if class is correct ; It will also check for current alias config and it will sent it to constructor |
29,722 | protected function getPageNotFound ( ) { $ this -> debug ( 'Controller and action changed to: ' . implode ( "/" , $ this -> pageNotFound ) ) ; $ this -> request ( ) -> setController ( $ this -> pageNotFound [ 0 ] ) ; $ this -> request ( ) -> setAction ( $ this -> pageNotFound [ 1 ] ) ; if ( isset ( $ this -> pageNotFound [ 3 ] ) ) $ this -> request ( ) -> setModule ( $ this -> pageNotFound [ 3 ] ) ; if ( isset ( $ this -> pageNotFound [ 2 ] ) && is_string ( $ this -> pageNotFound [ 2 ] ) ) $ this -> request ( ) -> setModule ( $ this -> pageNotFound [ 2 ] ) ; elseif ( isset ( $ this -> pageNotFound [ 2 ] ) && is_array ( $ this -> pageNotFound [ 2 ] ) && ! empty ( $ this -> pageNotFound [ 2 ] ) ) $ this -> request ( ) -> setParams ( $ this -> pageNotFound [ 2 ] ) ; return $ this -> getControllerClassFromNameAndModule ( $ this -> pageNotFound [ 0 ] , $ this -> request ( ) -> getModule ( ) ) ; } | Return controller class for in case that page was not found! |
29,723 | protected function getPageAccessDenied ( ) { $ this -> debug ( 'Controller and action changed to: ' . implode ( "/" , $ this -> pageAccessDenied ) ) ; $ this -> request ( ) -> setController ( $ this -> pageAccessDenied [ 0 ] ) ; $ this -> request ( ) -> setAction ( $ this -> pageAccessDenied [ 1 ] ) ; if ( isset ( $ this -> pageAccessDenied [ 3 ] ) ) $ this -> request ( ) -> setModule ( $ this -> pageAccessDenied [ 3 ] ) ; if ( isset ( $ this -> pageAccessDenied [ 2 ] ) && is_string ( $ this -> pageAccessDenied [ 2 ] ) ) $ this -> request ( ) -> setModule ( $ this -> pageAccessDenied [ 2 ] ) ; elseif ( isset ( $ this -> pageAccessDenied [ 2 ] ) && is_array ( $ this -> pageAccessDenied [ 2 ] ) && ! empty ( $ this -> pageAccessDenied [ 2 ] ) ) $ this -> request ( ) -> setParams ( $ this -> pageAccessDenied [ 2 ] ) ; return $ this -> getControllerClassFromNameAndModule ( $ this -> pageAccessDenied [ 0 ] , $ this -> request ( ) -> getModule ( ) ) ; } | Return class name to access denied controller |
29,724 | protected function getPageLogin ( ) { $ this -> debug ( 'Controller and action changed to: ' . implode ( "/" , $ this -> pageLogin ) ) ; if ( isset ( $ this -> pageLogin [ 3 ] ) ) $ this -> request ( ) -> setModule ( $ this -> pageLogin [ 3 ] ) ; if ( isset ( $ this -> pageLogin [ 2 ] ) && is_string ( $ this -> pageLogin [ 2 ] ) ) $ this -> request ( ) -> setModule ( $ this -> pageLogin [ 2 ] ) ; elseif ( isset ( $ this -> pageLogin [ 2 ] ) && is_array ( $ this -> pageLogin [ 2 ] ) && ! empty ( $ this -> pageLogin [ 2 ] ) ) $ this -> request ( ) -> setParams ( $ this -> pageLogin [ 2 ] ) ; $ this -> request ( ) -> setController ( $ this -> pageLogin [ 0 ] ) ; $ this -> request ( ) -> setAction ( $ this -> pageLogin [ 1 ] ) ; return $ this -> getControllerClassFromNameAndModule ( $ this -> pageLogin [ 0 ] , $ this -> request ( ) -> getModule ( ) ) ; } | Return class name to login controller |
29,725 | public function hasAccessTo ( $ controller , $ action , $ module = null ) { if ( ! $ this -> accessMap ) { return true ; } if ( is_null ( $ module ) ) { $ module = $ this -> request ( ) -> getModule ( ) ; } return $ this -> accessMap -> canAccess ( $ controller , $ action , $ module ) ; } | Checks access to a specific controller and action . |
29,726 | public function setEvents ( array $ events ) { if ( $ events ) { $ this -> ensureEvents ( ) ; foreach ( $ events as $ name => $ handler ) { $ this -> on ( $ name , $ handler ) ; } } } | set events so can set event - > handler by config |
29,727 | public function one ( $ name , $ handler , $ data = array ( ) ) { $ this -> ensureEvents ( ) ; $ this -> _events [ $ name ] = [ ] ; $ this -> _events [ $ name ] [ ] = $ data ? [ $ handler , $ data ] : [ $ handler ] ; } | bind only one event |
29,728 | public function on ( $ name , $ handler , $ data = array ( ) , $ append = true ) { $ this -> ensureEvents ( ) ; if ( $ append || empty ( $ this -> _events [ $ name ] ) ) { $ this -> _events [ $ name ] [ ] = $ data ? [ $ handler , $ data ] : [ $ handler ] ; } else { array_unshift ( $ this -> _events [ $ name ] , $ data ? [ $ handler , $ data ] : [ $ handler ] ) ; } } | bind event if append = false then unshift the first |
29,729 | public function trigger ( $ name , $ event = null ) { $ this -> ensureEvents ( ) ; $ this -> ensureEventListeners ( ) ; $ this -> bindEventListenersEvents ( ) ; if ( ! empty ( $ this -> _events [ $ name ] ) ) { $ args = func_get_args ( ) ; array_shift ( $ args ) ; if ( ! $ event instanceof Event ) { $ event = new Event ( ) ; array_unshift ( $ args , $ event ) ; } if ( $ event -> sender === null ) { $ event -> sender = $ this ; } $ event -> name = $ name ; foreach ( $ this -> _events [ $ name ] as $ handler ) { if ( isset ( $ handler [ 1 ] ) && $ handler [ 1 ] ) { $ olddata = $ handler [ 1 ] ; $ event -> data = array_merge ( $ olddata , $ event -> data ) ; } if ( is_string ( $ handler [ 0 ] ) && strpos ( $ handler [ 0 ] , ':' ) === false ) { $ callable = [ $ this , $ handler [ 0 ] ] ; } else { $ callable = Ioc :: resolveCallable ( $ handler [ 0 ] ) ; } call_user_func_array ( $ callable , $ args ) ; if ( $ event -> isPropagationStopped ( ) ) { return ; } } } Event :: trigger ( $ this , $ name , $ event ) ; } | trigger named event |
29,730 | public function setEventListener ( $ listener ) { $ this -> ensureEventListeners ( ) ; $ this -> _eventListeners [ Ioc :: resolveClassName ( $ listener ) ] = $ listener ; return $ this ; } | set an eventListener |
29,731 | public function removeEventListener ( $ listener ) { $ this -> ensureEventListeners ( ) ; unset ( $ this -> _eventListeners [ Ioc :: resolveClassName ( $ listener ) ] ) ; return $ this ; } | remove eventListener s events to this |
29,732 | public function setEventListeners ( $ listeners ) { $ this -> ensureEventListeners ( ) ; foreach ( $ listeners as $ listener ) { $ this -> _eventListeners [ Ioc :: resolveClassName ( $ listener ) ] = $ listener ; } return $ this ; } | set property eventListeners |
29,733 | public function get ( $ id = null ) { if ( empty ( $ id ) ) { return false ; } $ fields = [ $ this -> alias . '.id' , $ this -> alias . '.value' , ] ; $ blockExists = $ this -> hasField ( 'block' ) ; if ( $ blockExists ) { $ fields [ ] = $ this -> alias . '.block' ; } $ conditions = [ $ this -> alias . '.id' => $ id ] ; $ this -> recursive = - 1 ; return $ this -> find ( 'first' , compact ( 'fields' , 'conditions' ) ) ; } | Return name of department by record ID . |
29,734 | public function getListDepartments ( $ includeBlock = true ) { $ fields = [ $ this -> alias . '.id' , $ this -> alias . '.value' , ] ; $ conditions = [ ] ; $ blockExists = $ this -> hasField ( 'block' ) ; if ( ! $ includeBlock && $ blockExists ) { $ conditions [ $ this -> alias . '.block' ] = false ; } $ order = [ $ this -> alias . '.value' => 'asc' ] ; $ this -> recursive = - 1 ; return $ this -> find ( 'list' , compact ( 'fields' , 'conditions' , 'order' ) ) ; } | Return List of departments |
29,735 | protected function _getMethodNameForType ( $ type = null ) { $ result = '_getValueForString' ; if ( empty ( $ type ) ) { return $ result ; } $ type = mb_strtolower ( $ type ) ; $ methodName = '_getValueFor' . Inflector :: camelize ( $ type ) ; if ( method_exists ( $ this , $ methodName ) ) { $ result = $ methodName ; } return $ result ; } | Return string of method name for type |
29,736 | protected function _getExtendedInfo ( $ fieldName = null , $ data = null ) { $ result = $ this -> getEmptyText ( ) ; if ( empty ( $ fieldName ) ) { return $ result ; } list ( $ modelName , ) = pluginSplit ( $ fieldName ) ; if ( empty ( $ modelName ) ) { return $ result ; } $ elementName = 'infoEmployeeExtend' . $ modelName ; if ( $ this -> _View -> elementExists ( 'CakeLdap.' . $ elementName ) ) { $ result = $ this -> _View -> element ( 'CakeLdap.' . $ elementName , [ 'data' => $ data ] ) ; } return $ result ; } | Return string of rendered element for extended information |
29,737 | protected function _getValueForDateTimeBase ( $ data = null , $ returnTableRow = true , $ timeFormat = null ) { if ( empty ( $ timeFormat ) ) { $ timeFormat = '%x %X' ; } if ( empty ( $ data ) ) { $ result = $ this -> ViewExtension -> showEmpty ( $ data ) ; } else { $ result = $ this -> Time -> i18nFormat ( $ data , $ timeFormat ) ; } if ( $ returnTableRow ) { $ result = [ $ result , [ 'class' => 'text-center' ] ] ; } return $ result ; } | Return string of formatted date |
29,738 | protected function _getValueForBindModelBase ( $ data = null , $ returnTableRow = true , $ fullData = null , $ linkOpt = null , $ idField = null , $ controller = null ) { $ result = $ this -> ViewExtension -> showEmpty ( $ data ) ; if ( empty ( $ idField ) || empty ( $ controller ) || empty ( $ fullData ) || ! is_array ( $ fullData ) ) { return $ result ; } $ idField = ( string ) $ idField ; if ( ctype_digit ( $ idField ) ) { $ id = $ idField ; } else { $ id = Hash :: get ( $ fullData , $ idField ) ; } if ( ! empty ( $ id ) ) { $ methodLink = 'popupModalLink' ; $ result = $ this -> ViewExtension -> $ methodLink ( $ result , [ 'controller' => $ controller , 'action' => 'view' , $ id ] , $ linkOpt ) ; } return $ result ; } | Return string of A tag with href to binded model |
29,739 | protected function _getValueForNumberBase ( $ data = null , $ returnTableRow = true , $ places = 0 ) { if ( $ data === null ) { $ result = $ this -> ViewExtension -> showEmpty ( $ data ) ; } else { $ result = $ this -> Number -> format ( $ data , [ 'thousands' => ' ' , 'before' => '' , 'places' => ( int ) $ places ] ) ; } if ( $ returnTableRow ) { $ result = [ $ result , [ 'class' => 'text-right' ] ] ; } return $ result ; } | Return string of formatted number |
29,740 | protected function _getValueForStringBase ( $ data = null , $ returnTableRow = true ) { $ result = $ this -> ViewExtension -> showEmpty ( $ data ) ; return $ result ; } | Return string with value if value is not empty . Otherwise Empty message . |
29,741 | protected function _getValueForBoolean ( $ data = null , $ returnTableRow = true ) { $ result = $ this -> ViewExtension -> yesNo ( $ data ) ; if ( $ returnTableRow ) { $ result = [ $ result , [ 'class' => 'text-center' ] ] ; } return $ result ; } | Return string state of data Yes or No |
29,742 | protected function _getValueForGuid ( $ data = null , $ returnTableRow = true ) { $ result = $ this -> ViewExtension -> showEmpty ( $ data , '{' . h ( $ data ) . '}' ) ; return $ result ; } | Return string with GUID |
29,743 | protected function _getValueForEmployee ( $ data = null , $ returnTableRow = true , $ fullData = null , $ linkOpt = null ) { return $ this -> _getValueForBindModelBase ( $ data , $ returnTableRow , $ fullData , $ linkOpt , 'Employee.id' , 'employees' ) ; } | Return string of A tag with href to binded model Employee |
29,744 | protected function _getValueForManager ( $ data = null , $ returnTableRow = true , $ fullData = null , $ linkOpt = null ) { $ result = $ this -> _getValueForBindModelBase ( $ data , $ returnTableRow , $ fullData , $ linkOpt , 'Manager.id' , 'employees' ) ; if ( empty ( $ data ) ) { return $ result ; } $ managerTitle = Hash :: get ( $ fullData , 'Manager.' . CAKE_LDAP_LDAP_ATTRIBUTE_TITLE ) ; if ( empty ( $ managerTitle ) ) { return $ result ; } $ result .= ' - ' . h ( $ managerTitle ) ; return $ result ; } | Return string of A tag with href to binded model Manager |
29,745 | protected function _getValueForSubordinate ( $ data = null , $ returnTableRow = true , $ fullData = null , $ linkOpt = null ) { $ subordinateId = Hash :: get ( $ data , 'id' ) ; $ subordinateName = Hash :: get ( $ data , 'name' ) ; $ result = $ this -> _getValueForBindModelBase ( $ subordinateName , $ returnTableRow , $ fullData , $ linkOpt , $ subordinateId , 'employees' ) ; if ( empty ( $ data ) ) { return $ result ; } $ subordinateTitle = Hash :: get ( $ data , CAKE_LDAP_LDAP_ATTRIBUTE_TITLE ) ; if ( empty ( $ subordinateTitle ) ) { return $ result ; } $ result .= ' - ' . h ( $ subordinateTitle ) ; return $ result ; } | Return string of A tag with href to binded model Subordinate |
29,746 | protected function _getValueForDepartment ( $ data = null , $ returnTableRow = true , $ fullData = null , $ linkOpt = null ) { if ( ! is_array ( $ linkOpt ) ) { $ linkOpt = [ ] ; } $ linkOpt [ 'data-modal-size' ] = 'sm' ; return $ this -> _getValueForBindModelBase ( $ data , $ returnTableRow , $ fullData , $ linkOpt , 'Department.id' , 'departments' ) ; } | Return string of A tag with href to binded model Department |
29,747 | public function transform ( $ value ) { if ( null === $ value ) { return '' ; } if ( ! $ this -> mask ) { return $ value ; } return str_repeat ( $ this -> maskSymbol , $ this -> maskLength ) ; } | Transforms a password type into mask symbol . |
29,748 | protected function generateUniqueCode ( $ file , $ code ) { $ file = filename ( $ file ) ; $ base = 999 ; $ base -= floor ( sqrt ( $ base * $ this -> getChecksum ( $ file ) ) / 1000 ) ; $ base = crossfoot ( $ base ) ; $ base = sprintf ( "%03d" , $ base ) ; $ base = strrev ( $ base ) ; $ base .= $ code ; return $ base ; } | Generates an unique code for each exception type . |
29,749 | protected function getChecksum ( $ string ) { $ length = strlen ( $ string ) ; $ checksum = 0 ; for ( $ i = 0 ; $ i < $ length ; ++ $ i ) { $ checksum += ord ( $ string { $ i } ) * $ i ; } return $ checksum ; } | Returns checksum for passed input . |
29,750 | public function addNamespace ( $ namespace ) { $ result = in_array ( $ namespace , $ this -> getNamespaces ( ) ) ; if ( false === $ result ) { if ( is_string ( $ namespace ) ) { $ namespace = [ $ namespace ] ; } foreach ( $ namespace as $ singleNamespace ) { $ this -> namespaces [ ] = $ singleNamespace ; } $ this -> namespaceChanged ( ) ; $ result = true ; } return $ result ; } | Adds a namespace to the list of active namespaces . |
29,751 | public function __ ( $ key , $ arguments = null ) { return $ this -> translate ( $ key , $ arguments , self :: MODE_TRANSLATE_ENCODE ) ; } | Translates a string and encodes it . |
29,752 | protected function namespaceChanged ( ) { $ encoding = $ this -> getEncoding ( ) ; $ redirectLocale = $ this -> getRedirectLocale ( ) ; if ( ( ! self :: $ translatorInterfaces ) || ( false === isset ( self :: $ translatorInterfaces [ $ encoding ] ) ) ) { self :: $ translatorInterfaces [ $ encoding ] = $ this -> translatorInterfaceFactory ( ) ; } $ locale = ( $ redirectLocale !== null ) ? $ redirectLocale : $ this -> getLocale ( ) ; $ this -> setTranslationTableUid ( self :: $ translatorInterfaces [ $ encoding ] -> initLocaleNamespace ( $ locale , $ this -> getNamespaces ( ) ) ) ; return true ; } | This method is intend to re - initialize the namespaces in translation - tables . |
29,753 | protected function translate ( $ key , $ arguments = null , $ mode = self :: MODE_TRANSLATE ) { $ encoding = $ this -> getEncoding ( ) ; if ( false === $ this -> hasNamespace ( ) ) { throw new Doozr_I18n_Service_Exception ( 'Translation without namespace is not possible. Please set a namespace via setNamespace(...) ' . 'or addNamespace(...) first.' ) ; } $ translation = self :: $ translatorInterfaces [ $ encoding ] -> lookup ( $ key , $ this -> getTranslationTableUid ( ) , $ arguments ) ; switch ( $ mode ) { case self :: MODE_TRANSLATE_ENCODE : $ translation = htmlspecialchars ( $ translation , ENT_QUOTES & ENT_DISALLOWED & ENT_HTML5 , 'UTF-8' ) ; break ; case self :: MODE_TRANSLATE_ENCODE_PLUS : $ translation = htmlentities ( $ translation , ENT_QUOTES & ENT_DISALLOWED & ENT_HTML5 , 'UTF-8' , false ) ; break ; } return $ translation ; } | Translates a passes string . |
29,754 | public static function seemsUtf8 ( $ string ) { for ( $ i = 0 ; $ i < strlen ( $ string ) ; $ i ++ ) { if ( ord ( $ string [ $ i ] ) < 0x80 ) continue ; elseif ( ( ord ( $ string [ $ i ] ) & 0xE0 ) == 0xC0 ) $ n = 1 ; elseif ( ( ord ( $ string [ $ i ] ) & 0xF0 ) == 0xE0 ) $ n = 2 ; elseif ( ( ord ( $ string [ $ i ] ) & 0xF8 ) == 0xF0 ) $ n = 3 ; elseif ( ( ord ( $ string [ $ i ] ) & 0xFC ) == 0xF8 ) $ n = 4 ; elseif ( ( ord ( $ string [ $ i ] ) & 0xFE ) == 0xFC ) $ n = 5 ; else return false ; for ( $ j = 0 ; $ j < $ n ; $ j ++ ) { if ( ( ++ $ i == strlen ( $ string ) ) || ( ( ord ( $ string [ $ i ] ) & 0xC0 ) != 0x80 ) ) return false ; } } return true ; } | Check if a string has utf7 characters in it |
29,755 | public static function slug ( $ text , $ separator = '-' ) { $ text = self :: unaccent ( $ text ) ; return self :: postProcessText ( $ text , $ separator ) ; } | Does not transliterate correctly eastern languages |
29,756 | private static function postProcessText ( $ text , $ separator ) { if ( function_exists ( 'mb_strtolower' ) ) { $ text = mb_strtolower ( $ text ) ; } else { $ text = strtolower ( $ text ) ; } $ text = preg_replace ( '/\W/' , ' ' , $ text ) ; $ text = strtolower ( preg_replace ( '/[^A-Za-z0-9\/]+/' , $ separator , preg_replace ( '/([a-z\d])([A-Z])/' , '\1_\2' , preg_replace ( '/([A-Z]+)([A-Z][a-z])/' , '\1_\2' , preg_replace ( '/::/' , '/' , $ text ) ) ) ) ) ; return trim ( $ text , $ separator ) ; } | Cleans up the text and adds separator |
29,757 | public function pushLogToSession ( bool $ clean ) : void { if ( ! $ this -> isAllowedNotify ( ) ) { return ; } if ( ! empty ( Splash :: log ( ) -> err ) ) { foreach ( Splash :: log ( ) -> err as $ message ) { $ this -> session -> getFlashBag ( ) -> add ( 'error' , $ message ) ; } } if ( ! empty ( Splash :: log ( ) -> war ) ) { foreach ( Splash :: log ( ) -> war as $ message ) { $ this -> session -> getFlashBag ( ) -> add ( 'warning' , $ message ) ; } } if ( ! empty ( Splash :: log ( ) -> msg ) ) { foreach ( Splash :: log ( ) -> msg as $ message ) { $ this -> session -> getFlashBag ( ) -> add ( 'success' , $ message ) ; } } if ( $ clean ) { Splash :: log ( ) -> cleanLog ( ) ; } } | Push Splash Log to Symfoiny Session |
29,758 | public function isAllowedNotify ( ) : bool { if ( ! isset ( $ this -> authChecker ) ) { return true ; } try { foreach ( $ this -> getCoreParameter ( 'notify' ) as $ notifyRole ) { if ( $ this -> authChecker -> isGranted ( $ notifyRole ) ) { return true ; } } } catch ( AuthenticationCredentialsNotFoundException $ exc ) { return false ; } return false ; } | Decide if Current Logged User Needs to Be Notified or Not |
29,759 | public function mainAction ( Request $ request ) { ini_set ( 'display_errors' , 0 ) ; error_reporting ( E_ERROR ) ; define ( 'SPLASH_SERVER_MODE' , 1 ) ; $ userAgent = $ request -> headers -> get ( 'User-Agent' ) ; if ( is_string ( $ userAgent ) && ( false !== strpos ( $ userAgent , 'SOAP' ) ) ) { $ server = new \ SoapServer ( dirname ( __DIR__ ) . '/Resources/wsdl/splash.wsdl' , array ( 'cache_wsdl' => WSDL_CACHE_NONE ) ) ; $ server -> setObject ( $ this ) ; register_shutdown_function ( array ( self :: class , 'fatalHandler' ) ) ; $ response = new Response ( ) ; $ response -> headers -> set ( 'Content-Type' , 'text/xml; charset=ISO-8859-1' ) ; ob_start ( ) ; $ server -> handle ( ) ; $ response -> setContent ( ob_get_clean ( ) ) ; return $ response ; } if ( ! empty ( $ request -> get ( 'node' ) ) && $ this -> get ( 'splash.connectors.manager' ) -> identify ( $ request -> get ( 'node' ) ) ) { Splash :: log ( ) -> deb ( 'Splash Started In System Debug Mode' ) ; ini_set ( 'display_errors' , 1 ) ; error_reporting ( E_ALL ) ; $ html = SplashServer :: getStatusInformations ( ) ; $ html .= Splash :: log ( ) -> getHtmlLogList ( ) ; return new Response ( $ html ) ; } return new Response ( 'This WebService Provide no Description.' ) ; } | Execute Main External SOAP Requests . |
29,760 | public function showFileAction ( ) { $ id = $ this -> getRequest ( ) -> get ( $ this -> admin -> getIdParameter ( ) ) ; $ invoice = $ this -> admin -> getObject ( $ id ) ; if ( ! $ invoice ) { throw $ this -> createNotFoundException ( sprintf ( 'Unable to find the invoice with id : %s' , $ id ) ) ; } $ this -> admin -> checkAccess ( 'show' , $ invoice ) ; return new Response ( $ invoice -> getFile ( ) , 200 , [ 'Content-Type' => 'application/pdf' ] ) ; } | show file action . |
29,761 | public function generateAction ( Request $ request , $ order_id ) { $ manager = $ this -> getDoctrine ( ) -> getManager ( ) ; $ repo = $ manager -> getRepository ( 'LibrinfoEcommerceBundle:Order' ) ; $ order = $ repo -> find ( $ order_id ) ; if ( ! $ order ) { throw $ this -> createNotFoundException ( sprintf ( 'Unable to find the order with id : %s' , $ order_id ) ) ; } $ this -> admin -> checkAccess ( 'create' ) ; if ( $ order -> getCheckoutState ( ) != 'completed' ) { throw new \ Exception ( 'Checkout is not completed' ) ; } if ( count ( $ order -> getInvoices ( ) ) > 0 ) { throw new \ Exception ( 'Invoice has already been generated' ) ; } $ invoiceFactory = $ this -> container -> get ( 'librinfo_ecommerce.factory.invoice' ) ; $ invoice = $ invoiceFactory -> createForOrder ( $ order ) ; $ manager -> persist ( $ invoice ) ; $ manager -> flush ( ) ; $ order -> addInvoice ( $ invoice ) ; $ html = $ this -> renderView ( 'LibrinfoEcommerceBundle:OrderAdmin/Show:_invoices_inner.html.twig' , [ 'object' => $ order ] ) ; return new JsonResponse ( [ 'html' => $ html ] ) ; } | Generate invoice . |
29,762 | private function setCookieJar ( ) { switch ( $ this -> options [ 'cookie_type' ] ) { case 'array' : $ this -> cookiejar = new CookieJar ( ) ; break ; case 'file' : $ this -> cookiejar = new FileCookieJar ( $ this -> options [ 'cookie_file_name' ] ) ; break ; case 'session' : $ this -> cookiejar = new SessionCookieJar ( $ this -> options [ 'cookie_session_key' ] ) ; break ; default : throw new YouHostingException ( "You didn't specify a valid cookie type!" ) ; } } | Get the relevant cookie jar |
29,763 | public function searchClientId ( $ email ) { $ response = $ this -> get ( '/en/client/manage' , array ( 'email' => $ email , 'submit' => "Search" , ) ) ; return trim ( $ this -> getBetween ( ( string ) $ response -> getBody ( ) , '/en/client/view/id/' , '"' ) ) ; } | Get a client ID from an e - mail address |
29,764 | private function sendRequest ( $ request ) { $ response = $ this -> webclient -> send ( $ request ) ; if ( ! $ this -> isLoggedIn ( $ response ) ) { $ this -> webLogin ( ) ; $ response = $ this -> webclient -> send ( $ request ) ; } if ( $ response -> getStatusCode ( ) == 500 ) { throw new YouHostingException ( "Unknown YouHosting Error" ) ; } return $ response ; } | Send the request away |
29,765 | private function isLoggedIn ( ResponseInterface $ response ) { if ( $ response -> getStatusCode ( ) != 302 ) { return true ; } $ location = $ response -> getHeader ( 'Location' ) ; if ( strpos ( $ location , "/en/auth" ) !== false ) { return false ; } return true ; } | Check if the request failed because the user was not logged in |
29,766 | protected function webLogin ( ) { $ response = $ this -> webclient -> get ( "/en/auth" , array ( 'cookies' => $ this -> cookiejar , ) ) ; $ csrf = $ this -> getBetween ( ( string ) $ response -> getBody ( ) , "document.write('" , "');" ) ; $ csrf = str_replace ( "' + '" , "" , $ csrf ) ; $ name = $ this -> getBetween ( $ csrf , 'name="' , '"' ) ; $ value = $ this -> getBetween ( $ csrf , 'value="' , '"' ) ; $ response = $ this -> webclient -> post ( "/en/auth" , array ( 'body' => array ( 'submit' => 'Login' , 'email' => $ this -> username , 'password' => $ this -> password , $ name => $ value , ) , ) ) ; if ( $ response -> getStatusCode ( ) == 200 ) { throw new YouHostingException ( $ this -> getBetween ( ( string ) $ response -> getBody ( ) , '<div class="notification info">' , '</div>' ) ) ; } } | Login to YouHosting s website |
29,767 | public function createClient ( Client $ client , $ password ) { $ data = $ client -> toArray ( ) ; $ data [ 'password_confirm' ] = $ data [ 'password' ] = $ password ; $ data [ 'send_email' ] = 0 ; $ data [ 'submit' ] = 'Save' ; $ response = $ this -> post ( '/en/client/add' , $ data ) ; if ( $ response -> getStatusCode ( ) == 200 ) { $ error = $ this -> getBetween ( ( string ) $ response -> getBody ( ) , '<ul class="errors">' , '</ul>' ) ; $ error = $ this -> getBetween ( $ error , '<li>' , '</li>' ) ; throw new YouHostingException ( "Unable to create profile: " . $ error ) ; } $ response = $ this -> get ( $ response -> getHeader ( 'Location' ) ) ; $ client -> id = $ this -> getBetweenReverse ( ( string ) $ response -> getBody ( ) , '/en/client/view/id/' , '">' . $ client -> email ) ; return $ client ; } | Create a new client on YouHosting |
29,768 | public function getClient ( $ id ) { $ response = $ this -> get ( '/en/client/edit/id/' . $ id ) ; $ content = trim ( $ this -> getBetween ( ( string ) $ response -> getBody ( ) , '<table class="wide">' , "</table>" ) ) ; $ client = new Client ( array ( 'id' => $ id , 'email' => $ this -> getBetween ( $ content , '<input type="text" name="email" id="email" value="' , '">' ) , 'first_name' => $ this -> getBetween ( $ content , '<input type="text" name="first_name" id="first_name" value="' , '">' ) , 'last_name' => $ this -> getBetween ( $ content , '<input type="text" name="last_name" id="last_name" value="' , '">' ) , 'company' => $ this -> getBetween ( $ content , '<input type="text" name="company" id="company" value="' , '">' ) , 'address_1' => $ this -> getBetween ( $ content , '<input type="text" name="address_1" id="address_1" value="' , '">' ) , 'address_2' => $ this -> getBetween ( $ content , '<input type="text" name="address_2" id="address_2" value="' , '">' ) , 'country' => $ this -> getBetweenReverse ( $ content , '<option value="' , '" selected="selected">' ) , 'city' => $ this -> getBetween ( $ content , '<input type="text" name="city" id="city" value="' , '">' ) , 'state' => $ this -> getBetween ( $ content , '<input type="text" name="state" id="state" value="' , '">' ) , 'zip' => $ this -> getBetween ( $ content , '<input type="text" name="zip" id="zip" value="' , '">' ) , 'phone_cc' => $ this -> getBetween ( $ content , '<input type="text" name="phone_cc" id="phone_cc" value="' , '">' ) , 'phone' => $ this -> getBetween ( $ content , '<input type="text" name="phone" id="phone" value="' , '">' ) , ) ) ; return $ client ; } | Get a client from YouHosting |
29,769 | protected function GetConstructParams ( ) { return array ( $ this -> name , $ this -> typeDef , $ this -> defaultValue , $ this -> isNullable , $ this -> keyInfo , $ this -> foreignKey , $ this -> foreignKeyConstraint ) ; } | Gets the constructor parameters |
29,770 | function InnerJoin ( Table $ table , Condition $ condition , $ prepend = false ) { return $ this -> Join ( $ table , JoinType :: Inner ( ) , $ condition , $ prepend ) ; } | Returns a new source as inner join of this and the given source . |
29,771 | function LeftJoin ( Table $ table , Condition $ condition , $ prepend = false ) { return $ this -> Join ( $ table , JoinType :: Left ( ) , $ condition , $ prepend ) ; } | Returns a new source as left join of this and the given source . |
29,772 | function RightJoin ( Table $ table , Condition $ condition , $ prepend = false ) { return $ this -> Join ( $ table , JoinType :: Right ( ) , $ condition , $ prepend ) ; } | Returns a new source as right join of this and the given source . |
29,773 | function OuterJoin ( Table $ table , Condition $ condition , $ prepend = false ) { return $ this -> Join ( $ table , JoinType :: Outer ( ) , $ condition , $ prepend ) ; } | Returns a new source as outer join of this and the given source . |
29,774 | function Join ( Table $ table , JoinType $ join , Condition $ condition , $ prepend = false ) { $ result = $ this -> Duplicate ( ) ; if ( $ prepend ) { array_unshift ( $ result -> tables , $ table ) ; array_unshift ( $ result -> joins , $ join ) ; array_unshift ( $ result -> conditions , $ condition ) ; } else { $ result -> tables [ ] = $ table ; $ result -> joins [ ] = $ join ; $ result -> conditions [ ] = $ condition ; } return $ result ; } | Returns a new source as given join of this and the given source . |
29,775 | function ToString ( ) { $ resultArr = array ( ( string ) $ this -> tables [ 0 ] ) ; foreach ( $ this -> tables as $ key => $ table ) { if ( $ key == 0 ) continue ; $ part = ( string ) $ this -> joins [ $ key - 1 ] ; $ part .= ' ' . ( string ) $ table ; $ part .= ' ON ' . ( string ) $ this -> conditions [ $ key - 1 ] ; $ resultArr [ ] = $ part ; } return join ( ' ' , $ resultArr ) ; } | String representation as needed in FROM statement . |
29,776 | private function Duplicate ( ) { $ result = new Join ( $ this -> connection ) ; $ result -> tables = $ this -> tables ; $ result -> joins = $ this -> joins ; $ result -> conditions = $ this -> conditions ; return $ result ; } | Clones this object . |
29,777 | private function init ( string $ url ) : void { $ this -> resource = curl_init ( $ url ) ; curl_setopt ( $ this -> resource , CURLOPT_RETURNTRANSFER , true ) ; curl_setopt ( $ this -> resource , CURLOPT_CONNECTTIMEOUT , $ this -> loader -> getTimeout ( ) ) ; curl_setopt ( $ this -> resource , CURLOPT_USERAGENT , $ this -> loader -> getUserAgent ( ) ) ; curl_setopt ( $ this -> resource , CURLOPT_HEADER , true ) ; curl_setopt ( $ this -> resource , CURLINFO_HEADER_OUT , true ) ; $ proxy_host = $ this -> loader -> getOption ( 'ProxyHost' ) ; if ( null !== $ proxy_host ) { $ proxy_protocol = $ this -> loader -> getOption ( 'ProxyProtocol' ) ; if ( null !== $ proxy_protocol ) { $ allowedProtocolls = [ StreamCreator :: PROXY_PROTOCOL_HTTP , StreamCreator :: PROXY_PROTOCOL_HTTPS ] ; if ( ! in_array ( $ proxy_protocol , $ allowedProtocolls ) ) { throw new Exception ( 'Invalid/unsupported value "' . $ proxy_protocol . '" for option "ProxyProtocol".' , Exception :: INVALID_OPTION ) ; } } else { $ proxy_protocol = StreamCreator :: PROXY_PROTOCOL_HTTP ; } $ proxy_port = $ this -> loader -> getOption ( 'ProxyPort' ) ; curl_setopt ( $ this -> resource , CURLOPT_PROXY , $ proxy_protocol . '://' . $ proxy_host ) ; if ( null !== $ proxy_port ) { curl_setopt ( $ this -> resource , CURLOPT_PROXYPORT , $ proxy_port ) ; } $ proxy_user = $ this -> loader -> getOption ( 'ProxyUser' ) ; if ( null !== $ proxy_user ) { $ proxy_password = $ this -> loader -> getOption ( 'ProxyPassword' ) ; $ proxy_auth = $ this -> loader -> getOption ( 'ProxyAuth' ) ; if ( null !== $ proxy_auth ) { $ allowedAuth = [ StreamCreator :: PROXY_AUTH_BASIC , StreamCreator :: PROXY_AUTH_NTLM ] ; if ( ! in_array ( $ proxy_auth , $ allowedAuth ) ) { throw new Exception ( 'Invalid/unsupported value "' . $ proxy_auth . '" for option "ProxyAuth".' , Exception :: INVALID_OPTION ) ; } } else { $ proxy_auth = StreamCreator :: PROXY_AUTH_BASIC ; } if ( StreamCreator :: PROXY_AUTH_NTLM === $ proxy_auth ) { curl_setopt ( $ this -> resource , CURLOPT_PROXYAUTH , CURLAUTH_NTLM ) ; } curl_setopt ( $ this -> resource , CURLOPT_PROXYUSERPWD , $ proxy_user . ':' . $ proxy_password ) ; } } } | initialize the connection |
29,778 | public function send ( $ method , $ url , $ payload = null ) { $ socket = @ fsockopen ( $ this -> host , $ this -> port , $ errno , $ errstr ) ; if ( ! $ socket ) { throw new RuntimeException ( $ errno . ': ' . $ errstr ) ; } $ request = sprintf ( "%s %s HTTP/1.1\r\nHost: %s:%d\r\nContent-Type: application/json\r\nConnection: close\r\n" , $ method , $ url , $ this -> host , $ this -> port ) ; if ( $ payload !== null ) { $ request .= 'Content-Length: ' . strlen ( $ payload ) . "\r\n\r\n" . $ payload ; } $ request .= "\r\n" ; if ( $ this -> debug ) { echo $ request ; } fwrite ( $ socket , $ request ) ; $ buffer = '' ; while ( ! feof ( $ socket ) ) { $ buffer .= fgets ( $ socket ) ; } list ( $ headers , $ body ) = explode ( "\r\n\r\n" , $ buffer ) ; return [ 'headers' => $ headers , 'body' => $ body ] ; } | Sends an HTTP request to the CouchDB server . |
29,779 | public function index ( $ locationId ) { $ location = Location :: findOrFail ( $ locationId ) ; $ this -> authorize ( 'view' , $ location ) ; return $ this -> respondRelatedPhones ( $ locationId , 'location' ) ; } | Produce a list of Phones related to a selected Location |
29,780 | protected function getDirectoryByNamespace ( $ namespace , $ create = true ) { if ( ! isset ( $ this -> directoriesByNamespace [ $ namespace ] ) ) { if ( $ this -> isFlatDirectoryStructure ( ) !== true ) { $ structure = explode ( self :: NAMESPACE_SEPARATOR , $ namespace ) ; } else { $ structure = [ $ namespace ] ; } $ targetDirectory = $ this -> getDirectory ( ) . implode ( DIRECTORY_SEPARATOR , $ structure ) ; if ( $ create === true && file_exists ( $ targetDirectory ) === false ) { if ( is_writeable ( $ this -> getDirectory ( ) ) === false ) { throw new Doozr_Cache_Service_Exception ( sprintf ( 'Directory: "%s". isn\'t writable. Check permissions and path.' , $ this -> getDirectory ( ) ) ) ; } $ directory = $ this -> getDirectory ( ) ; foreach ( $ structure as $ node ) { if ( file_exists ( $ directory . $ node ) === false ) { if ( ! mkdir ( $ directory . $ node , 0755 ) ) { throw new Doozr_Cache_Service_Exception ( sprintf ( 'Can\'t make directory "%s". Check permissions and path.' , $ directory ) ) ; } $ directory .= $ node . DIRECTORY_SEPARATOR ; } } $ this -> clear ( ) ; } $ this -> directoriesByNamespace [ $ namespace ] = $ targetDirectory . DIRECTORY_SEPARATOR ; } return $ this -> directoriesByNamespace [ $ namespace ] ; } | Returns the path to write cache files to for a given namespace . |
29,781 | public function purge ( $ namespace ) { $ this -> purgeRuntimeCache ( ) ; $ directory = $ this -> getDirectoryByNamespace ( $ namespace ) ; $ removedEntries = $ this -> removeEntries ( $ directory ) ; unset ( $ this -> directoriesByNamespace [ $ namespace ] ) ; $ this -> clear ( ) ; return $ removedEntries ; } | Flushes the cache . |
29,782 | public function exists ( $ key , $ namespace ) { $ key = $ this -> calculateUuid ( $ key ) ; return file_exists ( $ this -> getFilenameByKeyAndNamespace ( $ key , $ namespace ) ) ; } | Checks if a dataset exists . |
29,783 | protected function writeFile ( $ filename , array $ dataset ) { $ result = false ; $ fileHandle = @ fopen ( $ filename , 'wb' ) ; if ( ! $ fileHandle ) { throw new Doozr_Cache_Service_Exception ( sprintf ( 'Can\'t access "%s" to store cache data. Check access rights and path' , $ filename ) ) ; } if ( $ this -> getLocking ( ) === true ) { flock ( $ fileHandle , LOCK_EX ) ; } $ result = ( fwrite ( $ fileHandle , implode ( PHP_EOL , $ dataset ) ) !== false ) ; if ( $ this -> getLocking ( ) === true ) { flock ( $ fileHandle , LOCK_UN ) ; } fclose ( $ fileHandle ) ; return $ result ; } | Writes the passed data to file . |
29,784 | protected function readFile ( $ filename , $ locking = true ) { if ( ! ( $ fileHandle = @ fopen ( $ filename , 'rb' ) ) ) { throw new Doozr_Cache_Service_Exception ( sprintf ( 'Can\'t access cache file "%s". Check access rights and path.' , $ filename ) ) ; } ( $ locking === true ) ? : flock ( $ fileHandle , LOCK_SH ) ; $ expire = trim ( fgets ( $ fileHandle , 12 ) ) ; if ( $ this -> maxUserdataLineLength == 0 ) { $ userdata = trim ( fgets ( $ fileHandle ) ) ; } else { $ userdata = trim ( fgets ( $ fileHandle , $ this -> maxUserdataLineLength ) ) ; } $ buffer = '' ; while ( ! feof ( $ fileHandle ) ) { $ buffer .= fread ( $ fileHandle , 8192 ) ; } $ value = $ this -> decode ( $ buffer ) ; ( $ locking === true ) ? : flock ( $ fileHandle , LOCK_UN ) ; fclose ( $ fileHandle ) ; touch ( $ filename , time ( ) ) ; $ this -> clear ( ) ; return [ $ expire , $ userdata , $ value , ] ; } | Reads a file from filesystem modifies its last access time and returns values structured . |
29,785 | final public function __isset ( $ name ) : bool { if ( $ this -> propertyStorage -> propertyExists ( $ name ) ) { return true ; } return parent :: __isset ( $ name ) ; } | Magic method . |
29,786 | public function getHandlerFor ( string $ type ) { if ( empty ( $ this -> handlers [ $ type ] ) ) { throw new \ InvalidArgumentException ( 'There is no handler for the "' . $ type . '" criteria type.' ) ; } elseif ( is_object ( $ this -> handlers [ $ type ] ) && $ this -> handlers [ $ type ] instanceof CriteriaHandler ) { return $ this -> handlers [ $ type ] ; } return new $ this -> handlers [ $ type ] ; } | Get the handler for the given criteria type . |
29,787 | public function getBlogPosts ( ) { $ blog_posts = BlogPost :: get ( ) -> filter ( 'ParentID' , $ this -> ID ) -> where ( sprintf ( '"PublishDate" < \'%s\'' , Convert :: raw2sql ( DBDatetime :: now ( ) ) ) ) ; $ this -> extend ( 'updateGetBlogPosts' , $ blog_posts ) ; return $ blog_posts ; } | Return visible blog posts . |
29,788 | public function getArchives ( ) { $ all_posts = $ this -> getBlogPosts ( ) ; $ years = [ ] ; $ months = [ ] ; foreach ( $ all_posts as $ post ) { if ( preg_match ( '/^(\d\d\d\d)-(\d\d)-/' , $ post -> PublishDate , $ match ) ) { if ( empty ( $ years [ $ match [ 1 ] ] ) ) { $ years [ $ match [ 1 ] ] = 1 ; } else { $ years [ $ match [ 1 ] ] ++ ; } if ( empty ( $ months [ $ match [ 1 ] . '-' . $ match [ 2 ] ] ) ) { $ months [ $ match [ 1 ] . '-' . $ match [ 2 ] ] = 1 ; } else { $ months [ $ match [ 1 ] . '-' . $ match [ 2 ] ] ++ ; } } } $ output = ArrayData :: create ( [ 'Years' => ArrayList :: create ( ) , 'Months' => ArrayList :: create ( ) , ] ) ; $ link_base = $ this -> Link ( ) . 'archive/' ; foreach ( $ years as $ year => $ count ) { $ yr = DBYear :: create ( ) ; $ yr -> setValue ( $ year ) ; $ cnt = DBInt :: create ( ) ; $ cnt -> setValue ( $ count ) ; $ result = ArrayData :: create ( [ 'Year' => $ yr , 'Count' => $ cnt , 'Link' => $ link_base . $ year . '/' ] ) ; $ output -> Years -> push ( $ result ) ; } foreach ( $ months as $ month => $ count ) { $ mth = DBDate :: create ( ) ; $ mth -> setValue ( $ month . '-01' ) ; $ cnt = DBInt :: create ( ) ; $ cnt -> setValue ( $ count ) ; $ result = ArrayData :: create ( [ 'Month' => $ mth , 'Count' => $ cnt , 'Link' => $ link_base . str_replace ( '-' , '/' , $ month ) . '/' ] ) ; $ output -> Months -> push ( $ result ) ; } return $ output ; } | Return all years & months containing visible blog posts |
29,789 | public function getSize ( ) { return ( true === isset ( $ this -> getFile ( ) [ 'size' ] ) ) ? $ this -> getFile ( ) [ 'size' ] : filesize ( $ this -> getLocation ( ) ) ; } | Retrieve the file size . |
29,790 | public function quoteIdent ( $ ident ) { if ( is_array ( $ ident ) ) { return array_map ( function ( $ ident ) { return '`' . str_replace ( array ( '`' , '.' ) , array ( '``' , '`.`' ) , $ ident ) . '`' ; } , $ ident ) ; } else { return '`' . str_replace ( array ( '`' , '.' ) , array ( '``' , '`.`' ) , $ ident ) . '`' ; } } | Quote identifier preserve dot . |
29,791 | protected function addJoin ( $ args , $ buffer_id , $ label ) { array_push ( $ args , $ label ) ; $ this -> buffers [ $ buffer_id ] [ ] = $ args ; } | Add join statement to buffer . |
29,792 | public final function compile ( ) { try { $ q = $ this -> compileQuery ( ) ; if ( $ this -> log_query ) { error_log ( sprintf ( "SQL Query (compile):\n%s" , $ this -> query_sql ) ) ; } return $ q ; } catch ( \ Exception $ ex ) { ob_end_clean ( ) ; throw $ ex ; } } | Call compile function in a safe way . |
29,793 | public function exec ( ) { if ( $ this -> query_sql === null ) { $ this -> compile ( ) ; } if ( $ this -> log_query ) { error_log ( sprintf ( "SQL Query (exec):\n%s" , $ this -> query_sql ) ) ; } if ( empty ( $ this -> query_params ) ) { $ t = microtime ( true ) ; try { $ r = $ this -> pdo -> exec ( $ this -> query_sql ) ; if ( $ this -> log_query ) { error_log ( sprintf ( "SQL Query time: %F ms (exec)." , ( microtime ( true ) - $ t ) * 1000 ) ) ; } } catch ( \ PDOException $ ex ) { throw new FlupdoException ( $ ex -> getMessage ( ) , $ ex -> getCode ( ) , $ ex , $ this -> query_sql , $ this -> query_params ) ; } if ( $ r === FALSE ) { throw new FlupdoException ( vsprintf ( "SQLSTATE[%s]: Error %s: %s" , $ this -> pdo -> errorInfo ( ) ) , $ this -> pdo -> errorCode ( ) , null , $ this -> query_sql , $ this -> query_params ) ; } return $ r ; } else { $ stmt = $ this -> query ( ) ; return $ stmt -> rowCount ( ) ; } } | Builds and executes an SQL statement returning the number of affected rows . |
29,794 | protected function explain ( ) { if ( $ this -> query_sql === null ) { $ this -> compile ( ) ; } $ sql = "\n EXPLAIN\n" . $ this -> interpolateQuery ( $ this -> query_sql , $ this -> query_params ) ; $ explain = $ this -> pdo -> query ( $ sql ) ; $ data = $ explain -> fetchAll ( \ PDO :: FETCH_ASSOC ) ; $ col_len = array ( ) ; $ t = "\n" ; foreach ( $ data as $ row ) { foreach ( $ row as $ k => $ v ) { $ col_len [ $ k ] = isset ( $ col_len [ $ k ] ) ? max ( $ col_len [ $ k ] , strlen ( $ v ) ) : strlen ( $ v ) ; } } foreach ( $ col_len as $ k => $ len ) { $ col_len [ $ k ] = max ( $ len , strlen ( $ k ) ) ; } foreach ( $ col_len as $ k => $ len ) { $ t .= '+' . str_repeat ( '-' , $ len + 2 ) ; } $ t .= "+\n" ; foreach ( $ col_len as $ k => $ len ) { $ t .= sprintf ( '| %-' . $ len . 's ' , $ k ) ; } $ t .= "+\n" ; foreach ( $ col_len as $ k => $ len ) { $ t .= '+' . str_repeat ( '-' , $ len + 2 ) ; } $ t .= "+\n" ; foreach ( $ data as $ row ) { foreach ( $ row as $ k => $ v ) { $ t .= sprintf ( '| %-' . $ col_len [ $ k ] . 's ' , $ v ) ; } $ t .= "|\n" ; } foreach ( $ col_len as $ k => $ len ) { $ t .= '+' . str_repeat ( '-' , $ len + 2 ) ; } $ t .= "+\n" ; if ( function_exists ( 'debug_msg' ) ) { debug_msg ( 'Explain last query:%s' , $ t ) ; } $ this -> uncompile ( ) ; } | Explain the query and dump result to log . |
29,795 | public function prepare ( $ driver_options = array ( ) ) { if ( $ this -> query_sql === null ) { $ this -> compile ( ) ; } return $ this -> pdo -> prepare ( $ this -> query_sql , $ driver_options ) ; } | Builds and prepares a statement for execution returns a statement object . |
29,796 | public function fetchAll ( $ key_column = null ) { $ result = $ this -> query ( ) ; if ( $ key_column === null ) { $ list = $ result -> fetchAll ( \ PDO :: FETCH_ASSOC ) ; } else { $ list = array ( ) ; while ( ( $ item = $ result -> fetch ( \ PDO :: FETCH_ASSOC ) ) ) { $ list [ $ item [ $ key_column ] ] = $ item ; } return $ list ; } $ result -> closeCursor ( ) ; return $ list ; } | Fetch everything into array |
29,797 | protected function sqlFinish ( ) { $ this -> query_sql = ob_get_clean ( ) ; if ( ! empty ( $ this -> query_params ) ) { $ this -> query_params = call_user_func_array ( 'array_merge' , $ this -> query_params ) ; } return $ this ; } | Finish SQL generating . Picks up the query from output buffer . |
29,798 | protected function sqlComment ( $ buffer_id ) { if ( isset ( $ this -> buffers [ $ buffer_id ] ) ) { foreach ( $ this -> buffers [ $ buffer_id ] as $ buf ) { echo $ this -> indent , '-- ' , str_replace ( array ( "\r" , "\n" ) , array ( '' , "\n" . $ this -> indent . '-- ' ) , $ this -> sqlRawBuffer ( $ buf ) ) , "\n" ; } } } | Generate SQL comment . |
29,799 | protected function sqlFlag ( $ buffer_id ) { if ( isset ( $ this -> buffers [ $ buffer_id ] ) ) { if ( isset ( $ this -> buffers [ $ flag_buf ] ) ) { echo ' ' , $ this -> buffers [ $ flag_buf ] ; } } } | Generate flag fragment . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.