idx
int64
0
60.3k
question
stringlengths
64
4.24k
target
stringlengths
5
618
49,900
public function getIp ( ) { if ( ! $ this -> ip ) { if ( $ this -> random ) { $ this -> ip = long2ip ( mt_rand ( ) ) ; } else { $ this -> ip = array_get ( $ _SERVER , 'HTTP_CLIENT_IP' , array_get ( $ _SERVER , 'HTTP_X_FORWARDED_FOR' , array_get ( $ _SERVER , 'HTTP_X_FORWARDED' , array_get ( $ _SERVER , 'HTTP_FORWARDED_...
Get ip from server info .
49,901
public function get ( $ property = '' ) { $ data = $ this -> getData ( ) ; if ( ! $ property ) { return $ data ; } return array_get ( $ data , $ property , '' ) ; }
Get an array or single item of geoip data Also stores data in memory for further requests .
49,902
public function getRaw ( ) { $ ip = $ this -> getIp ( ) ; $ this -> setIp ( $ ip ) ; $ data = array_get ( $ this -> storeRaw , $ ip ) ; if ( ! $ data ) { try { $ data = $ this -> getDriver ( ) -> getRaw ( $ ip ) ; } catch ( \ Exception $ e ) { throw new GeoIPException ( 'Failed to get raw geoip data' , 0 , $ e ) ; } $ ...
Get the raw geoip data from the driver .
49,903
protected function getData ( ) { $ ip = $ this -> getIp ( ) ; $ this -> setIp ( $ ip ) ; $ data = array_get ( $ this -> store , $ ip ) ; if ( ! $ data ) { try { $ data = $ this -> getDriver ( ) -> get ( $ ip ) ; } catch ( \ Exception $ e ) { throw new GeoIPException ( 'Failed to get geoip data' , 0 , $ e ) ; } $ this -...
Get an array or single item of geoip data .
49,904
protected function updateMaxmindDatabase ( ) { $ maxmindDatabaseUrl = array_get ( $ this -> config , 'maxmind.download' , 'http://geolite.maxmind.com/download/geoip/database/GeoLite2-City.mmdb.gz' ) ; $ database = array_get ( $ this -> config , 'maxmind.database' , false ) ; if ( ! file_exists ( $ dir = pathinfo ( $ da...
Update function for maxmind database .
49,905
public function get ( $ ip ) { $ data = $ this -> getRaw ( $ ip ) ; if ( empty ( $ data ) || ( array_get ( $ data , 'status' ) === 'fail' ) ) { return $ this -> getDefault ( ) ; } return [ 'city' => array_get ( $ data , 'city' ) , 'country' => array_get ( $ data , 'country' ) , 'countryCode' => array_get ( $ data , 'co...
Get array of data using ip - api .
49,906
protected function getUrl ( $ ip ) { $ baseUrl = 'http://ip-api.com/json/' ; $ key = '' ; if ( array_get ( $ this -> config , 'key' , false ) ) { $ baseUrl = 'https://pro.ip-api.com/json/' ; $ key = array_get ( $ this -> config , 'key' ) ; } return $ baseUrl . $ ip . ( ( $ key ) ? '?key=' . $ key : '' ) ; }
Get the ip - api url add key and change base url if pro user .
49,907
public function get ( $ ip ) { $ data = $ this -> getRaw ( $ ip ) ; if ( empty ( $ data ) ) { return $ this -> getDefault ( ) ; } return [ 'city' => $ data -> city -> name , 'country' => $ data -> country -> name , 'countryCode' => $ data -> country -> isoCode , 'latitude' => ( float ) number_format ( $ data -> locatio...
Get array of data using Maxmind .
49,908
protected function create ( ) { if ( array_get ( $ this -> config , 'user_id' , false ) ) { return $ this -> createWebClient ( ) ; } if ( array_get ( $ this -> config , 'database' , false ) ) { return $ this -> createDatabase ( ) ; } throw new InvalidCredentialsException ( ) ; }
Create the maxmind driver based on config .
49,909
protected function createWebClient ( ) { $ userId = array_get ( $ this -> config , 'user_id' , false ) ; $ licenseKey = array_get ( $ this -> config , 'license_key' , false ) ; if ( ! $ userId || ! $ licenseKey ) { throw new InvalidCredentialsException ( ) ; } return new Client ( $ userId , $ licenseKey ) ; }
Create the maxmind web client .
49,910
protected function createDatabase ( ) { $ database = array_get ( $ this -> config , 'database' , false ) ; if ( ! $ database || ! file_exists ( $ database ) ) { throw new InvalidCredentialsException ( ) ; } try { return new Reader ( $ database ) ; } catch ( \ MaxMind \ Db \ Reader \ InvalidDatabaseException $ e ) { thr...
Create the maxmind database reader .
49,911
protected function resolveUses ( string $ uses ) { $ result = $ this -> parseAdvancedUses ( $ uses ) ; return ! empty ( $ result -> getRoot ( ) ) ? $ result : $ uses ; }
prepare use variable for using .
49,912
protected function parseMultiLevelsValueCollection ( SimpleXMLElement $ content , MultiLevel $ multilevel ) : array { $ value = [ ] ; $ result = [ ] ; $ features = $ content -> { $ multilevel -> getRoot ( ) } ; if ( ! empty ( $ features ) ) { foreach ( $ features as $ key => $ feature ) { foreach ( $ multilevel as $ us...
Resolve values by collection of multi levels .
49,913
protected function filterValue ( $ value , ? string $ filter = null ) { $ resolver = $ this -> getFilterResolver ( $ filter ) ; if ( \ method_exists ( $ resolver [ 0 ] , $ resolver [ 1 ] ) ) { return $ this -> callFilterResolver ( $ resolver , $ value ) ; } return $ value ; }
Filter value .
49,914
protected function resolveValue ( array $ config , string $ hash ) { if ( ! isset ( $ config [ 'uses' ] ) ) { return $ config [ 'default' ] ?? null ; } if ( ! \ is_array ( $ config [ 'uses' ] ) ) { return $ this -> getValue ( $ this -> getContent ( ) , $ config [ 'uses' ] , $ hash ) ; } $ values = [ ] ; foreach ( $ con...
Resolve value from content .
49,915
protected function getFilterResolver ( string $ filter ) : array { $ class = $ filter ; $ method = 'filter' ; $ position = \ strpos ( $ filter , '@' ) ; if ( $ position === 0 ) { $ method = 'filter' . \ ucwords ( \ substr ( $ filter , 1 ) ) ; return [ $ this , $ method ] ; } if ( $ position !== false ) { list ( $ class...
Get filter resolver .
49,916
protected function parseData ( $ data ) { $ hash = \ hash ( 'sha256' , microtime ( true ) ) ; $ value = $ data ; $ filter = null ; if ( \ is_array ( $ data ) ) { $ value = $ this -> resolveValue ( $ data , $ hash ) ; $ filter = $ data [ 'filter' ] ?? null ; } if ( $ value === $ hash ) { $ value = $ data [ 'default' ] ?...
Parse single data .
49,917
public function rebase ( string $ base = null ) : self { $ this -> content = data_get ( $ this -> getOriginalContent ( ) , $ base ) ; return $ this ; }
Rebase document node .
49,918
public function namespaced ( string $ namespace , array $ schema , array $ config = [ ] ) : array { $ document = $ this -> getContent ( ) ; $ namespaces = $ this -> getAvailableNamespaces ( ) ; if ( ! \ is_null ( $ namespace ) && isset ( $ namespaces [ $ namespace ] ) ) { $ document = $ document -> children ( $ namespa...
Set document namespace and parse the XML .
49,919
protected function getValueAttribute ( SimpleXMLElement $ content , string $ use , $ default = null ) { return $ this -> castValue ( $ this -> getRawValueAttribute ( $ content , $ use , $ default ) ) ; }
Resolve value by uses as attribute .
49,920
protected function getRawValueAttribute ( SimpleXMLElement $ content , ? string $ use , $ default = null ) { list ( $ value , $ attribute ) = \ explode ( '::' , $ use , 2 ) ; if ( ! empty ( $ value ) ) { if ( \ is_null ( $ parent = object_get ( $ content , $ value ) ) ) { return $ default ; } } else { $ parent = $ cont...
Resolve value by uses as attribute as raw .
49,921
protected function getValueData ( SimpleXMLElement $ content , ? string $ use , $ default = null ) { $ value = $ this -> castValue ( data_get ( $ content , $ use ) ) ; if ( empty ( $ value ) && ! \ in_array ( $ value , [ '0' ] ) ) { return $ default ; } return $ value ; }
Resolve value by uses as data .
49,922
protected function getSelfMatchingValue ( SimpleXMLElement $ content , array $ matches = [ ] , ? string $ alias = null ) : array { $ name = $ matches [ 1 ] ; $ key = $ matches [ 2 ] ; $ meta = $ matches [ 3 ] ; $ item = [ ] ; $ uses = ( $ key == '@' ? $ meta : "{$key},{$meta}" ) ; if ( \ is_null ( $ alias ) ) { $ alias...
Get self matching value .
49,923
protected function getAvailableNamespaces ( ) : ? array { if ( \ is_null ( $ this -> namespaces ) ) { $ this -> namespaces = $ this -> getOriginalContent ( ) -> getNameSpaces ( true ) ; } return $ this -> namespaces ; }
Get available namespaces and cached it during runtime to avoid overhead .
49,924
public function files ( ) { if ( ! $ this -> hasRequestParameter ( 'uri' ) ) { throw new common_exception_MissingParameter ( 'uri' , __METHOD__ ) ; } $ itemUri = $ this -> getRequestParameter ( 'uri' ) ; $ item = $ this -> getResource ( $ itemUri ) ; if ( ! $ this -> hasRequestParameter ( 'lang' ) ) { throw new common_...
Returns a json encoded array describign a directory
49,925
public function fileExists ( ) { if ( ! $ this -> hasRequestParameter ( 'uri' ) || ! $ this -> hasRequestParameter ( 'path' ) || ! $ this -> hasRequestParameter ( 'lang' ) ) { throw new common_exception_MissingParameter ( ) ; } $ item = $ this -> getResource ( $ this -> getRequestParameter ( 'uri' ) ) ; $ itemLang = $ ...
Returns whenever or not a file exists at the indicated path
49,926
public function delete ( ) { if ( ! $ this -> hasRequestParameter ( 'uri' ) || ! $ this -> hasRequestParameter ( 'path' ) || ! $ this -> hasRequestParameter ( 'lang' ) ) { throw new common_exception_MissingParameter ( ) ; } $ item = $ this -> getResource ( $ this -> getRequestParameter ( 'uri' ) ) ; $ itemLang = $ this...
Delete a file from the item directory
49,927
protected function getMediaSource ( $ urlPrefix , $ item , $ itemLang ) { $ resolver = new ItemMediaResolver ( $ item , $ itemLang ) ; $ asset = $ resolver -> resolve ( $ urlPrefix ) ; return $ asset -> getMediaSource ( ) ; }
Get the media source based on the partial url
49,928
protected function defaultData ( ) { parent :: defaultData ( ) ; if ( $ this -> hasRequestParameter ( 'uri' ) ) { $ uri = $ this -> getRequestParameter ( 'uri' ) ; $ classUri = $ this -> getRequestParameter ( 'classUri' ) ; if ( ! empty ( $ uri ) ) { $ item = $ this -> getResource ( tao_helpers_Uri :: decode ( $ uri ) ...
overwrite the parent defaultData adding the item label to be sent to the view
49,929
public function editItemClass ( ) { $ this -> defaultData ( ) ; $ clazz = $ this -> getClass ( $ this -> getRequestParameter ( 'id' ) ) ; if ( $ this -> hasRequestParameter ( 'property_mode' ) ) { $ this -> setSessionAttribute ( 'property_mode' , $ this -> getRequestParameter ( 'property_mode' ) ) ; } $ myForm = $ this...
Edit a class
49,930
public function authoring ( ) { $ this -> defaultData ( ) ; $ item = $ this -> getResource ( $ this -> getRequestParameter ( 'id' ) ) ; if ( ! $ this -> isLocked ( $ item , 'item_locked.tpl' ) ) { $ this -> setData ( 'error' , false ) ; try { $ itemModel = $ this -> getClassService ( ) -> getItemModel ( $ item ) ; if (...
Item Authoring tool loader action
49,931
protected function getItemPacker ( ) { $ itemModel = $ this -> itemService -> getItemModel ( $ this -> item ) ; if ( is_null ( $ itemModel ) ) { throw new common_exception_NoImplementation ( 'No item model for item ' . $ this -> item -> getUri ( ) ) ; } $ impl = $ this -> itemService -> getItemModelImplementation ( $ i...
Get the packer for the item regarding it s implementation .
49,932
public function pack ( $ assetEncoders = array ( ) , $ nestedResourcesInclusion = true ) { try { $ itemPacker = $ this -> getItemPacker ( ) ; $ itemPacker -> setAssetEncoders ( $ assetEncoders ) ; $ itemPacker -> setNestedResourcesInclusion ( $ nestedResourcesInclusion ) ; $ itemPack = $ itemPacker -> packItem ( $ this...
Pack an item .
49,933
public function getItemCategories ( RdfResource $ item ) { $ categories = [ ] ; foreach ( $ item -> getTypes ( ) as $ class ) { $ eligibleProperties = $ this -> getElligibleProperties ( $ class ) ; $ propertiesValues = $ item -> getPropertiesValues ( array_keys ( $ eligibleProperties ) ) ; foreach ( $ propertiesValues ...
Get the categories of an item
49,934
public function getElligibleProperties ( RdfClass $ class ) { $ properties = $ this -> getItemService ( ) -> getClazzProperties ( $ class , new RdfClass ( self :: ITEM_CLASS_URI ) ) ; return array_filter ( $ properties , function ( $ property ) { if ( in_array ( $ property -> getUri ( ) , self :: $ excludedPropUris ) )...
Get the properties from a class that can be exposed
49,935
public function doesExposeCategory ( RdfProperty $ property ) { $ exposeProperty = new RdfProperty ( self :: EXPOSE_PROP_URI ) ; $ expose = $ property -> getOnePropertyValue ( $ exposeProperty ) ; return ! is_null ( $ expose ) && $ expose -> getUri ( ) === GenerisRdf :: GENERIS_TRUE ; }
Check if a property is exposed
49,936
public function exposeCategory ( RdfProperty $ property , $ value ) { $ exposeProperty = new RdfProperty ( self :: EXPOSE_PROP_URI ) ; if ( $ value == true ) { $ property -> setPropertyValue ( $ exposeProperty , GenerisRdf :: GENERIS_TRUE ) ; } else { $ property -> removePropertyValue ( $ exposeProperty , GenerisRdf ::...
Expose or not a property
49,937
public function getItemService ( ) { if ( is_null ( $ this -> itemService ) ) { $ this -> itemService = taoItems_models_classes_ItemsService :: singleton ( ) ; } return $ this -> itemService ; }
Service getter and initializer .
49,938
public static function copyResources ( $ sourceDirectory , $ destinationDirectory , $ excludeFiles = array ( ) ) { $ exclude = array_merge ( $ excludeFiles , array ( '.' , '..' , '.svn' ) ) ; $ success = true ; foreach ( scandir ( $ sourceDirectory ) as $ file ) { if ( ! in_array ( $ file , $ exclude ) ) { $ success &=...
Copy the resources from one directory to another
49,939
public static function setContext ( $ parameters , $ prefix = '' ) { self :: $ context = array ( ) ; foreach ( $ parameters as $ key => $ value ) { self :: $ context [ $ prefix . $ key ] = $ value ; } }
Short description of method setContext
49,940
public function getDirectory ( $ parentLink = '' , $ acceptableMime = array ( ) , $ depth = 1 ) { if ( ! tao_helpers_File :: securityCheck ( $ parentLink ) ) { throw new common_exception_Error ( __ ( 'Your path contains error' ) ) ; } $ label = rtrim ( $ parentLink , '/' ) ; if ( strrpos ( $ parentLink , '/' ) !== fals...
Get a array representing the tree of directory
49,941
public function download ( $ link ) { $ file = $ this -> getFile ( $ link ) ; $ relPath = $ this -> getItemDirectory ( ) -> getRelPath ( $ file ) ; $ tmpDir = rtrim ( \ tao_helpers_File :: createTempDir ( ) , '/' ) ; $ tmpFile = $ tmpDir . $ relPath ; if ( ! is_dir ( dirname ( $ tmpFile ) ) ) { mkdir ( dirname ( $ tmpF...
Copy file content to temp file . Path is return to be downloaded
49,942
public function add ( $ source , $ fileName , $ parent ) { if ( ! \ tao_helpers_File :: securityCheck ( $ fileName , true ) ) { throw new \ common_Exception ( 'Unsecured filename "' . $ fileName . '"' ) ; } if ( ( $ resource = fopen ( $ source , 'r' ) ) === false ) { throw new \ common_Exception ( 'Unable to read conte...
Add content to file
49,943
public function sasEditInstance ( ) { $ this -> loadStandaloneMode ( ) ; $ clazz = $ this -> getCurrentClass ( ) ; $ instance = $ this -> getCurrentInstance ( ) ; $ formContainer = new tao_actions_form_Instance ( $ clazz , $ instance ) ; $ myForm = $ formContainer -> getForm ( ) ; if ( $ myForm -> isSubmited ( ) ) { if...
Edit an instances
49,944
public function viewItem ( ) { $ this -> loadStandaloneMode ( ) ; if ( ! $ this -> isXmlHttpRequest ( ) ) { throw new common_exception_BadRequest ( 'wrong request mode' ) ; } $ itemClass = $ this -> getCurrentClass ( ) ; $ item = $ this -> getCurrentInstance ( ) ; $ lang = null ; if ( $ this -> hasRequestParameter ( 't...
view and item
49,945
protected function deployItem ( core_kernel_classes_Resource $ item , $ languageCode , $ compiledDirectory ) { $ itemService = taoItems_models_classes_ItemsService :: singleton ( ) ; $ sourceDir = $ itemService -> getItemDirectory ( $ item , $ languageCode ) ; $ success = taoItems_helpers_Deployment :: copyResources ( ...
deploys the item into the given absolute directory
49,946
protected function createService ( core_kernel_classes_Resource $ item , tao_models_classes_service_StorageDirectory $ destinationDirectory ) { $ service = new tao_models_classes_service_ServiceCall ( new core_kernel_classes_Resource ( taoItems_models_classes_ItemsService :: INSTANCE_SERVICE_ITEM_RUNNER ) ) ; $ service...
Create the item s ServiceCall .
49,947
public function getItemClass ( $ uri = '' ) { $ returnValue = null ; if ( empty ( $ uri ) && ! is_null ( $ this -> itemClass ) ) { $ returnValue = $ this -> itemClass ; } else { $ clazz = $ this -> getClass ( $ uri ) ; if ( $ this -> isItemClass ( $ clazz ) ) { $ returnValue = $ clazz ; } } return $ returnValue ; }
get an item subclass by uri . If the uri is not set it returns the item class ( the top level class . If the uri don t reference an item subclass it returns null
49,948
public function isItemClass ( core_kernel_classes_Class $ clazz ) { $ returnValue = ( bool ) false ; if ( $ this -> itemClass -> getUri ( ) == $ clazz -> getUri ( ) ) { return true ; } foreach ( $ clazz -> getParentClasses ( true ) as $ parent ) { if ( $ parent -> getUri ( ) == $ this -> itemClass -> getUri ( ) ) { $ r...
check if the class is a or a subclass of an Item
49,949
public function deleteResource ( core_kernel_classes_Resource $ resource ) { if ( LockManager :: getImplementation ( ) -> isLocked ( $ resource ) ) { $ userId = common_session_SessionManager :: getSession ( ) -> getUser ( ) -> getIdentifier ( ) ; LockManager :: getImplementation ( ) -> releaseLock ( $ resource , $ user...
delete an item
49,950
public function hasItemContent ( core_kernel_classes_Resource $ item , $ lang = '' ) { if ( is_null ( $ item ) ) { return false ; } if ( empty ( $ lang ) ) { $ lang = $ this -> getSessionLg ( ) ; } $ itemContents = $ item -> getPropertyValuesByLg ( $ this -> itemContentProperty , $ lang ) ; return ! $ itemContents -> i...
Check if the item has an itemContent Property
49,951
public function hasItemModel ( core_kernel_classes_Resource $ item , $ models ) { $ returnValue = ( bool ) false ; $ itemModel = $ item -> getOnePropertyValue ( $ this -> itemModelProperty ) ; if ( $ itemModel instanceof core_kernel_classes_Resource ) { if ( in_array ( $ itemModel -> getUri ( ) , $ models ) ) { $ retur...
Check if the Item has on of the itemModel property in the models array
49,952
public function isItemModelDefined ( core_kernel_classes_Resource $ item ) { $ returnValue = ( bool ) false ; if ( ! is_null ( $ item ) ) { $ model = $ item -> getOnePropertyValue ( $ this -> itemModelProperty ) ; if ( $ model instanceof core_kernel_classes_Literal ) { if ( strlen ( ( string ) $ model ) > 0 ) { $ retur...
Check if the itemModel has been defined for that item
49,953
public function getModelRuntime ( core_kernel_classes_Resource $ item ) { $ returnValue = null ; if ( ! is_null ( $ item ) ) { $ itemModel = $ item -> getOnePropertyValue ( $ this -> itemModelProperty ) ; if ( ! is_null ( $ itemModel ) ) { $ returnValue = $ itemModel -> getOnePropertyValue ( $ this -> getProperty ( tao...
Get the runtime associated to the item model .
49,954
public function hasModelStatus ( core_kernel_classes_Resource $ item , $ status ) { $ returnValue = ( bool ) false ; if ( ! is_null ( $ item ) ) { if ( ! is_array ( $ status ) && is_string ( $ status ) ) { $ status = array ( $ status ) ; } try { $ itemModel = $ item -> getOnePropertyValue ( $ this -> itemModelProperty ...
Short description of method hasModelStatus
49,955
protected function cloneItemContent ( core_kernel_classes_Resource $ source , core_kernel_classes_Resource $ destination , core_kernel_classes_Property $ property ) { $ serializer = $ this -> getFileReferenceSerializer ( ) ; $ this -> setItemModel ( $ destination , $ this -> getItemModel ( $ source ) ) ; foreach ( $ so...
Clone item content
49,956
public function getItemModel ( core_kernel_classes_Resource $ item ) { $ returnValue = null ; $ itemModel = $ item -> getOnePropertyValue ( $ this -> itemModelProperty ) ; if ( $ itemModel instanceof core_kernel_classes_Resource ) { $ returnValue = $ itemModel ; } return $ returnValue ; }
Short description of method getItemModel
49,957
public function setItemModel ( core_kernel_classes_Resource $ item , core_kernel_classes_Resource $ model ) { return $ item -> editPropertyValues ( $ this -> getProperty ( self :: PROPERTY_ITEM_MODEL ) , $ model ) ; }
Set the model of an item
49,958
public function getSessionLg ( ) { $ sessionLang = \ common_session_SessionManager :: getSession ( ) -> getDataLanguage ( ) ; if ( empty ( $ sessionLang ) ) { throw new Exception ( 'the data language of the user cannot be found in session' ) ; } return ( string ) $ sessionLang ; }
Rertrieve current user s language from the session object to know where item content should be located
49,959
public function deleteItemContent ( core_kernel_classes_Resource $ item ) { $ definitonFileValues = $ item -> getPropertyValues ( $ this -> itemContentProperty ) ; if ( ! empty ( $ definitonFileValues ) ) { $ directory = $ this -> getFileReferenceSerializer ( ) -> unserializeDirectory ( reset ( $ definitonFileValues ) ...
Deletes the content but does not unreference it
49,960
public function getItemModelImplementation ( core_kernel_classes_Resource $ itemModel ) { $ serviceId = ( string ) $ itemModel -> getOnePropertyValue ( $ this -> getProperty ( self :: PROPERTY_ITEM_MODEL_SERVICE ) ) ; if ( empty ( $ serviceId ) ) { throw new common_exception_NoImplementation ( 'No implementation found ...
Get the correct implementation for a specific item model
49,961
public function setDefaultFilesourceId ( $ filesourceId ) { $ ext = common_ext_ExtensionsManager :: singleton ( ) -> getExtensionById ( 'taoItems' ) ; $ ext -> setConfig ( self :: CONFIG_DEFAULT_FILESOURCE , $ filesourceId ) ; }
sets the filesource to use for new items
49,962
public function getItemDirectory ( core_kernel_classes_Resource $ item , $ language = '' ) { if ( $ language === '' ) { $ files = $ item -> getPropertyValues ( $ this -> itemContentProperty ) ; } else { $ files = $ item -> getPropertyValuesByLg ( $ this -> itemContentProperty , $ language ) -> toArray ( ) ; } if ( coun...
Returns the items flysystem directory
49,963
public function getDefaultItemDirectory ( ) { $ filesystemId = common_ext_ExtensionsManager :: singleton ( ) -> getExtensionById ( 'taoItems' ) -> getConfig ( self :: CONFIG_DEFAULT_FILESOURCE ) ; return $ this -> getServiceManager ( ) -> get ( FileSystemService :: SERVICE_ID ) -> getDirectory ( $ filesystemId ) ; }
Returns the defaul item directory
49,964
public function getAllByModel ( $ itemModel ) { if ( ! empty ( $ itemModel ) ) { $ uri = ( $ itemModel instanceof core_kernel_classes_Resource ) ? $ itemModel -> getUri ( ) : $ itemModel ; return $ this -> itemClass -> searchInstances ( array ( $ this -> itemModelProperty -> getUri ( ) => $ uri ) , array ( 'recursive' ...
Get items of a specific model
49,965
public function setAssets ( $ type , $ assets , $ publicDirectory ) { if ( ! in_array ( $ type , self :: $ assetTypes ) ) { throw new InvalidArgumentException ( 'Unknow asset type "' . $ type . '", it should be either ' . implode ( ', ' , self :: $ assetTypes ) ) ; } if ( ! is_array ( $ assets ) ) { throw new InvalidAr...
Set item s assets of a given type to the pack .
49,966
protected function getItemModel ( ) { try { return $ this -> getItem ( ) -> getUniquePropertyValue ( new core_kernel_classes_Property ( taoItems_models_classes_ItemsService :: PROPERTY_ITEM_MODEL ) ) ; } catch ( common_Exception $ e ) { return null ; } }
Obtains a reference on the Item Model related to the currently exported item instance .
49,967
public function getAssetContent ( $ assetPath ) { $ mediaAsset = $ this -> getItemMediaResolver ( ) -> resolve ( $ assetPath ) ; $ mediaSource = $ mediaAsset -> getMediaSource ( ) ; $ srcPath = $ mediaSource -> download ( $ mediaAsset -> getMediaIdentifier ( ) ) ; return file_get_contents ( $ srcPath ) ; }
Get the content of an asset .
49,968
public static function quickTransform ( $ xml , $ xsl , $ params = array ( ) ) { $ xml_dom = self :: getDOM ( $ xml ) ; $ xsl_dom = self :: prepareXsl ( $ xsl , $ params ) ; return self :: transform ( $ xml_dom , $ xsl_dom , $ params ) ; }
Transform the given xml with the given stylesheet adding params if necessary
49,969
public static function prepareXsl ( $ xsl , $ params = array ( ) ) { $ xsl_dom = self :: getDOM ( $ xsl ) ; return self :: addParams ( $ xsl_dom , $ params ) ; }
prepare the xsl stylesheet and add params dynamically
49,970
public static function getDOM ( $ str ) { $ dom = new DOMDocument ( ) ; is_file ( $ str ) ? $ dom -> load ( $ str ) : $ dom -> loadXML ( $ str ) ; return $ dom ; }
return the DOM corresponding to the parameter
49,971
private static function addParams ( $ dom , $ params ) { if ( ! sizeof ( $ params ) ) { return $ dom ; } $ xpath = new DOMXPath ( $ dom ) ; $ xpath -> registerNamespace ( self :: XSLT_SHORT_NS , self :: XSLT_NS ) ; $ items = $ xpath -> query ( '/' . self :: XSLT_SHORT_NS . ':stylesheet|' . self :: XSLT_SHORT_NS . ':tra...
insert the tag param for each params noexistent in xsl stylesheet
49,972
private function renderItem ( $ item ) { $ this -> response = $ this -> response -> withBody ( stream_for ( $ this -> getRenderedItem ( $ item ) ) ) ; }
Add the rendered item to psr7 response
49,973
public function getAdapters ( ) { $ registry = $ this -> getRegistry ( ) ; $ config = [ ] ; if ( $ registry -> isRegistered ( self :: REGISTRY_ENTRY_KEY ) ) { $ config = $ registry -> get ( self :: REGISTRY_ENTRY_KEY ) ; } if ( isset ( $ config [ self :: PREVIEWERS_KEY ] ) ) { return $ config [ self :: PREVIEWERS_KEY ]...
Gets the list of adapters
49,974
public function registerAdapter ( DynamicModule $ module ) { if ( ! is_null ( $ module ) && ! empty ( $ module -> getModule ( ) ) ) { $ registry = $ this -> getRegistry ( ) ; $ config = [ ] ; if ( $ registry -> isRegistered ( self :: REGISTRY_ENTRY_KEY ) ) { $ config = $ registry -> get ( self :: REGISTRY_ENTRY_KEY ) ;...
Registers a previewer adapter
49,975
public function unregisterAdapter ( $ moduleId ) { $ registry = $ this -> getRegistry ( ) ; $ config = [ ] ; if ( $ registry -> isRegistered ( self :: REGISTRY_ENTRY_KEY ) ) { $ config = $ registry -> get ( self :: REGISTRY_ENTRY_KEY ) ; } if ( isset ( $ config [ self :: PREVIEWERS_KEY ] ) && isset ( $ config [ self ::...
Unregisters a previewer adapter
49,976
public function getStrings ( \ core_kernel_classes_Resource $ resource ) { $ tokenizer = $ this -> getItemContentTokenizer ( $ resource ) ; if ( is_null ( $ tokenizer ) ) { return [ ] ; } return $ tokenizer -> getStrings ( $ resource ) ; }
Find item model tokenizer and send request to it to extract tokens
49,977
public function registerPreviewExtraButtons ( $ name , $ toolConfig ) { $ newConfig = array ( 'extraButtons' => array ( ) ) ; $ newConfig [ 'extraButtons' ] [ $ name ] = $ toolConfig ; $ this -> register ( self :: AMD , $ newConfig ) ; }
Register an extra button for the preview in the client lib config registry
49,978
protected function getClassProperties ( ) { $ properties = parent :: getClassProperties ( ) ; unset ( $ properties [ taoItems_models_classes_ItemsService :: PROPERTY_ITEM_MODEL ] ) ; unset ( $ properties [ taoItems_models_classes_ItemsService :: PROPERTY_ITEM_CONTENT ] ) ; unset ( $ properties [ taoItems_models_classes...
Get editable properties
49,979
protected function registerExtensions ( array $ config ) { foreach ( $ config as $ entry ) { $ name = ArrayHelper :: getValue ( $ entry , 'name' , false ) ; $ options = ArrayHelper :: getValue ( $ entry , 'options' , '' ) ; $ depends = ArrayHelper :: getValue ( $ entry , 'depends' , [ ] ) ; if ( in_array ( $ name , $ t...
Register jQuery IAS extensions .
49,980
protected function registerEventHandlers ( array $ config ) { foreach ( $ config as $ name => $ depends ) { $ eventName = 'eventOn' . ucfirst ( $ name ) ; if ( ! empty ( $ this -> $ eventName ) ) { if ( ! $ this -> checkEnabledExtensions ( $ depends ) ) { throw new InvalidConfigException ( "The \"{$name}\" event requir...
Register jQuery IAS event handlers .
49,981
protected function checkEnabledExtensions ( $ extensions ) { $ extensions = ( array ) $ extensions ; if ( empty ( $ extensions ) ) { return true ; } else { return ( count ( array_intersect ( $ this -> enabledExtensions , $ extensions ) ) == count ( $ extensions ) ) ; } }
Check whether the given extensions are enabled .
49,982
public function add ( $ tracking ) { $ sessionTracks = [ ] ; if ( Session :: has ( $ this -> sessionIdentifier ) ) { $ sessionTracks = Session :: get ( $ this -> sessionIdentifier ) ; } $ trackingKey = md5 ( $ tracking ) ; $ sessionTracks [ $ trackingKey ] = $ tracking ; Session :: flash ( $ this -> sessionIdentifier ,...
adds a tracking
49,983
public function get ( ) { $ trackings = [ ] ; if ( Session :: has ( $ this -> sessionIdentifier ) ) { $ trackings = Session :: get ( $ this -> sessionIdentifier ) ; Session :: forget ( $ this -> sessionIdentifier ) ; } return $ trackings ; }
returns all trackings
49,984
public function trackPage ( $ page = null , $ title = null , $ hittype = null ) { $ allowedHitTypes = [ 'pageview' , 'appview' , 'event' , 'transaction' , 'item' , 'social' , 'exception' , 'timing' ] ; if ( $ hittype === null ) { $ hittype = $ allowedHitTypes [ 0 ] ; } if ( ! in_array ( $ hittype , $ allowedHitTypes ) ...
track an page view
49,985
public function trackEvent ( $ category , $ action , $ label = null , $ value = null ) { $ command = '' ; if ( $ label !== null ) { $ command .= ", '{$label}'" ; if ( $ value !== null && is_numeric ( $ value ) ) { $ command .= ", {$value}" ; } } $ trackingCode = "ga('send', 'event', '{$category}', '{$action}'$command);...
track an event
49,986
public function render ( ) { $ script [ ] = $ this -> _getJavascriptTemplateBlockBegin ( ) ; $ trackingUserId = ( null === $ this -> userId ) ? '' : sprintf ( ", {'userId': '%s'}" , $ this -> userId ) ; if ( $ this -> debug ) { $ script [ ] = "ga('create', '{$this->trackingId}', { 'cookieDomain': 'none' }, '{$this->tra...
returns the javascript embedding code
49,987
public function nonInteraction ( $ value = null ) { if ( null === $ value ) { return $ this -> nonInteraction ; } $ this -> nonInteraction = ( $ value === true ) ; return $ this ; }
sets or gets nonInteraction
49,988
public function setCustom ( $ dimension , $ value = null ) { if ( $ value === null && is_array ( $ dimension ) ) { $ params = json_encode ( $ dimension ) ; $ trackingCode = "ga('set', $params);" ; } else { $ trackingCode = "ga('set', '$dimension', '$value');" ; } $ this -> trackCustom ( $ trackingCode ) ; return $ this...
sets custom dimensions
49,989
protected function _getJavascriptTemplateBlockBegin ( ) { $ appendix = $ this -> debug ? '_debug' : '' ; $ scriptTag = ( $ this -> cspNonce === null ) ? '<script>' : '<script nonce="' . $ this -> cspNonce . '">' ; return ( $ this -> renderScriptBlock ) ? $ scriptTag . "(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject'...
returns start block
49,990
public function makeInstance ( ) { $ class = $ this -> getVersionedRedisSentinelManagerClass ( ) ; $ config = $ this -> config -> get ( 'database.redis-sentinel' , [ ] ) ; $ driver = Arr :: pull ( $ config , 'client' , 'predis' ) ; if ( $ this -> appVersionLessThan ( '5.7' ) ) { return new RedisSentinelManager ( new $ ...
Create an instance of the package s core Redis Sentinel service .
49,991
protected function getVersionedRedisSentinelManagerClass ( ) { if ( $ this -> config -> isLumen ) { $ frameworkVersion = '5.4' ; } else { $ frameworkVersion = '5.4.20' ; } if ( $ this -> appVersionLessThan ( $ frameworkVersion ) ) { return Laravel540RedisSentinelManager :: class ; } return Laravel5420RedisSentinelManag...
Get the fully - qualified class name of the RedisSentinelManager class for the current version of Laravel or Lumen .
49,992
protected function resolveConnection ( $ name = null ) { $ name = $ name ? : 'default' ; $ options = Arr :: get ( $ this -> config , 'options' , [ ] ) ; if ( isset ( $ this -> config [ $ name ] ) ) { return $ this -> connector ( ) -> connect ( $ this -> config [ $ name ] , $ options ) ; } if ( isset ( $ this -> config ...
Get the Redis Connection instance represented by the specified name
49,993
public function register ( ) { if ( ! $ this -> config -> shouldIntegrateHorizon ) { return ; } $ this -> config -> loadHorizonConfiguration ( ) ; $ this -> registerServices ( ) ; if ( $ this -> shouldRebindHorizonRedisFactory ( ) ) { $ this -> rebindHorizonRedisFactory ( ) ; } }
Configure the package s services for use with Laravel Horizon .
49,994
protected function rebindHorizonRedisFactory ( ) { foreach ( ( new HorizonServiceBindings ( ) ) as $ serviceClass ) { $ this -> app -> when ( $ serviceClass ) -> needs ( RedisFactory :: class ) -> give ( function ( ) { return $ this -> app -> make ( 'redis-sentinel.manager' ) ; } ) ; } }
Add contextual bindings for Horizon s services that inject the package s Redis Sentinel manager .
49,995
protected function addHorizonSentinelQueueConnector ( ) { $ this -> app -> make ( 'queue' ) -> extend ( 'redis-sentinel' , function ( ) { $ redis = $ this -> app -> make ( 'redis-sentinel.manager' ) ; return new HorizonRedisConnector ( $ redis ) ; } ) ; }
Add redis - sentinel as an available queue connection driver option to the Laravel queue manager using Horizon s modified Redis connector .
49,996
public function boot ( ) { $ this -> bootComponentDrivers ( ) ; if ( $ this -> config -> shouldOverrideLaravelRedisApi ) { $ this -> removeDeferredRedisServices ( ) ; } if ( $ this -> config -> shouldIntegrateHorizon ) { $ horizon = new HorizonServiceProvider ( $ this -> app , $ this -> config ) ; $ horizon -> register...
Boot the service by registering extensions with Laravel s cache queue and session managers for the redis - sentinel driver .
49,997
public function register ( ) { $ this -> config = ConfigurationLoader :: load ( $ this -> app ) ; $ this -> registerServices ( ) ; if ( $ this -> config -> shouldOverrideLaravelRedisApi ) { $ this -> registerOverrides ( ) ; } }
Bind the redis - sentinel database driver to the application service container .
49,998
protected function registerServices ( ) { $ this -> app -> singleton ( 'redis-sentinel' , function ( ) { return VersionedManagerFactory :: make ( $ this -> app , $ this -> config ) ; } ) ; $ this -> app -> singleton ( 'redis-sentinel.manager' , function ( $ app ) { return $ app -> make ( 'redis-sentinel' ) -> getVersio...
Register the core Redis Sentinel connection manager .
49,999
protected function registerOverrides ( ) { $ this -> app -> singleton ( 'redis' , function ( $ app ) { return $ app -> make ( 'redis-sentinel' ) ; } ) ; $ this -> app -> bind ( 'redis.connection' , function ( $ app ) { return $ app -> make ( 'redis-sentinel.manager' ) -> connection ( ) ; } ) ; }
Replace the standard Laravel Redis service with the Redis Sentinel database driver so all Redis operations use Sentinel connections .