idx
int64
0
60.3k
question
stringlengths
101
6.21k
target
stringlengths
7
803
44,100
public function allFlashes ( ) { if ( ! $ this -> isOpened ( ) ) { $ this -> start ( ) ; } if ( ! empty ( $ this -> old_flashes ) ) { $ _oldf = $ this -> old_flashes ; $ this -> old_flashes = array ( ) ; return $ _oldf ; } return null ; }
Get current session flash parameters stack
44,101
public function clearFlashes ( ) { if ( ! $ this -> isOpened ( ) ) { $ this -> start ( ) ; } $ this -> flashes = array ( ) ; $ this -> old_flashes = array ( ) ; return $ this ; }
Delete current session flash parameters
44,102
public function addVisitor ( UserInterface $ user , Request $ request ) { $ days = 30 ; $ ip = $ request -> getClientIp ( ) ; $ data = $ this -> getVisitors ( ) ; $ date = new \ DateTime ( ) ; $ currTimestamp = $ date -> getTimestamp ( ) ; $ date -> setTime ( $ date -> format ( 'H' ) , 0 , 0 ) ; $ todayTimestamp = $ date -> getTimestamp ( ) ; if ( ! isset ( $ data [ $ todayTimestamp ] ) ) { $ data [ $ todayTimestamp ] = array ( ) ; } $ type = $ user -> getSymbbType ( ) ; $ currVisitor = array ( 'id' => $ user -> getId ( ) , 'type' => $ type , 'ip' => $ ip , 'lastVisiting' => $ currTimestamp ) ; $ overwriteKey = null ; $ maxOldDate = new \ DateTime ( ) ; $ maxOldDate -> setTime ( 0 , 0 , 0 ) ; $ maxOldDate -> modify ( '-' . $ days . 'days' ) ; foreach ( $ data as $ timestamp => $ tmp ) { if ( ! is_numeric ( $ timestamp ) || $ timestamp < $ maxOldDate -> getTimestamp ( ) ) { unset ( $ data [ $ timestamp ] ) ; } } foreach ( $ data [ $ todayTimestamp ] as $ key => $ visitor ) { if ( ( $ currVisitor [ 'type' ] == 'guest' && $ visitor [ 'type' ] == $ currVisitor [ 'type' ] && $ visitor [ 'ip' ] == $ currVisitor [ 'ip' ] ) || ( $ currVisitor [ 'type' ] == 'user' && $ visitor [ 'type' ] == $ currVisitor [ 'type' ] && $ visitor [ 'id' ] == $ currVisitor [ 'id' ] ) ) { $ overwriteKey = $ key ; break ; } } if ( $ overwriteKey !== null ) { $ data [ $ todayTimestamp ] [ $ overwriteKey ] = $ currVisitor ; } else { $ data [ $ todayTimestamp ] [ ] = $ currVisitor ; } ksort ( $ data , SORT_NUMERIC ) ; $ data = array_reverse ( $ data , true ) ; $ this -> memcache -> set ( self :: MEMCACHE_VISITOR_KEY , $ data , ( 86400 * $ days ) ) ; }
this method will add a visitor to the statistic currently its only a memcache storage because this information is not important if someone will track his visitors fully he should use a analytics tool
44,103
public function get ( ) { foreach ( $ this -> _commands as $ command ) { $ location = $ this -> _commandLocator -> locate ( basename ( $ command ) ) ; if ( $ location !== null ) { return $ location ; } } return null ; }
Returns the path to the first command found in the list .
44,104
protected function readUntil ( $ search ) { while ( ( $ position = strpos ( $ this -> buffer , $ search ) ) === false ) { if ( feof ( $ this -> fp ) ) { fclose ( $ this -> fp ) ; throw new DecodeException ( "Invalid multipart data encountered; " . "end of content was reached before expected" ) ; } $ this -> buffer .= fread ( $ this -> fp , $ this -> bytesPerRead ) ; } return $ position ; }
Read the input stream into the buffer until a string is encountered
44,105
protected function addValue ( & $ fieldsArray , $ name , $ value ) { $ arrayCheck = substr ( $ name , - 2 ) ; if ( $ arrayCheck == '[]' ) { $ nameSubstr = substr ( $ name , 0 , - 2 ) ; if ( ! isset ( $ fieldsArray [ $ nameSubstr ] ) ) $ fieldsArray [ $ nameSubstr ] = [ ] ; $ fieldsArray [ $ nameSubstr ] [ ] = $ value ; } else { $ fieldsArray [ $ name ] = $ value ; } }
Inserts the value into the passed array . Used to parse input array from HTTP request body if needed
44,106
public function getUserOption ( $ option , $ defaultValue = null ) { return isset ( $ this -> _options [ $ option ] ) ? $ this -> _options [ $ option ] : $ defaultValue ; }
Returns the value of an option if present
44,107
protected function _setDefaultUserOptions ( array $ options ) { foreach ( $ options as $ option => $ value ) { if ( ! $ this -> getUserOption ( $ option ) ) $ this -> setUserOption ( $ option , $ value ) ; } return $ this ; }
Used to set defaults will not overwrite existing values
44,108
public function city ( ) { $ requestParams = $ this -> initRequestParams ( 'city' ) ; $ this -> request ( 'city' , $ requestParams ) ; return empty ( $ this -> error ) ; }
Get City list from gateway
44,109
public function fee ( $ cityId , $ orderAmount ) { $ params = compact ( 'cityId' , 'orderAmount' ) ; $ requestParams = $ this -> initRequestParams ( 'fee' , $ params ) ; $ this -> request ( 'fee' , $ requestParams ) ; return empty ( $ this -> error ) ; }
Get fee result by city and amount
44,110
public function getFeeValue ( $ cityId , $ orderAmount ) { $ result = $ this -> fee ( $ cityId , $ orderAmount ) ; if ( ! $ result ) { dd ( $ this -> getResultRaw ( ) ) ; return null ; } return $ this -> getResultFeeValue ( ) ; }
Get fee value by city and amount
44,111
public function status ( $ orderCode , $ toNumber ) { $ params = compact ( 'orderCode' , 'toNumber' ) ; $ requestParams = $ this -> initRequestParams ( 'status' , $ params ) ; $ this -> request ( 'status' , $ requestParams ) ; return empty ( $ this -> error ) ; }
Get payment status
44,112
private function request ( $ type , $ requestParams ) { $ this -> cleanup ( ) ; $ curl = new Curl ( ) ; $ curl -> setCheckCertificates ( $ this -> configParams [ 'strongSSL' ] ) ; $ curl -> post ( $ this -> configParams [ 'gatewayUrl' ] , array ( 'type' => $ type , 'input' => $ requestParams , ) ) ; $ this -> parseErrors ( $ curl ) ; if ( ! $ this -> error || $ this -> error [ 'type' ] == self :: C_ERROR_PROCESSING ) { $ this -> response = json_decode ( $ curl -> result ) ; } }
Executing http request
44,113
private function parseErrors ( Curl $ curl ) { $ this -> rawResponse = $ curl -> result ; if ( $ curl -> error ) { $ this -> error = array ( 'type' => self :: C_ERROR_HTTP , 'message' => 'Curl error: ' . $ curl -> error , ) ; return ; } if ( $ curl -> code != '200' ) { $ this -> error = array ( 'type' => self :: C_ERROR_HTTP , 'message' => 'Response code: ' . $ curl -> code , ) ; return ; } if ( empty ( $ curl -> result ) ) { $ this -> error = array ( 'type' => self :: C_ERROR_GATEWAY , 'message' => 'Empty Response' , ) ; return ; } $ response = @ json_decode ( $ curl -> result ) ; if ( ! $ response || empty ( $ response -> type ) ) { $ this -> error = array ( 'type' => self :: C_ERROR_GATEWAY , 'message' => 'Response is not json or Unrecognized response format' , ) ; return ; } if ( $ response -> type == 'error' ) { $ this -> error = array ( 'type' => self :: C_ERROR_PROCESSING , 'message' => $ response -> message , ) ; return ; } }
Parse error type
44,114
public static function simpleArrayToObject ( $ array , $ object = null ) { foreach ( $ array as $ key => $ value ) { $ object -> $ key = $ value ; } return $ object ; }
utilisation simple array with numeric keys to object
44,115
public function visitForm ( FormInterface $ form ) { $ template = "form/{$form->getType()}.twig" ; return $ this -> loadTemplate ( $ template ) -> render ( [ "id" => $ form -> getId ( ) , "classes" => $ form -> getClasses ( ) , "data" => $ form -> getData ( ) , "method" => $ form -> getMethod ( ) , "target" => $ form -> getTarget ( ) , "writables" => $ form -> getWritableBearer ( ) -> getWritables ( ) , "actions" => $ form -> getActions ( ) , "errors" => $ form -> getErrors ( ) , ] ) ; }
Render FormInterface into html .
44,116
public function visitFormAction ( FormActionInterface $ formAction ) { $ template = "form-action/{$formAction->getType()}.twig" ; return $ this -> loadTemplate ( $ template ) -> render ( [ "label" => $ formAction -> getLabel ( ) , "target" => $ formAction -> getTarget ( ) , "classes" => $ formAction -> getClasses ( ) , "data" => $ formAction -> getData ( ) , ] ) ; }
Render FormActionInterface into html .
44,117
public function visitFilter ( FilterInterface $ filter ) { if ( $ filter instanceof DummyFilter ) { $ type = 'dummy' ; } elseif ( $ filter instanceof SelectFilter ) { $ type = 'select' ; } elseif ( $ filter instanceof SearchFilter ) { $ type = 'search' ; } elseif ( $ filter instanceof SortFilter ) { $ type = 'sort' ; } elseif ( $ filter instanceof PaginationFilter ) { $ type = "{$filter->getType()}-pagination" ; } elseif ( method_exists ( $ filter , 'getType' ) === true ) { $ type = $ filter -> getType ( ) ; } else { $ type = 'dummy' ; } $ template = "filter/$type.twig" ; return $ this -> loadTemplate ( $ template ) -> render ( [ "id" => $ filter -> getId ( ) , "options" => $ filter -> getOptions ( ) , ] ) ; }
Helper method to render a FilterInterface to html .
44,118
protected function _restoreFromArray ( array $ spec ) { foreach ( $ spec as $ key => $ value ) { if ( property_exists ( $ this , $ key ) ) { $ this -> { $ key } = $ value ; } } }
Restore object state from array
44,119
public function setGroup ( $ group , $ feature ) { if ( ! isset ( $ this -> _aGroup [ $ group ] ) ) { $ this -> _aGroup [ $ group ] = array ( ) ; } if ( ! in_array ( $ feature , $ this -> _aGroup [ $ group ] ) ) { $ this -> _aGroup [ $ group ] [ ] = $ feature ; } return $ this ; }
Affects a feature to a group
44,120
protected static function _matchAgentAgainstSignatures ( $ userAgent , $ signatures ) { $ userAgent = strtolower ( $ userAgent ) ; foreach ( $ signatures as $ signature ) { if ( ! empty ( $ signature ) ) { if ( strpos ( $ userAgent , $ signature ) !== false ) { return true ; } } } return false ; }
Match a user agent string against a list of signatures
44,121
public final function get ( $ key ) { if ( isset ( $ this -> _map [ $ key ] ) ) { return $ this -> _map [ $ key ] ; } return null ; }
Returns the value to which this map maps the specified key .
44,122
public final function putAll ( array $ values ) { if ( ! is_array ( $ values ) ) { return ; } foreach ( $ values as $ key => $ value ) { $ this -> put ( $ key , $ value ) ; } }
Copies all of the mappings from the specified map to this map .
44,123
public final function remove ( $ key ) { $ previous = $ this -> get ( $ key ) ; if ( isset ( $ this -> _map [ $ key ] ) ) { unset ( $ this -> _map [ $ key ] ) ; } return $ previous ; }
Removes the mapping for this key from this map if it is present .
44,124
protected function initLocale ( $ locale ) { $ file = $ this -> localeDir . '/' . $ locale . '.php' ; if ( file_exists ( $ file ) ) { $ data = include $ file ; if ( ! is_array ( $ data ) ) { $ data = [ ] ; } } else { $ data = [ ] ; } if ( ! isset ( $ data [ 'pluralForm' ] ) || ! is_callable ( $ data [ 'pluralForm' ] ) ) { $ data [ 'pluralForm' ] = null ; } if ( ! isset ( $ data [ 'texts' ] ) ) { $ data [ 'texts' ] = [ ] ; } $ this -> data [ $ locale ] = $ data ; }
Set translations and plural form for the given locale .
44,125
protected function getPluralIndex ( callable $ pluralForm , $ number ) { $ nplurals = 0 ; $ plural = 0 ; call_user_func_array ( $ pluralForm , [ & $ nplurals , & $ plural , $ number ] ) ; if ( is_bool ( $ plural ) ) { $ plural = $ plural ? 1 : 0 ; } if ( $ plural < 0 ) { $ plural = 0 ; } if ( $ plural > $ nplurals - 1 ) { $ plural = $ nplurals - 1 ; } return $ plural ; }
Get plural form index for the given number .
44,126
public function addNamespace ( $ prefix , $ baseDir ) { $ prefix = trim ( $ prefix , '\\' ) . '\\' ; $ baseDir = rtrim ( $ baseDir , DIRECTORY_SEPARATOR ) . DIRECTORY_SEPARATOR ; if ( ! isset ( $ this -> namespaceMap [ $ prefix ] ) ) { $ this -> namespaceMap [ $ prefix ] = [ ] ; } array_push ( $ this -> namespaceMap [ $ prefix ] , str_replace ( '$path' , $ this -> basePath , $ baseDir ) ) ; }
Registers a PSR - 4 namespace .
44,127
public function register ( ) { spl_autoload_register ( function ( $ class ) { $ prefix = $ class ; while ( false !== $ pos = strrpos ( $ prefix , '\\' ) ) { $ prefix = substr ( $ class , 0 , $ pos + 1 ) ; $ relativeClass = substr ( $ class , $ pos + 1 ) ; $ paths = $ this -> getPaths ( $ prefix ) ; if ( $ paths !== null ) { foreach ( $ paths as $ baseDir ) { $ file = $ baseDir . str_replace ( '\\' , DIRECTORY_SEPARATOR , $ relativeClass ) . '.php' ; if ( file_exists ( $ file ) ) { require $ file ; return true ; } } } $ prefix = rtrim ( $ prefix , '\\' ) ; } return false ; } ) ; }
Registers the autoloading via SPL .
44,128
function setRenderer ( $ renderer ) { if ( ! $ renderer instanceof iViewRenderer && ! is_callable ( $ renderer ) ) throw new \ InvalidArgumentException ( sprintf ( 'Renderer must extend of (iViewRenderer) or callable. given: (%s)' , \ Poirot \ Std \ flatten ( $ renderer ) ) ) ; $ this -> renderer = $ renderer ; return $ this ; }
Set Iso Renderer
44,129
protected function setResolverOptions ( $ options ) { $ resolver = $ this -> resolver ( ) ; $ resolver -> with ( $ resolver :: parseWith ( $ options ) ) ; }
Proxy Helper Options For Resolver
44,130
public function getMaxValue ( ) { $ retour = 0 ; foreach ( $ this -> listeValues as $ indice => $ value ) { if ( is_array ( $ value ) ) { for ( $ i = 0 ; $ i < count ( $ value ) ; $ i ++ ) { if ( $ value [ $ i ] > $ retour ) $ retour = $ value [ $ i ] ; } } else { if ( $ value > $ retour ) $ retour = $ value ; } } return $ retour ; }
renvoi la valeur maximal parmis la liste de valeur
44,131
public function getStateCandidates ( int $ state ) : array { $ candidates = [ ] ; foreach ( $ this -> candidates as $ candidateId => $ candidate ) { if ( $ candidate -> getState ( ) == $ state ) { $ candidates [ $ candidateId ] = $ candidate ; } } return $ candidates ; }
Get all candidates of a specific state .
44,132
public function getCandidateIds ( ) : array { $ candidateIds = [ ] ; foreach ( $ this -> candidates as $ candidate ) { $ candidateIds [ ] = $ candidate -> getId ( ) ; } return $ candidateIds ; }
Get an array of candidate ids .
44,133
public function getCandidatesStatus ( ) : array { $ candidates = [ ] ; foreach ( $ this -> getElectedCandidates ( ) as $ candidate ) { $ candidates [ 'elected' ] [ ] = $ candidate -> getId ( ) ; } foreach ( $ this -> getActiveCandidates ( ) as $ candidate ) { $ candidates [ 'active' ] [ ] = [ $ candidate -> getId ( ) , $ candidate -> getVotes ( ) ] ; } foreach ( $ this -> getDefeatedCandidates ( ) as $ candidate ) { $ candidates [ 'defeated' ] [ ] = $ candidate -> getId ( ) ; } return $ candidates ; }
Get status of all candidates .
44,134
public function process ( Payload $ payload ) { $ directory = $ this -> getDirectorySettingOrFail ( ) ; $ branch = $ this -> getSettingValue ( self :: OPTION_BRANCH , $ payload -> getRepository ( ) -> getMasterBranch ( ) ) ; $ url = $ this -> getSettingValue ( self :: OPTION_REPOSITORY , $ payload -> getRepository ( ) -> getUrl ( ) ) ; $ git = $ this -> resolveGitCommand ( ) ; $ command = array ( 'cd' , escapeshellarg ( $ directory ) , '&&' , $ git , self :: COMMAND , escapeshellarg ( $ url ) , escapeshellarg ( $ branch ) ) ; if ( TRUE === ( boolean ) $ this -> getSettingValue ( self :: OPTION_REBASE , FALSE ) ) { $ command [ ] = self :: COMMAND_REBASE ; } $ output = $ this -> executeGitCommand ( $ command ) ; $ payload -> getResponse ( ) -> addOutputFromPlugin ( $ this , $ output ) ; }
Perform whichever task the Plugin should perform based on the payload s data .
44,135
public function set ( CheckerInterface $ checker ) : self { $ this -> checkers [ $ checker -> getId ( ) ] = $ checker ; return $ this ; }
Add or replace a checker instance to the collection at given id .
44,136
public static function validator ( EntityStructure $ entityStructure , $ data ) { switch ( gettype ( $ data ) ) { case 'array' : return new ArrayValidator ( $ entityStructure , $ data ) ; default : return false ; } }
Get validator matching for the given data type .
44,137
public function init ( ) { $ this -> userService = $ this -> di -> get ( "userService" ) ; $ this -> session = $ this -> di -> get ( "session" ) ; $ this -> response = $ this -> di -> get ( "response" ) ; $ this -> view = $ this -> di -> get ( "view" ) ; $ this -> pageRender = $ this -> di -> get ( "pageRender" ) ; }
Initiate the controller .
44,138
public function getPostLogin ( ) { if ( $ this -> userService -> checkLoggedin ( ) ) { $ this -> response -> redirect ( "" ) ; } $ title = "Administration - Login" ; $ form = new UserLoginForm ( $ this -> di ) ; $ form -> check ( ) ; $ data = [ "form" => $ form -> getHTML ( ) , ] ; $ this -> view -> add ( "user/login" , $ data ) ; $ this -> pageRender -> renderPage ( [ "title" => $ title ] ) ; }
Login - page
44,139
public function stripBadChars ( string $ parameter , array $ optionalChars = [ ] ) : string { return str_replace ( self :: badChars . $ optionalChars , "" , $ parameter ) ; }
Strip unauthorized chars from string
44,140
public function readFromArray ( array $ data ) : array { foreach ( $ data as $ key => $ value ) { if ( is_string ( $ value ) ) { $ value = $ this -> macro_processor -> process ( $ value ) ; $ data [ $ key ] = $ value ; } else if ( is_array ( $ value ) ) { $ data [ $ key ] = $ this -> readFromArray ( $ value ) ; } } return $ data ; }
Read from array
44,141
public function offsetGet ( $ offset ) { if ( $ this -> ResolveTraitOffsetExists ( $ offset ) ) { return $ this -> ResolveTraitOffsetGet ( $ offset ) ; } if ( $ this -> AccessTraitOffsetExists ( $ offset ) ) { return $ this -> AccessTraitOffsetGet ( $ offset ) ; } if ( $ this -> getLoops ( ) -> hasService ( $ offset ) ) { return $ this -> getLoops ( ) -> getService ( $ offset ) ; } user_error ( "Undefined index: $offset" , E_USER_NOTICE ) ; }
Gets a value either via the ResolveTrait AccessTrait or the loops getService functionality
44,142
public function add ( ... $ parameters ) { if ( count ( $ parameters ) === 1 ) { $ this -> routes [ 'regular' ] [ ] = [ 'closure' => $ parameters [ 0 ] , 'groupArgs' => [ ] ] ; } elseif ( count ( $ parameters ) === 2 ) { $ this -> routes [ 'regular' ] [ ] = [ 'closure' => $ parameters [ 1 ] , 'groupArgs' => $ parameters [ 0 ] ] ; } else { throw new \ InvalidArgumentException ; } }
Add non multilingual route
44,143
public function addMultiLanguage ( ... $ parameters ) { if ( count ( $ parameters ) === 1 ) { $ this -> routes [ 'ml' ] [ ] = [ 'closure' => $ parameters [ 0 ] , 'groupArgs' => [ ] ] ; } elseif ( count ( $ parameters ) === 2 ) { $ this -> routes [ 'ml' ] [ ] = [ 'closure' => $ parameters [ 1 ] , 'groupArgs' => $ parameters [ 0 ] ] ; } else { throw new \ InvalidArgumentException ; } }
Add multilingual route
44,144
public function setCatchAll ( ... $ parameters ) { if ( count ( $ parameters ) === 1 ) { $ this -> routes [ 'catchAll' ] = [ 'closure' => $ parameters [ 0 ] , 'groupArgs' => [ ] ] ; } elseif ( count ( $ parameters ) === 2 ) { $ this -> routes [ 'catchAll' ] = [ 'closure' => $ parameters [ 1 ] , 'groupArgs' => $ parameters [ 0 ] ] ; } else { throw new \ InvalidArgumentException ; } }
Add catch all route
44,145
public function registerAll ( ) { $ service = resolve ( LanguageService :: class ) ; $ languages = $ service -> getAllEnabled ( ) ; foreach ( $ this -> routes [ 'ml' ] as $ value ) { foreach ( $ languages as $ language ) { $ prefix = null ; if ( ! $ language -> is_default ) { $ prefix = $ language -> code ; } Route :: group ( array_merge ( [ 'prefix' => $ prefix ] , $ value [ 'groupArgs' ] ) , function ( $ router ) use ( $ value , $ language ) { $ value [ 'closure' ] ( $ router , $ language -> code ) ; } ) ; } } foreach ( $ this -> routes [ 'regular' ] as $ value ) { Route :: group ( $ value [ 'groupArgs' ] , function ( $ router ) use ( $ value ) { $ value [ 'closure' ] ( $ router ) ; } ) ; } if ( ! empty ( $ this -> routes [ 'catchAll' ] ) ) { Route :: group ( $ this -> routes [ 'catchAll' ] [ 'groupArgs' ] , function ( $ router ) { $ this -> routes [ 'catchAll' ] [ 'closure' ] ( $ router ) ; } ) ; } $ router = resolve ( 'router' ) ; $ router -> getRoutes ( ) -> refreshActionLookups ( ) ; $ router -> getRoutes ( ) -> refreshNameLookups ( ) ; }
It registers all routes
44,146
public function get ( $ identifier ) : ColumnInterface { if ( false === $ this -> has ( $ identifier ) ) { throw new ColumnNotFoundException ( $ identifier ) ; } return $ this -> items [ $ identifier ] ; }
Returns column by its identifier
44,147
public static function elapsedTime ( string $ point_name ) : string { if ( isset ( Debug :: $ time [ $ point_name ] ) ) return sprintf ( "%01.4f" , microtime ( true ) - Debug :: $ time [ $ point_name ] ) ; }
Get elapsed time for current point
44,148
public static function memoryUsage ( string $ point_name ) : string { if ( isset ( Debug :: $ memory [ $ point_name ] ) ) { $ unit = array ( 'B' , 'KB' , 'MB' , 'GB' , 'TiB' , 'PiB' ) ; $ size = memory_get_usage ( ) - Debug :: $ memory [ $ point_name ] ; $ memory_usage = @ round ( $ size / pow ( 1024 , ( $ i = floor ( log ( $ size , 1024 ) ) ) ) , 2 ) . ' ' . $ unit [ ( $ i < 0 ? 0 : $ i ) ] ; return $ memory_usage ; } }
Get memory usage for current point
44,149
public function setShape ( $ value , $ replace = true ) { $ name = 'shapes' ; if ( ! ( is_array ( $ value ) || is_string ( $ value ) ) ) { throw new CPS_Exception ( array ( array ( 'long_message' => 'Invalid request parameter' , 'code' => ERROR_CODE_INVALID_PARAMETER , 'level' => 'REJECTED' , 'source' => 'CPS_API' ) ) ) ; } if ( $ replace ) { $ this -> _setRawParam ( $ name , $ value ) ; } else { $ exParam = $ this -> _getRawParam ( $ name ) ; if ( ! is_array ( $ exParam ) ) { $ exParam = array ( $ exParam ) ; } if ( is_array ( $ value ) ) { foreach ( $ value as $ val ) { $ exParam [ ] = $ val ; } } else if ( is_string ( $ value ) ) { $ exParam [ ] = $ value ; } $ this -> _setRawParam ( $ name , $ exParam ) ; } }
Sets shape definition for geospatial search
44,150
public function setParam ( $ name , $ value ) { if ( in_array ( $ name , $ this -> _textParamNames ) ) { $ this -> _setTextParam ( $ name , $ value ) ; } else if ( in_array ( $ name , $ this -> _rawParamNames ) ) { $ this -> _setRawParam ( $ name , $ value ) ; } else { throw new CPS_Exception ( array ( array ( 'long_message' => 'Invalid request parameter' , 'code' => ERROR_CODE_INVALID_PARAMETER , 'level' => 'REJECTED' , 'source' => 'CPS_API' ) ) ) ; } }
sets a request parameter
44,151
private function _setTextParam ( & $ name , & $ value ) { if ( ! is_array ( $ value ) ) $ value = array ( $ value ) ; $ this -> _textParams [ $ name ] = $ value ; }
sets a text - only request parameter
44,152
private function _setRawParam ( & $ name , & $ value ) { if ( ! is_array ( $ value ) ) $ value = array ( $ value ) ; $ this -> _rawParams [ $ name ] = $ value ; }
sets a raw request parameter
44,153
private static function _setDocId ( & $ subdoc , & $ parentNode , $ id , & $ docIdXpath , $ curLevel = 0 ) { if ( $ parentNode -> nodeName == $ docIdXpath [ $ curLevel ] ) { if ( $ curLevel == count ( $ docIdXpath ) - 1 ) { $ curChild = $ parentNode -> firstChild ; while ( $ curChild ) { $ nextChild = $ curChild -> nextSibling ; $ parentNode -> removeChild ( $ curChild ) ; $ curChild = $ nextChild ; } if ( ! CPS_Request :: isValidUTF8 ( ( string ) $ id ) ) throw new CPS_Exception ( array ( array ( 'long_message' => 'Invalid UTF-8 encoding in document ID' , 'code' => ERROR_CODE_INVALID_UTF8 , 'level' => 'ERROR' , 'source' => 'CPS_API' ) ) ) ; $ textNode = $ subdoc -> createTextNode ( $ id ) ; $ parentNode -> appendChild ( $ textNode ) ; } else { $ found = false ; $ curChild = $ parentNode -> firstChild ; while ( $ curChild ) { if ( $ curChild -> nodeName == $ docIdXpath [ $ curLevel + 1 ] ) { CPS_Request :: _setDocId ( $ subdoc , $ curChild , $ id , $ docIdXpath , $ curLevel + 1 ) ; $ found = true ; break ; } $ curChild = $ curChild -> nextSibling ; } if ( ! $ found ) { $ newNode = $ subdoc -> createElement ( $ docIdXpath [ $ curLevel + 1 ] ) ; $ parentNode -> appendChild ( $ newNode ) ; CPS_Request :: _setDocId ( $ subdoc , $ newNode , $ id , $ docIdXpath , $ curLevel + 1 ) ; } } } else { throw new CPS_Exception ( array ( array ( 'long_message' => 'Document root xpath not matching document ID xpath' , 'code' => ERROR_CODE_INVALID_XPATHS , 'level' => 'REJECTED' , 'source' => 'CPS_API' ) ) ) ; } }
sets the docid inside the document
44,154
public function delete ( $ object ) { $ deleted = $ object -> delete ( ) ; if ( ! $ deleted ) { return new Payload ( $ object , 'not_deleted' ) ; } Cache :: tags ( $ this -> model -> getTable ( ) ) -> flush ( $ updated -> getKey ( ) ) ; return new Payload ( null , 'deleted' ) ; }
Delete the given Model
44,155
public function execute ( InputInterface $ input , OutputInterface $ output ) { $ outputPath = DATADIR ; $ output -> write ( [ '' , ' Generating install files...' , '' ] , true ) ; $ this -> dumpStructure ( $ outputPath ) ; $ output -> writeln ( ' Exported DB structure' ) ; $ this -> dumpData ( $ outputPath ) ; $ output -> write ( [ ' Exported DB data' , '' ] , true ) ; }
Execute this console command in order to generate install files
44,156
public function getDumpStructureCommand ( $ database , $ username , $ password , $ outputPath ) { return sprintf ( 'mysqldump %s -u %s -p%s --no-data | sed "s/AUTO_INCREMENT=[0-9]*//" > %s' , escapeshellarg ( $ database ) , escapeshellarg ( $ username ) , escapeshellarg ( $ password ) , escapeshellarg ( $ outputPath ) ) ; }
Return the mysqldump command for structure only
44,157
public function getDumpDataCommand ( $ database , $ username , $ password , $ outputPath , $ tables = array ( ) ) { $ tables = array_map ( 'escapeshellarg' , $ tables ) ; $ command = sprintf ( 'mysqldump %s %s -u %s -p%s --no-create-info > %s' , escapeshellarg ( $ database ) , implode ( ' ' , $ tables ) , escapeshellarg ( $ username ) , escapeshellarg ( $ password ) , escapeshellarg ( $ outputPath ) ) ; return $ command ; }
Return the mysqldump command for data only
44,158
protected function dumpStructure ( $ outputPath ) { return shell_exec ( $ this -> getDumpStructureCommand ( $ this -> dbConfig [ 'database' ] , $ this -> dbConfig [ 'username' ] , $ this -> dbConfig [ 'password' ] , $ outputPath . '/' . self :: STRUCTURE_FILE ) ) ; }
Export database structure to dbStructure install file
44,159
protected function dumpData ( $ outputPath ) { $ tables = Arr :: get ( $ this -> installConfig , 'dataTables' , [ ] ) ; if ( ! count ( $ tables ) ) { return ; } $ command = sprintf ( 'mysqldump %s %s -u %s -p%s --no-create-info > %s' , escapeshellarg ( $ this -> dbConfig [ 'database' ] ) , implode ( ' ' , $ tables ) , escapeshellarg ( $ this -> dbConfig [ 'username' ] ) , escapeshellarg ( $ this -> dbConfig [ 'password' ] ) , escapeshellarg ( $ outputPath . '/' . self :: DATA_FILE ) ) ; return shell_exec ( $ command ) ; }
Export database data to dbData install file
44,160
public function pushEvent ( $ collectionName , $ event ) { $ url = self :: BASE_API_URL . $ collectionName ; $ result = Request :: post ( $ url ) -> sendsAndExpectsType ( Mime :: JSON ) -> addHeaders ( [ 'X-Project-Id' => $ this -> projectId , 'X-Api-Key' => $ this -> apiKey ] ) -> body ( json_encode ( $ event ) ) -> send ( ) ; return $ this -> buildResponse ( $ event , $ result ) ; }
Push an event to the Connect API .
44,161
private function buildResponse ( $ event , $ response ) { $ success = ! $ response -> hasErrors ( ) ; $ duplicate = ( $ response -> code == 409 ) ; $ statusCode = $ response -> code ; $ errorMessage = null ; if ( $ response -> code == 401 ) { $ errorMessage = 'Unauthorised. Please check your Project Id and API Key' ; } if ( $ response -> body != null && $ response -> body -> errorMessage != null ) { $ errorMessage = $ response -> body -> errorMessage ; } return new Response ( $ success , $ duplicate , $ statusCode , $ errorMessage , $ event ) ; }
Build a single response to return to the user
44,162
private function buildBatchResponse ( $ batch , $ response ) { $ result = [ ] ; $ responseBody = json_decode ( $ response -> raw_body , true ) ; foreach ( $ batch as $ collection => $ events ) { $ eventResults = [ ] ; $ eventResponses = $ responseBody [ $ collection ] ; foreach ( $ events as $ index => $ event ) { $ eventResponse = $ eventResponses [ $ index ] ; $ eventResult = new Response ( $ eventResponse [ 'success' ] , $ eventResponse [ 'duplicate' ] , null , $ eventResponse [ 'message' ] , $ event ) ; array_push ( $ eventResults , $ eventResult ) ; } $ result [ $ collection ] = $ eventResults ; } $ statusCode = $ response -> code ; $ errorMessage = $ response -> body -> errorMessage ; return new ResponseBatch ( $ statusCode , $ errorMessage , $ result ) ; }
Build a batch of responses to return to the user
44,163
public function thenPathNamedShouldHaveTheFollowingResponse ( $ httpMethod , $ pathName , PyStringNode $ data ) { $ this -> thenIShouldHaveAPathNamed ( $ httpMethod , $ pathName ) ; $ operation = $ this -> extractPath ( $ httpMethod , $ pathName ) ; $ operationResponseSchemaList = $ operation [ 'responses' ] [ '200' ] [ 'schema' ] [ 'allOf' ] ; $ decodedExpected = $ this -> jsonDecode ( $ data -> getRaw ( ) ) ; Assert :: assertContains ( $ decodedExpected , $ operationResponseSchemaList ) ; }
Error and response result are stored under the same key
44,164
public function merge ( array $ newConfig , array & $ config ) { foreach ( $ newConfig as $ routeName => $ routeInfo ) { if ( ! isset ( $ config [ $ routeName ] ) ) { $ config [ $ routeName ] = $ this -> newRoute ( $ routeName , $ routeInfo ) ; } if ( isset ( $ routeInfo [ 'child_routes' ] ) ) { if ( ! isset ( $ config [ $ routeName ] [ 'child_routes' ] ) ) { $ config [ $ routeName ] [ 'child_routes' ] = array ( ) ; } $ this -> merge ( $ routeInfo [ 'child_routes' ] , $ config [ $ routeName ] [ 'child_routes' ] ) ; } } }
Recursively update the route stack .
44,165
public function get ( $ name , $ default = null ) { if ( ! str_contains ( $ name , '::' ) ) { throw new InvalidArgumentException ( "Setting key must be in the format '[module]::[setting]', '$name' given." ) ; } $ defaultFromConfig = $ this -> getDefaultFromConfigFor ( $ name ) ; if ( $ this -> setting -> has ( $ name ) ) { return $ this -> setting -> get ( $ name ) ; } return is_null ( $ default ) ? $ defaultFromConfig : $ default ; }
Getting the setting .
44,166
public function setFromRequest ( $ settings ) { $ this -> removeTokenKey ( $ settings ) ; foreach ( $ settings as $ settingName => $ settingValues ) { $ this -> set ( $ settingName , $ settingValues ) ; } }
Set multiple given configuration values from a request .
44,167
public function moduleConfig ( $ modules ) { if ( is_string ( $ modules ) ) { $ config = config ( 'society.' . strtolower ( $ modules ) . '.settings' ) ; return $ config ; } $ config = [ ] ; foreach ( $ modules as $ module ) { if ( $ moduleSettings = config ( 'society.' . strtolower ( $ module -> getName ( ) ) . '.settings' ) ) { $ config [ $ module -> getName ( ) ] = $ moduleSettings ; } } return $ config ; }
Return all modules that have settings with its settings .
44,168
private function getConfigFor ( $ name ) { list ( $ module , $ settingName ) = explode ( '::' , $ name ) ; $ result = [ ] ; foreach ( config ( "society.$module.settings" ) as $ sub ) { $ result = array_merge ( $ result , $ sub ) ; } return Arr :: get ( $ result , "$settingName" ) ; }
Get the settings configuration file .
44,169
public function find ( $ class , DataRequest $ dataRequest ) { try { $ dataRequest -> setSelectedFields ( array ( '*' ) ) ; $ queryBuilder = $ this -> entityManager -> getQueryBuilder ( ) ; $ this -> entityManager -> buildDataRequestQuery ( $ dataRequest , $ queryBuilder , $ class , 'a' ) ; $ accessEntities = $ queryBuilder -> getQuery ( ) -> getResult ( ) ; if ( $ accessEntities == null ) { return array ( ) ; } foreach ( $ accessEntities as $ accessEntity ) { $ this -> loadPermissions ( $ accessEntity ) ; } return $ accessEntities ; } catch ( \ Exception $ e ) { throw new Exception ( 'Cannot load the access entities for the given data request from the database.' , 0 , $ e ) ; } }
Returns an array with all found access entities for the given DataRequest object .
44,170
public function count ( $ class , DataRequest $ dataRequest ) { try { $ request = clone $ dataRequest ; $ request -> setPage ( 0 ) ; $ request -> setNumberOfEntries ( 0 ) ; $ queryBuilder = $ this -> entityManager -> getQueryBuilder ( ) ; $ this -> entityManager -> buildDataRequestQuery ( $ request , $ queryBuilder , $ class , 'a' ) ; $ queryBuilder -> select ( $ queryBuilder -> expr ( ) -> count ( 'a.id' ) ) ; $ data = $ queryBuilder -> getQuery ( ) ; if ( $ data === false ) { return 0 ; } return $ data -> getSingleScalarResult ( ) ; } catch ( \ Exception $ e ) { throw new Exception ( 'Cannot count the access entities for the given data request.' , 0 , $ e ) ; } }
Returns the number of all found access entities for the given DataRequest object .
44,171
public function has ( $ class , $ entityId ) { try { $ em = $ this -> entityManager -> getDoctrineEntityManager ( ) ; $ data = $ em -> getRepository ( $ class ) -> findOneBy ( array ( 'id' => $ entityId , ) ) ; if ( $ data !== null ) { return true ; } return false ; } catch ( \ Exception $ e ) { throw new Exception ( 'Cannot check if there is an access entitiy for the given class "' . $ class . '" and id "' . $ entityId . '".' , 0 , $ e ) ; } }
Returns true if the given entity id exists
44,172
public function get ( $ class , $ entityId ) { try { $ em = $ this -> entityManager -> getDoctrineEntityManager ( ) ; $ accessEntity = $ em -> getRepository ( $ class ) -> findOneBy ( array ( 'id' => $ entityId , ) ) ; if ( $ accessEntity !== null ) { $ this -> loadPermissions ( $ accessEntity ) ; return $ accessEntity ; } return false ; } catch ( \ Exception $ e ) { throw new Exception ( 'Cannot load the access entitiy for the given class "' . $ class . '" and id "' . $ entityId . '".' , 0 , $ e ) ; } }
Returns the entity for the given id . Returns false if there is no entity for the given id .
44,173
public function hasAccessEntityForUuid ( $ class , $ uuid ) { try { $ em = $ this -> entityManager -> getDoctrineEntityManager ( ) ; $ data = $ em -> getRepository ( $ class ) -> findOneBy ( array ( 'uuid' => $ uuid , ) ) ; if ( $ data !== null ) { return true ; } return false ; } catch ( \ Exception $ e ) { throw new Exception ( 'Cannot check if there is an access entitiy for the given uuid "' . $ uuid . '".' , 0 , $ e ) ; } }
Returns true if there is a access entity for the given uuid
44,174
public function hasAccessEntityForName ( $ class , $ name ) { try { $ em = $ this -> entityManager -> getDoctrineEntityManager ( ) ; $ data = $ em -> getRepository ( $ class ) -> findOneBy ( array ( 'name' => $ name , ) ) ; if ( $ data !== null ) { return true ; } return false ; } catch ( \ Exception $ e ) { throw new Exception ( 'Cannot check if there is an access entitiy for the given type "' . $ class . '" and name "' . $ name . '".' , 0 , $ e ) ; } }
Returns true if there is a access entity for the given type and name
44,175
public function getAccessEntityForUuid ( $ class , $ uuid ) { try { $ em = $ this -> entityManager -> getDoctrineEntityManager ( ) ; $ accessEntity = $ em -> getRepository ( $ class ) -> findOneBy ( array ( 'uuid' => $ uuid , ) ) ; if ( $ accessEntity !== null ) { $ this -> loadPermissions ( $ accessEntity ) ; return $ accessEntity ; } return false ; } catch ( \ Exception $ e ) { throw new Exception ( 'Cannot load the access entitiy from the database for the given uuid "' . $ uuid . '".' , 0 , $ e ) ; } }
Returns the access entity object for the given uuid
44,176
public function getAccessEntityForName ( $ class , $ name ) { try { $ em = $ this -> entityManager -> getDoctrineEntityManager ( ) ; $ accessEntity = $ em -> getRepository ( $ class ) -> findOneBy ( array ( 'name' => $ name , ) ) ; if ( $ accessEntity !== null ) { $ this -> loadPermissions ( $ accessEntity ) ; return $ accessEntity ; } return false ; } catch ( \ Exception $ e ) { throw new Exception ( 'Cannot load the access entitiy for the given class "' . $ class . '" and name "' . $ name . '".' , 0 , $ e ) ; } }
Returns the access entity object for the given type and name
44,177
public function addAccessEntity ( AccessEntity $ accessEntity ) { try { $ em = $ this -> entityManager -> getDoctrineEntityManager ( ) ; $ em -> persist ( $ accessEntity ) ; $ em -> flush ( ) ; return $ accessEntity -> getUuid ( ) ; } catch ( \ Exception $ e ) { throw new Exception ( 'Cannot add the new access entitiy "' . $ accessEntity -> getName ( ) . '".' , 0 , $ e ) ; } }
Adds an access entity . Returns the uuid of the access entity or false if the access entity can not inserted .
44,178
public function updateAccessEntity ( AccessEntity $ accessEntity ) { try { $ em = $ this -> entityManager -> getDoctrineEntityManager ( ) ; $ em -> flush ( ) ; return true ; } catch ( \ Exception $ e ) { throw new Exception ( 'Cannot update the access entitiy "' . $ accessEntity -> getUuid ( ) . '".' , 0 , $ e ) ; } }
Updates the access entity . Returns true if everything worked as excepted or false if the update didn t worked .
44,179
public function deleteAccessEntity ( AccessEntity $ accessEntity ) { try { $ em = $ this -> entityManager -> getDoctrineEntityManager ( ) ; $ em -> remove ( $ accessEntity ) ; $ em -> flush ( ) ; return true ; } catch ( \ Exception $ e ) { throw new Exception ( 'Cannot delete the access entitiy "' . $ uuid . '".' , 0 , $ e ) ; } }
Deletes the given access entity in the database .
44,180
protected function loadPermissions ( AccessEntity $ accessEntity ) { $ permissions = $ this -> permissionsDataSource -> getPermissionsForUuid ( $ accessEntity -> getUuid ( ) ) ; if ( $ permissions === false ) { return ; } $ accessEntity -> setPermissions ( $ permissions ) ; }
Loads the permissions for the given access entity object
44,181
public function set ( $ name , $ value ) { if ( isset ( $ this -> locked [ $ name ] ) ) { throw new LockedItemException ( $ name ) ; } $ this -> items [ $ name ] = $ value ; }
Sets a item by name .
44,182
public function get ( $ name ) { if ( ! $ this -> has ( $ name ) ) { throw new ItemNotFoundException ( $ name ) ; } return $ this -> items [ $ name ] ; }
Returns a item by name .
44,183
public function lock ( $ name ) { if ( ! $ this -> has ( $ name ) ) { throw new ItemNotFoundException ( $ name ) ; } $ this -> locked [ $ name ] = true ; return $ this ; }
Locks an item .
44,184
public function unlock ( $ name ) { if ( ! $ this -> has ( $ name ) ) { throw new ItemNotFoundException ( $ name ) ; } unset ( $ this -> locked [ $ name ] ) ; return $ this ; }
Unlocks an item .
44,185
public function isLocked ( $ name ) { if ( ! $ this -> has ( $ name ) ) { throw new ItemNotFoundException ( $ name ) ; } return isset ( $ this -> locked [ $ name ] ) ; }
Returns true if the item is locked .
44,186
public function init ( ) { parent :: init ( ) ; $ id = $ this -> getRandomId ( ) ; $ view = $ this -> getView ( ) ; TinymceAsset :: register ( $ view ) ; TinymceLanguageAsset :: register ( $ view ) ; $ view -> registerJs ( "tinymce.init({selector:'#$id',plugins:'$this->plugins',font_formats:'$this->font_formats',fontsize_formats:'$this->fontsize_formats',autosave_ask_before_unload:false,preview_styles:false,toolbar:'$this->toolbar'});" ) ; }
newdocument strikethrough cut copy paste blockquote removeformat subscript superscript
44,187
public function sort ( ) { if ( ! $ this -> request -> is ( 'ajax' ) || ! $ this -> request -> is ( 'post' ) ) { throw new MethodNotAllowedException ( ) ; } if ( empty ( $ this -> request -> data ) ) { throw new BadRequestException ( ) ; } $ languages = $ this -> Languages -> patchEntities ( $ this -> Languages -> find ( 'allFrontendBackend' ) , $ this -> request -> data ) ; $ connection = $ this -> Languages -> connection ( ) ; $ connection -> begin ( ) ; foreach ( $ languages as $ language ) { if ( ! $ this -> Languages -> save ( $ language ) ) { $ connection -> rollback ( ) ; break ; } } if ( $ connection -> inTransaction ( ) ) { $ connection -> commit ( ) ; $ status = 'success' ; $ flashMessage = __d ( 'wasabi_core' , 'The language position has been updated.' ) ; } else { $ status = 'error' ; $ flashMessage = $ this -> dbErrorMessage ; } $ frontendLanguages = $ this -> Languages -> filterFrontend ( new Collection ( $ languages ) ) -> sortBy ( 'position' , SORT_ASC , SORT_NUMERIC ) -> toList ( ) ; $ backendLanguages = $ this -> Languages -> filterBackend ( new Collection ( $ languages ) ) -> sortBy ( 'position' , SORT_ASC , SORT_NUMERIC ) -> toList ( ) ; $ this -> set ( compact ( 'status' , 'flashMessage' , 'frontendLanguages' , 'backendLanguages' ) ) ; $ this -> set ( '_serialize' , [ 'status' , 'flashMessage' , 'frontendLanguages' , 'backendLanguages' ] ) ; $ this -> RequestHandler -> renderAs ( $ this , 'json' ) ; }
Sort action AJAX POST
44,188
public function change ( $ id = null ) { if ( $ id === null || ! $ this -> Languages -> exists ( [ 'id' => $ id ] ) ) { $ this -> Flash -> error ( $ this -> invalidRequestMessage ) ; $ this -> redirect ( $ this -> referer ( ) ) ; return ; } $ this -> request -> session ( ) -> write ( 'contentLanguageId' , ( int ) $ id ) ; $ this -> redirect ( $ this -> referer ( ) ) ; }
Change action GET
44,189
public function getTemplateAccessors ( ) { if ( $ this -> templateAccessors ) return $ this -> templateAccessors ; $ vars = parent :: getTemplateAccessors ( ) ; $ cc = new ReflectionClass ( 'ContentController' ) ; $ site_tree = new ReflectionClass ( 'SiteTree' ) ; $ hierarchy = new ReflectionClass ( 'Hierarchy' ) ; $ methods = array_merge ( $ site_tree -> getMethods ( ) , $ cc -> getMethods ( ) , $ hierarchy -> getMethods ( ) , array_keys ( singleton ( 'SiteTree' ) -> has_many ( ) ) , array_keys ( singleton ( 'SiteTree' ) -> many_many ( ) ) , array_keys ( singleton ( 'SiteTree' ) -> db ( ) ) , array_keys ( DataObject :: config ( ) -> fixed_fields ) ) ; foreach ( $ methods as $ m ) { $ name = is_object ( $ m ) ? $ m -> getName ( ) : $ m ; if ( preg_match ( "/[A-Z]/" , $ name [ 0 ] ) ) { $ vars [ ] = $ name ; } } $ vars [ ] = "Form" ; return $ this -> templateAccessors = $ vars ; }
Gets all the core template accessors available to SiteTree templates and caches the result
44,190
final protected function generateUrl ( string $ name , array $ params = [ ] ) : string { return $ this -> urlGenerator -> generate ( $ name , $ params ) ; }
Generate a URL by the given name and params
44,191
public function replace_child ( Node $ what , $ with ) { $ replace_key = array_search ( $ what , $ this -> children ) ; if ( $ replace_key === false ) return false ; if ( is_array ( $ with ) ) foreach ( $ with as $ child ) $ child -> set_parent ( $ this ) ; array_splice ( $ this -> children , $ replace_key , 1 , $ with ) ; return true ; }
Replaces a child node
44,192
public function remove_child ( Node $ child ) { $ key = array_search ( $ what , $ this -> children ) ; if ( $ key === false ) return false ; $ this -> children [ $ key ] -> set_parent ( ) ; unset ( $ this -> children [ $ key ] ) ; return true ; }
Removes a child fromthe node
44,193
public function last_tag_node ( ) { $ children_len = count ( $ this -> children ) ; for ( $ i = $ children_len - 1 ; $ i >= 0 ; $ i -- ) if ( $ this -> children [ $ i ] instanceof Node_Container_Tag ) return $ this -> children [ $ i ] ; return null ; }
Gets the last child of type Node_Container_Tag .
44,194
public function get_html ( $ nl2br = true , $ htmlEntities = true ) { $ html = '' ; foreach ( $ this -> children as $ child ) $ html .= $ child -> get_html ( $ nl2br , $ htmlEntities ) ; if ( $ this instanceof Node_Container_Document ) return $ html ; $ bbcode = $ this -> root ( ) -> get_bbcode ( $ this -> tag ) ; if ( is_callable ( $ bbcode -> handler ( ) ) && ( $ func = $ bbcode -> handler ( ) ) !== false ) return $ func ( $ html , $ this -> attribs , $ this ) ; return str_replace ( '%content%' , $ html , $ bbcode -> handler ( ) ) ; }
Gets a HTML representation of this node
44,195
public function get_text ( ) { $ text = '' ; foreach ( $ this -> children as $ child ) $ text .= $ child -> get_text ( ) ; return $ text ; }
Gets the raw text content of this node and it s children .
44,196
function edit_field ( ) { global $ mf_domain ; $ data = $ this -> fields_form ( ) ; $ field = $ this -> get_custom_field ( $ _GET [ 'custom_field_id' ] ) ; if ( ! $ field ) { $ this -> mf_flash ( 'error' ) ; } else { $ no_set = array ( 'options' , 'active' , 'display_order' ) ; foreach ( $ field as $ k => $ v ) { if ( ! in_array ( $ k , $ no_set ) ) { $ data [ 'core' ] [ $ k ] [ 'value' ] = $ v ; } } $ data [ 'option' ] = unserialize ( $ field [ 'options' ] ) ; } $ this -> form_custom_field ( $ data ) ; ?> <?php }
Page for edit a custom field
44,197
function get_custom_fields_name ( ) { $ path = MF_PATH . '/field_types/*' ; $ folders = glob ( $ path , GLOB_ONLYDIR ) ; $ fields = array ( ) ; foreach ( $ folders as $ folder ) { $ name = preg_match ( '/\/([\w\_]+)\_field$/i' , $ folder , $ name_match ) ; $ fields [ $ name_match [ 1 ] ] = preg_replace ( '/_/' , ' ' , $ name_match [ 1 ] ) ; } return $ fields ; }
Get the list of custom fields
44,198
public static function save_order_field ( $ group_id , $ order ) { global $ wpdb ; if ( ! is_numeric ( $ group_id ) ) { return false ; } foreach ( $ order as $ key => $ value ) { $ update = $ wpdb -> update ( MF_TABLE_CUSTOM_FIELDS , array ( 'display_order' => $ key ) , array ( 'custom_group_id' => $ group_id , 'id' => $ value ) , array ( '%d' ) , array ( '%d' , '%d' ) ) ; if ( $ update === false ) { return $ update ; } } return true ; }
Save the order of the custom fields
44,199
public static function has_fields ( $ post_type_name ) { global $ wpdb ; $ sql = $ wpdb -> prepare ( "SELECT COUNT(1) FROM " . MF_TABLE_CUSTOM_FIELDS . " WHERE post_type = %s" , $ post_type_name ) ; return $ wpdb -> get_var ( $ sql ) > 0 ; }
Return True if the post type has at least one custom field