idx
int64
0
60.3k
question
stringlengths
92
4.62k
target
stringlengths
7
635
800
public function setLimit ( $ limit ) { $ this -> limit = $ limit > 0 ? $ limit : 1 ; $ this -> setPage ( $ this -> page ) ; }
Sets the results limit for one page .
801
public function getNextPage ( ) { $ lastPage = $ this -> getLastPage ( ) ; return $ this -> page < $ lastPage ? $ this -> page + 1 : $ lastPage ; }
Returns the next page number .
802
public function getLastPage ( ) { return $ this -> hasResults ( ) ? ceil ( $ this -> adapter -> getTotalResults ( ) / $ this -> limit ) : $ this -> getFirstPage ( ) ; }
Returns the last page number .
803
public function getResults ( ) { return $ this -> hasResults ( ) ? $ this -> adapter -> getResults ( $ this -> getOffset ( ) , $ this -> limit ) : [ ] ; }
Returns results list for the current page and limit .
804
public function addAttributes ( $ arrAttributes ) { foreach ( $ arrAttributes as $ key => $ val ) { $ this -> attributes [ $ key ] = $ val ; } }
Adds the supplied array of attributes
805
public function generateCode ( ) { $ content = "" ; foreach ( $ this -> arrTemplates as $ template ) { if ( ! file_exists ( $ template ) ) { continue ; } $ content .= file_get_contents ( $ template ) ; } foreach ( $ this -> attributes as $ key => $ val ) { $ content = str_replace ( $ this -> placeHolderStart . $ key . ...
Generates the File content
806
public function generate ( ) { if ( ! $ this -> filePath ) { throw new Exception ( 'Trying to save file without path' ) ; } $ tempDir = codemonkey_pathTempDir ; $ content = $ this -> generateCode ( ) ; $ this -> checkIfTempFolderExists ( ) ; $ this -> checkIfFoldersExist ( ) ; try { $ fp = fopen ( $ tempDir . $ this ->...
Creates the file in the temp folder
807
protected function checkIfFoldersExist ( ) { $ arrFilePath = explode ( DIRECTORY_SEPARATOR , $ this -> filePath ) ; array_pop ( $ arrFilePath ) ; if ( count ( $ arrFilePath ) > 0 ) { $ folderPath = implode ( DIRECTORY_SEPARATOR , $ arrFilePath ) ; $ folder = new Folder ( ) ; $ folder -> createFolderIfNotExists ( $ fold...
Create folders if not existing
808
public static function each ( ORM & $ model , Request $ request , $ data = null ) { if ( ! is_null ( $ data ) ) { foreach ( $ data as $ key ) { $ model -> $ key = $ request -> $ $ key ; } } else { foreach ( $ request -> all ( ) as $ key => $ value ) { if ( in_array ( $ key , $ model -> _columns ) ) { $ model -> $ key =...
Set each properties of model from request .
809
public function run ( callable $ callback , array $ argsCollection ) { $ this -> collector -> init ( ) ; $ children = [ ] ; foreach ( $ argsCollection as $ key => $ args ) { $ pid = pcntl_fork ( ) ; switch ( $ pid ) { case - 1 : throw new \ RuntimeException ( sprintf ( 'Unable to fork process %d of %d' , $ key , count ...
Run a callback in parallel processes
810
public function getTable ( ) { $ this -> _resetSizes ( ) ; $ this -> _repadAllLines ( ) ; return array ( 'title' => $ this -> getTitle ( ) , 'head' => $ this -> getHeader ( ) , 'body' => $ this -> getBody ( ) , 'foot' => $ this -> getFooter ( ) , ) ; }
Get the full table array
811
public function getTableIterator ( $ part = 'body' , $ iterator_flag = self :: ITERATE_ON_LINES ) { $ this -> _repadAllLines ( ) ; $ table = $ this -> getTable ( ) ; unset ( $ table [ 'title' ] ) ; if ( ! empty ( $ part ) ) { if ( isset ( $ table [ $ part ] ) ) { if ( $ iterator_flag & self :: ITERATE_ON_COLUMNS ) { $ ...
Get the full table or a part of the table as an ArrayIterator object
812
public function addLine ( $ contents = null , $ default = null ) { $ this -> addBodyLine ( is_array ( $ contents ) ? $ contents : array ( $ contents ) , null , $ default ) ; return $ this ; }
Add a new line in the table body
813
public function setHeaderLine ( array $ contents , $ line_index = null , $ default = null ) { $ this -> _setPartLine ( $ contents , $ line_index , $ default , 'thead' ) ; return $ this ; }
Set a table header line
814
public function addHeaderLine ( array $ contents , $ line_index = null , $ default = null ) { $ this -> _setPartLine ( $ contents , $ line_index , $ default , 'thead' , 'insert' ) ; return $ this ; }
Add a new table header line
815
public function setHeaderColumn ( array $ contents = array ( ) , $ column_index = null , $ default = null ) { $ this -> _setPartColumn ( $ contents , $ column_index , $ default , 'thead' ) ; return $ this ; }
Set a column in the table header
816
public function addHeaderColumn ( array $ contents = array ( ) , $ column_index = null , $ default = null ) { $ this -> _setPartColumn ( $ contents , $ column_index , $ default , 'thead' , 'insert' ) ; return $ this ; }
Add a new column in the table header
817
public function setHeaderCell ( $ content , $ line_index = null , $ cell_index = null ) { $ this -> _setPartCell ( $ content , $ line_index , $ cell_index , 'thead' ) ; return $ this ; }
Set a table header cell
818
public function addHeaderCell ( $ content , $ line_index = null , $ cell_index = null ) { $ this -> _setPartCell ( $ content , $ line_index , $ cell_index , 'thead' , 'insert' ) ; return $ this ; }
Add a new table header cell
819
public function setBodyColumn ( array $ contents = array ( ) , $ column_index = null , $ default = null ) { $ this -> _setPartColumn ( $ contents , $ column_index , $ default , 'tbody' ) ; return $ this ; }
Set a column in the table body
820
public function setBodyCell ( $ content , $ line_index = null , $ cell_index = null ) { $ this -> _setPartCell ( $ content , $ line_index , $ cell_index , 'tbody' ) ; return $ this ; }
Set a table body cell
821
public function addBodyCell ( $ content , $ line_index = null , $ cell_index = null ) { $ this -> _setPartCell ( $ content , $ line_index , $ cell_index , 'tbody' , 'insert' ) ; return $ this ; }
Add a new table body cell
822
public function setFooterColumn ( array $ contents = array ( ) , $ column_index = null , $ default = null ) { $ this -> _setPartColumn ( $ contents , $ column_index , $ default , 'tfoot' ) ; return $ this ; }
Set a column in the table footers
823
public function addFooterColumn ( array $ contents = array ( ) , $ column_index = null , $ default = null ) { $ this -> _setPartColumn ( $ contents , $ column_index , $ default , 'tfoot' , 'insert' ) ; return $ this ; }
Add a new column in the table footers
824
public function setFooterCell ( $ content , $ line_index = null , $ cell_index = null ) { $ this -> _setPartCell ( $ content , $ line_index , $ cell_index , 'tfoot' ) ; return $ this ; }
Set a table footer cell
825
public function addFooterCell ( $ content , $ line_index = null , $ cell_index = null ) { $ this -> _setPartCell ( $ content , $ line_index , $ cell_index , 'tfoot' , 'insert' ) ; return $ this ; }
Add a new table footer cell
826
public function getTableColumnSize ( ) { if ( $ this -> column_size === 0 && $ this -> line_size === 0 && $ this -> cell_size === 0 ) { $ this -> _parseTableSizes ( ) ; } return $ this -> column_size ; }
Get the table columns size
827
public function getTableLineSize ( ) { if ( $ this -> column_size === 0 && $ this -> line_size === 0 && $ this -> cell_size === 0 ) { $ this -> _parseTableSizes ( ) ; } return $ this -> line_size ; }
Get the table lines size
828
public function getTableCellSize ( ) { if ( $ this -> column_size === 0 && $ this -> line_size === 0 && $ this -> cell_size === 0 ) { $ this -> _parseTableSizes ( ) ; } return $ this -> cell_size ; }
Get the table cells size
829
public function getSizesInfos ( ) { if ( $ this -> column_size === 0 && $ this -> line_size === 0 && $ this -> cell_size === 0 ) { $ this -> _parseTableSizes ( ) ; } return sprintf ( self :: $ default_foot_mask , $ this -> getColumnSize ( ) , $ this -> getLineSize ( ) , $ this -> getCellSize ( ) ) ; }
Get a string information presenting an overview of the table
830
protected function _setPart ( array $ contents , $ part ) { if ( property_exists ( $ this , $ part ) ) { $ this -> { $ part } = $ this -> _getSetOfLines ( $ contents ) ; $ this -> _parseTableSizes ( true ) ; } elseif ( ! in_array ( $ part , self :: $ _table_parts ) ) { throw new InvalidArgumentException ( sprintf ( 'Un...
Set a table part lines
831
protected function _setPartLine ( array $ contents , $ line_index , $ part , $ action = 'replace' ) { if ( property_exists ( $ this , $ part ) ) { if ( is_null ( $ line_index ) ) { end ( $ this -> { $ part } ) ; $ line_index = key ( $ this -> { $ part } ) + 1 ; } else { $ line_index -- ; } if ( $ line_index < $ this ->...
Set a single table part line
832
protected function _setPartColumn ( array $ contents , $ column_index , $ default , $ part , $ action = 'replace' ) { if ( property_exists ( $ this , $ part ) ) { if ( is_null ( $ column_index ) || $ column_index > $ this -> getColumnSize ( ) ) { $ column_index = $ this -> getColumnSize ( ) ; } else { $ column_index --...
Set a single table part column
833
protected function _setPartCell ( $ content , $ line_index , $ cell_index , $ part , $ action = 'replace' ) { if ( property_exists ( $ this , $ part ) ) { if ( is_null ( $ line_index ) ) { end ( $ this -> { $ part } ) ; $ line_index = key ( $ this -> { $ part } ) ; } else { $ line_index -- ; } if ( is_null ( $ cell_ind...
Set a single table part cell
834
protected function _getPart ( $ part ) { if ( property_exists ( $ this , $ part ) ) { return $ this -> { $ part } ; } elseif ( ! in_array ( $ part , self :: $ _table_parts ) ) { throw new InvalidArgumentException ( sprintf ( 'Unknown table part "%s"!' , $ part ) ) ; } }
Get a table part lines array
835
protected function _getPartLine ( $ line_index , $ part ) { if ( property_exists ( $ this , $ part ) ) { if ( is_null ( $ line_index ) ) { $ column_index = $ this -> getLineSize ( ) ; } else { $ line_index -- ; } return isset ( $ this -> { $ part } [ $ line_index ] ) ? $ this -> { $ part } [ $ line_index ] : null ; } e...
Get a single table part line
836
protected function _getPartColumn ( $ column_index , $ part ) { if ( property_exists ( $ this , $ part ) ) { if ( is_null ( $ column_index ) ) { $ column_index = $ this -> getColumnSize ( ) ; } else { $ column_index -- ; } $ column = array ( ) ; foreach ( $ this -> tbody as $ line ) { $ column [ ] = isset ( $ line [ $ ...
Get a column of the table body
837
protected function _getPartCell ( $ line_index , $ cell_index , $ part ) { if ( property_exists ( $ this , $ part ) ) { if ( is_null ( $ line_index ) ) { $ line_index = $ this -> getLineSize ( ) ; } else { $ line_index -- ; } if ( is_null ( $ cell_index ) ) { if ( isset ( $ this -> { $ part } [ $ line_index ] ) ) { end...
Get a single table part cell
838
protected function _getSetOfLines ( $ content ) { if ( ! is_array ( $ content ) ) $ content = array ( $ content ) ; reset ( $ content ) ; if ( ! is_array ( current ( $ content ) ) ) { $ content = array ( 0 => $ content ) ; } return $ content ; }
This rebuilds an array to a multi - dimensional array of arrays if necessary
839
protected function _repadAllLines ( ) { $ this -> _parseTableSizes ( true ) ; foreach ( self :: $ _table_parts as $ part ) { if ( ! empty ( $ this -> { $ part } ) && is_array ( $ this -> { $ part } ) ) { foreach ( $ this -> { $ part } as $ l => $ part_line ) { if ( ! empty ( $ part_line ) && count ( $ part_line ) !== $...
Recalculation of each line when the cell count has changed
840
protected function _getPaddedLine ( $ content ) { if ( ! is_array ( $ content ) ) $ content = array ( $ content ) ; if ( $ this -> column_size === 0 && $ this -> line_size === 0 && $ this -> cell_size === 0 ) { $ this -> _parseTableSizes ( ) ; } if ( count ( $ content ) > $ this -> getColumnSize ( ) ) { $ this -> _repa...
This completes a line if necessary with empty cells
841
protected function _parseTableSizes ( $ reset = false ) { if ( $ reset ) $ this -> _resetSizes ( ) ; $ this -> line_size = count ( $ this -> tbody ) ; foreach ( self :: $ _table_parts as $ part ) { if ( ! empty ( $ this -> { $ part } ) && is_array ( $ this -> { $ part } ) ) { foreach ( $ this -> { $ part } as $ part_li...
Calculation of all table sizes
842
public function render ( $ str_pad_flag = STR_PAD_RIGHT ) { $ stacks = array ( ) ; if ( $ this -> column_size === 0 && $ this -> line_size === 0 && $ this -> cell_size === 0 ) { $ this -> _parseTableSizes ( ) ; } foreach ( self :: $ _table_parts as $ part ) { if ( ! empty ( $ this -> { $ part } ) && is_array ( $ this -...
Plain text rendering of the table
843
public function add ( $ pField , $ pType , $ pValue = NULL ) { if ( $ pField == ItemInterface :: IDFIELD ) { if ( ! is_array ( $ pValue ) and ! $ pValue instanceof Id ) { $ id = new Id ( $ pValue ) ; $ pValue = $ id -> getOrig ( ) ; } else if ( is_array ( $ pValue ) ) { if ( empty ( $ pValue ) ) { throw new Exception (...
Add a new condition .
844
public function firstOrCreate ( array $ where ) { $ this -> applyCriteria ( ) ; $ this -> applyScope ( ) ; $ model = $ this -> model -> firstOrCreate ( $ where ) ; $ this -> resetModel ( ) ; event ( new RepositoryEntityCreated ( $ this , $ model ) ) ; return $ this -> parserResult ( $ model ) ; }
Find data by multiple fields or create if not exists .
845
public function createOrUpdate ( array $ where , array $ attributes ) { $ this -> applyCriteria ( ) ; $ this -> applyScope ( ) ; $ _skipPresenter = $ this -> skipPresenter ; $ this -> skipPresenter ( true ) ; $ model = $ this -> model -> firstOrCreate ( $ where ) ; $ model -> fill ( $ attributes ) ; $ model -> save ( )...
Find data by multiple fields and update or create if not exists .
846
public function onKernelRequest ( ) { $ token = $ this -> tokenStorage -> getToken ( ) ; if ( ! $ token ) { return ; } if ( ! $ token instanceof UsernamePasswordToken ) { return ; } if ( $ token -> getProviderKey ( ) != 'backoffice' ) { return ; } $ filter = $ this -> entityManager -> getFilters ( ) -> enable ( 'node_p...
Enable the NodePublicationFilter when not in the backoffice ..
847
public static function GetPhpIniSizeLimit ( $ iniVarName ) { $ rawIniValue = @ ini_get ( $ iniVarName ) ; if ( $ rawIniValue === FALSE ) { return 0 ; } else if ( $ rawIniValue === NULL ) { return NULL ; } $ unit = strtoupper ( substr ( $ rawIniValue , - 1 ) ) ; $ multiplier = ( $ unit == 'M' ? 1048576 : ( $ unit == 'K'...
Get PHP data limit as integer value by given PHP INI variable name .
848
public static function & GetById ( $ formId ) { if ( isset ( self :: $ instances [ $ formId ] ) ) { return self :: $ instances [ $ formId ] ; } else { throw new \ RuntimeException ( 'No form instance exists under form id `' . $ formId . '`.' . ' Check if searched form instance has been already initialized' . ' or if fo...
Get form instance by form id string . If no form instance found thrown an RuntimeException .
849
public static function & GetAutoFocusedFormField ( $ formId , $ fieldName ) { if ( self :: $ autoFocusedFormField ) { list ( $ currentFormId , $ currentFieldName ) = self :: $ autoFocusedFormField ; return self :: GetById ( $ currentFormId ) -> GetField ( $ currentFieldName ) ; } return NULL ; }
Get form field instance with defined autofocus boolean attribute . If there is no field in any form with this attribute return NULL .
850
public function mergeFeatures ( array $ features ) { foreach ( $ features as $ feature ) { $ this -> storeToAll ( $ feature ) ; $ this -> storeToCanonical ( $ feature ) ; } }
Merges the given features into this set
851
protected function storeToAll ( FeatureInterface $ feature ) { $ name = $ feature -> getName ( ) ; if ( ! isset ( $ this -> all [ $ name ] ) ) { $ this -> all [ $ name ] = [ ] ; } $ this -> all [ $ name ] [ $ feature -> getProvider ( ) -> getName ( ) ] = $ feature ; }
Stores the given feature to the array of all encountered features
852
protected function storeToCanonical ( FeatureInterface $ feature ) { $ name = $ feature -> getName ( ) ; $ was = $ this -> getFeature ( $ name ) ; $ new = $ feature -> resolve ( $ was ) ; $ this -> canonical [ $ name ] = $ new ; if ( $ was !== $ new ) { $ this -> logger -> debug ( 'New canonical feature: {feature} from...
Conditionally marks a feature instance as canonical for a name
853
public function exportList ( Array $ list ) { $ that = $ this ; return sprintf ( 'array(%s)' , A :: implode ( $ list , ',' , function ( $ item ) use ( $ that ) { if ( is_array ( $ item ) ) { return $ that -> exportList ( $ item ) ; } elseif ( $ item instanceof \ stdClass ) { return $ that -> exportStdClass ( $ item , '...
Nimmt einen Array und exportiert diesen in einer Zeile
854
public function exportKeyList ( Array $ array , $ type = 'keyList' ) { $ that = $ this ; return sprintf ( 'array(%s)' , A :: implode ( $ array , ',' , function ( $ item , $ key ) use ( $ that , $ type ) { if ( is_array ( $ item ) ) { $ value = $ type === 'keyList' ? $ that -> exportKeyList ( $ item ) : $ that -> export...
Sowie exportList jedoch setzt dieses auch die Keys
855
public function getOrderForSeller ( Profile $ seller ) { foreach ( $ this -> getOrders ( ) as $ order ) { if ( $ order -> getSeller ( ) -> getId ( ) == $ seller -> getId ( ) ) { return $ order ; } } return $ this -> createOrderForSeller ( $ seller ) ; }
Get Order for given Seller
856
public function createOrderForSeller ( Profile $ seller ) { $ order = new Order ( ) ; $ order -> setSeller ( $ seller ) ; if ( $ this -> getBuyer ( ) ) { $ order -> setBuyer ( $ this -> getBuyer ( ) ) ; } $ this -> addOrder ( $ order ) ; return $ order ; }
Create Order for given Seller
857
public function load ( $ resource , $ type = null ) { $ configs = Yaml :: parse ( $ resource ) ; return $ this -> createSchemas ( $ configs ) ; }
Loads the schemas configurations resource file .
858
public function getTable ( ) { if ( isset ( $ this -> table ) ) { return $ this -> table ; } return snake_case ( array_pop ( explode ( '\\' , get_class ( $ this ) ) ) ) ; }
When automapping the table name use singular case rather than plural .
859
public function getType ( $ kebabCase = false ) { if ( $ kebabCase ) { return strtolower ( str_replace ( '_' , '-' , $ this -> getTable ( ) ) ) ; } return strtoupper ( $ this -> getTable ( ) ) ; }
Get this Entity s type .
860
private static function isValidOrigin ( RequestInterface $ request ) : bool { if ( ! self :: compareHeaderUrl ( $ request , 'Origin' ) ) { return false ; } if ( ! self :: compareHeaderUrl ( $ request , 'Referer' ) ) { return false ; } return true ; }
Checks if the request has valid origin headers present .
861
private static function compareHeaderUrl ( RequestInterface $ request , string $ headerName ) : bool { $ headerValue = $ request -> getHeader ( $ headerName ) ; if ( $ headerValue === null ) { return true ; } $ headerUrl = Url :: tryParse ( $ headerValue ) ; if ( $ headerUrl === null ) { return false ; } return $ heade...
Compares a header url with the url in the request .
862
public function encode ( JWT $ jwt ) { $ this -> jwt = $ jwt ; $ token = Codec :: encode ( $ jwt -> getClaims ( ) , $ this -> secret ) ; return $ token ; }
Encodes given JWT
863
public function decode ( $ token ) { $ jwt = new JWT ( ) ; try { $ decoded = Codec :: decode ( $ token , $ this -> secret , [ 'HS256' ] ) ; } catch ( \ Firebase \ JWT \ SignatureInvalidException $ e ) { $ jwt -> setSignatureValid ( false ) ; } catch ( \ Exception $ e ) { } list ( $ header , $ payload , $ signature ) = ...
Decodes given token
864
public function savePriority ( ) { $ ITER = 1 ; $ metaTable = TableRegistry :: get ( 'CmsContentMeta' ) ; if ( $ this -> request -> is ( 'post' ) ) : $ items = explode ( ',' , $ this -> request -> data [ 'order' ] ) ; foreach ( $ items as $ id ) : $ meta = $ metaTable -> get ( $ id ) ; $ meta -> priority = $ ITER ++ ; ...
This function is invoked in AJAX to save the priority sorting
865
public function actionIndex ( $ page = 1 ) { $ sort = [ ] ; $ params = Yii :: $ app -> request -> queryParams ; if ( empty ( $ params [ 'sort' ] ) ) { $ sort [ 'defaultOrder' ] = [ 'parent_uid' => SORT_ASC , 'module_id' => SORT_ASC ] ; } else { if ( $ params [ 'sort' ] == 'module_id' ) { $ sort [ 'defaultOrder' ] = [ '...
Lists all Modmgr models .
866
public function actionRebuildDefaultConfig ( $ id ) { $ model = $ this -> findModel ( $ id ) ; $ configDefault = $ model -> buildDefaultConfig ( $ model -> module_class ) ; $ model -> config_default = var_export ( $ configDefault , true ) ; $ model -> save ( true , [ 'config_default' ] ) ; return $ model -> config_defa...
Rebuild default module config . Use in ajax request .
867
public function actionCreate ( $ parent = 0 ) { $ installModel = new CreateModule ( [ 'tc' => $ this -> module -> tcModule ] ) ; $ post = Yii :: $ app -> request -> post ( ) ; if ( empty ( $ post ) ) { $ installModel -> loadDefaultValues ( ) ; $ installModel -> parentUid = ModulesManager :: numberedIdFromDbId ( $ paren...
Creates a new Modmgr model . If creation is successful the browser will be redirected to the view page .
868
public function actionUpdate ( $ id ) { $ model = $ this -> findModel ( $ id ) ; $ oldSubmodulesParentUid = $ model -> parent_uid . '/{' . $ model -> id . '}' ; $ post = Yii :: $ app -> request -> post ( ) ; $ loaded = $ model -> load ( $ post ) ; if ( $ loaded && $ model -> save ( ) ) { $ newSubmodulesParentUid = $ mo...
Updates an existing Modmgr model . If update is successful the browser will be redirected to the view page .
869
public function actionDelete ( $ id ) { $ model = $ this -> findModel ( $ id ) ; if ( $ model -> is_active == false ) { $ model -> delete ( ) ; Yii :: $ app -> session -> setFlash ( 'success' , Yii :: t ( $ this -> tcModule , "Module has been deleted" ) ) ; } else { Yii :: $ app -> session -> setFlash ( 'error' , Yii :...
Deletes an existing Modmgr model . If deletion is successful the browser will be redirected to the index page .
870
public function actionChangeActive ( $ id ) { $ model = $ this -> findModel ( $ id ) ; $ model -> is_active = $ model -> is_active ? false : true ; $ model -> save ( ) ; Yii :: $ app -> session -> setFlash ( 'success' , Yii :: t ( $ this -> tcModule , "Module's activity has been changed" ) ) ; $ params = Yii :: $ app -...
Change is_active model attribute .
871
public function setModelName ( $ modelName ) { if ( ! class_exists ( $ modelName ) ) throw new Exception ( "Model '{$modelName}' could not be found" ) ; $ model = new \ ReflectionClass ( $ modelName ) ; if ( ! $ model -> implementsInterface ( '\Phalcon\Mvc\ModelInterface' ) ) throw new Exception ( "'{$modelName}' must ...
Set Modelname - must implement Phalcon \ Mvc \ ModelInterface
872
public function getThumbnail ( $ originalImagePath , $ type ) { if ( array_key_exists ( $ type , $ this -> getTypes ( ) ) ) { return preg_replace ( '#^(.*)\.(' . implode ( '|' , $ this -> getAllowedExtensions ( ) ) . ')$#' , '$1-' . $ this -> getThumbnailPrefix ( ) . '-' . $ type . '.$2' , $ originalImagePath ) ; } ret...
Get thumbnail path from original image path
873
public function cleanThumbnails ( $ path = '' ) { $ cleanPathInfo = new SplFileInfo ( realpath ( $ this -> getDocumentRoot ( ) . DIRECTORY_SEPARATOR . $ path ) ) ; if ( strpos ( $ cleanPathInfo -> getRealPath ( ) , $ this -> getDocumentRoot ( ) ) === 0 ) { if ( $ cleanPathInfo -> isDir ( ) ) { $ dirIterator = new Recur...
Clean thumbnails for specified thumbnails directory or image Directory or image must exist
874
public function get ( $ name ) { if ( $ this -> cache -> has ( $ name ) ) { return $ this -> loader -> load ( $ this -> cache -> get ( $ name ) ) ; } if ( ! $ this -> cache -> isFresh ( ) ) { $ this -> refresh ( ) ; return $ this -> get ( $ name ) ; } throw new \ InvalidArgumentException ( sprintf ( 'Unknown resource n...
Return the definition for the given resource name
875
public function keys ( ) { $ names = $ this -> cache -> keys ( ) ; if ( empty ( $ names ) && ! $ this -> cache -> isFresh ( ) ) { $ this -> refresh ( ) ; return $ this -> keys ( ) ; } return $ names ; }
Return all the resource names
876
public function refresh ( ) { $ url = $ this -> resolver -> resolve ( $ this -> host , '/*' ) ; $ response = $ this -> http -> options ( $ url , [ 'headers' => [ 'Accept' => 'application/json' , ] , ] ) ; if ( $ response -> getStatusCode ( ) !== 200 || ! $ response -> hasHeader ( 'Link' ) ) { throw new CapabilitiesExce...
Reload all the resource names available for the server
877
public function createField ( $ dbQuery , $ entity , $ param = null , $ identifier = null ) { if ( class_exists ( $ this -> fieldClass ) ) { $ this -> field = new $ this -> fieldClass ( $ dbQuery , $ entity , $ param , $ identifier ) ; } else { e ( 'Class (##) not found' , E_SAMSON_CORE_ERROR , $ this -> fieldClass ) ;...
Create field class instance
878
public function __async_save ( ) { $ response = array ( 'status' => 0 ) ; if ( isset ( $ _POST ) ) { $ entity = & $ _POST [ '__entity' ] ; $ param = & $ _POST [ '__param' ] ; $ identifier = & $ _POST [ '__obj_id' ] ; $ value = & $ _POST [ '__value' ] ; if ( ! isset ( $ value ) ) { e ( 'CMSField - no "value" is passed f...
Save handler for CMS Field input
879
final public function ormToEntity ( $ data = [ ] , $ entity = '' ) { $ entities = [ ] ; foreach ( $ data as $ value ) { if ( $ entity != '' ) { $ entityName = '\entity\\' . $ entity ; $ entityObject = new $ entityName ( Database :: instance ( ) -> db ( ) ) ; foreach ( $ value as $ key => $ value2 ) { $ entityObject -> ...
transform sql data in Entity
880
public static function chainToCamel ( $ chain ) { self :: verifyString ( $ chain ) ; return lcfirst ( preg_replace ( '/ /' , '' , ucwords ( preg_replace ( '/[-]/' , ' ' , $ chain ) ) ) ) ; }
Converts chain - case to camelCase .
881
public function has_required_properties ( ) { return ( ! empty ( $ this -> plural_name ) && ! empty ( $ this -> post_type ) && ! empty ( $ this -> singular_name ) && ! empty ( $ this -> slug ) ) ; }
Determines if required properties are populated or not .
882
public function enumerateLinks ( $ alcontinue = false , $ alfrom = null , $ alto = null , $ alprefix = null , $ alunique = null , array $ alprop = null , $ alnamespace = null , $ allimit = null ) { $ path = '?action=query&meta=siteinfo' ; if ( $ alcontinue ) { $ path .= '&alcontinue=' ; } if ( isset ( $ alfrom ) ) { $ ...
Method to enumerate all links that point to a given namespace .
883
public function saveMultiple ( array $ objects ) { array_walk ( $ objects , [ $ this , 'assertObjectInstance' ] ) ; return $ this -> manager -> getDriver ( ) -> inTransaction ( function ( Driver $ driver , array $ objects ) { return array_map ( [ $ this , 'save' ] , $ objects ) ; } , $ objects ) ; }
Save multiple objects into database
884
public function save ( $ object ) { $ this -> assertObjectInstance ( $ object ) ; $ state = $ this -> getState ( $ object ) ; if ( $ state -> isReadOnly ( ) ) { return null ; } $ relationsIterator = new \ ArrayIterator ( $ this -> getRelations ( ) ) ; $ modifiedManyManyRelations = $ this -> handleManyManyRelations ( $ ...
Save an object to the database
885
static function init ( ) { elgg_register_event_handler ( 'pagesetup' , 'system' , array ( __CLASS__ , 'pagesetup' ) ) ; elgg_register_plugin_hook_handler ( 'register' , "menu:admin_control_panel" , array ( __CLASS__ , 'handlerAdminButtonsMenuRegister' ) ) ; elgg_register_action ( 'backup/db/save' , elgg_get_config ( 'p...
Fired on system init
886
static function pagesetup ( ) { $ parent_id = 'administer_utilities' ; $ section = 'administer' ; if ( $ parent_id && ! elgg_is_menu_item_registered ( 'page' , $ parent_id ) ) { elgg_register_admin_menu_item ( $ section , $ parent_id ) ; } elgg_register_menu_item ( 'page' , array ( 'name' => 'backup/database' , 'href' ...
Fired on system pagesetup
887
static function handlerAdminButtonsMenuRegister ( $ hook , $ type , $ menu , $ params ) { elgg_trigger_plugin_hook ( 'register' , "menu:$menu_name" , $ vars , $ menu ) ; $ menu [ ] = ElggMenuItem :: factory ( array ( 'name' => 'backup/db/save' , 'href' => elgg_add_action_tokens_to_url ( 'action/backup/db/save' ) , 'tex...
Fired on admin_control_panel menu registration
888
static function execSystemCommand ( $ cmd , & $ return_code ) { if ( ! function_exists ( 'proc_open' ) || ! function_exists ( 'proc_close' ) ) { throw new RuntimeException ( "Process execution functions are missing!" ) ; } $ proc = proc_open ( $ cmd , array ( 0 => array ( 'pipe' , 'r' ) , 1 => array ( 'pipe' , 'w' ) , ...
Executes system command when possible
889
public static function registerSettingsGroup ( $ groupName , $ options ) { foreach ( $ options as $ section ) { add_settings_section ( $ section [ 'id' ] , $ section [ 'title' ] , $ section [ 'callback' ] , $ section [ 'page' ] ) ; foreach ( $ section [ 'fields' ] as $ field ) { register_setting ( $ groupName , $ field...
Scaffolds settings group sections and fields
890
private static function generateBytes ( $ length ) { $ bytes = '' ; for ( $ i = 1 ; $ i <= $ length ; $ i ++ ) { $ bytes = \ chr ( \ mt_rand ( 0 , 255 ) ) . $ bytes ; } return $ bytes ; }
Generates random bytes for use in version 4 UUIDs
891
protected function saveXML ( & $ data ) { $ this -> validateParameters ( ) ; $ xmldoc = new \ DOMDocument ( "1.0" , "UTF-8" ) ; $ xmldoc -> formatOutput = true ; $ root = $ xmldoc -> createElement ( "array" ) ; $ root = $ xmldoc -> appendChild ( $ root ) ; array_to_dom ( $ root , $ data ) ; $ xml = $ xmldoc -> saveXML ...
This is internal auxiliary function for converting the settings to XML and storing it to the target file defined by the iniailization .
892
protected function loadXML ( & $ data ) { $ this -> validateParameters ( ) ; if ( ! file_exists ( $ this -> save_path ) && empty ( $ this -> config_file_must_exist ) ) { return true ; } if ( ! file_exists ( $ this -> save_path ) || ! is_readable ( $ this -> save_path ) ) { throw new \ Exception ( sprintf ( "The config ...
This is internal auxiliary function for loading the settings from the target file defined by the iniailization .
893
public function setParameter ( $ name , $ value ) { $ this -> temp_settings [ $ name ] = $ value ; $ this -> temp_settings [ "__dirty" ] [ $ this -> context ] = true ; }
Sets a settings parameter .
894
public function getParameter ( $ name , $ get_dirty = false , $ default = null ) { if ( $ get_dirty && $ this -> isDirty ( ) ) { if ( empty ( $ this -> temp_settings [ $ name ] ) ) { return null ; } return $ this -> temp_settings [ $ name ] ; } if ( ! isset ( $ this -> settings [ $ name ] ) ) { return $ default ; } ret...
Returns the value of a settings parameter .
895
public function validateSettings ( ) { if ( empty ( $ this -> validator ) ) { return true ; } return $ this -> validator -> validate ( $ this , $ this -> context ) ; }
Validates the current settings values .
896
public function loadSettings ( ) { if ( $ this -> isDirty ( true ) ) { return true ; } $ this -> loadXML ( $ this -> settings ) ; $ this -> temp_settings = $ this -> settings ; unset ( $ this -> temp_settings [ "__dirty" ] ) ; return true ; }
Loads the settings from the target file .
897
public function saveSettings ( ) { $ old_dirty_state = $ this -> temp_settings [ "__dirty" ] ; unset ( $ this -> temp_settings [ "__dirty" ] ) ; try { $ this -> saveXML ( $ this -> temp_settings ) ; $ this -> settings = $ this -> temp_settings ; return true ; } catch ( \ Exception $ ex ) { $ this -> temp_settings [ "__...
Saves the settings from to the target file .
898
public function addManyToSet ( array $ values ) { $ this -> requiresCurrentField ( ) ; $ this -> newObj [ '$addToSet' ] [ $ this -> currentField ] = array ( '$each' => $ values ) ; return $ this ; }
Append multiple values to the current array field only if they do not already exist in the array .
899
public function push ( $ valueOrExpression ) { if ( $ valueOrExpression instanceof Expr ) { $ valueOrExpression = array_merge ( array ( '$each' => array ( ) ) , $ valueOrExpression -> getQuery ( ) ) ; } $ this -> requiresCurrentField ( ) ; $ this -> newObj [ '$push' ] [ $ this -> currentField ] = $ valueOrExpression ; ...
Append one or more values to the current array field .