idx
int64
0
60.3k
question
stringlengths
101
6.21k
target
stringlengths
7
803
41,700
public static function NotificationPreference ( $ ActivityType , $ Preferences , $ Type = NULL ) { if ( is_numeric ( $ Preferences ) ) { $ User = Gdn :: UserModel ( ) -> GetID ( $ Preferences ) ; if ( ! $ User ) return $ Type == 'both' ? array ( FALSE , FALSE ) : FALSE ; $ Preferences = GetValue ( 'Preferences' , $ User ) ; } if ( $ Type === NULL ) { $ Result = self :: NotificationPreference ( $ ActivityType , $ Preferences , 'Email' ) || self :: NotificationPreference ( $ ActivityType , $ Preferences , 'Popup' ) ; return $ Result ; } elseif ( $ Type === 'both' ) { $ Result = array ( self :: NotificationPreference ( $ ActivityType , $ Preferences , 'Popup' ) , self :: NotificationPreference ( $ ActivityType , $ Preferences , 'Email' ) ) ; return $ Result ; } $ ConfigPreference = C ( "Preferences.$Type.$ActivityType" , '0' ) ; if ( ( int ) $ ConfigPreference === 2 ) $ Preference = TRUE ; if ( $ ConfigPreference !== FALSE ) $ Preference = ArrayValue ( $ Type . '.' . $ ActivityType , $ Preferences , $ ConfigPreference ) ; else $ Preference = FALSE ; return $ Preference ; }
Get default notification preference for an activity type .
41,701
public function SendNotification ( $ ActivityID , $ Story = '' , $ Force = FALSE ) { $ Activity = $ this -> GetID ( $ ActivityID ) ; if ( ! $ Activity ) return ; $ Activity = ( object ) $ Activity ; $ Story = Gdn_Format :: Text ( $ Story == '' ? $ Activity -> Story : $ Story , FALSE ) ; if ( is_null ( $ Activity -> RegardingUserID ) && $ Activity -> CommentActivityID > 0 ) { $ CommentActivity = $ this -> GetID ( $ Activity -> CommentActivityID ) ; $ Activity -> RegardingUserID = $ CommentActivity -> RegardingUserID ; $ Activity -> Route = '/activity/item/' . $ Activity -> CommentActivityID ; } $ User = Gdn :: UserModel ( ) -> GetID ( $ Activity -> RegardingUserID , DATASET_TYPE_OBJECT ) ; if ( $ User ) { if ( $ Force ) $ Preference = $ Force ; else { $ Preferences = $ User -> Preferences ; $ Preference = ArrayValue ( 'Email.' . $ Activity -> ActivityType , $ Preferences , Gdn :: Config ( 'Preferences.Email.' . $ Activity -> ActivityType ) ) ; } if ( $ Preference ) { $ ActivityHeadline = Gdn_Format :: Text ( Gdn_Format :: ActivityHeadline ( $ Activity , $ Activity -> ActivityUserID , $ Activity -> RegardingUserID ) , FALSE ) ; $ Email = new Gdn_Email ( ) ; $ Email -> Subject ( sprintf ( T ( '[%1$s] %2$s' ) , Gdn :: Config ( 'Garden.Title' ) , $ ActivityHeadline ) ) ; $ Email -> To ( $ User ) ; $ Message = sprintf ( $ Story == '' ? T ( 'EmailNotification' , "%1\$s\n\n%2\$s" ) : T ( 'EmailStoryNotification' , "%3\$s\n\n%2\$s" ) , $ ActivityHeadline , ExternalUrl ( $ Activity -> Route == '' ? '/' : $ Activity -> Route ) , $ Story ) ; $ Email -> Message ( $ Message ) ; $ Notification = array ( 'ActivityID' => $ ActivityID , 'User' => $ User , 'Email' => $ Email , 'Route' => $ Activity -> Route , 'Story' => $ Story , 'Headline' => $ ActivityHeadline , 'Activity' => $ Activity ) ; $ this -> EventArguments = $ Notification ; $ this -> FireEvent ( 'BeforeSendNotification' ) ; try { if ( ! GetValue ( 'Banned' , $ User ) ) $ Email -> Send ( ) ; $ Emailed = self :: SENT_OK ; } catch ( phpmailerException $ pex ) { if ( $ pex -> getCode ( ) == PHPMailer :: STOP_CRITICAL ) $ Emailed = self :: SENT_FAIL ; else $ Emailed = self :: SENT_ERROR ; } catch ( Exception $ ex ) { $ Emailed = self :: SENT_FAIL ; } try { $ this -> SQL -> Put ( 'Activity' , array ( 'Emailed' => $ Emailed ) , array ( 'ActivityID' => $ ActivityID ) ) ; } catch ( Exception $ Ex ) { } } } }
Send notification .
41,702
public function Comment ( $ Comment ) { $ Comment [ 'InsertUserID' ] = Gdn :: Session ( ) -> UserID ; $ Comment [ 'DateInserted' ] = Gdn_Format :: ToDateTime ( ) ; $ Comment [ 'InsertIPAddress' ] = Gdn :: Request ( ) -> IpAddress ( ) ; $ this -> Validation -> ApplyRule ( 'ActivityID' , 'Required' ) ; $ this -> Validation -> ApplyRule ( 'Body' , 'Required' ) ; $ this -> Validation -> ApplyRule ( 'DateInserted' , 'Required' ) ; $ this -> Validation -> ApplyRule ( 'InsertUserID' , 'Required' ) ; $ this -> EventArguments [ 'Comment' ] = $ Comment ; $ this -> FireEvent ( 'BeforeSaveComment' ) ; if ( $ this -> Validate ( $ Comment ) ) { $ Activity = $ this -> GetID ( $ Comment [ 'ActivityID' ] , DATASET_TYPE_ARRAY ) ; Gdn :: Controller ( ) -> Json ( 'Activity' , $ CommentActivityID ) ; $ _ActivityID = $ Comment [ 'ActivityID' ] ; if ( $ CommentActivityID = GetValue ( 'CommentActivityID' , $ Activity [ 'Data' ] ) ) { Gdn :: Controller ( ) -> Json ( 'CommentActivityID' , $ CommentActivityID ) ; $ Comment [ 'ActivityID' ] = $ CommentActivityID ; } $ Spam = SpamModel :: IsSpam ( 'ActivityComment' , $ Comment ) ; if ( $ Spam ) return SPAM ; $ ApprovalRequired = CheckRestriction ( 'Vanilla.Approval.Require' ) ; if ( $ ApprovalRequired && ! GetValue ( 'Verified' , Gdn :: Session ( ) -> User ) ) { LogModel :: Insert ( 'Pending' , 'ActivityComment' , $ Comment ) ; return UNAPPROVED ; } $ ID = $ this -> SQL -> Insert ( 'ActivityComment' , $ Comment ) ; if ( $ ID ) { if ( $ Activity && GetValue ( 'Bump' , $ Activity [ 'Data' ] ) ) { $ this -> SQL -> Put ( 'Activity' , array ( 'DateUpdated' => $ Comment [ 'DateInserted' ] ) , array ( 'ActivityID' => $ Activity [ 'ActivityID' ] ) ) ; if ( $ _ActivityID != $ Comment [ 'ActivityID' ] ) { $ this -> SQL -> Put ( 'Activity' , array ( 'DateUpdated' => $ Comment [ 'DateInserted' ] ) , array ( 'ActivityID' => $ _ActivityID ) ) ; } } } return $ ID ; } return FALSE ; }
Save a comment on an activity .
41,703
public function SendNotificationQueue ( ) { foreach ( $ this -> _NotificationQueue as $ UserID => $ Notifications ) { if ( is_array ( $ Notifications ) ) { $ Notification = $ Notifications [ 0 ] ; $ Email = $ Notification [ 'Email' ] ; if ( is_object ( $ Email ) ) { $ this -> EventArguments = $ Notification ; $ this -> FireEvent ( 'BeforeSendNotification' ) ; try { $ User = Gdn :: UserModel ( ) -> GetID ( $ UserID ) ; if ( ! GetValue ( 'Banned' , $ User ) ) $ Email -> Send ( ) ; $ Emailed = self :: SENT_OK ; } catch ( phpmailerException $ pex ) { if ( $ pex -> getCode ( ) == PHPMailer :: STOP_CRITICAL ) $ Emailed = self :: SENT_FAIL ; else $ Emailed = self :: SENT_ERROR ; } catch ( Exception $ Ex ) { $ Emailed = self :: SENT_FAIL ; } try { $ this -> SQL -> Put ( 'Activity' , array ( 'Emailed' => $ Emailed ) , array ( 'ActivityID' => $ Notification [ 'ActivityID' ] ) ) ; } catch ( Exception $ Ex ) { } } } } unset ( $ this -> _NotificationQueue ) ; $ this -> _NotificationQueue = array ( ) ; }
Send all notifications in the queue .
41,704
public function QueueNotification ( $ ActivityID , $ Story = '' , $ Position = 'last' , $ Force = FALSE ) { $ Activity = $ this -> GetID ( $ ActivityID ) ; if ( ! is_object ( $ Activity ) ) return ; $ Story = Gdn_Format :: Text ( $ Story == '' ? $ Activity -> Story : $ Story , FALSE ) ; if ( is_null ( $ Activity -> RegardingUserID ) && $ Activity -> CommentActivityID > 0 ) { $ CommentActivity = $ this -> GetID ( $ Activity -> CommentActivityID ) ; $ Activity -> RegardingUserID = $ CommentActivity -> RegardingUserID ; $ Activity -> Route = '/activity/item/' . $ Activity -> CommentActivityID ; } $ User = Gdn :: UserModel ( ) -> GetID ( $ Activity -> RegardingUserID , DATASET_TYPE_OBJECT ) ; if ( $ User ) { if ( $ Force ) $ Preference = $ Force ; else { $ ConfigPreference = C ( 'Preferences.Email.' . $ Activity -> ActivityType , '0' ) ; if ( $ ConfigPreference !== FALSE ) $ Preference = GetValue ( 'Email.' . $ Activity -> ActivityType , $ User -> Preferences , $ ConfigPreference ) ; else $ Preference = FALSE ; } if ( $ Preference ) { $ ActivityHeadline = Gdn_Format :: Text ( Gdn_Format :: ActivityHeadline ( $ Activity , $ Activity -> ActivityUserID , $ Activity -> RegardingUserID ) , FALSE ) ; $ Email = new Gdn_Email ( ) ; $ Email -> Subject ( sprintf ( T ( '[%1$s] %2$s' ) , Gdn :: Config ( 'Garden.Title' ) , $ ActivityHeadline ) ) ; $ Email -> To ( $ User ) ; $ Message = sprintf ( $ Story == '' ? T ( 'EmailNotification' , "%1\$s\n\n%2\$s" ) : T ( 'EmailStoryNotification' , "%3\$s\n\n%2\$s" ) , $ ActivityHeadline , ExternalUrl ( $ Activity -> Route == '' ? '/' : $ Activity -> Route ) , $ Story ) ; $ Email -> Message ( $ Message ) ; if ( ! array_key_exists ( $ User -> UserID , $ this -> _NotificationQueue ) ) $ this -> _NotificationQueue [ $ User -> UserID ] = array ( ) ; $ Notification = array ( 'ActivityID' => $ ActivityID , 'User' => $ User , 'Email' => $ Email , 'Route' => $ Activity -> Route , 'Story' => $ Story , 'Headline' => $ ActivityHeadline , 'Activity' => $ Activity ) ; if ( $ Position == 'first' ) $ this -> _NotificationQueue [ $ User -> UserID ] = array_merge ( array ( $ Notification ) , $ this -> _NotificationQueue [ $ User -> UserID ] ) ; else $ this -> _NotificationQueue [ $ User -> UserID ] [ ] = $ Notification ; } } }
Queue a notification for sending .
41,705
public function Queue ( $ Data , $ Preference = FALSE , $ Options = array ( ) ) { $ this -> _Touch ( $ Data ) ; if ( ! isset ( $ Data [ 'NotifyUserID' ] ) || ! isset ( $ Data [ 'ActivityType' ] ) ) throw new Exception ( 'Data missing NotifyUserID and/or ActivityType' , 400 ) ; if ( $ Data [ 'ActivityUserID' ] == $ Data [ 'NotifyUserID' ] && ! GetValue ( 'Force' , $ Options ) ) return ; $ Notified = $ Data [ 'Notified' ] ; $ Emailed = $ Data [ 'Emailed' ] ; if ( isset ( self :: $ Queue [ $ Data [ 'NotifyUserID' ] ] [ $ Data [ 'ActivityType' ] ] ) ) { list ( $ CurrentData , $ CurrentOptions ) = self :: $ Queue [ $ Data [ 'NotifyUserID' ] ] [ $ Data [ 'ActivityType' ] ] ; $ Notified = $ Notified ? $ Notified : $ CurrentData [ 'Notified' ] ; $ Emailed = $ Emailed ? $ Emailed : $ CurrentData [ 'Emailed' ] ; $ Data = array_merge ( $ CurrentData , $ Data ) ; $ Options = array_merge ( $ CurrentOptions , $ Options ) ; } if ( $ Preference ) { list ( $ Popup , $ Email ) = self :: NotificationPreference ( $ Preference , $ Data [ 'NotifyUserID' ] , 'both' ) ; if ( ! $ Popup && ! $ Email ) return ; if ( $ Popup ) $ Notified = self :: SENT_PENDING ; if ( $ Email ) $ Emailed = self :: SENT_PENDING ; } $ Data [ 'Notified' ] = $ Notified ; $ Data [ 'Emailed' ] = $ Emailed ; self :: $ Queue [ $ Data [ 'NotifyUserID' ] ] [ $ Data [ 'ActivityType' ] ] = array ( $ Data , $ Options ) ; }
Queue an activity for saving later .
41,706
public function getEditUrl ( $ backend = false ) { $ url = [ 'action' => 'edit' , 'controller' => 'Users' , 'plugin' => 'Community' ] ; if ( $ backend ) { $ url [ 'prefix' ] = 'admin' ; $ url [ ] = $ this -> id ; } return Router :: url ( $ url ) ; }
Get current user edit profile url .
41,707
public function getFileFromChunks ( UploadedFile $ uploadedFile ) { $ filename = time ( ) . '-' . $ uploadedFile -> getClientOriginalName ( ) ; $ path = $ this -> tmpDir . DIRECTORY_SEPARATOR . $ filename ; if ( FlowBasic :: save ( $ path , $ this -> tmpDir ) ) { return new UploadedFile ( $ path , $ uploadedFile -> getClientOriginalName ( ) , $ uploadedFile -> getClientMimeType ( ) ) ; } return null ; }
Check if all chunks of a file being uploaded have been received If yes return the name of the reassembled temporary file
41,708
public function initializeMediaFromUploadedFile ( UploadedFile $ uploadedFile , $ folderId , $ siteId , $ title = null ) { $ media = new $ this -> mediaClass ( ) ; $ media -> setSiteId ( $ siteId ) ; $ media -> setFile ( $ uploadedFile ) ; $ media -> setFilesystemName ( $ uploadedFile -> getFilename ( ) ) ; $ media -> setMediaFolder ( $ this -> folderRepository -> find ( $ folderId ) ) ; $ media -> setName ( $ uploadedFile -> getClientOriginalName ( ) ) ; $ media -> setMimeType ( $ uploadedFile -> getMimeType ( ) ) ; if ( null === $ title ) { $ title = $ uploadedFile -> getFilename ( ) ; } foreach ( $ this -> frontLanguages as $ language ) { $ media -> addTitle ( $ language , $ title ) ; } return $ media ; }
initialize a media to fit an uploaded file
41,709
public function saveMedia ( $ media ) { $ file = $ media -> getFile ( ) ; $ this -> mediaStorageManager -> uploadFile ( $ file -> getFilename ( ) , $ file -> getRealPath ( ) , false ) ; $ this -> objectManager -> persist ( $ media ) ; $ this -> objectManager -> flush ( ) ; $ event = new MediaEvent ( $ media ) ; $ this -> dispatcher -> dispatch ( MediaEvents :: MEDIA_ADD , $ event ) ; }
Save a media in database
41,710
protected function FillInstance ( $ errorId , $ errorMessage , $ exception ) { $ this -> errorId = $ errorId ; $ this -> errorMessage = $ errorMessage ; $ this -> exceptionObj = $ exception ; }
Sets the properties of the object
41,711
public function setSlug ( $ slug ) { if ( $ slug !== null ) { $ slug = ( string ) $ slug ; } $ this -> slug = $ slug ; }
Setting to null should regenerate the slug
41,712
public function getDernieresActualites ( $ params = array ( ) ) { $ sqlLimit = "" ; if ( isset ( $ params [ 'sqlLimit' ] ) && $ params [ 'sqlLimit' ] != '' ) { $ sqlLimit = $ params [ 'sqlLimit' ] ; } $ sqlFields = "idActualite, titre, date, " . "photoIllustration, texte, urlFichier" ; if ( isset ( $ params [ 'sqlFields' ] ) && $ params [ 'sqlFields' ] != '' ) { $ sqlFields = $ params [ 'sqlFields' ] ; } $ sqlWhere = "" ; if ( isset ( $ params [ 'sqlWhere' ] ) && $ params [ 'sqlWhere' ] != '' ) { $ sqlWhere = $ params [ 'sqlWhere' ] ; } $ req = "SELECT $sqlFields FROM actualites " . "WHERE 1=1 $sqlWhere ORDER BY date DESC $sqlLimit" ; $ res = $ this -> connexionBdd -> requete ( $ req ) ; $ i = 0 ; if ( ! isset ( $ params [ 'returnAsMysqlRes' ] ) || $ params [ 'returnAsMysqlRes' ] != true ) { $ retour = array ( ) ; while ( $ fetch = mysql_fetch_assoc ( $ res ) ) { $ retour [ $ i ] = $ fetch ; $ i ++ ; } } else { $ retour = $ res ; } return $ retour ; }
Renvoi les dernieres actualites pour la page d accueil sous forme de resultat mysql ou de tableau
41,713
public function getEntityManager ( ) { if ( isset ( $ this -> entityManager ) && is_object ( $ this -> entityManager ) ) { return $ this -> entityManager ; } $ pkgID = $ this -> c -> getPackageID ( ) ; if ( $ pkgID > 0 ) { return Package :: getByID ( $ pkgID ) -> getEntityManager ( ) ; } else { return ORM :: entityManager ( 'app' ) ; } }
Gets the controller specific entity manager . If the controller belongs to a package returns the package s entity manager . Otherwise returns the application specific entity manager .
41,714
public static function br ( int $ amount = 1 ) : string { $ output = "" ; for ( $ i = 0 ; $ i < $ amount ; $ i ++ ) { $ output .= self :: tag ( "br" ) ; } return $ output ; }
Create a BR Tag
41,715
public static function button ( string $ label , string $ type = "submit" , string $ onclick = null , array $ attributes = [ ] ) : string { $ buttonPreAttributes = [ "type" => $ type , ] ; if ( $ onclick ) { $ buttonPreAttributes [ "onclick" ] = $ onclick ; } $ buttonAttributes = array_merge ( $ buttonPreAttributes , $ attributes ) ; return self :: tag ( "button" , $ label , $ buttonAttributes ) ; }
Create a Button Tag
41,716
public static function input ( string $ name , string $ type = "text" , string $ value = null , array $ attributes = [ ] ) : string { $ preAttributesInput = [ "name" => $ name , "type" => $ type , ] ; if ( ! is_null ( $ value ) ) { $ preAttributesInput [ "value" ] = $ value ; } $ attributesInput = array_merge ( $ preAttributesInput , $ attributes ) ; return self :: tag ( "input" , "" , $ attributesInput ) ; }
Create an input tag
41,717
public static function label ( string $ label , string $ for , array $ attributes = [ ] ) : string { $ preAttributesLabel = [ "for" => $ for , ] ; $ attributesLabel = array_merge ( $ preAttributesLabel , $ attributes ) ; return self :: tag ( "label" , $ label , $ attributesLabel ) ; }
Creates label Tag
41,718
public static function span ( string $ content = null , array $ attributes = [ ] ) : string { return self :: tag ( "span" , $ content , $ attributes ) ; }
Create span tag
41,719
public static function table ( string $ content = null , array $ attributes = [ ] ) : string { return self :: tag ( "table" , $ content , $ attributes ) ; }
Create table tag
41,720
public static function tbody ( string $ content = null , array $ attributes = [ ] ) : string { return self :: tag ( "tbody" , $ content , $ attributes ) ; }
create tbody tag
41,721
public static function td ( string $ content = null , array $ attributes = [ ] ) : string { return self :: tag ( "td" , $ content , $ attributes ) ; }
create td tag
41,722
public static function th ( string $ content = null , array $ attributes = [ ] ) : string { return self :: tag ( "th" , $ content , $ attributes ) ; }
Create th tag
41,723
public static function thead ( string $ content = null , array $ attributes = [ ] ) : string { return self :: tag ( "thead" , $ content , $ attributes ) ; }
Create thead tag
41,724
public static function tr ( string $ content = null , array $ attributes = [ ] ) : string { return self :: tag ( "tr" , $ content , $ attributes ) ; }
Create tr tag
41,725
public static function ul ( string $ content = null , array $ attributes = [ ] ) : string { return self :: tag ( "ul" , $ content , $ attributes ) ; }
Render unordered list tag
41,726
public static function ol ( string $ content = null , array $ attributes = [ ] ) : string { return self :: tag ( "ol" , $ content , $ attributes ) ; }
Render Ordered List
41,727
public static function li ( string $ content = null , array $ attributes = [ ] ) : string { return self :: tag ( "li" , $ content , $ attributes ) ; }
Render List Item Tag
41,728
public static function renderTable ( array $ head = [ ] , array $ body = [ ] , array $ attributes = [ ] ) : string { $ strHead = "" ; $ strBody = "" ; foreach ( $ head as $ thRow ) { $ strHead .= self :: renderTableHeaderRow ( $ thRow ) ; } if ( $ strHead != "" ) { $ strHead = self :: thead ( $ strHead ) ; } foreach ( $ body as $ tr ) { $ strBody .= self :: renderTableRow ( $ tr ) ; } if ( $ strBody != "" ) { $ strBody = self :: tbody ( $ strBody ) ; } return self :: tag ( "table" , $ strHead . $ strBody , $ attributes ) ; }
Put all elements together to form a standard table
41,729
public function register ( ) { $ app = $ this -> app ; foreach ( $ app -> getProviders ( ) as $ provider ) { $ provider = new $ provider ( $ app ) ; if ( ! $ provider instanceof ServiceProvider ) { throw new ProviderException ( sprintf ( 'Your %s proiver must be a instance of ServiceProvider' , get_class ( $ provider ) ) ) ; } $ provider -> register ( ) ; $ app = $ provider -> app ( ) ; } }
register the providers
41,730
protected function parseResponse ( $ rawResponse , $ infoList , $ command ) { $ httpStatusCode = isset ( $ infoList [ 'http_code' ] ) ? $ infoList [ 'http_code' ] : 0 ; $ messageList = [ "HTTP Response Status Code: {$httpStatusCode}" , WebDriver_Exception_Protocol :: getCommandDescription ( $ command ) ] ; switch ( $ httpStatusCode ) { case 0 : $ message = $ this -> buildResponseErrorMessage ( "No response or broken." , $ messageList ) ; throw new WebDriver_NoSeleniumException ( $ message ) ; case WebDriver_Http :: SUCCESS_OK : $ decodedJsonList = json_decode ( $ rawResponse , true ) ; if ( $ decodedJsonList === null ) { $ errorList = [ "Can't decode response JSON:" , json_last_error_msg ( ) ] ; $ message = $ this -> buildResponseErrorMessage ( $ errorList , $ messageList ) ; throw new WebDriver_Exception_Protocol ( $ message ) ; } if ( isset ( $ decodedJsonList [ 'status' ] ) && ! WebDriver_Exception_FailedCommand :: isOk ( $ decodedJsonList [ 'status' ] ) ) { throw WebDriver_Exception_FailedCommand :: factory ( $ command , $ infoList , $ rawResponse , $ decodedJsonList ) ; } return $ decodedJsonList ; default : if ( WebDriver_Http :: isError ( $ httpStatusCode ) ) { throw WebDriver_Exception_Protocol :: factory ( $ command , $ infoList , $ rawResponse ) ; } $ errorMessage = "Unexpected HTTP status code: {$httpStatusCode}" ; $ message = $ this -> buildResponseErrorMessage ( $ errorMessage , $ messageList ) ; throw new WebDriver_Exception ( $ message ) ; } }
Returns parsed response .
41,731
private function updateFromPostCache ( Comment $ comment , $ c ) { if ( $ comment -> postId == null ) { return ; } if ( $ this -> postCache == null || $ this -> postCache [ 'ID' ] != $ comment -> postId ) { $ this -> postCache = $ this -> adminApi -> getPost ( $ comment -> postId ) ; } $ comment -> date = $ this -> getMetaKeyValue ( $ this -> postCache , "linkoscope_created_$comment->id" ) ? : $ c [ 'date' ] ; $ comment -> score = $ this -> getMetaKeyValue ( $ this -> postCache , "linkoscope_score_$comment->id" ) ? : strtotime ( $ c [ 'date' ] ) ; }
fetch associated post if it hasn t been fetched before or if the incorrect post is cached .
41,732
public function appendStylesheet ( $ href , $ media = null , array $ attributes = [ ] , $ priority = false ) { static $ counter = 0 ; $ attributes [ 'rel' ] = 'stylesheet' ; $ attributes [ 'href' ] = $ href ; $ media && $ attributes [ 'media' ] = $ media ; $ this -> links [ $ priority == 'high' ? $ counter + 1000 : $ counter ] = Html :: buildHtmlElement ( 'link' , $ attributes ) ; $ counter ++ ; return $ this ; }
Link to a CSS stylesheet
41,733
public function next ( ) { if ( next ( $ this -> _fetched ) instanceof SQLResultRow ) { return current ( $ this -> _fetched ) ; } else { try { $ mySQLResultRow = new MySQLResultRow ( $ this -> _result ) ; } catch ( SQLResultRowException $ e ) { return false ; } if ( ! $ this -> _buffered ) { $ this -> _fetched = [ ] ; } $ this -> _fetched [ ] = $ mySQLResultRow ; return $ mySQLResultRow ; } }
Read next result - row from the result - set .
41,734
public static function standardiseFile ( $ file ) { $ fileName = ltrim ( $ file , '\\' ) ; $ file = '' ; $ namespace = '' ; if ( $ lastNsPos = strripos ( $ fileName , '\\' ) ) { $ namespace = substr ( $ fileName , 0 , $ lastNsPos ) ; $ fileName = substr ( $ fileName , $ lastNsPos + 1 ) ; $ file = str_replace ( '\\' , DIRECTORY_SEPARATOR , $ namespace ) . DIRECTORY_SEPARATOR ; } $ file .= str_replace ( '_' , DIRECTORY_SEPARATOR , $ fileName ) . '.php' ; return $ file ; }
Standardise the filename .
41,735
function saveToSession ( $ data , $ name = '' ) { if ( ! $ name ) $ name = $ this -> owner -> FormName ( ) ; \ Session :: set ( "FormInfo.{$name}.data" , $ data ) ; }
save form data to session
41,736
function loadFromSession ( $ name = '' ) { if ( ! $ name ) $ name = $ this -> owner -> FormName ( ) ; $ formSession = \ Session :: get ( "FormInfo.{$name}.data" ) ; if ( $ formSession ) $ this -> owner -> loadDataFrom ( $ formSession ) ; }
load form data from session
41,737
function clearSessionData ( $ name = '' , $ clearErrors = true ) { if ( ! $ name ) $ name = $ this -> owner -> FormName ( ) ; \ Session :: clear ( "FormInfo.{$name}.data" ) ; if ( $ clearErrors ) \ Session :: clear ( "FormInfo.{$name}.errors" ) ; }
clear current form data session
41,738
public static function tableName ( ) { if ( static :: TABLE_NAME ) { return static :: TABLE_NAME ; } else { $ cn = str_replace ( '\\' , '_' , get_called_class ( ) ) ; $ inf = self :: services ( ) -> get ( 'inflector' ) ; $ tableName = $ inf -> underscore ( $ inf -> pluralize ( $ cn ) ) ; return static :: tableNamePrefix ( ) . $ tableName . static :: tableNameSuffix ( ) ; } ; }
Returns the value of the TABLE_NAME constant if not empty otherwise it figures out the name of the table out of the name of the model class .
41,739
public function resourceConfigurationFor ( $ resourceName ) { foreach ( $ this -> resourceConfigurations as $ config ) { if ( $ config -> getResource ( ) === $ resourceName ) { return $ config ; } } return null ; }
Get ResourceConfiguration from resource name .
41,740
public static function fixDirectorySeparator ( string $ path , $ useCleanPrefix = false ) : string { if ( ( $ path = trim ( $ path ) ) == '' ) { return $ path ; } $ path = preg_replace ( '`(\/|\\\)+`' , DIRECTORY_SEPARATOR , $ path ) ; if ( $ useCleanPrefix ) { $ path = DIRECTORY_SEPARATOR . ltrim ( $ path , DIRECTORY_SEPARATOR ) ; } return $ path ; }
Fix Path Separator
41,741
public static function normalizePath ( $ path ) : string { $ path = self :: fixDirectorySeparator ( $ path ) ; $ path = preg_replace ( '|(?<=.)/+|' , DIRECTORY_SEPARATOR , $ path ) ; if ( ':' === substr ( $ path , 1 , 1 ) ) { $ path = ucfirst ( $ path ) ; } if ( Validator :: isAbsolutePath ( $ path ) && strpos ( $ path , '.' ) ) { $ explode = explode ( DIRECTORY_SEPARATOR , $ path ) ; $ array = [ ] ; foreach ( $ explode as $ key => $ value ) { if ( '.' == $ value ) { continue ; } if ( '..' == $ value ) { array_pop ( $ array ) ; } else { $ array [ ] = $ value ; } } $ path = implode ( DIRECTORY_SEPARATOR , $ array ) ; } return $ path ; }
Normalize a filesystem path .
41,742
public static function multiByteEntities ( $ mixed , $ entity = false ) { static $ hasIconV ; static $ limit ; if ( ! isset ( $ hasIconV ) ) { $ hasIconV = function_exists ( 'iconv' ) ; } if ( ! isset ( $ limit ) ) { $ limit = @ ini_get ( 'pcre.backtrack_limit' ) ; $ limit = ! is_numeric ( $ limit ) ? 4096 : abs ( $ limit ) ; $ limit = $ limit < 512 ? 512 : $ limit ; $ limit = $ limit > 40960 ? 40960 : $ limit ; } if ( ! $ hasIconV && ! $ entity ) { return $ mixed ; } if ( is_array ( $ mixed ) ) { foreach ( $ mixed as $ key => $ value ) { $ mixed [ $ key ] = self :: multiByteEntities ( $ value , $ entity ) ; } } elseif ( is_object ( $ mixed ) ) { foreach ( get_object_vars ( $ mixed ) as $ key => $ value ) { $ mixed -> { $ key } = self :: multiByteEntities ( $ value , $ entity ) ; } } elseif ( strlen ( $ mixed ) > $ limit ) { return implode ( '' , self :: multiByteEntities ( str_split ( $ mixed , $ limit ) , $ entity ) ) ; } if ( $ entity ) { $ mixed = htmlentities ( html_entity_decode ( $ mixed ) ) ; } return $ hasIconV ? ( preg_replace_callback ( '/[\x{80}-\x{10FFFF}]/u' , function ( $ match ) { $ char = current ( $ match ) ; $ utf = iconv ( 'UTF-8' , 'UCS-4//IGNORE' , $ char ) ; return sprintf ( "&#x%s;" , ltrim ( strtolower ( bin2hex ( $ utf ) ) , "0" ) ) ; } , $ mixed ) ? : $ mixed ) : $ mixed ; }
Entities the Multi bytes deep string
41,743
public static function maybeUnSerialize ( $ original ) { if ( ! is_string ( $ original ) || trim ( $ original ) == '' ) { return $ original ; } if ( self :: isSerialized ( $ original ) ) { return @ unserialize ( trim ( $ original ) ) ; } return $ original ; }
Un - serialize value only if it was serialized .
41,744
public function run ( ) { if ( $ this -> unRegister ( ) && empty ( static :: $ keys [ $ this -> getKey ( ) ] ) ) { call_user_func_array ( $ this -> callback , $ this -> arguments ) ; } }
Run the shutdown handler .
41,745
public function unRegister ( ) { if ( isset ( static :: $ handlers [ $ this -> handlerId ] ) ) { if ( ! is_null ( $ this -> getKey ( ) ) ) { static :: $ keys [ $ this -> getKey ( ) ] -- ; } unset ( static :: $ handlers [ $ this -> handlerId ] ) ; return true ; } return false ; }
Unregister handler .
41,746
public function reRegister ( $ key = null ) { $ this -> setKey ( $ key ) ; static :: $ handlers [ $ this -> handlerId ] = $ this ; }
Reregister handler .
41,747
protected function setKey ( $ key ) { $ this -> removeKey ( ) ; $ this -> key = $ key ; if ( isset ( $ key ) ) { static :: $ keys [ $ key ] = isset ( static :: $ keys [ $ key ] ) ? static :: $ keys [ $ key ] + 1 : 1 ; } }
Set key for final nested destructor .
41,748
public function _Bootstrap ( ) { $ this -> forward ( ) -> setResponse ( new HtmlResponse ( ) ) ; $ this -> forward ( ) -> getCurrentRoute ( ) -> setDefault ( new Route ( array ( 'action' => '_error' ) ) ) ; }
Bootstrapping the class
41,749
public function _error ( ) { $ model = new ViewModel ( 'application/error' ) ; $ model -> addVariable ( 'error_type' , 'error' ) ; $ model -> addVariable ( 'error' , ErrorController :: $ errors ) ; return $ model ; }
If there was an error this method will display it
41,750
public function idsAction ( $ ids ) { $ items = $ this -> get ( 'opifer.content.content_manager' ) -> getRepository ( ) -> findByIds ( $ ids ) ; $ contents = $ this -> get ( 'jms_serializer' ) -> serialize ( $ items , 'json' , SerializationContext :: create ( ) -> setGroups ( [ 'list' ] ) -> enableMaxDepthChecks ( ) ) ; $ data = [ 'results' => json_decode ( $ contents , true ) , 'total_results' => count ( $ items ) ] ; return new JsonResponse ( $ data ) ; }
Get a content items by a list of ids
41,751
public static function add ( $ category , $ content , array $ save = array ( ) ) { $ page = Page :: html ( ) ; if ( $ page -> url [ 'format' ] != 'html' ) { return ; } $ page -> filter ( 'response' , function ( $ page , $ response ) use ( $ category , $ content , $ save ) { if ( empty ( $ page -> url [ 'query' ] ) ) { $ sitemap = new Component ( ) ; $ sitemap -> upsert ( $ category , array_merge ( array ( 'path' => $ page -> url [ 'path' ] , 'title' => $ page -> title , 'description' => $ page -> description , 'keywords' => $ page -> keywords , 'image' => $ page -> image , 'content' => $ content , ) , $ save ) ) ; unset ( $ sitemap ) ; } } , array ( 'html' , 200 ) ) ; }
Include the current page in the sitemap if it is an HTML page and has no query string . Made static to save you the hassle of opening and closing the database .
41,752
private function where ( $ category , $ and = '' ) { if ( ! empty ( $ category ) ) { $ sql = array ( ) ; foreach ( ( array ) $ category as $ like ) { $ sql [ ] = "c.category LIKE '{$like}%'" ; } $ category = 'AND ' . implode ( ' OR ' , $ sql ) ; } return trim ( 'INNER JOIN sitemap AS m INNER JOIN categories AS c WHERE s.docid = m.docid AND m.category_id = c.id ' . $ category . ' ' . $ and ) ; }
Adds the category and additional parameters to a query string .
41,753
private function id ( $ category ) { if ( is_null ( $ this -> ids ) ) { $ this -> ids = array ( ) ; $ categories = $ this -> db -> all ( 'SELECT category, id FROM categories' , '' , 'assoc' ) ; foreach ( $ categories as $ row ) { $ this -> ids [ $ row [ 'category' ] ] = $ row [ 'id' ] ; } } if ( ! isset ( $ this -> ids [ $ category ] ) ) { $ parent = 0 ; $ previous = '' ; foreach ( explode ( '/' , $ category ) as $ path ) { if ( ! isset ( $ this -> ids [ $ previous . $ path ] ) ) { $ this -> ids [ $ previous . $ path ] = $ this -> exec ( 'INSERT' , 'categories' , array ( $ previous . $ path , $ parent ) ) ; } $ parent = $ this -> ids [ $ previous . $ path ] ; $ previous .= $ path . '/' ; } } return $ this -> ids [ $ category ] ; }
Converts a category string into it s id .
41,754
protected function marshalScheme ( $ scheme ) : ? string { if ( null === $ scheme ) { return null ; } if ( ! is_string ( $ scheme ) ) { throw new UriException ( 'Scheme must be a string' ) ; } return strtolower ( $ scheme ) ; }
marshals the scheme .
41,755
protected function marshalPort ( $ port ) : ? int { if ( null === $ port ) { return null ; } $ port = ( int ) $ port ; if ( 0 > $ port || 65535 < $ port ) { throw new UriException ( sprintf ( 'Invalid port: %s, value must be between 0 and 65535' , $ port ) ) ; } return $ port ; }
marshals the port .
41,756
protected function marshalPath ( $ path ) : string { if ( null === $ path ) { $ path = '/' ; } if ( ! is_string ( $ path ) ) { throw new UriException ( 'Path must be a string or null' ) ; } return preg_replace_callback ( '/(?:[^' . self :: $ unreservedCharacters . self :: $ subDelimitedCharacters . '%:@\/]++|%(?![A-Fa-f0-9]{2}))/' , function ( $ match ) { return rawurlencode ( $ match [ 0 ] ) ; } , $ path ) ; }
marshals the path .
41,757
protected function marshalQueryAndFragment ( $ string ) : string { if ( ! is_string ( $ string ) ) { throw new UriException ( 'Query and Fragment must be a string or null' ) ; } return preg_replace_callback ( '/(?:[^' . self :: $ unreservedCharacters . self :: $ subDelimitedCharacters . '%:@\/]++|%(?![A-Fa-f0-9]{2}))/' , function ( $ match ) { return rawurlencode ( $ match [ 0 ] ) ; } , $ string ) ; }
marshals the query and fragment .
41,758
public function StrReplace ( $ search = ' ' , $ replace = '' ) { $ owner = $ this -> owner ; $ owner -> value = str_replace ( $ search , $ replace , $ owner -> value ) ; return $ owner ; }
Replace all occurrences of the search string with the replacement string .
41,759
public function Nice ( ) { $ owner = $ this -> owner ; $ value = preg_replace ( '/([a-z)([A-Z0-9]])/' , '$1 $2' , $ owner -> value ) ; $ value = preg_replace ( '/([a-zA-Z])-([a-zA-Z0-9])/' , '$1 $2' , $ value ) ; $ value = str_replace ( '_' , ' ' , $ value ) ; $ owner -> value = trim ( $ value ) ; return $ owner ; }
Converts this camel case and hyphenated string to a space separated string .
41,760
public function Hyphenate ( ) { $ value = preg_replace ( '/([A-Z])/' , '-$1' , $ this -> owner -> value ) ; $ value = trim ( $ value ) ; return Convert :: raw2url ( $ value ) ; }
Converts this camel case string to a hyphenated kebab or spinal case string .
41,761
public function RemoveSpaces ( ) { $ owner = $ this -> owner ; $ owner -> value = str_replace ( [ ' ' , '&nbsp' ] , '' , $ owner -> value ) ; return $ owner ; }
Removes spaces from this string .
41,762
public function implicitWait ( $ timeout ) { $ timeoutNormalize = intval ( ceil ( $ timeout / 100 ) ) ; if ( $ this -> cache [ self :: WAIT_IMPLICIT ] === $ timeoutNormalize ) { return null ; } $ this -> cache [ self :: WAIT_IMPLICIT ] = $ timeout ; $ param = [ 'ms' => intval ( $ timeout ) ] ; $ command = $ this -> driver -> factoryCommand ( 'timeouts/implicit_wait' , WebDriver_Command :: METHOD_POST , $ param ) ; return $ this -> driver -> curl ( $ command ) [ 'value' ] ; }
Set the amount of time the driver should wait when searching for elements .
41,763
public function createUseCaseDiagramm ( ) { $ nodes = $ this -> findAll ( ) ; $ diagrammService = $ this -> getDiagrammService ( ) ; return $ diagrammService -> createDiagrammFromNodes ( $ nodes , UseCaseDiagramm :: TYPE_USE_CASE ) ; }
Creates an use case diagramm from all entities
41,764
public function createUseCaseDiagrammFor ( $ entity ) { if ( is_int ( $ entity ) ) { $ entity = $ this -> getById ( $ entity ) ; } elseif ( ! $ entity instanceof UseCaseEntity ) { throw new \ InvalidArgumentException ( 'Unkown entity data type "' . gettype ( $ entity ) . '"' ) ; } $ diagrammService = $ this -> getDiagrammService ( ) ; return $ diagrammService -> createDiagrammFromNodes ( array ( $ entity ) , UseCaseDiagramm :: TYPE_USE_CASE ) ; }
Creates an use case diagramm from an single entity
41,765
public function sendAsync ( $ mobileNumber , $ message , $ messageId = null ) { $ this -> requestForm = new SenderForm ( $ mobileNumber , $ message , $ messageId ) ; return $ this -> client -> requestAsync ( 'POST' , '' , [ 'form_params' => $ this -> requestForm -> get ( ) ] ) ; }
Send a message and return a promise .
41,766
public function send ( $ mobileNumber , $ message , $ messageId = null ) { return $ this -> sendAsync ( $ mobileNumber , $ message , $ messageId ) -> then ( function ( ResponseInterface $ response ) { return new SentResponse ( $ response , $ this -> requestForm ) ; } , function ( $ exception ) { return $ this -> throwError ( $ exception ) ; } ) -> wait ( ) ; }
Send a message immediately .
41,767
public static function queryPosts ( $ args ) { $ query = new WP_Query ( $ args ) ; $ posts = false ; if ( $ query -> have_posts ( ) ) { global $ post ; $ posts = array ( ) ; while ( $ query -> have_posts ( ) ) { $ query -> the_post ( ) ; $ thePost = static :: create ( $ post ) ; array_push ( $ posts , $ thePost ) ; } } return $ posts ; }
Query for posts and returns an array of the model
41,768
public static function create ( $ post ) { if ( is_numeric ( $ post ) ) { $ transientKey = sprintf ( 'WPMVC\Models\Post(%d)' , $ post ) ; $ storedData = WP :: getTransient ( $ transientKey ) ; if ( $ storedData === false ) { $ post = WP :: getPost ( intval ( $ post ) ) ; WP :: setTransient ( $ transientKey , $ post , static :: $ transientTimeout ) ; } else { $ post = $ storedData ; } } elseif ( is_array ( $ post ) ) { $ post = ( object ) $ post ; } return new static ( $ post ) ; }
Creates a new instance by the post ID
41,769
protected function loadMetaData ( ) { $ transientKey = sprintf ( 'WPMVC\Models\Post(%d)::loadMetaData' , $ this -> id ( ) ) ; $ metaData = WP :: getTransient ( $ transientKey ) ; if ( ! $ metaData ) { $ keys = WP :: getPostCustom ( $ this -> id ( ) ) ; $ metaData = array ( ) ; if ( $ keys && is_array ( $ keys ) && count ( $ keys ) ) { foreach ( $ keys as $ key => $ value ) { if ( is_array ( $ value ) && count ( $ value ) == 1 ) { $ metaData [ $ key ] = $ value [ 0 ] ; } else { $ metaData [ $ key ] = $ value ; } } } WP :: setTransient ( $ transientKey , $ metaData , static :: $ transientTimeout ) ; } $ this -> metaData = $ metaData ; }
Loads the post s meta data
41,770
public function hasMeta ( $ option ) { return ( isset ( $ this -> metaData [ $ option ] ) ) ? $ this -> metaData [ $ option ] : false ; }
Checks if the post has a meta key
41,771
public function content ( $ moreLinkText = null , $ stripTeaser = false ) { global $ post ; $ _p = $ post ; $ post = $ this -> post ; setup_postdata ( $ post ) ; $ content = get_the_content ( $ moreLinkText , $ stripTeaser ) ; $ content = WP :: applyFilters ( 'the_content' , $ content ) ; $ content = str_replace ( ']]>' , ']]&gt;' , $ content ) ; $ post = $ _p ; if ( $ _p ) { setup_postdata ( $ post ) ; } return $ content ; }
Retrieve the post s content
41,772
public function excerpt ( $ wordCount = 20 , $ delimiter = '...' ) { global $ post ; $ _p = $ post ; $ post = $ this -> post ; setup_postdata ( $ post ) ; $ limit = $ wordCount + 1 ; $ full_excerpt = get_the_excerpt ( ) ; $ full_excerpt_count = count ( explode ( ' ' , $ full_excerpt ) ) ; $ new_excerpt = explode ( ' ' , $ full_excerpt , $ limit ) ; if ( $ full_excerpt_count <= $ wordCount ) { $ delimiter = '' ; } else { array_pop ( $ new_excerpt ) ; } $ new_excerpt = implode ( ' ' , $ new_excerpt ) . $ delimiter ; $ post = $ _p ; if ( $ _p ) { setup_postdata ( $ post ) ; } return $ new_excerpt ; }
Retrieve the post s excerpt
41,773
public function getTerms ( $ taxonomy ) { if ( ! $ this -> terms ) { $ transientKey = sprintf ( 'WPMVC\Models\Post::getTerms(%s)' , $ this -> id ( ) , $ taxonomy ) ; $ terms = WP :: getTransient ( $ transientKey ) ; if ( ! $ terms ) { $ args = array ( 'orderby' => 'name' , 'order' => 'ASC' ) ; $ terms = wp_get_post_terms ( $ this -> id ( ) , $ taxonomy , $ args ) ; WP :: setTransient ( $ transientKey , $ terms , static :: $ transientTimeout ) ; } $ this -> terms [ $ taxonomy ] = $ terms ; } return $ this -> terms [ $ taxonomy ] ; }
Retrieves the taxonomy terms for the post
41,774
public function thumbnail ( $ size = 'full' ) { $ thumb = wp_get_attachment_image_src ( get_post_thumbnail_id ( $ this -> id ( ) ) , $ size ) ; return isset ( $ thumb [ 0 ] ) ? $ thumb [ 0 ] : '' ; }
Retrieve the post s thumbnail
41,775
protected function loadAdjacentPost ( $ direction = null ) { $ loadPrev = $ loadNext = false ; switch ( $ direction ) { case 'prev' : $ loadPrev = true ; break ; case 'next' : $ loadNext = true ; break ; default : $ loadPrev = $ loadNext = true ; break ; } if ( $ loadPrev && ! $ this -> prevPost ) { $ this -> prevPost = $ this -> getAdjacentPost ( 'prev' , $ this -> get ( 'post_type' ) ) ; } if ( $ loadNext && ! $ this -> nextPost ) { $ this -> nextPost = $ this -> getAdjacentPost ( 'next' , $ this -> get ( 'post_type' ) ) ; } }
Loads the adjacent posts
41,776
protected static function resolveStatic ( $ type , $ data ) { $ request = Request :: instance ( ) ; $ config = Config :: instance ( ) ; if ( $ type == RESOLVE_ROUTE || $ type == RESOLVE_LANG ) { if ( preg_match ( '#^((\.)([a-zA-Z0-9_-]+)(\.)(.+))#' , $ data , $ matches ) ) { $ src = $ matches [ 3 ] ; $ data = preg_replace ( '#^(\.)(' . preg_quote ( $ src ) . ')(\.)#isU' , '' , $ data ) ; } else { $ src = $ request -> src ; } return [ $ config -> config [ $ type ] [ $ src ] , $ data ] ; } else { if ( preg_match ( '#^((\.)([^(\/)]+)([(\/)]*)(.*))#' , $ data , $ matches ) ) { $ src = $ matches [ 3 ] ; $ data = $ matches [ 5 ] ; } else { if ( $ request -> src != '' ) { $ src = $ request -> src ; } else { $ src = 'app' ; } } if ( $ src == 'vendor' ) { return VENDOR_PATH . $ data ; } else { if ( ! isset ( $ config -> config [ $ type ] [ $ src ] ) ) { throw new MissingConfigException ( 'The section "' . $ type . '/' . $ src . '" does not exist in configuration' ) ; } } return $ config -> config [ $ type ] [ $ src ] . $ data ; } }
when you want to use a lang route image template this method is used to resolve the right path the method use the instance of \ Gcs \ Framework \ Core \ Config \ Config
41,777
public function htmlAction ( Request $ request , $ teaserId ) { $ requestStack = $ this -> get ( 'request_stack' ) ; $ masterRequest = $ requestStack -> getMasterRequest ( ) ; if ( $ request -> get ( 'preview' ) || $ request -> get ( '_preview' ) ) { $ request -> attributes -> set ( '_preview' , true ) ; } elseif ( $ masterRequest !== $ request && $ masterRequest -> attributes -> get ( '_preview' ) ) { $ request -> attributes -> set ( '_preview' , true ) ; } $ teaser = $ this -> get ( 'phlexible_teaser.teaser_service' ) -> find ( $ teaserId ) ; $ request -> attributes -> set ( 'contentDocument' , $ teaser ) ; $ renderConfigurator = $ this -> get ( 'phlexible_element_renderer.configurator' ) ; $ renderConfig = $ renderConfigurator -> configure ( $ request ) ; if ( $ renderConfig -> getResponse ( ) ) { return $ renderConfig -> getResponse ( ) ; } if ( $ request -> get ( 'template' ) ) { $ renderConfig -> set ( 'template' , $ request -> get ( 'template' , 'teaser' ) ) ; } $ data = $ renderConfig -> getVariables ( ) ; return $ this -> render ( $ data [ 'template' ] , ( array ) $ data ) ; }
Render action .
41,778
public function addFromString ( $ localname , $ contents ) { return $ this -> pclZip -> add ( array ( array ( PCLZIP_ATT_FILE_NAME => $ localname , PCLZIP_ATT_FILE_CONTENT => $ contents , ) ) ) ; }
Add a file to a ZIP archive using its contents
41,779
public function write ( string $ uri , $ data ) { if ( ! file_exists ( dirname ( $ uri ) ) ) { mkdir ( dirname ( $ uri ) , 0755 , true ) ; } if ( ! file_put_contents ( $ uri , $ data ) ) { throw new ErrorException ( "Failed to write output to file: " . $ uri ) ; } return true ; }
Write the data to the storage engine
41,780
public function register ( $ class ) { if ( $ this -> initialized ) { throw new RuntimeException ( 'The components have already been initialized.' ) ; } if ( ! class_exists ( $ class ) ) { throw new RuntimeException ( sprintf ( 'The component "%s" not exists.' , $ class ) ) ; } $ component = new $ class ( ) ; if ( ! $ component instanceof ComponentInterface ) { throw new InvalidArgumentException ( sprintf ( 'The component "%s" must implement "%s".' , $ class , ComponentInterface :: CLASS ) ) ; } $ this -> container [ $ class ] = $ component ; return md5 ( $ class . $ component -> getVersion ( ) ) ; }
Register the component .
41,781
public function init ( ServicesInterface $ services , ListenersInterface $ listeners , EventsInterface $ events , ConfigInterface $ config ) { if ( $ this -> initialized ) { throw new RuntimeException ( 'The components have already been initialized.' ) ; } $ this -> initialized = true ; foreach ( $ this -> container as $ component ) { if ( method_exists ( $ component , 'getServicesConfig' ) ) { $ services -> add ( $ component -> getServicesConfig ( ) ) ; } if ( method_exists ( $ component , 'getListenersConfig' ) ) { $ listeners -> add ( $ component -> getListenersConfig ( ) ) ; } if ( method_exists ( $ component , 'getEventsConfig' ) ) { foreach ( $ component -> getEventsConfig ( ) as $ item ) { call_user_func_array ( [ $ events , 'attach' ] , $ item ) ; } } if ( method_exists ( $ component , 'getSystemConfig' ) ) { $ config -> merge ( $ component -> getSystemConfig ( ) ) ; } } }
Initializes components .
41,782
public function createInstance ( $ file , $ type = null , array $ options = array ( ) ) { if ( ! is_file ( $ file ) && $ type === null ) { throw new \ InvalidArgumentException ( 'You must enter a $type if the file does not exist yet.' ) ; } $ type = pathinfo ( $ file , PATHINFO_EXTENSION ) ; switch ( $ type ) { case self :: JSON_TYPE : $ file = new Json ( $ file , $ options ) ; break ; case self :: YAML_TYPE : $ file = new Yaml ( $ file , $ options ) ; break ; default : throw UnsupportedFileTypeException :: create ( $ type ) ; } return $ file ; }
Creates an instance of a file .
41,783
protected function makePagerFromArray ( $ data , $ page = 1 , $ limit = 10 ) { $ adapter = new ArrayAdapter ( $ data ) ; $ pager = new Pagerfanta ( $ adapter ) ; $ pager -> setMaxPerPage ( $ limit ) ; $ pager -> setCurrentPage ( $ page ) ; return $ pager ; }
Creates a pager from an array
41,784
public function paginate ( array $ data , $ page , $ limit , $ url , $ params = array ( ) ) { $ pager = $ this -> makePagerFromArray ( $ data , $ page , $ limit ) ; return $ this -> factory -> createCollectionFromPager ( $ pager , $ url , $ params ) ; }
Handles creating a pager and turning it into a collection representation
41,785
public function getLangClient ( ) { if ( ! array_key_exists ( 'HTTP_ACCEPT_LANGUAGE' , $ _SERVER ) || ! $ _SERVER [ 'HTTP_ACCEPT_LANGUAGE' ] ) { return Config :: config ( ) [ 'user' ] [ 'output' ] [ 'lang' ] ; } else { $ langcode = ( ! empty ( $ _SERVER [ 'HTTP_ACCEPT_LANGUAGE' ] ) ) ? $ _SERVER [ 'HTTP_ACCEPT_LANGUAGE' ] : '' ; $ langcode = ( ! empty ( $ langcode ) ) ? explode ( ";" , $ langcode ) : $ langcode ; $ langcode = ( ! empty ( $ langcode [ '0' ] ) ) ? explode ( "," , $ langcode [ '0' ] ) : $ langcode ; $ langcode = ( ! empty ( $ langcode [ '0' ] ) ) ? explode ( "-" , $ langcode [ '0' ] ) : $ langcode ; return $ langcode [ '0' ] ; } }
get the client language
41,786
public function delete ( $ key ) { $ file = $ this -> generateFileLocation ( $ key ) ; if ( file_exists ( $ file ) ) unlink ( $ file ) ; }
Limpa um cache
41,787
public function set ( $ key , $ content , $ time = null ) { $ time = strtotime ( ! is_null ( $ time ) ? $ time : self :: $ time ) ; $ content = serialize ( array ( 'expires' => $ time , 'content' => $ content ) ) ; return $ this -> createCacheFile ( $ key , $ content ) ; }
Salva um valor no cache
41,788
public function get ( $ key ) { $ filename = $ this -> generateFileLocation ( $ key ) ; if ( file_exists ( $ filename ) && is_readable ( $ filename ) ) { $ cache = unserialize ( file_get_contents ( $ filename ) ) ; if ( $ cache [ 'expires' ] > time ( ) ) { return $ cache [ 'content' ] ; } else { unlink ( $ filename ) ; } } return null ; }
Salva um valor do cache
41,789
public function addFieldGuessers ( array $ fieldGuessers ) { foreach ( $ fieldGuessers as $ name => $ fieldGuesser ) { $ this -> add ( $ name , $ fieldGuesser ) ; } }
Adds an array of field guessers .
41,790
public function get ( $ name ) { if ( ! $ this -> has ( $ name ) ) { throw new \ InvalidArgumentException ( sprintf ( 'The field guesser "%s" does not exist.' , $ name ) ) ; } return $ this -> fieldGuessers [ $ name ] ; }
Returns a field guesser by name .
41,791
public function build ( ) : ConsulEnvManager { $ kv = ( new ServiceFactory ( [ 'base_uri' => $ this -> consulServer ] ) ) -> get ( 'kv' ) ; $ manager = new ConsulEnvManager ( $ kv , $ this -> overwriteEvenIfDefined ) ; $ this -> clear ( ) ; return $ manager ; }
Build the manager with the properties that have been defined .
41,792
public static function factory ( ? Enviroment $ environment = null ) : Parser { $ environment = $ environment ?? Enviroment :: getFromSapi ( PHP_SAPI ) ; return self :: evaluate ( $ environment ) -> isInstanceOf ( Parser :: class ) -> getValue ( ) ; }
Devuelve el parser asociado a un nombre
41,793
public function makeHtml ( Enviroment $ enviroment ) : ? Parser { if ( ! $ enviroment -> isHtml ( ) ) { return null ; } return Parser :: make ( ) -> addDecorator ( PaddingDecorator :: make ( ) ) -> addDecorator ( LineWidthDecorator :: make ( ) ) -> addDecorator ( HtmlTagDecorator :: make ( ) ) -> addDecorator ( MarginDecorator :: make ( ) ) ; }
Crea un objeto Html Parser
41,794
public function makeConsole ( Enviroment $ enviroment ) : ? Parser { if ( ! $ enviroment -> isConsole ( ) ) { return null ; } return Parser :: make ( ) -> addDecorator ( PaddingDecorator :: make ( ) ) -> addDecorator ( LineWidthDecorator :: make ( ) ) -> addDecorator ( ConsoleTagDecorator :: make ( ) ) -> addDecorator ( MarginDecorator :: make ( ) ) ; }
Crea un objeto Console Parser
41,795
public function setup ( array $ extracters ) { foreach ( $ extracters as $ extracter ) { if ( ( false === ( $ extracter [ 'reference' ] instanceof TrackingParameterQueryExtracterInterface ) ) && ( false === ( $ extracter [ 'reference' ] instanceof TrackingParameterCookieExtracterInterface ) ) && ( false === ( $ extracter [ 'reference' ] instanceof TrackingParameterInitializerInterface ) ) ) { throw new InvalidConfigurationException ( sprintf ( 'Invalid tracking parameter extracter "%s".' , $ extracter [ 'name' ] ) ) ; } $ this -> extracters [ $ extracter [ 'name' ] ] = $ extracter [ 'reference' ] ; } }
Set all formatters available .
41,796
public function extract ( Request $ request ) { $ trackingParameters = new ParameterBag ( ) ; foreach ( $ this -> extracters as $ extracter ) { if ( $ extracter instanceof TrackingParameterCookieExtracterInterface ) { $ trackingParameters -> add ( $ extracter -> extractFromCookies ( $ request -> cookies ) ) ; } } foreach ( $ this -> extracters as $ extracter ) { if ( $ extracter instanceof TrackingParameterQueryExtracterInterface ) { $ trackingParameters -> add ( $ extracter -> extractFromQuery ( $ request -> query ) ) ; } } return $ trackingParameters ; }
Extract tracking parameters from query or from cookies .
41,797
public function status ( $ id ) { $ url = self :: HOST . self :: STATUS ; $ params = $ this -> get_default_params ( ) ; $ params [ 'id' ] = $ id ; $ result = $ this -> request ( $ url , $ params ) ; return $ result ; }
Check message status
41,798
public function balance ( ) { $ url = self :: HOST . self :: BALANCE ; $ params = $ this -> get_default_params ( ) ; $ result = $ this -> request ( $ url , $ params ) ; $ result = explode ( "\n" , $ result ) ; return array ( 'code' => $ result [ 0 ] , 'balance' => $ result [ 1 ] ) ; }
Check user balance
41,799
public function limit ( ) { $ url = self :: HOST . self :: LIMIT ; $ params = $ this -> get_default_params ( ) ; $ result = $ this -> request ( $ url , $ params ) ; $ result = explode ( "\n" , $ result ) ; return array ( 'code' => $ result [ 0 ] , 'total' => $ result [ 1 ] , 'current' => $ result [ 2 ] ) ; }
Check day limit