idx
int64
0
60.3k
question
stringlengths
64
4.24k
target
stringlengths
5
618
5,900
public function getValues ( ) { $ cookies = [ ] ; try { foreach ( $ this -> cookies as $ name => $ cookie ) { $ cookies [ $ name ] = $ cookie -> getValue ( ) ; } } catch ( CookieException $ ce ) { throw $ ce ; } return $ cookies ; }
Get values from all registered cookies and dump as an associative array
5,901
public function save ( ) { try { foreach ( $ this -> cookies as $ c ) { $ c -> save ( ) ; } } catch ( CookieException $ ce ) { throw $ ce ; } return true ; }
Save all registered cookies
5,902
public function load ( ) { try { foreach ( $ this -> cookies as $ c ) { $ c -> load ( ) ; } } catch ( CookieException $ ce ) { throw $ ce ; } return $ this ; }
Load all registered cookies
5,903
public function addCategory ( array $ category ) { if ( empty ( $ category [ 'term' ] ) ) { require_once 'Zend/Feed/Builder/Exception.php' ; throw new Zend_Feed_Builder_Exception ( "you have to define the name of the category" ) ; } if ( ! $ this -> offsetExists ( 'category' ) ) { $ categories = array ( $ category ) ; } else { $ categories = $ this -> offsetGet ( 'category' ) ; $ categories [ ] = $ category ; } $ this -> offsetSet ( 'category' , $ categories ) ; return $ this ; }
Add a category to the entry
5,904
public function addEnclosure ( $ url , $ type = '' , $ length = '' ) { if ( ! $ this -> offsetExists ( 'enclosure' ) ) { $ enclosure = array ( ) ; } else { $ enclosure = $ this -> offsetGet ( 'enclosure' ) ; } $ enclosure [ ] = array ( 'url' => $ url , 'type' => $ type , 'length' => $ length ) ; $ this -> offsetSet ( 'enclosure' , $ enclosure ) ; return $ this ; }
Add an enclosure to the entry
5,905
public function all ( ) { $ result = array ( ) ; $ data = $ this -> data ( ) ; if ( ! is_array ( $ data ) ) $ data = array ( $ data ) ; foreach ( $ data as $ entry ) { $ result [ ] = $ this -> resolveActionFromStdClass ( $ entry ) ; } return $ result ; }
returns a list of all actions
5,906
public function action ( ) { $ action = $ this -> data ( ) ; if ( ! $ action instanceof stdClass ) return null ; return $ this -> resolveActionFromStdClass ( $ action ) ; }
returns the action or null
5,907
protected function sessionSection ( Request $ request ) : SectionInterface { if ( empty ( $ request -> getAttribute ( SessionStarter :: ATTRIBUTE ) ) ) { throw new AuthException ( "Unable to use authorization thought session, no session exists" ) ; } $ session = $ request -> getAttribute ( SessionStarter :: ATTRIBUTE ) ; return $ session -> getSection ( $ this -> section ) ; }
Get session section from given request .
5,908
public function toJson ( array $ fields = [ ] , array $ expand = [ ] , $ recursive = true ) { return Json :: encode ( $ this -> toArray ( $ fields , $ expand , $ recursive ) ) ; }
Converts the model into an json .
5,909
public static function create ( $ name = null , $ driver = 'file' ) { if ( is_null ( $ name ) ) { return new static ( null , $ driver ) ; } if ( ! isset ( static :: $ instances [ $ name ] ) ) { static :: $ instances [ $ name ] = new static ( $ name , $ driver ) ; } return static :: $ instances [ $ name ] ; }
Create a configuration instance
5,910
public function driver ( $ driver ) { $ driver = CCCORE_NAMESPACE . '\\' . 'CCConfig_' . ucfirst ( $ driver ) ; if ( ! class_exists ( $ driver ) ) { throw new \ InvalidArgumentException ( "CCConfig - Invalid driver '" . $ driver . "'" ) ; } $ this -> _driver = new $ driver ; }
Set the configuration dirver
5,911
public function name ( $ name = null ) { if ( is_null ( $ name ) ) { return $ this -> _instance_name ; } $ this -> _instance_name = $ name ; }
Name getter and setter
5,912
public function write ( $ driver = null ) { if ( empty ( $ this -> _instance_name ) ) { throw new CCException ( "CCConfig::write - configuration name is missing." ) ; } if ( ! is_null ( $ driver ) ) { $ this -> driver ( $ driver ) ; } $ this -> _driver -> write ( $ this -> _instance_name , $ this -> _data ) ; }
save a configuration file this method overwrites your configuration file!!
5,913
public function _delete ( ) { if ( empty ( $ this -> _instance_name ) ) { throw new CCException ( "CCConfig::write - configuration name is missing." ) ; } return $ this -> _driver -> delete ( $ this -> _instance_name ) ; }
Delete the entire configuration Attention with this one he can be evil!
5,914
final protected function initTaxonomiesTrait ( ) : void { add_action ( "init" , function ( ) { foreach ( $ this -> getTaxonomies ( ) as $ taxonomy ) { $ this -> registerTaxonomy ( $ taxonomy ) ; } } , 15 ) ; }
Initializes this trait and registers these taxonomies using the appropriate WordPress action hook .
5,915
protected function beforeApplyOptions ( $ stub ) { $ refModel = new ReflectionClass ( $ this -> model ) ; $ refIntermeidateModel = new ReflectionClass ( $ this -> defaultOptions [ 'intermediate_model' ] ) ; $ model = $ refIntermeidateModel -> getShortName ( ) ; if ( $ refModel -> getNamespaceName ( ) !== $ refIntermeidateModel -> getNamespaceName ( ) ) { $ model = '\\' . $ refIntermeidateModel -> getName ( ) ; } return str_replace ( 'DummyIntermediateModel' , $ model , $ stub ) ; }
replace more before apply options code
5,916
public static function instance ( ) { if ( null === self :: $ _instance ) { $ session_factory = new SessionFactory ; $ session = $ session_factory -> newInstance ( $ _COOKIE ) ; $ segment = $ session -> getSegment ( 'Barebone\Session' ) ; self :: $ _instance = $ segment ; } return self :: $ _instance ; }
Instantiate Session Segment
5,917
public static function setup ( $ prefix = null ) { $ theme = self :: name ( $ prefix ) ; $ path = self :: find ( $ theme ) ; if ( $ path !== null ) { $ config = self :: getData ( $ theme , 'meta' ) ; if ( $ config -> get ( 'type' ) == 'theme' ) { return $ theme ; } } return null ; }
Setup current theme .
5,918
public static function find ( $ theme ) { $ paths = App :: path ( 'Plugin' ) ; foreach ( $ paths as $ path ) { $ path = FS :: clean ( $ path . '/' , DS ) ; $ themeFolder = $ path . $ theme ; if ( FS :: isDir ( $ themeFolder ) ) { return $ themeFolder ; } } return Configure :: read ( 'plugins.' . $ theme ) ; }
Find theme plugin in path .
5,919
private function assertCurlResult ( $ curl , $ result , $ descriptor ) { if ( $ result === false ) { $ error = curl_error ( $ curl ) ; @ curl_close ( $ curl ) ; throw new RequestError ( $ error , $ descriptor ) ; } @ curl_close ( $ curl ) ; return $ result ; }
Asserts that the curl result was successful .
5,920
private function parseHeader ( $ header ) { list ( $ key , $ value ) = explode ( ": " , trim ( $ header ) , 2 ) ; return array ( strtolower ( $ key ) , $ value ) ; }
Parses an HTTP header line .
5,921
private function openFile ( $ file , $ mode ) { $ handle = @ fopen ( $ file , $ mode ) ; if ( $ handle === false ) { throw new \ InvalidArgumentException ( "Could not open $file" ) ; } return $ handle ; }
Opens a file and returns a file handle .
5,922
public function getRoute ( $ name ) { if ( ! isset ( $ this -> routes [ $ name ] ) ) { throw new \ LogicException ( sprintf ( 'Route "%s" not found.' , $ name ) ) ; } return $ this -> routes [ $ name ] ; }
Get Route from name
5,923
public function getSetting ( $ name ) { if ( ! isset ( $ this -> settings [ $ name ] ) ) { throw new \ LogicException ( sprintf ( 'The setting "%s" don\'t exists.' , $ name ) ) ; } return $ this -> settings [ $ name ] ; }
Set setting from name
5,924
public function getMetadata ( $ className , $ subset ) { $ classMetadataCacheKey = $ this -> getClassMetadataCacheKey ( $ className ) ; $ classMetadata = $ this -> cacheStorage -> getItem ( $ classMetadataCacheKey ) ; if ( $ classMetadata === null ) { $ classMetadata = $ this -> readClassMetadata ( $ className ) ; $ this -> cacheStorage -> addItem ( $ classMetadataCacheKey , $ classMetadata ) ; } if ( ! is_array ( $ classMetadata ) ) { throw new \ LogicException ( sprintf ( 'Invalid metadata for class %s.' , $ className ) ) ; } if ( ! isset ( $ classMetadata [ $ subset ] ) ) { throw new \ LogicException ( sprintf ( 'No metadata for subset "%s" in class %s.' , $ subset , $ className ) ) ; } $ subsetMetadata = $ classMetadata [ $ subset ] ; if ( ! ( $ subsetMetadata instanceof DT \ Metadata ) ) { throw new \ LogicException ( sprintf ( 'Invalid metadata for subset "%s" in class %s.' , $ subset , $ className ) ) ; } return $ subsetMetadata ; }
Returns metadata for specified subset of class fields
5,925
protected static function readPropertyAnnotations ( \ ReflectionProperty & $ property , AnnotationReader & $ reader ) { $ dataMap = [ ] ; $ strategyMap = [ ] ; $ validatorsMap = [ ] ; foreach ( $ reader -> getPropertyAnnotations ( $ property ) as $ annotation ) { switch ( true ) { case ( $ annotation instanceof DT \ Annotation \ Data ) : $ dataMap [ $ annotation -> subset ] = $ annotation ; break ; case ( $ annotation instanceof DT \ Annotation \ Strategy ) : $ strategyMap [ $ annotation -> subset ] = $ annotation ; break ; case ( $ annotation instanceof DT \ Annotation \ Validator ) : $ validatorsMap [ $ annotation -> subset ] [ ] = $ annotation ; break ; } } foreach ( $ dataMap as $ subset => $ data ) { $ strategy = isset ( $ strategyMap [ $ subset ] ) ? $ strategyMap [ $ subset ] : null ; $ validators = isset ( $ validatorsMap [ $ subset ] ) ? $ validatorsMap [ $ subset ] : [ ] ; yield $ subset => [ $ data , $ strategy , $ validators ] ; } }
Reads and groups up annotations for specified property
5,926
protected static function isValidGetter ( \ ReflectionClass & $ reflection , $ name ) { if ( ! $ reflection -> hasMethod ( $ name ) ) { throw new \ LogicException ( sprintf ( 'Invalid metadata for %s: no getter %s.' , $ reflection -> getName ( ) , $ name ) ) ; } $ getter = $ reflection -> getMethod ( $ name ) ; if ( ! $ getter -> isPublic ( ) ) { throw new \ LogicException ( sprintf ( 'Invalid metadata for %s: getter %s is not public.' , $ reflection -> getName ( ) , $ name ) ) ; } if ( $ getter -> getNumberOfRequiredParameters ( ) > 0 ) { throw new \ LogicException ( sprintf ( 'Invalid metadata for %s: getter %s should not require parameters.' , $ reflection -> getName ( ) , $ name ) ) ; } return true ; }
Validates if class has valid getter method with specified name
5,927
protected static function isValidSetter ( \ ReflectionClass & $ reflection , $ name ) { if ( ! $ reflection -> hasMethod ( $ name ) ) { throw new \ LogicException ( sprintf ( 'Invalid metadata for %s: no setter %s.' , $ reflection -> getName ( ) , $ name ) ) ; } $ setter = $ reflection -> getMethod ( $ name ) ; if ( ! $ setter -> isPublic ( ) ) { throw new \ LogicException ( sprintf ( 'Invalid metadata for %s: setter %s is not public.' , $ reflection -> getName ( ) , $ name ) ) ; } if ( $ setter -> getNumberOfParameters ( ) < 1 ) { throw new \ LogicException ( sprintf ( 'Invalid metadata for %s: setter %s should accept at least one parameter.' , $ reflection -> getName ( ) , $ name ) ) ; } if ( $ setter -> getNumberOfRequiredParameters ( ) > 1 ) { throw new \ LogicException ( sprintf ( 'Invalid metadata for %s: setter %s requires too many parameters.' , $ reflection -> getName ( ) , $ name ) ) ; } return true ; }
Validates if class has valid setter method with specified name
5,928
public function validate ( array $ array ) { $ messages = [ ] ; foreach ( $ this -> metadata -> fields as $ field ) { $ value = array_key_exists ( $ field , $ array ) ? $ array [ $ field ] : null ; if ( ! ( ( $ value === null ) && $ this -> metadata -> nullables [ $ field ] ) ) { $ validator = $ this -> getValidator ( $ field ) ; if ( ! $ validator -> isValid ( $ value ) ) { $ messages [ $ field ] = $ validator -> getMessages ( ) ; } } } $ globalValidator = $ this -> getValidator ( self :: GLOBAL_VALIDATOR_KEY ) ; if ( ! $ globalValidator -> isValid ( $ array ) ) { $ messages [ self :: GLOBAL_VALIDATOR_KEY ] = $ globalValidator -> getMessages ( ) ; } return $ messages ; }
Validates associative array according metadata
5,929
protected function getValidator ( $ field ) { $ result = null ; if ( isset ( $ this -> validators [ $ field ] ) ) { $ result = $ this -> validators [ $ field ] ; } else { $ result = new ValidatorChain ( ) ; $ result -> setPluginManager ( $ this -> validatorPluginManager ) ; if ( isset ( $ this -> metadata -> validators [ $ field ] ) ) { foreach ( $ this -> metadata -> validators [ $ field ] as $ validator ) { $ result -> attachByName ( $ validator -> name , $ validator -> options , true , $ validator -> priority ) ; } } if ( ( $ field !== self :: GLOBAL_VALIDATOR_KEY ) && ( $ this -> metadata -> nullables [ $ field ] === false ) ) { $ result -> attachByName ( NotEmpty :: class , [ 'type' => NotEmpty :: NULL | NotEmpty :: OBJECT ] , true , 10000 ) ; } $ this -> validators [ $ field ] = $ result ; } return $ result ; }
Builds validator chain for specified field according metadata
5,930
public function getTemplatePath ( ) { $ useRepositoryLayer = config ( 'generator.use_repository_layer' , true ) ; $ useServiceLayer = config ( 'generator.use_service_layer' , true ) ; if ( $ useServiceLayer && $ useRepositoryLayer ) { $ templateFilename = 'Controller_Service' ; } elseif ( $ useRepositoryLayer ) { $ templateFilename = 'Controller_Repository' ; } else { $ templateFilename = 'Controller' ; } return 'scaffold/' . $ templateFilename ; }
Get the template path for generate
5,931
public function getResponseCode ( ) { $ code = 0 ; $ dom = $ this -> getDOMDocument ( ) ; $ xpath = new DOMXPath ( $ dom ) ; if ( ( $ codeAttribute = $ xpath -> query ( '/response/@code' ) -> item ( 0 ) ) instanceof DOMAttr ) { $ code = intval ( $ codeAttribute -> nodeValue ) ; } return $ code ; }
Returns the response code from the API .
5,932
public function getErrorMessage ( ) { $ errorMessage = '' ; $ dom = $ this -> getDOMDocument ( ) ; $ xpath = new DOMXPath ( $ dom ) ; if ( ( $ errorNode = $ xpath -> query ( '/response/error' ) -> item ( 0 ) ) instanceof DOMNode ) { $ errorMessage = $ errorNode -> nodeValue ; } return $ errorMessage ; }
Returns the error message from the Tulip API .
5,933
public function getDOMDocument ( ) { if ( $ this -> domDocument instanceof DOMDocument === false ) { $ this -> domDocument = new DOMDocument ( '1.0' , 'UTF-8' ) ; libxml_clear_errors ( ) ; $ previousSetting = libxml_use_internal_errors ( true ) ; @ $ this -> domDocument -> loadXML ( $ this -> response -> getBody ( ) ) ; libxml_clear_errors ( ) ; libxml_use_internal_errors ( $ previousSetting ) ; } return $ this -> domDocument ; }
Returns the response body as DOMDocument instance .
5,934
private function buildAuthorizationHeader ( $ oauth ) { $ return = 'Authorization: OAuth ' ; $ values = array ( ) ; foreach ( $ oauth as $ key => $ value ) { $ values [ ] = "$key=\"" . rawurlencode ( $ value ) . "\"" ; } $ return .= implode ( ', ' , $ values ) ; return $ return ; }
Private method to generate authorization header used by cURL
5,935
private function checkOptGroup ( $ options , $ class , $ style ) { foreach ( $ options as $ option ) { if ( ! isset ( $ option [ 'value' ] ) ) { $ result = $ this -> checkOptGroup ( $ option , $ class , $ style ) ; if ( $ result ) { return $ result ; } continue ; } if ( $ this -> isSelected ( $ option ) ) { return sprintf ( '<input type="hidden" id="ctrl_%s" name="%s" value="%s" /><span%s>%s</span>' , $ this -> strId , $ this -> strName , StringUtil :: specialchars ( $ option [ 'value' ] ) , $ class . $ style , $ option [ 'label' ] ) ; } } return null ; }
Scan an option group for the selected option .
5,936
public function getAuthManager ( ) : ? AuthManager { if ( ! $ this -> hasAuthManager ( ) ) { $ this -> setAuthManager ( $ this -> getDefaultAuthManager ( ) ) ; } return $ this -> authManager ; }
Get auth manager
5,937
public static function generate ( string $ yasql , string $ name = null , int $ indent = null ) { $ model = new Parser ( $ yasql , $ name ) ; $ view = new Generator ( $ model , $ indent ) ; return $ view -> output ( ) ; }
Generates the SQL from a YASQL
5,938
public static function parse ( string $ yasql , string $ name = null ) { $ parser = new Parser ( $ yasql , $ name ) ; return $ parser -> getData ( ) ; }
Parses a YASQL and returns the parsed data
5,939
public function getCacheFactory ( ) : ? Factory { if ( ! $ this -> hasCacheFactory ( ) ) { $ this -> setCacheFactory ( $ this -> getDefaultCacheFactory ( ) ) ; } return $ this -> cacheFactory ; }
Get cache factory
5,940
public function saveXml ( ) { $ doc = new DOMDocument ( $ this -> _element -> ownerDocument -> version , $ this -> _element -> ownerDocument -> actualEncoding ) ; $ doc -> appendChild ( $ doc -> importNode ( $ this -> _element , true ) ) ; $ doc -> formatOutput = true ; return $ doc -> saveXML ( ) ; }
Override Zend_Feed_Element to allow formated feeds
5,941
public function send ( ) { if ( headers_sent ( ) ) { require_once 'Zend/Feed/Exception.php' ; throw new Zend_Feed_Exception ( 'Cannot send ATOM because headers have already been sent.' ) ; } header ( 'Content-Type: application/atom+xml; charset=' . $ this -> _element -> ownerDocument -> actualEncoding ) ; echo $ this -> saveXML ( ) ; }
Send feed to a http client with the correct header
5,942
public function getRedisFactory ( ) : ? Factory { if ( ! $ this -> hasRedisFactory ( ) ) { $ this -> setRedisFactory ( $ this -> getDefaultRedisFactory ( ) ) ; } return $ this -> redisFactory ; }
Get redis factory
5,943
public function boot ( ) { ValidatorFacade :: extend ( 'valid_nonce' , function ( $ attaribute , $ value , $ params , $ validator ) { $ action = $ params [ 0 ] ; return ( bool ) wp_verify_nonce ( $ value , $ action ) ; } ) ; }
Add valid_nonce validation rule
5,944
public function getEntity ( $ id , $ hydrationMode = AbstractQuery :: HYDRATE_OBJECT ) { return $ this -> getQueryBuilder ( [ 'id' => $ id ] ) -> getQuery ( ) -> setMaxResults ( 1 ) -> getOneOrNullResult ( $ hydrationMode ) ; }
Returns an entity by its ID .
5,945
public function getEntitiesById ( array $ ids , $ hydrationMode = AbstractQuery :: HYDRATE_OBJECT ) { return $ this -> getQueryBuilder ( [ 'id' => $ ids ] ) -> getQuery ( ) -> execute ( null , $ hydrationMode ) ; }
Returns a list of entities extracted by their IDs .
5,946
public function getEntities ( array $ options = [ ] , $ hydrationMode = AbstractQuery :: HYDRATE_OBJECT ) { $ options = EntityRepositoryOptionsResolver :: createAndResolve ( $ options ) ; return $ this -> getQueryBuilder ( $ options [ 'filters' ] , $ options [ 'sorting' ] ) -> getQuery ( ) -> execute ( null , $ hydrationMode ) ; }
Returns a list of all the entities .
5,947
public function getPaginatedEntities ( array $ options = [ ] , $ hydrationMode = AbstractQuery :: HYDRATE_OBJECT ) { $ options = PaginatedEntityRepositoryOptionsResolver :: createAndResolve ( $ options ) ; $ queryBuilder = $ this -> addPagination ( $ this -> getQueryBuilder ( $ options [ 'filters' ] , $ options [ 'sorting' ] ) , $ options [ 'elementsPerPage' ] , $ options [ 'page' ] ) ; return new Paginator ( $ queryBuilder -> getQuery ( ) -> setHydrationMode ( $ hydrationMode ) ) ; }
Returns a paginated list of entities .
5,948
protected function getQueryBuilder ( array $ filters = [ ] , array $ sorting = [ ] ) { $ queryBuilder = $ this -> getBaseQueryBuilder ( ) ; if ( ! empty ( $ filters ) ) { $ this -> addFilters ( $ queryBuilder , $ filters ) ; } if ( empty ( $ sorting ) ) { $ this -> addSorting ( $ queryBuilder , $ this -> getDefaultSorting ( ) ) ; } else { $ this -> addSorting ( $ queryBuilder , $ sorting ) ; } return $ queryBuilder ; }
Returns a complete QueryBuilder instance for the current entity .
5,949
protected function addFilters ( QueryBuilder $ queryBuilder , $ filters = array ( ) ) { foreach ( $ filters as $ field => $ value ) { $ methodName = sprintf ( 'add%sFilter' , ucfirst ( $ field ) ) ; if ( method_exists ( $ this , $ methodName ) ) { $ this -> $ methodName ( $ queryBuilder , $ value ) ; continue ; } if ( null === $ value || '' === $ value || ( is_array ( $ value ) && 0 == count ( $ value ) ) ) { continue ; } $ field = $ this -> addEntityAlias ( $ field ) ; if ( is_array ( $ value ) ) { $ queryBuilder -> andWhere ( $ queryBuilder -> expr ( ) -> in ( $ field , $ value ) ) ; } else { $ queryBuilder -> andWhere ( $ queryBuilder -> expr ( ) -> eq ( $ field , $ queryBuilder -> expr ( ) -> literal ( $ value ) ) ) ; } } return $ queryBuilder ; }
Adds filters to the QueryBuilder instance .
5,950
protected function addSorting ( QueryBuilder $ queryBuilder , array $ sorting = [ ] ) { foreach ( $ sorting as $ field => $ sortOrder ) { if ( ! $ this -> isFieldSortable ( $ field ) ) { continue ; } if ( ! $ this -> isSortOrderValid ( $ sortOrder ) ) { continue ; } $ methodName = sprintf ( 'add%sSorting' , ucfirst ( $ field ) ) ; if ( method_exists ( $ this , $ methodName ) ) { $ this -> $ methodName ( $ queryBuilder , $ sortOrder ) ; continue ; } $ queryBuilder -> addOrderBy ( $ this -> addEntityAlias ( $ field ) , strtolower ( $ sortOrder ) ) ; } return $ queryBuilder ; }
Adds sorting to the specified query builder .
5,951
protected function addPagination ( QueryBuilder $ queryBuilder , $ elementsPerPage , $ page = 1 ) { $ elementsPerPage = ( int ) $ elementsPerPage ; $ page = ( int ) $ page ; return $ queryBuilder -> setMaxResults ( $ elementsPerPage ) -> setFirstResult ( $ elementsPerPage * ( $ page - 1 ) ) ; }
Adds pagination to the specified query builder .
5,952
protected function hasJoin ( QueryBuilder $ queryBuilder , $ joinString ) { foreach ( $ queryBuilder -> getDQLPart ( 'join' ) as $ joinsList ) { foreach ( $ joinsList as $ joinExpression ) { if ( $ joinExpression -> getJoin ( ) == $ joinString ) { return true ; } } } return false ; }
Returns TRUE if the join string is already present inside the query builder FALSE otherwise .
5,953
public function renderStop ( $ stop ) { $ options = array ( ) ; $ options [ 'data-id' ] = ArrayHelper :: getValue ( $ stop , 'id' ) ; $ options [ 'data-text' ] = ArrayHelper :: getValue ( $ stop , 'text' ) ; $ options [ 'data-button' ] = ArrayHelper :: getValue ( $ stop , 'button' ) ; $ options [ 'data-class' ] = ArrayHelper :: getValue ( $ stop , 'class' ) ; $ options [ 'data-options' ] = ArrayHelper :: getValue ( $ stop , 'options' ) ; if ( $ options [ 'data-options' ] !== null ) { $ config = array ( ) ; foreach ( $ options [ 'data-options' ] as $ key => $ option ) { $ config [ ] = $ key . ':' . $ option ; } $ options [ 'data-options' ] = implode ( ';' , $ config ) ; } $ title = ArrayHelper :: getValue ( $ stop , 'title' ) ; if ( ! empty ( $ title ) ) { $ title = "<h4>{$title}</h4>" ; } $ content = '<p>' . ArrayHelper :: getValue ( $ stop , 'body' , '' ) . '</p>' ; return \ CHtml :: tag ( 'li' , $ options , $ title . $ content ) ; }
Renders a single stop
5,954
public function addText ( $ text , $ styleFont = null , $ styleParagraph = null ) { $ text = new PHPWord_Section_Text ( $ text , $ styleFont , $ styleParagraph ) ; $ this -> _elementCollection [ ] = $ text ; return $ text ; }
Add a Text Element
5,955
public function addObject ( $ src , $ style = null ) { $ object = new PHPWord_Section_Object ( $ src , $ style ) ; if ( ! is_null ( $ object -> getSource ( ) ) ) { $ inf = pathinfo ( $ src ) ; $ ext = $ inf [ 'extension' ] ; if ( strlen ( $ ext ) == 4 && strtolower ( substr ( $ ext , - 1 ) ) == 'x' ) { $ ext = substr ( $ ext , 0 , - 1 ) ; } $ iconSrc = PHPWORD_BASE_PATH . 'PHPWord/_staticDocParts/' ; if ( ! file_exists ( $ iconSrc . '_' . $ ext . '.png' ) ) { $ iconSrc = $ iconSrc . '_default.png' ; } else { $ iconSrc .= '_' . $ ext . '.png' ; } $ rIDimg = PHPWord_Media :: addSectionMediaElement ( $ iconSrc , 'image' ) ; $ data = PHPWord_Media :: addSectionMediaElement ( $ src , 'oleObject' ) ; $ rID = $ data [ 0 ] ; $ objectId = $ data [ 1 ] ; $ object -> setRelationId ( $ rID ) ; $ object -> setObjectId ( $ objectId ) ; $ object -> setImageRelationId ( $ rIDimg ) ; $ this -> _elementCollection [ ] = $ object ; return $ object ; } else { trigger_error ( 'Source does not exist or unsupported object type.' ) ; } }
Add a OLE - Object Element
5,956
public function addPreserveText ( $ text , $ styleFont = null , $ styleParagraph = null ) { if ( $ this -> _insideOf == 'footer' || $ this -> _insideOf == 'header' ) { $ ptext = new PHPWord_Section_Footer_PreserveText ( $ text , $ styleFont , $ styleParagraph ) ; $ this -> _elementCollection [ ] = $ ptext ; return $ ptext ; } else { trigger_error ( 'addPreserveText only supported in footer/header.' ) ; } }
Add a PreserveText Element
5,957
public function createTextRun ( $ styleParagraph = null ) { $ textRun = new PHPWord_Section_TextRun ( $ styleParagraph ) ; $ this -> _elementCollection [ ] = $ textRun ; return $ textRun ; }
Create a new TextRun
5,958
public static function addTitle ( $ text , $ depth = 0 ) { $ anchor = '_Toc' . ++ self :: $ _anchor ; $ bookmarkId = self :: $ _bookmarkId ++ ; $ title = array ( ) ; $ title [ 'text' ] = $ text ; $ title [ 'depth' ] = $ depth ; $ title [ 'anchor' ] = $ anchor ; $ title [ 'bookmarkId' ] = $ bookmarkId ; self :: $ _titles [ ] = $ title ; return array ( $ anchor , $ bookmarkId ) ; }
Add a Title
5,959
public static function reindex ( $ collection , $ getIndex = 'getIdentifier' ) { if ( ! Code :: isTraversable ( $ collection ) ) { throw new \ InvalidArgumentException ( '$collection muss Traversable sein. ' . Code :: varInfo ( $ collection ) ) ; } $ getIndex = Code :: castGetter ( $ getIndex ) ; $ ret = array ( ) ; foreach ( $ collection as $ o ) { $ ret [ $ getIndex ( $ o ) ] = $ o ; } return $ ret ; }
Organisiert die Collection mit einem neuen Index
5,960
public static function getInstance ( $ name = self :: DEFAULT_NAME ) { if ( empty ( self :: $ _instances [ $ name ] ) ) { self :: $ _instances [ $ name ] = new Toolbar ( $ name ) ; } return self :: $ _instances [ $ name ] ; }
Get toolbar instance .
5,961
public function loadItemType ( $ type ) { $ signature = md5 ( $ type ) ; if ( isset ( $ this -> _buttons [ $ signature ] ) ) { return $ this -> _buttons [ $ signature ] ; } list ( $ plugin , $ name ) = pluginSplit ( $ type ) ; $ alias = Slug :: filter ( $ name , '_' ) ; $ aliasClass = Inflector :: classify ( $ alias ) ; $ className = $ this -> _getItemClassName ( $ plugin , $ aliasClass ) ; if ( ! $ className ) { return false ; } $ this -> _buttons [ $ signature ] = new $ className ( $ this ) ; return $ this -> _buttons [ $ signature ] ; }
Load object of item type .
5,962
public function render ( ) { $ i = 0 ; $ output = [ ] ; $ count = count ( $ this -> _items ) ; foreach ( $ this -> _items as $ item ) { $ i ++ ; $ item [ 'class' ] = 'item-wrapper tb-item-' . $ i ; if ( $ i == 1 ) { $ item [ 'class' ] .= ' first' ; } if ( $ i == $ count ) { $ item [ 'class' ] .= ' last' ; } $ output [ ] = $ this -> renderItem ( $ item ) ; } return implode ( PHP_EOL , $ output ) ; }
Render toolbar items .
5,963
public function renderItem ( & $ node ) { $ type = $ node [ 0 ] ; $ item = $ this -> loadItemType ( $ type ) ; if ( $ item === false ) { return null ; } return $ item -> render ( $ node ) ; }
Render toolbar item html .
5,964
protected function _getItemClassName ( $ plugin , $ aliasClass ) { if ( $ plugin === null ) { $ plugin = 'Core' ; } $ buttonClass = $ plugin . '.' . self :: CLASS_NAME_PREFIX . $ aliasClass ; $ className = App :: className ( $ buttonClass , self :: CLASS_TYPE ) ; if ( $ className === false ) { $ buttonClass = self :: CLASS_NAME_PREFIX . $ aliasClass ; $ className = App :: className ( $ buttonClass , self :: CLASS_TYPE ) ; } return $ className ; }
Get full class name .
5,965
protected function _createIcon ( HtmlHelper $ html , $ title , array $ options = [ ] ) { list ( $ options , $ iconOptions ) = $ this -> _createIconAttr ( $ options ) ; if ( Arr :: key ( 'createIcon' , $ iconOptions ) ) { unset ( $ iconOptions [ 'createIcon' ] ) ; $ title = $ html -> icon ( $ options [ 'icon' ] , $ iconOptions ) . PHP_EOL . $ title ; unset ( $ options [ 'icon' ] ) ; } if ( Arr :: key ( 'iconInline' , $ options ) ) { unset ( $ options [ 'iconInline' ] ) ; } return [ $ title , $ options ] ; }
Create current icon .
5,966
protected function _createIconAttr ( array $ options = [ ] ) { $ iconOptions = [ 'class' => '' ] ; if ( Arr :: key ( 'icon' , $ options ) ) { if ( Arr :: key ( 'iconClass' , $ options ) ) { $ iconOptions = $ this -> _addClass ( $ iconOptions , $ options [ 'iconClass' ] ) ; unset ( $ options [ 'iconClass' ] ) ; } list ( $ options , $ iconOptions ) = $ this -> _setIconOptions ( $ options , $ iconOptions ) ; } return [ $ options , $ iconOptions ] ; }
Create icon attributes .
5,967
protected function _getBtnClass ( array $ options = [ ] ) { if ( Arr :: key ( 'button' , $ options ) ) { $ button = $ options [ 'button' ] ; unset ( $ options [ 'button' ] ) ; if ( is_callable ( $ this -> getConfig ( 'prepareBtnClass' ) ) ) { return ( array ) call_user_func ( $ this -> getConfig ( 'prepareBtnClass' ) , $ this , $ options , $ button ) ; } $ options = $ this -> _setBtnClass ( $ button , $ options ) ; } return $ options ; }
Create and get button classes .
5,968
protected function _getToolTipAttr ( array $ options = [ ] , $ toggle = 'tooltip' ) { if ( Arr :: key ( 'tooltip' , $ options ) ) { $ tooltip = $ options [ 'tooltip' ] ; unset ( $ options [ 'tooltip' ] ) ; if ( is_callable ( $ this -> getConfig ( 'prepareTooltip' ) ) ) { return ( array ) call_user_func ( $ this -> getConfig ( 'prepareTooltip' ) , $ this , $ options , $ tooltip ) ; } $ _options = [ 'data-toggle' => $ toggle , 'data-placement' => 'top' , ] ; if ( Arr :: key ( 'tooltipPos' , $ options ) ) { $ _options [ 'data-placement' ] = ( string ) $ options [ 'tooltipPos' ] ; unset ( $ options [ 'tooltipPos' ] ) ; } $ options = $ this -> _setTooltipTitle ( $ tooltip , $ options ) ; return Hash :: merge ( $ _options , $ options ) ; } return $ options ; }
Create and get tooltip attributes .
5,969
protected function _prepareBeforeAfterContainer ( $ type , $ value ) { $ output = null ; $ iconClass = ( $ type === 'before' ) ? 'prefix' : 'postfix' ; if ( $ value !== null ) { $ output = $ value ; if ( is_string ( $ output ) ) { $ hasIcon = preg_match ( '/icon:[a-zA-Z]/' , $ output ) ; if ( $ hasIcon > 0 ) { list ( , $ icon ) = explode ( ':' , $ output , 2 ) ; $ icon = Str :: low ( $ icon ) ; $ output = $ this -> Html -> icon ( $ icon , [ 'class' => $ iconClass ] ) ; } } } return $ output ; }
Prepare before after content for input container .
5,970
protected function _setBtnClass ( $ button , array $ options = [ ] ) { if ( $ button !== true ) { $ classes = [ $ this -> _configRead ( 'btnPref' ) ] ; foreach ( ( array ) $ button as $ button ) { $ classes [ ] = $ this -> _configRead ( 'btnPref' ) . '-' . $ button ; } $ options = $ this -> _addClass ( $ options , implode ( ' ' , $ classes ) ) ; } return $ options ; }
Setup button classes by options .
5,971
protected function _setIconOptions ( array $ options = [ ] , array $ iconOptions = [ ] ) { $ icon = $ options [ 'icon' ] ; if ( Arr :: key ( 'iconInline' , $ options ) ) { $ iconPrefix = $ this -> _configRead ( 'iconPref' ) ; $ options = $ this -> _addClass ( $ options , implode ( ' ' , [ $ this -> _class ( 'icon' ) , $ iconPrefix , $ iconPrefix . '-' . $ icon ] ) ) ; unset ( $ options [ 'icon' ] ) ; } else { $ options [ 'escape' ] = false ; $ iconOptions [ 'createIcon' ] = true ; } return [ $ options , $ iconOptions ] ; }
Setup icon options .
5,972
protected function _setTooltipTitle ( $ tooltip , array $ options = [ ] ) { if ( $ tooltip === true && ! Arr :: key ( 'title' , $ options ) ) { $ options [ 'title' ] = strip_tags ( $ options [ 'label' ] ) ; } if ( is_string ( $ tooltip ) ) { $ options [ 'title' ] = $ tooltip ; } return $ options ; }
Setup tooltip title by options .
5,973
public static function arrayAppendLast ( array $ array , string $ last , string $ others = null ) { $ count = count ( $ array ) ; foreach ( $ array as $ key => $ value ) { $ array [ $ key ] = $ value . ( -- $ count > 0 ? $ others : $ last ) ; } return $ array ; }
Appends a string to the last item in an array
5,974
public function getContentType ( ) { $ contentType = null ; $ _contentType = $ this -> getHeader ( 'Content-Type' ) ; if ( ! empty ( $ _contentType ) ) { $ _contentType = explode ( ';' , $ _contentType [ 0 ] ) ; $ contentType = $ _contentType [ 0 ] ; } return $ contentType ; }
Get primary content - type header without encoding info
5,975
public static function setResponseStatus ( int $ status ) : void { if ( array_key_exists ( $ status , Http :: $ http_status_messages ) ) { header ( 'HTTP/1.1 ' . $ status . ' ' . Http :: $ http_status_messages [ $ status ] ) ; } }
Set response header status
5,976
public static function getBaseUrl ( ) : string { $ https = ( isset ( $ _SERVER [ 'HTTPS' ] ) && strtolower ( $ _SERVER [ 'HTTPS' ] ) == 'on' ) ? 'https://' : 'http://' ; return $ https . rtrim ( rtrim ( $ _SERVER [ 'HTTP_HOST' ] , '\\/' ) . dirname ( $ _SERVER [ 'PHP_SELF' ] ) , '\\/' ) ; }
Gets the base URL
5,977
public static function getUriString ( ) : string { $ url = '' ; $ request_url = ( isset ( $ _SERVER [ 'REQUEST_URI' ] ) ) ? $ _SERVER [ 'REQUEST_URI' ] : '' ; $ script_url = ( isset ( $ _SERVER [ 'PHP_SELF' ] ) ) ? $ _SERVER [ 'PHP_SELF' ] : '' ; if ( $ request_url != $ script_url ) { $ url = trim ( preg_replace ( '/' . str_replace ( '/' , '\/' , str_replace ( 'index.php' , '' , $ script_url ) ) . '/' , '' , $ request_url , 1 ) , '/' ) ; } $ url = preg_replace ( '/\?.*/' , '' , $ url ) ; return $ url ; }
Get Uri String
5,978
public static function getUriSegment ( int $ segment ) { $ segments = self :: getUriSegments ( ) ; return isset ( $ segments [ $ segment ] ) ? $ segments [ $ segment ] : null ; }
Get Uri Segment
5,979
protected function matchCode ( $ code ) { $ language = $ code ; $ country = null ; $ parts = explode ( '-' , $ code ) ; if ( count ( $ parts ) === 2 ) { $ language = $ parts [ 0 ] ; $ country = strtoupper ( $ parts [ 1 ] ) ; } if ( in_array ( $ code , $ this -> languages ) ) { return [ $ language , $ country ] ; } elseif ( $ country && in_array ( "$language-$country" , $ this -> languages ) || in_array ( "$language-*" , $ this -> languages ) ) { return [ $ language , $ country ] ; } elseif ( in_array ( $ language , $ this -> languages ) ) { return [ $ language , null ] ; } else { return [ null , null ] ; } }
Tests whether the given code matches any of the configured languages .
5,980
public function aboutAction ( ) { $ oLicense = LicenseQuery :: create ( ) -> findOne ( ) ; require_once dirname ( __FILE__ ) . '/../../../../app/SymfonyRequirements.php' ; $ symfonyRequirements = new \ SymfonyRequirements ( ) ; $ symfonyRequirements -> addRequirement ( extension_loaded ( 'mcrypt' ) , "Check if mcrypt ist loaded for RSA encryption" , "Please enable mcrypt-Extension. See <a href='http://php.net/manual/de/mcrypt.setup.php'>http://php.net/manual/de/mcrypt.setup.php</a>" ) ; $ aRequirements = $ symfonyRequirements -> getRequirements ( ) ; $ aRecommendations = $ symfonyRequirements -> getRecommendations ( ) ; $ aFailedRequirements = $ symfonyRequirements -> getFailedRequirements ( ) ; $ aFailedRecommendations = $ symfonyRequirements -> getFailedRecommendations ( ) ; $ iniPath = $ symfonyRequirements -> getPhpIniConfigPath ( ) ; $ sVersion = file_get_contents ( dirname ( __FILE__ ) . '/../../../../version.txt' ) ; return $ this -> render ( 'SlashworksAppBundle:About:about.html.twig' , array ( "license" => $ oLicense , "version" => $ sVersion , "iniPath" => $ iniPath , "requirements" => $ aRequirements , "recommendations" => $ aRecommendations , "failedrequirements" => $ aFailedRequirements , "failedrecommendations" => $ aFailedRecommendations ) ) ; }
Display form for license activation
5,981
public function initialize ( array $ config ) { $ isMaterializeCss = $ this -> getConfig ( 'materializeCss' , false ) ; if ( $ isMaterializeCss === true ) { $ this -> _configWrite ( 'prepareBtnClass' , function ( Helper $ form , $ options , $ button ) { return $ this -> _prepareBtn ( $ form , $ options , $ button ) ; } ) ; $ this -> _configWrite ( 'prepareTooltip' , function ( Helper $ html , $ options , $ tooltip ) { return $ this -> _prepareTooltip ( $ html , $ options , $ tooltip ) ; } ) ; } parent :: initialize ( $ config ) ; }
Constructor hook method . Implement this method to avoid having to overwrite the constructor and call parent .
5,982
public function getAssets ( $ key ) { $ value = Hash :: get ( $ this -> _assets , $ key ) ; if ( is_string ( $ value ) ) { return $ value ; } return Hash :: sort ( ( array ) $ value , '{n}.weight' , 'asc' ) ; }
Get sort assets included list .
5,983
public function icon ( $ icon = 'home' , array $ options = [ ] ) { $ iconPref = $ this -> _configRead ( 'iconPref' ) ; $ _classes = [ $ this -> _class ( __FUNCTION__ ) , $ iconPref , $ iconPref . '-' . $ icon , ] ; $ options = $ this -> _addClass ( $ options , implode ( ' ' , $ _classes ) ) ; $ classes = $ options [ 'class' ] ; unset ( $ options [ 'class' ] ) ; $ templater = $ this -> templater ( ) ; return $ templater -> format ( __FUNCTION__ , [ 'class' => $ classes , 'attrs' => $ templater -> formatAttributes ( $ options ) , ] ) ; }
Create icon element .
5,984
public function less ( $ path , array $ options = [ ] ) { $ cssPath = [ ] ; if ( ! Arr :: key ( 'force' , $ options ) ) { $ options [ 'force' ] = false ; } if ( is_array ( $ path ) ) { foreach ( $ path as $ i ) { if ( $ result = $ this -> Less -> process ( $ i , $ options [ 'force' ] ) ) { $ cssPath [ ] = $ result ; } } } if ( is_string ( $ path ) && $ result = $ this -> Less -> process ( $ path , $ options [ 'force' ] ) ) { $ cssPath [ ] = $ result ; } return $ this -> css ( $ cssPath , $ options ) ; }
Creates a CSS stylesheets from less .
5,985
public function link ( $ title , $ url = null , array $ options = [ ] ) { $ options = $ this -> addClass ( $ options , $ this -> _class ( __FUNCTION__ ) ) ; $ options = Hash :: merge ( [ 'escapeTitle' => false , 'clear' => false , 'label' => $ title , ] , $ options ) ; $ isClear = ( bool ) $ options [ 'clear' ] ; unset ( $ options [ 'clear' ] ) ; $ options = $ this -> _setTitleAttr ( $ title , $ options ) ; if ( $ this -> _isEscapeTitle ( $ title , $ isClear , $ options ) ) { $ title = $ this -> tag ( 'span' , $ title , [ 'class' => $ this -> _class ( __FUNCTION__ ) . '-title' ] ) ; } $ options = $ this -> _getBtnClass ( $ options ) ; $ options = $ this -> _getToolTipAttr ( $ options ) ; list ( $ title , $ options ) = $ this -> _createIcon ( $ this , $ title , $ options ) ; unset ( $ options [ 'label' ] ) ; return parent :: link ( $ title , $ url , $ options ) ; }
Create an html link .
5,986
public function status ( $ status = 0 , array $ url = [ ] , $ icon = 'circle' ) { $ class = ( int ) $ status === 1 ? 'ck-green' : 'ck-red' ; if ( count ( $ url ) === 0 ) { return $ this -> icon ( $ icon , [ 'class' => $ class ] ) ; } return $ this -> link ( null , 'javascript:void(0);' , [ 'icon' => $ icon , 'class' => $ class , 'data-url' => $ this -> Url -> build ( $ url ) ] ) ; }
Create status icon or link .
5,987
public function toggle ( Entity $ entity , array $ url = [ ] , array $ data = [ ] ) { if ( count ( $ url ) === 0 ) { $ url = [ 'action' => 'toggle' , 'prefix' => $ this -> request -> getParam ( 'prefix' ) , 'plugin' => $ this -> request -> getParam ( 'plugin' ) , 'controller' => $ this -> request -> getParam ( 'controller' ) , ( int ) $ entity -> get ( 'id' ) , ( int ) $ entity -> get ( 'status' ) ] ; } $ data = Hash :: merge ( [ 'url' => $ url , 'entity' => $ entity , ] , $ data ) ; return $ this -> _View -> element ( 'Core.' . __FUNCTION__ , $ data ) ; }
Create and render ajax toggle element .
5,988
protected function _setTitleAttr ( $ title , array $ options = [ ] ) { if ( ! Arr :: key ( 'title' , $ options ) ) { $ options [ 'title' ] = strip_tags ( $ title ) ; } return $ options ; }
Setup default title attr .
5,989
public function asFormattedXml ( $ compressed = false , $ indent = "\t" , $ level = 0 ) { JLog :: add ( 'JXMLElement::asFormattedXml() is deprecated, use SimpleXMLElement::asXml() instead.' , JLog :: WARNING , 'deprecated' ) ; $ out = '' ; $ out .= ( $ compressed ) ? '' : "\n" . str_repeat ( $ indent , $ level ) ; $ out .= '<' . $ this -> getName ( ) ; foreach ( $ this -> attributes ( ) as $ attr ) { $ out .= ' ' . $ attr -> getName ( ) . '="' . htmlspecialchars ( ( string ) $ attr , ENT_COMPAT , 'UTF-8' ) . '"' ; } if ( ! count ( $ this -> children ( ) ) && ! ( string ) $ this ) { $ out .= " />" ; } else { if ( count ( $ this -> children ( ) ) ) { $ out .= '>' ; $ level ++ ; foreach ( $ this -> children ( ) as $ child ) { $ out .= $ child -> asFormattedXml ( $ compressed , $ indent , $ level ) ; } $ level -- ; $ out .= ( $ compressed ) ? '' : "\n" . str_repeat ( $ indent , $ level ) ; } elseif ( ( string ) $ this ) { $ out .= '>' . htmlspecialchars ( ( string ) $ this , ENT_COMPAT , 'UTF-8' ) ; } $ out .= '</' . $ this -> getName ( ) . '>' ; } return $ out ; }
Return a well - formed XML string based on SimpleXML element
5,990
public function setLabel ( Label $ label ) { $ label -> checkId ( ) ; $ label -> setScriptEvents ( true ) ; $ this -> label = $ label ; return $ this ; }
Set the Label
5,991
public function setValues ( array $ values ) { $ this -> values = array ( ) ; foreach ( $ values as $ value ) { $ this -> addValue ( $ value ) ; } return $ this ; }
Set the possible values
5,992
public function getDefault ( ) { if ( $ this -> default ) { return $ this -> default ; } if ( ! empty ( $ this -> values ) ) { return reset ( $ this -> values ) ; } return null ; }
Get the default value
5,993
public function generateTree ( $ pad = '' , $ relativePath = '' ) { $ generatedMd = '' ; if ( ! empty ( $ this -> subPages ) ) { foreach ( $ this -> subPages as $ subPageName => $ subPage ) { $ subPageFile = './' . $ relativePath . $ subPageName . DIRECTORY_SEPARATOR . $ subPage -> getPageBfe ( ) ; $ generatedMd .= "$pad- [$subPageName]($subPageFile)" . PHP_EOL ; $ generatedMd .= $ subPage -> generateTree ( $ pad . ' ' , $ relativePath . $ subPageName . DIRECTORY_SEPARATOR ) ; } } if ( ! empty ( $ this -> classMds ) ) { foreach ( $ this -> classMds as $ chapter ) { $ chapterName = $ chapter -> getReflexion ( ) -> getShortName ( ) ; $ chapterFile = $ relativePath . $ this -> getPageBfe ( ) ; $ chapterAnchor = $ chapterFile . '#' . $ chapter -> getReflexion ( ) -> getShortName ( ) ; $ generatedMd .= "$pad- [$chapterName]($chapterAnchor)" . PHP_EOL ; } } return $ generatedMd ; }
Generate overview markdown tree
5,994
public function write ( ) { $ m = new \ Mustache_Engine ( [ 'loader' => new \ Mustache_Loader_FilesystemLoader ( __DIR__ . '/../views' ) ] ) ; $ template = $ m -> loadTemplate ( 'Page' ) ; $ generatedMd = $ template -> render ( $ this ) ; $ this -> writeSubPages ( ) ; @ mkdir ( $ this -> page_rd , 0777 , true ) ; file_put_contents ( $ this -> page_rd . DIRECTORY_SEPARATOR . $ this -> page_bfe , $ generatedMd ) ; }
Write markdown file
5,995
public function writeSubPages ( ) { foreach ( $ this -> subPages as $ subPageName => $ subPage ) { $ subPageDirectory = $ this -> page_rd . DIRECTORY_SEPARATOR . $ subPageName ; $ subPage -> setDirectory ( $ subPageDirectory ) ; $ subPage -> write ( ) ; } }
Write sub pages of this page
5,996
static public function getReadableType ( $ type ) { switch ( $ type ) { case self :: TYPE_GOOGLE : return 'google' ; case self :: TYPE_FACEBOOK : return 'facebook' ; case self :: TYPE_YAHOO : return 'yahoo' ; case self :: TYPE_TWITTER : return 'twitter' ; } }
Convert type to human - readable form
5,997
static public function getStorableType ( $ type ) { switch ( $ type ) { case 'google' : return self :: TYPE_GOOGLE ; case 'facebook' : return self :: TYPE_FACEBOOK ; case 'yahoo' : return self :: TYPE_YAHOO ; case 'twitter' : return self :: TYPE_TWITTER ; } }
Convert human - readable type to integer
5,998
public function getPsrLog ( ) : ? LoggerInterface { if ( ! $ this -> hasPsrLog ( ) ) { $ this -> setPsrLog ( $ this -> getDefaultPsrLog ( ) ) ; } return $ this -> psrLog ; }
Get psr log
5,999
public function doSearchKnowledgeBase ( $ data , $ form ) { if ( ! $ this -> kbPageId ) { return $ this -> controller -> redirectBack ( ) ; } $ page = KnowledgebasePage :: get ( ) -> byID ( $ this -> kbPageId ) ; if ( ! $ page ) { return $ this -> controller -> redirectBack ( ) ; } $ link = ( ! empty ( $ data [ 'Query' ] ) ) ? sprintf ( '%s?q=%s' , $ page -> AbsoluteLink ( ) , strip_tags ( $ data [ 'Query' ] ) ) : $ page -> AbsoluteLink ( ) ; $ this -> extend ( 'UpdateLink' , $ link , $ data ) ; return $ this -> controller -> redirect ( $ link ) ; }
Handler for the form submission .