idx
int64
0
60.3k
question
stringlengths
64
4.24k
target
stringlengths
5
618
31,600
public function removeFolders ( $ regex = null ) { Argument :: i ( ) -> test ( 1 , 'string' , 'null' ) ; $ this -> absolute ( ) ; $ folders = $ this -> getFolders ( $ regex ) ; if ( empty ( $ folders ) ) { return $ this ; } foreach ( $ folders as $ folder ) { $ folder -> remove ( ) ; } return $ this ; }
Removes a folder given the path and optionally the regular expression
31,601
function AddHour ( Hour $ hour ) { foreach ( $ this -> hours as $ currentHour ) { if ( $ currentHour -> Hour == $ hour -> Hour ) return ; } $ this -> hours [ ] = $ hour ; }
Adds an hour if not already added
31,602
function RemoveHour ( Hour $ hour ) { $ result = array ( ) ; foreach ( $ this -> hours as $ currentHour ) { if ( $ currentHour -> Hour != $ hour -> Hour ) $ result [ ] = $ currentHour ; } $ this -> hours = $ result ; }
Removes an hour from the list of hours if present
31,603
public function renderToolProspectsWidgetsContentAction ( ) { $ melisKey = $ this -> params ( ) -> fromRoute ( 'melisKey' , '' ) ; $ view = new ViewModel ( ) ; $ view -> melisKey = $ melisKey ; return $ view ; }
Renders the Widget Container
31,604
public function renderToolProspectsWidgetNumProspectsAction ( ) { $ melisTool = $ this -> getServiceLocator ( ) -> get ( 'MelisCoreTool' ) ; $ melisKey = $ this -> params ( ) -> fromRoute ( 'melisKey' , '' ) ; $ melisProspectsService = $ this -> getServiceLocator ( ) -> get ( 'MelisProspectsService' ) ; $ numPropects = $ melisProspectsService -> getProspectsDataForWidgets ( 'numPropects' ) ; $ view = new ViewModel ( ) ; $ view -> melisKey = $ melisKey ; $ view -> numPropects = $ numPropects ; return $ view ; }
Renders the Number of Prospects
31,605
public function renderToolProspectsHeaderRefreshAction ( ) { $ melisKey = $ this -> params ( ) -> fromRoute ( 'melisKey' , '' ) ; $ view = new ViewModel ( ) ; $ view -> melisKey = $ melisKey ; return $ view ; }
Renders the Refresh Button of the tool
31,606
public function renderToolProspectsModalContainerAction ( ) { $ id = $ this -> params ( ) -> fromQuery ( 'id' ) ; $ view = new ViewModel ( ) ; $ melisKey = $ this -> params ( ) -> fromRoute ( 'melisKey' , '' ) ; $ view -> melisKey = $ melisKey ; $ view -> id = $ id ; $ view -> setTerminal ( true ) ; return $ view ; }
Renders to modal container
31,607
public function renderToolProspectUpdateFormAction ( ) { $ prospectId = ( int ) $ this -> params ( ) -> fromQuery ( 'prospectId' , '' ) ; $ melisCoreConfig = $ this -> serviceLocator -> get ( 'MelisCoreConfig' ) ; $ appConfigForm = $ melisCoreConfig -> getFormMergedAndOrdered ( 'melistoolprospects/tools/melistoolprospects_tool_prospects/forms/melistoolprospects_tool_prospects_update' , 'melistoolprospects_tool_prospects_update' ) ; $ factory = new \ Zend \ Form \ Factory ( ) ; $ formElements = $ this -> serviceLocator -> get ( 'FormElementManager' ) ; $ factory -> setFormElementManager ( $ formElements ) ; $ form = $ factory -> createForm ( $ appConfigForm ) ; $ prospectTable = $ this -> getServiceLocator ( ) -> get ( 'MelisProspects' ) ; $ themeTable = $ this -> getServiceLocator ( ) -> get ( 'MelisCmsProspectsThemeTable' ) ; $ themeItemTable = $ this -> getServiceLocator ( ) -> get ( 'MelisCmsProspectsThemeItemTable' ) ; $ container = new Container ( 'meliscore' ) ; if ( ! empty ( $ prospectId ) ) { $ prospect = $ prospectTable -> getEntryById ( $ prospectId ) -> current ( ) ; if ( ! empty ( $ prospect ) ) { $ theme = $ themeItemTable -> getEntryById ( $ prospect -> pros_theme ) -> current ( ) ; if ( ! empty ( $ theme ) ) { $ temp = $ themeItemTable -> getItemByThemeId ( $ theme -> pros_theme_id , ( int ) $ container [ 'melis-lang-id' ] , true ) ; $ data = array ( ) ; foreach ( $ temp as $ item ) { $ i = $ item ; if ( empty ( $ item -> item_trans_text ) ) { $ i = $ themeItemTable -> getItemById ( $ item -> pros_theme_item_id , null , true ) -> current ( ) ; } $ data [ ] = $ i ; } $ form -> get ( 'pros_theme' ) -> loadValueOptions ( $ data ) ; } else { $ load [ ] = array ( 'pros_theme_item_id' => $ prospect -> pros_theme , 'pros_theme_name' => $ prospect -> pros_theme ) ; $ form -> get ( 'pros_theme' ) -> loadValueOptions ( $ load ) ; } $ form -> setData ( ( array ) $ prospect ) ; } } $ melisKey = $ this -> params ( ) -> fromRoute ( 'melisKey' , '' ) ; $ view = new ViewModel ( ) ; $ view -> melisKey = $ melisKey ; $ view -> form = $ form ; $ view -> title = "tr_prospect_manager_fm_delete_update_title" ; return $ view ; }
Renders the update form content for the modal
31,608
public function renderToolProspectsContentFiltersSiteAction ( ) { $ tableSite = $ this -> getServiceLocator ( ) -> get ( 'MelisEngineTableSite' ) ; $ translator = $ this -> getServiceLocator ( ) -> get ( 'translator' ) ; $ sites = $ tableSite -> fetchAll ( ) ; $ siteId = $ this -> getRequest ( ) -> getPost ( 'pros_site_id' ) ; $ options = '<option value="">' . $ translator -> translate ( 'tr_melistoolprospects_prospects_common_choose_label' ) . '</option>' ; foreach ( $ sites as $ site ) { $ selected = ( $ site -> site_id == $ siteId ) ? 'selected' : '' ; $ options .= '<option value="' . $ site -> site_id . '" ' . $ selected . '>' . $ site -> site_label . '</option>' ; } $ view = new ViewModel ( ) ; $ view -> options = $ options ; return $ view ; }
renders the list content prospects filter site
31,609
public function removeProspectDataAction ( ) { $ response = array ( ) ; $ this -> getEventManager ( ) -> trigger ( 'meliscmsprospects_toolprospects_delete_start' , $ this , $ response ) ; $ translator = $ this -> getServiceLocator ( ) -> get ( 'translator' ) ; $ prospectTable = $ this -> getServiceLocator ( ) -> get ( 'MelisProspects' ) ; $ id = $ this -> params ( ) -> fromRoute ( 'id' , $ this -> params ( ) -> fromQuery ( 'id' , '' ) ) ; $ prospectTable -> deleteById ( $ id ) ; $ response = array ( 'textTitle' => 'tr_melistoolprospects_tool_prospects' , 'textMessage' => 'tr_prospect_manager_fm_delete_data_content' , 'success' => true , ) ; $ this -> getEventManager ( ) -> trigger ( 'meliscmsprospects_toolprospects_delete_end' , $ this , array_merge ( $ response , array ( 'typeCode' => 'CMS_PROSPECTS_DELETE' , 'itemId' => $ id ) ) ) ; return new JsonModel ( $ response ) ; }
Removed a specific prospect data in the database table
31,610
public function retrieveProspectDataByIdAction ( ) { $ prospectTable = $ this -> getServiceLocator ( ) -> get ( 'MelisProspects' ) ; $ id = $ this -> params ( ) -> fromRoute ( 'id' , $ this -> params ( ) -> fromQuery ( 'id' , '' ) ) ; return new JsonModel ( $ prospectTable -> getEntryById ( $ id ) ) ; }
returns the prospect data from the ID provided
31,611
public function updateProspectDataAction ( ) { $ response = array ( ) ; $ this -> getEventManager ( ) -> trigger ( 'meliscmsprospects_toolprospects_save_start' , $ this , $ response ) ; $ id = null ; $ success = 0 ; $ errors = array ( ) ; $ textTitle = 'tr_melistoolprospects_tool_prospects' ; $ textMessage = '' ; $ translator = $ this -> getServiceLocator ( ) -> get ( 'translator' ) ; $ prospectTable = $ this -> getServiceLocator ( ) -> get ( 'MelisProspects' ) ; $ melisTool = $ this -> getServiceLocator ( ) -> get ( 'MelisCoreTool' ) ; $ melisTool -> setMelisToolKey ( 'melistoolprospects' , 'melistoolprospects_tool_prospects' ) ; $ prospectForm = $ melisTool -> getForm ( 'melistoolprospects_tool_prospects_update' ) ; if ( $ this -> getRequest ( ) -> isPost ( ) ) { $ postValues = get_object_vars ( $ this -> getRequest ( ) -> getPost ( ) ) ; $ postValues = $ melisTool -> sanitizePost ( $ postValues , array ( 'pros_message' ) ) ; $ id = $ this -> getRequest ( ) -> getPost ( 'pros_id' ) ; $ prospectForm -> setData ( $ postValues ) ; if ( $ prospectForm -> isValid ( ) ) { $ data = $ prospectForm -> getData ( ) ; $ curData = $ prospectTable -> getEntryById ( $ id ) ; $ curData = $ curData -> current ( ) ; $ data [ 'pros_contact_date' ] = $ curData -> pros_contact_date ; $ data [ 'pros_type' ] = $ curData -> pros_type ; $ prospectTable -> save ( $ data , $ id ) ; $ textMessage = $ translator -> translate ( 'tr_prospect_manager_fm_update_data_content' ) ; $ success = 1 ; } else { $ textMessage = $ translator -> translate ( 'tr_prospect_manager_fm_update_data_content_error' ) ; $ errors = $ prospectForm -> getMessages ( ) ; } $ melisMelisCoreConfig = $ this -> serviceLocator -> get ( 'MelisCoreConfig' ) ; $ appConfigForm = $ melisMelisCoreConfig -> getItem ( 'melistoolprospects/tools/melistoolprospects_tool_prospects/forms/melistoolprospects_tool_prospects_update' ) ; $ appConfigForm = $ appConfigForm [ 'elements' ] ; foreach ( $ errors as $ keyError => $ valueError ) { foreach ( $ appConfigForm as $ keyForm => $ valueForm ) { if ( $ valueForm [ 'spec' ] [ 'name' ] == $ keyError && ! empty ( $ valueForm [ 'spec' ] [ 'options' ] [ 'label' ] ) ) $ errors [ $ keyError ] [ 'label' ] = $ valueForm [ 'spec' ] [ 'options' ] [ 'label' ] ; } } } $ response = array ( 'success' => $ success , 'textTitle' => $ textTitle , 'textMessage' => $ textMessage , 'errors' => $ errors ) ; $ this -> getEventManager ( ) -> trigger ( 'meliscmsprospects_toolprospects_save_end' , $ this , array_merge ( $ response , array ( 'typeCode' => 'CMS_PROSPECTS_UPDATE' , 'itemId' => $ id ) ) ) ; return new JsonModel ( $ response ) ; }
Updates an specific information of Prospect Data
31,612
public function getSubtitle ( ) { return $ this -> getCachedProperty ( 'subtitle' , function ( ) { $ element = $ this -> query ( 'atom:subtitle' , Node :: SINGLE ) ; return $ element ? $ this -> getExtensions ( ) -> parseElement ( $ this , $ element ) : null ; } ) ; }
Return title .
31,613
public function addSubtitle ( $ value , $ type = 'text' ) { $ element = $ this -> addChild ( 'atom:subtitle' , 'subtitle' ) ; $ element -> setContent ( $ value , $ type ) ; return $ element ; }
Add subtitle .
31,614
public function update ( ) { $ args = func_get_args ( ) ; $ category = null ; if ( count ( $ args ) == 1 && $ args [ 0 ] instanceof Category ) { $ category = $ args [ 0 ] ; } elseif ( count ( $ args ) == 2 && ! empty ( $ args [ 0 ] ) && is_array ( $ args [ 1 ] ) ) { $ category = $ this -> find ( $ args [ 0 ] ) ; $ category -> fill ( $ args [ 1 ] ) ; } elseif ( count ( $ args ) == 3 && ! empty ( $ args [ 0 ] ) && is_array ( $ args [ 1 ] ) && ! empty ( $ args [ 2 ] ) ) { $ category = $ this -> find ( $ args [ 0 ] ) ; $ category -> setFrontLocale ( $ args [ 2 ] ) ; $ category -> fill ( $ args [ 1 ] ) ; } if ( $ category instanceof category ) { if ( $ this -> fireEvent ( 'updating' , array ( $ category ) ) === false ) { return false ; } $ category -> setCaller ( $ this ) ; $ category -> saveWithTranslation ( ) ; $ this -> fireEvent ( 'updated' , array ( $ category ) ) ; return $ category ; } throw new Exception ( sprintf ( Exception :: CANT_UPDATE_MODEL , 'Subbly\\Model\\Category' , $ this -> name ( ) ) ) ; }
Update a Category .
31,615
public function delete ( $ category ) { if ( ! is_object ( $ category ) ) { $ category = $ this -> find ( $ category ) ; } if ( $ category instanceof category ) { if ( $ this -> fireEvent ( 'deleting' , array ( $ category ) ) === false ) { return false ; } $ category -> setCaller ( $ this ) ; $ category -> delete ( $ this ) ; $ this -> fireEvent ( 'deleted' , array ( $ category ) ) ; } }
Delete a Category .
31,616
public function copy ( File $ to ) : File { $ this -> manager -> copy ( $ this -> getUrl ( ) , $ path = Paths :: normalize ( Paths :: appendPath ( $ to -> getUrl ( ) , $ this -> getName ( ) ) ) ) ; return new File ( $ path ) ; }
copy this file to an other place
31,617
public function mkdir ( string $ path = "" ) : File { if ( ! empty ( $ path ) ) { $ dir = new File ( Paths :: appendPath ( $ this -> getUrl ( ) , $ path ) ) ; $ dir -> mkdir ( ) ; return $ dir ; } else { if ( ! $ this -> isDirectory ( ) && ! $ this -> isFile ( ) ) { $ this -> manager -> createDir ( $ this -> getUrl ( ) ) ; } return $ this ; } }
create current or given path
31,618
public function delete ( ) { if ( $ this -> isDirectory ( ) ) { $ this -> manager -> deleteDir ( $ this -> getUrl ( ) ) ; } else { $ this -> manager -> delete ( $ this -> getUrl ( ) ) ; } }
delete this file
31,619
public function isDirectory ( ) : bool { if ( $ this -> isRoot ( ) ) { return true ; } $ content = $ this -> manager -> listContents ( $ this -> getParent ( ) -> getUrl ( ) , false ) ; return count ( array_filter ( $ content , function ( $ item ) { if ( $ item [ "basename" ] == $ this -> getName ( ) ) { return $ item [ "type" ] == "dir" ; } return false ; } ) ) === 1 ; }
check if this dir exists
31,620
public function get ( string $ path ) : File { return ( new File ( Paths :: appendPath ( $ this -> getUrl ( ) , $ path ) ) ) -> addFilters ( $ this -> recursiveFilter , true ) ; }
get a sub directory of current directory
31,621
public function move ( File $ to ) : File { $ this -> manager -> move ( $ this -> getUrl ( ) , Paths :: appendPath ( $ to -> getUrl ( ) , $ this -> getName ( ) ) ) ; return new File ( Paths :: appendPath ( $ this -> getUrl ( ) , $ this -> getName ( ) ) ) ; }
move file to other directory
31,622
public function printTree ( $ int = 0 ) { try { $ signs = "" ; for ( $ i = 0 ; $ i <= $ int ; $ i ++ ) { $ signs .= " " ; } $ signs .= "---" ; echo $ this -> getName ( ) . PHP_EOL ; foreach ( $ this -> listContents ( false ) as $ value ) { echo $ signs . $ value -> getName ( ) . PHP_EOL ; if ( $ value -> isDirectory ( ) ) { $ value -> printTree ( $ int ++ ) ; } } } catch ( DirectoryNotFoundException $ e ) { } }
print a file tree
31,623
public function search ( string $ word ) { $ index = $ this -> addFilter ( new Search ( $ word ) ) ; $ content = $ this -> listContents ( true ) ; $ this -> removeFilter ( $ index ) ; return $ content ; }
search for files which contains given string in their name
31,624
public function getIterator ( ) { if ( null === $ this -> queue ) { $ this -> queue = new SplPriorityQueue ( ) ; $ this -> queueOrder = 0 ; foreach ( parent :: getIterator ( ) as $ filter ) { $ this -> queue -> insert ( $ filter , array ( $ this -> priorities [ $ filter -> getName ( ) ] , $ this -> queueOrder -- ) ) ; } } return clone $ this -> queue ; }
Build a SplPriorityQueue if not already and returns a clone
31,625
protected function _isAllowed ( ) { $ result = parent :: _isAllowed ( ) ; $ result = $ result && $ this -> _authorization -> isAllowed ( $ this -> _aclResource ) ; return $ result ; }
Check user s access rights to the controller .
31,626
public function isVirtual ( string $ propertyName ) : bool { $ this -> existsOrFail ( $ propertyName ) ; return $ this -> isExistingPropertyVirtual ( $ propertyName ) ; }
Tell whether or not a property is virtual .
31,627
public function setterAvailable ( string $ propertyName ) : bool { $ this -> existsOrFail ( $ propertyName ) ; return $ this -> isExistingPropertySetterAvailable ( $ propertyName ) ; }
Tell whether or not the setter function for a property is available .
31,628
public function getterAvailable ( string $ propertyName ) : bool { $ this -> existsOrFail ( $ propertyName ) ; return $ this -> isExistingPropertyGetterAvailable ( $ propertyName ) ; }
Tell whether or not the getter function for a property is available .
31,629
private function existingPropertyVirtualOrFail ( string $ propertyName ) : void { assert ( $ this -> propertyExists ( $ propertyName ) ) ; if ( ! $ this -> isExistingPropertyVirtual ( $ propertyName ) ) { throw new NonVirtualPropertyException ( $ propertyName ) ; } }
Fail if an existing property is not virtual .
31,630
private function existingPropertySetterAvailableOrFail ( string $ propertyName ) : void { assert ( $ this -> propertyExists ( $ propertyName ) ) ; if ( ! $ this -> isExistingPropertySetterAvailable ( $ propertyName ) ) { throw new UnavailableOperationException ( $ propertyName ) ; } }
Fail if the setter of an existing property is not available .
31,631
private function existingPropertyGetterAvailableOrFail ( string $ propertyName ) : void { assert ( $ this -> propertyExists ( $ propertyName ) ) ; if ( ! $ this -> isExistingPropertyGetterAvailable ( $ propertyName ) ) { throw new UnavailableOperationException ( $ propertyName ) ; } }
Fail if the getter of an existing property is not available .
31,632
private function isExistingPropertyVirtual ( string $ propertyName ) : bool { assert ( $ this -> propertyExists ( $ propertyName ) ) ; return $ this -> properties [ $ propertyName ] === self :: PROPERTY_VIRTUAL ; }
Tell whether or not an existing property is virtual .
31,633
public function filterSlug ( string $ string ) : string { return mb_strtolower ( trim ( ( string ) preg_replace ( '~[^0-9a-z]+~i' , '-' , html_entity_decode ( ( string ) preg_replace ( '~&([a-z]{1,2})(?:acute|cedil|circ|grave|lig|orn|ring|slash|th|tilde|uml);~i' , '$1' , htmlentities ( $ string , ENT_QUOTES , 'UTF-8' ) ) , ENT_QUOTES , 'UTF-8' ) ) , '-' ) ) ; }
Filters the provided string as a slug .
31,634
public function url ( $ file = null , $ extra = null , $ rewrite = true ) { if ( $ extra === false && $ rewrite === true ) { list ( $ extra , $ rewrite ) = [ null , $ extra ] ; } return url ( ) -> to ( $ file , $ extra , true , $ rewrite ) ; }
GET COMPLETE URL
31,635
public function viewArchive ( $ request ) { $ year = $ request -> param ( 'Year' ) ; $ month = $ request -> param ( 'Month' ) ; $ this -> blogPosts = $ this -> getArchives ( ) ; if ( ! $ this -> blogPosts -> count ( ) ) { return $ this -> httpError ( 404 ) ; } $ title = $ year ; if ( $ month ) { $ title = $ month . '/' . $ year ; } $ orig_title = $ this -> dataRecord -> Title ; $ this -> Title = 'Archived posts for "' . $ title . '" | ' . $ orig_title ; $ this -> ArchivePeriod = $ title ; return $ this -> render ( ) ; }
Display archived posts either by year or year - month
31,636
public function next ( ) { if ( is_int ( $ this -> current ) ) { return $ this -> get ( $ this -> current + 1 ) ; } return $ this -> first ; }
Fetches the next after the last selected element in the collection
31,637
public function last ( ) { if ( $ this -> count ( ) ) { $ this -> current = $ this -> count ( ) - 1 ; return $ this -> get ( $ this -> count ( ) - 1 ) ; } }
Fetches the last element in the collection
31,638
public function remove ( $ value ) { $ oldCollection = $ this -> getArrayCopy ( ) ; if ( ! in_array ( $ value , $ oldCollection ) ) return $ this ; $ newCollection = array ( ) ; foreach ( $ oldCollection as $ val ) { if ( $ val === $ value ) continue ; $ newCollection [ ] = $ val ; } $ this -> exchangeArray ( $ newCollection ) ; return $ this ; }
Removes a value from the array collection
31,639
public function set ( $ index , $ newValue ) { if ( ! $ this -> offsetSet ( $ index , $ newValue ) ) { $ this -> append ( $ newValue ) ; } return $ this ; }
Sets a value to an index in the collection . If the index does not exist it is appended to the collection
31,640
public function find ( $ value ) { $ return = new ArrayCollection ( ) ; foreach ( $ this as $ object ) { if ( $ value === $ object ) $ return -> append ( $ object ) ; } return $ return ; }
Finds all elements that match the given value
31,641
public function findObjectsByMethod ( $ method , $ value , array $ methodArgs = array ( ) ) { $ return = new ArrayCollection ( ) ; foreach ( $ this as $ object ) { if ( method_exists ( $ object , $ method ) ) { if ( $ value === call_user_func_array ( array ( $ object , $ method ) , $ methodArgs ) ) $ return -> append ( $ object ) ; } } return $ return ; }
Finds all objects that the given method returns the given value
31,642
public function findObjectByMethod ( $ method , $ value , array $ methodArgs = array ( ) ) { foreach ( $ this as $ object ) { if ( method_exists ( $ object , $ method ) ) { if ( $ value === call_user_func_array ( array ( $ object , $ method ) , $ methodArgs ) ) return $ object ; } } }
Finds the first object that the given method returns the given value
31,643
public function findObjects ( $ property , $ value ) { $ return = new ArrayCollection ( ) ; foreach ( $ this as $ object ) { if ( property_exists ( $ object , $ property ) ) { if ( $ value === $ object -> $ property ) $ return -> append ( $ object ) ; } } return $ return ; }
Finds all objects that the given property has the given value
31,644
public function findObject ( $ property , $ value ) { foreach ( $ this as $ object ) { if ( property_exists ( $ object , $ property ) ) { if ( $ value === $ object -> $ property ) return $ object ; } } }
Finds the first object that the given property has the given value
31,645
public function setConfig ( $ config ) { $ this -> config = $ config ; $ this -> routes = $ config [ 'routes' ] ; $ this -> templates = $ config [ 'templates' ] ; $ this -> options = $ config [ 'options' ] ; $ this -> layoutView = $ config [ 'layout' ] ; return $ this ; }
Set the AuthController config
31,646
private static function splitToken ( $ item ) { if ( is_array ( $ item ) ) { $ tokenName = $ item [ 0 ] ; $ tokenData = $ item [ 1 ] ; } else { $ tokenName = null ; $ tokenData = $ item ; } return [ $ tokenName , $ tokenData ] ; }
Splits a token into name and data .
31,647
static public function hasPerm ( $ request , $ permission ) { $ res = User_Precondition :: loginRequired ( $ request ) ; if ( true !== $ res ) { return $ res ; } if ( $ request -> user -> hasPerm ( $ permission ) ) { return true ; } throw new Pluf_Exception ( 'you do not have permission' , 4005 , null , 400 , '' , 'you do not have permission' ) ; }
Check if the user has a given permission ..
31,648
function SetButtonAttribute ( $ optValue , $ attribute , $ value ) { if ( ! isset ( $ this -> fieldAttributes [ $ optValue ] ) ) { $ this -> fieldAttributes [ $ optValue ] = array ( ) ; } $ this -> fieldAttributes [ $ optValue ] [ $ attribute ] = $ value ; }
Sets an attribute directly to a single radio button
31,649
function SetLabelAttribute ( $ optValue , $ attribute , $ value ) { if ( ! isset ( $ this -> labelAttributes [ $ optValue ] ) ) { $ this -> labelAttributes [ $ optValue ] = array ( ) ; } $ this -> labelAttributes [ $ optValue ] [ $ attribute ] = $ value ; }
Sets an attribute directly to a single button label
31,650
public function SqlBuilder ( ) { if ( ! $ this -> builder ) $ this -> builder = new Sql \ Builder ( $ this -> Connection ( ) ) ; return $ this -> builder ; }
Gets a sql builder for handling the database
31,651
final function KeyField ( ) { if ( ! $ this -> keyField ) { $ fieldMappers = $ this -> FieldMappers ( ) ; foreach ( $ fieldMappers as $ name => $ mapper ) { $ keyInfo = $ mapper -> FieldInfo ( ) -> KeyInfo ( ) ; if ( $ keyInfo && $ keyInfo -> IsPrimary ( ) ) { $ this -> keyField = $ name ; break ; } } if ( ! $ this -> keyField ) { throw new \ Exception ( 'No (primary) key field found in ' . $ this -> TableName ( ) ) ; } } return $ this -> keyField ; }
Gets the key field name .
31,652
final function Table ( $ alias = '' , array $ fieldAliases = array ( ) ) { $ sql = $ this -> SqlBuilder ( ) ; return $ sql -> Table ( $ this -> TableName ( ) , $ this -> FieldNames ( $ fieldAliases ) , $ alias ) ; }
Create an Sql \ Table for constructing queries
31,653
final function FieldNames ( array $ aliases = array ( ) ) { $ fieldNames = array_keys ( $ this -> FieldMappers ( ) ) ; $ result = array ( ) ; foreach ( $ fieldNames as $ fieldName ) { if ( array_key_exists ( $ fieldName , $ aliases ) ) $ result [ $ aliases [ $ fieldName ] ] = $ fieldName ; else $ result [ ] = $ fieldName ; } return $ result ; }
Return field names of related table as needed for Sql \ Table construction
31,654
final function FieldMapper ( $ name ) { $ fieldMappers = $ this -> FieldMappers ( ) ; if ( ! array_key_exists ( $ name , $ fieldMappers ) ) throw new \ InvalidArgumentException ( $ name . ' is not a field of ' . $ this -> TableName ( ) ) ; return $ fieldMappers [ $ name ] ; }
Returns field mapper object for the given field name .
31,655
final function FetchFromReader ( DBInterfaces \ IDatabaseReader $ reader ) { $ objects = array ( ) ; while ( $ reader -> Read ( ) ) { $ object = $ this -> CreateInstance ( $ reader -> ByName ( $ this -> KeyField ( ) ) ) ; $ object -> InitFromReader ( $ reader ) ; $ objects [ ] = $ object ; } $ reader -> Close ( ) ; return $ objects ; }
Returns all object by reading the reader to its end .
31,656
public final function OneFromReader ( DBInterfaces \ IDatabaseReader $ reader ) { $ object = null ; if ( $ reader -> Read ( ) ) { $ object = $ this -> CreateInstance ( $ reader [ $ this -> KeyField ( ) ] ) ; $ object -> InitFromReader ( $ reader ) ; } $ reader -> Close ( ) ; return $ object ; }
Returns one object by reading the reader .
31,657
public final function Fetch ( $ distinct = false , Sql \ Condition $ where = null , Sql \ OrderList $ orderBy = null , Sql \ GroupList $ groupBy = null , $ offset = 0 , $ count = null , Sql \ Join $ join = null , Sql \ JoinType $ joinType = null , Sql \ Condition $ joinCondition = null ) { $ t = $ this -> Table ( ) ; $ src = $ t ; if ( $ join ) { if ( ! $ joinType || ! $ joinCondition ) throw new \ InvalidArgumentException ( "If join is given, a join type and join condition are also required." ) ; $ src = $ join -> Join ( $ t , $ joinType , $ joinCondition , true ) ; } $ sql = $ this -> SqlBuilder ( ) ; $ select = $ sql -> Select ( $ distinct , $ t -> ToSelectList ( ) , $ src , $ where , $ orderBy , $ groupBy , $ offset , $ count ) ; $ reader = $ this -> Connection ( ) -> ExecuteQuery ( ( string ) $ select ) ; return $ this -> FetchFromReader ( $ reader ) ; }
Fetches table objects .
31,658
public final function FirstByField ( $ field , $ value , Sql \ OrderList $ orderBy = null , Sql \ GroupList $ groupBy = null ) { $ result = $ this -> FetchByField ( false , $ field , $ value , $ orderBy , $ groupBy , 0 , 1 ) ; if ( count ( $ result ) ) return $ result [ 0 ] ; }
Returns first result by field value
31,659
public final function FetchByField ( $ distinct , $ field , $ value , Sql \ OrderList $ orderBy = null , Sql \ GroupList $ groupBy = null , $ offset = 0 , $ count = null ) { $ where = $ this -> FieldCondition ( $ field , $ value ) ; return $ this -> Fetch ( $ distinct , $ where , $ orderBy , $ groupBy , $ offset , $ count ) ; }
Returns results by field value .
31,660
private function FieldCondition ( $ field , $ value ) { $ tbl = $ this -> Table ( ) ; $ mapper = $ this -> FieldMapper ( $ field ) ; $ dbVal = $ mapper -> ToDBString ( $ value ) ; $ sql = $ this -> SqlBuilder ( ) ; if ( $ dbVal === null ) return $ sql -> IsNull ( $ tbl -> Field ( $ field ) ) ; else return $ sql -> Equals ( $ tbl -> Field ( $ field ) , $ sql -> Value ( $ dbVal ) ) ; }
Sql condition for matching a field value
31,661
public final function CountByField ( $ distinct , $ field , $ value , Sql \ GroupList $ groupBy = null ) { $ where = $ this -> FieldCondition ( $ field , $ value ) ; return $ this -> Count ( $ distinct , $ where , $ groupBy ) ; }
Returns count by field value .
31,662
private function BuildSource ( Sql \ Table $ table , Sql \ Join $ join = null , Sql \ JoinType $ joinType = null , Sql \ Condition $ joinCondition = null ) { $ src = $ table ; if ( $ join ) { if ( ! $ joinType || ! $ joinCondition ) throw new \ InvalidArgumentException ( "If join is given, a join type and join condition are also required." ) ; $ src = $ join -> Join ( $ table , $ joinType , $ joinCondition , true ) ; } return $ src ; }
Builds a sql source by prepending the table to the join if join is given .
31,663
public final function Delete ( Sql \ Condition $ where , Sql \ OrderList $ orderBy = null , $ offset = 0 , $ count = 0 ) { $ sql = $ this -> SqlBuilder ( ) ; $ delete = $ sql -> Delete ( $ this -> Table ( ) , $ where , $ orderBy , $ offset , $ count ) ; $ this -> Connection ( ) -> ExecuteQuery ( ( string ) $ delete ) ; }
Deletes data recors from the underlying tables
31,664
public final function Update ( Sql \ SetList $ setList , Sql \ Condition $ where = null , Sql \ OrderList $ orderBy = null , $ offset = 0 , $ count = 0 ) { $ sql = $ this -> SqlBuilder ( ) ; $ update = $ sql -> Update ( $ this -> Table ( ) , $ setList , $ where , $ orderBy , $ offset , $ count ) ; $ this -> Connection ( ) -> ExecuteQuery ( ( string ) $ update ) ; }
Performs an update on the underlying table
31,665
public static function tags ( $ value , $ base_url = FALSE , $ separator = ", " ) { $ cache_key = md5 ( $ value ) ; if ( Arr :: get ( self :: $ _cache , $ cache_key ) ) { return self :: $ _cache [ $ cache_key ] ; } self :: $ _cache [ $ cache_key ] = array ( 'load' => FALSE , 'tags' => array ( ) , ) ; $ base_url = ( $ base_url ) ? $ base_url : URL :: base ( TRUE , TRUE ) . 'tag/' ; foreach ( explode ( $ separator , $ value ) as $ tag ) { if ( ! $ tag ) { continue ; } $ tag = array ( 'name' => $ tag , 'slug' => URL :: title ( $ tag , '-' , TRUE ) , ) ; $ tag [ 'url' ] = $ base_url . $ tag [ 'slug' ] ; self :: $ _cache [ $ cache_key ] [ 'tags' ] [ ] = $ tag ; } if ( self :: $ _cache [ $ cache_key ] [ 'tags' ] ) { self :: $ _cache [ $ cache_key ] [ 'load' ] = TRUE ; } return self :: $ _cache [ $ cache_key ] ; }
Transform string to array of tags Elements must be separate by colon and one space
31,666
public static function items ( $ value ) { $ cache_key = md5 ( $ value ) ; if ( Arr :: get ( self :: $ _cache , $ cache_key ) ) { return self :: $ _cache [ $ cache_key ] ; } self :: $ _cache [ $ cache_key ] = array ( 'load' => FALSE , 'items' => array ( ) ) ; foreach ( explode ( ' - ' , $ value ) as $ items ) { $ new_item = array ( ) ; if ( ! trim ( $ items ) ) continue ; foreach ( explode ( "\n" , $ items ) as $ key_value ) { if ( ! trim ( $ key_value ) ) continue ; $ item = explode ( ':' , $ key_value ) ; $ new_item [ trim ( $ item [ 0 ] ) ] = trim ( $ item [ 1 ] ) ; } self :: $ _cache [ $ cache_key ] [ 'items' ] [ ] = $ new_item ; } if ( self :: $ _cache [ $ cache_key ] [ 'items' ] ) { self :: $ _cache [ $ cache_key ] [ 'load' ] = TRUE ; } return self :: $ _cache [ $ cache_key ] ; }
Transform multiples terms and elements to an multi dimentionnal array .
31,667
public static function api ( $ value ) { $ cache_key = md5 ( $ value ) ; if ( Arr :: get ( self :: $ _cache , $ cache_key ) ) { return self :: $ _cache [ $ cache_key ] ; } self :: $ _cache [ $ cache_key ] = array ( 'load' => FALSE , ) ; $ request = Request :: factory ( $ value ) ; try { $ request = Request :: factory ( $ request -> uri ( ) ) -> query ( $ request -> query ( ) ) -> execute ( ) -> body ( ) ; $ request = json_decode ( $ request ) ; self :: $ _cache [ $ cache_key ] = array ( 'load' => $ request -> meta -> status === 200 , 'meta' => $ request -> meta , 'response' => $ request -> response , ) ; } catch ( Request_Exception $ e ) { self :: $ _cache [ $ cache_key ] = array ( 'error' => $ e -> getMessage ( ) ) ; return self :: $ _cache [ $ cache_key ] ; } return self :: $ _cache [ $ cache_key ] ; }
Json api result form URL
31,668
public function retrieveFilenameOfCurrentClass ( ) { if ( null === $ this -> getFilenameOfCurrentClass ( ) ) { if ( null === $ debugBacktrace = $ this -> getDebugBacktrace ( ) ) { $ debugBacktrace = debug_backtrace ( ) ; $ this -> setDebugBacktrace ( $ debugBacktrace ) ; } $ this -> filenameOfCurrentClass = filename ( $ debugBacktrace [ 0 ] [ 'file' ] ) ; } return $ this -> filenameOfCurrentClass ; }
Getter for filenameOfCurrentClass .
31,669
protected static function instantiate ( $ className , $ arguments = null , $ constructor = null , $ includeFilename = null ) { if ( null !== $ includeFilename ) { include_once $ includeFilename ; } $ reflectionOfClass = new ReflectionClass ( $ className ) ; if ( false === $ reflectionOfClass -> isInstantiable ( ) ) { if ( null === $ constructor ) { $ constructor = self :: parseConstructor ( $ reflectionOfClass ) ; } if ( null === $ arguments ) { return call_user_func ( $ className . '::' . $ constructor ) ; } else { if ( is_array ( $ arguments ) ) { return call_user_func_array ( $ className . '::' . $ constructor , $ arguments ) ; } else { return call_user_func ( $ className . '::' . $ constructor , $ arguments ) ; } } } else { if ( $ arguments ) { if ( ! is_array ( $ arguments ) ) { $ arguments = [ $ arguments ] ; } return $ reflectionOfClass -> newInstanceArgs ( $ arguments ) ; } else { return $ reflectionOfClass -> newInstance ( ) ; } } }
Returns an instance fof class requested .
31,670
public function clear ( $ cacheDir ) { if ( is_dir ( $ this -> legacyRootDir . '/innomatic/setup' ) ) { return ; } $ this -> legacyKernel -> runCallback ( function ( ) { $ gc = new CacheGarbageCollector ( ) ; $ gc -> emptyCache ( ) ; } ) ; }
Clears Innomatic legacy cache .
31,671
public static function getOffsetBySeconds ( $ seconds ) { $ tmp = abs ( $ seconds ) ; $ hour = ( int ) ( $ tmp / 3600 ) ; $ minute = ( int ) ( ( $ tmp % 3600 ) / 60 ) ; $ result = $ seconds < 0 ? '-' : '+' ; $ result .= ( $ hour < 10 ? '0' . $ hour : $ hour ) . ':' ; $ result .= $ minute < 10 ? '0' . $ minute : $ minute ; return $ result ; }
Returns the offset string based on the given seconds
31,672
public static function getSecondsFromOffset ( $ sign , $ hours , $ minutes ) { $ hours = ( int ) $ hours ; $ minutes = ( int ) $ minutes ; $ offset = $ hours * 3600 ; $ offset += $ minutes * 60 ; if ( $ sign == '-' ) { $ offset = $ offset * - 1 ; } return $ offset ; }
Returns the number of seconds from the given offset values
31,673
private function convertColumns ( array $ row ) { $ result = [ ] ; foreach ( $ row as $ fieldName => $ value ) { if ( is_null ( $ value ) ) { $ result [ $ fieldName ] = null ; continue ; } switch ( $ this -> columnTypes [ $ fieldName ] ) { case self :: BOOL : $ value = is_null ( $ value ) ? null : $ value == 't' ; break ; case self :: INTEGER : case self :: SMALLINT : case self :: BIGINT : $ value = ( int ) $ value ; break ; case self :: NUMERIC : $ value = ( float ) $ value ; break ; case self :: JSON : $ value = json_decode ( $ value , true ) ; break ; case self :: HSTORE : $ value = self :: fromHStore ( $ value ) ; break ; case self :: DATE : case self :: TIMESTAMP : case self :: TIMESTAMPTZ : $ value = self :: fromTimestamp ( $ value ) ; break ; case self :: SMALLINT_ARRAY : case self :: INTEGER_ARRAY : $ value = self :: fromArray ( $ value ) ; if ( ! is_null ( $ value ) ) { $ value = array_map ( function ( $ a ) { return $ a === 'NULL' ? null : intval ( $ a ) ; } , $ value ) ; } break ; case self :: BIGINT_ARRAY : case self :: NUMERIC_ARRAY : $ value = self :: fromArray ( $ value ) ; if ( ! is_null ( $ value ) ) { $ value = array_map ( function ( $ a ) { return $ a === 'NULL' ? null : doubleval ( $ a ) ; } , $ value ) ; } break ; case self :: TEXT_ARRAY : case self :: VARCHAR_ARRAY : case self :: CHAR_ARRAY : $ value = self :: fromArray ( $ value ) ; break ; case self :: HSTORE_ARRAY : $ array = self :: fromArray ( $ value ) ; $ value = [ ] ; foreach ( $ array as $ val ) { $ value [ ] = self :: fromHStore ( $ val ) ; } break ; case self :: JSON_ARRAY : $ array = self :: fromArray ( $ value ) ; $ value = [ ] ; foreach ( $ array as $ val ) { $ value [ ] = json_decode ( $ val , true ) ; } break ; case self :: INTERVAL : $ value = self :: fromInterval ( $ value ) ; break ; } $ result [ $ fieldName ] = $ value ; } return $ result ; }
Convert pg types to php types
31,674
public function fetchField ( $ column ) { if ( $ this -> rowCount == 0 ) { throw new Exception ( 'Empty result set' ) ; } $ row = $ this -> current ( ) ; if ( ! isset ( $ this -> columnOids [ $ column ] ) ) { throw new Exception ( "Field '$column' not found" ) ; } return $ row [ $ column ] ; }
Get field value of the current element
31,675
private function fetchRow ( ) { $ row = pg_fetch_array ( $ this -> result , null , PGSQL_ASSOC ) ; if ( empty ( $ row ) ) { return $ row ; } return $ this -> convertColumns ( $ row ) ; }
Get current row
31,676
private static function fromHStore ( $ string ) { $ result = [ ] ; if ( empty ( $ string ) ) { return $ result ; } preg_match_all ( '#"((?:\\\"|[^"])*)"=>"((?:\\\"|[^"])*)"#U' , $ string , $ matches ) ; foreach ( $ matches [ 1 ] as $ id => $ val ) { $ result [ stripcslashes ( $ val ) ] = stripcslashes ( $ matches [ 2 ] [ $ id ] ) ; } return $ result ; }
Convert hstore to php array
31,677
private static function fromTimestamp ( $ value ) { $ result = false ; if ( empty ( $ value ) ) { return $ result ; } $ result = new \ DateTime ( $ value ) ; return $ result -> getTimestamp ( ) ; }
Convert db time to unix timestamp
31,678
private static function fromInterval ( $ value ) { if ( is_null ( $ value ) ) { return null ; } $ res = preg_match ( "/(?P<sign>\-)?(?:(?P<years>\d+) years? ?)?(?:(?P<months>\d+) mons? ?)?(?:(?P<days>\d+) days? ?)?" . "(?:(?P<h>\d+):(?P<m>\d+):(?P<s>\d+))?(?:\.(?P<ms>\d+))?/" , $ value , $ match ) ; if ( ! $ res ) { throw new Exception ( 'Malformed interval' ) ; } $ match += [ 'years' => 0 , 'months' => 0 , 'days' => 0 , 'h' => 0 , 'm' => 0 , 's' => 0 ] ; $ res = $ match [ 'years' ] * 31557600 + $ match [ 'months' ] * 2592000 + $ match [ 'days' ] * 86400 + $ match [ 'h' ] * 3600 + $ match [ 'm' ] * 60 + $ match [ 's' ] ; if ( ! empty ( $ match [ 'ms' ] ) ) { $ res = floatval ( $ res ) + floatval ( $ match [ 'ms' ] / intval ( '1' . str_repeat ( '0' , strlen ( $ match [ 'ms' ] ) ) ) ) ; } if ( isset ( $ match [ 'sign' ] ) && $ match [ 'sign' ] == '-' ) { $ res *= - 1 ; } return $ res ; }
Convert pg interval to seconds
31,679
protected function getCrawler ( int $ year ) { $ getter = 'getters.uf.' . $ this -> getter ; $ url = str_replace ( '<year>' , $ year , config ( $ getter . '.part' ) ) ; try { $ request = $ this -> client -> request ( 'GET' , $ url ) ; } catch ( ClientException $ e ) { return false ; } if ( $ request -> getStatusCode ( ) != 200 ) { return false ; } $ client = new GClient ( ) ; $ uri = config ( $ getter . '.url' ) . $ url ; $ crawler = $ client -> request ( 'GET' , $ uri ) ; return $ crawler ; }
Gets the crawler for the web page according to the configuration file
31,680
protected function renderDecoration ( ) { if ( $ this -> title !== null ) { $ this -> title = Yii :: t ( 'app' , $ this -> title ) ; echo "<h4 class=\"{$this->titleCssClass}\"><i class='icon-list-alt'></i> {$this->title}</h4>\n" ; } }
Renders the decoration for the portlet . The default implementation will render the title if it is set .
31,681
function addFromArray ( $ assets ) { if ( ! is_array ( $ assets ) ) $ assets = [ $ assets ] ; foreach ( $ assets as $ key => $ asset ) { if ( $ key === 'debug' ) { if ( self :: $ debug ) $ this -> addFromArray ( $ asset ) ; } else if ( $ key === 'prod' ) { if ( ! self :: $ debug ) $ this -> addFromArray ( $ asset ) ; } else { if ( isset ( self :: $ libs [ $ asset ] ) ) { $ this -> addLib ( $ asset ) ; } elseif ( substr ( $ asset , - 4 ) == '.css' || strpos ( $ asset , '.css?v=' ) !== false ) { $ this -> addCss ( $ asset ) ; } else { $ this -> addJs ( $ asset ) ; } } } }
Include assets from array
31,682
function js ( $ flush = true ) { $ js = $ this -> _js ; if ( $ flush ) $ this -> _js = [ ] ; $ html = '' ; foreach ( $ js as $ url => $ inc ) { $ html .= '<script src="' . $ url . '"></script>' . PHP_EOL ; } if ( ! empty ( $ this -> _scripts ) ) { $ scripts = $ this -> _scripts ; if ( $ flush ) $ this -> _scripts = [ ] ; $ html .= '<script>' . PHP_EOL ; foreach ( $ scripts as $ script ) { $ html .= $ script . PHP_EOL ; } $ html .= '</script>' ; } return $ html ; }
Returns HTML for including all added js assets
31,683
function css ( $ flush = true ) { $ css = $ this -> _css ; if ( $ flush ) $ this -> _css = [ ] ; $ html = '' ; foreach ( $ css as $ url => $ inc ) { $ html .= '<link rel="stylesheet" href="' . $ url . '">' . PHP_EOL ; } if ( ! empty ( $ this -> _styles ) ) { $ styles = $ this -> _styles ; if ( $ flush ) $ this -> _styles = [ ] ; $ html .= '<style>' . PHP_EOL ; foreach ( $ styles as $ selector => $ style ) { if ( $ selector ) { $ html .= $ selector . ' { ' . $ style . ' }' . PHP_EOL ; } else { $ html .= $ style ; } } $ html .= '</style>' ; } return $ html ; }
Returns HTML for including all added css assets
31,684
function script ( $ script , $ scriptId = null ) { if ( ! isset ( $ scriptId ) || ! isset ( $ this -> _scriptIds [ $ scriptId ] ) ) { $ this -> _scripts [ ] = $ script ; if ( isset ( $ scriptId ) ) $ this -> _scriptIds [ $ scriptId ] = true ; } }
Include js code
31,685
protected function _styleToString ( & $ style ) { if ( is_array ( $ style ) ) { $ css = $ this -> newStyle ( ) ; foreach ( $ style as $ prop => $ val ) { $ css [ $ prop ] = $ val ; } return $ css -> css ( ) ; } elseif ( is_a ( $ style , '\\s4y\\Style' ) ) { return $ style -> css ( ) ; } return $ style . PHP_EOL ; }
Converts style specified as array or Css object to string
31,686
function saveClass ( $ className = '' ) { $ css = $ this -> css ( ) ; if ( $ css === '' ) return false ; if ( isset ( self :: $ _cssIndex [ $ css ] ) ) { $ className = self :: $ _cssIndex [ $ css ] ; } else { if ( $ className === '' ) { $ classNamePrefix = 'class' ; $ className = $ classNamePrefix . rand ( 0 , 2000000000 ) ; } else { $ classNamePrefix = $ className ; } while ( isset ( self :: $ _classes [ $ className ] ) ) { $ className = $ classNamePrefix . rand ( 0 , 2000000000 ) ; } self :: $ _classes [ $ className ] = true ; self :: $ _cssIndex [ $ css ] = $ className ; $ this -> _assets -> addStyle ( $ css , '.' . $ className ) ; } return $ className ; }
Save CSS style with specified classname selector with reusing already defined classnames
31,687
public static function handle ( $ number = '' , $ message = '' , $ file = '' , $ line = 0 , $ context = [ ] ) { if ( ! ( $ number & error_reporting ( ) ) ) { return true ; } $ type = self :: getErrorType ( $ number ) ; $ error = new Doozr_Exception ( $ message , $ number ) ; $ error -> type ( $ type ) -> message ( $ message ) -> file ( $ file ) -> line ( $ line ) ; throw new Doozr_Error_Exception ( $ message , $ number , $ error ) ; }
Replacement for PHP s default internal error handler . All Errors are dispatched to this method - we decide here what to do with it . We need this hook to stay informed about Doozr s state and to pipe the Errors to attached Logger - Subsystem .
31,688
public static function getErrorType ( $ error ) { switch ( $ error ) { case E_ERROR : case E_USER_ERROR : $ type = 'ERROR' ; break ; case E_WARNING : case E_USER_WARNING : $ type = 'WARNING' ; break ; case E_PARSE : $ type = 'PARSE' ; break ; case E_NOTICE : case E_USER_NOTICE : $ type = 'NOTICE' ; break ; case E_CORE_ERROR : $ type = 'CORE-ERROR' ; break ; case E_CORE_WARNING : $ type = 'CORE-WARNING' ; break ; case E_COMPILE_ERROR : $ type = 'COMPILE-ERROR' ; break ; case E_COMPILE_WARNING : $ type = 'COMPILE-WARNING' ; break ; case E_STRICT : $ type = 'STRICT' ; break ; case E_RECOVERABLE_ERROR : $ type = 'RECOVERABLE' ; break ; case E_DEPRECATED : case E_USER_DEPRECATED : $ type = 'DEPRECATED' ; break ; case E_USER_EXCEPTION : case E_USER_CORE_EXCEPTION : $ type = 'EXCEPTION' ; break ; case E_USER_CORE_FATAL_EXCEPTION : $ type = 'EXCEPTION' ; break ; default : $ type = 'UNCLASSIFIED' ; break ; } return $ type ; }
Returns the translation from php - errorcode to our internal types .
31,689
public function log ( $ type , $ message , array $ context = [ ] , $ time = null , $ fingerprint = null , $ separator = null ) { parent :: log ( $ type , $ message , $ context , $ time , $ fingerprint , $ separator ) ; $ time = ( $ time !== null ) ? $ time : $ this -> date . ' [' . $ this -> dateTime -> getMicrotimeDiff ( $ _SERVER [ 'REQUEST_TIME' ] ) . ']' ; $ this -> archive ( sha1 ( $ message . $ type . $ fingerprint ) , [ 'type' => $ type , 'message' => $ message , 'context' => $ context , 'time' => $ time , 'fingerprint' => $ fingerprint , 'separator' => $ separator , ] ) ; $ this -> notify ( 'log' ) ; return true ; }
Dispatches a passed message and all arguments to attached loggers .
31,690
public function detachAll ( $ clearContents = false ) { $ this -> observer = new SplObjectStorage ( ) ; if ( true === $ clearContents ) { $ this -> clear ( ) ; } }
Removes all attached loggers . Optionally it removes all contents as well .
31,691
public function getLogger ( $ name ) { foreach ( $ this -> observer as $ logger ) { if ( strtolower ( $ logger -> getName ( ) ) === strtolower ( $ name ) ) { return $ logger ; } } return ; }
Returns a logging by its name .
31,692
public function setLogger ( LoggerInterface $ logger ) { if ( ! $ logger instanceof SplObserver ) { throw new Doozr_Logging_Exception ( sprintf ( 'Please implement SplObserver before trying to attach your logging.' ) ) ; } $ this -> attach ( $ logger ) ; return null ; }
Setter for logging .
31,693
public function notify ( $ event = null ) { foreach ( $ this -> observer as $ observer ) { $ observer -> update ( $ this , $ event ) ; } $ this -> clear ( ) ; }
Notifies the attached observers about changes .
31,694
public function getDoubledLocale ( ) { $ locale = $ this -> getLocale ( ) ; if ( stristr ( $ locale , '-' ) === false ) { $ locale = $ locale . '-' . $ locale ; } return $ locale ; }
Returns the locale as doubled locale value like de will be de - de to equalite the format with values like de - at en - gb ...
31,695
public function detect ( $ lookupAlternative = true ) { if ( ! self :: $ initialized ) { self :: $ initialized = $ this -> init ( $ lookupAlternative ) ; } return $ this ; }
This method is intend to detect the user preferred locale .
31,696
public function override ( array $ preferences ) { $ this -> locale = $ preferences [ 'locale' ] ; $ this -> weight = $ preferences [ 'weight' ] ; $ this -> language = $ preferences [ 'language' ] ; $ this -> country = $ preferences [ 'country' ] ; $ this -> writePreferences ( $ preferences ) ; return $ this ; }
Overrides locale configuration and storages it to configured storages .
31,697
protected function init ( $ lookupAlternative ) { $ userPreferences = $ this -> readPreferences ( ) ; if ( null === $ userPreferences ) { $ userPreferences = $ this -> detectPreferences ( ) ; if ( false === $ userPreferences || ! in_array ( $ userPreferences [ 'locale' ] , self :: $ availableLocales ) ) { if ( $ lookupAlternative ) { $ userPreferences = null ; $ countDetectedLocales = count ( $ this -> detectedLocales ) ; for ( $ i = 1 ; $ i < $ countDetectedLocales ; ++ $ i ) { if ( in_array ( $ this -> detectedLocales [ $ i ] [ 'locale' ] , self :: $ availableLocales ) ) { $ userPreferences [ 'locale' ] = $ this -> detectedLocales [ $ i ] [ 'locale' ] ; $ userPreferences [ 'weight' ] = $ this -> detectedLocales [ $ i ] [ 'weight' ] ; $ userPreferences [ 'language' ] = $ this -> detectedLanguages [ $ i ] ; $ userPreferences [ 'country' ] = $ this -> detectedCountries [ $ i ] ; break ; } } } if ( ! $ lookupAlternative || $ userPreferences === null ) { $ userPreferences [ 'locale' ] = self :: $ default [ 'locale' ] ; $ userPreferences [ 'weight' ] = self :: $ default [ 'weight' ] ; $ userPreferences [ 'language' ] = self :: $ default [ 'language' ] ; $ userPreferences [ 'country' ] = self :: $ default [ 'country' ] ; } } $ this -> dirty = true ; } $ this -> locale = $ userPreferences [ 'locale' ] ; $ this -> weight = $ userPreferences [ 'weight' ] ; $ this -> language = $ userPreferences [ 'language' ] ; $ this -> country = $ userPreferences [ 'country' ] ; if ( $ this -> dirty ) { $ this -> writePreferences ( $ userPreferences ) ; } return true ; }
This method is intend to initialize and start the detection .
31,698
private function writePreferences ( array $ preferences ) { $ result = true ; if ( Doozr_Kernel :: RUNTIME_ENVIRONMENT_CLI !== self :: $ runtimeEnvironment ) { foreach ( self :: $ storages as $ storage ) { $ method = 'write' . ucfirst ( $ storage ) ; $ result = $ result && $ this -> { $ method } ( $ preferences ) ; } } return $ result ; }
This method is intend to write the given preferences to all configured storages .
31,699
private function detectPreferences ( ) { $ detectedPreferences = false ; if ( Doozr_Kernel :: RUNTIME_ENVIRONMENT_CLI !== self :: $ runtimeEnvironment ) { $ detectedPreferences = $ this -> detectByRequestHeader ( ) ; if ( ! $ detectedPreferences ) { $ detectedPreferences = $ this -> detectByUserIp ( ) ; } } return $ detectedPreferences ; }
This method is intend to control the detection of the users locale preferences .