idx
int64 0
60.3k
| question
stringlengths 64
4.24k
| target
stringlengths 5
618
|
|---|---|---|
8,300
|
private function getReflection ( string $ className ) : \ ReflectionClass { if ( empty ( $ this -> reflectionContainer [ $ className ] ) ) { $ this -> reflectionContainer [ $ className ] = new \ ReflectionClass ( $ className ) ; } return $ this -> reflectionContainer [ $ className ] ; }
|
Retrieve reflection .
|
8,301
|
public function getEntry ( $ language , $ entryId ) { if ( isset ( $ this -> entries [ $ language ] ) && isset ( $ this -> entries [ $ language ] [ $ entryId ] ) ) { return $ this -> entries [ $ language ] [ $ entryId ] ; } return null ; }
|
Get the translatable entry
|
8,302
|
public function setEntry ( $ language , $ entryId , $ entryValue ) { $ language = ( string ) $ language ; $ entryId = ( string ) $ entryId ; $ entryValue = ( string ) $ entryValue ; if ( ! isset ( $ this -> entries [ $ language ] ) && $ entryValue ) { $ this -> entries [ $ language ] = array ( ) ; } if ( $ entryValue ) { $ this -> entries [ $ language ] [ $ entryId ] = $ entryValue ; } else { if ( isset ( $ this -> entries [ $ language ] [ $ entryId ] ) ) { unset ( $ this -> entries [ $ language ] [ $ entryId ] ) ; } } return $ this ; }
|
Set the translatable entry for the specific language
|
8,303
|
public function removeEntry ( $ entryId , $ language = null ) { $ entryId = ( string ) $ entryId ; foreach ( $ this -> entries as $ languageKey => $ entries ) { if ( $ language && $ language !== $ languageKey ) { continue ; } if ( isset ( $ this -> entries [ $ languageKey ] [ $ entryId ] ) ) { unset ( $ this -> entries [ $ languageKey ] [ $ entryId ] ) ; } } return $ this ; }
|
Remove entries of the given id
|
8,304
|
public function removeLanguage ( $ language ) { $ language = ( string ) $ language ; if ( isset ( $ this -> entries [ $ language ] ) ) { unset ( $ this -> entries [ $ language ] ) ; } return $ this ; }
|
Remove entries of the given language
|
8,305
|
public function render ( \ DOMDocument $ domDocument ) { $ domElement = $ domDocument -> createElement ( "dico" ) ; foreach ( $ this -> entries as $ language => $ entries ) { $ languageElement = $ domDocument -> createElement ( "language" ) ; $ languageElement -> setAttribute ( "id" , $ language ) ; foreach ( $ entries as $ entryId => $ entryValue ) { $ entryElement = $ domDocument -> createElement ( $ entryId , $ entryValue ) ; $ languageElement -> appendChild ( $ entryElement ) ; } $ domElement -> appendChild ( $ languageElement ) ; } return $ domElement ; }
|
Render the Dico
|
8,306
|
public static function create ( $ host , $ port , $ password ) { $ factory = new \ Socket \ Raw \ Factory ( ) ; $ socket = $ factory -> createClient ( sprintf ( '%s:%s' , $ host , $ port ) ) ; return new \ gries \ Rcon \ Connection ( $ socket , $ password ) ; }
|
Create a new RconConnection
|
8,307
|
function getLoginURL ( $ scope = null , $ redirectURI = null ) { $ redirectURI = $ redirectURI ? : $ this -> getCurrentURI ( ) ; self :: $ persistance -> setVariable ( 'redirect_uri' , $ redirectURI ) ; return $ this -> getAuthorizationURL ( $ redirectURI , $ scope ) ; }
|
When a user is not authentified you need to create a link to the URL returned by this method .
|
8,308
|
function getLogoutURL ( $ redirectURI = null ) { $ redirectURI = $ redirectURI ? : $ this -> getCurrentURI ( ) ; return $ this -> logoutURL . '?' . http_build_query ( array ( 'redirect_uri' => $ redirectURI ) , '' , '&' ) ; }
|
If you want to place a logout button you can use this link to log the user out of the player page too . Don t forget to empty your sessions .
|
8,309
|
protected function getAccessToken ( ) { $ token = self :: $ persistance -> getVariable ( 'token' ) ; if ( ! $ this -> isAccessTokenExpired ( $ token ) ) { return $ token -> access_token ; } else if ( $ token !== null && $ token -> refresh_token !== null ) { $ token = $ this -> getTokenFromRefreshToken ( $ token -> refresh_token ) ; return $ token -> access_token ; } if ( isset ( $ _REQUEST [ 'code' ] ) ) { $ code = $ _REQUEST [ 'code' ] ; if ( $ code ) { $ redirectURI = self :: $ persistance -> getVariable ( 'redirect_uri' ) ? : $ this -> getCurrentURI ( ) ; $ token = $ this -> getTokenFromCode ( $ code , $ redirectURI ) ; self :: $ persistance -> deleteVariable ( 'redirect_uri' ) ; self :: $ persistance -> deleteVariable ( 'code' ) ; return $ token -> access_token ; } } }
|
Tries to get an access token . If one is found in the session it returns it . If a code is found in the request it tries to exchange it for an access token on the OAuth2 Token Endpoint Else it returns false
|
8,310
|
public function all ( OutputInterface $ output , array $ response ) { $ this -> printTable ( $ output , [ 'Key' , 'Name' , 'Type' , 'Public' , 'Dependencies' , 'Outdated' , 'Updated At' , 'Bad Licenses' , 'Unknown Licenses' ] , [ 'ids' , 'name' , 'project_type' , 'public' , 'dep_number' , 'out_number' , 'updated_at' , 'licenses_red' , 'licenses_unknown' ] , $ response , function ( $ key , $ value ) use ( $ output ) { if ( 'public' === $ key ) { return $ value === 1 ? 'Yes' : 'No' ; } if ( ! in_array ( $ key , [ 'out_number' , 'licenses_red' , 'licenses_unknown' ] , true ) ) { return $ value ; } return $ this -> printBoolean ( $ output , $ value > 0 ? $ value : 'No' , $ value , ! $ value , false ) ; } ) ; }
|
output for projects API .
|
8,311
|
public function licenses ( OutputInterface $ output , array $ response ) { $ table = $ this -> createTable ( $ output ) ; $ table -> setHeaders ( [ 'license' , 'name' ] ) ; foreach ( $ response [ 'licenses' ] as $ license => $ projects ) { foreach ( $ projects as $ project ) { $ name = $ license === 'unknown' ? '<error>' . $ project [ 'name' ] . '</error>' : $ project [ 'name' ] ; $ license = $ license === 'unknown' ? '<error>unknown</error>' : $ license ; $ table -> addRow ( [ $ license , $ name ] ) ; } } $ table -> render ( $ output ) ; }
|
output for licenses API .
|
8,312
|
protected function executeInTransaction ( string $ method ) : void { try { $ this -> database -> beginTransaction ( ) ; $ this -> { $ method } ( ) ; $ this -> database -> commit ( ) ; } catch ( Exception $ exception ) { $ this -> database -> rollBack ( ) ; $ this -> handleException ( $ exception ) ; } }
|
Execute the migration command inside a transaction layer .
|
8,313
|
public function getElement ( $ using , $ value ) { try { $ results = $ this -> curl ( 'POST' , '/element' , array ( 'using' => $ using , 'value' => $ value ) ) ; } catch ( E5xx_NoSuchElementWebDriverError $ e ) { throw new E5xx_NoSuchElementWebDriverError ( 500 , sprintf ( 'Element not found with %s, %s' , $ using , $ value ) . "\n\n" . $ e -> getMessage ( ) , $ e -> getResults ( ) ) ; } return $ this -> newWebDriverElement ( $ results [ 'value' ] ) ; }
|
retrieve an element from the currently loaded page
|
8,314
|
public function getElements ( $ using , $ value ) { try { $ results = $ this -> curl ( 'POST' , '/elements' , array ( 'using' => $ using , 'value' => $ value ) ) ; } catch ( E5xx_NoSuchElementWebDriverError $ e ) { throw new E5xx_NoSuchElementWebDriverError ( sprintf ( 'Element not found with %s, %s' , $ using , $ value ) . "\n\n" . $ e -> getMessage ( ) , $ e -> getResults ( ) ) ; } return array_filter ( array_map ( array ( $ this , 'newWebDriverElement' ) , $ results [ 'value' ] ) ) ; }
|
Find all occurances of an element on the current page
|
8,315
|
protected function newWebDriverElement ( $ value ) { if ( ! array_key_exists ( 'ELEMENT' , ( array ) $ value ) ) { return null ; } return new WebDriverElement ( $ this -> getElementPath ( $ value [ 'ELEMENT' ] ) , $ value [ 'ELEMENT' ] ) ; }
|
helper method to wrap an element inside the WebDriverElement object
|
8,316
|
public function schema ( $ key = null , $ value = null ) { $ numArgs = func_num_args ( ) ; if ( 0 === $ numArgs ) { return $ this -> schema ; } elseif ( 1 === $ numArgs ) { if ( is_array ( $ key ) ) { $ this -> schema = new NObject ( $ key ) ; } elseif ( $ this -> schema -> offsetExists ( $ key ) ) { return $ this -> schema [ $ key ] ; } } else { $ this -> schema [ $ key ] = $ value ; } }
|
Getter and setter of collection schema . If there is no argument specified the method will set and override schema . If argument specified method will act as getter to specific field schema .
|
8,317
|
public function prepare ( $ key , $ value , $ schema = null ) { if ( is_null ( $ schema ) ) { $ schema = $ this -> schema ( $ key ) ; if ( is_null ( $ schema ) ) { return $ value ; } } return $ schema -> prepare ( $ value ) ; }
|
Prepare data value for specific field name
|
8,318
|
public function attach ( $ document ) { if ( isset ( $ this -> connection ) ) { $ document = $ this -> connection -> unmarshall ( $ document ) ; } $ document = new NObject ( $ document ) ; $ this -> applyHook ( 'attaching' , $ document ) ; if ( isset ( $ this -> options [ 'model' ] ) ) { $ Model = $ this -> options [ 'model' ] ; $ model = new $ Model ( $ document -> toArray ( ) , array ( 'collection' => $ this , ) ) ; } else { $ model = new Model ( $ document -> toArray ( ) , array ( 'collection' => $ this , ) ) ; } $ this -> applyHook ( 'attached' , $ model ) ; return $ model ; }
|
Attach document to Norm system as model .
|
8,319
|
public function find ( $ criteria = array ( ) ) { if ( ! is_array ( $ criteria ) ) { $ criteria = array ( '$id' => $ criteria , ) ; } $ criteria = new NObject ( $ criteria ) ; $ this -> applyHook ( 'searching' , $ criteria ) ; $ cursor = $ this -> connection -> query ( $ this , $ criteria -> toArray ( ) ) ; $ this -> applyHook ( 'searched' , $ cursor ) ; return $ cursor ; }
|
Find data with specified criteria
|
8,320
|
public function findOne ( $ criteria = array ( ) ) { $ model = $ this -> fetchCache ( $ criteria ) ; if ( is_null ( $ model ) ) { $ cursor = $ this -> find ( $ criteria ) ; $ model = $ cursor -> getNext ( ) ; $ this -> rememberCache ( $ criteria , $ model ) ; } return $ model ; }
|
Find one document from collection
|
8,321
|
public function newInstance ( $ cloned = array ( ) ) { if ( $ cloned instanceof Model ) { $ cloned = $ cloned -> toArray ( Model :: FETCH_PUBLISHED ) ; } if ( isset ( $ this -> options [ 'model' ] ) ) { $ Model = $ this -> options [ 'model' ] ; return new $ Model ( $ cloned , array ( 'collection' => $ this ) ) ; } else { return new Model ( $ cloned , array ( 'collection' => $ this ) ) ; } }
|
Create new instance of model
|
8,322
|
public function filter ( Model $ model , $ key = null ) { if ( is_null ( $ this -> filter ) ) { $ this -> filter = Filter :: fromSchema ( $ this -> schema ( ) ) ; } $ this -> applyHook ( 'filtering' , $ model , $ key ) ; $ result = $ this -> filter -> run ( $ model , $ key ) ; $ this -> applyHook ( 'filtered' , $ model , $ key ) ; return $ result ; }
|
Filter model data with functions to cleanse prepare and validate data . When key argument specified filter will run partially for specified key only .
|
8,323
|
public function save ( Model $ model , $ options = array ( ) ) { $ options = array_merge ( array ( 'filter' => true , 'observer' => true , ) , $ options ) ; if ( $ options [ 'filter' ] ) { $ this -> filter ( $ model ) ; } if ( $ options [ 'observer' ] ) { $ this -> applyHook ( 'saving' , $ model , $ options ) ; } $ modified = $ this -> connection -> persist ( $ this , $ model -> dump ( ) ) ; $ model -> setId ( $ modified [ '$id' ] ) ; if ( $ options [ 'observer' ] ) { $ this -> applyHook ( 'saved' , $ model , $ options ) ; } $ model -> sync ( $ modified ) ; $ this -> resetCache ( ) ; }
|
Save model to persistent state
|
8,324
|
public function remove ( Model $ model = null ) { if ( func_num_args ( ) === 0 ) { $ this -> connection -> remove ( $ this ) ; } else { if ( is_null ( $ model ) ) { throw new \ Exception ( '[Norm/Collection] Cannot remove null model' ) ; } $ this -> applyHook ( 'removing' , $ model ) ; $ result = $ this -> connection -> remove ( $ this , $ model ) ; if ( $ result ) { $ model -> reset ( ) ; } $ this -> applyHook ( 'removed' , $ model ) ; } }
|
Remove single model
|
8,325
|
protected function rememberCache ( $ criteria , $ model ) { $ ser = serialize ( $ criteria ) ; $ this -> cache [ $ ser ] = $ model ; }
|
Put item in cache bags .
|
8,326
|
protected function fetchCache ( $ criteria ) { $ ser = serialize ( $ criteria ) ; if ( isset ( $ this -> cache [ $ ser ] ) ) { return $ this -> cache [ $ ser ] ; } }
|
Get item from cache .
|
8,327
|
public static function add ( $ type , $ data = [ ] , $ function = 0 , $ styles = 0 , $ scripts = 0 ) { if ( ! is_admin ( ) || ! self :: required_params_exist ( $ type , $ data ) ) { return false ; } $ data = self :: set_params ( $ data , $ function , $ styles , $ scripts ) ; $ slug = $ data [ 'slug' ] ; self :: $ data [ $ type ] [ $ slug ] = $ data ; add_action ( 'admin_menu' , function ( ) use ( $ type , $ slug ) { self :: set ( $ type , $ slug ) ; } ) ; return true ; }
|
Add menu or submenu .
|
8,328
|
private static function required_params_exist ( $ type , $ data ) { $ required = [ 'name' , 'slug' ] ; if ( 'submenu' === $ type ) { array_push ( $ required , 'parent' ) ; } foreach ( $ required as $ field ) { if ( ! isset ( $ data [ $ field ] ) || empty ( $ data [ $ field ] ) ) { return false ; } } return true ; }
|
Validate if the required parameters exist .
|
8,329
|
private static function set ( $ type , $ slug ) { global $ pagenow ; $ data = self :: $ data [ $ type ] [ $ slug ] ; do_action ( 'wp_menu_pre_add_' . $ type . '_page' ) ; if ( 'menu' === $ type ) { $ page = add_menu_page ( $ data [ 'title' ] , $ data [ 'name' ] , $ data [ 'capability' ] , $ data [ 'slug' ] , $ data [ 'function' ] , $ data [ 'icon_url' ] , $ data [ 'position' ] ) ; } elseif ( 'submenu' === $ type ) { $ page = add_submenu_page ( $ data [ 'parent' ] , $ data [ 'title' ] , $ data [ 'name' ] , $ data [ 'capability' ] , $ data [ 'slug' ] , $ data [ 'function' ] ) ; } do_action ( 'wp_menu_after_add_' . $ type . '_page' , 'load-' . $ page ) ; if ( ! $ pagenow || 'admin.php' === $ pagenow ) { self :: set_action ( $ page , $ data [ 'styles' ] ) ; self :: set_action ( $ page , $ data [ 'scripts' ] ) ; } }
|
Set menu and submenu admin .
|
8,330
|
private static function validate_method ( $ method ) { if ( $ method && isset ( $ method [ 0 ] ) && isset ( $ method [ 1 ] ) ) { if ( method_exists ( $ method [ 0 ] , $ method [ 1 ] ) ) { return true ; } } return false ; }
|
Check if method exists .
|
8,331
|
private function getVarsWithoutCircularReferences ( $ showNulls , & $ previousDTOs = [ ] ) { $ previousDTOs [ spl_object_hash ( $ this ) ] = true ; $ classProperties = $ this -> reflection -> getProperties ( \ ReflectionProperty :: IS_PROTECTED ) ; $ vars = array ( ) ; foreach ( $ classProperties as $ property ) { if ( ! isset ( $ this -> { $ property -> name } ) ) { $ var = null ; } else if ( $ this -> { $ property -> name } instanceof DTO ) { if ( ! isset ( $ previousDTOs [ spl_object_hash ( $ this -> { $ property -> name } ) ] ) ) { $ var = $ this -> { $ property -> name } -> getVarsWithoutCircularReferences ( $ showNulls , $ previousDTOs ) ; } } else if ( is_array ( $ this -> { $ property -> name } ) && count ( $ this -> { $ property -> name } ) > 0 && $ this -> { $ property -> name } [ 0 ] instanceof DTO ) { $ var = array ( ) ; foreach ( $ this -> { $ property -> name } as $ i => $ v ) { if ( ! isset ( $ previousDTOs [ spl_object_hash ( $ v ) ] ) ) { $ var [ $ i ] = $ v -> getVarsWithoutCircularReferences ( $ showNulls , $ previousDTOs ) ; } } } else if ( is_object ( $ this -> { $ property -> name } ) && method_exists ( $ this -> { $ property -> name } , '__toString' ) ) { $ var = ( string ) $ this -> { $ property -> name } ; } else { $ var = $ this -> { $ property -> name } ; } if ( $ showNulls || ( $ var !== null && ( ! is_array ( $ var ) || count ( $ var ) > 0 ) ) ) { $ vars [ $ this -> camelToUnderscore ( $ property -> name ) ] = $ var ; } } return $ vars ; }
|
Export protected class parameters as an associative array .
|
8,332
|
public function getDefaultRedis ( ) : ? Connection { $ factory = Redis :: getFacadeRoot ( ) ; if ( isset ( $ factory ) ) { return $ factory -> connection ( ) ; } return $ factory ; }
|
Get a default redis value if any is available
|
8,333
|
public static function check ( Identifiable $ element ) { $ elementId = $ element -> getId ( ) ; if ( ! $ elementId ) { $ element -> setId ( new static ( ) ) ; return $ element -> getId ( ) ; } $ dangerousCharacters = array ( ' ' , '|' , PHP_EOL ) ; $ danger = false ; foreach ( $ dangerousCharacters as $ dangerousCharacter ) { if ( stripos ( $ elementId , $ dangerousCharacter ) !== false ) { $ danger = true ; break ; } } if ( $ danger ) { trigger_error ( "Don't use special characters in IDs, they might cause problems! Stripping them for you..." ) ; $ elementId = str_ireplace ( $ dangerousCharacters , '' , $ elementId ) ; $ element -> setId ( $ elementId ) ; } return $ element -> getId ( ) ; }
|
Check and return the Id of an Identifable Element
|
8,334
|
public function is ( $ characteristic ) { switch ( strtolower ( $ characteristic ) ) { case "ajax" : return ( isset ( $ this -> _env [ 'HTTP_X_REQUESTED_WITH' ] ) && $ this -> _env [ 'HTTP_X_REQUESTED_WITH' ] == "XMLHttpRequest" ) ; case "delete" : return ( $ this -> method == "DELETE" ) ; case "flash" : return ( $ this -> _env [ 'HTTP_USER_AGENT' ] == "Shockwave Flash" ) ; case "get" : return ( $ this -> method == "GET" ) ; case "head" : return ( $ this -> method == "HEAD" ) ; case "mobile" : $ mobile_user_agents = array ( "Android" , "AvantGo" , "Blackberry" , "DoCoMo" , "iPod" , "iPhone" , "J2ME" , "NetFront" , "Nokia" , "MIDP" , "Opera Mini" , "PalmOS" , "PalmSource" , "Plucker" , "portalmmm" , "ReqwirelessWeb" , "SonyEricsson" , "Symbian" , "UP\.Browser" , "Windows CE" , "Xiino" ) ; $ pattern = "/" . implode ( "|" , $ mobile_user_agents ) . "/i" ; return ( boolean ) preg_match ( $ pattern , $ this -> _env [ 'HTTP_USER_AGENT' ] ) ; case "options" : return ( $ this -> method == "OPTIONS" ) ; case "post" : return ( $ this -> method == "POST" ) ; case "put" : return ( $ this -> method == "PUT" ) ; case "ssl" : return $ this -> _env [ 'HTTPS' ] ; default : return false ; } }
|
Checks for request characteristics .
|
8,335
|
protected function parseUrl ( $ url = "" ) { $ parsed = ( $ url ) ? parse_url ( $ url ) : parse_url ( $ this -> _env [ 'REQUEST_URI' ] ) ; if ( preg_match ( '/[a-zA-Z0-9_]+\.php/i' , $ parsed [ 'path' ] , $ matches ) ) { $ parsed [ 'path' ] = preg_replace ( "/$matches[0]/" , '/' , $ parsed [ 'path' ] ) ; } return $ parsed ; }
|
Get parsed url
|
8,336
|
public function setControl ( Control $ control ) { $ control -> checkId ( ) ; $ control -> addScriptFeature ( $ this ) ; $ this -> control = $ control ; $ this -> updateScriptEvents ( ) ; return $ this ; }
|
Set the Control
|
8,337
|
protected function updateScriptEvents ( ) { if ( ! $ this -> control || ! ScriptLabel :: isEventLabel ( $ this -> labelName ) ) { return $ this ; } if ( $ this -> control instanceof Scriptable ) { $ this -> control -> setScriptEvents ( true ) ; } return $ this ; }
|
Enable Script Events on the Control if needed
|
8,338
|
protected function buildScriptText ( ) { $ controlId = Builder :: escapeText ( $ this -> control -> getId ( ) ) ; $ scriptText = '' ; $ closeBlock = false ; if ( ScriptLabel :: isEventLabel ( $ this -> labelName ) ) { $ scriptText .= "if (Event.ControlId == {$controlId}) {declare Control <=> Event.Control;" ; $ closeBlock = true ; } else { $ scriptText .= "declare Control <=> Page.GetFirstChild({$controlId});" ; } $ class = $ this -> control -> getManiaScriptClass ( ) ; $ name = preg_replace ( '/^CMl/' , '' , $ class , 1 ) ; $ scriptText .= "declare {$name} <=> (Control as {$class});" ; $ scriptText .= $ this -> scriptText . "" ; if ( $ closeBlock ) { $ scriptText .= "}" ; } return $ scriptText ; }
|
Build the script text for the Control
|
8,339
|
public function getCachePath ( ) : string { $ path = $ this -> getRuntimePath ( ) . DIRECTORY_SEPARATOR . 'cache' ; FileHelper :: createDirectory ( $ path ) ; return $ path ; }
|
Returns the path to the file cache directory .
|
8,340
|
public function api ( $ name ) { $ this -> initializeClient ( $ this -> url , $ this -> client ) ; $ class = 'Rs\\VersionEye\\Api\\' . ucfirst ( $ name ) ; if ( class_exists ( $ class ) ) { return new $ class ( $ this -> client ) ; } else { throw new \ InvalidArgumentException ( 'unknown api "' . $ name . '" requested' ) ; } }
|
returns an api .
|
8,341
|
private function initializeClient ( $ url , HttpClient $ client = null ) { if ( $ client ) { return $ this -> client = $ client ; } return $ this -> client = $ this -> createDefaultHttpClient ( $ url ) ; }
|
initializes the http client .
|
8,342
|
private static function generateVersion ( $ namespace , $ name , $ version ) { if ( ! self :: isValid ( $ namespace ) ) { return false ; } $ nhex = str_replace ( array ( '-' , '{' , '}' ) , '' , $ namespace ) ; $ nstr = '' ; $ len = strlen ( $ nhex ) ; for ( $ i = 0 ; $ i < $ len ; $ i += 2 ) { $ nstr .= chr ( hexdec ( $ nhex [ $ i ] . $ nhex [ $ i + 1 ] ) ) ; } if ( $ version == 3 ) { $ hash = md5 ( $ nstr . $ name ) ; $ digit = 0x3000 ; } else { $ hash = sha1 ( $ nstr . $ name ) ; $ digit = 0x5000 ; } return sprintf ( '%08s-%04s-%04x-%04x-%12s' , substr ( $ hash , 0 , 8 ) , substr ( $ hash , 8 , 4 ) , ( hexdec ( substr ( $ hash , 12 , 4 ) ) & 0x0fff ) | $ digit , ( hexdec ( substr ( $ hash , 16 , 4 ) ) & 0x3fff ) | 0x8000 , substr ( $ hash , 20 , 12 ) ) ; }
|
Generates v3 or v5 UUIDs .
|
8,343
|
public function addDirectory ( $ directory ) { $ directories = $ this -> getDirectory ( true ) ; if ( is_string ( $ directory ) ) { $ directory = explode ( ',' , $ directory ) ; } else if ( ! is_array ( $ directory ) ) { require_once 'Zend/Validate/Exception.php' ; throw new Zend_Validate_Exception ( 'Invalid options to validator provided' ) ; } foreach ( $ directory as $ content ) { if ( empty ( $ content ) || ! is_string ( $ content ) ) { continue ; } $ directories [ ] = trim ( $ content ) ; } $ directories = array_unique ( $ directories ) ; foreach ( $ directories as $ key => $ dir ) { if ( empty ( $ dir ) ) { unset ( $ directories [ $ key ] ) ; } } $ this -> _directory = implode ( ',' , $ directories ) ; return $ this ; }
|
Adds the file directory which will be checked
|
8,344
|
protected function updateCode ( ) : array { $ output = [ ] ; $ returnValue = 0 ; $ updateMaster = 'ls' ; if ( $ this -> getBranch ( ) !== 'master' ) { $ updateMaster = ' git checkout master && git pull && git checkout ' . $ this -> getBranch ( ) . ' ' ; } $ commands = [ 'git reset --hard HEAD' , 'git pull' , $ updateMaster , 'composer install --no-dev' , 'yarn install --production' , ] ; foreach ( $ commands as $ command ) { exec ( 'cd ' . $ this -> getBasepath ( ) . ' && ' . $ command , $ output , $ returnValue ) ; } return [ 'output' => $ output , 'returnValue' => $ returnValue , ] ; }
|
Executes the actual deployment commands .
|
8,345
|
protected function getItem ( $ foreignKey ) { $ value = $ foreignKey [ 'field' ] ; if ( ! empty ( $ foreignKey [ 'name' ] ) ) { $ value .= "', '" . $ foreignKey [ 'name' ] ; } $ output = sprintf ( "\$table->foreign('%s')->references('%s')->on('%s')" , $ value , $ foreignKey [ 'references' ] , $ foreignKey [ 'on' ] ) ; if ( $ foreignKey [ 'onUpdate' ] ) { $ output .= sprintf ( "->onUpdate('%s')" , $ foreignKey [ 'onUpdate' ] ) ; } if ( $ foreignKey [ 'onDelete' ] ) { $ output .= sprintf ( "->onDelete('%s')" , $ foreignKey [ 'onDelete' ] ) ; } if ( isset ( $ foreignKey [ 'decorators' ] ) ) { $ output .= $ this -> addDecorators ( $ foreignKey [ 'decorators' ] ) ; } return $ output . ';' ; }
|
Return string for adding a foreign key
|
8,346
|
public static function error ( $ number , $ string , $ file , $ line ) { throw new \ ErrorException ( $ string , 0 , $ number , $ file , $ line ) ; }
|
Convert errors to \ ErrorException instances
|
8,347
|
public static function create ( $ file = null , $ data = null , $ encode = false ) { $ view = parent :: create ( static :: view_namespace ( ) . '::' . $ file , $ data , $ encode ) ; \ CCAsset :: holder ( 'theme' ) -> path = static :: public_namespace ( ) ; \ CCAsset :: holder ( 'vendor' ) -> path = 'assets/vendor/' ; return $ view ; }
|
theme creator returns a new view instance
|
8,348
|
protected function _parse ( $ response ) { $ defaults = array ( 'body' => '' , 'headers' => array ( 'Content-Type: text/html; charset=utf-8' ) , 'status' => 200 ) ; if ( is_array ( $ response ) ) { $ response += $ defaults ; } elseif ( is_string ( $ response ) ) { $ defaults [ 'body' ] = $ response ; $ response = $ defaults ; } else { throw new \ LogicException ( 'Response can\'t be NULL.' ) ; } return $ response ; }
|
Parses a response .
|
8,349
|
public static final function byName ( $ enumName ) { $ instances = self :: getInstances ( get_called_class ( ) ) ; return isset ( $ instances [ $ enumName ] ) ? $ instances [ $ enumName ] : null ; }
|
Returns the enum value instance representing the provided const name or null when the const name is not present in the enum .
|
8,350
|
private final static function & getInstances ( $ fqcn ) { if ( ! isset ( self :: $ instances [ $ fqcn ] ) ) { self :: loadClass ( $ fqcn ) ; } return self :: $ instances [ $ fqcn ] ; }
|
Returns the array of all value singletons of one Enum class
|
8,351
|
private final static function loadClass ( $ fqcn ) { $ reflectionClass = new ReflectionClass ( $ fqcn ) ; $ constants = $ reflectionClass -> getConstants ( ) ; foreach ( $ constants as $ name => $ value ) { $ instance = new $ fqcn ( $ fqcn , $ name , $ value ) ; if ( is_callable ( [ $ instance , '__initEnum' ] ) ) { $ instance -> __initEnum ( ) ; } $ instanceConstructorName = '__' . $ name ; if ( is_callable ( [ $ instance , $ instanceConstructorName ] ) ) { $ instance -> $ instanceConstructorName ( ) ; } if ( ! isset ( self :: $ instances [ $ fqcn ] ) ) { self :: $ instances [ $ fqcn ] = [ ] ; } self :: $ instances [ $ fqcn ] [ $ name ] = $ instance ; } }
|
Uses reflection to load and cache all value singletons of the class represented by the fqcn .
|
8,352
|
public function validateScopes ( $ scopeParam = '' , ClientEntity $ client , $ redirectUri = null ) { $ scopesList = explode ( $ this -> server -> getScopeDelimiter ( ) , $ scopeParam ) ; for ( $ i = 0 ; $ i < count ( $ scopesList ) ; $ i ++ ) { $ scopesList [ $ i ] = trim ( $ scopesList [ $ i ] ) ; if ( $ scopesList [ $ i ] === '' ) { unset ( $ scopesList [ $ i ] ) ; } } if ( $ this -> server -> scopeParamRequired ( ) === true && $ this -> server -> getDefaultScope ( ) === null && count ( $ scopesList ) === 0 ) { throw new Exception \ InvalidRequestException ( 'scope' ) ; } elseif ( count ( $ scopesList ) === 0 && $ this -> server -> getDefaultScope ( ) !== null ) { if ( is_array ( $ this -> server -> getDefaultScope ( ) ) ) { $ scopesList = $ this -> server -> getDefaultScope ( ) ; } else { $ scopesList = [ 0 => $ this -> server -> getDefaultScope ( ) ] ; } } $ scopes = [ ] ; foreach ( $ scopesList as $ scopeItem ) { $ scope = $ this -> server -> getScopeStorage ( ) -> get ( $ scopeItem , $ this -> getIdentifier ( ) , $ client -> getId ( ) ) ; if ( ( $ scope instanceof ScopeEntity ) === false ) { throw new Exception \ InvalidScopeException ( $ scopeItem , $ redirectUri ) ; } $ scopes [ $ scope -> getId ( ) ] = $ scope ; } return $ scopes ; }
|
Given a list of scopes validate them and return an array of Scope entities
|
8,353
|
public static function create ( $ modelAlias = null , $ criteria = null ) { if ( $ criteria instanceof SystemSettingsQuery ) { return $ criteria ; } $ query = new SystemSettingsQuery ( null , null , $ modelAlias ) ; if ( $ criteria instanceof Criteria ) { $ query -> mergeWith ( $ criteria ) ; } return $ query ; }
|
Returns a new SystemSettingsQuery object .
|
8,354
|
public function filterByKey ( $ key = null , $ comparison = null ) { if ( null === $ comparison ) { if ( is_array ( $ key ) ) { $ comparison = Criteria :: IN ; } elseif ( preg_match ( '/[\%\*]/' , $ key ) ) { $ key = str_replace ( '*' , '%' , $ key ) ; $ comparison = Criteria :: LIKE ; } } return $ this -> addUsingAlias ( SystemSettingsPeer :: KEY , $ key , $ comparison ) ; }
|
Filter the query on the key column
|
8,355
|
public function buildUrl ( ) { $ url = $ this -> getApiUrl ( ) ; if ( $ endpoint = $ this -> getEndpoint ( ) ) { $ url .= $ endpoint ; } if ( $ id = $ this -> getId ( ) ) { $ url .= '/' . $ id ; } $ parameters = [ ] ; if ( $ include = $ this -> getInclude ( ) ) { if ( is_array ( $ include ) ) { $ include = implode ( ',' , $ include ) ; } $ parameters [ 'include' ] = $ include ; } if ( $ filters = $ this -> getFilters ( ) ) { if ( ! empty ( $ filters ) ) { $ parameters [ 'filter' ] = $ filters ; } } if ( $ pageSize = $ this -> getPageSize ( ) ) { if ( ! empty ( $ pageSize ) ) { $ parameters [ 'page' ] = [ 'size' => $ pageSize ] ; } } if ( $ sort = $ this -> getSort ( ) ) { if ( ! empty ( $ sort ) ) { $ parameters [ 'sort' ] = $ sort ; } } if ( $ parameters ) { $ url .= '?' . http_build_query ( $ parameters ) ; } return $ url ; }
|
Build api call url .
|
8,356
|
public function httpGetRequest ( $ url ) { if ( $ this -> useCache ( ) ) { $ cache = $ this -> getCache ( ) ; if ( $ response = $ cache -> get ( $ url ) ) { return $ response ; } } if ( empty ( $ this -> client ) ) { $ this -> client = new Client ( [ 'verify' => false ] ) ; } $ this -> response = $ this -> client -> request ( 'GET' , $ url , [ 'headers' => $ this -> getHeaders ( ) ] ) ; $ response = json_decode ( $ this -> response -> getBody ( ) ) ; if ( ! empty ( $ cache ) ) { $ cache -> put ( $ url , $ response , $ this -> getCacheTtl ( ) ) ; } return $ response ; }
|
Make a GET request and respond with json decoded to array .
|
8,357
|
public function httpPostRequest ( $ url , $ parameters ) { if ( empty ( $ this -> client ) ) { $ this -> client = new Client ( [ 'verify' => false ] ) ; } $ this -> response = $ this -> client -> request ( 'POST' , $ url , [ 'headers' => $ this -> getHeaders ( ) , 'json' => $ parameters ] ) ; $ response = json_decode ( $ this -> response -> getBody ( ) ) ; return $ response ; }
|
Make a POST request and respond with json decoded to array .
|
8,358
|
public function get ( $ fields = null ) { if ( ! empty ( $ fields ) ) { $ this -> fields ( $ fields ) ; } return $ this -> httpGetRequest ( $ this -> buildUrl ( ) ) ; }
|
Call get request .
|
8,359
|
public function first ( ) { $ response = $ this -> httpGetRequest ( $ this -> buildUrl ( ) ) ; if ( empty ( $ response -> data [ 0 ] ) ) { return false ; } return $ response -> data [ 0 ] ; }
|
Get first item from get response .
|
8,360
|
public function flush ( ) { $ this -> filters = [ ] ; $ this -> include = null ; $ this -> id = null ; $ this -> endpoint = null ; $ this -> sort = null ; $ this -> fields = null ; $ this -> pageSize = null ; $ this -> response = null ; }
|
Unset all call parameters .
|
8,361
|
public function useCache ( $ caching = null ) { if ( is_null ( $ caching ) ) { return ( $ this -> useCache && $ this -> getCache ( ) ) ; } $ this -> useCache = ( bool ) $ caching ; return $ this ; }
|
Check if cache can be used in this request or set caching for request .
|
8,362
|
protected function resetJsonResult ( ) { $ this -> jsonResult [ 'skipped' ] = false ; $ this -> jsonResult [ 'pass' ] = false ; $ this -> jsonResult [ 'failure' ] = false ; $ this -> jsonResult [ 'error' ] = false ; $ this -> jsonResult [ 'unknown' ] = false ; }
|
initializer for json result set in write progress method
|
8,363
|
protected function writeScanPassStatistic ( CoverFishResult $ coverFishResult ) { $ passStatistic = '%s file(s) and %s method(s) scanned, scan succeeded, no problems found.%s' ; $ passStatistic = sprintf ( $ passStatistic , $ coverFishResult -> getFileCount ( ) , $ coverFishResult -> getTestCount ( ) , PHP_EOL ) ; $ scanResultMacro = '%s%s%s' ; $ scanResult = sprintf ( $ scanResultMacro , ( $ this -> outputLevel === 0 ) ? PHP_EOL : null , PHP_EOL , ( false === $ this -> preventAnsiColors ) ? Color :: tplGreenColor ( $ passStatistic ) : $ passStatistic ) ; $ this -> write ( $ scanResult ) ; }
|
write scan pass results
|
8,364
|
protected function writeScanFailStatistic ( CoverFishResult $ coverFishResult ) { $ errorStatistic = '%s file(s) and %s method(s) scanned, coverage failed: %s cover annotation problem(s) found!%s' ; $ errorStatistic = sprintf ( $ errorStatistic , $ coverFishResult -> getFileCount ( ) , $ coverFishResult -> getTestCount ( ) , $ coverFishResult -> getFailureCount ( ) , PHP_EOL ) ; $ scanResultMacro = '%s%s%s%s' ; $ scanResult = sprintf ( $ scanResultMacro , ( $ this -> outputLevel === 0 ) ? PHP_EOL : null , PHP_EOL , ( false === $ this -> preventAnsiColors ) ? Color :: tplRedColor ( $ errorStatistic ) : $ errorStatistic , $ this -> getScanFailPassStatistic ( $ coverFishResult ) ) ; $ this -> write ( $ scanResult ) ; throw new CoverFishFailExit ( ) ; }
|
write scan fail result
|
8,365
|
protected static function __zipWith ( callable $ f , array $ a , array $ b ) : array { $ result = [ ] ; while ( ( $ ai = array_shift ( $ a ) ) !== null && ( $ bi = array_shift ( $ b ) ) !== null ) { $ result [ ] = $ f ( $ ai , $ bi ) ; } return $ result ; }
|
Custom Array Zip
|
8,366
|
protected static function __dropWhile ( callable $ predicate , array $ list ) : array { foreach ( $ list as $ item ) { if ( $ predicate ( $ item ) ) { array_shift ( $ list ) ; } else { break ; } } return $ list ; }
|
Drop Elements with Predicate
|
8,367
|
protected static function __takeWhile ( callable $ predicate , array $ list ) : array { $ result = [ ] ; foreach ( $ list as $ item ) { if ( $ predicate ( $ item ) ) { $ result [ ] = $ item ; } else { break ; } } return $ result ; }
|
Take Elements with Predicate
|
8,368
|
public static function thumb ( $ src , $ url = '#' , $ htmlOptions = array ( ) ) { static :: addCssClass ( $ htmlOptions , 'th' ) ; return \ CHtml :: link ( \ CHtml :: image ( $ src ) , $ url , $ htmlOptions ) ; }
|
Renders a Foundation thumbnail
|
8,369
|
public static function addCssClass ( & $ options , $ class ) { if ( isset ( $ options [ 'class' ] ) ) { $ classes = ' ' . $ options [ 'class' ] . ' ' ; if ( ( $ pos = strpos ( $ classes , ' ' . $ class . ' ' ) ) === false ) { $ options [ 'class' ] .= ' ' . $ class ; } } else { $ options [ 'class' ] = $ class ; } }
|
Adds a CSS class to the specified options . If the CSS class is already in the options it will not be added again .
|
8,370
|
public function callUrl ( $ url , $ args = array ( ) , $ returnType = 'raw' , $ requestType = 'GET' , $ cache = 300 , $ enctype = Zend_Http_Client :: ENC_URLENCODED ) { $ body = null ; $ cacheKey = md5 ( $ url . $ requestType . var_export ( $ args , true ) . var_export ( $ this -> globalParams , true ) ) ; $ requestType = isset ( $ methodDetails [ 'method' ] ) ? $ methodDetails [ 'method' ] : 'GET' ; if ( mb_strtolower ( $ requestType ) == 'get' && $ cache ) { $ body = CacheService :: inst ( ) -> get ( $ cacheKey ) ; } if ( ! $ body ) { $ uri = $ url ; $ client = $ this -> getClient ( $ uri ) ; $ client -> setMethod ( $ requestType ) ; $ client -> setEncType ( $ enctype ) ; $ paramMethod = 'setParameter' . $ requestType ; if ( $ this -> globalParams ) { foreach ( $ this -> globalParams as $ key => $ value ) { $ client -> $ paramMethod ( $ key , $ value ) ; } } foreach ( $ args as $ index => $ pname ) { $ client -> $ paramMethod ( $ index , $ pname ) ; } $ response = $ client -> request ( ) ; if ( $ response -> isSuccessful ( ) ) { $ body = $ response -> getBody ( ) ; if ( $ cache ) { CacheService :: inst ( ) -> store ( $ cacheKey , $ body , $ cache ) ; } } else { if ( $ response -> getStatus ( ) == 500 ) { error_log ( "Failure: " . $ response -> getBody ( ) ) ; error_log ( var_export ( $ client , true ) ) ; } throw new FailedRequestException ( "Failed executing $url: " . $ response -> getMessage ( ) . " for request to $uri (" . $ client -> getUri ( true ) . ')' , $ response -> getBody ( ) ) ; } } if ( isset ( $ this -> returnHandlers [ $ returnType ] ) ) { $ handler = $ this -> returnHandlers [ $ returnType ] ; return $ handler -> handleReturn ( $ body ) ; } else { return $ body ; } }
|
Call a URL directly without it being mapped to a configured web method .
|
8,371
|
protected function getClient ( $ uri ) { if ( ! $ this -> httpClient || ! $ this -> maintainSession ) { $ this -> httpClient = new Zend_Http_Client ( $ uri , array ( 'maxredirects' => 0 , 'timeout' => 10 ) ) ; if ( $ this -> useCookies ) { $ this -> httpClient -> setCookieJar ( ) ; } } else { $ this -> httpClient -> setUri ( $ uri ) ; } if ( $ this -> maintainSession ) { $ this -> httpClient -> resetParameters ( ) ; } if ( $ this -> authInfo ) { $ this -> httpClient -> setAuth ( $ this -> authInfo [ 'user' ] , $ this -> authInfo [ 'pass' ] ) ; } return $ this -> httpClient ; }
|
Create and return the http client defined in a separate method for testing purposes
|
8,372
|
protected function waitFrame ( ) { $ frameType = $ this -> input -> readOctet ( ) ; $ channel = $ this -> input -> readShort ( ) ; $ size = $ this -> input -> readLong ( ) ; $ payload = $ this -> input -> read ( $ size ) ; $ ch = $ this -> input -> readOctet ( ) ; if ( $ ch != 0xCE ) { throw new \ Exception ( sprintf ( 'Framing error, unexpected byte: %x' , $ ch ) ) ; } return array ( $ frameType , $ channel , $ payload ) ; }
|
Wait for a frame from the server
|
8,373
|
public function waitChannel ( $ channelId ) { while ( true ) { list ( $ frameType , $ frameChannel , $ payload ) = $ this -> waitFrame ( ) ; if ( $ frameChannel == $ channelId ) { return array ( $ frameType , $ payload ) ; } array_push ( $ this -> channels [ $ frameChannel ] -> frame_queue , array ( $ frameType , $ payload ) ) ; if ( ( $ frameType == 1 ) && ( $ frameChannel == 0 ) ) { $ this -> wait ( ) ; } } return array ( ) ; }
|
Wait for a frame from the server destined for a particular channel .
|
8,374
|
public function channel ( $ channelId = null ) { if ( isset ( $ this -> channels [ $ channelId ] ) ) { return $ this -> channels [ $ channelId ] ; } else { $ channelId = $ channelId ? : $ this -> getFreeChannelId ( ) ; $ ch = new Channel ( $ this -> connection , $ channelId ) ; return $ this -> channels [ $ channelId ] = $ ch ; } }
|
Fetch a Channel object identified by the numeric channel_id or create that object if it doesn t already exist .
|
8,375
|
public function close ( $ replyCode = 0 , $ replyText = '' , $ methodSig = array ( 0 , 0 ) ) { $ args = new Writer ( ) ; $ args -> writeShort ( $ replyCode ) ; $ args -> writeShortStr ( $ replyText ) ; $ args -> writeShort ( $ methodSig [ 0 ] ) ; $ args -> writeShort ( $ methodSig [ 1 ] ) ; $ this -> sendMethodFrame ( array ( 10 , 60 ) , $ args ) ; return $ this -> wait ( array ( "10,61" , ) ) ; }
|
request a connection close
|
8,376
|
protected function openOk ( Reader $ args ) { $ this -> knownHosts = $ args -> readShortstr ( ) ; if ( $ this -> debug ) { Helper :: debugMsg ( "Open OK! known_hosts: " . $ this -> knownHosts ) ; } return null ; }
|
signal that the connection is ready
|
8,377
|
protected function redirect ( Reader $ args ) { $ host = $ args -> readShortstr ( ) ; $ this -> knownHosts = $ args -> readShortstr ( ) ; if ( $ this -> debug ) { Helper :: debugMsg ( sprintf ( 'Redirected to [%s], known_hosts [%s]' , $ host , $ this -> knownHosts ) ) ; } return $ host ; }
|
asks the client to use a different server
|
8,378
|
protected function _xSecureOk ( $ response ) { $ args = new Writer ( ) ; $ args -> writeLongStr ( $ response ) ; $ this -> sendMethodFrame ( array ( 10 , 21 ) , $ args ) ; }
|
security mechanism response
|
8,379
|
protected function start ( Reader $ args ) { $ this -> versionMajor = $ args -> readOctet ( ) ; $ this -> versionMinor = $ args -> readOctet ( ) ; $ this -> serverProperties = $ args -> readTable ( ) ; $ this -> mechanisms = explode ( " " , $ args -> readLongstr ( ) ) ; $ this -> locales = explode ( " " , $ args -> readLongstr ( ) ) ; if ( $ this -> debug ) { Helper :: debugMsg ( sprintf ( 'Start from server, version: %d.%d, properties: %s, ' . 'mechanisms: %s, locales: %s' , $ this -> versionMajor , $ this -> versionMinor , self :: dumpTable ( $ this -> serverProperties ) , implode ( ', ' , $ this -> mechanisms ) , implode ( ', ' , $ this -> locales ) ) ) ; } }
|
start connection negotiation
|
8,380
|
protected function tune ( Reader $ args ) { $ v = $ args -> readShort ( ) ; if ( $ v ) { $ this -> channelMax = $ v ; } $ v = $ args -> readLong ( ) ; if ( $ v ) { $ this -> frameMax = $ v ; } $ this -> heartbeat = $ args -> readShort ( ) ; $ this -> xTuneOk ( $ this -> channelMax , $ this -> frameMax , 0 ) ; }
|
propose connection tuning parameters
|
8,381
|
protected function xTuneOk ( $ channelMax , $ frameMax , $ heartbeat ) { $ args = new Writer ( ) ; $ args -> writeShort ( $ channelMax ) ; $ args -> writeLong ( $ frameMax ) ; $ args -> writeShort ( $ heartbeat ) ; $ this -> sendMethodFrame ( array ( 10 , 31 ) , $ args ) ; $ this -> waitTuneOk = False ; }
|
negotiate connection tuning parameters
|
8,382
|
public function service ( $ service , $ subject , $ predicate = null , $ object = null ) { $ this -> graphBuilder -> service ( $ service , $ subject , $ predicate , $ object ) ; return $ this ; }
|
Adds the given graph or triple as an service condition .
|
8,383
|
public function convertToRconData ( $ id ) { $ idAndTypePacked = pack ( 'VV' , $ id , $ this -> type ) ; $ endOfMessage = chr ( 0 ) . chr ( 0 ) ; $ message = $ idAndTypePacked . $ this -> body . $ endOfMessage ; $ data = pack ( "V" , strlen ( $ message ) ) . $ message ; return $ data ; }
|
The message id used for this message . This will be encoded in the RconData .
|
8,384
|
public function _add_meta_boxes ( $ post_type , $ post ) { $ post_type_object = get_post_type_object ( $ post_type ) ; if ( empty ( $ post_type_object ) || empty ( $ post_type_object -> public ) ) { return ; } add_meta_box ( 'wp-seo' , __ ( 'SEO' , 'inc2734-wp-seo' ) , array ( $ this , '_wp_seo_meta_box' ) , $ post_type , 'normal' ) ; }
|
Add meta box in pages of public post type
|
8,385
|
public function _wp_seo_meta_box ( $ post ) { ?> <?php wp_nonce_field ( 'wp-seo-meta-box-action' , 'wp-seo-meta-box-nonce' ) ; ?> <p> <label for="wp-seo-meta-description"> <b> <?php esc_html_e ( 'Meta description' , 'inc2734-wp-seo' ) ; ?> </b> </label><br /> <input type="text" name="wp-seo-meta-description" class="widefat" id="wp-seo-meta-description" value=" <?php echo esc_attr ( get_post_meta ( $ post -> ID , 'wp-seo-meta-description' , true ) ) ; ?> " /> </p> <p> <b> <?php esc_html_e ( 'Meta robots' , 'inc2734-wp-seo' ) ; ?> </b><br /> <?php $ robots = ( array ) get_post_meta ( $ post -> ID , 'wp-seo-meta-robots' , true ) ; $ robots_choices = [ 'noindex' , 'nofollow' , ] ?> <?php foreach ( $ robots_choices as $ robot ) : ?> <label for="wp-seo-meta-robots- <?php echo esc_attr ( $ robot ) ; ?> " style="margin-right: 1em;"> <input type="checkbox" name="wp-seo-meta-robots[]" id="wp-seo-meta-robots- <?php echo esc_attr ( $ robot ) ; ?> " value=" <?php echo esc_attr ( $ robot ) ; ?> " <?php checked ( in_array ( $ robot , $ robots ) ) ; ?> /> <?php echo esc_html ( $ robot ) ; ?> </label> <?php endforeach ; ?> </p> <?php }
|
Display meta box
|
8,386
|
public function _save_meta_description ( $ post_id ) { if ( empty ( $ _POST [ 'wp-seo-meta-box-nonce' ] ) ) { return ; } if ( ! wp_verify_nonce ( wp_unslash ( filter_input ( INPUT_POST , 'wp-seo-meta-box-nonce' ) ) , 'wp-seo-meta-box-action' ) ) { return ; } if ( defined ( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) { return ; } if ( ! current_user_can ( 'edit_post' , $ post_id ) ) { return ; } if ( ! isset ( $ _POST [ 'wp-seo-meta-description' ] ) ) { return ; } if ( is_array ( $ _POST [ 'wp-seo-meta-description' ] ) ) { return ; } $ meta_description = wp_unslash ( filter_input ( INPUT_POST , 'wp-seo-meta-description' ) ) ; update_post_meta ( $ post_id , 'wp-seo-meta-description' , $ meta_description ) ; }
|
Save meta description
|
8,387
|
public function _save_meta_robots ( $ post_id ) { if ( empty ( $ _POST [ 'wp-seo-meta-box-nonce' ] ) ) { return ; } if ( ! wp_verify_nonce ( wp_unslash ( filter_input ( INPUT_POST , 'wp-seo-meta-box-nonce' ) ) , 'wp-seo-meta-box-action' ) ) { return ; } if ( defined ( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) { return ; } if ( ! current_user_can ( 'edit_post' , $ post_id ) ) { return ; } if ( ! isset ( $ _POST [ 'wp-seo-meta-robots' ] ) || ! is_array ( $ _POST [ 'wp-seo-meta-robots' ] ) ) { update_post_meta ( $ post_id , 'wp-seo-meta-robots' , [ ] ) ; return ; } $ meta_robots = filter_input ( INPUT_POST , 'wp-seo-meta-robots' , FILTER_DEFAULT , FILTER_REQUIRE_ARRAY ) ; update_post_meta ( $ post_id , 'wp-seo-meta-robots' , $ meta_robots ) ; }
|
Save meta robots
|
8,388
|
public static function getTypeInstance ( $ type ) { $ type = ucfirst ( strtolower ( $ type ) ) ; if ( ! isset ( self :: $ instances [ $ type ] ) ) { $ class = 'JFusion\\Api\\Platform\\' . $ type ; self :: $ instances [ $ type ] = new $ class ( ) ; } return self :: $ instances [ $ type ] ; }
|
Get a platform type object .
|
8,389
|
public static function generate_token ( $ length ) { $ byte_length = ( $ length / 2 ) ; $ new_token = bin2hex ( openssl_random_pseudo_bytes ( $ byte_length , $ strong_enough ) ) ; if ( $ strong_enough == false || empty ( $ new_token ) ) { $ exception = bootstrap :: get_library ( 'exception' ) ; throw new $ exception ( 'can not generate cryptographically strong enough token' ) ; } return $ new_token ; }
|
generates cryptographically strong tokens
|
8,390
|
public function setLayers ( array $ layers ) { $ this -> layers = array_values ( array_filter ( $ layers , function ( $ layer ) : bool { return $ layer instanceof Layer ; } ) ) ; return $ this ; }
|
Sets the layers of the icon .
|
8,391
|
public function register_asset ( \ Amarkal \ Assets \ AbstractAsset $ new_asset ) { if ( NULL == $ this -> assets ) { $ this -> assets = array ( ) ; $ this -> assets [ ] = $ new_asset ; } else { foreach ( $ this -> assets as $ asset ) { if ( $ asset -> handle == $ new_asset -> handle && get_class ( $ asset ) == get_class ( $ new_asset ) ) { throw new DuplicateAssetException ( "An asset with the handle {$new_asset->handle} already exists" ) ; } } $ this -> assets [ ] = $ new_asset ; } }
|
Register a single asset
|
8,392
|
public static function expandNamespace ( $ classOrClassName , $ expandNamespace ) { if ( mb_strpos ( $ classOrClassName , '\\' ) !== 0 && self :: getNamespace ( $ classOrClassName ) === NULL ) { return $ expandNamespace . '\\' . ltrim ( $ classOrClassName , '\\' ) ; } return $ classOrClassName ; }
|
Erweitert einen nicht qualifzierten Klassenamen mit einem Namespace
|
8,393
|
public function userCanReachCenter ( User $ user , Center $ center ) { foreach ( $ user -> getGroupCenters ( ) as $ groupCenter ) { if ( $ center -> getId ( ) === $ groupCenter -> getCenter ( ) -> getId ( ) ) { return true ; } } return false ; }
|
Determines if a user is active on this center
|
8,394
|
public function getReachableCenters ( User $ user , Role $ role , Scope $ scope = null ) { $ centers = array ( ) ; foreach ( $ user -> getGroupCenters ( ) as $ groupCenter ) { $ permissionGroup = $ groupCenter -> getPermissionsGroup ( ) ; foreach ( $ permissionGroup -> getRoleScopes ( ) as $ roleScope ) { if ( $ this -> isRoleReached ( $ role , new Role ( $ roleScope -> getRole ( ) ) ) ) { if ( $ scope === null ) { $ centers [ ] = $ groupCenter -> getCenter ( ) ; break 1 ; } else { if ( $ scope -> getId ( ) == $ roleScope -> getScope ( ) -> getId ( ) ) { $ centers [ ] = $ groupCenter -> getCenter ( ) ; break 1 ; } } } } } return $ centers ; }
|
Get reachable Centers for the given user role and optionnaly Scope
|
8,395
|
public function getReachableScopes ( User $ user , Role $ role , Center $ center ) { return $ this -> getReachableCircles ( $ user , $ role , $ center ) ; }
|
Return all reachable scope for a given user center and role
|
8,396
|
public function getReachableCircles ( User $ user , Role $ role , Center $ center ) { $ scopes = array ( ) ; foreach ( $ user -> getGroupCenters ( ) as $ groupCenter ) { if ( $ center -> getId ( ) === $ groupCenter -> getCenter ( ) -> getId ( ) ) { $ permissionGroup = $ groupCenter -> getPermissionsGroup ( ) ; foreach ( $ permissionGroup -> getRoleScopes ( ) as $ roleScope ) { if ( $ this -> isRoleReached ( $ role , new Role ( $ roleScope -> getRole ( ) ) ) ) { $ scopes [ ] = $ roleScope -> getScope ( ) ; } } } } return $ scopes ; }
|
Return all reachable circle for a given user center and role
|
8,397
|
protected function isRoleReached ( Role $ childRole , Role $ parentRole ) { $ reachableRoles = $ this -> roleHierarchy -> getReachableRoles ( [ $ parentRole ] ) ; return in_array ( $ childRole , $ reachableRoles ) ; }
|
Test if a parent role may give access to a given child role
|
8,398
|
public function getCacheStore ( ) : ? Store { if ( ! $ this -> hasCacheStore ( ) ) { $ this -> setCacheStore ( $ this -> getDefaultCacheStore ( ) ) ; } return $ this -> cacheStore ; }
|
Get cache store
|
8,399
|
public function getDefaultCacheStore ( ) : ? Store { $ manager = Cache :: getFacadeRoot ( ) ; if ( isset ( $ manager ) ) { $ repository = $ manager -> store ( ) ; return $ repository -> getStore ( ) ; } return $ manager ; }
|
Get a default cache store value if any is available
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.