idx
int64 0
60.3k
| question
stringlengths 64
4.24k
| target
stringlengths 5
618
|
|---|---|---|
12,600
|
protected function getRestResource ( ) { $ parentResource = $ this -> getParentResource ( ) ; if ( $ parentResource !== null ) { $ childResource = $ parentResource -> getChildResource ( $ this -> matchingUrl ) ; if ( $ childResource ) { $ childResource -> setUrlHandler ( $ this ) ; return $ childResource ; } } $ className = $ this -> apiResourceClassName ; $ resource = new $ className ( $ this -> getParentResource ( ) ) ; $ resource -> setUrlHandler ( $ this ) ; return $ resource ; }
|
Gets the RestResource object
|
12,601
|
public function addNodeType ( NodeTypeContract $ nodeType ) { if ( ! $ this -> hasNodeType ( $ nodeType -> getKey ( ) ) ) { $ this -> put ( $ nodeType -> getKey ( ) , $ nodeType ) ; } }
|
Adds a node type to the bag
|
12,602
|
public function get_cron ( $ id ) : ? array { if ( $ this -> check ( ) && ( $ data = $ this -> db -> rselect ( $ this -> table , [ ] , [ 'id' => $ id ] ) ) ) { $ data [ 'cfg' ] = json_decode ( $ data [ 'cfg' ] , 1 ) ; return $ data ; } return null ; }
|
Returns the full row as an indexed array for the given CRON ID .
|
12,603
|
public function start ( $ id_cron ) : bool { $ res = false ; if ( $ this -> check ( ) && ( $ cron = $ this -> get_cron ( $ id_cron ) ) ) { bbn \ appui \ history :: disable ( ) ; $ start = date ( 'Y-m-d H:i:s' ) ; if ( $ this -> db -> update ( $ this -> table , [ 'prev' => $ start , 'next' => date ( 'Y-m-d H:i:s' , $ this -> get_next_date ( $ cron [ 'cfg' ] [ 'frequency' ] ) ) ] , [ 'id' => $ id_cron ] ) ) { $ res = true ; } bbn \ appui \ history :: enable ( ) ; } return $ res ; }
|
Writes in the given CRON row the next start time the current as previous and the new running status .
|
12,604
|
public function finish ( $ id , $ res = '' ) { if ( ( $ article = $ this -> get_article ( $ id ) ) && ( $ cron = $ this -> get_cron ( $ article [ 'id_cron' ] ) ) ) { bbn \ appui \ history :: disable ( ) ; $ time = $ this -> timer -> has_started ( 'cron_' . $ article [ 'id_cron' ] ) ? $ this -> timer -> stop ( 'cron_' . $ article [ 'id_cron' ] ) : 0 ; if ( ! empty ( $ res ) ) { bbn \ x :: hdump ( $ id , $ res ) ; $ this -> db -> update ( $ this -> jtable , [ 'finish' => date ( 'Y-m-d H:i:s' ) , 'duration' => $ time , 'res' => $ res ] , [ 'id' => $ id ] ) ; } else { $ this -> db -> delete ( $ this -> jtable , [ 'id' => $ id ] ) ; $ prev = $ this -> db -> rselect ( $ this -> jtable , [ 'res' , 'id' ] , [ 'id_cron' => $ article [ 'id_cron' ] ] , [ 'finish' => 'DESC' ] ) ; if ( $ prev [ 'res' ] === 'error' ) { $ this -> db -> update ( $ this -> jtable , [ 'res' => 'Restarted after error' ] , [ 'id' => $ prev [ 'id' ] ] ) ; } } bbn \ appui \ history :: enable ( ) ; return $ time ; } return false ; }
|
Writes in the given CRON row the duration and the new finished status .
|
12,605
|
public function get_next ( $ id_cron = null ) : ? array { if ( $ this -> check ( ) && ( $ data = $ this -> db -> get_row ( " SELECT * FROM {$this->table} WHERE `active` = 1 AND `next` < NOW()" . ( bbn \ str :: is_uid ( $ id_cron ) ? " AND `id` = '$id_cron'" : '' ) . " ORDER BY `priority` ASC, `next` ASC LIMIT 1" ) ) ) { $ data [ 'cfg' ] = json_decode ( $ data [ 'cfg' ] , 1 ) ; return $ data ; } }
|
Returns the whole row for the next CRON to be executed from now if there is any .
|
12,606
|
public function beforeValidate ( ) { $ model = $ this -> owner ; foreach ( $ this -> attributes as $ attr => $ options ) { $ this -> ensureAttributes ( $ attr , $ options ) ; if ( $ file = UploadedFile :: getInstance ( $ model , $ attr ) ) { $ model -> { $ attr } = $ file ; } } }
|
function for EVENT_BEFORE_VALIDATE
|
12,607
|
private function checkAttrExists ( $ attribute ) { foreach ( $ this -> attributes as $ attr => $ options ) { $ this -> ensureAttributes ( $ attr , $ options ) ; if ( $ attr == $ attribute ) { return ; } } throw new InvalidParamException ( ) ; }
|
Check isset attribute or not
|
12,608
|
public static function definition ( ) { static $ def = array ( 'fields' => array ( 'id' => array ( 'name' => 'ID' , 'datatype' => 'integer' , 'default' => 0 , 'required' => true ) , 'language_id' => array ( 'name' => 'LanguageID' , 'datatype' => 'integer' , 'default' => 0 , 'required' => true ) , 'created' => array ( 'name' => 'Created' , 'datatype' => 'integer' , 'default' => 0 , 'required' => true ) , 'modified' => array ( 'name' => 'Modified' , 'datatype' => 'integer' , 'default' => 0 , 'required' => true ) , 'user_id' => array ( 'name' => 'UserID' , 'datatype' => 'integer' , 'default' => 0 , 'required' => true ) , 'session_key' => array ( 'name' => 'SessionKey' , 'datatype' => 'string' , 'default' => '' , 'required' => true ) , 'ip' => array ( 'name' => 'IPAddress' , 'datatype' => 'string' , 'default' => '' , 'required' => true ) , 'contentobject_id' => array ( 'name' => 'ContentObjectID' , 'datatype' => 'integer' , 'default' => 0 , 'required' => true ) , 'parent_comment_id' => array ( 'name' => 'ParentCommentID' , 'datatype' => 'integer' , 'default' => 0 , 'required' => true ) , 'name' => array ( 'name' => 'Name' , 'datatype' => 'string' , 'default' => '' , 'required' => true ) , 'email' => array ( 'name' => 'EMail' , 'datatype' => 'string' , 'default' => '' , 'required' => true ) , 'url' => array ( 'name' => 'URL' , 'datatype' => 'string' , 'default' => '' , 'required' => true ) , 'text' => array ( 'name' => 'Text' , 'datatype' => 'string' , 'default' => '' , 'required' => true ) , 'status' => array ( 'name' => 'Status' , 'datatype' => 'integer' , 'default' => 0 , 'required' => true ) , 'title' => array ( 'name' => 'Title' , 'datatype' => 'string' , 'default' => '' , 'required' => true ) ) , 'keys' => array ( 'id' ) , 'function_attributes' => array ( 'contentobject' => 'contentObject' ) , 'increment_key' => 'id' , 'class_name' => 'ezcomComment' , 'name' => 'ezcomment' ) ; return $ def ; }
|
Fields definition .
|
12,609
|
static function fetchByEmail ( $ email , $ sorts = null , $ offset = null , $ length = null , $ status = false ) { $ cond = array ( ) ; $ cond [ 'email' ] = $ email ; if ( $ status !== false ) { $ cond [ 'status' ] = $ status ; } $ limit = null ; if ( ! is_null ( $ offset ) ) { $ limit = array ( ) ; $ limit = array ( 'offset' => $ offset , 'length' => $ length ) ; } $ return = eZPersistentObject :: fetchObjectList ( self :: definition ( ) , null , $ cond , $ sorts , $ limit ) ; return $ return ; }
|
fetch comment by email
|
12,610
|
static function fetchByContentObjectID ( $ contentObjectID , $ languageID , $ status = null , $ sorts = null , $ offset = null , $ length = null ) { $ cond = array ( ) ; $ cond [ 'contentobject_id' ] = $ contentObjectID ; if ( $ languageID !== false ) { $ cond [ 'language_id' ] = $ languageID ; } if ( ! is_null ( $ status ) ) { $ cond [ 'status' ] = $ status ; } if ( is_null ( $ offset ) || is_null ( $ length ) ) { return null ; } else { $ limit = array ( 'offset' => $ offset , 'length' => $ length ) ; $ return = eZPersistentObject :: fetchObjectList ( self :: definition ( ) , null , $ cond , $ sorts , $ limit ) ; return $ return ; } }
|
fetch comment list by contentobject id
|
12,611
|
static function countByContent ( $ contentObjectID = false , $ languageID = false , $ status = null ) { $ cond = array ( ) ; if ( $ contentObjectID !== false ) { $ cond [ 'contentobject_id' ] = $ contentObjectID ; } if ( $ languageID !== false ) { $ cond [ 'language_id' ] = $ languageID ; } if ( ! is_null ( $ status ) ) { $ cond [ 'status' ] = $ status ; } return eZPersistentObject :: count ( self :: definition ( ) , $ cond ) ; }
|
Count the comments by content object id
|
12,612
|
static function countContentObjectByEmail ( $ email , $ status = false ) { $ statusString = "" ; if ( $ status !== false ) { $ statusString = " AND status = $status" ; } $ sql = "SELECT COUNT(*) as row_count FROM " . "( SELECT DISTINCT contentobject_id, language_id " . " FROM ezcomment " . " WHERE email='$email'" . "$statusString" . ") as contentobject" ; $ db = eZDB :: instance ( ) ; $ result = $ db -> arrayQuery ( $ sql ) ; return $ result [ 0 ] [ 'row_count' ] ; }
|
Fetch the count of contentobject the user commented on
|
12,613
|
public static function forks ( $ number , callable $ childHandler = null ) { $ num = ( int ) $ number > 0 ? ( int ) $ number : 0 ; if ( $ num <= 0 ) { return false ; } $ pidAry = [ ] ; for ( $ id = 0 ; $ id < $ num ; $ id ++ ) { $ child = self :: fork ( $ id , $ childHandler ) ; $ pidAry [ $ child [ 'pid' ] ] = $ child ; } return $ pidAry ; }
|
fork multi child processes .
|
12,614
|
public static function fork ( $ id = 0 , callable $ childHandler = null ) { $ info = [ ] ; $ pid = pcntl_fork ( ) ; if ( $ pid > 0 ) { $ info = [ 'id' => $ id , 'pid' => $ pid , 'startTime' => time ( ) , ] ; } elseif ( $ pid === 0 ) { $ pid = getmypid ( ) ; if ( $ childHandler ) { $ childHandler ( $ id , $ pid ) ; } } else { Cli :: stderr ( "Fork child process failed! exiting.\n" ) ; } return $ info ; }
|
fork a child process .
|
12,615
|
public static function kill ( $ pid , $ force = false , $ timeout = 3 ) { return self :: sendSignal ( $ pid , $ force ? SIGKILL : SIGTERM , $ timeout ) ; }
|
send kill signal to the process
|
12,616
|
public static function changeScriptOwner ( $ user , $ group = '' ) { $ uInfo = posix_getpwnam ( $ user ) ; if ( ! $ uInfo || ! isset ( $ uInfo [ 'uid' ] ) ) { throw new \ RuntimeException ( "User ({$user}) not found." ) ; } $ uid = ( int ) $ uInfo [ 'uid' ] ; if ( $ group ) { if ( ! $ gInfo = posix_getgrnam ( $ group ) ) { throw new \ RuntimeException ( "Group {$group} not exists" , - 300 ) ; } $ gid = ( int ) $ gInfo [ 'gid' ] ; } else { $ gid = ( int ) $ uInfo [ 'gid' ] ; } if ( ! posix_initgroups ( $ uInfo [ 'name' ] , $ gid ) ) { throw new \ RuntimeException ( "The user [{$user}] is not in the user group ID [GID:{$gid}]" , - 300 ) ; } posix_setgid ( $ gid ) ; if ( posix_geteuid ( ) !== $ gid ) { throw new \ RuntimeException ( "Unable to change group to {$user} (UID: {$gid})." , - 300 ) ; } posix_setuid ( $ uid ) ; if ( posix_geteuid ( ) !== $ uid ) { throw new \ RuntimeException ( "Unable to change user to {$user} (UID: {$uid})." , - 300 ) ; } }
|
Set unix user and group for current process script .
|
12,617
|
public static function getPidFromFile ( $ pidFile , $ check = false ) { if ( $ pidFile && file_exists ( $ pidFile ) ) { $ pid = ( int ) file_get_contents ( $ pidFile ) ; if ( $ check && self :: isRunning ( $ pid ) ) { return $ pid ; } unlink ( $ pidFile ) ; } return 0 ; }
|
get Pid from File
|
12,618
|
public function toString ( ) { return sprintf ( 'Pop Source Object [host:\'%s\'][port:\'%s\'][user:\'%s\']' , $ this -> sourceConfig -> getHost ( ) , $ this -> sourceConfig -> getPort ( ) , $ this -> sourceConfig -> getUsername ( ) ) ; }
|
Returns a string representation for the source object
|
12,619
|
public static function form ( $ slug , $ name = '' , array $ attributes = [ ] ) { $ class_name = get_called_class ( ) ; $ instance = $ class_name :: get_instance ( ) ; $ instance -> form_open ( $ attributes ) ; $ args = $ instance -> form_arguments ( ) ; $ instance -> load_template ( $ slug , $ name , $ args ) ; $ instance -> form_close ( ) ; }
|
Display form control
|
12,620
|
public function encodeMethod ( $ method , $ params ) { $ string = $ this -> encoder -> encodeMethod ( $ method , $ params ) ; return $ this -> encrypt ( $ string ) ; }
|
Encode a method call .
|
12,621
|
public function encodeException ( \ Exception $ exception ) { $ string = $ this -> encoder -> encodeException ( $ exception ) ; try { return $ this -> encrypt ( $ string ) ; } catch ( \ Exception $ e ) { if ( $ this -> plainExceptions ) { return $ string ; } throw $ e ; } }
|
Encode an exception .
|
12,622
|
public function encodeResult ( $ result ) { $ string = $ this -> encoder -> encodeResult ( $ result ) ; return $ this -> encrypt ( $ string ) ; }
|
Encode a result from the method call .
|
12,623
|
public function decodeMethod ( $ crypt ) { $ string = $ this -> decrypt ( $ crypt ) ; return $ this -> encoder -> decodeMethod ( $ string ) ; }
|
Decode an encoded method .
|
12,624
|
public function decodeResult ( $ crypt ) { $ string = $ this -> decrypt ( $ crypt ) ; return $ this -> encoder -> decodeResult ( $ string ) ; }
|
Decode an encoded result .
|
12,625
|
public function getContent ( ) { return new TextFileContent ( $ this -> content . ( $ this -> footer === "" ? "" : $ this -> footer . $ this -> newline ) ) ; }
|
Returns the chunked file s content . The content consists of the header then every chunk and then the footer .
|
12,626
|
public static function getImageConvertExecutable ( ) { if ( ! is_null ( self :: $ imageConvert ) ) { return self :: $ imageConvert ; } return ( self :: $ imageConvert = self :: findExecutableInPath ( 'convert' ) ) ; }
|
Returns the path to the ImageMagick convert utility .
|
12,627
|
public static function getImageIdentifyExecutable ( ) { if ( ! is_null ( self :: $ imageIdentify ) ) { return self :: $ imageIdentify ; } return ( self :: $ imageIdentify = self :: findExecutableInPath ( 'identify' ) ) ; }
|
Returns the path to the ImageMagick identify utility .
|
12,628
|
public static function hasExtensionSupport ( $ extension , $ version = null ) { if ( is_null ( $ version ) ) { return extension_loaded ( $ extension ) ; } return extension_loaded ( $ extension ) && version_compare ( phpversion ( $ extension ) , $ version , ">=" ) ; }
|
Determines if the specified extension is loaded .
|
12,629
|
public static function classExists ( $ className , $ autoload = true ) { try { if ( class_exists ( $ className , $ autoload ) ) { return true ; } return false ; } catch ( ezcBaseAutoloadException $ e ) { return false ; } }
|
Returns if a given class exists . Checks for a given class name and returns if this class exists or not . Catches the ezcBaseAutoloadException and returns false if it was thrown .
|
12,630
|
public static function os ( ) { if ( is_null ( self :: $ os ) ) { $ uname = php_uname ( 's' ) ; if ( substr ( $ uname , 0 , 7 ) == 'Windows' ) { self :: $ os = 'Windows' ; } elseif ( substr ( $ uname , 0 , 3 ) == 'Mac' ) { self :: $ os = 'Mac' ; } elseif ( strtolower ( $ uname ) == 'linux' ) { self :: $ os = 'Linux' ; } elseif ( strtolower ( substr ( $ uname , 0 , 7 ) ) == 'freebsd' ) { self :: $ os = 'FreeBSD' ; } else { self :: $ os = PHP_OS ; } } return self :: $ os ; }
|
Returns the operating system on which PHP is running .
|
12,631
|
public static function findExecutableInPath ( $ fileName ) { if ( array_key_exists ( 'PATH' , $ _ENV ) ) { $ envPath = trim ( $ _ENV [ 'PATH' ] ) ; } else if ( ( $ envPath = getenv ( 'PATH' ) ) !== false ) { $ envPath = trim ( $ envPath ) ; } if ( is_string ( $ envPath ) && strlen ( trim ( $ envPath ) ) == 0 ) { $ envPath = false ; } switch ( self :: os ( ) ) { case 'Unix' : case 'FreeBSD' : case 'Mac' : case 'MacOS' : case 'Darwin' : case 'Linux' : case 'SunOS' : if ( $ envPath ) { $ dirs = explode ( ':' , $ envPath ) ; foreach ( $ dirs as $ dir ) { if ( file_exists ( "{$dir}/{$fileName}" ) ) { return "{$dir}/{$fileName}" ; } } } elseif ( @ file_exists ( "./{$fileName}" ) ) { return $ fileName ; } break ; case 'Windows' : if ( $ envPath ) { $ dirs = explode ( ';' , $ envPath ) ; foreach ( $ dirs as $ dir ) { if ( @ file_exists ( "{$dir}\\{$fileName}.exe" ) ) { return "{$dir}\\{$fileName}.exe" ; } } } elseif ( @ file_exists ( "{$fileName}.exe" ) ) { return "{$fileName}.exe" ; } break ; } return null ; }
|
Returns the path of the specified executable if it can be found in the system s path .
|
12,632
|
public static function reset ( ) { self :: $ imageIdentify = null ; self :: $ imageConvert = null ; self :: $ os = null ; }
|
Reset the cached information .
|
12,633
|
private function writeLog ( $ log ) { $ fh = fopen ( $ this -> _filepath , 'a' ) ; fwrite ( $ fh , $ log ) ; fclose ( $ fh ) ; }
|
Writes log to media .
|
12,634
|
public function publishEventAdvice ( JoinPointInterface $ joinPoint ) { $ event = array_values ( $ joinPoint -> getMethodArguments ( ) ) [ 0 ] ; $ this -> broker -> queueEvent ( $ event ) ; }
|
Publishes an event as soon as a method with an event annotation is called .
|
12,635
|
public function assets ( $ args , $ assoc_args ) { list ( $ type ) = $ args ; $ global = self :: get_flag ( 'global' , $ assoc_args ) ; if ( false === array_search ( $ type , [ 'css' , 'js' ] ) ) { self :: e ( $ this -> __ ( 'Only css and js are supported.' ) ) ; } $ header = [ 'Handle' , 'Source' , 'Dependency' , 'Version' , 'css' === $ type ? 'Media' : 'Footer' , ] ; $ rows = [ ] ; if ( $ global ) { switch ( $ type ) { case 'js' : break ; case 'css' : break ; default : break ; } } else { $ assets = Library :: all_assets ( ) [ $ type ] ; foreach ( $ assets as $ handle => $ asset ) { $ rows [ ] = array_merge ( [ $ handle ] , array_map ( function ( $ var ) { if ( is_bool ( $ var ) ) { return $ var ? 'Yes' : 'No' ; } elseif ( is_array ( $ var ) ) { return empty ( $ var ) ? '-' : implode ( ', ' , $ var ) ; } elseif ( is_null ( $ var ) ) { return '-' ; } else { return $ var ; } } , $ asset ) ) ; } } self :: table ( $ header , $ rows ) ; self :: l ( '' ) ; self :: s ( sprintf ( '%d %s are available on WPametu.' , count ( $ rows ) , $ type ) ) ; }
|
Show all asset libraries of WPametu
|
12,636
|
public function akismet ( ) { try { if ( ! class_exists ( 'Akismet' ) ) { throw new \ Exception ( 'Akismet is not installed.' ) ; } if ( ! ( $ key = \ Akismet :: get_api_key ( ) ) ) { throw new \ Exception ( 'Akismet API key is not set.' ) ; } if ( 'valid' !== \ Akismet :: verify_key ( $ key ) ) { throw new \ Exception ( 'Akismet API key is invalid.' ) ; } static :: s ( 'Akismet is available!' ) ; } catch ( \ Exception $ e ) { static :: e ( $ e -> getMessage ( ) ) ; } }
|
Check if akismet is available
|
12,637
|
public function parse ( $ filename , ProjectDescriptorBuilder $ builder ) { if ( class_exists ( 'phpDocumentor\Event\Dispatcher' ) ) { Dispatcher :: getInstance ( ) -> dispatch ( 'parser.file.pre' , PreFileEvent :: createInstance ( $ this ) -> setFile ( $ filename ) ) ; } $ this -> log ( 'Starting to parse file: ' . $ filename ) ; try { $ file = $ this -> createFileReflector ( $ builder , $ filename ) ; if ( ! $ file ) { $ this -> log ( '>> Skipped file ' . $ filename . ' as no modifications were detected' ) ; return ; } $ file -> process ( ) ; $ builder -> buildFileUsingSourceData ( $ file ) ; $ this -> logErrorsForDescriptor ( $ builder -> getProjectDescriptor ( ) -> getFiles ( ) -> get ( $ file -> getFilename ( ) ) ) ; } catch ( Exception $ e ) { $ this -> log ( ' Unable to parse file "' . $ filename . '", an error was detected: ' . $ e -> getMessage ( ) , LogLevel :: ALERT ) ; } }
|
Parses the file identified by the given filename and passes the resulting FileDescriptor to the ProjectBuilder .
|
12,638
|
protected function createFileReflector ( ProjectDescriptorBuilder $ builder , $ filename ) { $ file = new FileReflector ( $ filename , $ this -> parser -> doValidation ( ) , $ this -> parser -> getEncoding ( ) ) ; $ file -> setDefaultPackageName ( $ this -> parser -> getDefaultPackageName ( ) ) ; $ file -> setMarkers ( $ this -> parser -> getMarkers ( ) ) ; $ file -> setFilename ( $ this -> getRelativeFilename ( $ filename ) ) ; $ cachedFiles = $ builder -> getProjectDescriptor ( ) -> getFiles ( ) ; $ hash = $ cachedFiles -> get ( $ file -> getFilename ( ) ) ? $ cachedFiles -> get ( $ file -> getFilename ( ) ) -> getHash ( ) : null ; return $ hash === $ file -> getHash ( ) && ! $ this -> parser -> isForced ( ) ? null : $ file ; }
|
Creates a new FileReflector for the given filename or null if the file contains no modifications .
|
12,639
|
protected function logErrorsForDescriptor ( FileDescriptor $ fileDescriptor ) { $ errors = $ fileDescriptor -> getAllErrors ( ) ; foreach ( $ errors as $ error ) { $ this -> log ( $ error -> getCode ( ) , $ error -> getSeverity ( ) , $ error -> getContext ( ) ) ; } }
|
Writes the errors found in the Descriptor to the log .
|
12,640
|
public function getRelativeFilename ( $ filename ) { $ result = ltrim ( substr ( $ filename , strlen ( $ this -> parser -> getPath ( ) ) ) , DIRECTORY_SEPARATOR ) ; if ( $ result === '' ) { throw new \ InvalidArgumentException ( 'File is not present in the given project path: ' . $ filename ) ; } return $ result ; }
|
Returns the filename relative to the root of the project directory .
|
12,641
|
public static function zip ( $ i , $ o , $ del = false , $ afilename = null , $ s = 0 ) { $ i = str_replace ( '\\' , '/' , $ i ) ; $ zp = new \ ZipArchive ( ) ; if ( file_exists ( $ o ) ) { $ flags = 0 ; } else { $ flags = \ ZipArchive :: CREATE ; } $ zp -> open ( $ o , $ flags ) ; $ afilename = ( is_string ( $ afilename ) ) ? $ afilename : basename ( $ i ) ; $ success = $ zp -> addFile ( $ i , $ afilename ) ; $ zp -> close ( ) ; if ( true === $ del ) unlink ( $ afilename ) ; if ( $ success ) { if ( $ s > 0 ) { return self :: split ( $ o , $ s ) ; } } else { return false ; } }
|
Compact a file in multipart zip archive .
|
12,642
|
protected static function split ( $ i , $ s ) { $ fs = filesize ( $ i ) ; $ p = 1 ; for ( $ c = 0 ; $ c < $ fs ; $ c = $ c + $ s ) { $ data = file_get_contents ( $ i , FILE_BINARY , null , $ c , $ s ) ; $ fn = "$i.$p" ; file_put_contents ( $ fn , $ data ) ; $ p ++ ; unset ( $ data ) ; } unlink ( $ i ) ; return $ p - 1 ; }
|
Split the zip archive .
|
12,643
|
public static function unzip ( $ i , $ o , $ p = 0 ) { $ success = true ; if ( $ p > 0 ) { $ success = self :: merge ( $ i , $ p ) ; } if ( $ success == false ) { return false ; } $ zp = new \ ZipArchive ( ) ; $ zp -> open ( $ i ) ; if ( $ zp -> extractTo ( $ o ) ) { $ zp -> close ( ) ; unset ( $ zp ) ; return true ; } else { return false ; } }
|
Decompact the zip archive .
|
12,644
|
protected static function merge ( $ i , $ p ) { for ( $ c = 1 ; $ c <= $ p ; $ c ++ ) { $ data = file_get_contents ( "$i.$c" ) ; file_put_contents ( $ i , $ data , FILE_APPEND ) ; unset ( $ data ) ; } return true ; }
|
Merge the parts of zip archive .
|
12,645
|
public static function isEncryptedZip ( $ pathToArchive ) { $ fp = @ fopen ( $ pathToArchive , 'r' ) ; $ encrypted = false ; if ( $ fp && fseek ( $ fp , 6 ) == 0 ) { $ string = fread ( $ fp , 2 ) ; if ( false !== $ string ) { $ data = unpack ( "vgeneral" , $ string ) ; $ encrypted = $ data [ 'general' ] & 0x01 ? true : false ; } fclose ( $ fp ) ; } return $ encrypted ; }
|
Check if the file is encrypted
|
12,646
|
public function generateObjectUrl ( $ name , $ object , array $ parameters = array ( ) , $ absolute = false ) { if ( $ name != 'list' ) { return parent :: generateObjectUrl ( $ name , $ object , $ parameters , $ absolute ) ; } return parent :: generateObjectUrl ( $ name , $ object -> getForm ( ) , $ parameters , $ absolute ) ; }
|
This is to create the correct route when going back to the form edit instead of the field list .
|
12,647
|
public function validate ( ErrorElement $ errorElement , $ field ) { if ( $ field -> getType ( ) == 'date' ) { $ formatter = new IntlDateFormatter ( null , null , null ) ; $ formatter -> setPattern ( 'd-M-y' ) ; if ( ! $ formatter -> parse ( $ field -> getDefault ( ) ) ) { $ errorElement -> with ( 'default' ) -> addViolation ( 'Dit is geen geldige standaardwaarde voor datum volgens formaat dag-maand-jaar' ) ; } } }
|
Add specific validation when default for type = date is entered .
|
12,648
|
public function getCategory ( ) { $ categoryModel = static :: getCategoryModel ( ) ; return ( $ this -> type == self :: TYPE_CATEGORY ) ? $ this -> hasOne ( $ categoryModel :: className ( ) , [ 'id' => $ this -> options -> category_id ] ) : null ; }
|
Only type TYPE_CATEGORY
|
12,649
|
public function receive ( ) { $ input = file_get_contents ( 'php://input' ) ; if ( $ this -> logger !== null && $ this -> logger -> isHandling ( Logger :: DEBUG ) ) { $ this -> logger -> addDebug ( 'Receive request' , array ( 'request' => ctype_print ( $ input ) ? $ input : 'base64:' . base64_encode ( $ input ) ) ) ; } return $ input ; }
|
Receive the serialized json request .
|
12,650
|
public function evaluate ( $ new , $ current ) { switch ( $ new -> tagName ) { case 'li' : return $ this -> handleLI ( $ new , $ current ) ; case 'dt' : case 'dd' : return $ this -> handleDT ( $ new , $ current ) ; case 'rt' : case 'rp' : return $ this -> handleRT ( $ new , $ current ) ; case 'optgroup' : return $ this -> closeIfCurrentMatches ( $ new , $ current , array ( 'optgroup' ) ) ; case 'option' : return $ this -> closeIfCurrentMatches ( $ new , $ current , array ( 'option' , 'optgroup' ) ) ; case 'tr' : return $ this -> closeIfCurrentMatches ( $ new , $ current , array ( 'tr' ) ) ; case 'td' : case 'th' : return $ this -> closeIfCurrentMatches ( $ new , $ current , array ( 'th' , 'td' ) ) ; case 'tbody' : case 'thead' : case 'tfoot' : case 'table' : return $ this -> closeIfCurrentMatches ( $ new , $ current , array ( 'thead' , 'tfoot' , 'tbody' ) ) ; } return $ current ; }
|
Evaluate the rule for the current tag name .
|
12,651
|
private function createManager ( OutputInterface $ output ) { try { return new Manager ( Manifest :: loadFile ( self :: MANIFEST_FILE ) ) ; } catch ( FileException $ e ) { $ output -> writeln ( '<error>Unable to search for updates.</error>' ) ; exit ( 1 ) ; } }
|
Returns manager instance or exit with status code 1 on failure .
|
12,652
|
private function updateCurrentVersion ( Manager $ manager , $ version , $ allowMajor , $ allowPreRelease , OutputInterface $ output ) { if ( $ manager -> update ( $ version , $ allowMajor , $ allowPreRelease ) ) { $ output -> writeln ( '<info>Updated to latest version.</info>' ) ; } else { $ output -> writeln ( '<comment>Already up-to-date.</comment>' ) ; } }
|
Updates current version .
|
12,653
|
public function html_with_label ( $ with_script = 1 ) { $ s = $ this -> html ( ) ; if ( ! empty ( $ s ) ) { if ( BBN_IS_DEV ) { $ title = str_replace ( '"' , '' , print_r ( bbn \ str :: make_readable ( $ this -> cfg ) , true ) ) ; } else if ( isset ( $ this -> attr [ 'title' ] ) ) { $ title = $ this -> attr [ 'title' ] ; } else { $ title = isset ( $ this -> label ) ? $ this -> label : '' ; } if ( ! isset ( $ this -> cfg [ 'field' ] ) || $ this -> cfg [ 'field' ] !== 'hidden' ) { $ s = '<label class="bbn-form-label" title="' . $ title . '" for="' . $ this -> attr [ 'id' ] . '">' . $ this -> label . '</label><div class="bbn-form-field">' . $ s . '</div>' ; } } return $ s ; }
|
Returns the element with its label and inside a div
|
12,654
|
protected function domainRouting ( ) { $ request = & $ this -> request ; if ( $ this -> routeGetRequestsOnly ) { $ selfClass = version_compare ( PHP_VERSION , '5.5' , '>' ) ? self :: class : __CLASS__ ; trigger_error ( "[" . $ selfClass . "] Routing only GET requests with special media " . "site version or localization conditions is not allowed in module router." , E_USER_WARNING ) ; $ this -> routeGetRequestsOnly = FALSE ; } $ allMatchedParams = [ ] ; foreach ( $ this -> domainRoutes as & $ route ) { $ allMatchedParams = $ route -> Matches ( $ request ) ; if ( $ allMatchedParams !== NULL ) { $ this -> currentDomainRoute = clone $ route ; $ this -> currentModule = $ this -> currentDomainRoute -> GetModule ( ) ; $ this -> currentDomainRoute -> SetMatchedParams ( $ allMatchedParams ) ; $ this -> domainRoutingSetRequestedAndDefaultParams ( $ allMatchedParams ) ; $ break = $ this -> domainRoutingFilterParams ( $ allMatchedParams ) ; $ this -> domainRoutingSetUpRouterByDomainRoute ( ) ; if ( $ break ) break ; } } }
|
Process routing by defined module domain routes . If any module domain route matches the request complete current domain route property and current domain module property and set up requested domain params and default domain params by matched domain route params .
|
12,655
|
public function getUrl ( $ url ) { if ( is_array ( $ url ) && ! empty ( $ url [ 'route' ] ) ) { try { $ Comet = \ CometPHP \ Comet :: getInstance ( ) ; } catch ( \ CometPHP \ Exceptions \ CometNotBooted $ e ) { return null ; } $ routeName = $ url [ 'route' ] ; unset ( $ url [ 'route' ] ) ; $ generatedUrl = $ Comet [ 'routeGenerator' ] -> generate ( $ routeName , $ url ) ; return $ generatedUrl ; } return $ url ; }
|
base function to return the url for the link method
|
12,656
|
private function build_src ( $ src ) { if ( ! preg_match ( '/^(https?:)?\/\//u' , $ src ) ) { $ src = trailingslashit ( $ this -> get_root_uri ( ) ) . ltrim ( $ src , '/' ) ; } return $ src ; }
|
Build URL for library
|
12,657
|
public function getCachedTemplate ( Dwoo $ dwoo ) { if ( $ this -> cacheTime !== null ) { $ cacheLength = $ this -> cacheTime ; } else { $ cacheLength = $ dwoo -> getCacheTime ( ) ; } if ( $ cacheLength === 0 ) { return false ; } $ cachedFile = $ this -> getCacheFilename ( $ dwoo ) ; if ( isset ( self :: $ cache [ 'cached' ] [ $ this -> cacheId ] ) === true && file_exists ( $ cachedFile ) ) { return $ cachedFile ; } elseif ( $ this -> compilationEnforced !== true && file_exists ( $ cachedFile ) && ( $ cacheLength === - 1 || filemtime ( $ cachedFile ) > ( $ _SERVER [ 'REQUEST_TIME' ] - $ cacheLength ) ) && $ this -> isValidCompiledFile ( $ this -> getCompiledFilename ( $ dwoo ) ) ) { self :: $ cache [ 'cached' ] [ $ this -> cacheId ] = true ; return $ cachedFile ; } else { return true ; } }
|
returns the cached template output file name true if it s cache - able but not cached or false if it s not cached
|
12,658
|
public function cache ( Dwoo $ dwoo , $ output ) { $ cacheDir = $ dwoo -> getCacheDir ( ) ; $ cachedFile = $ this -> getCacheFilename ( $ dwoo ) ; $ temp = tempnam ( $ cacheDir , 'temp' ) ; if ( ! ( $ file = @ fopen ( $ temp , 'wb' ) ) ) { $ temp = $ cacheDir . uniqid ( 'temp' ) ; if ( ! ( $ file = @ fopen ( $ temp , 'wb' ) ) ) { trigger_error ( 'Error writing temporary file \'' . $ temp . '\'' , E_USER_WARNING ) ; return false ; } } fwrite ( $ file , $ output ) ; fclose ( $ file ) ; $ this -> makeDirectory ( dirname ( $ cachedFile ) , $ cacheDir ) ; if ( ! @ rename ( $ temp , $ cachedFile ) ) { @ unlink ( $ cachedFile ) ; @ rename ( $ temp , $ cachedFile ) ; } if ( $ this -> chmod !== null ) { chmod ( $ cachedFile , $ this -> chmod ) ; } self :: $ cache [ 'cached' ] [ $ this -> cacheId ] = true ; return $ cachedFile ; }
|
caches the provided output into the cache file
|
12,659
|
public function clearCache ( Dwoo $ dwoo , $ olderThan = - 1 ) { $ cachedFile = $ this -> getCacheFilename ( $ dwoo ) ; return ! file_exists ( $ cachedFile ) || ( filectime ( $ cachedFile ) < ( time ( ) - $ olderThan ) && unlink ( $ cachedFile ) ) ; }
|
clears the cached template if it s older than the given time
|
12,660
|
public function getCompiledTemplate ( Dwoo $ dwoo , Dwoo_ICompiler $ compiler = null ) { $ compiledFile = $ this -> getCompiledFilename ( $ dwoo ) ; if ( $ this -> compilationEnforced !== true && isset ( self :: $ cache [ 'compiled' ] [ $ this -> compileId ] ) === true ) { } elseif ( $ this -> compilationEnforced !== true && $ this -> isValidCompiledFile ( $ compiledFile ) ) { self :: $ cache [ 'compiled' ] [ $ this -> compileId ] = true ; } else { $ this -> compilationEnforced = false ; if ( $ compiler === null ) { $ compiler = $ dwoo -> getDefaultCompilerFactory ( $ this -> getResourceName ( ) ) ; if ( $ compiler === null || $ compiler === array ( 'Dwoo_Compiler' , 'compilerFactory' ) ) { if ( class_exists ( 'Dwoo_Compiler' , false ) === false ) { include DWOO_DIRECTORY . 'Dwoo/Compiler.php' ; } $ compiler = Dwoo_Compiler :: compilerFactory ( ) ; } else { $ compiler = call_user_func ( $ compiler ) ; } } $ this -> compiler = $ compiler ; $ compiler -> setCustomPlugins ( $ dwoo -> getCustomPlugins ( ) ) ; $ compiler -> setSecurityPolicy ( $ dwoo -> getSecurityPolicy ( ) ) ; $ this -> makeDirectory ( dirname ( $ compiledFile ) , $ dwoo -> getCompileDir ( ) ) ; file_put_contents ( $ compiledFile , $ compiler -> compile ( $ dwoo , $ this ) ) ; if ( $ this -> chmod !== null ) { chmod ( $ compiledFile , $ this -> chmod ) ; } self :: $ cache [ 'compiled' ] [ $ this -> compileId ] = true ; } return $ compiledFile ; }
|
returns the compiled template file name
|
12,661
|
public static function templateFactory ( Dwoo $ dwoo , $ resourceId , $ cacheTime = null , $ cacheId = null , $ compileId = null , Dwoo_ITemplate $ parentTemplate = null ) { return new self ( $ resourceId , $ cacheTime , $ cacheId , $ compileId ) ; }
|
returns a new template string object with the resource id being the template source code
|
12,662
|
protected function getCacheFilename ( Dwoo $ dwoo ) { if ( $ this -> cacheId === null ) { if ( isset ( $ _SERVER [ 'REQUEST_URI' ] ) === true ) { $ cacheId = $ _SERVER [ 'REQUEST_URI' ] ; } elseif ( isset ( $ _SERVER [ 'SCRIPT_FILENAME' ] ) && isset ( $ _SERVER [ 'argv' ] ) ) { $ cacheId = $ _SERVER [ 'SCRIPT_FILENAME' ] . '-' . implode ( '-' , $ _SERVER [ 'argv' ] ) ; } else { $ cacheId = '' ; } $ this -> getCompiledFilename ( $ dwoo ) ; $ this -> cacheId = str_replace ( '../' , '__' , $ this -> compileId . strtr ( $ cacheId , '\\%?=!:;' . PATH_SEPARATOR , '/-------' ) ) ; } return $ dwoo -> getCacheDir ( ) . $ this -> cacheId . '.html' ; }
|
returns the full cached file name and assigns a default value to it if required
|
12,663
|
protected function makeDirectory ( $ path , $ baseDir = null ) { if ( is_dir ( $ path ) === true ) { return ; } if ( $ this -> chmod === null ) { $ chmod = 0777 ; } else { $ chmod = $ this -> chmod ; } mkdir ( $ path , $ chmod , true ) ; if ( strpos ( PHP_OS , 'WIN' ) !== 0 && $ baseDir !== null ) { $ path = strtr ( str_replace ( $ baseDir , '' , $ path ) , '\\' , '/' ) ; $ folders = explode ( '/' , trim ( $ path , '/' ) ) ; foreach ( $ folders as $ folder ) { $ baseDir .= $ folder . DIRECTORY_SEPARATOR ; chmod ( $ baseDir , $ chmod ) ; } } }
|
ensures the given path exists
|
12,664
|
private function resetResultset ( ) { if ( null !== $ this -> stmt ) { $ this -> stmt -> execute ( ) ; $ this -> result = $ this -> stmt -> get_result ( ) ; } }
|
Reset the resultset .
|
12,665
|
public function cronAction ( $ tabItem ) { $ this -> performAccessChecks ( ) ; return $ this -> render ( 'SmileEzUICronBundle:cron:index.html.twig' , [ 'tab_items' => $ this -> tabItems , 'tab_item_selected' => $ tabItem , 'params' => array ( ) , 'hasErrors' => false ] ) ; }
|
Render tab item content
|
12,666
|
public function get ( $ line ) { return isset ( $ this -> lines [ $ line - 1 ] ) ? $ this -> lines [ $ line - 1 ] : null ; }
|
Gets content of the line
|
12,667
|
public function render ( Varien_Object $ row ) { $ name = trim ( $ this -> getColumn ( ) -> getNamePattern ( ) ) ; if ( ! empty ( $ name ) ) { $ nameParams = array_map ( 'trim' , array_filter ( explode ( ',' , $ this -> getColumn ( ) -> getNameParams ( ) ) ) ) ; if ( count ( $ nameParams ) ) { $ params = [ $ name ] ; foreach ( $ nameParams as $ key ) { $ params [ ] = $ row -> getDataUsingMethod ( $ key ) ; } $ name = call_user_func_array ( [ $ this , '__' ] , $ params ) ; } $ this -> getColumn ( ) -> setName ( $ name ) ; } return parent :: render ( $ row ) ; }
|
Renders grid column
|
12,668
|
public function validateSchema ( $ schema = self :: STRICT_SCHEMA ) { $ content = file_get_contents ( $ this -> path ) ; $ data = json_decode ( $ content ) ; if ( null === $ data && 'null' !== $ content ) { self :: validateSyntax ( $ content , $ this -> path ) ; } $ schemaFile = __DIR__ . '/../../../res/composer-schema.json' ; $ schemaData = json_decode ( file_get_contents ( $ schemaFile ) ) ; if ( $ schema === self :: LAX_SCHEMA ) { $ schemaData -> additionalProperties = true ; $ schemaData -> required = array ( ) ; } $ validator = new Validator ( ) ; $ validator -> check ( $ data , $ schemaData ) ; if ( ! $ validator -> isValid ( ) ) { $ errors = array ( ) ; foreach ( ( array ) $ validator -> getErrors ( ) as $ error ) { $ errors [ ] = ( $ error [ 'property' ] ? $ error [ 'property' ] . ' : ' : '' ) . $ error [ 'message' ] ; } throw new JsonValidationException ( '"' . $ this -> path . '" does not match the expected JSON schema' , $ errors ) ; } return true ; }
|
Validates the schema of the current json file according to composer - schema . json rules
|
12,669
|
protected function routeDetectStrategy ( ) { list ( $ requestCtrlName , $ requestActionName ) = parent :: routeDetectStrategy ( ) ; if ( ! $ this -> internalRequest ) $ this -> domainRouting ( ) ; return [ $ requestCtrlName , $ requestActionName ] ; }
|
Process normal route strategy detection from core router and than process domain routing if request is not internal . Return array with possible query string controller name and action .
|
12,670
|
public function routeMatched ( $ request_type , $ route_pattern , $ query_path ) { $ matched = $ this -> app -> trigger ( 'system.request.route.matching' , array ( $ this , 'processRouteMatching' ) , array ( 'request_type' => $ request_type , 'query_path' => $ query_path , 'route_pattern' => $ route_pattern ) ) ; return $ matched ; }
|
check if a route is matched given a query path
|
12,671
|
public function findMatchedRoute ( $ request_method = "" , $ query_path = "" , $ route_map ) { $ query_path = $ this -> normalize ( $ query_path ) ; $ request_matched = false ; $ output = "" ; if ( count ( $ route_map ) > 0 ) { $ request_types = array_keys ( $ route_map ) ; $ request_types_to_lookup = array ( ) ; foreach ( $ request_types as $ request_type ) { if ( $ request_type == $ request_method || $ request_type == "*" ) { $ request_types_to_lookup [ ] = $ request_type ; } } foreach ( $ request_types_to_lookup as $ request_type ) { if ( isset ( $ route_map [ $ request_type ] ) && count ( $ route_map [ $ request_type ] ) > 0 ) { foreach ( $ route_map [ $ request_type ] as $ route_pattern => $ route ) { $ matched = $ this -> routeMatched ( $ request_type , $ route_pattern , $ query_path ) ; if ( $ matched ) { $ request_matched = true ; break 2 ; } } } } } return $ request_matched ; }
|
find a route
|
12,672
|
public function processRouteMatchingNative ( $ event ) { $ request_type = $ event -> props ( 'request_type' ) ; $ uri = $ event -> props ( 'query_path' ) ; $ route_pattern = $ event -> props ( 'route_pattern' ) ; $ result = false ; $ params = array ( ) ; $ route_pattern_length = strlen ( $ route_pattern ) ; $ path_pos = strpos ( $ route_pattern , "*path" ) ; if ( $ path_pos !== FALSE ) { $ first_part_of_path = substr ( $ route_pattern , 0 , $ path_pos ) ; if ( substr ( $ uri , 0 , $ path_pos ) == $ first_part_of_path ) { $ uri_length = strlen ( $ uri ) ; $ params [ ":path" ] = substr ( $ uri , $ path_pos , $ uri_length - $ path_pos ) ; $ route = $ this -> getRoute ( $ request_type , $ route_pattern ) ; $ route -> setParams ( $ params ) ; $ this -> setMatchedRoute ( $ route ) ; $ result = true ; return $ result ; } } $ uri_comps = explode ( "/" , $ uri ) ; $ uri_comps_count = count ( $ uri_comps ) ; $ route_pattern_comps = explode ( "/" , $ route_pattern ) ; $ route_pattern_comps_count = count ( $ route_pattern_comps ) ; if ( $ uri_comps_count == $ route_pattern_comps_count ) { for ( $ k = 1 ; $ k < $ route_pattern_comps_count ; $ k ++ ) { if ( $ route_pattern_comps [ $ k ] [ 0 ] == ":" ) { $ token = $ route_pattern_comps [ $ k ] ; $ params [ $ token ] = $ uri_comps [ $ k ] ; $ route_pattern_comps [ $ k ] = "" ; $ uri_comps [ $ k ] = "" ; } } $ uri_reformed = implode ( "/" , $ uri_comps ) ; $ route_pattern_reformed = implode ( "/" , $ route_pattern_comps ) ; $ route = $ this -> getRoute ( $ request_type , $ route_pattern ) ; $ route -> setParams ( $ params ) ; if ( $ uri_reformed == $ route_pattern_reformed ) { $ results = $ this -> app -> trigger ( "system.routing.route.matched" , "" , array ( 'route' => $ route ) ) ; $ result = true ; if ( is_array ( $ results ) && count ( $ results ) > 0 ) { foreach ( $ results as $ matched ) { if ( ! $ matched ) { $ result = false ; break ; } } } else if ( $ results === FALSE ) { $ result = false ; } if ( $ result ) { $ this -> setMatchedRoute ( $ route ) ; } } } return $ result ; }
|
process route matching
|
12,673
|
public static function check_config ( $ cfg ) { if ( ! \ is_array ( $ cfg ) ) { self :: $ error = "The configuration is not a valid array" ; return false ; } self :: $ validator -> check ( bbn \ x :: to_object ( $ cfg ) , static :: $ schema ) ; self :: $ error = '' ; if ( self :: $ validator -> isValid ( ) ) { return 1 ; } foreach ( self :: $ validator -> getErrors ( ) as $ error ) { self :: $ error .= sprintf ( "[%s] %s" , $ error [ 'property' ] , $ error [ 'message' ] ) ; var_dump ( $ cfg ) ; } return false ; }
|
Confront the JSON schema object with the current configuration
|
12,674
|
public static function css_to_string ( $ css ) { if ( \ is_string ( $ css ) ) { return ' style="' . bbn \ str :: escape_dquotes ( $ css ) . '"' ; } else if ( \ is_array ( $ css ) && \ count ( $ css ) > 0 ) { $ st = '' ; foreach ( $ css as $ prop => $ val ) { $ st .= $ prop . ':' . $ val . ';' ; } return ' style="' . bbn \ str :: escape_dquotes ( $ st ) . '"' ; } }
|
Generates style string for a HTML tag
|
12,675
|
protected function update ( ) { $ this -> cfg = [ ] ; foreach ( $ this as $ key => $ var ) { if ( $ key !== 'cfg' && ! \ is_null ( $ var ) ) { if ( \ is_array ( $ var ) ) { foreach ( $ var as $ k => $ v ) { if ( ! isset ( $ this -> cfg [ $ key ] ) ) { $ this -> cfg [ $ key ] = [ ] ; } if ( ! \ is_null ( $ v ) ) { $ this -> cfg [ $ key ] [ $ k ] = $ v ; } } } else { $ this -> cfg [ $ key ] = $ var ; } } } return $ this ; }
|
Sets the configuration property according to the current configuration
|
12,676
|
public function append ( $ ele ) { $ args = \ func_get_args ( ) ; foreach ( $ args as $ ele ) { if ( ! isset ( $ this -> content ) ) { if ( \ is_array ( $ ele ) && isset ( $ ele [ 0 ] ) ) { $ this -> content = $ ele ; } else { $ this -> content = \ is_object ( $ ele ) ? [ $ ele ] : $ ele ; } } else if ( \ is_array ( $ this -> content ) ) { if ( \ is_array ( $ ele ) ) { array_merge ( $ this -> content , $ ele ) ; } else { array_push ( $ this -> content , $ ele ) ; } } else if ( \ is_string ( $ this -> content ) ) { if ( \ is_array ( $ ele ) ) { foreach ( $ ele as $ e ) { $ this -> content .= $ e -> html ( ) ; } } else { $ this -> content .= \ is_object ( $ ele ) ? $ ele -> html ( ) : $ ele ; } } } return $ this ; }
|
Add an element to the content or a string if it s one
|
12,677
|
public function get_config ( ) { $ this -> update ( ) ; $ tmp = bbn \ x :: remove_empty ( $ this -> cfg ) ; if ( isset ( $ tmp [ 'content' ] ) && \ is_array ( $ tmp [ 'content' ] ) ) { foreach ( $ tmp [ 'content' ] as $ i => $ c ) { if ( \ is_object ( $ c ) ) { if ( method_exists ( $ c , 'get_config' ) ) { $ tmp [ 'content' ] [ $ i ] = $ c -> get_config ( ) ; } } } } return $ tmp ; }
|
Returns the current configuration .
|
12,678
|
public function script ( $ with_ele = 1 ) { $ this -> update ( ) ; $ r = '' ; if ( isset ( $ this -> attr [ 'id' ] ) ) { if ( isset ( $ this -> cfg [ 'events' ] ) ) { foreach ( $ this -> cfg [ 'events' ] as $ event => $ fn ) { $ r .= '.' . $ event . '(' . ( strpos ( $ fn , 'function' ) === 0 ? $ fn : 'function(e){' . $ fn . '}' ) . ')' ; } } if ( isset ( $ this -> cfg [ 'widget' ] , $ this -> cfg [ 'widget' ] [ 'name' ] ) ) { $ r .= '.' . $ this -> cfg [ 'widget' ] [ 'name' ] . '(' ; if ( isset ( $ this -> cfg [ 'widget' ] [ 'options' ] ) ) { $ r .= '{' ; foreach ( $ this -> cfg [ 'widget' ] [ 'options' ] as $ n => $ o ) { $ r .= '"' . $ n . '":' ; if ( \ is_string ( $ o ) ) { $ o = trim ( $ o ) ; if ( ( strpos ( $ o , 'function(' ) === 0 ) ) { $ r .= $ o ; } else { $ r .= '"' . bbn \ str :: escape_dquotes ( $ o ) . '"' ; } } else if ( \ is_bool ( $ o ) ) { $ r .= $ o ? 'true' : 'false' ; } else { $ r .= json_encode ( $ o ) ; } $ r .= ',' ; } $ r .= '}' ; } $ r .= ')' ; } if ( ! empty ( $ this -> help ) ) { } if ( ! empty ( $ r ) ) { if ( $ with_ele ) { $ r = '$("#' . $ this -> attr [ 'id' ] . '")' . $ r . ';' . PHP_EOL ; } else { $ r = $ r . ';' . PHP_EOL ; } } } if ( ! empty ( $ this -> script ) ) { $ r .= $ this -> script . PHP_EOL ; } if ( \ is_array ( $ this -> content ) ) { foreach ( $ this -> content as $ c ) { if ( \ is_array ( $ c ) ) { $ c = new bbn \ html \ element ( $ c ) ; } if ( \ is_object ( $ c ) && method_exists ( $ c , 'script' ) ) { $ r .= $ c -> script ( ) ; } } } return $ r ; }
|
Returns the javascript coming with the object
|
12,679
|
public function html ( $ with_js = 1 ) { $ html = '' ; if ( $ this -> tag ) { $ this -> update ( ) ; $ html .= '<' . $ this -> tag ; foreach ( $ this -> attr as $ key => $ val ) { if ( \ is_string ( $ key ) ) { $ html .= ' ' . htmlspecialchars ( $ key ) . '="' ; if ( is_numeric ( $ val ) ) { $ html .= $ val ; } else if ( \ is_string ( $ val ) ) { $ html .= htmlspecialchars ( $ val ) ; } $ html .= '"' ; } } if ( \ count ( $ this -> css ) > 0 ) { $ html .= self :: css_to_string ( $ this -> css ) ; } if ( $ this -> xhtml ) { $ html .= ' /' ; } $ html .= '>' ; if ( ! \ in_array ( $ this -> tag , self :: $ self_closing_tags ) ) { if ( isset ( $ this -> text ) ) { $ html .= $ this -> text ; } if ( isset ( $ this -> content ) ) { if ( \ is_string ( $ this -> content ) ) { $ html .= $ this -> content ; } else if ( \ is_array ( $ this -> content ) ) { foreach ( $ this -> content as $ c ) { if ( \ is_array ( $ c ) ) { $ c = new bbn \ html \ element ( $ c ) ; } $ html .= $ c -> html ( $ with_js ) ; } } } $ html .= '</' . $ this -> tag . '>' ; } if ( isset ( $ this -> placeholder ) && strpos ( $ this -> placeholder , '%s' ) !== false ) { $ html = sprintf ( $ this -> placeholder , $ html ) ; } } return $ html ; }
|
Returns the corresponding HTML string
|
12,680
|
public function getNextLine ( ) { if ( $ this -> currentMessagePosition === 0 ) { $ this -> nextMail ( ) ; } if ( $ this -> hasMoreMailData ) { $ data = fgets ( $ this -> fh ) ; if ( feof ( $ this -> fh ) || substr ( $ data , 0 , 5 ) === "From " ) { $ this -> hasMoreMailData = false ; return null ; } return $ data ; } return null ; }
|
Returns one line of data from the current mail in the set including the ending linebreak .
|
12,681
|
public function deleteAction ( $ id ) { $ this -> denyAccessUnlessGranted ( 'ROLE_ADMIN' , null , 'Unable to access this page !' ) ; $ postManager = $ this -> get ( 'asf_document.post.manager' ) ; $ post = $ postManager -> getRepository ( ) -> findOneBy ( array ( 'id' => $ id ) ) ; try { if ( is_null ( $ post ) ) throw new \ Exception ( $ this -> get ( 'translator' ) -> trans ( 'An error occurs when deleting the post' , array ( ) , 'asf_document' ) ) ; $ postManager -> getEntityManager ( ) -> remove ( $ post ) ; $ postManager -> getEntityManager ( ) -> flush ( ) ; if ( $ this -> has ( 'asf_layout.flash_message' ) ) { $ this -> get ( 'asf_layout.flash_message' ) -> success ( $ this -> get ( 'translator' ) -> trans ( 'The post "%name%" successfully deleted' , array ( '%name%' => $ post -> getTitle ( ) ) , 'asf_document' ) ) ; } } catch ( \ Exception $ e ) { if ( $ this -> has ( 'asf_layout.flash_message' ) ) { $ this -> get ( 'asf_layout.flash_message' ) -> danger ( $ e -> getMessage ( ) ) ; } } return $ this -> redirect ( $ this -> get ( 'router' ) -> generate ( 'asf_document_post_list' ) ) ; }
|
Delete a post
|
12,682
|
public static function render ( ResponseInterface $ response , $ view , array $ params = [ ] ) { return Application :: getInstance ( ) -> view -> render ( $ response , $ view , $ params ) ; }
|
Render a view file .
|
12,683
|
public function hasPermissionThroughRole ( $ permission ) { if ( ! $ this -> isMethodRolesExists ( ) ) { return false ; } if ( ! $ permission = $ this -> preparePermission ( $ permission ) ) { return false ; } foreach ( $ permission -> roles as $ role ) { if ( $ this -> roles -> contains ( $ role ) ) { return true ; } } return false ; }
|
Has permission through role
|
12,684
|
public function hasDirectPermission ( $ permission ) { $ name = $ permission instanceof Permission ? $ permission -> name : $ permission ; return ( bool ) $ this -> permissions -> where ( 'name' , $ name ) -> count ( ) ; }
|
Has direct permission
|
12,685
|
public function eachPermission ( array $ permissions , callable $ callback ) { $ permissions = array_flatten ( $ permissions ) ; foreach ( $ permissions as $ permission ) { if ( $ permission = $ this -> preparePermission ( $ permission ) ) { $ callback ( $ permission ) ; } } }
|
Calc each permission
|
12,686
|
public function handle ( ) { try { $ request = $ this -> transport -> receive ( ) ; list ( $ method , $ params ) = $ this -> encoder -> decodeMethod ( $ request ) ; if ( ! $ method ) { $ result = null ; } else { if ( $ this -> logger !== null && $ this -> logger -> isHandling ( \ Monolog \ Logger :: DEBUG ) ) { $ this -> logger -> addDebug ( 'Receive remote method invocation' , array ( 'method' => $ method , 'params' => $ params ) ) ; } $ result = $ this -> invoke ( $ this -> target , $ method , $ params ) ; } $ response = $ this -> encoder -> encodeResult ( $ result ) ; $ this -> transport -> respond ( $ response ) ; } catch ( \ Exception $ e ) { $ response = $ this -> encoder -> encodeException ( $ e ) ; $ this -> transport -> respond ( $ response ) ; } }
|
Handle a remote invokation request .
|
12,687
|
public function getRolesByUser ( $ userGuid ) { if ( ! isset ( $ userGuid ) || $ userGuid === '' ) { return [ ] ; } if ( $ userGuid instanceof User ) { $ userGuid = $ userGuid -> getGUID ( ) ; } $ query = ( new Query ) -> select ( 'b.*' ) -> from ( [ 'a' => $ this -> assignmentTable , 'b' => $ this -> itemTable ] ) -> where ( '{{a}}.[[item_name]]={{b}}.[[name]]' ) -> andWhere ( [ 'a.user_guid' => ( string ) $ userGuid ] ) -> andWhere ( [ 'b.type' => Item :: TYPE_ROLE ] ) ; $ roles = [ ] ; foreach ( $ query -> all ( $ this -> db ) as $ row ) { $ roles [ $ row [ 'name' ] ] = $ this -> populateItem ( $ row ) ; } return $ roles ; }
|
Get roles by user .
|
12,688
|
protected function getInheritedPermissionsByUser ( $ userGuid ) { $ query = ( new Query ) -> select ( 'item_name' ) -> from ( $ this -> assignmentTable ) -> where ( [ 'user_guid' => ( string ) $ userGuid ] ) ; $ childrenList = $ this -> getChildrenList ( ) ; $ result = [ ] ; foreach ( $ query -> column ( $ this -> db ) as $ roleName ) { $ this -> getChildrenRecursive ( $ roleName , $ childrenList , $ result ) ; } if ( empty ( $ result ) ) { return [ ] ; } $ query = ( new Query ) -> from ( $ this -> itemTable ) -> where ( [ 'type' => Item :: TYPE_PERMISSION , 'name' => array_keys ( $ result ) , ] ) ; $ permissions = [ ] ; foreach ( $ query -> all ( $ this -> db ) as $ row ) { $ permissions [ $ row [ 'name' ] ] = $ this -> populateItem ( $ row ) ; } return $ permissions ; }
|
Returns all permissions that the user inherits from the roles assigned to him .
|
12,689
|
protected function revokeFailedAssignment ( Assignment $ assignment ) { if ( $ assignment -> failedAt === null ) { return false ; } if ( strtotime ( $ assignment -> failedAt ) < strtotime ( gmdate ( 'Y-m-d H:i:s' ) ) ) { $ role = $ this -> getRole ( $ assignment -> roleName ) ; if ( ! $ role ) { return true ; } $ this -> revoke ( $ role -> name , $ assignment -> userGuid ) ; return true ; } return false ; }
|
Revoke failed assignment . If assignment s failedAt attribute is null false will be given directly .
|
12,690
|
public function getUserGuidsByRole ( $ roleName ) { if ( empty ( $ roleName ) ) { return [ ] ; } return ( new Query ) -> select ( '[[user_guid]]' ) -> from ( $ this -> assignmentTable ) -> where ( [ 'item_name' => $ roleName ] ) -> column ( $ this -> db ) ; }
|
Returns all role assignment information for the specified role .
|
12,691
|
public function onSinglePageLoaded ( array & $ pageData ) { if ( ! isset ( $ pageData [ 'content' ] ) ) { $ pageData [ 'content' ] = $ this -> prepareFileContent ( $ pageData [ 'raw_content' ] , $ pageData [ 'meta' ] ) ; $ pageData [ 'content' ] = $ this -> parseFileContent ( $ pageData [ 'content' ] ) ; } }
|
Parses the contents of all pages
|
12,692
|
public function initialize ( $ id , $ alias = null ) { $ this -> id = $ id ; $ this -> alias = $ alias ; }
|
Initializes the state of this object
|
12,693
|
public function buildOptions ( array $ options ) { $ options = array_merge ( array ( 'link' => null , 'icon' => null , ) , $ options ) ; if ( isset ( $ options [ 'link' ] ) && $ options [ 'link' ] !== null ) { $ options [ 'extras' ] [ 'link' ] = ( array ) $ options [ 'link' ] ; } $ options [ 'extras' ] [ 'icon' ] = $ options [ 'icon' ] ; return $ options ; }
|
Builds the full option array used to configure the item .
|
12,694
|
function _filterHost ( $ host ) { if ( strstr ( $ host , ':' ) !== false ) throw new \ InvalidArgumentException ( 'Host name can`t contains port number.' ) ; $ host = strtolower ( $ host ) ; return $ host ; }
|
Validate and Filter host value
|
12,695
|
public function is ( $ value , $ rules ) { $ valTO = $ this -> apply ( $ value , $ rules ) ; if ( $ valTO -> fails ( ) ) { return false ; } return $ valTO -> getValue ( ) ; }
|
validates a text value or an array of text values . returns the filtered value or false if validation fails .
|
12,696
|
public function applyFilters ( $ value , $ rules = array ( ) ) { $ valueTO = $ this -> valueTO -> forge ( $ value ) ; foreach ( $ rules as $ rule => $ parameter ) { if ( $ parameter === false ) { continue ; } $ this -> filter -> apply ( $ rule , $ valueTO , $ parameter ) ; if ( $ valueTO -> getBreak ( ) ) { break ; } } return $ valueTO ; }
|
apply filters on a single value .
|
12,697
|
public function run ( $ destination , $ source , $ default = null ) { $ result = null ; if ( is_object ( $ destination ) && is_object ( $ source ) && get_class ( $ destination ) == get_class ( $ source ) ) { $ result = $ this -> mergeObject ( $ destination , $ source ) ; } elseif ( is_array ( $ source ) && is_array ( $ destination ) ) { $ result = $ this -> mergeArray ( $ destination , $ source ) ; } elseif ( ! is_null ( $ source ) && $ source !== $ default ) { $ result = $ source ; } return $ result ; }
|
Merges the source on top of the destination and returns the result .
|
12,698
|
private function mergeObject ( $ destinationObject , $ sourceObject ) { $ reflectedDestination = new \ ReflectionObject ( $ destinationObject ) ; $ reflectedSource = new \ ReflectionObject ( $ sourceObject ) ; $ defaultPropertyValues = $ reflectedDestination -> getDefaultProperties ( ) ; foreach ( $ reflectedSource -> getProperties ( ) as $ sourceProperty ) { $ destinationObject = $ this -> mergeProperty ( $ destinationObject , $ reflectedDestination -> getProperty ( $ sourceProperty -> getName ( ) ) , $ sourceObject , $ sourceProperty , $ defaultPropertyValues ) ; } return $ destinationObject ; }
|
Deep - merge the source object over the destination object and return the results .
|
12,699
|
private function mergeArray ( $ destinationArray , $ sourceArray ) { $ result = array ( ) ; foreach ( $ destinationArray as $ key => $ destinationArrayItem ) { if ( is_int ( $ key ) ) { $ result [ ] = $ destinationArrayItem ; } else { $ result [ $ key ] = $ destinationArrayItem ; } } foreach ( $ sourceArray as $ key => $ sourceArrayItem ) { if ( is_int ( $ key ) ) { $ result [ ] = $ sourceArrayItem ; } else { $ result [ $ key ] = $ this -> run ( $ result [ $ key ] , $ sourceArrayItem ) ; } } return $ result ; }
|
Deep - merges the source array over the destination array .
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.