idx
int64
0
60.3k
question
stringlengths
92
4.62k
target
stringlengths
7
635
16,100
public function toArray ( ) { if ( $ this -> hasAttachment ) { return $ this -> attachmentMessageToArray ( ) ; } if ( $ this -> hasText ) { if ( count ( $ this -> buttons ) > 0 ) { return $ this -> buttonMessageToArray ( ) ; } return $ this -> textMessageToArray ( ) ; } if ( count ( $ this -> cards ) > 0 ) { return $ t...
Returns message payload for JSON conversion .
16,101
protected function textMessageToArray ( ) { $ message = [ ] ; $ message [ 'recipient' ] = $ this -> recipient ; $ message [ 'notification_type' ] = $ this -> notificationType ; $ message [ 'message' ] [ 'text' ] = $ this -> text ; return $ message ; }
Returns message for simple text message .
16,102
protected function attachmentMessageToArray ( ) { $ message = [ ] ; $ message [ 'recipient' ] = $ this -> recipient ; $ message [ 'notification_type' ] = $ this -> notificationType ; $ message [ 'message' ] [ 'attachment' ] [ 'type' ] = $ this -> attachmentType ; $ message [ 'message' ] [ 'attachment' ] [ 'payload' ] [...
Returns message for attachment message .
16,103
protected function genericMessageToArray ( ) { $ message = [ ] ; $ message [ 'recipient' ] = $ this -> recipient ; $ message [ 'notification_type' ] = $ this -> notificationType ; $ message [ 'message' ] [ 'attachment' ] [ 'type' ] = 'template' ; $ message [ 'message' ] [ 'attachment' ] [ 'payload' ] [ 'template_type' ...
Returns message for Generic Template message .
16,104
protected function buttonMessageToArray ( ) { $ message = [ ] ; $ message [ 'recipient' ] = $ this -> recipient ; $ message [ 'notification_type' ] = $ this -> notificationType ; $ message [ 'message' ] [ 'attachment' ] [ 'type' ] = 'template' ; $ message [ 'message' ] [ 'attachment' ] [ 'payload' ] [ 'template_type' ]...
Returns message for Button Template message .
16,105
public function url ( $ url ) { if ( $ this -> isNotSetOrEmpty ( $ url ) ) { throw CouldNotCreateButton :: urlNotProvided ( ) ; } elseif ( ! filter_var ( $ url , FILTER_VALIDATE_URL ) ) { throw CouldNotCreateButton :: invalidUrlProvided ( $ url ) ; } $ this -> payload [ 'url' ] = $ url ; $ this -> isTypeWebUrl ( ) ; re...
Set a URL for the button .
16,106
protected function makePayload ( $ data ) { if ( $ this -> isNotSetOrEmpty ( $ data ) ) { return $ this ; } switch ( $ this -> payload [ 'type' ] ) { case ButtonType :: WEB_URL : $ this -> url ( $ data ) ; break ; case ButtonType :: PHONE_NUMBER : $ this -> phone ( $ data ) ; break ; case ButtonType :: POSTBACK : $ thi...
Make payload by data and type .
16,107
public function toArray ( ) { $ this -> title ( $ this -> title ) ; $ this -> makePayload ( $ this -> data ) ; return $ this -> payload ; }
Builds payload and returns an array .
16,108
public function buttons ( array $ buttons = [ ] ) { if ( count ( $ buttons ) > 3 ) { throw CouldNotCreateMessage :: messageButtonsLimitExceeded ( ) ; } $ this -> buttons = $ buttons ; return $ this ; }
Add up to 3 call to action buttons .
16,109
public function subtitle ( $ subtitle ) { if ( mb_strlen ( $ subtitle ) > 80 ) { throw CouldNotCreateCard :: subtitleLimitExceeded ( $ subtitle ) ; } $ this -> payload [ 'subtitle' ] = $ subtitle ; return $ this ; }
Set Card Subtitle .
16,110
public function toArray ( ) { if ( ! isset ( $ this -> payload [ 'title' ] ) ) { throw CouldNotCreateCard :: titleNotProvided ( ) ; } if ( count ( $ this -> buttons ) > 0 ) { $ this -> payload [ 'buttons' ] = $ this -> buttons ; } return $ this -> payload ; }
Returns a payload for API request .
16,111
protected function normalize ( array $ parameters ) { foreach ( $ parameters as $ parameter => $ value ) { if ( null !== $ this -> knownParameters [ $ parameter ] ) { $ parameters [ $ parameter ] = sprintf ( $ this -> knownParameters [ $ parameter ] , $ value ) ; } } return $ parameters ; }
Normalizes parameters depending on Paybox s 6 . 2 parameters specifications .
16,112
public function onPayboxIpnResponse ( PayboxResponseEvent $ event ) { $ path = sprintf ( '%s/../data/%s' , $ this -> rootDir , date ( 'Y\/m\/d\/' ) ) ; $ this -> filesystem -> mkdir ( $ path ) ; $ content = sprintf ( 'Signature verification : %s%s' , $ event -> isVerified ( ) ? 'OK' : 'KO' , PHP_EOL ) ; foreach ( $ eve...
Creates a txt file containing all parameters for each IPN .
16,113
protected function stringifyParameters ( ) { if ( isset ( $ this -> parameters [ 'PBX_HMAC' ] ) ) { unset ( $ this -> parameters [ 'PBX_HMAC' ] ) ; } ksort ( $ this -> parameters ) ; return Tools :: stringify ( $ this -> parameters ) ; }
Returns all parameters as a querystring .
16,114
protected function computeHmac ( ) { $ binKey = pack ( 'H*' , $ this -> globals [ 'hmac_key' ] ) ; return hash_hmac ( $ this -> globals [ 'hmac_algorithm' ] , $ this -> stringifyParameters ( ) , $ binKey ) ; }
Computes the hmac hash .
16,115
protected function getServer ( ) { $ servers = array ( ) ; if ( isset ( $ this -> globals [ 'production' ] ) && ( true === $ this -> globals [ 'production' ] ) ) { $ servers [ ] = $ this -> servers [ 'primary' ] ; $ servers [ ] = $ this -> servers [ 'secondary' ] ; } else { $ servers [ ] = $ this -> servers [ 'preprod'...
Returns the url of an available server .
16,116
protected function getWebPage ( $ url ) { $ curl = curl_init ( ) ; curl_setopt ( $ curl , CURLOPT_URL , $ url ) ; curl_setopt ( $ curl , CURLOPT_RETURNTRANSFER , true ) ; curl_setopt ( $ curl , CURLOPT_HEADER , false ) ; curl_setopt ( $ curl , CURLOPT_FOLLOWLOCATION , true ) ; $ output = curl_exec ( $ curl ) ; curl_clo...
Returns the content of a web resource .
16,117
public function indexAction ( ) { $ paybox = $ this -> get ( 'lexik_paybox.request_handler' ) ; $ paybox -> setParameters ( array ( 'PBX_CMD' => 'CMD' . time ( ) , 'PBX_DEVISE' => '978' , 'PBX_PORTEUR' => 'test@paybox.com' , 'PBX_RETOUR' => 'Mt:M;Ref:R;Auto:A;Erreur:E' , 'PBX_TOTAL' => '1000' , 'PBX_TYPEPAIEMENT' => 'C...
Index action creates the form for a payment call .
16,118
public function ipnAction ( ) { $ payboxResponse = $ this -> container -> get ( 'lexik_paybox.response_handler' ) ; $ result = $ payboxResponse -> verifySignature ( ) ; return new Response ( $ result ? 'OK' : 'KO' ) ; }
Instant Payment Notification action . Here presentation is anecdotal the requesting server only looks at the http status .
16,119
protected function getRequestParameters ( ) { if ( $ this -> request -> isMethod ( 'POST' ) ) { $ parameters = $ this -> request -> request ; } else { $ parameters = $ this -> request -> query ; } return $ parameters ; }
Returns the GET or POST parameters form the request .
16,120
protected function initSignature ( ) { if ( ! $ this -> getRequestParameters ( ) -> has ( $ this -> parameters [ 'hmac' ] [ 'signature_name' ] ) ) { $ this -> logger -> error ( 'Payment signature not set.' ) ; return false ; } $ signature = $ this -> getRequestParameters ( ) -> get ( $ this -> parameters [ 'hmac' ] [ '...
Gets the signature set in the http request .
16,121
protected function initData ( ) { foreach ( $ this -> getRequestParameters ( ) as $ key => $ value ) { $ this -> logger -> info ( sprintf ( '%s=%s' , $ key , $ value ) ) ; if ( $ this -> parameters [ 'hmac' ] [ 'signature_name' ] !== $ key ) { $ this -> data [ $ key ] = urlencode ( $ value ) ; } } }
Concatenates all parameters set in the http request .
16,122
public function verifySignature ( ) { $ this -> logger -> info ( 'New IPN call.' ) ; $ this -> initData ( ) ; $ this -> initSignature ( ) ; $ file = fopen ( $ this -> parameters [ 'public_key' ] , 'r' ) ; $ cert = fread ( $ file , 1024 ) ; fclose ( $ file ) ; $ publicKey = openssl_pkey_get_public ( $ cert ) ; $ result ...
Verifies the validity of the signature .
16,123
private function createOptionsRoutes ( Application $ app ) { foreach ( $ app [ 'cors.allowed_methods' ] as $ path => $ route ) { $ app -> match ( $ path , new Cors \ OptionsController ( $ route [ 'methods' ] ) ) -> setRequirements ( $ route [ 'requirements' ] ) -> method ( 'OPTIONS' ) ; } }
Create options route
16,124
public function getParameters ( ) { if ( null === $ this -> getParameter ( 'PBX_HMAC' ) ) { $ this -> setParameter ( 'PBX_TIME' , date ( 'c' ) ) ; $ this -> setParameter ( 'PBX_HMAC' , strtoupper ( $ this -> computeHmac ( ) ) ) ; } $ resolver = new ParameterResolver ( $ this -> globals [ 'currencies' ] ) ; return $ res...
Returns all parameters set for a payment .
16,125
public function getForm ( $ options = array ( ) ) { $ options [ 'csrf_protection' ] = false ; $ parameters = $ this -> getParameters ( ) ; if ( method_exists ( 'Symfony\Component\Form\AbstractType' , 'getBlockPrefix' ) ) { $ builder = $ this -> factory -> createNamedBuilder ( '' , 'Symfony\Component\Form\Extension\Core...
Returns a form with defined parameters .
16,126
protected function checkEndpoint ( ) { if ( $ this -> endpoint == '' || null === $ this -> endpoint || empty ( $ this -> endpoint ) ) { throw new \ RunTimeException ( 'No endpoint defined.' ) ; } }
Perform a call
16,127
public function customerRetrieve ( $ id ) { Stripe :: setApiKey ( $ this -> key ) ; $ customer = false ; try { $ customer = Stripe_Customer :: retrieve ( $ id ) ; } catch ( Exception $ e ) { return false ; } return $ customer ; }
The customerRetrieve method gets a customer object for viewing updating or deleting .
16,128
protected function _formatResult ( $ response ) { $ result = array ( ) ; foreach ( $ this -> fields as $ local => $ stripe ) { if ( is_array ( $ stripe ) ) { foreach ( $ stripe as $ obj => $ field ) { if ( isset ( $ response -> $ obj -> $ field ) ) { $ result [ $ local ] = $ response -> $ obj -> $ field ; } } } else { ...
Returns an array of fields we want from Stripe s response objects
16,129
function sendText ( $ to , $ from , $ message , $ unicode = null ) { if ( ! is_numeric ( $ from ) && ! mb_check_encoding ( $ from , 'UTF-8' ) ) { trigger_error ( '$from needs to be a valid UTF-8 encoded string' ) ; return false ; } if ( ! mb_check_encoding ( $ message , 'UTF-8' ) ) { trigger_error ( '$message needs to ...
Prepare new text message .
16,130
function sendBinary ( $ to , $ from , $ body , $ udh ) { $ body = bin2hex ( $ body ) ; $ udh = bin2hex ( $ udh ) ; $ from = $ this -> validateOriginator ( $ from ) ; $ post = array ( 'from' => $ from , 'to' => $ to , 'type' => 'binary' , 'body' => $ body , 'udh' => $ udh ) ; return $ this -> sendRequest ( $ post ) ; }
Prepare new WAP message .
16,131
function pushWap ( $ to , $ from , $ title , $ url , $ validity = 172800000 ) { if ( ! mb_check_encoding ( $ title , 'UTF-8' ) || ! mb_check_encoding ( $ url , 'UTF-8' ) ) { trigger_error ( '$title and $udh need to be valid UTF-8 encoded strings' ) ; return false ; } $ from = $ this -> validateOriginator ( $ from ) ; $...
Prepare new binary message .
16,132
private function sendRequest ( $ data ) { $ data = array_merge ( $ data , array ( 'username' => $ this -> nx_key , 'password' => $ this -> nx_secret ) ) ; $ post = '' ; foreach ( $ data as $ k => $ v ) { $ post .= "&$k=$v" ; } if ( function_exists ( 'curl_version' ) ) { $ to_nexmo = curl_init ( $ this -> nx_uri ) ; cur...
Prepare and send a new message .
16,133
private function normaliseKeys ( $ obj ) { if ( $ obj instanceof stdClass ) { $ new_obj = new stdClass ( ) ; $ is_obj = true ; } else { $ new_obj = array ( ) ; $ is_obj = false ; } foreach ( $ obj as $ key => $ val ) { if ( $ val instanceof stdClass || is_array ( $ val ) ) { $ val = $ this -> normaliseKeys ( $ val ) ; ...
Recursively normalise any key names in an object removing unwanted characters
16,134
private function nexmoParse ( $ from_nexmo ) { $ response = json_decode ( $ from_nexmo ) ; $ response_obj = $ this -> normaliseKeys ( $ response ) ; if ( $ response_obj ) { $ this -> nexmo_response = $ response_obj ; $ response_obj -> cost = $ total_cost = 0 ; if ( is_array ( $ response_obj -> messages ) ) { foreach ( ...
Parse server response .
16,135
public function displayOverview ( $ nexmo_response = null ) { $ info = ( ! $ nexmo_response ) ? $ this -> nexmo_response : $ nexmo_response ; if ( ! $ nexmo_response ) return 'Cannot display an overview of this response' ; if ( $ info -> messagecount > 1 ) { $ status = 'Your message was sent in ' . $ info -> messagecou...
Display a brief overview of a sent message . Useful for debugging and quick - start purposes .
16,136
public function reply ( $ message ) { if ( ! $ this -> inbound_message ) { return false ; } return $ this -> sendText ( $ this -> from , $ this -> to , $ message ) ; }
Reply the current message if one is set .
16,137
protected function getFinalTarget ( $ uploadData ) { if ( null === $ this -> options [ 'bucket' ] ) { throw new MissingBucketException ( 'No bucket was set when trying to upload a file to S3' ) ; } $ key = trim ( str_replace ( '\\' , '/' , parent :: getFinalTarget ( $ uploadData ) ) , '/' ) ; if ( strpos ( $ key , './'...
This method is overloaded so that the final target points to a URI using S3 protocol
16,138
public function balance ( ) { if ( ! isset ( $ this -> cache [ 'balance' ] ) ) { $ tmp = $ this -> apiCall ( 'get_balance' ) ; if ( ! $ tmp [ 'data' ] ) return false ; $ this -> cache [ 'balance' ] = $ tmp [ 'data' ] [ 'value' ] ; } return ( float ) $ this -> cache [ 'balance' ] ; }
Return your account balance in Euros
16,139
public function smsPricing ( $ country_code ) { $ country_code = strtoupper ( $ country_code ) ; if ( ! isset ( $ this -> cache [ 'country_codes' ] ) ) $ this -> cache [ 'country_codes' ] = array ( ) ; if ( ! isset ( $ this -> cache [ 'country_codes' ] [ $ country_code ] ) ) { $ tmp = $ this -> apiCall ( 'get_pricing' ...
Find out the price to send a message to a country
16,140
public function getCountryDialingCode ( $ country_code ) { $ country_code = strtoupper ( $ country_code ) ; if ( ! isset ( $ this -> cache [ 'country_codes' ] ) ) $ this -> cache [ 'country_codes' ] = array ( ) ; if ( ! isset ( $ this -> cache [ 'country_codes' ] [ $ country_code ] ) ) { $ tmp = $ this -> apiCall ( 'ge...
Return a countries international dialing code
16,141
public function numbersList ( ) { if ( ! isset ( $ this -> cache [ 'own_numbers' ] ) ) { $ tmp = $ this -> apiCall ( 'get_own_numbers' ) ; if ( ! $ tmp [ 'data' ] ) return false ; $ this -> cache [ 'own_numbers' ] = $ tmp [ 'data' ] ; } if ( ! $ this -> cache [ 'own_numbers' ] [ 'numbers' ] ) { return array ( ) ; } ret...
Get an array of all purchased numbers for your account
16,142
public function numbersSearch ( $ country_code , $ pattern ) { $ country_code = strtoupper ( $ country_code ) ; $ tmp = $ this -> apiCall ( 'search_numbers' , array ( 'country_code' => $ country_code , 'pattern' => $ pattern ) ) ; if ( ! $ tmp [ 'data' ] || ! isset ( $ tmp [ 'data' ] [ 'numbers' ] ) ) return false ; re...
Search available numbers to purchase for your account
16,143
public function numbersBuy ( $ country_code , $ msisdn ) { $ country_code = strtoupper ( $ country_code ) ; $ tmp = $ this -> apiCall ( 'buy_number' , array ( 'country_code' => $ country_code , 'msisdn' => $ msisdn ) ) ; return ( $ tmp [ 'http_code' ] === 200 ) ; }
Purchase an available number to your account
16,144
public function numbersCancel ( $ country_code , $ msisdn ) { $ country_code = strtoupper ( $ country_code ) ; $ tmp = $ this -> apiCall ( 'cancel_number' , array ( 'country_code' => $ country_code , 'msisdn' => $ msisdn ) ) ; return ( $ tmp [ 'http_code' ] === 200 ) ; }
Cancel an existing number on your account
16,145
private function apiCall ( $ command , $ data = array ( ) ) { if ( ! isset ( $ this -> rest_commands [ $ command ] ) ) { return false ; } $ cmd = $ this -> rest_commands [ $ command ] ; $ url = $ cmd [ 'url' ] ; $ url = str_replace ( array ( '{k}' , '{s}' ) , array ( $ this -> nx_key , $ this -> nx_secret ) , $ url ) ;...
Run a REST command on Nexmo SMS services
16,146
public function send ( $ text , $ imagePath = null , $ sticker = null ) { if ( empty ( $ text ) ) { return false ; } $ request_params = [ 'headers' => [ 'Authorization' => 'Bearer ' . $ this -> token , ] , ] ; $ request_params [ 'multipart' ] = [ [ 'name' => 'message' , 'contents' => $ text ] ] ; if ( ! empty ( $ image...
Send text message image or sticker on Line notify
16,147
private function publishFiles ( ) { $ publishTag = $ this -> _packageTag ; $ this -> publishes ( [ __DIR__ . '/config/' . $ this -> _packageTag . '.php' => base_path ( 'config/' . $ this -> _packageTag . '.php' ) , ] , $ publishTag ) ; $ this -> publishes ( [ __DIR__ . '/resources/views' => base_path ( 'resources/views...
Publish files for Laravel PHP Info .
16,148
public static function read_field ( $ fp , $ wire_type , & $ limit = null ) { switch ( $ wire_type ) { case 0 : return Protobuf :: read_varint ( $ fp , $ limit ) ; case 1 : $ limit -= 8 ; return fread ( $ fp , 8 ) ; case 2 : $ len = Protobuf :: read_varint ( $ fp , $ limit ) ; $ limit -= $ len ; return fread ( $ fp , $...
Read a unknown field from the stream and return its raw bytes
16,149
public function getCMSFields ( ) { $ this -> beforeUpdateCMSFields ( function ( FieldList $ fields ) { if ( $ this -> exists ( ) ) { $ fields -> addFieldsToTab ( 'Root.Domains' , [ GridField :: create ( 'Domains' , '' , $ this -> Domains ( ) , GridFieldConfig_RecordEditor :: create ( 10 ) ) ] ) ; } $ fields -> removeBy...
Show the configuration fields for each subsite
16,150
public function getPageTypeMap ( ) { $ pageTypeMap = [ ] ; $ pageTypes = SiteTree :: page_type_classes ( ) ; foreach ( $ pageTypes as $ pageType ) { $ pageTypeMap [ $ pageType ] = singleton ( $ pageType ) -> i18n_singular_name ( ) ; } asort ( $ pageTypeMap ) ; return $ pageTypeMap ; }
Return a list of the different page types available to the CMS
16,151
public function allowedThemes ( ) { if ( $ themes = self :: $ allowed_themes ) { return ArrayLib :: valuekey ( $ themes ) ; } $ themes = [ ] ; if ( is_dir ( THEMES_PATH ) ) { foreach ( scandir ( THEMES_PATH ) as $ theme ) { if ( $ theme [ 0 ] == '.' ) { continue ; } $ theme = strtok ( $ theme , '_' ) ; $ themes [ $ the...
Return the themes that can be used with this subsite as an array of themecode = > description
16,152
protected function createDefaultPages ( ) { SubsiteState :: singleton ( ) -> withState ( function ( SubsiteState $ newState ) { $ newState -> setSubsiteId ( $ this -> ID ) ; DB :: quiet ( ) ; $ siteTree = new SiteTree ( ) ; $ siteTree -> requireDefaultRecords ( ) ; } ) ; }
Automatically create default pages for new subsites
16,153
public function adminDuplicate ( ) { $ newItem = $ this -> duplicate ( ) ; $ message = _t ( __CLASS__ . '.CopyMessage' , 'Created a copy of {title}' , [ 'title' => Convert :: raw2js ( $ this -> Title ) ] ) ; return <<<JS statusMessage($message, 'good'); $('Form_EditForm').loadURLFromServer('admin...
Javascript admin action to duplicate this subsite
16,154
public function duplicate ( $ doWrite = true , $ manyMany = 'many_many' ) { $ duplicate = parent :: duplicate ( $ doWrite ) ; $ oldSubsiteID = SubsiteState :: singleton ( ) -> getSubsiteId ( ) ; self :: changeSubsite ( $ this -> ID ) ; $ stack = [ [ 0 , 0 ] ] ; while ( count ( $ stack ) > 0 ) { list ( $ sourceParentID ...
Duplicate this subsite
16,155
public function validate ( $ validator ) { if ( $ this -> checkHostname ( $ this -> Value ( ) ) ) { return true ; } $ validator -> validationError ( $ this -> getName ( ) , _t ( 'DomainNameField.INVALID_DOMAIN' , 'Invalid domain name' ) , 'validation' ) ; return false ; }
Validate this field as a valid hostname
16,156
public function requireDefaultRecords ( ) { if ( ! $ this -> owner ) { return ; } $ schema = DataObject :: getSchema ( ) ; $ groupTable = Convert :: raw2sql ( $ schema -> tableName ( Group :: class ) ) ; $ groupFields = DB :: field_list ( $ groupTable ) ; if ( isset ( $ groupFields [ 'SubsiteID' ] ) ) { DB :: query ( '...
Migrations for GroupSubsites data .
16,157
public function updateTreeTitle ( & $ title ) { if ( $ this -> owner -> AccessAllSubsites ) { $ title = _t ( __CLASS__ . '.GlobalGroup' , 'global group' ) ; $ title = htmlspecialchars ( $ this -> owner -> Title , ENT_QUOTES ) . ' <i>(' . $ title . ')</i>' ; } else { $ subsites = Convert :: raw2xml ( implode ( ', ' , $ ...
If this group belongs to a subsite append the subsites title to the group title to make it easy to distinguish in the tree - view of the security admin interface .
16,158
public function getIsAdmin ( HTTPRequest $ request ) { $ adminPaths = static :: config ( ) -> get ( 'admin_url_paths' ) ; $ adminPaths [ ] = AdminRootController :: admin_url ( ) ; $ currentPath = rtrim ( $ request -> getURL ( ) , '/' ) . '/' ; foreach ( $ adminPaths as $ adminPath ) { if ( substr ( $ currentPath , 0 , ...
Determine whether the website is being viewed from an admin protected area or not
16,159
protected function detectSubsiteId ( HTTPRequest $ request ) { if ( $ request -> getVar ( 'SubsiteID' ) !== null ) { return ( int ) $ request -> getVar ( 'SubsiteID' ) ; } if ( SubsiteState :: singleton ( ) -> getUseSessions ( ) && $ request -> getSession ( ) -> get ( 'SubsiteID' ) !== null ) { return ( int ) $ request...
Use the given request to detect the current subsite ID
16,160
public function getSubstitutedDomain ( ) { $ currentHost = $ _SERVER [ 'HTTP_HOST' ] ; $ domain = preg_replace ( '/\.\*$/' , ".{$currentHost}" , $ this -> Domain ) ; $ domain = preg_replace ( '/^\*\./' , "subsite." , $ domain ) ; $ domain = str_replace ( '.www.' , '.' , $ domain ) ; return $ domain ; }
Retrieves domain name with wildcards substituted with actual values
16,161
public function getCMSTreeTitle ( ) { $ subsite = Subsite :: currentSubsite ( ) ; return $ subsite ? Convert :: raw2xml ( $ subsite -> Title ) : _t ( __CLASS__ . '.SITECONTENTLEFT' , 'Site Content' ) ; }
Set the title of the CMS tree
16,162
public function sectionSites ( $ includeMainSite = true , $ mainSiteTitle = 'Main site' , $ member = null ) { if ( $ mainSiteTitle == 'Main site' ) { $ mainSiteTitle = _t ( 'Subsites.MainSiteTitle' , 'Main site' ) ; } if ( ! $ member ) { $ member = Security :: getCurrentUser ( ) ; } if ( ! $ member ) { return ArrayList...
Find all subsites accessible for current user on this controller .
16,163
public function shouldChangeSubsite ( $ adminClass , $ recordSubsiteID , $ currentSubsiteID ) { if ( Config :: inst ( ) -> get ( $ adminClass , 'treats_subsite_0_as_global' ) && $ recordSubsiteID == 0 ) { return false ; } if ( $ recordSubsiteID != $ currentSubsiteID ) { return true ; } return false ; }
Helper for testing if the subsite should be adjusted .
16,164
public function canAccess ( ) { $ member = Security :: getCurrentUser ( ) ; if ( $ member && ( Permission :: checkMember ( $ member , [ 'ADMIN' , 'CMS_ACCESS_LeftAndMain' , 'CMS_ACCESS_CMSMain' , ] ) ) ) { return true ; } $ accessibleSites = $ this -> owner -> sectionSites ( true , 'Main site' , $ member ) ; return $ a...
Check if the current controller is accessible for this user on this subsite .
16,165
public function duplicateToSubsitePrep ( $ subsiteID , $ includeChildren ) { if ( is_object ( $ subsiteID ) ) { $ subsiteID = $ subsiteID -> ID ; } return SubsiteState :: singleton ( ) -> withState ( function ( SubsiteState $ newState ) use ( $ subsiteID , $ includeChildren ) { $ newState -> setSubsiteId ( $ subsiteID ...
Does the basic duplication but doesn t write anything this means we can subclass this easier and do more complex relation duplication .
16,166
public function onBeforeDuplicate ( ) { $ subsiteId = SubsiteState :: singleton ( ) -> getSubsiteId ( ) ; if ( $ subsiteId !== null ) { $ this -> owner -> SubsiteID = $ subsiteId ; } }
When duplicating a page assign the current subsite ID from the state
16,167
public function duplicateToSubsite ( $ subsiteID = null , $ includeChildren = false ) { $ clone = $ this -> owner -> duplicateToSubsitePrep ( $ subsiteID , $ includeChildren ) ; $ clone -> invokeWithExtensions ( 'onBeforeDuplicateToSubsite' , $ this -> owner ) ; if ( ! $ includeChildren ) { $ clone -> write ( ) ; } $ c...
Create a duplicate of this page and save it to another subsite
16,168
public function duplicateSubsiteRelations ( $ originalPage ) { $ thisClass = $ originalPage -> ClassName ; $ relations = Config :: inst ( ) -> get ( $ thisClass , 'duplicate_to_subsite_relations' ) ; if ( $ relations && ! empty ( $ relations ) ) { foreach ( $ relations as $ relation ) { $ items = $ originalPage -> $ re...
Duplicate relations using a static property to define which ones we want to duplicate
16,169
public function updatePreviewLink ( & $ link , $ action = null ) { $ url = Director :: absoluteURL ( $ this -> owner -> Link ( $ action ) ) ; $ link = HTTP :: setGetVar ( 'SubsiteID' , $ this -> owner -> SubsiteID , $ url ) ; return $ link ; }
Use the CMS domain for iframed CMS previews to prevent single - origin violations and SSL cert problems . Always set SubsiteID to avoid errors because a page doesn t exist on the CMS domain .
16,170
public function MetaTags ( & $ tags ) { if ( $ this -> owner -> SubsiteID ) { $ tags .= '<meta name="x-subsite-id" content="' . $ this -> owner -> SubsiteID . "\" />\n" ; } return $ tags ; }
Inject the subsite ID into the content so it can be used by frontend scripts .
16,171
public function augmentValidURLSegment ( ) { $ subsite = Subsite :: $ force_subsite ? : SubsiteState :: singleton ( ) -> getSubsiteId ( ) ; if ( empty ( $ this -> owner -> SubsiteID ) || $ subsite == $ this -> owner -> SubsiteID ) { return null ; } $ prevForceSubsite = Subsite :: $ force_subsite ; Subsite :: $ force_su...
Ensure that valid url segments are checked within the correct subsite of the owner object even if the current subsiteID is set to some other subsite .
16,172
public function updateFormFields ( FieldList $ fields ) { $ sites = Subsite :: accessible_sites ( 'CMS_ACCESS_AssetAdmin' ) ; $ values = [ ] ; $ values [ 0 ] = _t ( __CLASS__ . '.AllSitesDropdownOpt' , 'All sites' ) ; foreach ( $ sites as $ site ) { $ values [ $ site -> ID ] = $ site -> Title ; } ksort ( $ values ) ; i...
Add subsites - specific fields to the folder editor .
16,173
public function canView ( $ member = null ) { if ( parent :: canView ( $ member ) ) { return true ; } if ( Subsite :: all_accessible_sites ( ) -> count ( ) > 0 ) { return true ; } return false ; }
Relax the access permissions so anyone who has access to any CMS subsite can access this controller .
16,174
public function setProxy ( $ host , $ port , $ ssl = false , $ username = null , $ password = null ) { $ scheme = ( $ ssl ? 'https://' : 'http://' ) ; if ( ! is_null ( $ username ) ) { return $ this -> options [ 'proxy' ] = sprintf ( '%s%s:%s@%s:%s' , $ scheme , $ username , $ password , $ host , $ port ) ; } return $ ...
Enable proxy if needed .
16,175
public function run ( ) { $ model = Yii :: createObject ( $ this -> modelClass ) ; $ event = $ this -> getFormEvent ( $ model ) ; $ this -> trigger ( self :: EVENT_BEFORE_REQUEST , $ event ) ; $ load = $ model -> load ( Yii :: $ app -> request -> post ( ) ) ; if ( Yii :: $ app -> request -> isAjax ) { Yii :: $ app -> r...
Request password reset for a user .
16,176
public function actionRevoke ( $ roleName , $ email ) { $ user = UserModel :: findByEmail ( $ email ) ; if ( empty ( $ user ) ) { throw new Exception ( Yii :: t ( 'yii2mod.user' , 'User is not found.' ) ) ; } $ role = $ this -> findRole ( $ roleName ) ; if ( ! in_array ( $ roleName , array_keys ( $ this -> _authManager...
Revoke role from the user
16,177
protected function findRole ( $ roleName ) { if ( ( $ role = $ this -> _authManager -> getRole ( $ roleName ) ) !== null ) { return $ role ; } throw new Exception ( Yii :: t ( 'yii2mod.user' , 'The role "{roleName}" is not found.' , [ 'roleName' => $ roleName , ] ) ) ; }
Returns the named role .
16,178
public function run ( $ token ) { try { $ model = Yii :: createObject ( $ this -> modelClass , [ $ token ] ) ; $ event = $ this -> getFormEvent ( $ model ) ; $ this -> trigger ( self :: EVENT_BEFORE_RESET , $ event ) ; } catch ( InvalidParamException $ e ) { throw new BadRequestHttpException ( $ e -> getMessage ( ) ) ;...
Reset password for a user .
16,179
public function convertDbConfig ( $ db ) { $ connectionOptions = [ ] ; if ( $ db [ 'dbdriver' ] === 'pdo' ) { return $ this -> convertDbConfigPdo ( $ db ) ; } elseif ( $ db [ 'dbdriver' ] === 'mysqli' ) { $ connectionOptions = [ 'driver' => $ db [ 'dbdriver' ] , 'user' => $ db [ 'username' ] , 'password' => $ db [ 'pas...
Convert CodeIgniter database config array to Doctrine s
16,180
public function run ( ) { $ model = Yii :: createObject ( $ this -> modelClass ) ; $ event = $ this -> getFormEvent ( $ model ) ; $ this -> trigger ( self :: EVENT_BEFORE_SIGNUP , $ event ) ; $ load = $ model -> load ( Yii :: $ app -> request -> post ( ) ) ; if ( Yii :: $ app -> request -> isAjax ) { Yii :: $ app -> re...
Signup a user .
16,181
protected function replaceNode ( $ string ) { if ( empty ( $ string ) ) { $ this -> node -> parentNode -> removeChild ( $ this -> node ) ; return null ; } $ newDocument = new Document ( $ string ) ; if ( $ newDocument -> outertext !== $ string ) { throw new RuntimeException ( 'Not valid HTML fragment' ) ; } $ newNode =...
Replace this node
16,182
protected function replaceChild ( $ string ) { if ( ! empty ( $ string ) ) { $ newDocument = new Document ( $ string ) ; if ( $ newDocument -> outertext !== $ string ) { throw new RuntimeException ( 'Not valid HTML fragment' ) ; } } foreach ( $ this -> node -> childNodes as $ node ) { $ this -> node -> removeChild ( $ ...
Replace child node
16,183
protected function replaceText ( $ string ) { if ( empty ( $ string ) ) { $ this -> node -> parentNode -> removeChild ( $ this -> node ) ; return null ; } $ newElement = $ this -> node -> ownerDocument -> createTextNode ( $ string ) ; $ newNode = $ this -> node -> ownerDocument -> importNode ( $ newElement , true ) ; $...
Replace this node with text
16,184
public function childNodes ( $ idx = - 1 ) { $ nodeList = $ this -> getIterator ( ) ; if ( $ idx === - 1 ) { return $ nodeList ; } if ( isset ( $ nodeList [ $ idx ] ) ) { return $ nodeList [ $ idx ] ; } return null ; }
Returns children of node
16,185
public function firstChild ( ) { $ node = $ this -> node -> firstChild ; if ( $ node === null ) { return null ; } return new Element ( $ node ) ; }
Returns the first child of node
16,186
public function lastChild ( ) { $ node = $ this -> node -> lastChild ; if ( $ node === null ) { return null ; } return new Element ( $ node ) ; }
Returns the last child of node
16,187
public function nextSibling ( ) { $ node = $ this -> node -> nextSibling ; if ( $ node === null ) { return null ; } return new Element ( $ node ) ; }
Returns the next sibling of node
16,188
public function previousSibling ( ) { $ node = $ this -> node -> previousSibling ; if ( $ node === null ) { return null ; } return new Element ( $ node ) ; }
Returns the previous sibling of node
16,189
public function getAllAttributes ( ) { if ( $ this -> node -> hasAttributes ( ) ) { $ attributes = [ ] ; foreach ( $ this -> node -> attributes as $ attr ) { $ attributes [ $ attr -> name ] = $ attr -> value ; } return $ attributes ; } return null ; }
Returns array of attributes
16,190
public function loadHtml ( $ html ) { if ( ! is_string ( $ html ) ) { throw new InvalidArgumentException ( __METHOD__ . ' expects parameter 1 to be string.' ) ; } libxml_use_internal_errors ( true ) ; libxml_disable_entity_loader ( true ) ; $ sxe = simplexml_load_string ( $ html ) ; if ( libxml_get_errors ( ) ) { $ thi...
Load HTML from string
16,191
public function loadHtmlFile ( $ filePath ) { if ( ! is_string ( $ filePath ) ) { throw new InvalidArgumentException ( __METHOD__ . ' expects parameter 1 to be string.' ) ; } if ( ! preg_match ( "/^https?:\/\//i" , $ filePath ) && ! file_exists ( $ filePath ) ) { throw new RuntimeException ( "File $filePath not found" ...
Load HTML from file
16,192
public function html ( ) { if ( $ this :: $ callback !== null ) { call_user_func ( $ this :: $ callback , $ this ) ; } return trim ( $ this -> document -> saveHTML ( $ this -> document -> documentElement ) ) ; }
Get dom node s outer html
16,193
public function innerHtml ( ) { $ text = '' ; foreach ( $ this -> document -> documentElement -> childNodes as $ node ) { $ text .= trim ( $ this -> document -> saveXML ( $ node ) ) ; } return $ text ; }
Get dom node s inner html
16,194
public function save ( $ filepath = '' ) { $ string = $ this -> innerHtml ( ) ; if ( $ filepath !== '' ) { file_put_contents ( $ filepath , $ string , LOCK_EX ) ; } return $ string ; }
Save dom as string
16,195
protected function determineDynamicType ( $ mix_value ) { switch ( gettype ( $ mix_value ) ) { case 'boolean' : $ int_dynamic_type = Schema :: PROPERTY_BOOLEAN ; break ; case 'integer' : $ int_dynamic_type = Schema :: PROPERTY_INTEGER ; break ; case 'double' : $ int_dynamic_type = Schema :: PROPERTY_DOUBLE ; break ; ca...
Dynamically determine type for a value
16,196
public function mapFromResults ( array $ arr_results ) { $ arr_entities = [ ] ; foreach ( $ arr_results as $ obj_result ) { $ arr_entities [ ] = $ this -> mapOneFromResult ( $ obj_result ) ; } return $ arr_entities ; }
Map 1 - many results out of the Raw response data array
16,197
public function delete ( $ entities ) { if ( $ entities instanceof Entity ) { $ entities = [ $ entities ] ; } return $ this -> obj_gateway -> withSchema ( $ this -> obj_schema ) -> withTransaction ( $ this -> consumeTransaction ( ) ) -> deleteMulti ( $ entities ) ; }
Delete one or more Model objects from the Datastore
16,198
public function fetchById ( $ str_id ) { return $ this -> obj_gateway -> withSchema ( $ this -> obj_schema ) -> withTransaction ( $ this -> str_transaction_id ) -> fetchById ( $ str_id ) ; }
Fetch a single Entity from the Datastore by it s Key ID
16,199
public function fetchByIds ( array $ arr_ids ) { return $ this -> obj_gateway -> withSchema ( $ this -> obj_schema ) -> withTransaction ( $ this -> str_transaction_id ) -> fetchByIds ( $ arr_ids ) ; }
Fetch multiple entities by Key ID