idx
int64
0
60.3k
question
stringlengths
92
4.62k
target
stringlengths
7
635
5,600
public static function isValid ( $ gid ) { if ( preg_match ( "/^[A-Z0-9]+$/" , $ gid ) ) { if ( strlen ( $ gid ) <= 50 && strlen ( $ gid ) >= 47 ) { return true ; } } return false ; }
Determines if the format of a given GlobalID is valid .
5,601
protected function unPrepareData ( $ data ) { $ dataUn = @ unserialize ( $ data ) ; if ( $ data === 'b:0;' || $ dataUn !== false ) { return $ dataUn ; } else { echo $ data ; } }
Retorna los datos exactamente como se cachearon
5,602
public static function getEntityIdForClass ( $ className ) { self :: entitiesMap ( ) ; if ( false === isset ( self :: $ entitiesMap [ $ className ] ) ) { throw new InvalidParamException ( Yii :: t ( 'dotplant.entity.structure' , 'Unknown entity class \'{class}\'.' , [ 'class' => $ className ] ) ) ; } return ( int ) sel...
Returns Entity id according to given Entity class name
5,603
public function addFromAnnotations ( $ classname , $ filter = "" ) { $ loops = $ this -> getLoops ( ) ; $ properties = $ loops -> getService ( "annotations" ) -> get ( is_object ( $ classname ) ? get_class ( $ classname ) : $ classname ) -> properties ; $ result = [ ] ; foreach ( $ properties -> find ( "Form\Element" )...
Adds form elements based on annotations .
5,604
public function confirm ( $ values ) { $ this -> confirmed = FALSE ; $ values = Misc :: unflattenArray ( $ values , "-" ) ; foreach ( $ this -> getFormElements ( ) as $ name => $ child ) { $ child -> setValue ( array_key_exists ( $ name , $ values ) ? $ values [ $ name ] : NULL ) ; $ this -> value -> offsetSet ( $ name...
Checks passed input for its validity
5,605
public function validate ( ) { $ validated = TRUE ; foreach ( $ this -> getFormElements ( ) as $ name => $ child ) { $ validated &= $ child -> validate ( ) ; } $ validated &= $ this -> fireEvent ( "Form\onValidate" , [ $ this -> value , $ this ] , TRUE , FALSE ) ; return ( bool ) $ validated ; }
Validates all form elements
5,606
public function applyFilter ( ) { foreach ( $ this -> getFormElements ( ) as $ name => $ child ) { $ this -> value -> offsetSet ( $ name , $ child -> getValue ( TRUE ) ) ; } }
Updates the value and applies the hard filter
5,607
public function submit ( ) { if ( ! $ this -> confirmed ) { throw new Exception ( "Form: Please call 'confirm' before calling 'submit'." ) ; } $ this -> submitted = $ this -> fireEvent ( "Form\onSubmit" , [ $ this -> getValue ( ) , $ this ] , TRUE , FALSE ) ; if ( $ this -> submitted ) { $ this -> fireEvent ( "Form\onC...
Submits the form
5,608
public function confirmAction ( $ parameter ) { if ( $ parameter || $ this -> no_confirm ) { return ; } $ this -> initFromSession ( ) ; if ( $ this -> request -> isPost ( ) ) { $ this -> confirm ( $ this -> request -> post ( ) ) ; } else if ( ! $ this -> confirmed ) { return Misc :: redirect ( $ this , 302 , $ this -> ...
Trigger the confirm action via URL
5,609
public function backAction ( $ parameter ) { if ( $ parameter ) { return ; } $ this -> initFromSession ( ) ; $ this -> back ( ) ; $ this -> saveToSession ( ) ; return Misc :: redirect ( $ this , 302 , $ this -> getLoops ( ) ) ; }
Trigger the back action via URL
5,610
public function submitAction ( $ parameter ) { if ( $ parameter ) { return ; } $ this -> initFromSession ( ) ; if ( ! $ this -> request -> isPost ( ) ) { if ( $ this -> confirmed ) { $ this -> back ( ) ; $ this -> saveToSession ( ) ; } return Misc :: redirect ( $ this ) ; } if ( $ this -> no_confirm ) { if ( ! $ this -...
Trigger the submit action via URL
5,611
public function getValue ( $ array = FALSE , $ array_strict = TRUE ) { if ( $ array ) { $ result = [ ] ; foreach ( $ this -> getFormElements ( ) as $ name => $ child ) { $ result [ $ name ] = $ child -> getValue ( $ array_strict ) ; } return $ result ; } else { return $ this -> value ; } }
Returns the value of the form
5,612
public function getFormValue ( $ strict = FALSE ) { $ result = [ ] ; foreach ( $ this -> getFormElements ( ) as $ name => $ child ) { $ result [ $ name ] = $ child instanceof Subform ? $ child -> getFormValue ( $ strict ) : $ child -> getValue ( $ strict ) ; } return new Value ( $ this , $ result ) ; }
Return the current value as a form value
5,613
public function onSessionInit ( $ value ) { if ( ! $ value -> offsetExists ( "value" ) ) { return ; } $ value = $ value -> offsetGet ( "value" ) ; foreach ( $ this -> getFormElements ( ) as $ name => $ child ) { if ( ! $ value -> offsetExists ( $ name ) ) continue ; $ newvalue = $ value -> offsetGet ( $ name ) ; $ chil...
The session trait directly sets the values - call setValue manually
5,614
public function setFilepath ( $ filepath ) { $ this -> _path = pathinfo ( $ filepath ) ; if ( ! isset ( $ this -> _path [ 'extension' ] ) ) $ this -> _path [ 'extension' ] = null ; return $ this ; }
Sets the directory name and extension based on the given filepath string .
5,615
public function getFilepath ( ) { $ filepath = $ this -> _path [ 'dirname' ] . DIRECTORY_SEPARATOR . $ this -> _path [ 'filename' ] ; if ( $ this -> _path [ 'extension' ] ) $ filepath .= '.' . $ this -> _path [ 'extension' ] ; return $ filepath ; }
Returns the full filepath string .
5,616
public function setExtension ( $ extension = null ) { if ( ! $ extension ) { $ this -> _path [ 'extension' ] = null ; } else { $ this -> _path [ 'extension' ] = ( string ) trim ( $ extension , '.' ) ; } return $ this ; }
Sets the extension for the file .
5,617
public static function alias_to_namespace ( $ class , $ namespace = '' ) { empty ( $ namespace ) or $ namespace = rtrim ( $ namespace , '\\' ) . '\\' ; $ parts = explode ( '\\' , $ class ) ; $ root_class = $ namespace . array_pop ( $ parts ) ; class_alias ( $ class , $ root_class ) ; }
Aliases the given class into the given Namespace . By default it will add it to the global namespace .
5,618
protected static function find_core_class ( $ class ) { foreach ( static :: $ core_namespaces as $ ns ) { if ( array_key_exists ( strtolower ( $ ns_class = $ ns . '\\' . $ class ) , static :: $ classes ) ) { return $ ns_class ; } } return false ; }
Returns the class with namespace prefix when available
5,619
public static function load ( $ class ) { if ( strpos ( $ class , 'static::' ) === 0 ) { return true ; } $ loaded = false ; $ class = ltrim ( $ class , '\\' ) ; $ namespaced = ( $ pos = strripos ( $ class , '\\' ) ) !== false ; if ( empty ( static :: $ auto_initialize ) ) { static :: $ auto_initialize = $ class ; } if ...
Loads a class .
5,620
protected static function class_to_path ( $ class , $ psr = false ) { $ file = '' ; if ( $ last_ns_pos = strripos ( $ class , '\\' ) ) { $ namespace = substr ( $ class , 0 , $ last_ns_pos ) ; $ class = substr ( $ class , $ last_ns_pos + 1 ) ; $ file = str_replace ( '\\' , DS , $ namespace ) . DS ; } $ file .= str_repla...
Takes a class name and turns it into a path . It follows the PSR - 0 standard except for makes the entire path lower case unless you tell it otherwise .
5,621
public function mapsParameters ( ContainerBuilder $ container , $ rootNodeName , $ config ) { foreach ( $ config as $ name => $ value ) { if ( is_array ( $ value ) ) { $ this -> mapsParameters ( $ container , $ rootNodeName . '.' . $ name , $ value ) ; } else { $ container -> setParameter ( $ rootNodeName . '.' . $ nam...
Maps parameters in container
5,622
public function configureTwigBundle ( ContainerBuilder $ container , array $ config ) { foreach ( array_keys ( $ container -> getExtensions ( ) ) as $ name ) { switch ( $ name ) { case 'twig' : $ container -> prependExtensionConfig ( $ name , array ( 'form_themes' => array ( $ config [ 'form_theme' ] ) ) ) ; break ; } ...
Configure twig bundle
5,623
public function injectControllerDependencies ( $ controller , ServiceLocatorInterface $ serviceLocator ) { if ( ! $ controller instanceof DispatchableInterface ) { return ; } $ parentLocator = $ serviceLocator -> getServiceLocator ( ) ; if ( $ controller instanceof ServiceLocatorAwareInterface ) { $ controller -> setSe...
Inject required dependencies into the controller .
5,624
protected function init ( ) { $ starttime = explode ( ' ' , microtime ( ) ) ; self :: $ starttime = $ starttime [ 1 ] + $ starttime [ 0 ] ; $ this -> router = array ( ) ; }
Init microtime fill some default values
5,625
public static function page_time ( ) { $ mtime = explode ( ' ' , microtime ( ) ) ; $ totaltime = $ mtime [ 0 ] + $ mtime [ 1 ] - self :: $ starttime ; return $ totaltime ; }
Get current page generation time . Using this for profiling .
5,626
public function softmodules_list ( ) { $ list = array ( ) ; foreach ( $ this -> components as $ com ) { $ controller = $ this -> component_load ( $ com ) ; if ( empty ( $ controller ) ) { continue ; } $ clist = $ controller -> softmodules_list ( ) ; $ list = array_merge ( $ list , $ clist ) ; } return $ list ; }
Get list of softmodules by components . Parse components and return list .
5,627
protected function getIntSuffix ( $ str ) { $ a = explode ( '-' , $ str ) ; $ b = ( int ) $ a [ count ( $ a ) - 1 ] ; return $ b ; }
Very useful function often usings it in URLs parsing ...
5,628
public function countcomponents ( $ pos ) { return isset ( $ this -> positions [ $ pos ] ) ? count ( $ this -> positions [ $ pos ] ) : 0 ; }
Get the count of components in current position
5,629
public function run ( $ URL , $ host = '' ) { if ( ROUTER_DEBUG ) { BLog :: addToLog ( '[Router]: Router started! URL=' . $ URL . '; host=' . $ host ) ; } $ this -> init ( ) ; $ this -> url = $ URL ; $ this -> host = $ host ; $ r = $ this -> parseurl ( $ URL , $ host ) ; if ( ROUTER_DEBUG ) { if ( $ r ) { BLog :: addTo...
First function that runs in router
5,630
public function component_load ( $ cname ) { $ fn = BCOMPONENTSFRAMEWORKPATH . $ cname . DIRECTORY_SEPARATOR . 'controller.php' ; if ( ! file_exists ( $ fn ) ) { $ fn = BCOMPONENTSAPPLICATIONPATH . $ cname . DIRECTORY_SEPARATOR . 'controller.php' ; } if ( ! file_exists ( $ fn ) ) { BLog :: addToLog ( '[Router]: Could n...
Create component controller object by component name ...
5,631
public function generatepage_json ( ) { $ status = 200 ; foreach ( $ this -> rules as & $ c ) { $ this -> positions [ $ c -> position ] = $ c -> output ; if ( $ c -> status != 200 ) { $ status = $ c -> status ; } } header ( 'Content-type: text/json' ) ; if ( $ status == 403 ) { header ( $ _SERVER [ 'SERVER_PROTOCOL' ] ...
Output final JSON
5,632
public function generatepage_pdf ( ) { foreach ( $ this -> rules as & $ c ) { $ this -> positions [ $ c -> position ] = $ c -> output ; } header ( "Content-type: application/pdf" ) ; echo $ this -> positions [ 'content' ] ; }
Output final PDF .
5,633
protected function addSection ( $ section , $ contents , $ overwrite = false ) { if ( $ overwrite || ! isset ( $ this -> sections [ $ section ] ) ) { $ this -> sections [ $ section ] = $ contents ; } return $ this ; }
Register a new template section
5,634
protected function getSection ( $ section ) { return isset ( $ this -> sections [ $ section ] ) ? $ this -> sections [ $ section ] : null ; }
Get the specified template section
5,635
public static function insert ( string $ table , array $ fields , array $ values = null ) : string { if ( isset ( $ values ) ) { if ( count ( $ values ) !== count ( $ fields ) ) { echo "Fields count is not equal to Values count!" . PHP_EOL ; exit ; } } $ sql = "INSERT INTO `$table` (" ; $ sql .= "`" . implode ( '`, `' ...
Generate INSERT SQL statement
5,636
public static function checkSlug ( $ slug , $ id = 0 ) { $ count = self :: factory ( ) -> where ( 'slug' , $ slug ) -> where_not_equal ( 'id' , $ id ) -> count ( ) ; return $ count > 0 ; }
Checks that slug not exists
5,637
public function validate ( ) { $ result = array ( ) ; if ( empty ( $ this -> slug ) ) $ this -> slug = $ this -> title ; $ this -> slug = \ lib \ MyFunctions :: slug ( $ this -> slug ) ; if ( empty ( $ this -> slug ) ) { $ result [ 'slug' ] = Validate :: cantLeaveBlank ( _ ( 'Slug' ) ) ; } else { $ slugExists = self ::...
Validates the info
5,638
public static function _creationSchema ( Array $ options = array ( ) ) { $ class = self :: _tableNameForClass ( get_called_class ( ) ) ; $ options = array_merge ( self :: _defaultCreateOptions ( ) , $ options ) ; return <<<EODCREATE TABLE IF NOT EXISTS `{$class}` ( `id` bigint(11) NOT NULL AUTO_IN...
Get the SQL creation sentece of this table
5,639
public function outputImage ( $ params = array ( ) ) { $ param_defaults = array ( 'width' => 120 , 'height' => 40 , ) ; $ params = \ array_merge ( $ param_defaults , $ params ) ; $ code = $ this -> generateCode ( $ this -> length ) ; $ font_size = $ params [ 'height' ] * $ this -> font_scale ; $ image = @ \ imagecreate...
Outputs image and appropriate headers
5,640
protected function check_internal_upgrades ( ) { $ oldProjectName = $ this -> projectName ; $ this -> projectName = $ this -> internalProjectName ; if ( ! isset ( self :: $ cache [ $ this -> projectName ] ) ) { $ this -> reconnect_db ( ) ; $ oldVersionFileLocation = $ this -> versionFileLocation ; $ oldUpgradeConfigFil...
Determine if there are any upgrades that need to be performed ...
5,641
protected function read_upgrade_config_file ( ) { $ config = parse_ini_file ( $ this -> upgradeConfigFile , true , INI_SCANNER_RAW ) ; if ( is_array ( $ config ) ) { $ myConfig = $ config ; if ( isset ( $ config [ 'main' ] ) ) { if ( isset ( $ config [ 'main' ] [ 'initial_version' ] ) ) { $ this -> initialVersion = $ c...
Read information from our config file so we know what to expect .
5,642
protected function update_database_version ( $ newVersionString ) { $ versionInfo = $ this -> parse_version_string ( $ newVersionString ) ; $ sql = "UPDATE " . $ this -> dbTable . " SET version_string=:vStr WHERE project_name=:pName" ; $ params = array ( 'vStr' => $ versionInfo [ 'version_string' ] , 'pName' => $ this ...
Updates information that s stored in the database internal to cs - project so the version there is consistent with all the others .
5,643
protected function check_database_version ( array $ checkThis ) { $ data = $ this -> get_database_version ( ) ; $ versionString = $ data [ 'version_string' ] ; if ( $ versionString == $ checkThis [ 'version_string' ] ) { $ retval = TRUE ; } else { $ retval = FALSE ; } if ( ! $ retval ) { $ this -> do_log ( "Version che...
Checks consistency of version information in the database and optionally against a given version string .
5,644
protected function get_upgrade_list ( ) { $ this -> get_database_version ( ) ; $ dbVersion = $ this -> databaseVersion ; $ newVersion = $ this -> versionFileVersion ; $ retval = array ( ) ; if ( ! $ this -> is_higher_version ( $ dbVersion , $ newVersion ) ) { $ this -> error_handler ( __METHOD__ . ": version (" . $ new...
Determines list of upgrades to perform .
5,645
private function createTracker ( InputInterface $ input ) { switch ( $ input -> getArgument ( 'type' ) ) { case 'github' : $ tracker = new GithubTracker ( $ input -> getOption ( 'username' ) ) ; break ; case 'jira' : $ tracker = new JiraTracker ( $ input -> getOption ( 'host' ) , $ input -> getOption ( 'username' ) , $...
creates the correct tracker .
5,646
public function convert ( array $ data ) { if ( empty ( $ data [ 'code' ] ) ) { if ( empty ( $ data [ 'ctcp' ] ) ) { $ event = new UserEvent ; } else { $ event = new CtcpEvent ; $ event -> setCtcpCommand ( $ data [ 'ctcp' ] [ 'command' ] ) ; if ( ! empty ( $ data [ 'ctcp' ] [ 'params' ] ) ) { $ event -> setCtcpParams (...
Converts event data into an object .
5,647
public function addEventListener ( $ eventName , $ listener , $ priority = EventPriority :: NORMAL ) { if ( ! isset ( $ this -> _listeners [ $ eventName ] [ $ priority ] ) ) { $ this -> _listeners -> extendDeepValue ( array ( $ priority => array ( ) ) , $ eventName ) ; } $ this -> _listeners [ $ eventName ] [ $ priorit...
Add event listener for specified event name with priority
5,648
public function dispatchEvent ( $ event , $ parameters = array ( ) ) { if ( is_string ( $ event ) ) { $ event = new BaseEvent ( $ event , $ parameters ) ; } $ eventName = $ event -> getName ( ) ; $ event -> setDispatcher ( $ this ) ; if ( $ this -> hasListeners ( $ eventName ) ) { foreach ( $ this -> _listeners [ $ eve...
Dispatch event to all listener subscribed
5,649
public function isUnread ( User $ user ) { if ( $ this -> posts -> count ( ) === 0 ) { return false ; } return $ this -> posts -> last ( ) -> isUnread ( $ user ) ; }
Gets whether the user has read this thread since the last post
5,650
public function postBatch ( ) { $ fp = fsockopen ( $ this -> hostname , $ this -> port , $ errno , $ errstr , 30 ) ; if ( FALSE === $ fp ) { throw new \ RuntimeException ( $ errstr , $ errno ) ; } for ( $ i = 0 , $ c = count ( $ this -> buffer ) ; $ i < $ c ; $ i ++ ) { $ message = $ this -> buffer [ $ i ] ; $ request ...
Posts all the messages as a batch .
5,651
function output ( $ o ) { if ( is_array ( $ o ) ) { $ this -> response -> setContent ( json_encode ( $ o ) ) ; $ this -> response -> headers -> set ( 'Content-Type' , 'application/json' ) ; die ( ) ; } else { $ this -> response -> setContent ( $ o ) ; } }
Outputs to screen . If param is an array then json headers + data are generated .
5,652
protected function setDataEditSettings ( ) { foreach ( array ( 'settings.tags' , 'settings.protocols' ) as $ field ) { $ data = $ this -> getData ( $ field ) ; if ( is_array ( $ data ) ) { $ this -> setData ( $ field , implode ( ',' , $ data ) ) ; } } }
Prepare an set template variables
5,653
public function getConvertedSourceValue ( ) { $ currency = $ this -> getCurrency ( ) ; $ value = $ this -> getSourceValue ( ) ; if ( $ currency != $ value -> getCurrency ( ) ) { $ value = Converter :: get ( ) -> convert ( $ value , $ currency ) ; } return $ value ; }
Converts the currency of getSourceValue if the currency is different Uses Converter class
5,654
public function exists ( $ index ) { $ request = $ this -> createRequestInstance ( self :: INDEX_EXIST , $ index , null ) ; try { $ this -> client -> send ( $ request ) ; } catch ( ClientException $ exception ) { return false ; } return true ; }
Checks if an index exists
5,655
public function create ( $ index , $ body = null ) { $ request = $ this -> createRequestInstance ( self :: INDEX_CREATE , $ index , null ) ; if ( null !== $ body ) { $ request -> setBody ( $ body ) ; } return $ this -> client -> send ( $ request ) ; }
Creates an index .
5,656
public function delete ( $ index ) { $ request = $ this -> createRequestInstance ( self :: INDEX_DELETE , $ index , null ) ; return $ this -> client -> send ( $ request ) ; }
deletes an index .
5,657
public function refresh ( $ index ) { $ request = $ this -> createRequestInstance ( self :: INDEX_REFRESH , $ index , null ) ; return $ this -> client -> send ( $ request ) ; }
refreshes an index .
5,658
public function getAliases ( $ index = null ) { $ request = $ this -> createRequestInstance ( self :: INDEX_GET_ALIASES , $ index , null ) ; return $ this -> client -> send ( $ request ) ; }
Gets all aliases based on indices .
5,659
public function updateAliases ( array $ aliasActions ) { if ( ! isset ( $ aliasActions [ 'actions' ] ) ) { throw new RepositoryException ( 'Actions key is missing' ) ; } $ request = $ this -> createRequestInstance ( self :: INDEX_UPDATE_ALIASES , null , null ) ; $ request -> setBody ( $ aliasActions ) ; return $ this -...
Updates aliases by given actions
5,660
public function editorAction ( ) { $ model = $ this -> getModel ( ) ; $ service = $ this -> getServiceLocator ( ) ; $ factory = $ service -> get ( 'Grid\Menu\Model\Menu\StructureFactory' ) ; return array ( 'locale' => $ this -> getAdminLocale ( ) , 'forest' => $ model -> findRenderList ( ) , 'types' => array_filter ( a...
Menu - editor
5,661
protected function getForm ( StructureInterface $ structure ) { $ service = $ this -> getServiceLocator ( ) -> get ( 'Form' ) ; $ form = $ service -> create ( 'Grid\Menu\Meta\Base' ) ; $ meta = $ service -> get ( 'Grid\Menu\Meta\Type' ) ; $ type = $ structure -> getType ( ) ; if ( $ meta -> has ( $ type ) ) { foreach (...
Get form for menu - item structure
5,662
public function createAction ( ) { $ success = null ; $ params = $ this -> params ( ) ; $ request = $ this -> getRequest ( ) ; $ type = $ params -> fromRoute ( 'type' ) ; $ parent = $ params -> fromRoute ( 'parentId' , null ) ; $ menu = $ this -> getModel ( ) -> create ( array ( 'type' => $ type , ) ) ; $ form = $ this...
Create menu - item
5,663
public function editAction ( ) { $ success = null ; $ params = $ this -> params ( ) ; $ request = $ this -> getRequest ( ) ; $ menuId = $ params -> fromRoute ( 'menuId' ) ; $ menu = $ this -> getModel ( ) -> find ( $ menuId ) ; if ( empty ( $ menu ) ) { $ this -> getResponse ( ) -> setStatusCode ( 404 ) ; return ; } $ ...
Edit menu - item
5,664
public function get ( $ key ) { $ row = $ this -> db -> dal ( ) -> from ( $ this -> getTable ( ) ) -> where ( 'key' , $ key ) -> first ( ) ; if ( isset ( $ row [ 'value' ] ) ) { $ res = unserialize ( $ row [ 'value' ] ) ; if ( isset ( $ res [ '_dataType' ] ) && isset ( $ res [ 'input' ] ) ) return $ this -> types [ $ r...
Returns a value .
5,665
public static function open ( array $ options = [ ] ) { $ method = array_get ( $ options , 'method' , 'post' ) ; $ attributes [ 'method' ] = self :: getMethod ( $ method ) ; $ attributes [ 'action' ] = self :: getAction ( $ options ) ; $ attributes [ 'accept-charset' ] = array_get ( $ options , 'charset' , 'UTF-8' ) ; ...
function to open the form .
5,666
protected static function getAction ( array $ options ) { if ( array_has ( $ options , 'url' ) ) { return 'http://' . array_get ( $ options , 'url' ) ; } if ( array_has ( $ options , 'secure' ) ) { return 'https://' . array_get ( $ options , 'secure' ) ; } if ( array_has ( $ options , 'route' ) ) { return path ( ) . ar...
Function to set the method .
5,667
public static function checked ( $ type , $ name , $ checked = false , $ options = [ ] ) { if ( ! isset ( $ options [ 'name' ] ) ) { $ options [ 'name' ] = $ name ; } $ id = self :: getIdAttribute ( $ name , $ options ) ; $ merge = compact ( 'type' , 'value' , 'id' ) ; $ options = array_merge ( $ options , $ merge ) ; ...
Create a form checked field .
5,668
protected static function exclure ( & $ options , $ args = [ 'type' , 'value' , 'name' ] ) { foreach ( $ options as $ key => $ option ) { if ( array_has ( $ args , $ key ) ) { unset ( $ options [ $ key ] ) ; } } }
Exclure main input arguments from array .
5,669
public static function token ( ) { self :: $ csrfToken = ! empty ( self :: $ csrfToken ) ? self :: $ csrfToken : Session :: token ( ) ; return self :: hidden ( '_token' , self :: $ csrfToken ) ; }
Create a form csrf input hidden .
5,670
public static function password ( $ name , $ value = null , array $ options = [ ] ) { self :: exclure ( $ options ) ; return self :: input ( 'password' , $ name , $ value , $ options ) ; }
function to create form password input .
5,671
public static function email ( $ name , $ value = null , array $ options = [ ] ) { self :: exclure ( $ options ) ; return self :: input ( 'email' , $ name , $ value , $ options ) ; }
generate form input email .
5,672
public static function url ( $ name , $ value = null , array $ options = [ ] ) { self :: exclure ( $ options ) ; return self :: input ( 'url' , $ name , $ value , $ options ) ; }
generate a url form input .
5,673
public static function file ( $ name , $ options = [ ] ) { self :: exclure ( $ options ) ; return self :: input ( 'file' , $ name , null , $ options ) ; }
generate a file input field .
5,674
public static function textarea ( $ name , $ value = null , array $ options = [ ] ) { self :: exclure ( $ options ) ; $ options = self :: setTextAreaSize ( $ options ) ; $ options [ 'id' ] = self :: getIdAttribute ( $ name , $ options ) ; $ options [ 'name' ] = $ name ; unset ( $ options [ 'size' ] ) ; $ options = Html...
generate a textarea input field .
5,675
public static function setTextAreaSize ( $ options ) { if ( isset ( $ options [ 'size' ] ) ) { return self :: setQuickTextAreaSize ( $ options ) ; } $ cols = array_get ( $ options , 'cols' , 50 ) ; $ rows = array_get ( $ options , 'rows' , 10 ) ; return array_merge ( $ options , compact ( 'cols' , 'rows' ) ) ; }
set a textarea size from options .
5,676
public static function setQuickTextAreaSize ( $ options ) { $ value = explode ( 'x' , $ options [ 'size' ] ) ; if ( count ( $ value ) < 2 ) { return array_merge ( $ options , [ 'cols' => 50 , 'rows' => 10 ] ) ; } elseif ( ! is_numeric ( $ value [ 0 ] ) || ! is_numeric ( $ value [ 1 ] ) ) { return array_merge ( $ option...
get a textarea size from string option .
5,677
public static function select ( $ name , $ list = [ ] , $ selected = null , $ options = [ ] ) { self :: exclure ( $ options , [ 'name' ] ) ; $ options [ 'name' ] = $ name ; $ sub = '' ; if ( ! empty ( $ list ) ) { foreach ( $ list as $ value ) { $ sub .= self :: option ( $ value , ( ! is_null ( $ selected ) && $ value ...
generate a select input field .
5,678
public static function checkbox ( $ name , $ checked = false , $ options = [ ] ) { self :: exclure ( $ options ) ; return self :: checked ( 'checkbox' , $ name , $ checked , $ options ) ; }
Set a form checkbox .
5,679
public static function radio ( $ name , $ checked = false , $ options = [ ] ) { self :: exclure ( $ options , [ 'value' ] ) ; return self :: checked ( 'radio' , $ name , $ checked , $ options ) ; }
Set a form radio .
5,680
public static function image ( $ url , $ name = null , $ options = [ ] ) { $ options [ 'src' ] = $ url ; self :: exclure ( $ options ) ; return self :: input ( 'image' , $ name , null , $ options ) ; }
generate a file image field .
5,681
public static function reset ( $ value , array $ options = [ ] ) { self :: exclure ( $ options , [ 'type' , 'value' ] ) ; return self :: input ( 'reset' , 'null' , $ value , $ options ) ; }
function to genenrate reset .
5,682
public static function submit ( $ value , array $ options = [ ] ) { self :: exclure ( $ options , [ 'type' , 'value' ] ) ; return self :: input ( 'submit' , 'null' , $ value , $ options ) ; }
function to genenrate submit .
5,683
public static function label ( $ name , $ value = null , array $ options = [ ] ) { self :: exclure ( $ options , [ 'value' , 'for' ] ) ; self :: $ labels [ ] = $ name ; $ value = e ( self :: formatLabel ( $ name , $ value ) ) ; $ options = Html :: attributes ( $ options ) ; return '<label for="' . $ name . '"' . $ opti...
Create a form label .
5,684
public static function AddKernelCommands ( $ app ) { self :: setKernelClasses ( ) ; foreach ( self :: $ kernelCommands as $ value ) { $ app -> add ( new $ value ( ) ) ; } }
Add all kernel command classes to console .
5,685
public static function AddUserCommands ( $ app ) { self :: setUserClasses ( ) ; if ( ! is_null ( self :: $ userCommands ) ) { foreach ( self :: $ userCommands as $ value ) { $ app -> add ( new $ value ( ) ) ; } } }
Add all user command classes to console .
5,686
public static function getUserClasses ( ) { $ classes = [ ] ; $ namespace = "Vinala\App\Support\Lumos" ; foreach ( get_declared_classes ( ) as $ value ) { if ( str_contains ( $ value , $ namespace ) ) { $ classes [ ] = $ value ; } } return $ classes ; }
Search for commmand classes of user .
5,687
public static function getKernelClasses ( ) { $ classes = [ ] ; $ namespace = "Vinala\Kernel\Console\Commands" ; foreach ( get_declared_classes ( ) as $ value ) { if ( \ Strings :: contains ( $ value , $ namespace ) ) { $ classes [ ] = $ value ; } } return $ classes ; }
Search for commmand classes of kernel .
5,688
public function convertToRcon ( ) { $ header = pack ( 'VV' , $ this -> id , $ this -> type ) ; return $ header . $ this -> body . pack ( 'HH' , 0x00 , 0x00 ) ; }
Converts the packet to RCON format
5,689
public static function createFromRcon ( $ data ) { if ( mb_strlen ( $ data ) < 10 ) { throw new Exception \ InvalidPacket ( 'Packet data length is less than 10 bytes' ) ; } if ( ! ( $ packet = @ unpack ( 'V1id/V1type/a*body' , $ data ) ) ) { throw new Exception \ InvalidPacket ( 'Packet data cannot be unpacked' ) ; } i...
Creates a new package from raw RCON data
5,690
public static function addRule ( $ path , $ callback , $ args = array ( ) , $ successOn = true ) { return self :: $ rules = Hash :: insert ( self :: $ rules , $ path , array ( $ callback , $ args , $ successOn ) ) ; }
Adds a new rule definition .
5,691
public static function is ( ) { $ args = func_get_args ( ) ; if ( ! empty ( self :: $ __mockedInstance ) && ! empty ( self :: $ __mockedInstance -> parametersMatchers ) ) { foreach ( self :: $ __mockedInstance -> parametersMatchers as $ parametersMatcher ) { if ( $ args == $ parametersMatcher ) { return call_user_func_...
Run the rules defined by paths . By default the AND conjunction is assumed when 2 or more paths are passed .
5,692
public static function isOnline ( $ host = 'google.com' , $ force = false ) { static $ hosts = array ( ) ; if ( $ force || ! array_key_exists ( $ host , $ hosts ) ) { $ hosts [ $ host ] = ! in_array ( gethostbyname ( $ host ) , array ( $ host , false ) ) ; } return $ hosts [ $ host ] ; }
Check if given host is online .
5,693
public static function path ( $ stack = false ) { if ( false === $ stack ) { return __FILE__ ; } if ( ! defined ( 'DEBUG_BACKTRACE_IGNORE_ARGS' ) ) { define ( 'DEBUG_BACKTRACE_IGNORE_ARGS' , 2 ) ; } $ trace = debug_backtrace ( DEBUG_BACKTRACE_IGNORE_ARGS ) ; if ( empty ( $ trace [ $ stack ] ) ) { throw new Exception ( ...
Path of current file or backtrace s file .
5,694
public static function plugin ( $ pwd = null ) { if ( empty ( $ pwd ) ) { $ pwd = self :: path ( ) ; } $ plugins = CakePlugin :: loaded ( ) ; if ( array_keys ( self :: $ _plugins ) != $ plugins ) { self :: $ _plugins = array ( ) ; foreach ( $ plugins as $ plugin ) { self :: $ _plugins [ $ plugin ] = CakePlugin :: path ...
Identify current plugin .
5,695
public static function pluginPrefix ( $ prefix , $ plugin = null ) { if ( empty ( $ plugin ) ) { $ plugin = self :: plugin ( self :: path ( 1 ) ) ; } $ prefixes = array_flip ( ( array ) Configure :: read ( $ plugin . '.routingPrefixes' ) ) ; if ( ! array_key_exists ( $ prefix , $ prefixes ) ) { return $ prefix ; } retu...
Gets the custom prefix for any given plugin s built - in prefix . Defaults to the original plugin s prefix if none is defined .
5,696
public static function reload ( ) { if ( empty ( self :: $ _initialState ) ) { foreach ( ( array ) Configure :: read ( 'Routing.prefixes' ) as $ prefix ) { self :: addRule ( 'Page.' . $ prefix , array ( 'self' , '__isPage' ) , $ prefix ) ; } self :: $ _initialState = get_class_vars ( 'Reveal' ) ; return ; } foreach ( s...
Reloads default Reveal rules . Resets all class variables and removes all non - default rules .
5,697
public static function version ( $ plugin = null ) { if ( empty ( $ plugin ) ) { try { $ plugin = self :: plugin ( self :: path ( true ) ) ; } catch ( Exception $ e ) { } } if ( empty ( $ plugin ) ) { throw new Exception ( ) ; } $ name = $ plugin . '.version' ; if ( ! Configure :: check ( $ name ) ) { $ versionPath = C...
Used to determine the current plugin s version .
5,698
protected static function _execute ( $ rule ) { if ( ! isset ( $ rule [ 2 ] ) ) { $ rule [ 2 ] = true ; } if ( ! isset ( $ rule [ 1 ] ) ) { $ rule [ 1 ] = array ( ) ; } list ( $ callback , $ args , $ successOn ) = $ rule ; if ( ! is_callable ( $ callback ) ) { if ( is_array ( $ callback ) ) { $ callback = implode ( '::...
Executes a rule s callback by passing the arguments and comparing the result to the successOn value .
5,699
protected function getHttpClient ( ) { $ options = [ 'base_url' => 'https://api.bitbucket.org' , 'api_version' => '1.0' , 'verify_peer' => true , ] ; $ client = new Client ( $ options ) ; $ client -> addListener ( new NormalizeArrayListener ( ) ) ; return $ client ; }
Get the http client .