idx
int64
0
60.3k
question
stringlengths
101
6.21k
target
stringlengths
7
803
25,800
public static function set ( $ key , $ value , $ preferGlobal = false ) { if ( ! isset ( self :: $ _config [ $ key ] ) ) { return false ; } if ( ! $ preferGlobal && self :: $ _CurrentHTMLInstance && isset ( self :: $ _CurrentHTMLInstance -> $ key ) ) { self :: s3t ( self :: $ _CurrentHTMLInstance -> $ key , $ value ) ; } else { if ( class_exists ( 'Xiphe\THEMASTER\core\THE' ) && class_exists ( TM \ THE :: SETTINGS ) ) { $ prev = TM \ THEWPSETTINGS :: sGet_setting ( $ key , XIPHE_HTML_TEXTID ) ; self :: s3t ( $ prev , $ value ) ; TM \ THESETTINGS :: sSet_setting ( $ key , XIPHE_HTML_TEXTID , $ prev ) ; } else { self :: s3t ( self :: $ _config [ $ key ] , $ value ) ; } } return true ; }
Changes a global configuration .
25,801
public static function s3t ( & $ target , $ value ) { if ( $ value === '++' && is_numeric ( ( $ oldValue = $ target ) ) ) { $ value = $ oldValue + 1 ; } elseif ( $ value === '--' && is_numeric ( ( $ oldValue = $ target ) ) ) { $ value = $ oldValue - 1 ; } $ target = $ value ; }
Sets the given value to the linked target .
25,802
public function getHeaderValue ( $ header , $ glue = '' ) { if ( $ header = $ this -> response -> getHeader ( $ header , true ) ) { if ( is_array ( $ header ) ) { return implode ( $ glue , $ header ) ; } } return $ header ; }
return a scalar value of \ Guzzle \ Http \ Message \ Header type
25,803
public static function buildAsync ( $ host , $ port , $ user , $ pass , $ exchangeName , $ escapeMode = self :: ESCAPE_MODE_SERIALIZE , $ timeout = 0 ) { return self :: build ( $ host , $ port , $ user , $ pass , $ exchangeName , false , $ escapeMode , $ timeout ) ; }
Build an async publisher
25,804
public static function buildSync ( $ host , $ port , $ user , $ pass , $ exchangeName , $ escapeMode = self :: ESCAPE_MODE_SERIALIZE , $ timeout = 0 ) { return self :: build ( $ host , $ port , $ user , $ pass , $ exchangeName , true , $ escapeMode , $ timeout ) ; }
Build a sync publisher
25,805
private static function build ( $ host , $ port , $ user , $ pass , $ exchangeName , $ sync , $ escapeMode , $ timeout ) { $ driver = DriverFactory :: getDriver ( [ 'host' => $ host , 'port' => $ port , 'user' => $ user , 'pwd' => $ pass ] ) ; $ publisher = ( $ sync ) ? new SyncPublisher ( $ driver , $ exchangeName , $ timeout ) : new AsyncPublisher ( $ driver , $ exchangeName ) ; if ( $ escapeMode === self :: ESCAPE_MODE_NONE ) { return $ publisher ; } if ( $ escapeMode === self :: ESCAPE_MODE_JSON ) { return new SerializingPublisher ( $ publisher , new JsonSerializer ( ) ) ; } if ( $ escapeMode === self :: ESCAPE_MODE_SERIALIZE ) { return new SerializingPublisher ( $ publisher , new PhpSerializer ( ) ) ; } throw new \ InvalidArgumentException ( 'Bad serializer name' ) ; }
Build a publisher
25,806
protected function doWriteStartElement ( string $ elementName ) { $ this -> append ( function ( \ DOMNode $ parent ) use ( $ elementName ) { $ element = $ this -> doc -> createElement ( $ elementName ) ; $ parent -> appendChild ( $ element ) ; array_push ( $ this -> openElements , $ element ) ; } , 'start element: "' . $ elementName . '"' ) ; }
really writes an opening tag
25,807
public function writeText ( string $ data ) : XmlStreamWriter { return $ this -> append ( function ( \ DOMNode $ parent ) use ( $ data ) { $ parent -> appendChild ( $ this -> doc -> createTextNode ( $ this -> encode ( $ data ) ) ) ; } , 'text' ) ; }
Write a text node
25,808
public function writeCData ( string $ cdata ) : XmlStreamWriter { return $ this -> append ( function ( \ DOMNode $ parent ) use ( $ cdata ) { $ parent -> appendChild ( $ this -> doc -> createCDATASection ( $ this -> encode ( $ cdata ) ) ) ; } , 'cdata' ) ; }
Write a cdata section
25,809
public function writeComment ( string $ comment ) : XmlStreamWriter { return $ this -> append ( function ( \ DOMNode $ parent ) use ( $ comment ) { $ parent -> appendChild ( $ this -> doc -> createComment ( $ this -> encode ( $ comment ) ) ) ; } , 'comment' ) ; }
Write a comment
25,810
public function writeXmlFragment ( string $ fragment ) : XmlStreamWriter { return $ this -> append ( function ( \ DOMNode $ parent ) use ( $ fragment ) { $ fragmentNode = $ this -> doc -> createDocumentFragment ( ) ; $ fragmentNode -> appendXML ( $ fragment ) ; @ $ parent -> appendChild ( $ fragmentNode ) ; } , 'document fragment' ) ; }
Write an xml fragment
25,811
public function importStreamWriter ( XmlStreamWriter $ writer ) : XmlStreamWriter { return $ this -> append ( function ( \ DOMNode $ parent ) use ( $ writer ) { $ parent -> appendChild ( $ this -> doc -> importNode ( $ writer -> asDom ( ) -> documentElement , true ) ) ; } , 'imported nodes' ) ; }
Import another stream
25,812
private function append ( \ Closure $ appendTo , string $ type ) : XmlStreamWriter { libxml_use_internal_errors ( true ) ; try { $ appendTo ( end ( $ this -> openElements ) ) ; } catch ( \ DOMException $ e ) { throw new XmlException ( 'Error writing "' . $ type , $ e ) ; } $ errors = libxml_get_errors ( ) ; if ( ! empty ( $ errors ) ) { libxml_clear_errors ( ) ; throw new XmlException ( 'Error writing "' . $ type . '": ' . implode ( ', ' , array_map ( function ( $ error ) { return trim ( $ error -> message ) ; } , $ errors ) ) ) ; } return $ this ; }
wraps handling on element stack
25,813
public function addOption ( $ option ) { if ( in_array ( $ option , Generator :: $ tagOptionKeys ) && ! $ this -> hasOption ( $ option ) ) { $ this -> options [ ] = $ option ; } }
Adds an option to the Tag
25,814
public function removeOption ( $ option ) { if ( $ this -> hasOption ( $ option ) ) { $ key = array_search ( $ option , $ this -> options ) ; unset ( $ this -> options [ $ key ] ) ; } }
Removes an option from the Tag
25,815
public function update ( $ what = 'all' ) { if ( $ what == 'all' || $ what == 'classes' ) { Generator :: updateClasses ( $ this ) ; } if ( $ what == 'all' || $ what == 'urls' ) { Generator :: magicUrls ( $ this ) ; } if ( $ what == 'content' ) { Content :: parse ( $ this ) ; } if ( $ what == 'content' || $ what == 'all' || $ what == 'inlineInner' ) { if ( $ this -> hasOption ( 'inlineInner' ) || ( $ this -> name !== 'blank' && ! $ this -> hasOption ( 'forbidInlineInner' ) && ! $ this -> isSelfClosing ( ) && ! $ this -> hasOption ( 'start' ) && strlen ( $ this -> content ) < Config :: get ( 'maxLineWidth' ) && ! preg_match ( '/\r\n|\n|\r/' , $ this -> content ) ) ) { $ this -> inlineInner = true ; } else { $ this -> inlineInner = false ; } } if ( $ what == 'all' || $ what == 'attributes' ) { ksort ( $ this -> attributes ) ; $ this -> attributeString = Generator :: attsToString ( $ this ) ; } }
Updates class variables .
25,816
public function setAttrs ( $ attrs ) { $ oldAttrs = $ this -> attributes ; $ oldClasses = $ this -> classes ; $ this -> attributes = $ attrs ; $ this -> attributes = Generator :: parseAtts ( $ this ) ; $ this -> attributes = array_merge ( $ oldAttrs , $ this -> attributes ) ; $ this -> classes = null ; $ this -> update ( 'classes' ) ; if ( ! empty ( $ oldClasses ) && ! empty ( $ this -> classes ) ) { $ this -> attributes [ 'class' ] = implode ( ' ' , array_merge ( $ oldClasses , $ this -> classes ) ) ; } $ this -> classes = null ; if ( ! empty ( $ oldAttrs [ 'style' ] ) && ! empty ( $ this -> attributes [ 'style' ] ) ) { $ this -> attributes [ 'style' ] = Generator :: mergeStyles ( $ this -> attributes [ 'style' ] , $ oldAttrs [ 'style' ] ) ; } $ this -> update ( ) ; }
Add an array of attributes to the tag .
25,817
public function isSelfclosing ( ) { if ( isset ( $ this -> selfclosing ) ) { return ( bool ) $ this -> selfclosing ; } if ( $ this -> hasOption ( 'selfQlose' ) ) { $ this -> selfclosing = true ; return true ; } elseif ( $ this -> hasOption ( 'doNotSelfQlose' ) ) { $ this -> selfclosing = false ; return false ; } return in_array ( $ this -> realName , TagInfo :: $ selfClosing ) ; }
Checks if this tag is meant to be self closing .
25,818
public function closingComment ( ) { if ( ! empty ( $ this -> attributes [ 'id' ] ) ) { $ hint = '#' . $ this -> attributes [ 'id' ] ; } elseif ( ! empty ( $ this -> classes ) ) { $ hint = '.' . $ this -> classes [ 0 ] ; } else { return false ; } Generator :: call ( 'il_comment' , array ( $ hint ) ) ; }
Adds the closing comment containing the tag id or class .
25,819
public function content ( ) { if ( ! $ this -> _contentPrinted ) { if ( ! $ this -> inlineInner ) { Generator :: tabs ( ) ; } if ( $ this -> hasOption ( 'cleanContent' ) || ( Config :: get ( 'clean' ) && ! $ this -> hasOption ( 'doNotCleanContent' ) ) ) { echo trim ( Cleaner :: getClean ( $ this -> content ) ) ; } else { echo $ this -> content ; } if ( ! $ this -> inlineInner ) { Generator :: lineBreak ( ) ; } $ this -> _contentPrinted = true ; } }
Echoes the tag content .
25,820
public function monitor ( Daemon $ daemon , $ currentObject = null ) { $ currentMemory = $ this -> getMemoryUsage ( ) ; if ( $ this -> memory > 0 && $ currentMemory > $ this -> memory ) { $ this -> logger -> warning ( 'Memory usage increased' , [ 'bytes_increased_by' => $ currentMemory - $ this -> memory , 'bytes_current_memory' => $ currentMemory ] ) ; } $ this -> memory = $ currentMemory ; }
Monitor the daemon
25,821
public function sure ( ) { return ! ( substr ( $ this -> args [ 0 ] , 0 , 4 ) == 'http' || substr ( $ this -> args [ 0 ] , 0 , 3 ) == '../' || substr ( $ this -> args [ 0 ] , 0 , 3 ) == '\./' || substr ( $ this -> args [ 0 ] , 0 , 2 ) == './' || substr ( $ this -> args [ 0 ] , 0 , 1 ) == '/' ) ; }
Don t use this module if content looks like an url .
25,822
public static function appendAlias ( & $ moduleName ) { if ( isset ( self :: $ moduleAliases [ $ moduleName ] ) ) { $ moduleName = self :: $ moduleAliases [ $ moduleName ] ; } }
Checks if the called name is a module alias .
25,823
public static function execute ( $ name , & $ args , & $ options , $ called ) { $ moduleClass = 'Xiphe\HTML\modules\\' . ucfirst ( $ name ) ; if ( is_object ( self :: $ _loadedModules [ $ name ] ) ) { self :: $ _loadedModules [ $ name ] -> execute ( $ args , $ options , $ called ) ; } else { $ Module = new $ moduleClass ( ) ; $ Module -> execute ( $ args , $ options , $ called ) ; } }
Loads and executes modules
25,824
public static function get ( $ name , & $ args , & $ options , & $ called ) { $ moduleClass = 'Xiphe\HTML\modules\\' . ucfirst ( $ name ) ; if ( ! isset ( self :: $ _loadedModules [ $ name ] ) ) { self :: $ _loadedModules [ $ name ] = new $ moduleClass ( ) ; self :: $ _loadedModules [ $ name ] -> name = $ name ; } self :: $ _loadedModules [ $ name ] -> init ( $ args , $ options , $ called ) ; return self :: $ _loadedModules [ $ name ] ; }
Returns a freshly initiated module .
25,825
public static function exist ( $ name ) { $ name = ucfirst ( $ name ) ; if ( in_array ( $ name , self :: $ _unavailableModules ) ) { return false ; } if ( isset ( self :: $ _loadedModules [ $ name ] ) ) { return true ; } if ( file_exists ( self :: getModulePath ( ) . $ name . '.php' ) ) { return true ; } else { self :: $ _unavailableModules [ ] = $ name ; } return false ; }
Checks if the Module was loaded before or if the module file exists
25,826
public static function fromObject ( $ object ) : self { $ className = get_class ( $ object ) ; if ( isset ( self :: $ cache [ $ className ] ) ) { return self :: $ cache [ $ className ] ; } self :: $ cache [ $ className ] = new self ( new \ ReflectionObject ( $ object ) ) ; return self :: $ cache [ $ className ] ; }
creates the structure from given object
25,827
private function extractProperties ( \ ReflectionClass $ objectClass ) : array { return propertiesOf ( $ objectClass , \ ReflectionProperty :: IS_PUBLIC ) -> filter ( function ( \ ReflectionProperty $ property ) { return ! $ property -> isStatic ( ) && ! annotationsOf ( $ property ) -> contain ( 'XmlIgnore' ) ; } ) -> map ( function ( \ ReflectionProperty $ property ) { return $ this -> createSerializerDelegate ( annotationsOf ( $ property ) , $ property -> getName ( ) ) ; } ) -> data ( ) ; }
extract informations about properties
25,828
private function extractMethods ( \ ReflectionClass $ objectClass ) : array { return methodsOf ( $ objectClass , \ ReflectionMethod :: IS_PUBLIC ) -> filter ( function ( \ ReflectionMethod $ method ) { if ( $ method -> getNumberOfParameters ( ) != 0 || $ method -> isStatic ( ) || $ method -> isConstructor ( ) || $ method -> isDestructor ( ) || 0 == strncmp ( $ method -> getName ( ) , '__' , 2 ) ) { return false ; } return ! annotationsOf ( $ method ) -> contain ( 'XmlIgnore' ) ; } ) -> map ( function ( \ ReflectionMethod $ method ) { return $ this -> createSerializerDelegate ( annotationsOf ( $ method ) , $ method -> getName ( ) ) ; } ) -> data ( ) ; }
extract informations about methods
25,829
private function createSerializerDelegate ( Annotations $ annotations , string $ defaultTagName ) : XmlSerializerDelegate { if ( $ annotations -> contain ( 'XmlAttribute' ) ) { $ xmlAttribute = $ annotations -> firstNamed ( 'XmlAttribute' ) ; return new Attribute ( $ xmlAttribute -> attributeName ( ) , $ xmlAttribute -> getValueByName ( 'skipEmpty' , true ) ) ; } elseif ( $ annotations -> contain ( 'XmlFragment' ) ) { $ xmlFragment = $ annotations -> firstNamed ( 'XmlFragment' ) ; return new Fragment ( false !== $ xmlFragment -> tagName ( ) ? $ xmlFragment -> tagName ( ) : null , $ xmlFragment -> getValueByName ( 'transformNewLineToBr' , false ) ) ; } elseif ( $ annotations -> contain ( 'XmlTag' ) ) { $ xmlTag = $ annotations -> firstNamed ( 'XmlTag' ) ; return new Tag ( false !== $ xmlTag -> tagName ( ) ? $ xmlTag -> tagName ( ) : '' , $ xmlTag -> getValueByName ( 'elementTagName' ) ) ; } return new Tag ( $ defaultTagName ) ; }
extracts informations about annotated element
25,830
public function isSelected ( $ selected , $ value , $ i ) { if ( is_array ( $ selected ) ) { foreach ( $ selected as $ s ) { if ( $ this -> isSelected ( $ s , $ value , $ i ) ) { return true ; } } } elseif ( is_int ( $ selected ) && $ i === $ selected ) { return true ; } elseif ( $ value === $ selected ) { return true ; } return false ; }
Checks for selected options .
25,831
public function consume ( $ message , array $ headers = [ ] ) { try { $ this -> transactionManager -> beginTransaction ( ) ; } catch ( BeginException $ e ) { throw new ConsumerException ( $ e -> getMessage ( ) , $ e -> getCode ( ) , $ e ) ; } try { $ this -> consumer -> consume ( $ message , $ headers ) ; $ this -> transactionManager -> commit ( ) ; } catch ( \ Exception $ e ) { $ this -> transactionManager -> rollback ( ) ; throw $ e ; } }
Consumes a message .
25,832
public static function get ( $ initArgs = array ( ) ) { if ( get_class ( Core \ Config :: getHTMLInstance ( ) ) == 'Xiphe\HTML' ) { return Core \ Config :: getHTMLInstance ( ) ; } elseif ( get_class ( $ GLOBALS [ 'HTML' ] ) == 'Xiphe\HTML' ) { return $ GLOBALS [ 'HTML' ] ; } else { return new HTML ( $ initArgs ) ; } }
Getter for a HTML instance .
25,833
public function getOption ( $ key ) { if ( Core \ Config :: isValidOptionName ( $ key ) ) { if ( isset ( $ this -> $ key ) ) { return $ this -> $ key ; } else { return Core \ Config :: get ( $ key , true ) ; } } }
Request an option value .
25,834
public function setOption ( $ key , $ value ) { if ( Core \ Config :: isValidOptionName ( $ key ) ) { Core \ Config :: s3t ( $ this -> $ key , $ value ) ; } return $ this ; }
Set an option value for this instance
25,835
public function unsetOption ( $ key ) { if ( Core \ Config :: isValidOptionName ( $ key ) && isset ( $ this -> $ key ) ) { unset ( $ this -> $ key ) ; } return $ this ; }
Deletes an intance option if set .
25,836
public function unsetInstanceOptions ( ) { foreach ( Core \ Config :: getDefaults ( ) as $ k => $ v ) { if ( isset ( $ this -> $ k ) ) { unset ( $ this -> $ k ) ; } } return $ this ; }
Deletes all instance options of this instance .
25,837
public function addTabs ( $ i = 1 ) { Core \ Config :: setHTMLInstance ( $ this ) ; Core \ Config :: set ( 'tabs' , ( Core \ Config :: get ( 'tabs' ) + $ i ) ) ; return $ this ; }
Manipulates the current Tab count .
25,838
public function xhtml ( ) { $ this -> htmlattrs [ 'xmlns' ] = 'http://www.w3.org/1999/xhtml' ; echo '<?xml version="1.0" ?>' . "\n" ; echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"' ; Core \ Generator :: lineBreak ( ) ; Core \ Config :: set ( 'tabs' , '++' ) ; Core \ Generator :: tabs ( ) ; echo '"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">' ; Core \ Generator :: lineBreak ( ) ; Core \ Config :: set ( 'tabs' , '--' ) ; echo $ this -> getHtml ( ) ; echo $ this -> getHead ( ) ; }
Generate a XHTML header .
25,839
public function html5 ( ) { echo '<!DOCTYPE HTML>' . "\n" ; Core \ Generator :: lineBreak ( ) ; echo $ this -> getHtml ( ) ; echo $ this -> getHead ( ) ; \ Xiphe \ HTML :: get ( ) -> utf8 ( ) -> meta ( 'http-equiv=X-UA-Compatible|content=IE\=edge,chrome\=1' ) ; }
Generate a HTML5 header .
25,840
public function getHtml ( ) { $ html = new Core \ Tag ( 'html' , array ( ( isset ( $ this -> args [ 1 ] ) ? $ this -> args [ 1 ] : null ) ) , array ( 'generate' , 'start' ) ) ; $ html -> setAttrs ( $ this -> htmlattrs ) ; return $ html ; }
Returns the actual html tag .
25,841
public function getHead ( ) { $ head = new Core \ Tag ( 'head' , array ( ( isset ( $ this -> args [ 0 ] ) ? $ this -> args [ 0 ] : null ) ) , array ( 'generate' , 'start' ) ) ; $ head -> setAttrs ( $ this -> headattrs ) ; return $ head ; }
Returns the head tag .
25,842
public function ieClass ( $ before = '' ) { $ sIeClass = '' ; if ( class_exists ( 'Xiphe\THEMASTER\core\THEMASTER' ) ) { if ( \ Xiphe \ THETOOLS :: is_browser ( 'ie' ) ) { if ( \ Xiphe \ THETOOLS :: is_browser ( 'ie<=6' ) ) { $ sIeClass = $ before . 'lt-ie10 lt-ie9 lt-ie8 lt-ie7' ; } elseif ( \ Xiphe \ THETOOLS :: is_browser ( 'ie<=7' ) ) { $ sIeClass = $ before . 'lt-ie10 lt-ie9 lt-ie8' ; } elseif ( \ Xiphe \ THETOOLS :: is_browser ( 'ie<=8' ) ) { $ sIeClass = $ before . 'lt-ie10 lt-ie9' ; } elseif ( \ Xiphe \ THETOOLS :: is_browser ( 'ie<=9' ) ) { $ sIeClass = $ before . 'lt-ie10' ; } } } return $ sIeClass ; }
Checks if \ Xiphe \ THETOOLS exists and append ie classes .
25,843
public function browserClass ( $ before = '' ) { if ( class_exists ( 'Xiphe\THEMASTER\core\THEMASTER' ) ) { $ browser = str_replace ( ' ' , '_' , strtolower ( \ Xiphe \ THETOOLS :: get_browser ( ) ) ) ; $ version = str_replace ( '.' , '-' , \ Xiphe \ THETOOLS :: get_browserVersion ( ) ) ; $ engine = strtolower ( \ Xiphe \ THETOOLS :: get_layoutEngine ( ) ) ; if ( ! empty ( $ engine ) ) { $ engine .= ' ' ; } if ( \ Xiphe \ THETOOLS :: is_browser ( 'mobile' ) ) { $ mobile = 'mobile no-desktop' ; } else { $ mobile = 'desktop no-mobile' ; } return "$before$engine$browser $browser-$version $mobile" ; } return '' ; }
Checks if \ Xiphe \ THETOOLS exists and appends browser classes .
25,844
public static function buildAsync ( $ host , $ port , $ user , $ pass , $ queueName , QueueConsumer $ consumer , $ escapeMode = self :: ESCAPE_MODE_SERIALIZE , $ requeueOnFailure = true , LoggerInterface $ logger = null , $ stopOnFailure = false ) { return self :: build ( $ host , $ port , $ user , $ pass , $ queueName , $ consumer , false , $ escapeMode , $ requeueOnFailure , $ stopOnFailure ) ; }
Build an async daemon
25,845
private static function build ( $ host , $ port , $ user , $ pass , $ queueName , QueueConsumer $ consumer , $ sync , $ escapeMode , $ requeueOnFailure , LoggerInterface $ logger = null , $ stopOnFailure = false ) { $ consumer = self :: getSerializingConsumer ( $ consumer , $ escapeMode ) ; $ driver = DriverFactory :: getDriver ( [ 'host' => $ host , 'port' => $ port , 'user' => $ user , 'pwd' => $ pass ] ) ; $ builder = new HandlerBuilder ( $ driver ) ; if ( $ sync ) { $ builder -> sync ( $ consumer ) ; } else { $ builder -> async ( $ consumer ) ; } if ( ! $ stopOnFailure ) { $ builder -> continueOnFailure ( ) ; } if ( ! $ requeueOnFailure ) { $ builder -> doNotRequeueOnFailure ( ) ; } $ builder -> log ( ( $ logger === null ) ? new NullLogger ( ) : $ logger ) ; return new QueueHandlingDaemon ( $ driver , $ builder -> build ( ) , $ queueName ) ; }
Build a daemon
25,846
private static function _applyPreGenerationFilters ( & $ Obj ) { if ( $ Obj -> name == 'comment' && Config :: get ( 'noComments' ) ) { $ Obj -> destroy ( ) ; return false ; } if ( in_array ( 'justGetObject' , $ Obj -> options ) ) { return $ Obj ; } if ( in_array ( 'return' , $ Obj -> options ) ) { ob_start ( ) ; } }
Things that must be done before the Tag will be created .
25,847
private static function _applyPostGenerationFilters ( & $ Obj ) { if ( in_array ( 'return' , $ Obj -> options ) ) { return ob_get_clean ( ) ; } if ( in_array ( 'getObject' , $ Obj -> options ) ) { return $ Obj ; } }
Things that must be done after the Tag was generated .
25,848
public static function parseAtts ( $ input ) { if ( is_object ( $ input ) && get_class ( $ input ) == 'Xiphe\HTML\core\Tag' ) { $ Tag = $ input ; $ input = $ Tag -> attributes ; } if ( is_array ( $ input ) ) { return $ input ; } if ( empty ( $ input ) ) { return array ( ) ; } $ atts = preg_split ( '/(?<=[^\\\])[|]+/' , $ input , - 1 , PREG_SPLIT_NO_EMPTY ) ; $ input = array ( ) ; foreach ( $ atts as $ k => $ attr ) { $ attr = preg_split ( '/(?<=[^\\\])[=]+/' , $ attr , 2 ) ; foreach ( $ attr as $ k => $ v ) { $ attr [ $ k ] = preg_replace ( '/[\\\]([=|\|])/' , '$1' , $ v ) ; } if ( count ( $ attr ) == 1 ) { if ( isset ( $ Tag ) && count ( $ atts ) == 1 ) { if ( ( $ t = self :: getKeyAlias ( $ attr ) ) && ! self :: _ignoreKeyAlias ( $ t , $ Tag ) ) { extract ( $ t ) ; $ attr [ 1 ] = substr ( $ attr [ 0 ] , strlen ( $ alias ) ) ; $ attr [ 0 ] = $ key ; } else { $ key = self :: getSingleAttrKey ( $ Tag ) ; if ( false !== $ key ) { $ attr [ 1 ] = $ attr [ 0 ] ; $ attr [ 0 ] = $ key ; } else { $ attr [ 1 ] = null ; } } } elseif ( isset ( $ Tag ) && ( $ t = self :: getKeyAlias ( $ attr ) ) ) { extract ( $ t ) ; $ attr [ 1 ] = substr ( $ attr [ 0 ] , strlen ( $ alias ) ) ; $ attr [ 0 ] = $ key ; } else { $ attr [ 1 ] = null ; } if ( isset ( $ Tag ) && $ attr [ 0 ] === '%default' ) { $ attr [ 0 ] = TagInfo :: $ singleAttrkeys [ $ Tag -> name ] ; } } $ input [ $ attr [ 0 ] ] = $ attr [ 1 ] ; } return $ input ; }
Parser for string formated attribute arrays
25,849
public static function updateClasses ( Tag & $ Tag ) { if ( empty ( $ Tag -> classes ) && isset ( $ Tag -> attributes [ 'class' ] ) ) { $ classes = explode ( ' ' , $ Tag -> attributes [ 'class' ] ) ; } elseif ( ! empty ( $ Tag -> classes ) ) { $ classes = $ Tag -> classes ; } if ( isset ( $ classes ) ) { sort ( $ classes ) ; $ Tag -> classes = $ classes ; $ Tag -> attributes [ 'class' ] = implode ( ' ' , $ classes ) ; } }
Builds an array of classes by seperating the class attribute by spaces If if was not build before
25,850
public static function mergeStyles ( $ a , $ b ) { $ a = explode ( ';' , $ a ) ; $ amap = array ( ) ; $ gk = function ( $ s ) { return trim ( substr ( $ s , 0 , strpos ( $ s , ':' ) ) ) ; } ; foreach ( $ a as $ k => $ v ) { if ( trim ( $ v ) == '' ) { unset ( $ a [ $ k ] ) ; continue ; } $ a [ $ k ] = trim ( $ v ) ; $ amap [ $ gk ( $ v ) ] = $ k ; } foreach ( explode ( ';' , $ b ) as $ st ) { if ( trim ( $ st ) == '' ) { continue ; } if ( isset ( $ amap [ $ gk ( $ st ) ] ) ) { unset ( $ a [ $ amap [ $ gk ( $ st ) ] ] ) ; } $ a [ ] = trim ( $ st ) ; } sort ( $ a ) ; return str_replace ( array ( ': ' , ': ' ) , ':' , implode ( ';' , $ a ) ) . ';' ; }
Merges two strings containing styles .
25,851
public static function mergeClasses ( $ a , $ b ) { $ str = 0 ; if ( ! is_array ( $ a ) ) { $ str ++ ; $ a = explode ( ' ' , $ a ) ; } if ( ! is_array ( $ b ) ) { $ str ++ ; $ b = explode ( ' ' , $ b ) ; } $ b = array_filter ( $ b , function ( $ item ) use ( $ a ) { return ! in_array ( $ item , $ a ) ; } ) ; $ r = array_merge ( $ a , $ b ) ; sort ( $ r ) ; if ( $ str === 2 ) { $ r = implode ( ' ' , $ r ) ; } return $ r ; }
Merge two strings or arrays of classes
25,852
public static function mergeAttrs ( $ b , $ a , $ combineClasses = true , $ combineStyles = true ) { $ a = self :: parseAtts ( $ a ) ; $ b = self :: parseAtts ( $ b ) ; if ( $ combineClasses && isset ( $ a [ 'class' ] ) && isset ( $ b [ 'class' ] ) ) { $ a [ 'class' ] = self :: mergeClasses ( $ a [ 'class' ] , $ b [ 'class' ] ) ; unset ( $ b [ 'class' ] ) ; } if ( $ combineStyles && isset ( $ a [ 'style' ] ) && isset ( $ b [ 'style' ] ) ) { $ a [ 'style' ] = self :: mergeStyles ( $ a [ 'style' ] , $ b [ 'style' ] ) ; unset ( $ b [ 'style' ] ) ; } $ r = array_merge ( $ b , $ a ) ; ksort ( $ r ) ; return $ r ; }
Merge two sets of Tag attributes .
25,853
public static function addDefaultAttributes ( Tag & $ Tag ) { if ( isset ( TagInfo :: $ defaultAttributes [ $ Tag -> name ] ) ) { $ Tag -> attributes = array_merge ( TagInfo :: $ defaultAttributes [ $ Tag -> name ] , $ Tag -> attributes ) ; } }
Adds default attributes to the tag .
25,854
public static function addDefaultOptions ( Tag & $ Tag ) { if ( isset ( TagInfo :: $ defaultOptions [ $ Tag -> name ] ) ) { foreach ( TagInfo :: $ defaultOptions [ $ Tag -> name ] as $ defopt ) { if ( ! in_array ( $ defopt , $ Tag -> options ) ) { $ Tag -> options [ ] = $ defopt ; } } } }
Adds default options to the tag .
25,855
public static function addDoubleAttributes ( Tag & $ Tag ) { if ( isset ( TagInfo :: $ doubleAttrs [ $ Tag -> name ] ) ) { $ missing = array ( ) ; $ found = '' ; foreach ( TagInfo :: $ doubleAttrs [ $ Tag -> name ] as $ k => $ name ) { if ( $ k === '%callback' ) { $ callback = $ name ; continue ; } if ( isset ( $ Tag -> attributes [ $ name ] ) ) { $ found = $ Tag -> attributes [ $ name ] ; } else { $ missing [ ] = $ name ; } } if ( empty ( $ found ) || empty ( $ missing ) ) { return ; } foreach ( $ missing as $ k ) { $ Tag -> attributes [ $ k ] = $ found ; } if ( count ( $ missing ) && isset ( $ callback ) && is_callable ( $ callback ) ) { call_user_func_array ( $ callback , array ( & $ Tag , $ missing ) ) ; } } }
Duplicates some attributes if needed .
25,856
public static function magicAlt ( Tag & $ Tag , $ changed ) { switch ( $ Tag -> realName ) { case 'img' : if ( in_array ( 'alt' , $ changed ) ) { $ Tag -> attributes [ 'alt' ] = basename ( $ Tag -> attributes [ 'alt' ] ) ; } break ; default : break ; } }
Callback function for double attrs on an image tag .
25,857
public static function getKeyAlias ( array & $ attr ) { foreach ( TagInfo :: $ attrKeyAliases as $ alias => $ key ) { if ( strpos ( $ attr [ 0 ] , $ alias ) === 0 ) { return compact ( 'key' , 'alias' ) ; } } return false ; }
Checks and applies aliases for attribute keys
25,858
private static function _ignoreKeyAlias ( array $ t , Tag & $ Tag ) { extract ( $ t ) ; $ single = self :: getSingleAttrKey ( $ Tag ) ; if ( isset ( TagInfo :: $ ignoreAlisasesOnSingle [ $ single ] ) && in_array ( $ alias , TagInfo :: $ ignoreAlisasesOnSingle [ $ single ] ) ) { return true ; } return false ; }
Checks if the current key alias is meant to be ignored .
25,859
public static function getSingleAttrKey ( Tag & $ Tag ) { if ( isset ( TagInfo :: $ singleAttrKeys [ $ Tag -> name ] ) ) { return TagInfo :: $ singleAttrKeys [ $ Tag -> name ] ; } else { return TagInfo :: $ defaultSingleAttrKey ; } }
Getter for the single attribute keys
25,860
public function writeStartElement ( string $ elementName ) : self { $ this -> doWriteStartElement ( $ elementName ) ; $ this -> depth ++ ; return $ this ; }
Write an opening tag
25,861
public function writeEndElement ( ) : self { if ( $ this -> isFinished ( ) ) { throw new \ LogicException ( 'Can not write end elements, no element open.' ) ; } $ this -> doWriteEndElement ( ) ; $ this -> depth -- ; return $ this ; }
Write an end element
25,862
public static function getClean ( $ str ) { if ( is_object ( $ str ) && get_class ( $ str ) == 'Xiphe\HTML\core\Tag' ) { $ Tag = $ str ; $ str = $ Tag -> content ; } switch ( Config :: get ( 'cleanMode' ) ) { case 'strong' : $ str = self :: getStrong ( $ str ) ; break ; case 'basic' : $ str = self :: getBasic ( $ str ) ; break ; default : return $ str ; } if ( isset ( $ Tag ) ) { $ Tag -> content = $ str ; } return $ str ; }
Cleans up the given content
25,863
public static function getBasic ( $ str ) { $ r = '' ; foreach ( preg_split ( '/\n\r|\n|\r/' , $ str , - 1 , PREG_SPLIT_NO_EMPTY ) as $ k => $ line ) { $ r .= Generator :: getTabs ( ) ; $ r .= trim ( $ line ) ; $ r .= Generator :: getLineBreak ( ) ; } return $ r ; }
unifies the tabs in the given string .
25,864
public static function parseAttrs ( $ attr ) { if ( trim ( $ attr ) == '' ) { return '' ; } preg_match_all ( '/[a-zA-Z0-9-_:.]+(\s?=\s?("|\')[^\2]*\2|\s)/U' , $ attr , $ attr ) ; $ attr = $ attr [ 0 ] ; $ r = array ( ) ; foreach ( $ attr as $ k => $ v ) { if ( trim ( $ v ) == '' ) { continue ; } $ e = explode ( '=' , $ v , 2 ) ; $ at = trim ( $ e [ 0 ] ) ; $ val = isset ( $ e [ 1 ] ) ? trim ( $ e [ 1 ] ) : null ; if ( $ val !== null ) { $ val = trim ( $ val , substr ( $ val , 0 , 1 ) ) ; } $ r [ $ at ] = $ val ; } return $ r ; }
Parses tag attributes into an array .
25,865
public static function getStrong ( $ str ) { $ tree = preg_split ( '/(<[^!]?[^>]+>(<![^>]+>)?)/' , $ str , - 1 , PREG_SPLIT_OFFSET_CAPTURE | PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY ) ; $ r = array ( ) ; $ line = '' ; $ isInline = true ; $ oneLine = array ( ) ; $ lastWasTag = false ; foreach ( $ tree as $ k => $ elm ) { $ info ; switch ( self :: _getTreeElm ( $ elm [ 0 ] , $ info ) ) { case 'start' : $ add = new Tag ( $ info [ 1 ] , array ( self :: parseAttrs ( $ info [ 2 ] ) ) , array ( 'generate' , ( $ info [ 3 ] == '/>' ? 'selfQlose' : 'doNotSelfQlose' ) , 'start' , ( in_array ( $ info [ 1 ] , TagInfo :: $ inlineTags ) ? 'inline' : null ) ) ) ; break ; case 'end' : $ add = Store :: get ( ) ; break ; case 'comment' : case 'content' : default : $ add = $ elm [ 0 ] ; break ; } self :: _toLine ( $ add , $ r , $ line , $ isInline , $ oneLine , $ lastWasTag ) ; } if ( strlen ( $ line ) ) { $ r [ ] = $ line ; } return implode ( Generator :: getLineBreak ( ) , $ r ) . Generator :: getLineBreak ( ) ; }
Tears the given string into its smalest possible parts and rebuilds it so it will fit nicely into the markup generated by Xiphe \ HTML
25,866
private static function _getTreeElm ( $ str , & $ info ) { $ str = preg_replace ( '/(\n\r|\n|\r|\s)+/' , ' ' , $ str ) ; if ( strpos ( $ str , '</' ) === 0 ) { return 'end' ; } elseif ( strpos ( $ str , '<!' ) === 0 ) { return 'content' ; } elseif ( strpos ( $ str , '<!--' ) === 0 ) { return 'comment' ; } elseif ( strpos ( $ str , '<' ) === 0 ) { preg_match ( '/<([a-zA-Z0-9]+)(.*?(?=\/>|>))(\/>|>)+/' , $ str , $ info ) ; return 'start' ; } return 'content' ; }
Checks the type of the given tree element .
25,867
protected function callbacks ( ) : array { if ( ! is_array ( $ this -> callbackList ) ) { if ( ! file_exists ( $ this -> configPath . '/xsl-callbacks.ini' ) ) { $ this -> callbackList = [ ] ; } else { $ this -> callbackList = @ parse_ini_file ( $ this -> configPath . '/xsl-callbacks.ini' ) ; if ( false === $ this -> callbackList ) { throw new XslCallbackException ( 'XSL callback in ' . $ this -> configPath . '/xsl-callbacks.ini contains errors and can not be parsed.' ) ; } } } return $ this -> callbackList ; }
reads list of callbacks from configuration
25,868
final public function init ( & $ args , & $ options , & $ called ) { $ this -> args = & $ args ; $ this -> options = & $ options ; $ this -> called = & $ called ; if ( class_exists ( '\WP' ) ) { call_user_func_array ( 'do_action' , array ( 'Xiphe\HTML\ModuleCreated' , & $ this , Config :: getHTMLInstance ( ) ) ) ; } }
Initiation of a new module .
25,869
final public function generate ( ) { $ options = array_merge ( $ this -> options , ( array ) 'generate' ) ; Generator :: call ( $ this -> called , $ this -> args , $ options ) ; }
Generates a default tag using the current module parameters .
25,870
public function onWSClientCommand ( WSEventDispatcher \ WSClientEvent $ event ) { $ this -> data [ 'commands' ] [ ] = array ( 'command' => $ event -> getCommand ( ) , 'arguments' => $ event -> getArguments ( ) , 'url' => $ event -> getUrl ( ) , 'cache' => $ event -> getUseCache ( ) , 'content' => $ event -> getContent ( ) , 'key' => $ event -> getKey ( ) , 'statusCode' => $ event -> getStatusCode ( ) , 'executiontime' => $ event -> getTiming ( ) ) ; }
Listen for wsclient command event
25,871
public function serialize ( $ value , XmlStreamWriter $ xmlWriter , string $ tagName = null , string $ elementTagName = null ) : XmlStreamWriter { switch ( gettype ( $ value ) ) { case 'NULL' : $ this -> serializeNull ( $ xmlWriter , $ tagName ) ; break ; case 'boolean' : $ this -> serializeBool ( $ value , $ xmlWriter , $ tagName ) ; break ; case 'string' : case 'integer' : case 'double' : $ this -> serializeScalarValue ( $ value , $ xmlWriter , $ tagName ) ; break ; case 'array' : $ this -> serializeArray ( $ value , $ xmlWriter , $ tagName , $ elementTagName ) ; break ; case 'object' : if ( $ value instanceof \ Traversable && ! annotationsOf ( $ value ) -> contain ( 'XmlNonTraversable' ) ) { if ( null === $ tagName && $ value instanceof \ Traversable && annotationsOf ( $ value ) -> contain ( 'XmlTag' ) ) { $ annotation = annotationsOf ( $ value ) -> firstNamed ( 'XmlTag' ) ; $ tagName = $ annotation -> getTagName ( ) ; $ elementTagName = $ annotation -> getElementTagName ( ) ; } $ this -> serializeArray ( $ value , $ xmlWriter , $ tagName , $ elementTagName ) ; } else { $ this -> serializeObject ( $ value , $ xmlWriter , $ tagName ) ; } break ; default : } return $ xmlWriter ; }
serialize any data structure to xml
25,872
public function serializeNull ( XmlStreamWriter $ xmlWriter , string $ tagName = null ) : XmlStreamWriter { return $ xmlWriter -> writeStartElement ( null === $ tagName ? 'null' : $ tagName ) -> writeElement ( 'null' ) -> writeEndElement ( ) ; }
serializes null to xml
25,873
public function serializeBool ( $ value , XmlStreamWriter $ xmlWriter , string $ tagName = null ) : XmlStreamWriter { return $ this -> serializeScalarValue ( $ this -> convertBoolToString ( $ value ) , $ xmlWriter , null === $ tagName ? 'boolean' : $ tagName ) ; }
serializes boolean value to xml
25,874
public function serializeFloat ( $ value , XmlStreamWriter $ xmlWriter , string $ tagName = null ) : XmlStreamWriter { return $ this -> serializeScalarValue ( $ value , $ xmlWriter , $ tagName ) ; }
serializes float value to xml
25,875
protected function serializeScalarValue ( $ value , XmlStreamWriter $ xmlWriter , string $ tagName = null ) : XmlStreamWriter { return $ xmlWriter -> writeStartElement ( null === $ tagName ? gettype ( $ value ) : $ tagName ) -> writeText ( strval ( $ value ) ) -> writeEndElement ( ) ; }
serializes any scalar value to xml
25,876
public function serializeArray ( $ array , XmlStreamWriter $ xmlWriter , string $ tagName = null , string $ elementTagName = null ) : XmlStreamWriter { if ( null === $ tagName ) { $ tagName = 'array' ; } if ( ! empty ( $ tagName ) ) { $ xmlWriter -> writeStartElement ( $ tagName ) ; } foreach ( $ array as $ key => $ value ) { if ( is_int ( $ key ) ) { $ this -> serialize ( $ value , $ xmlWriter , $ elementTagName ) ; } else { $ this -> serialize ( $ value , $ xmlWriter , $ key ) ; } } if ( ! empty ( $ tagName ) ) { $ xmlWriter -> writeEndElement ( ) ; } return $ xmlWriter ; }
serializes an array to xml
25,877
public function serializeObject ( $ object , XmlStreamWriter $ xmlWriter , string $ tagName = null ) : XmlStreamWriter { $ this -> serializerFor ( $ object ) -> serialize ( $ object , $ this , $ xmlWriter , $ tagName ) ; return $ xmlWriter ; }
serializes an object to xml
25,878
protected function serializerFor ( $ object ) : ObjectXmlSerializer { if ( ! annotationsOf ( $ object ) -> contain ( 'XmlSerializer' ) ) { return AnnotationBasedObjectXmlSerializer :: fromObject ( $ object ) ; } return $ this -> injector -> getInstance ( annotationsOf ( $ object ) -> firstNamed ( 'XmlSerializer' ) -> getValue ( ) -> getName ( ) ) ; }
returns serializer for given object
25,879
public function onXmlFile ( string $ xmlFile , bool $ xinclude = true ) : self { $ doc = new \ DOMDocument ( ) ; if ( false === @ $ doc -> load ( $ xmlFile ) ) { throw new XslProcessorException ( 'Can not read xml document file ' . $ xmlFile ) ; } if ( true === $ xinclude ) { $ doc -> xinclude ( ) ; } return $ this -> onDocument ( $ doc ) ; }
sets the document to transform
25,880
public function applyStylesheet ( \ DOMDocument $ stylesheet ) : self { $ this -> stylesheets [ ] = $ stylesheet ; $ this -> xsltProcessor -> importStylesheet ( $ stylesheet ) ; return $ this ; }
add a stylesheet to use
25,881
public function applyStylesheetFromFile ( string $ stylesheetFile ) : self { $ stylesheet = new \ DOMDocument ( ) ; if ( false === @ $ stylesheet -> load ( $ stylesheetFile ) ) { throw new XslProcessorException ( 'Can not read stylesheet file ' . $ stylesheetFile ) ; } return $ this -> applyStylesheet ( $ stylesheet ) ; }
add a stylesheet to use from a file
25,882
public function usingCallback ( string $ name , $ instance ) : self { $ this -> xslCallbacks -> addCallback ( $ name , $ instance ) ; return $ this ; }
register an instance as callback
25,883
protected function registerCallbacks ( ) { self :: $ _callbacks = $ this -> xslCallbacks ; $ this -> xsltProcessor -> registerPHPFunctions ( get_class ( $ this ) . '::invokeCallback' ) ; }
register all callback instances
25,884
public function withParameter ( string $ nameSpace , string $ paramName , string $ paramValue ) : self { if ( false === $ this -> xsltProcessor -> setParameter ( $ nameSpace , $ paramName , $ paramValue ) ) { throw new XslProcessorException ( 'Could not set parameter ' . $ nameSpace . ':' . $ paramName . ' with value ' . $ paramValue ) ; } if ( ! isset ( $ this -> parameters [ $ nameSpace ] ) ) { $ this -> parameters [ $ nameSpace ] = [ ] ; } $ this -> parameters [ $ nameSpace ] [ $ paramName ] = $ paramValue ; return $ this ; }
sets a parameter for a namespace
25,885
public function withParameters ( string $ nameSpace , array $ params ) : self { if ( false === $ this -> xsltProcessor -> setParameter ( $ nameSpace , $ params ) ) { throw new XslProcessorException ( 'Could not set parameters in ' . $ nameSpace ) ; } if ( ! isset ( $ this -> parameters [ $ nameSpace ] ) ) { $ this -> parameters [ $ nameSpace ] = [ ] ; } $ this -> parameters [ $ nameSpace ] = array_merge ( $ this -> parameters [ $ nameSpace ] , $ params ) ; return $ this ; }
set a list of parameters for the given namespace
25,886
public function toDoc ( ) : \ DOMDocument { if ( null === $ this -> document ) { throw new XslProcessorException ( 'Can not transform, set document or xml file to transform first' ) ; } $ this -> registerCallbacks ( ) ; $ result = $ this -> xsltProcessor -> transformToDoc ( $ this -> document ) ; if ( false === $ result ) { throw new XslProcessorException ( $ this -> createMessage ( ) ) ; } return $ result ; }
transoforms the document into another DOMDocument
25,887
public function toUri ( string $ uri ) : int { if ( null === $ this -> document ) { throw new XslProcessorException ( 'Can not transform, set document or xml file to transform first' ) ; } $ this -> registerCallbacks ( ) ; $ bytes = $ this -> xsltProcessor -> transformToURI ( $ this -> document , $ uri ) ; if ( false === $ bytes ) { throw new XslProcessorException ( $ this -> createMessage ( ) ) ; } return $ bytes ; }
transforms the document and saves it to the given uri returns the amount of bytes written
25,888
public function toXml ( ) : string { if ( null === $ this -> document ) { throw new XslProcessorException ( 'Can not transform, set document or xml file to transform first' ) ; } $ this -> registerCallbacks ( ) ; $ result = $ this -> xsltProcessor -> transformToXML ( $ this -> document ) ; if ( false === $ result ) { throw new XslProcessorException ( $ this -> createMessage ( ) ) ; } return $ result ; }
transforms the document and returns the result as string
25,889
private function createMessage ( ) : string { $ message = '' ; foreach ( libxml_get_errors ( ) as $ error ) { $ message .= trim ( $ error -> message ) . ( ( $ error -> file ) ? ( ' in file ' . $ error -> file ) : ( '' ) ) . ' on line ' . $ error -> line . ' in column ' . $ error -> column . "\n" ; } libxml_clear_errors ( ) ; if ( strlen ( $ message ) === 0 ) { return 'Transformation failed: unknown error.' ; } return $ message ; }
creates a message frim the last libxml error
25,890
protected function createStreamWriter ( string $ xmlExtension ) : XmlStreamWriter { $ className = $ this -> types [ $ xmlExtension ] ; return new $ className ( $ this -> version , $ this -> encoding ) ; }
creates a xml stream writer of the given type
25,891
protected function createAsAvailable ( ) : XmlStreamWriter { foreach ( array_keys ( $ this -> types ) as $ xmlExtension ) { if ( extension_loaded ( $ xmlExtension ) ) { return $ this -> createStreamWriter ( $ xmlExtension ) ; } } throw new XmlException ( 'No supported xml extension available, can not create a xml stream writer!' ) ; }
creates a xml stream writer depending on available xml extensions
25,892
public function asManyToMany ( $ alias , $ junction , $ column , $ table , $ pk , $ columns = '*' ) { $ this -> relationProcessor -> queue ( __FUNCTION__ , func_get_args ( ) ) ; return $ this ; }
Appends many - to - many grabber to the queue
25,893
public function asOneToOne ( $ column , $ alias , $ table , $ link ) { $ this -> relationProcessor -> queue ( __FUNCTION__ , func_get_args ( ) ) ; return $ this ; }
Appends one - to - one grabber to the queue
25,894
public function asOneToMany ( $ table , $ pk , $ alias ) { $ this -> relationProcessor -> queue ( __FUNCTION__ , func_get_args ( ) ) ; return $ this ; }
Appends one - to - many grabber to the queue
25,895
private function asData ( array $ data ) { foreach ( $ data as $ key => $ value ) { if ( $ value instanceof RawSqlFragmentInterface ) { $ data [ $ key ] = $ value -> getFragment ( ) ; } elseif ( $ value instanceof RawBindingInterface ) { $ data [ $ key ] = $ value -> getTarget ( ) ; } else { $ placeholder = $ this -> getUniqPlaceholder ( ) ; $ data [ $ key ] = $ placeholder ; $ this -> bind ( $ placeholder , $ value ) ; } } return $ data ; }
Prepared raw data before a command is executed
25,896
private function createUniqPlaceholder ( $ key ) { if ( $ key instanceof RawSqlFragment ) { $ placeholder = $ key -> getFragment ( ) ; } else if ( $ key instanceof RawBindingInterface ) { $ placeholder = $ key -> getTarget ( ) ; } else { $ placeholder = $ this -> getUniqPlaceholder ( ) ; $ this -> bind ( $ placeholder , $ key ) ; } return $ placeholder ; }
Creates unique placeholder
25,897
private function getCount ( $ column ) { $ alias = 'count' ; $ original = clone $ this -> queryBuilder ; $ bindings = $ this -> bindings ; $ this -> queryBuilder -> setQueryString ( $ this -> queryBuilder -> guessCountQuery ( $ column , $ alias ) ) ; $ count = $ this -> query ( $ alias ) ; $ this -> queryBuilder = $ original ; $ this -> bindings = $ bindings ; return $ count ; }
Returns count for pagination This is the implementation of Memento pattern
25,898
public function fetchAllTables ( ) { $ tables = array ( ) ; $ result = $ this -> pdo -> query ( 'SHOW TABLES' ) -> fetchAll ( ) ; foreach ( $ result as $ index => $ array ) { $ data = array_values ( $ array ) ; $ tables [ ] = $ data [ 0 ] ; } return $ tables ; }
Fetch all tables
25,899
public function dump ( array $ tables = array ( ) ) { $ result = null ; if ( empty ( $ tables ) ) { $ tables = $ this -> fetchAllTables ( ) ; } foreach ( $ tables as $ table ) { $ select = $ this -> queryBuilder -> clear ( ) -> select ( '*' ) -> from ( $ table ) -> getQueryString ( ) ; $ stmt = $ this -> pdo -> query ( $ select ) ; $ fieldCount = $ stmt -> columnCount ( ) ; $ result .= $ this -> queryBuilder -> clear ( ) -> dropTable ( $ table ) -> getQueryString ( ) ; ; $ createResult = $ this -> pdo -> query ( sprintf ( 'SHOW CREATE TABLE %s' , $ table ) ) -> fetch ( ) ; $ result .= "\n\n" . $ createResult [ 'Create Table' ] . ";\n\n" ; for ( $ i = 0 ; $ i < $ fieldCount ; $ i ++ ) { while ( $ row = $ stmt -> fetch ( PDO :: FETCH_NUM ) ) { $ values = array ( ) ; for ( $ j = 0 ; $ j < $ fieldCount ; $ j ++ ) { $ row [ $ j ] = addslashes ( $ row [ $ j ] ) ; $ row [ $ j ] = str_replace ( "\n" , "\\n" , $ row [ $ j ] ) ; $ row [ $ j ] = sprintf ( '"%s"' , $ row [ $ j ] ) ; array_push ( $ values , $ row [ $ j ] ) ; } $ result .= $ this -> queryBuilder -> clear ( ) -> insertShort ( $ table , $ values ) -> getQueryString ( ) ; $ result .= "\n" ; unset ( $ vals ) ; } } $ result .= "\n" ; } return $ result ; }
Dump tables into SQL string