idx
int64
0
60.3k
question
stringlengths
64
4.24k
target
stringlengths
5
618
32,300
public function validate ( $ path , array $ mimeTypes = [ ] ) { if ( empty ( $ mimeTypes ) ) { $ mimeTypes = $ this -> mimeTypes ; } return in_array ( self :: getType ( $ path ) , $ mimeTypes ) ; }
validate mime type file
32,301
private static function init ( ) { static :: $ manager = new MountManager ( self :: $ filesystems ) ; $ local = new CachedAdapter ( new Local ( "/" , LOCK_EX , Local :: SKIP_LINKS ) , new CacheStore ( ) ) ; self :: addAdapter ( "local" , $ local ) ; self :: addAdapter ( "file" , $ local ) ; self :: $ manager -> addPlugin ( new ListPaths ( ) ) ; }
init default filesystems
32,302
public static function addAdapter ( string $ name , AdapterInterface $ adapter ) { $ adapter = new Filesystem ( $ adapter ) ; if ( static :: $ manager == NULL && empty ( self :: $ filesystems ) ) { self :: init ( ) ; } self :: $ filesystems [ $ name ] = $ adapter ; static :: $ manager -> mountFilesystem ( $ name , $ adapter ) ; }
add an adapter
32,303
public function deleted ( MemberInvitation $ invitation ) { $ member = Member :: findOrFail ( $ invitation -> member_id ) ; $ member -> forceDelete ( ) ; }
Listen to the MemberInvitation delete event .
32,304
public function setContent ( $ content , $ type = 'text' ) { $ type = ( string ) $ type ; $ this -> setType ( $ type ) ; $ document = $ this -> getDomElement ( ) -> ownerDocument ; if ( 'text' === $ type || 'html' === $ type ) { $ this -> getDomElement ( ) -> nodeValue = ( string ) $ content ; } elseif ( 'xhtml' === $ type ) { if ( ! $ content instanceof \ DOMElement ) { throw new \ InvalidArgumentException ( 'Content should be an instance of DOMElement' ) ; } Xhtml :: import ( $ content , $ this -> getDomElement ( ) ) ; } elseif ( $ this -> isXmlMimeType ( $ type ) ) { if ( ! $ content instanceof \ DOMElement ) { throw new \ InvalidArgumentException ( 'Content should be an instance of DOMElement' ) ; } $ this -> getDomElement ( ) -> appendChild ( $ document -> importNode ( $ content , true ) ) ; } elseif ( stripos ( $ type , 'text/' ) === 0 ) { $ this -> getDomElement ( ) -> nodeValue = ( string ) $ content ; } else { $ this -> getDomElement ( ) -> nodeValue = base64_encode ( $ content ) ; } $ this -> setCachedProperty ( 'content' , $ content ) ; }
Set new content .
32,305
public function buildCode ( ) { $ library = $ this -> getLibrary ( ) ; $ alias = $ this -> getAlias ( ) ; if ( empty ( $ alias ) ) { $ alias = $ library ; } return '#Include "' . $ library . '" as ' . $ alias . PHP_EOL ; }
Builds the directive .
32,306
protected function _newId ( MW_DB_Connection_Interface $ conn , $ sql ) { $ result = $ conn -> create ( $ sql ) -> execute ( ) ; if ( ( $ row = $ result -> fetch ( MW_DB_Result_Abstract :: FETCH_NUM ) ) === false ) { throw new MShop_Exception ( sprintf ( 'ID of last inserted database record not available' ) ) ; } $ result -> finish ( ) ; return $ row [ 0 ] ; }
Returns the newly created ID for the last record which was inserted .
32,307
protected function _getCachedStatement ( MW_DB_Connection_Interface $ conn , $ key , $ sql = null ) { if ( ! isset ( $ this -> _stmts [ 'stmt' ] [ $ key ] ) || ! isset ( $ this -> _stmts [ 'conn' ] [ $ key ] ) || $ conn !== $ this -> _stmts [ 'conn' ] [ $ key ] ) { if ( $ sql === null ) { $ sql = $ this -> _context -> getConfig ( ) -> get ( $ key , $ key ) ; } $ this -> _stmts [ 'stmt' ] [ $ key ] = $ conn -> create ( $ sql ) ; $ this -> _stmts [ 'conn' ] [ $ key ] = $ conn ; } return $ this -> _stmts [ 'stmt' ] [ $ key ] ; }
Returns the cached statement for the given key or creates a new prepared statement . If no SQL string is given the key is used to retrieve the SQL string from the configuration .
32,308
private function _getSiteIds ( $ sitelevel ) { $ locale = $ this -> _context -> getLocale ( ) ; $ siteIds = array ( $ locale -> getSiteId ( ) ) ; if ( $ sitelevel & MShop_Locale_Manager_Abstract :: SITE_PATH ) { $ siteIds = array_merge ( $ siteIds , $ locale -> getSitePath ( ) ) ; } if ( $ sitelevel & MShop_Locale_Manager_Abstract :: SITE_SUBTREE ) { $ siteIds = array_merge ( $ siteIds , $ locale -> getSiteSubTree ( ) ) ; } $ siteIds = array_unique ( $ siteIds ) ; return $ siteIds ; }
Returns the site IDs for the given site level constant .
32,309
protected function _getSubManager ( $ domain , $ manager , $ name ) { $ domain = strtolower ( $ domain ) ; $ manager = strtolower ( $ manager ) ; $ key = $ domain . $ manager . $ name ; if ( ! isset ( $ this -> _subManagers [ $ key ] ) ) { if ( empty ( $ domain ) || ctype_alnum ( $ domain ) === false ) { throw new MShop_Exception ( sprintf ( 'Invalid characters in domain name "%1$s"' , $ domain ) ) ; } if ( preg_match ( '/^[a-z0-9\/]+$/' , $ manager ) !== 1 ) { throw new MShop_Exception ( sprintf ( 'Invalid characters in manager name "%1$s"' , $ manager ) ) ; } if ( $ name === null ) { $ path = 'classes/' . $ domain . '/manager/' . $ manager . '/name' ; $ name = $ this -> _context -> getConfig ( ) -> get ( $ path , 'Default' ) ; } if ( empty ( $ name ) || ctype_alnum ( $ name ) === false ) { throw new MShop_Exception ( sprintf ( 'Invalid characters in manager name "%1$s"' , $ name ) ) ; } $ domainname = ucfirst ( $ domain ) ; $ subnames = $ this -> _createSubNames ( $ manager ) ; $ classname = 'MShop_' . $ domainname . '_Manager_' . $ subnames . '_' . $ name ; $ interface = 'MShop_' . $ domainname . '_Manager_' . $ subnames . '_Interface' ; if ( class_exists ( $ classname ) === false ) { throw new MShop_Exception ( sprintf ( 'Class "%1$s" not available' , $ classname ) ) ; } $ subManager = new $ classname ( $ this -> _context ) ; if ( ( $ subManager instanceof $ interface ) === false ) { throw new MShop_Exception ( sprintf ( 'Class "%1$s" does not implement interface "%2$s"' , $ classname , $ interface ) ) ; } $ this -> _subManagers [ $ key ] = $ this -> _addManagerDecorators ( $ subManager , $ manager , $ domain ) ; } return $ this -> _subManagers [ $ key ] ; }
Returns a new manager the given extension name .
32,310
private function _getCriteriaKeys ( array $ prefix , MW_Common_Criteria_Expression_Interface $ expr = null ) { if ( $ expr === null ) { return array ( ) ; } $ result = array ( ) ; foreach ( $ this -> _getCriteriaNames ( $ expr ) as $ item ) { if ( ( $ pos = strpos ( $ item , '(' ) ) !== false ) { $ item = substr ( $ item , 0 , $ pos ) ; } if ( ( $ pos = strpos ( $ item , ':' ) ) !== false ) { $ item = substr ( $ item , $ pos + 1 ) ; } $ result = array_merge ( $ result , $ this -> _cutNameTail ( $ prefix , $ item ) ) ; } return $ result ; }
Returns a list of unique criteria names shortend by the last element after the
32,311
private function _getCriteriaKeyList ( MW_Common_Criteria_Interface $ criteria , array $ required ) { $ keys = array_merge ( $ required , $ this -> _getCriteriaKeys ( $ required , $ criteria -> getConditions ( ) ) ) ; foreach ( $ criteria -> getSortations ( ) as $ sortation ) { $ keys = array_merge ( $ keys , $ this -> _getCriteriaKeys ( $ required , $ sortation ) ) ; } $ keys = array_unique ( array_merge ( $ required , $ keys ) ) ; sort ( $ keys ) ; return $ keys ; }
Returns a sorted list of required criteria keys .
32,312
private function _cutNameTail ( array $ prefix , $ string ) { $ result = array ( ) ; $ noprefix = true ; $ strlen = strlen ( $ string ) ; $ sep = $ this -> _getKeySeparator ( ) ; foreach ( $ prefix as $ key ) { $ len = strlen ( $ key ) ; if ( strncmp ( $ string , $ key , $ len ) === 0 ) { if ( $ strlen > $ len && ( $ pos = strrpos ( $ string , $ sep ) ) !== false ) { $ result [ ] = $ string = substr ( $ string , 0 , $ pos ) ; $ result = array_merge ( $ result , $ this -> _cutNameTail ( $ prefix , $ string ) ) ; } $ noprefix = false ; break ; } } if ( $ noprefix ) { if ( ( $ pos = strrpos ( $ string , $ sep ) ) !== false ) { $ result [ ] = substr ( $ string , 0 , $ pos ) ; } else { $ result [ ] = $ string ; } } return $ result ; }
Cuts the last part separated by a dot repeatedly and returns the list of resulting string .
32,313
protected function _addManagerDecorators ( MShop_Common_Manager_Interface $ manager , $ managerpath , $ domain ) { $ config = $ this -> _context -> getConfig ( ) ; $ decorators = $ config -> get ( 'mshop/common/manager/decorators/default' , array ( ) ) ; $ excludes = $ config -> get ( 'mshop/' . $ domain . '/manager/' . $ managerpath . '/decorators/excludes' , array ( ) ) ; foreach ( $ decorators as $ key => $ name ) { if ( in_array ( $ name , $ excludes ) ) { unset ( $ decorators [ $ key ] ) ; } } $ classprefix = 'MShop_Common_Manager_Decorator_' ; $ manager = $ this -> _addDecorators ( $ this -> _context , $ manager , $ decorators , $ classprefix ) ; $ classprefix = 'MShop_Common_Manager_Decorator_' ; $ decorators = $ config -> get ( 'mshop/' . $ domain . '/manager/' . $ managerpath . '/decorators/global' , array ( ) ) ; $ manager = $ this -> _addDecorators ( $ this -> _context , $ manager , $ decorators , $ classprefix ) ; $ subpath = $ this -> _createSubNames ( $ managerpath ) ; $ classprefix = 'MShop_' . ucfirst ( $ domain ) . '_Manager_' . $ subpath . '_Decorator_' ; $ decorators = $ config -> get ( 'mshop/' . $ domain . '/manager/' . $ managerpath . '/decorators/local' , array ( ) ) ; return $ this -> _addDecorators ( $ this -> _context , $ manager , $ decorators , $ classprefix ) ; }
Adds the configured decorators to the given manager object .
32,314
protected function _createSubNames ( $ manager ) { $ names = explode ( '/' , $ manager ) ; foreach ( $ names as $ key => $ subname ) { if ( empty ( $ subname ) || ctype_alnum ( $ subname ) === false ) { throw new MShop_Exception ( sprintf ( 'Invalid characters in manager name "%1$s"' , $ manager ) ) ; } $ names [ $ key ] = ucfirst ( $ subname ) ; } return implode ( '_' , $ names ) ; }
Transforms the manager path to the appropriate class names .
32,315
private function _getCriteriaNames ( MW_Common_Criteria_Expression_Interface $ expr ) { if ( $ expr instanceof MW_Common_Criteria_Expression_Compare_Interface ) { return array ( $ expr -> getName ( ) ) ; } if ( $ expr instanceof MW_Common_Criteria_Expression_Combine_Interface ) { $ list = array ( ) ; foreach ( $ expr -> getExpressions ( ) as $ item ) { $ list = array_merge ( $ list , $ this -> _getCriteriaNames ( $ item ) ) ; } return $ list ; } if ( $ expr instanceof MW_Common_Criteria_Expression_Sort_Interface ) { return array ( $ expr -> getName ( ) ) ; } return array ( ) ; }
Returns a list of criteria names from a expression and its sub - expressions .
32,316
protected function _getItem ( $ key , $ id , array $ ref = array ( ) ) { $ criteria = $ this -> createSearch ( ) ; $ criteria -> setConditions ( $ criteria -> compare ( '==' , $ key , $ id ) ) ; $ items = $ this -> searchItems ( $ criteria , $ ref ) ; if ( ( $ item = reset ( $ items ) ) === false ) { throw new MShop_Exception ( sprintf ( 'Item with ID "%2$s" in "%1$s" not found' , $ key , $ id ) ) ; } return $ item ; }
Returns the item for the given search key and ID .
32,317
private function _getJoins ( array $ attributes , $ prefix ) { $ iface = 'MW_Common_Criteria_Attribute_Interface' ; $ sep = $ this -> _getKeySeparator ( ) ; $ name = $ prefix . $ sep . 'id' ; if ( isset ( $ attributes [ $ name ] ) && $ attributes [ $ name ] instanceof $ iface ) { return $ attributes [ $ name ] -> getInternalDeps ( ) ; } else if ( isset ( $ attributes [ 'id' ] ) && $ attributes [ 'id' ] instanceof $ iface ) { return $ attributes [ 'id' ] -> getInternalDeps ( ) ; } return array ( ) ; }
Returns the SQL strings for joining dependent tables .
32,318
protected function _getResourceName ( ) { if ( $ this -> _resourceName === null ) { $ this -> _resourceName = $ this -> _context -> getConfig ( ) -> get ( 'resource/default' , 'db' ) ; } return $ this -> _resourceName ; }
Returns the name of the resource or of the default resource .
32,319
protected function _setResourceName ( $ name ) { $ config = $ this -> _context -> getConfig ( ) ; if ( $ config -> get ( 'resource/' . $ name ) === null ) { $ this -> _resourceName = $ config -> get ( 'resource/default' , 'db' ) ; } else { $ this -> _resourceName = $ name ; } }
Sets the name of the database resource that should be used .
32,320
protected function _deleteItems ( array $ ids , $ sql , $ siteidcheck = true , $ name = 'id' ) { if ( empty ( $ ids ) ) { return ; } $ context = $ this -> _getContext ( ) ; $ dbname = $ this -> _getResourceName ( ) ; $ search = $ this -> createSearch ( ) ; $ search -> setConditions ( $ search -> compare ( '==' , $ name , $ ids ) ) ; $ types = array ( $ name => MW_DB_Statement_Abstract :: PARAM_STR ) ; $ translations = array ( $ name => '"' . $ name . '"' ) ; $ cond = $ search -> getConditionString ( $ types , $ translations ) ; $ sql = str_replace ( ':cond' , $ cond , $ sql ) ; $ dbm = $ context -> getDatabaseManager ( ) ; $ conn = $ dbm -> acquire ( $ dbname ) ; try { $ stmt = $ conn -> create ( $ sql ) ; if ( $ siteidcheck ) { $ stmt -> bind ( 1 , $ context -> getLocale ( ) -> getSiteId ( ) , MW_DB_Statement_Abstract :: PARAM_INT ) ; } $ stmt -> execute ( ) -> finish ( ) ; $ dbm -> release ( $ conn , $ dbname ) ; } catch ( Exception $ e ) { $ dbm -> release ( $ conn , $ dbname ) ; throw $ e ; } }
Deletes items specified by its IDs .
32,321
protected function _begin ( $ dbname = 'db' ) { $ dbm = $ this -> _context -> getDatabaseManager ( ) ; $ conn = $ dbm -> acquire ( $ dbname ) ; $ conn -> begin ( ) ; $ dbm -> release ( $ conn , $ dbname ) ; }
Starts a database transaction on the connection identified by the given name .
32,322
protected function _commit ( $ dbname = 'db' ) { $ dbm = $ this -> _context -> getDatabaseManager ( ) ; $ conn = $ dbm -> acquire ( $ dbname ) ; $ conn -> commit ( ) ; $ dbm -> release ( $ conn , $ dbname ) ; }
Commits the running database transaction on the connection identified by the given name .
32,323
protected function _rollback ( $ dbname = 'db' ) { $ dbm = $ this -> _context -> getDatabaseManager ( ) ; $ conn = $ dbm -> acquire ( $ dbname ) ; $ conn -> rollback ( ) ; $ dbm -> release ( $ conn , $ dbname ) ; }
Rolls back the running database transaction on the connection identified by the given name .
32,324
protected function _process ( ) { $ this -> _msg ( 'Processing catalog demo data' , 0 ) ; $ item = null ; $ context = $ this -> _getContext ( ) ; $ manager = MShop_Factory :: createManager ( $ context , 'catalog' ) ; try { $ item = $ manager -> getTree ( null , array ( ) , MW_Tree_Manager_Abstract :: LEVEL_ONE ) ; $ this -> _removeItems ( $ item -> getId ( ) , 'catalog/list' , 'catalog' , 'media' ) ; $ this -> _removeItems ( $ item -> getId ( ) , 'catalog/list' , 'catalog' , 'text' ) ; $ this -> _removeListItems ( $ item -> getId ( ) , 'catalog/list' , 'product' ) ; } catch ( Exception $ e ) { ; } if ( $ context -> getConfig ( ) -> get ( 'setup/default/demo' , false ) == true ) { $ ds = DIRECTORY_SEPARATOR ; $ path = __DIR__ . $ ds . 'data' . $ ds . 'demo-catalog.php' ; if ( ( $ data = include ( $ path ) ) == false ) { throw new MShop_Exception ( sprintf ( 'No file "%1$s" found for catalog domain' , $ path ) ) ; } if ( $ item === null ) { $ item = $ manager -> createItem ( ) ; $ item -> setCode ( $ data [ 'code' ] ) ; $ item -> setLabel ( $ data [ 'label' ] ) ; $ item -> setConfig ( $ data [ 'config' ] ) ; $ item -> setStatus ( $ data [ 'status' ] ) ; $ manager -> insertItem ( $ item ) ; } if ( isset ( $ data [ 'media' ] ) ) { $ this -> _addMedia ( $ item -> getId ( ) , $ data [ 'media' ] , 'catalog' ) ; } if ( isset ( $ data [ 'product' ] ) ) { $ this -> _addProducts ( $ item -> getId ( ) , $ data [ 'product' ] , 'catalog' ) ; } if ( isset ( $ data [ 'text' ] ) ) { $ this -> _addTexts ( $ item -> getId ( ) , $ data [ 'text' ] , 'catalog' ) ; } $ this -> _status ( 'added' ) ; } else { $ this -> _status ( 'removed' ) ; } }
Insert catalog nodes and relations .
32,325
function explodeSkusByWildcard ( $ skus ) { $ return = array ( ) ; foreach ( $ skus as $ sku ) { $ sku = str_replace ( '*' , '%' , $ sku ) ; $ result = $ this -> getReadAdapter ( ) -> select ( ) -> from ( $ this -> getProductTable ( ) ) -> where ( $ this -> getProductSkuField ( ) . ' LIKE ?' , $ sku ) -> query ( ) ; foreach ( $ result -> fetchAll ( ) as $ matchedSku ) { array_push ( $ return , $ matchedSku [ $ this -> getProductSkuField ( ) ] ) ; } } return $ return ; }
Inputs an array of SKUs derives all possible SKUs with wildcards
32,326
public static function map ( CommandInterface $ command ) { $ mapper = new static ( ) ; $ mapper -> setCommand ( $ command ) ; if ( $ mapper -> save ( ) === false ) { throw new YiiException ( 'Unable to save an instance of \jlorente\command\db\CommandMapper. Errors: [' . Json :: encode ( $ mapper -> getErrors ( ) ) . ']' ) ; } }
Stores a CommandInterface object in the database .
32,327
public function addRecordStartedEvent ( JoinPointInterface $ joinPoint ) { $ data = $ joinPoint -> getMethodArgument ( 'data' ) ; $ externalIdentifier = Arrays :: getValueByPath ( $ data , '__externalIdentifier' ) ; $ title = Arrays :: getValueByPath ( $ data , '__label' ) ; $ importer = $ joinPoint -> getProxy ( ) ; list ( $ importerClassName ) = $ this -> getImporterClassNames ( $ importer ) ; $ data [ '__message' ] = sprintf ( '%s: "%s" (%s)' , $ importerClassName , $ title ? : '-- No label --' , $ externalIdentifier ) ; $ event = $ importer -> getImportService ( ) -> addEvent ( sprintf ( '%s:Record:Started' , $ importerClassName ) , $ externalIdentifier , $ data ) ; $ importer -> setCurrentEvent ( $ event ) ; }
Add record started event
32,328
protected function getImporterClassNames ( ImporterInterface $ importer ) { $ importerClassName = get_class ( $ importer ) ; $ importerClassName = substr ( $ importerClassName , strrpos ( $ importerClassName , '\\' ) + 1 ) ; $ dataProvider = $ importer -> getDataProvider ( ) ; $ dataProviderClassName = get_class ( $ dataProvider ) ; $ dataProviderClassName = substr ( $ dataProviderClassName , strrpos ( $ dataProviderClassName , '\\' ) + 1 ) ; return [ $ importerClassName , $ dataProviderClassName ] ; }
Get the Importer and DataProvider class name
32,329
static public function clear ( $ id = null , $ path = null ) { if ( $ id !== null ) { if ( $ path !== null ) { self :: $ _controllers [ $ id ] [ $ path ] = null ; } else { self :: $ _controllers [ $ id ] = array ( ) ; } return ; } self :: $ _controllers = array ( ) ; }
Removes all controller objects from the cache .
32,330
public function controlMiraklSettings ( $ docTypes ) { $ documentDto = $ this -> getDocumentTypesDto ( ) ; $ countDocHiPay = count ( $ docTypes ) ; $ cpt = 0 ; $ cptLegal = 3 ; $ cptSoleMan = 3 ; foreach ( $ documentDto as $ document ) { $ pattern1 = '/^LEGAL_/' ; $ pattern2 = '/^SOLE_MAN_/' ; if ( preg_match ( $ pattern1 , $ document [ 'code' ] ) ) { $ cptLegal -- ; } if ( preg_match ( $ pattern2 , $ document [ 'code' ] ) ) { $ cptSoleMan -- ; } if ( array_key_exists ( $ document [ 'code' ] , $ docTypes ) ) { $ cpt ++ ; } } if ( $ cptLegal < 0 ) { $ cptLegal = 0 ; } if ( $ cptSoleMan < 0 ) { $ cptSoleMan = 0 ; } $ cpt = $ cpt - ( $ cptLegal + $ cptSoleMan ) ; $ countDocHiPay = $ countDocHiPay - ( $ cptLegal + $ cptSoleMan ) ; if ( $ countDocHiPay == $ cpt ) { $ bool = true ; } else { $ bool = false ; } return $ bool ; }
Control if the mirakl settings is ok with the HiPay Prerequisites
32,331
protected function _addMetaList ( $ ids , $ domain , & $ expire ) { $ manager = MShop_Factory :: createManager ( $ this -> _getContext ( ) , $ domain . '/list' ) ; $ search = $ manager -> createSearch ( ) ; $ expr = array ( $ search -> compare ( '==' , $ domain . '.list.parentid' , $ ids ) , $ search -> compare ( '>' , $ domain . '.list.datestart' , date ( 'Y-m-d H:i:00' ) ) , ) ; $ search -> setConditions ( $ search -> combine ( '&&' , $ expr ) ) ; $ search -> setSortations ( array ( $ search -> sort ( '+' , $ domain . '.list.datestart' ) ) ) ; $ search -> setSlice ( 0 , 1 ) ; foreach ( $ manager -> searchItems ( $ search ) as $ listItem ) { $ expire = $ this -> _expires ( $ expire , $ listItem -> getDateStart ( ) ) ; } }
Adds a new expiration date if a list item is activated in the future .
32,332
protected function _createSubNames ( $ client ) { $ names = explode ( '/' , $ client ) ; foreach ( $ names as $ key => $ subname ) { if ( empty ( $ subname ) || ctype_alnum ( $ subname ) === false ) { throw new Client_Html_Exception ( sprintf ( 'Invalid characters in client name "%1$s"' , $ client ) ) ; } $ names [ $ key ] = ucfirst ( $ subname ) ; } return implode ( '_' , $ names ) ; }
Transforms the client path to the appropriate class names .
32,333
protected function _getTemplate ( $ confpath , $ default ) { $ ds = DIRECTORY_SEPARATOR ; foreach ( ( array ) $ default as $ fname ) { $ file = $ this -> _context -> getConfig ( ) -> get ( $ confpath , $ fname ) ; foreach ( array_reverse ( $ this -> _templatePaths ) as $ path => $ relPaths ) { foreach ( $ relPaths as $ relPath ) { $ absPath = $ path . $ ds . $ relPath . $ ds . $ file ; if ( $ ds !== '/' ) { $ absPath = str_replace ( '/' , $ ds , $ absPath ) ; } if ( is_file ( $ absPath ) ) { return $ absPath ; } } } } throw new Client_Html_Exception ( sprintf ( 'Template "%1$s" not available' , $ file ) ) ; }
Returns the absolute path to the given template file . It uses the first one found from the configured paths in the manifest files but in reverse order .
32,334
protected function _isCachable ( $ what , $ confpath , array $ default ) { foreach ( $ this -> _getSubClients ( $ confpath , $ default ) as $ subclient ) { if ( $ subclient -> isCachable ( $ what ) === false ) { return false ; } } return true ; }
Tests if the output of the sub - clients is cachable .
32,335
public function addCheckbox ( ) : Checkbox { $ checkbox = new Checkbox ( $ this -> form , $ this -> name . '[]' ) ; $ this -> checkboxes [ ] = $ checkbox ; return $ checkbox ; }
Adds a checkbox to this group and returns it .
32,336
public function append ( $ string ) { $ encoding = $ this -> str -> getEncoding ( ) ; if ( $ string instanceof Str ) { if ( $ string -> getEncoding ( ) !== $ encoding ) { throw new MisMatchedEncodingException ( ) ; } $ toBeAppended = $ string ; } else { $ toBeAppended = new Str ( $ string , $ encoding ) ; } $ this -> str = new Str ( $ this -> str . $ toBeAppended , $ encoding ) ; return $ this ; }
Appends a copy of the specified string to this instance .
32,337
public function insert ( $ index , $ string ) { $ this -> str = $ this -> str -> insert ( ( string ) $ string , $ index ) ; return $ this ; }
Inserts a string into this instance at the specified character position .
32,338
public function remove ( $ startIndex , $ length ) { $ start = UTF8 :: substr ( ( string ) $ this -> str , 0 , $ startIndex , $ this -> str -> getEncoding ( ) ) ; $ end = UTF8 :: substr ( ( string ) $ this -> str , $ startIndex + $ length , $ this -> str -> getLength ( ) , $ this -> str -> getEncoding ( ) ) ; $ this -> str = new Str ( $ start . $ end ) ; return $ this ; }
Removes the specified range of characters from this instance .
32,339
function _save_dir ( $ dir ) { $ dirs = explode ( '/' , preg_replace ( '#^/|/(?=/)|/$#' , '' , $ dir ) ) ; $ temp = & $ this -> dirs ; foreach ( $ dirs as $ dir ) { if ( ! isset ( $ temp [ $ dir ] ) ) { $ temp [ $ dir ] = array ( ) ; } $ temp = & $ temp [ $ dir ] ; } }
Save directories to cache
32,340
function _remove_dir ( $ dir ) { $ dirs = explode ( '/' , preg_replace ( '#^/|/(?=/)|/$#' , '' , $ dir ) ) ; $ temp = & $ this -> dirs ; foreach ( $ dirs as $ dir ) { if ( $ dir == end ( $ dirs ) ) { unset ( $ temp [ $ dir ] ) ; return true ; } if ( ! isset ( $ temp [ $ dir ] ) ) { return false ; } $ temp = & $ temp [ $ dir ] ; } }
Remove directories from cache
32,341
function _is_dir ( $ dir ) { $ dirs = explode ( '/' , preg_replace ( '#^/|/(?=/)|/$#' , '' , $ dir ) ) ; $ temp = & $ this -> dirs ; foreach ( $ dirs as $ dir ) { if ( ! isset ( $ temp [ $ dir ] ) ) { return false ; } $ temp = & $ temp [ $ dir ] ; } }
Checks cache for directory
32,342
function _chmod_recursive ( $ mode , $ path , & $ i ) { if ( ! $ this -> _read_put_responses ( $ i ) ) { return false ; } $ i = 0 ; $ entries = $ this -> _list ( $ path , true , false ) ; if ( $ entries === false ) { return $ this -> chmod ( $ mode , $ path ) ; } if ( empty ( $ entries ) ) { return false ; } foreach ( $ entries as $ filename => $ props ) { if ( $ filename == '.' || $ filename == '..' ) { continue ; } if ( ! isset ( $ props [ 'type' ] ) ) { return false ; } $ temp = $ path . '/' . $ filename ; if ( $ props [ 'type' ] == NET_SFTP_TYPE_DIRECTORY ) { if ( ! $ this -> _chmod_recursive ( $ mode , $ temp , $ i ) ) { return false ; } } else { $ attr = pack ( 'N2' , NET_SFTP_ATTR_PERMISSIONS , $ mode & 07777 ) ; if ( ! $ this -> _send_sftp_packet ( NET_SFTP_SETSTAT , pack ( 'Na*a*' , strlen ( $ temp ) , $ temp , $ attr ) ) ) { return false ; } $ i ++ ; if ( $ i >= 50 ) { if ( ! $ this -> _read_put_responses ( $ i ) ) { return false ; } $ i = 0 ; } } } $ attr = pack ( 'N2' , NET_SFTP_ATTR_PERMISSIONS , $ mode & 07777 ) ; if ( ! $ this -> _send_sftp_packet ( NET_SFTP_SETSTAT , pack ( 'Na*a*' , strlen ( $ path ) , $ path , $ attr ) ) ) { return false ; } $ i ++ ; if ( $ i >= 50 ) { if ( ! $ this -> _read_put_responses ( $ i ) ) { return false ; } $ i = 0 ; } return true ; }
Recursively chmods directories on the SFTP server
32,343
function _mkdir_helper ( $ dir ) { if ( ! $ this -> _send_sftp_packet ( NET_SFTP_MKDIR , pack ( 'Na*N' , strlen ( $ dir ) , $ dir , 0 ) ) ) { return false ; } $ response = $ this -> _get_sftp_packet ( ) ; if ( $ this -> packet_type != NET_SFTP_STATUS ) { user_error ( 'Expected SSH_FXP_STATUS' , E_USER_NOTICE ) ; return false ; } extract ( unpack ( 'Nstatus' , $ this -> _string_shift ( $ response , 4 ) ) ) ; if ( $ status != NET_SFTP_STATUS_OK ) { $ this -> _logError ( $ response , $ status ) ; return false ; } $ this -> _save_dir ( $ dir ) ; return true ; }
Helper function for directory creation
32,344
function _read_put_responses ( $ i ) { while ( $ i -- ) { $ response = $ this -> _get_sftp_packet ( ) ; if ( $ this -> packet_type != NET_SFTP_STATUS ) { user_error ( 'Expected SSH_FXP_STATUS' , E_USER_NOTICE ) ; return false ; } extract ( unpack ( 'Nstatus' , $ this -> _string_shift ( $ response , 4 ) ) ) ; if ( $ status != NET_SFTP_STATUS_OK ) { $ this -> _logError ( $ response , $ status ) ; break ; } } return $ i < 0 ; }
Reads multiple successive SSH_FXP_WRITE responses
32,345
protected function _checkCipherKeySize ( CipherAlgorithmIdentifier $ algo , string $ key ) { if ( $ algo instanceof BlockCipherAlgorithmIdentifier ) { if ( strlen ( $ key ) != $ algo -> keySize ( ) ) { throw new \ UnexpectedValueException ( sprintf ( 'Key length for %s must be %d, %d given.' , $ algo -> name ( ) , $ algo -> keySize ( ) , strlen ( $ key ) ) ) ; } } }
Validate cipher algorithm key size .
32,346
protected function _checkSignatureAlgoAndKey ( SignatureAlgorithmIdentifier $ sig_algo , AlgorithmIdentifier $ key_algo ) { if ( ! $ sig_algo -> supportsKeyAlgorithm ( $ key_algo ) ) { throw new \ UnexpectedValueException ( sprintf ( 'Signature algorithm %s does not support key algorithm %s.' , $ sig_algo -> name ( ) , $ key_algo -> name ( ) ) ) ; } }
Check that given signature algorithm supports key of given type .
32,347
protected function _algoToDigest ( SignatureAlgorithmIdentifier $ algo ) : string { $ oid = $ algo -> oid ( ) ; if ( ! array_key_exists ( $ oid , self :: MAP_DIGEST_OID_TO_NAME ) ) { throw new \ UnexpectedValueException ( sprintf ( 'Digest method %s not supported.' , $ algo -> name ( ) ) ) ; } return self :: MAP_DIGEST_OID_TO_NAME [ $ oid ] ; }
Get OpenSSL digest method for given signature algorithm identifier .
32,348
protected function _algoToCipher ( CipherAlgorithmIdentifier $ algo ) : string { $ oid = $ algo -> oid ( ) ; if ( array_key_exists ( $ oid , self :: MAP_CIPHER_OID_TO_NAME ) ) { return self :: MAP_CIPHER_OID_TO_NAME [ $ oid ] ; } if ( AlgorithmIdentifier :: OID_RC2_CBC == $ oid ) { if ( ! $ algo instanceof RC2CBCAlgorithmIdentifier ) { throw new \ UnexpectedValueException ( 'Not an RC2-CBC algorithm.' ) ; } return $ this -> _rc2AlgoToCipher ( $ algo ) ; } throw new \ UnexpectedValueException ( sprintf ( 'Cipher method %s not supported.' , $ algo -> name ( ) ) ) ; }
Get OpenSSL cipher method for given cipher algorithm identifier .
32,349
public function uploadFile ( stdClass $ params ) { $ this -> _checkParams ( $ params , array ( 'site' ) ) ; $ this -> _setLocale ( $ params -> site ) ; if ( ( $ fileinfo = reset ( $ _FILES ) ) === false ) { throw new Controller_ExtJS_Exception ( 'No file was uploaded' ) ; } $ config = $ this -> _getContext ( ) -> getConfig ( ) ; $ dir = $ config -> get ( 'controller/extjs/catalog/import/text/default/uploaddir' , 'uploads' ) ; if ( $ config -> get ( 'controller/extjs/catalog/import/text/default/enablecheck' , true ) ) { $ this -> _checkFileUpload ( $ fileinfo [ 'tmp_name' ] , $ fileinfo [ 'error' ] ) ; } $ fileext = pathinfo ( $ fileinfo [ 'name' ] , PATHINFO_EXTENSION ) ; $ dest = $ dir . DIRECTORY_SEPARATOR . md5 ( $ fileinfo [ 'name' ] . time ( ) . getmypid ( ) ) . '.' . $ fileext ; if ( rename ( $ fileinfo [ 'tmp_name' ] , $ dest ) !== true ) { $ msg = sprintf ( 'Uploaded file could not be moved to upload directory "%1$s"' , $ dir ) ; throw new Controller_ExtJS_Exception ( $ msg ) ; } $ perms = $ config -> get ( 'controller/extjs/catalog/import/text/default/fileperms' , 0660 ) ; if ( chmod ( $ dest , $ perms ) !== true ) { $ msg = sprintf ( 'Could not set permissions "%1$s" for file "%2$s"' , $ perms , $ dest ) ; throw new Controller_ExtJS_Exception ( $ msg ) ; } $ result = ( object ) array ( 'site' => $ params -> site , 'items' => array ( ( object ) array ( 'job.label' => 'Catalog text import: ' . $ fileinfo [ 'name' ] , 'job.method' => 'Catalog_Import_Text.importFile' , 'job.parameter' => array ( 'site' => $ params -> site , 'items' => $ dest , ) , 'job.status' => 1 , ) , ) , ) ; $ jobController = Controller_ExtJS_Admin_Job_Factory :: createController ( $ this -> _getContext ( ) ) ; $ jobController -> saveItems ( $ result ) ; return array ( 'items' => $ dest , 'success' => true , ) ; }
Uploads a CSV file with all catalog texts .
32,350
public function importFile ( stdClass $ params ) { $ this -> _checkParams ( $ params , array ( 'site' , 'items' ) ) ; $ this -> _setLocale ( $ params -> site ) ; $ items = ( ! is_array ( $ params -> items ) ? array ( $ params -> items ) : $ params -> items ) ; foreach ( $ items as $ path ) { $ container = $ this -> _createContainer ( $ path , 'controller/extjs/catalog/import/text/default/container' ) ; $ textTypeMap = array ( ) ; foreach ( $ this -> _getTextTypes ( 'catalog' ) as $ item ) { $ textTypeMap [ $ item -> getCode ( ) ] = $ item -> getId ( ) ; } foreach ( $ container as $ content ) { $ this -> _importTextsFromContent ( $ content , $ textTypeMap , 'catalog' ) ; } unlink ( $ path ) ; } return array ( 'success' => true , ) ; }
Imports a CSV file with all catalog texts .
32,351
protected function gernerate_pdf ( $ html ) { $ dompdf = new Dompdf ( ) ; $ dompdf -> loadHtml ( $ html ) ; $ dompdf -> setPaper ( 'A4' , 'portrait' ) ; $ dompdf -> set_option ( "compressed" , true ) ; $ dompdf -> set_option ( 'defaultFont' , 'sans-serif' ) ; $ dompdf -> set_option ( 'isHtml5ParserEnabled' , true ) ; return $ dompdf ; }
Generate a Dompdf object from the provided html
32,352
public function invoicepdf ( HTTPRequest $ request ) { $ loader = ModuleResourceLoader :: singleton ( ) ; $ style = file_get_contents ( $ loader -> resolvePath ( 'silvercommerce/orders-admin: client/dist/css/pdf.css' ) ) ; Requirements :: clear ( ) ; Requirements :: customCSS ( <<<CSS $styleCSS ) ; $ result = $ this -> invoice ( $ request ) ; $ html = $ result -> getValue ( ) ; $ html = str_replace ( 'src="' . BASE_URL , 'src="' . BASE_PATH , $ html ) ; $ pdf = $ this -> gernerate_pdf ( $ html ) ; $ this -> extend ( "updateInvoicePDF" , $ pdf ) ; $ pdf -> render ( ) ; $ pdf -> stream ( "{$this->object->FullRef}.pdf" ) ; exit ( ) ; }
Generate a PDF based on the invoice html output .
32,353
public static function getStr ( string $ key , ? string $ default = null ) : ? string { $ value = ini_get ( $ key ) ; return $ value === false || $ value === '' ? $ default : $ value ; }
Returns the string value of the given key or the given default if it is empty or does not exist .
32,354
public static function getNumeric ( $ key , $ default = null ) { $ value = ini_get ( $ key ) ; return $ value === false || $ value === '' ? $ default : $ value + 0 ; }
Returns the value of the given key filtered to an int or float .
32,355
public static function getBytes ( $ key , $ default = null ) : ? int { $ value = ini_get ( $ key ) ; if ( $ value === false || $ value === '' ) { return $ default ; } if ( $ value === '-1' ) { return - 1 ; } $ unit = preg_replace ( '/[^bkmgtpezy]/i' , '' , $ value ) ; $ size = preg_replace ( '/[^0-9\.]/' , '' , $ value ) ; return ( ( int ) $ size ) * ( $ unit ? pow ( 1024 , mb_stripos ( 'bkmgtpezy' , $ unit [ 0 ] ) ) : 1 ) ; }
Parses a bytes string representation value of the given key and returns it as an int .
32,356
public static function set ( $ key , $ value ) : void { Assert :: nullOrScalar ( $ value , 'ini values must be scalar or null. Got: %s' ) ; $ iniValue = $ value === false ? '0' : ( string ) $ value ; $ result = false ; $ ex = null ; try { $ result = Thrower :: call ( 'ini_set' , $ key , $ iniValue ) ; } catch ( \ Throwable $ ex ) { } if ( $ result === false || $ ex !== null ) { if ( ! static :: has ( $ key ) ) { throw new \ RuntimeException ( "The ini option '${key}' does not exist. New ini options cannot be added." , 0 , $ ex ) ; } if ( ! static :: $ keys [ $ key ] ) { throw new \ RuntimeException ( "Unable to change ini option '${key}', because it is not editable at runtime." , 0 , $ ex ) ; } $ value = Assert :: valueToString ( $ value ) ; throw new \ RuntimeException ( sprintf ( 'Unable to change ini option "%s" to %s.' , $ key , $ value ) , 0 , $ ex ) ; } if ( ini_get ( $ key ) !== $ iniValue ) { $ value = Assert :: valueToString ( $ value ) ; throw new \ RuntimeException ( sprintf ( 'Unable to change ini option "%s" to %s.' , $ key , $ value ) , 0 , $ ex ) ; } }
Set a new value for the given key .
32,357
private static function readKeys ( ) : void { static :: $ keys = [ ] ; foreach ( ini_get_all ( ) as $ key => $ value ) { static :: $ keys [ $ key ] = $ value [ 'access' ] === 1 || $ value [ 'access' ] === 7 ; } }
Process all ini options to get list of keys and determine which ones are editable .
32,358
public function setTypeId ( $ typeid ) { if ( $ typeid == $ this -> getTypeId ( ) ) { return ; } $ this -> _values [ 'typeid' ] = ( int ) $ typeid ; $ this -> setModified ( ) ; }
Sets the new type ID of the price .
32,359
public function setCurrencyId ( $ currencyid ) { if ( $ currencyid == $ this -> getCurrencyId ( ) ) { return ; } $ this -> _checkCurrencyId ( $ currencyid , false ) ; $ this -> _values [ 'currencyid' ] = $ currencyid ; $ this -> setModified ( ) ; }
Sets the used currency ID .
32,360
public function setDomain ( $ domain ) { if ( $ domain == $ this -> getDomain ( ) ) { return ; } $ this -> _values [ 'domain' ] = ( string ) $ domain ; $ this -> setModified ( ) ; }
Sets the new domain the price is valid for .
32,361
public function setQuantity ( $ quantity ) { if ( $ quantity == $ this -> getQuantity ( ) ) { return ; } $ this -> _values [ 'quantity' ] = ( int ) $ quantity ; $ this -> setModified ( ) ; }
Sets the quantity the price is valid for .
32,362
public function setValue ( $ price ) { if ( $ price == $ this -> getValue ( ) ) { return ; } $ this -> _checkPrice ( $ price ) ; $ this -> _values [ 'value' ] = $ this -> _formatNumber ( $ price ) ; $ this -> setModified ( ) ; }
Sets the new amount of money .
32,363
public function setCosts ( $ price ) { if ( $ price == $ this -> getCosts ( ) ) { return ; } $ this -> _checkPrice ( $ price ) ; $ this -> _values [ 'costs' ] = $ this -> _formatNumber ( $ price ) ; $ this -> setModified ( ) ; }
Sets the new costs .
32,364
public function setRebate ( $ price ) { if ( $ price == $ this -> getRebate ( ) ) { return ; } $ this -> _checkPrice ( $ price ) ; $ this -> _values [ 'rebate' ] = $ this -> _formatNumber ( $ price ) ; $ this -> setModified ( ) ; }
Sets the new rebate amount .
32,365
public function setTaxRate ( $ taxrate ) { if ( $ taxrate == $ this -> getTaxRate ( ) ) { return ; } $ this -> _checkPrice ( $ taxrate ) ; $ this -> _values [ 'taxrate' ] = $ this -> _formatNumber ( $ taxrate ) ; $ this -> setModified ( ) ; }
Sets the new tax rate .
32,366
public function setStatus ( $ status ) { if ( $ status == $ this -> getStatus ( ) ) { return ; } $ this -> _values [ 'status' ] = ( int ) $ status ; $ this -> setModified ( ) ; }
Sets the status of the item
32,367
public function setLabel ( $ label ) { if ( $ label == $ this -> getLabel ( ) ) { return ; } $ this -> _values [ 'label' ] = ( string ) $ label ; $ this -> setModified ( ) ; }
Sets the label of the item
32,368
public function addItem ( MShop_Price_Item_Interface $ item , $ quantity = 1 ) { if ( $ item -> getCurrencyId ( ) != $ this -> getCurrencyId ( ) ) { throw new MShop_Price_Exception ( sprintf ( 'Price can not be added. Currency ID "%1$s" of price item and currently used currency ID "%2$s" does not match.' , $ item -> getCurrencyId ( ) , $ this -> getCurrencyId ( ) ) ) ; } $ this -> _values [ 'value' ] = $ this -> _formatNumber ( $ this -> getValue ( ) + $ item -> getValue ( ) * $ quantity ) ; $ this -> _values [ 'costs' ] = $ this -> _formatNumber ( $ this -> getCosts ( ) + $ item -> getCosts ( ) * $ quantity ) ; $ this -> _values [ 'rebate' ] = $ this -> _formatNumber ( $ this -> getRebate ( ) + $ item -> getRebate ( ) * $ quantity ) ; }
Add the given price to the current one .
32,369
public function compare ( MShop_Price_Item_Interface $ price ) { if ( $ this -> getValue ( ) === $ price -> getValue ( ) && $ this -> getCosts ( ) === $ price -> getCosts ( ) && $ this -> getRebate ( ) === $ price -> getRebate ( ) && $ this -> getTaxrate ( ) === $ price -> getTaxrate ( ) && $ this -> getQuantity ( ) === $ price -> getQuantity ( ) && $ this -> getCurrencyId ( ) === $ price -> getCurrencyId ( ) ) { return true ; } return false ; }
Compares the properties of the given price item with its own one .
32,370
public function regexMatch ( $ pattern , $ options = '' ) { if ( ! $ this -> newSelf ( $ options ) -> contains ( 'u' ) ) $ options .= 'u' ; $ expression = $ this -> regexDelimiter . $ pattern . $ this -> regexDelimiter . $ options ; $ result = preg_match ( $ expression , $ this -> scalarString ) ; if ( $ result !== false ) return $ result === 1 ; throw new PcreException ( ) ; }
Returns true if the string matches the supplied pattern false otherwise .
32,371
public function regexExtract ( $ pattern , $ options = '' ) { $ matches = [ ] ; if ( ! $ this -> newSelf ( $ options ) -> contains ( 'u' ) ) $ options .= 'u' ; $ expression = $ this -> regexDelimiter . $ pattern . $ this -> regexDelimiter . $ options ; $ result = preg_match ( $ expression , $ this -> scalarString , $ matches ) ; if ( $ result !== false ) return $ this -> newSelfs ( $ matches ) ; throw new PcreException ( ) ; }
Given an expression with capture groups this will return those captures .
32,372
public function split ( $ pattern , $ limit = null , $ quote = true ) { if ( $ limit === 0 ) return [ ] ; if ( $ pattern === '' ) return [ $ this -> newSelf ( $ this -> scalarString ) ] ; if ( $ limit > 0 ) { $ limit += 1 ; } else { $ limit = - 1 ; } $ expression = $ this -> regexDelimiter ; if ( $ quote === true ) { $ expression .= preg_quote ( $ pattern , $ this -> regexDelimiter ) ; } else { $ expression .= $ pattern ; } $ expression .= $ this -> regexDelimiter . 'u' ; $ array = preg_split ( $ expression , $ this -> scalarString , $ limit ) ; if ( $ limit > 0 && count ( $ array ) === $ limit ) array_pop ( $ array ) ; return $ this -> newSelfs ( $ array ) ; }
Splits the string with the provided regular expression .
32,373
public function createCommand ( $ event ) { if ( ! empty ( $ this -> commands [ $ event -> name ] ) ) { if ( is_callable ( $ this -> condition ) && call_user_func ( $ this -> condition , $ this -> owner ) === false ) { return ; } $ class = $ this -> commands [ $ event -> name ] ; $ command = new $ class ( ) ; if ( ( $ command instanceof CommandInterface ) === false ) { throw new InvalidParamException ( 'Class name [' . get_class ( $ class ) . '] provided in "commands" param MUST implement the jlorente\command\base\CommandInterface interface' ) ; } $ command -> setReceiver ( $ this -> owner ) ; CommandMapper :: map ( $ command ) ; } }
Generates and stores the Command object depending on the triggered event .
32,374
protected function _getDomainManager ( $ domain ) { $ domain = strtolower ( trim ( $ domain , "/ \n\t\r\0\x0B" ) ) ; if ( strlen ( $ domain ) === 0 ) { throw new Exception ( 'An empty domain is invalid' ) ; } if ( ! isset ( $ this -> _domainManagers [ $ domain ] ) ) { $ parts = explode ( '/' , $ domain ) ; foreach ( $ parts as $ part ) { if ( ctype_alnum ( $ part ) === false ) { throw new Exception ( sprintf ( 'Invalid domain "%1$s"' , $ domain ) ) ; } } if ( ( $ domainname = array_shift ( $ parts ) ) === null ) { throw new Exception ( 'An empty domain is invalid' ) ; } if ( ! isset ( $ this -> _domainManagers [ $ domainname ] ) ) { $ iface = 'MShop_Common_Manager_Interface' ; $ factory = 'MShop_' . ucwords ( $ domainname ) . '_Manager_Factory' ; $ manager = call_user_func_array ( $ factory . '::createManager' , array ( $ this -> _additional ) ) ; if ( ! ( $ manager instanceof $ iface ) ) { throw new Exception ( sprintf ( 'No factory "%1$s" found' , $ factory ) ) ; } $ this -> _domainManagers [ $ domainname ] = $ manager ; } foreach ( $ parts as $ part ) { $ tmpname = $ domainname . '/' . $ part ; if ( ! isset ( $ this -> _domainManagers [ $ tmpname ] ) ) { $ this -> _domainManagers [ $ tmpname ] = $ this -> _domainManagers [ $ domainname ] -> getSubManager ( $ part ) ; } $ domainname = $ tmpname ; } } return $ this -> _domainManagers [ $ domain ] ; }
Returns the manager for the given domain and sub - domains .
32,375
public function dn ( $ domain , $ singular , $ plural , $ number ) { if ( $ this -> _getPluralIndex ( $ number , $ this -> getLocale ( ) ) > 0 ) { return ( string ) $ plural ; } return ( string ) $ singular ; }
Returns the plural string by given number .
32,376
public function affectedRows ( ) { try { return $ this -> _statement -> rowCount ( ) ; } catch ( PDOException $ e ) { throw new MW_DB_Exception ( $ e -> getMessage ( ) , $ e -> getCode ( ) , $ e -> errorInfo ) ; } }
Returns the number of rows affected by a INSERT UPDATE or DELETE statement .
32,377
public function fetch ( $ style = MW_DB_Result_Abstract :: FETCH_ASSOC ) { try { return $ this -> _statement -> fetch ( $ this -> _style [ $ style ] ) ; } catch ( PDOException $ e ) { throw new MW_DB_Exception ( $ e -> getMessage ( ) , $ e -> getCode ( ) , $ e -> errorInfo ) ; } }
Retrieves the next row from database result set .
32,378
public function finish ( ) { try { $ this -> _statement -> closeCursor ( ) ; } catch ( PDOException $ e ) { throw new MW_DB_Exception ( $ e -> getMessage ( ) , $ e -> getCode ( ) , $ e -> errorInfo ) ; } }
Cleans up pending database result sets .
32,379
public function nextResult ( ) { try { return $ this -> _statement -> nextRowset ( ) ; } catch ( PDOException $ e ) { throw new MW_DB_Exception ( $ e -> getMessage ( ) , $ e -> getCode ( ) , $ e -> errorInfo ) ; } }
Retrieves the next database result set .
32,380
protected function _calcDateLimit ( $ timestamp , $ skipdays = 0 , $ businessOnly = false , $ publicHolidays = '' ) { $ holidays = array ( ) ; if ( is_string ( $ publicHolidays ) && $ publicHolidays !== '' ) { $ holidays = explode ( ',' , str_replace ( ' ' , '' , $ publicHolidays ) ) ; if ( sort ( $ holidays ) === false ) { throw new MShop_Service_Exception ( sprintf ( 'Unable to sort public holidays: "%1$s"' , $ publicHolidays ) ) ; } $ holidays = array_flip ( $ holidays ) ; for ( $ i = 0 ; $ i <= $ skipdays ; $ i ++ ) { $ date = date ( 'Y-m-d' , $ timestamp - $ i * 86400 ) ; if ( isset ( $ holidays [ $ date ] ) ) { $ skipdays ++ ; } } } if ( $ businessOnly === true ) { for ( $ i = 0 ; $ i <= $ skipdays ; $ i ++ ) { $ ts = $ timestamp - $ i * 86400 ; if ( date ( 'N' , $ ts ) > 5 && ! isset ( $ holidays [ date ( 'Y-m-d' , $ ts ) ] ) ) { $ skipdays ++ ; } } } return date ( 'Y-m-d' , $ timestamp - $ skipdays * 86400 ) ; }
Calculates the last date behind the given timestamp depending on the other paramters .
32,381
protected function _checkConfig ( array $ config , array $ attributes ) { $ errors = array ( ) ; foreach ( $ config as $ key => $ def ) { if ( $ def [ 'required' ] === true && ( ! isset ( $ attributes [ $ key ] ) || $ attributes [ $ key ] === '' ) ) { $ errors [ $ key ] = sprintf ( 'Required attribute "%1$s" in provider configuration not available' , $ key ) ; continue ; } if ( isset ( $ attributes [ $ key ] ) ) { switch ( $ def [ 'type' ] ) { case 'boolean' : if ( $ attributes [ $ key ] != '0' && $ attributes [ $ key ] != '1' ) { $ errors [ $ key ] = 'Not a true/false value' ; continue 2 ; } break ; case 'string' : if ( is_string ( $ attributes [ $ key ] ) === false ) { $ errors [ $ key ] = 'Not a string' ; continue 2 ; } break ; case 'integer' : if ( ctype_digit ( $ attributes [ $ key ] ) === false ) { $ errors [ $ key ] = 'Not an integer number' ; continue 2 ; } break ; case 'decimal' : case 'float' : if ( is_numeric ( $ attributes [ $ key ] ) === false ) { $ errors [ $ key ] = 'Not a number' ; continue 2 ; } break ; case 'datetime' : $ pattern = '/^[0-9]{4}-[0-1][0-9]-[0-3][0-9] [0-2][0-9]:[0-5][0-9]:[0-5][0-9]$' ; if ( preg_match ( $ pattern , $ attributes [ $ key ] ) !== 1 ) { $ errors [ $ key ] = 'Invalid date and time' ; continue 2 ; } break ; case 'map' : if ( ! is_array ( $ attributes [ $ key ] ) ) { $ errors [ $ key ] = 'Not a valid map' ; continue 2 ; } break ; default : throw new MShop_Service_Exception ( sprintf ( 'Invalid characters in attribute for provider configuration. Attribute is not of type "%1$s".' , $ def [ 'type' ] ) ) ; } } $ errors [ $ key ] = null ; } return $ errors ; }
Checks required fields and the types of the config array .
32,382
protected function _getConfigValue ( array $ keys , $ default = null ) { $ srvconfig = $ this -> getServiceItem ( ) -> getConfig ( ) ; foreach ( $ keys as $ key ) { if ( isset ( $ srvconfig [ $ key ] ) ) { return $ srvconfig [ $ key ] ; } if ( isset ( $ this -> _beGlobalConfig [ $ key ] ) ) { return $ this -> _beGlobalConfig [ $ key ] ; } } return $ default ; }
Returns the configuration value that matches one of the given keys .
32,383
protected function _setConfigFE ( MShop_Order_Item_Base_Service_Interface $ orderServiceItem , array $ attributes , $ type ) { $ manager = MShop_Factory :: createManager ( $ this -> _context , 'order/base/service/attribute' ) ; $ attributeItems = array ( ) ; foreach ( $ attributes as $ key => $ value ) { $ ordBaseAttrItem = $ manager -> createItem ( ) ; $ ordBaseAttrItem -> setCode ( $ key ) ; $ ordBaseAttrItem -> setValue ( strip_tags ( $ value ) ) ; $ ordBaseAttrItem -> setType ( $ type ) ; $ attributeItems [ ] = $ ordBaseAttrItem ; } $ orderServiceItem -> setAttributes ( $ attributeItems ) ; }
Sets the attributes in the given service item .
32,384
public function setBaseId ( $ baseid ) { if ( $ baseid == $ this -> getBaseId ( ) ) { return ; } $ this -> _values [ 'baseid' ] = ( int ) $ baseid ; $ this -> setModified ( ) ; }
Sets the Base ID of the order .
32,385
public function setProductId ( $ productid ) { if ( $ productid == $ this -> getProductId ( ) ) { return ; } $ this -> _values [ 'ordprodid' ] = ( int ) $ productid ; $ this -> setModified ( ) ; }
Sets the ID of the ordered product .
32,386
public function transform ( $ prices ) { $ html = '' ; $ enc = $ this -> encoder ( ) ; $ format = $ this -> _getFormat ( ) ; $ iface = 'MShop_Price_Item_Interface' ; if ( ! is_array ( $ prices ) ) { $ prices = array ( $ prices ) ; } foreach ( $ prices as $ priceItem ) { if ( ! ( $ priceItem instanceof $ iface ) ) { throw new MW_View_Exception ( sprintf ( 'Object doesn\'t implement "%1$s"' , $ iface ) ) ; } $ costs = $ priceItem -> getCosts ( ) ; $ rebate = $ priceItem -> getRebate ( ) ; $ currency = $ this -> translate ( 'client/html/currency' , $ priceItem -> getCurrencyId ( ) ) ; $ html .= ' <div class="price-item"> <span class="quantity">' . $ enc -> html ( sprintf ( $ format [ 'quantity' ] , $ priceItem -> getQuantity ( ) ) , $ enc :: TRUST ) . '</span> <span class="value">' . $ enc -> html ( sprintf ( $ format [ 'value' ] , $ this -> number ( $ priceItem -> getValue ( ) ) , $ currency ) , $ enc :: TRUST ) . '</span>' . ( $ rebate > 0 ? ' <span class="rebate">' . $ enc -> html ( sprintf ( $ format [ 'rebate' ] , $ this -> number ( $ rebate ) , $ currency ) , $ enc :: TRUST ) . '</span> <span class="rebatepercent">' . $ enc -> html ( sprintf ( $ format [ 'rebate%' ] , $ this -> number ( round ( $ rebate * 100 / ( $ priceItem -> getValue ( ) + $ rebate ) ) , 0 ) ) , $ enc :: TRUST ) . '</span>' : '' ) . ( $ costs > 0 ? ' <span class="costs">' . $ enc -> html ( sprintf ( $ format [ 'costs' ] , $ this -> number ( $ costs ) , $ currency ) , $ enc :: TRUST ) . '</span>' : '' ) . '<span class="taxrate">' . $ enc -> html ( sprintf ( $ format [ 'taxrate' ] , $ this -> number ( $ priceItem -> getTaxrate ( ) ) ) , $ enc :: TRUST ) . '</span> </div>' ; } return $ html ; }
Returns the HTML for a price list .
32,387
protected function _getAttributeIds ( array $ colors ) { $ context = $ this -> _getContext ( ) ; $ attrTypeItem = $ this -> _getTypeItem ( 'attribute/type' , 'product' , 'color' ) ; $ mediaTypeItem = $ this -> _getTypeItem ( 'media/type' , 'attribute' , 'default' ) ; $ attrListTypeItem = $ this -> _getTypeItem ( 'attribute/list/type' , 'media' , 'default' ) ; $ mediaManager = MShop_Factory :: createManager ( $ context , 'media' ) ; $ mediaItem = $ mediaManager -> createItem ( ) ; $ mediaItem -> setTypeId ( $ mediaTypeItem -> getId ( ) ) ; $ mediaItem -> setDomain ( 'attribute' ) ; $ mediaItem -> setStatus ( 1 ) ; $ mediaItem -> setUrl ( '' ) ; $ attrManager = MShop_Factory :: createManager ( $ context , 'attribute' ) ; $ attrItem = $ attrManager -> createItem ( ) ; $ attrItem -> setTypeId ( $ attrTypeItem -> getId ( ) ) ; $ attrItem -> setDomain ( 'product' ) ; $ attrItem -> setStatus ( 1 ) ; $ attrListManager = MShop_Factory :: createManager ( $ context , 'attribute/list' ) ; $ attrListItem = $ attrListManager -> createItem ( ) ; $ attrListItem -> setTypeId ( $ attrListTypeItem -> getId ( ) ) ; $ attrListItem -> setDomain ( 'media' ) ; $ attrListItem -> setStatus ( 1 ) ; $ pos = 0 ; $ mime = '' ; $ attrList = array ( ) ; foreach ( $ colors as $ code => $ name ) { $ imageData = $ this -> _getImageData ( $ code , $ mime ) ; $ attrItem -> setId ( null ) ; $ attrItem -> setCode ( $ code ) ; $ attrItem -> setLabel ( $ name ) ; $ attrItem -> setPosition ( $ pos ++ ) ; $ attrManager -> saveItem ( $ attrItem ) ; $ mediaItem -> setId ( null ) ; $ mediaItem -> setLabel ( $ name ) ; $ mediaItem -> setMimetype ( $ mime ) ; $ mediaItem -> setPreview ( $ imageData ) ; $ mediaManager -> saveItem ( $ mediaItem ) ; $ attrListItem -> setId ( null ) ; $ attrListItem -> setParentId ( $ attrItem -> getId ( ) ) ; $ attrListItem -> setRefId ( $ mediaItem -> getId ( ) ) ; $ attrListManager -> saveItem ( $ attrListItem , false ) ; $ attrList [ ] = $ attrItem -> getId ( ) ; } return $ attrList ; }
Creates and returns the attribute IDs for the given attribute codes .
32,388
protected function _getImageData ( $ code , & $ mime ) { $ list = str_split ( ltrim ( $ code , '#' ) , 2 ) ; if ( count ( $ list ) !== 3 ) { throw new Exception ( sprintf ( 'Invalid color code "%1$s"' , $ code ) ) ; } if ( ( $ img = imagecreate ( 1 , 1 ) ) === false ) { throw new Exception ( 'Unable to create image' ) ; } if ( imagecolorallocate ( $ img , hexdec ( $ list [ 0 ] ) , hexdec ( $ list [ 1 ] ) , hexdec ( $ list [ 2 ] ) ) === false ) { throw new Exception ( 'Unable to allocate color' ) ; } try { ob_start ( ) ; if ( function_exists ( 'imagegif' ) === true && imagegif ( $ img ) === true ) { $ mime = 'image/gif' ; } else if ( function_exists ( 'imagepng' ) === true && imagepng ( $ img ) === true ) { $ mime = 'image/png' ; } else { throw new Exception ( 'Unable to create image. php-gd not installed?' ) ; } $ image = ob_get_contents ( ) ; ob_end_clean ( ) ; } catch ( Exception $ e ) { ob_end_clean ( ) ; throw $ e ; } if ( imagedestroy ( $ img ) === false ) { throw new Exception ( 'Unable to destroy image' ) ; } return 'data:' . $ mime . ';base64,' . base64_encode ( $ image ) ; }
Returns the base64 encoded image data for the given color code .
32,389
public function getSearchAttributes ( ) { $ attributes = array ( ) ; foreach ( $ this -> _searchConfig as $ values ) { $ attributes [ ] = new MW_Common_Criteria_Attribute_Default ( $ values ) ; } return $ attributes ; }
Returns a list of attributes which can be used in the search method .
32,390
public function createSearch ( ) { $ conn = $ this -> _dbm -> acquire ( $ this -> _dbname ) ; $ search = new MW_Common_Criteria_SQL ( $ conn ) ; $ this -> _dbm -> release ( $ conn , $ this -> _dbname ) ; return $ search ; }
Creates a new search object for storing search criterias .
32,391
public function deleteNode ( $ id = null ) { $ node = $ this -> getNode ( $ id , MW_Tree_Manager_Abstract :: LEVEL_ONE ) ; $ conn = $ this -> _dbm -> acquire ( $ this -> _dbname ) ; try { $ stmt = $ conn -> create ( $ this -> _config [ 'delete' ] ) ; $ stmt -> bind ( 1 , $ node -> left , MW_DB_Statement_Abstract :: PARAM_INT ) ; $ stmt -> bind ( 2 , $ node -> right , MW_DB_Statement_Abstract :: PARAM_INT ) ; $ stmt -> execute ( ) -> finish ( ) ; $ diff = $ node -> right - $ node -> left + 1 ; $ stmt = $ conn -> create ( $ this -> _config [ 'move-left' ] ) ; $ stmt -> bind ( 1 , - $ diff , MW_DB_Statement_Abstract :: PARAM_INT ) ; $ stmt -> bind ( 2 , 0 , MW_DB_Statement_Abstract :: PARAM_INT ) ; $ stmt -> bind ( 3 , $ node -> right + 1 , MW_DB_Statement_Abstract :: PARAM_INT ) ; $ stmt -> bind ( 4 , 0x7FFFFFFF , MW_DB_Statement_Abstract :: PARAM_INT ) ; $ stmt -> execute ( ) -> finish ( ) ; $ stmt = $ conn -> create ( $ this -> _config [ 'move-right' ] ) ; $ stmt -> bind ( 1 , - $ diff , MW_DB_Statement_Abstract :: PARAM_INT ) ; $ stmt -> bind ( 2 , $ node -> right + 1 , MW_DB_Statement_Abstract :: PARAM_INT ) ; $ stmt -> bind ( 3 , 0x7FFFFFFF , MW_DB_Statement_Abstract :: PARAM_INT ) ; $ stmt -> execute ( ) -> finish ( ) ; $ this -> _dbm -> release ( $ conn , $ this -> _dbname ) ; } catch ( Exception $ e ) { $ this -> _dbm -> release ( $ conn , $ this -> _dbname ) ; throw $ e ; } }
Deletes a node and its descendants from the storage .
32,392
public function saveNode ( MW_Tree_Node_Interface $ node ) { if ( $ node -> getId ( ) === null ) { throw new MW_Tree_Exception ( sprintf ( 'Unable to save newly created nodes, use insert method instead' ) ) ; } if ( $ node -> isModified ( ) === false ) { return ; } $ conn = $ this -> _dbm -> acquire ( $ this -> _dbname ) ; try { $ stmt = $ conn -> create ( $ this -> _config [ 'update' ] ) ; $ stmt -> bind ( 1 , $ node -> getLabel ( ) ) ; $ stmt -> bind ( 2 , $ node -> getCode ( ) ) ; $ stmt -> bind ( 3 , $ node -> getStatus ( ) ) ; $ stmt -> bind ( 4 , $ node -> getId ( ) ) ; $ stmt -> execute ( ) -> finish ( ) ; $ this -> _dbm -> release ( $ conn , $ this -> _dbname ) ; } catch ( Exception $ e ) { $ this -> _dbm -> release ( $ conn , $ this -> _dbname ) ; throw $ e ; } }
Stores the values of the given node to the storage .
32,393
public function searchNodes ( MW_Common_Criteria_Interface $ search , $ id = null ) { $ left = 1 ; $ right = 0x7FFFFFFF ; if ( $ id !== null ) { $ node = $ this -> _getNodeById ( $ id ) ; $ left = $ node -> left ; $ right = $ node -> right ; } $ types = $ this -> _getSearchTypes ( $ this -> _searchConfig ) ; $ translations = $ this -> _getSearchTranslations ( $ this -> _searchConfig ) ; $ conditions = $ search -> getConditionString ( $ types , $ translations ) ; $ sortations = $ search -> getSortationString ( $ types , $ translations ) ; $ sql = str_replace ( array ( ':cond' , ':order' ) , array ( $ conditions , $ sortations ) , $ this -> _config [ 'search' ] ) ; $ conn = $ this -> _dbm -> acquire ( $ this -> _dbname ) ; try { $ stmt = $ conn -> create ( $ sql ) ; $ stmt -> bind ( 1 , $ left , MW_DB_Statement_Abstract :: PARAM_INT ) ; $ stmt -> bind ( 2 , $ right , MW_DB_Statement_Abstract :: PARAM_INT ) ; $ result = $ stmt -> execute ( ) ; try { $ nodes = array ( ) ; while ( ( $ row = $ result -> fetch ( ) ) !== false ) { $ nodes [ $ row [ 'id' ] ] = $ this -> _createNode ( $ row ) ; } } catch ( Exception $ e ) { $ result -> finish ( ) ; throw $ e ; } $ this -> _dbm -> release ( $ conn , $ this -> _dbname ) ; } catch ( Exception $ e ) { $ this -> _dbm -> release ( $ conn , $ this -> _dbname ) ; throw $ e ; } return $ nodes ; }
Retrieves a list of nodes from the storage matching the given search criteria .
32,394
public function getPath ( $ id ) { $ result = array ( ) ; $ node = $ this -> getNode ( $ id , MW_Tree_Manager_Abstract :: LEVEL_ONE ) ; $ search = $ this -> createSearch ( ) ; $ expr = array ( $ search -> compare ( '<=' , $ this -> _searchConfig [ 'left' ] [ 'code' ] , $ node -> left ) , $ search -> compare ( '>=' , $ this -> _searchConfig [ 'right' ] [ 'code' ] , $ node -> right ) , ) ; $ search -> setConditions ( $ search -> combine ( '&&' , $ expr ) ) ; $ search -> setSortations ( array ( $ search -> sort ( '+' , $ this -> _searchConfig [ 'left' ] [ 'code' ] ) ) ) ; $ results = $ this -> searchNodes ( $ search ) ; foreach ( $ results as $ item ) { $ result [ $ item -> getId ( ) ] = $ item ; } return $ result ; }
Returns a list if node IDs that are in the path of given node ID .
32,395
protected function _checkSearchConfig ( array $ config ) { $ required = array ( 'id' , 'label' , 'status' , 'level' , 'left' , 'right' ) ; foreach ( $ required as $ key => $ entry ) { if ( isset ( $ config [ $ entry ] ) ) { unset ( $ required [ $ key ] ) ; } } if ( count ( $ required ) > 0 ) { $ msg = 'Search config in given configuration are missing: "%1$s"' ; throw new MW_Tree_Exception ( sprintf ( $ msg , implode ( ', ' , $ required ) ) ) ; } }
Checks if all required search configurations are available .
32,396
protected function _createTree ( MW_DB_Result_Interface $ result , MW_Tree_Node_Interface $ node ) { while ( ( $ record = $ result -> fetch ( ) ) !== false ) { $ newNode = $ this -> _createNode ( $ record ) ; while ( $ this -> _isChild ( $ newNode , $ node ) ) { $ node -> addChild ( $ newNode ) ; if ( ( $ newNode = $ this -> _createTree ( $ result , $ newNode ) ) === false ) { return false ; } } return $ newNode ; } return false ; }
Creates a tree from the result set returned by the database .
32,397
protected function _isChild ( MW_Tree_Node_Interface $ node , MW_Tree_Node_Interface $ parent ) { return $ node -> __get ( 'left' ) > $ parent -> __get ( 'left' ) && $ node -> __get ( 'right' ) < $ parent -> __get ( 'right' ) ; }
Tests if the first node is a child of the second node .
32,398
protected function _getLevelFromConstant ( $ level ) { switch ( $ level ) { case MW_Tree_Manager_Abstract :: LEVEL_ONE : return 0 ; case MW_Tree_Manager_Abstract :: LEVEL_LIST : return 1 ; case MW_Tree_Manager_Abstract :: LEVEL_TREE : return 0x7FFFFFFF ; default : throw new MW_Tree_Exception ( sprintf ( 'Invalid level constant "%1$d"' , $ level ) ) ; } }
Converts the level constant to the depth of the tree .
32,399
protected function _getNodeById ( $ id ) { $ conn = $ this -> _dbm -> acquire ( $ this -> _dbname ) ; try { $ stmt = $ conn -> create ( str_replace ( ':cond' , '1=1' , $ this -> _config [ 'get' ] ) ) ; $ stmt -> bind ( 1 , $ id , MW_DB_Statement_Abstract :: PARAM_INT ) ; $ stmt -> bind ( 2 , 0 , MW_DB_Statement_Abstract :: PARAM_INT ) ; $ result = $ stmt -> execute ( ) ; if ( ( $ row = $ result -> fetch ( ) ) === false ) { throw new MW_Tree_Exception ( sprintf ( 'No node with ID "%1$d" found' , $ id ) ) ; } $ node = $ this -> _createNode ( $ row ) ; $ this -> _dbm -> release ( $ conn , $ this -> _dbname ) ; } catch ( Exception $ e ) { $ this -> _dbm -> release ( $ conn , $ this -> _dbname ) ; throw $ e ; } return $ node ; }
Returns a single node identified by its ID .