idx
int64
0
241k
question
stringlengths
64
6.21k
target
stringlengths
5
803
16,000
public function replaceWith ( $ nodes ) { $ first = TRUE ; foreach ( $ this -> nodes as $ node ) { if ( ! $ first ) { if ( is_array ( $ nodes ) ) { $ nodes = new NodeCollection ( $ nodes , FALSE ) ; } $ nodes = clone $ nodes ; } $ node -> replaceWith ( $ nodes ) ; $ first = FALSE ; } return $ this ; }
Replace each node in the set of matched nodes with the provided new nodes and return the set of nodes that was removed .
16,001
public function replaceAll ( $ targets ) { if ( $ targets instanceof Node ) { $ targets -> replaceWith ( $ this -> nodes ) ; } elseif ( $ targets instanceof NodeCollection || is_array ( $ targets ) ) { $ first = TRUE ; foreach ( $ targets as $ target ) { $ target -> replaceWith ( $ first ? $ this -> nodes : clone $ thi...
Replace each target node with the set of matched nodes .
16,002
public function add ( $ nodes ) { if ( $ nodes instanceof Node ) { $ this -> nodes [ ] = $ nodes ; } elseif ( $ nodes instanceof NodeCollection ) { $ this -> nodes = array_merge ( $ this -> nodes , $ nodes -> nodes ) ; } elseif ( is_array ( $ nodes ) ) { $ this -> nodes = array_merge ( $ this -> nodes , $ nodes ) ; } e...
Add nodes to this collection .
16,003
public function enterNode ( Node $ node ) { if ( $ node instanceof UseUse ) { $ this -> imports [ ] = $ node -> name -> toString ( ) ; } return $ node ; }
Enter the node and record the import .
16,004
protected function deleteHooks ( $ module ) { $ query = ModuleHookQuery :: create ( ) ; if ( null !== $ module ) { $ query -> filterByModule ( $ module ) -> delete ( ) ; } else { $ query -> deleteAll ( ) ; } $ query = IgnoredModuleHookQuery :: create ( ) ; if ( null !== $ module ) { $ query -> filterByModule ( $ module...
Delete module hooks
16,005
public function getFormDefinedUrl ( $ parameterName , $ default = null ) { $ formDefinedUrl = $ this -> form -> get ( $ parameterName ) -> getData ( ) ; if ( empty ( $ formDefinedUrl ) ) { if ( $ default === null ) { $ default = ConfigQuery :: read ( 'base_url' , '/' ) ; } $ formDefinedUrl = $ default ; } return URL ::...
Build an absolute URL using the value of a form parameter .
16,006
private function findNextPrev ( LoopResultRow $ loopResultRow , $ imageId , $ imageType , $ currentPosition ) { if ( $ imageType == 'product' ) { $ imageRow = ProductImageQuery :: create ( ) -> filterById ( $ imageId ) -> findOne ( ) ; if ( $ imageRow != null ) { $ previousQuery = ProductImageQuery :: create ( ) -> fil...
Set the fields HAS_PREVIOUS HAS_NEXT PREVIOUS NEXT for the image loop
16,007
public function update ( BrandUpdateEvent $ event , $ eventName , EventDispatcherInterface $ dispatcher ) { if ( null !== $ brand = BrandQuery :: create ( ) -> findPk ( $ event -> getBrandId ( ) ) ) { $ brand -> setDispatcher ( $ dispatcher ) ; $ brand -> setVisible ( $ event -> getVisible ( ) ) -> setLogoImageId ( \ i...
process update brand
16,008
public function toggleVisibility ( BrandToggleVisibilityEvent $ event , $ eventName , EventDispatcherInterface $ dispatcher ) { $ brand = $ event -> getBrand ( ) ; $ brand -> setDispatcher ( $ dispatcher ) -> setVisible ( ! $ brand -> getVisible ( ) ) -> save ( ) ; $ event -> setBrand ( $ brand ) ; }
Toggle Brand visibility
16,009
public function viewCheck ( ViewCheckEvent $ event , $ eventName , EventDispatcherInterface $ dispatcher ) { if ( $ event -> getView ( ) == 'brand' ) { $ brand = BrandQuery :: create ( ) -> filterById ( $ event -> getViewId ( ) ) -> filterByVisible ( 1 ) -> count ( ) ; if ( $ brand == 0 ) { $ dispatcher -> dispatch ( T...
Check if is a brand view and if brand_id is visible
16,010
public function addLeftLink ( string $ name , string $ link = null , bool $ ajax = false ) : Item { return $ this -> leftItems [ ] = new Item ( $ name , [ 'link' => $ link ?? '#' , 'ajax' => $ ajax ] ) ; }
Prida link do dockbaru vlevo
16,011
public function addRightLink ( string $ name , string $ link = null , bool $ ajax = false ) : Item { return $ this -> rightItems [ ] = new Item ( $ name , [ 'link' => $ link ?? '#' , 'ajax' => $ ajax ] ) ; }
Prida link do dockbaru vpravo
16,012
public function isLinkAllowed ( string $ link ) : bool { if ( isset ( $ this -> allowedLinks [ $ link ] ) ) { return true ; } else { $ pos = strrpos ( $ link , ':' ) ; $ link = substr ( $ link , 0 , ( $ pos + 1 ) ) ; return isset ( $ this -> allowedLinks [ $ link ] ) ; } }
Ma opravneni zobrazit stranku?
16,013
private function checkHandlerPermission ( bool $ ajax = true ) : void { if ( ! isset ( $ this -> allowedHandler [ $ this -> presenter -> getSignal ( ) [ 1 ] ] ) ) { $ this -> presenter -> terminate ( ) ; } if ( $ ajax && ! $ this -> presenter -> isAjax ( ) ) { $ this -> presenter -> terminate ( ) ; } }
Zkontroluje opravneni a pokud je nema ukonci aplikaci
16,014
public function getAreaForCountry ( Country $ country ) { $ area = null ; if ( null !== $ areaDeliveryModule = AreaDeliveryModuleQuery :: create ( ) -> findByCountryAndModule ( $ country , $ this -> getModuleModel ( ) ) ) { $ area = $ areaDeliveryModule -> getArea ( ) ; } return $ area ; }
Return the first area that matches the given country for the given module
16,015
protected function createLexicalVariables ( ) { if ( ! $ this -> hasLexicalVariables ( ) ) { $ this -> lexicalUse = Token :: _use ( ) ; $ this -> lexicalOpenParen = Token :: openParen ( ) ; $ this -> lexicalVariables = new CommaListNode ( ) ; $ this -> lexicalCloseParen = Token :: closeParen ( ) ; $ this -> closeParen ...
Creates an empty lexical variables list if it does not already exist .
16,016
public function loadRelatedAjaxTabAction ( ) { return $ this -> render ( 'ajax/product-related-tab' , array ( 'product_id' => $ this -> getRequest ( ) -> get ( 'product_id' , 0 ) , 'folder_id' => $ this -> getRequest ( ) -> get ( 'folder_id' , 0 ) , 'accessory_category_id' => $ this -> getRequest ( ) -> get ( 'accessor...
Related information ajax tab loading
16,017
public function getVirtualDocumentListAjaxAction ( $ productId , $ pseId ) { $ this -> checkAuth ( AdminResources :: PRODUCT , array ( ) , AccessManager :: VIEW ) ; $ this -> checkXmlHttpRequest ( ) ; $ selectedId = \ intval ( MetaDataQuery :: getVal ( 'virtual' , MetaData :: PSE_KEY , $ pseId ) ) ; $ documents = Produ...
return a list of document which will be displayed in AJAX
16,018
public function updateAccessoryPositionAction ( ) { $ accessory = AccessoryQuery :: create ( ) -> findPk ( $ this -> getRequest ( ) -> get ( 'accessory_id' , null ) ) ; return $ this -> genericUpdatePositionAction ( $ accessory , TheliaEvents :: PRODUCT_UPDATE_ACCESSORY_POSITION ) ; }
Update accessory position
16,019
public function updateContentPositionAction ( ) { $ content = ProductAssociatedContentQuery :: create ( ) -> findPk ( $ this -> getRequest ( ) -> get ( 'content_id' , null ) ) ; return $ this -> genericUpdatePositionAction ( $ content , TheliaEvents :: PRODUCT_UPDATE_CONTENT_POSITION ) ; }
Update related content position
16,020
public function setProductTemplateAction ( $ productId ) { if ( null !== $ response = $ this -> checkAuth ( $ this -> resourceCode , array ( ) , AccessManager :: UPDATE ) ) { return $ response ; } $ product = ProductQuery :: create ( ) -> findPk ( $ productId ) ; if ( $ product != null ) { $ template_id = \ intval ( $ ...
Change product template for a given product .
16,021
public function updateAttributesAndFeaturesAction ( $ productId ) { $ product = ProductQuery :: create ( ) -> findPk ( $ productId ) ; if ( $ product != null ) { $ featureTemplate = FeatureTemplateQuery :: create ( ) -> filterByTemplateId ( $ product -> getTemplateId ( ) ) -> find ( ) ; if ( $ featureTemplate !== null ...
Update product attributes and features
16,022
protected function processSingleProductSaleElementUpdate ( $ data ) { $ event = new ProductSaleElementUpdateEvent ( $ this -> getExistingObject ( ) , $ data [ 'product_sale_element_id' ] ) ; $ event -> setReference ( $ data [ 'reference' ] ) -> setPrice ( $ data [ 'price' ] ) -> setCurrencyId ( $ data [ 'currency' ] ) ...
Process a single PSE update using form data array .
16,023
protected function processProductSaleElementUpdate ( $ changeForm ) { if ( null !== $ response = $ this -> checkAuth ( $ this -> resourceCode , array ( ) , AccessManager :: UPDATE ) ) { return $ response ; } try { $ form = $ this -> validateForm ( $ changeForm , "POST" ) ; $ data = $ form -> getData ( ) ; if ( \ is_arr...
Change a product sale element
16,024
public function buildCombinationsAction ( ) { if ( null !== $ response = $ this -> checkAuth ( $ this -> resourceCode , array ( ) , AccessManager :: UPDATE ) ) { return $ response ; } $ changeForm = $ this -> createForm ( AdminForm :: PRODUCT_COMBINATION_GENERATION ) ; try { $ form = $ this -> validateForm ( $ changeFo...
Build combinations from the combination output builder
16,025
public function priceCalculator ( ) { $ return_price = 0 ; $ price = \ floatval ( $ this -> getRequest ( ) -> query -> get ( 'price' , 0 ) ) ; $ product_id = \ intval ( $ this -> getRequest ( ) -> query -> get ( 'product_id' , 0 ) ) ; $ action = $ this -> getRequest ( ) -> query -> get ( 'action' , '' ) ; $ convert = \...
Invoked through Ajax ; this method calculates the taxed price from the untaxed price and vice versa .
16,026
public function loadConvertedPrices ( ) { $ product_sale_element_id = \ intval ( $ this -> getRequest ( ) -> get ( 'product_sale_element_id' , 0 ) ) ; $ currency_id = \ intval ( $ this -> getRequest ( ) -> get ( 'currency_id' , 0 ) ) ; $ price_with_tax = $ price_without_tax = $ sale_price_with_tax = $ sale_price_withou...
Calculate all prices
16,027
public function parse ( $ nodes , $ filename = NULL ) { $ this -> nodes = $ nodes ; $ this -> filename = $ filename ; $ this -> position = 0 ; $ this -> length = count ( $ nodes ) ; $ this -> operators = [ $ this -> sentinel ] ; $ this -> operands = [ ] ; $ this -> E ( ) ; if ( $ this -> next ( ) ) { $ next = $ this ->...
Parse the expression nodes into a tree .
16,028
public function changeValuesAction ( ) { if ( null !== $ response = $ this -> checkAuth ( $ this -> resourceCode , array ( ) , AccessManager :: UPDATE ) ) { return $ response ; } $ variables = $ this -> getRequest ( ) -> get ( 'variable' , array ( ) ) ; foreach ( $ variables as $ id => $ value ) { $ event = new ConfigU...
Change values modified directly from the variable list
16,029
public function isExpired ( ) { $ ret = true ; $ now = new \ DateTime ( ) ; if ( $ this -> expirationDate > $ now ) { $ ret = false ; } return $ ret ; }
Check if the Coupon is already Expired
16,030
public function drawBackOfficeInputs ( ) { return $ this -> facade -> getParser ( ) -> render ( 'coupon/type-fragments/remove-x.html' , [ 'label' => $ this -> getInputName ( ) , 'fieldId' => self :: AMOUNT_FIELD_NAME , 'fieldName' => $ this -> makeCouponFieldName ( self :: AMOUNT_FIELD_NAME ) , 'value' => $ this -> amo...
Draw the input displayed in the BackOffice allowing Admin to set its Coupon effect Override this method to do something useful
16,031
protected function getCouponFieldValue ( $ fieldName , $ data , $ defaultValue = null ) { if ( isset ( $ data [ self :: COUPON_DATASET_NAME ] [ $ fieldName ] ) ) { return $ this -> checkCouponFieldValue ( $ fieldName , $ data [ self :: COUPON_DATASET_NAME ] [ $ fieldName ] ) ; } elseif ( null !== $ defaultValue ) { ret...
A helper to get the value of a standard field name
16,032
public function getEffects ( $ data ) { $ effects = [ ] ; foreach ( $ this -> getFieldList ( ) as $ fieldName ) { $ effects [ $ fieldName ] = $ this -> getCouponFieldValue ( $ fieldName , $ data ) ; } return $ effects ; }
Create the effect array from the list of fields
16,033
public function verifyAccount ( $ value , ExecutionContextInterface $ context ) { if ( $ value == 1 ) { $ data = $ context -> getRoot ( ) -> getData ( ) ; if ( false === $ data [ 'password' ] || ( empty ( $ data [ 'password' ] ) && '0' != $ data [ 'password' ] ) ) { $ context -> getViolations ( ) -> add ( new Constrain...
If the user select Yes I have a password we check the password .
16,034
public function verifyExistingEmail ( $ value , ExecutionContextInterface $ context ) { $ data = $ context -> getRoot ( ) -> getData ( ) ; if ( $ data [ "account" ] == 0 ) { $ customer = CustomerQuery :: create ( ) -> findOneByEmail ( $ value ) ; if ( $ customer ) { $ context -> addViolation ( Translator :: getInstance...
If the user select I am a new customer we make sure is email address does not exit in the database .
16,035
public function exportChangePosition ( UpdatePositionEvent $ updatePositionEvent , $ eventName , EventDispatcherInterface $ dispatcher ) { $ this -> handler -> getExport ( $ updatePositionEvent -> getObjectId ( ) , true ) ; $ this -> genericUpdatePosition ( new ExportQuery , $ updatePositionEvent , $ dispatcher ) ; }
Handle export change position event
16,036
public function exportCategoryChangePosition ( UpdatePositionEvent $ updatePositionEvent , $ eventName , EventDispatcherInterface $ dispatcher ) { $ this -> handler -> getCategory ( $ updatePositionEvent -> getObjectId ( ) , true ) ; $ this -> genericUpdatePosition ( new ExportCategoryQuery , $ updatePositionEvent , $ ...
Handle export category change position event
16,037
public function getPricesByCurrency ( Currency $ currency , $ discount = 0 ) { $ defaultCurrency = Currency :: getDefaultCurrency ( ) ; $ productPrice = ProductPriceQuery :: create ( ) -> filterByProductSaleElementsId ( $ this -> getId ( ) ) -> filterByCurrencyId ( $ currency -> getId ( ) ) -> findOne ( ) ; if ( null =...
Get product prices for a specific currency .
16,038
public function getAllFiles ( $ sources ) { $ files = array ( ) ; foreach ( $ sources as $ source ) { if ( ! is_dir ( $ source ) ) { $ files [ ] = $ source ; continue ; } $ recursiveFiles = new RecursiveIteratorIterator ( new RecursiveDirectoryIterator ( $ source ) ) ; foreach ( $ recursiveFiles as $ file ) { if ( $ fi...
Check how of list is dir and find all files .
16,039
protected function addStandardModuleTemplatesToParserEnvironment ( $ parser , $ module ) { $ stdTpls = TemplateDefinition :: getStandardTemplatesSubdirsIterator ( ) ; foreach ( $ stdTpls as $ templateType => $ templateSubdirName ) { $ this -> addModuleTemplateToParserEnvironment ( $ parser , $ module , $ templateType ,...
Add all module s standard templates to the parser environment
16,040
protected function addModuleTemplateToParserEnvironment ( $ parser , $ module , $ templateType , $ templateSubdirName ) { $ templateDirectory = $ module -> getAbsoluteTemplateDirectoryPath ( $ templateSubdirName ) ; try { $ templateDirBrowser = new \ DirectoryIterator ( $ templateDirectory ) ; $ code = ucfirst ( $ modu...
Add a module template directory to the parser environment
16,041
public function viewCheck ( ViewCheckEvent $ event , $ eventName , EventDispatcherInterface $ dispatcher ) { if ( $ event -> getView ( ) == 'folder' ) { $ folder = FolderQuery :: create ( ) -> filterById ( $ event -> getViewId ( ) ) -> filterByVisible ( 1 ) -> count ( ) ; if ( $ folder == 0 ) { $ dispatcher -> dispatch...
Check if is a folder view and if folder_id is visible
16,042
protected function setDefault ( int $ localeId ) : void { $ this -> orm -> locales -> getById ( $ localeId ) -> setDefault ( ) ; }
Nastavi vychozi jazyk
16,043
protected function setAllowed ( array $ allowed ) : void { $ locales = $ this -> orm -> locales -> findAll ( ) ; foreach ( $ locales as $ locale ) { if ( in_array ( $ locale -> id , $ allowed ) ) { $ locale -> allowed = true ; } else { $ locale -> allowed = false ; } $ this -> orm -> persist ( $ locale ) ; } $ this -> ...
Nastavi povolene jazyky
16,044
public function checkWritableI18nDirectory ( $ dir ) { if ( file_exists ( $ dir ) ) { return is_writable ( $ dir ) ; } $ parentDir = dirname ( $ dir ) ; return file_exists ( $ parentDir ) && is_writable ( $ parentDir ) ; }
Check if a directory is writable or if the parent directory is writable
16,045
public function make ( array $ config ) { Arr :: requires ( $ config , [ 'token' ] ) ; $ client = new Client ( ) ; return new HipchatGateway ( $ client , $ config ) ; }
Create a new hipchat gateway instance .
16,046
protected function parse ( $ body ) { $ disableEntities = libxml_disable_entity_loader ( true ) ; $ internalErrors = libxml_use_internal_errors ( true ) ; try { $ xml = new SimpleXMLElement ( ( string ) $ body ? : '<root />' , LIBXML_NONET ) ; return json_decode ( json_encode ( $ xml ) , true ) ; } catch ( Exception $ ...
Parse an xml string to an array .
16,047
public function getZipCodeRE ( ) { $ zipCodeFormat = $ this -> getZipCodeFormat ( ) ; if ( empty ( $ zipCodeFormat ) ) { return null ; } $ zipCodeRE = preg_replace ( "/\\s+/" , ' ' , $ zipCodeFormat ) ; $ trans = [ "N" => "\\d" , "L" => "[a-zA-Z]" , "C" => ".+" , " " => " +" ] ; $ zipCodeRE = "#^" . strtr ( $ zipCodeRE...
get a regex pattern according to the zip code format field to match a zip code for this country .
16,048
public function getAreaId ( ) { $ firstAreaCountry = CountryAreaQuery :: create ( ) -> findOneByCountryId ( $ this -> getId ( ) ) ; if ( null !== $ firstAreaCountry ) { return $ firstAreaCountry -> getAreaId ( ) ; } return null ; }
This method ensure backward compatibility to Thelia 2 . 1 where a country belongs to one and only one shipping zone .
16,049
public static function getDefaultCountry ( ) { if ( null === self :: $ defaultCountry ) { self :: $ defaultCountry = CountryQuery :: create ( ) -> findOneByByDefault ( true ) ; if ( null === self :: $ defaultCountry ) { throw new \ LogicException ( Translator :: getInstance ( ) -> trans ( "Cannot find a default country...
Return the default country
16,050
public static function getShopLocation ( ) { $ countryId = ConfigQuery :: getStoreCountry ( ) ; if ( empty ( $ countryId ) ) { return self :: getDefaultCountry ( ) ; } $ shopCountry = CountryQuery :: create ( ) -> findPk ( $ countryId ) ; if ( $ shopCountry === null ) { throw new \ LogicException ( Translator :: getIns...
Return the shop country
16,051
protected function getAliasColumn ( ) { $ strColNameAlias = $ this -> get ( 'tag_alias' ) ; if ( $ this -> isTreePicker ( ) || ! $ strColNameAlias ) { $ strColNameAlias = $ this -> getIdColumn ( ) ; } return $ strColNameAlias ; }
Determine the correct alias column to use .
16,052
private function setDataForItem ( $ itemId , $ tags , $ thisExisting ) { if ( $ tags === null ) { $ tagIds = [ ] ; } else { $ tagIds = \ array_keys ( $ tags ) ; } $ valuesToRemove = \ array_diff ( $ thisExisting , $ tagIds ) ; if ( $ valuesToRemove ) { $ this -> connection -> createQueryBuilder ( ) -> delete ( 'tl_meta...
Update the tag ids for a given item .
16,053
public function updateChannel ( $ old , $ new , $ option ) { $ old [ 'release_channel' ] = ! empty ( $ old [ 'release_channel' ] ) ? $ old [ 'release_channel' ] : null ; $ new [ 'release_channel' ] = ! empty ( $ new [ 'release_channel' ] ) ? $ new [ 'release_channel' ] : 'stable' ; $ old [ 'theme_release_channel' ] = !...
Update Plugin Channel .
16,054
public function getParentList ( ) { if ( null === $ this -> parentList ) { $ this -> parentList = [ ] ; $ parent = $ this -> getDescriptor ( ) -> getParent ( ) ; for ( $ index = 1 ; null !== $ parent ; $ index ++ ) { $ this -> parentList [ $ parent -> getName ( ) . '-' ] = $ parent ; $ parent = $ parent -> getDescripto...
Return the template parent list
16,055
public function getTemplateFilePath ( $ templateName ) { $ templateList = array_merge ( [ $ this ] , $ this -> getParentList ( ) ) ; foreach ( $ templateList as $ templateDefinition ) { $ templateFilePath = sprintf ( '%s%s/%s' , THELIA_TEMPLATE_DIR , $ templateDefinition -> getPath ( ) , $ templateName ) ; if ( file_ex...
Find a template file path considering the template parents if any .
16,056
public function create ( CurrencyCreateEvent $ event , $ eventName , EventDispatcherInterface $ dispatcher ) { $ currency = new CurrencyModel ( ) ; $ isDefault = CurrencyQuery :: create ( ) -> count ( ) === 0 ; $ currency -> setDispatcher ( $ dispatcher ) -> setLocale ( $ event -> getLocale ( ) ) -> setName ( $ event -...
Create a new currencyuration entry
16,057
public function update ( CurrencyUpdateEvent $ event , $ eventName , EventDispatcherInterface $ dispatcher ) { if ( null !== $ currency = CurrencyQuery :: create ( ) -> findPk ( $ event -> getCurrencyId ( ) ) ) { $ currency -> setDispatcher ( $ dispatcher ) -> setLocale ( $ event -> getLocale ( ) ) -> setName ( $ event...
Change a currency
16,058
public function setDefault ( CurrencyUpdateEvent $ event , $ eventName , EventDispatcherInterface $ dispatcher ) { if ( null !== $ currency = CurrencyQuery :: create ( ) -> findPk ( $ event -> getCurrencyId ( ) ) ) { CurrencyQuery :: create ( ) -> filterByByDefault ( true ) -> update ( array ( 'ByDefault' => false ) ) ...
Set the default currency
16,059
public function delete ( CurrencyDeleteEvent $ event , $ eventName , EventDispatcherInterface $ dispatcher ) { if ( null !== ( $ currency = CurrencyQuery :: create ( ) -> findPk ( $ event -> getCurrencyId ( ) ) ) ) { if ( $ currency -> getByDefault ( ) ) { throw new \ RuntimeException ( Translator :: getInstance ( ) ->...
Delete a currencyuration entry
16,060
public function getActivityConfigs ( $ activity , $ config_path ) { $ configs = array ( ) ; if ( file_exists ( $ config_path ) ) { $ configs = require $ config_path ; } return isset ( $ configs [ $ activity ] ) ? $ configs [ $ activity ] : array ( ) ; }
Get the configs for a particular activity .
16,061
public function getActivityCount ( $ activity ) { $ plugin_activities = $ this -> getPluginActivities ( ) ; return empty ( $ plugin_activities [ $ activity ] ) ? 0 : $ plugin_activities [ $ activity ] ; }
Get the count for an activity .
16,062
public function getPluginActivities ( ) { $ activities = $ this -> getActivities ( ) ; if ( ! isset ( $ activities [ $ this -> plugin ] ) ) { $ activities [ $ this -> plugin ] = array ( ) ; } return $ activities [ $ this -> plugin ] ; }
Get all activities for a plugin .
16,063
public function maybeAddRatingPrompt ( $ activity , $ config_path ) { $ added = false ; $ configs = $ this -> getActivityConfigs ( $ activity , $ config_path ) ; if ( isset ( $ configs [ 'threshold' ] ) && $ this -> getActivityCount ( $ activity ) >= $ configs [ 'threshold' ] ) { $ rating_prompt = new \ Boldgrid \ Libr...
Maybe add a rating prompt for an activity .
16,064
public function savePluginActivities ( $ plugin_activities ) { $ activities = $ this -> getActivities ( ) ; $ activities [ $ this -> plugin ] = $ plugin_activities ; return $ this -> saveActivities ( $ activities ) ; }
Save all activities for this plugin .
16,065
protected function cleanFormData ( array $ data ) { foreach ( $ data as $ key => $ value ) { if ( \ is_array ( $ value ) ) { $ data [ $ key ] = $ this -> cleanFormData ( $ value ) ; } elseif ( \ is_object ( $ value ) ) { unset ( $ data [ $ key ] ) ; } } return $ data ; }
Remove all objects in data because they are probably not serializable
16,066
public function addForm ( BaseForm $ form ) { $ formErrorInformation = $ this -> getSession ( ) -> getFormErrorInformation ( ) ; $ formFieldErrors = [ ] ; foreach ( $ form -> getForm ( ) -> getIterator ( ) as $ field ) { $ errors = $ field -> getErrors ( ) ; if ( \ count ( $ errors ) > 0 ) { $ formFieldErrors [ $ field...
Add a new form to the error form context
16,067
public function getForm ( $ formId , $ formClass , $ formType ) { if ( isset ( $ this -> store [ $ formClass . ":" . $ formType ] ) && $ this -> store [ $ formClass . ":" . $ formType ] instanceof BaseForm ) { return $ this -> store [ $ formClass . ":" . $ formType ] ; } $ formErrorInformation = $ this -> getSession ( ...
Check if the specified form has errors and return an instance of this form if it s the case .
16,068
public function clearForm ( BaseForm $ form ) { $ formErrorInformation = $ this -> getSession ( ) -> getFormErrorInformation ( ) ; $ formClass = \ get_class ( $ form ) . ':' . $ form -> getType ( ) ; if ( isset ( $ formErrorInformation [ $ formClass ] ) ) { unset ( $ formErrorInformation [ $ formClass ] ) ; $ this -> g...
Remove form from the saved form error information .
16,069
protected function cleanOutdatedFormErrorInformation ( ) { $ formErrorInformation = $ this -> getSession ( ) -> getFormErrorInformation ( ) ; if ( ! empty ( $ formErrorInformation ) ) { $ now = time ( ) ; foreach ( $ formErrorInformation as $ name => $ formData ) { if ( $ now - $ formData [ 'timestamp' ] > self :: FORM...
Remove obsolete form error information .
16,070
public function sendEmailToShopManagers ( $ messageCode , $ messageParameters = [ ] , $ replyTo = [ ] ) { $ storeName = ConfigQuery :: getStoreName ( ) ; $ recipients = ConfigQuery :: getNotificationEmailsList ( ) ; $ to = [ ] ; foreach ( $ recipients as $ recipient ) { $ to [ $ recipient ] = $ storeName ; } $ this -> ...
Send a message to the shop managers .
16,071
public function createEmailMessage ( $ messageCode , $ from , $ to , $ messageParameters = [ ] , $ locale = null , $ cc = [ ] , $ bcc = [ ] , $ replyTo = [ ] ) { if ( null !== $ message = MessageQuery :: getFromName ( $ messageCode ) ) { if ( $ locale === null ) { $ locale = Lang :: getDefaultLanguage ( ) -> getLocale ...
Create a SwiftMessage instance from a given message code .
16,072
public function createSimpleEmailMessage ( $ from , $ to , $ subject , $ htmlBody , $ textBody , $ cc = [ ] , $ bcc = [ ] , $ replyTo = [ ] ) { $ instance = $ this -> getMessageInstance ( ) ; $ this -> setupMessageHeaders ( $ instance , $ from , $ to , $ cc , $ bcc , $ replyTo ) ; $ instance -> setSubject ( $ subject )...
Create a SwiftMessage instance from text
16,073
public function create ( TemplateCreateEvent $ event , $ eventName , EventDispatcherInterface $ dispatcher ) { $ template = new TemplateModel ( ) ; $ template -> setDispatcher ( $ dispatcher ) -> setLocale ( $ event -> getLocale ( ) ) -> setName ( $ event -> getTemplateName ( ) ) -> save ( ) ; $ event -> setTemplate ( ...
Create a new template entry
16,074
public function duplicate ( TemplateDuplicateEvent $ event , $ eventName , EventDispatcherInterface $ dispatcher ) { if ( null !== $ source = TemplateQuery :: create ( ) -> findPk ( $ event -> getSourceTemplateId ( ) ) ) { $ source -> setLocale ( $ event -> getLocale ( ) ) ; $ createEvent = new TemplateCreateEvent ( ) ...
Dupliucate an existing template entry
16,075
public function update ( TemplateUpdateEvent $ event , $ eventName , EventDispatcherInterface $ dispatcher ) { if ( null !== $ template = TemplateQuery :: create ( ) -> findPk ( $ event -> getTemplateId ( ) ) ) { $ template -> setDispatcher ( $ dispatcher ) -> setLocale ( $ event -> getLocale ( ) ) -> setName ( $ event...
Change a product template
16,076
public function delete ( TemplateDeleteEvent $ event , $ eventName , EventDispatcherInterface $ dispatcher ) { if ( null !== ( $ template = TemplateQuery :: create ( ) -> findPk ( $ event -> getTemplateId ( ) ) ) ) { $ productCount = ProductQuery :: create ( ) -> findByTemplateId ( $ template -> getId ( ) ) -> count ( ...
Delete a product template entry
16,077
public function autodiscover ( ) : void { $ entityMappings = [ ] ; foreach ( $ this -> fileSystem -> getEntityDirectories ( ) as $ entityDirectory ) { $ namespace = $ this -> namespaceDetector -> detectFromDirectory ( $ entityDirectory ) ; if ( ! $ namespace ) { continue ; } $ entityMappings [ ] = [ 'name' => $ namespa...
Needs to run before
16,078
protected function createFormDataArray ( $ object ) { return array ( "label" => $ object -> getLabel ( ) , "title" => $ object -> getTitleId ( ) , "firstname" => $ object -> getFirstname ( ) , "lastname" => $ object -> getLastname ( ) , "address1" => $ object -> getAddress1 ( ) , "address2" => $ object -> getAddress2 (...
Fills in the form data array
16,079
protected function renderEditionTemplate ( ) { return $ this -> render ( 'customer-edit' , array ( "address_id" => $ this -> getRequest ( ) -> get ( 'address_id' ) , "page" => $ this -> getRequest ( ) -> get ( 'page' ) , "customer_id" => $ this -> getCustomerId ( ) ) ) ; }
Render the edition template
16,080
public function renderToolTemplateHeaderRefreshAction ( ) { $ melisKey = $ this -> params ( ) -> fromRoute ( 'melisKey' , '' ) ; $ view = new ViewModel ( ) ; $ view -> melisKey = $ melisKey ; return $ view ; }
Renders the refresh button into the Header section of the Tool
16,081
public function renderToolTemplateContentFiltersSitesAction ( ) { $ translator = $ this -> getServiceLocator ( ) -> get ( 'translator' ) ; $ siteTable = $ this -> getServiceLocator ( ) -> get ( 'MelisEngineTableSite' ) ; $ sites = array ( ) ; $ sites [ ] = '<option value="">' . $ translator -> translate ( 'tr_meliscms_...
Renders to the site filter selection in the filter bar in the datatable
16,082
public function renderToolTemplatesModalAddHandlerAction ( ) { $ melisKey = $ this -> params ( ) -> fromRoute ( 'melisKey' , '' ) ; $ melisTool = $ this -> getServiceLocator ( ) -> get ( 'MelisCoreTool' ) ; $ melisTool -> setMelisToolKey ( 'meliscms' , 'meliscms_tool_templates' ) ; $ view = new ViewModel ( ) ; $ view -...
Renders the Add Tab and Content for the modal
16,083
public function renderToolTemplatesModalEditHandlerAction ( ) { $ melisKey = $ this -> params ( ) -> fromRoute ( 'melisKey' , '' ) ; $ melisTool = $ this -> getServiceLocator ( ) -> get ( 'MelisCoreTool' ) ; $ melisTool -> setMelisToolKey ( 'meliscms' , 'meliscms_tool_templates' ) ; $ view = new ViewModel ( ) ; $ view ...
Renders the Update Tab and Content for the modal
16,084
public function renderToolTemplatesModalEmptyHandlerAction ( ) { $ melisKey = $ this -> params ( ) -> fromRoute ( 'melisKey' , '' ) ; $ view = new ViewModel ( ) ; $ view -> melisKey = $ melisKey ; return $ view ; }
Handles the empty modal if there s no available modal form for the user .
16,085
public function modalTabToolTemplateAddAction ( ) { $ melisTool = $ this -> getServiceLocator ( ) -> get ( 'MelisCoreTool' ) ; $ melisTool -> setMelisToolKey ( 'meliscms' , 'meliscms_tool_templates' ) ; $ view = new ViewModel ( ) ; $ view -> setVariable ( 'meliscms_tool_template_add' , $ melisTool -> getForm ( 'meliscm...
This will be used to render the add form in the modal tab
16,086
public function getTemplateByPageIdAction ( ) { $ success = 0 ; $ request = $ this -> getRequest ( ) ; $ data = array ( ) ; if ( $ request -> isPost ( ) ) { $ template = $ this -> getServiceLocator ( ) -> get ( "MelisPageTemplate" ) ; $ success = 2 ; $ data = $ template -> getTemplate ( $ pageId ) ; } return $ data ; }
Return template of a page
16,087
protected function getControllers ( string $ controllersPath ) : array { $ controllers = [ ] ; if ( is_dir ( $ controllersPath ) ) { foreach ( scandir ( $ controllersPath ) as $ controller ) { if ( $ controller == '.' || $ controller == '..' || is_dir ( $ controllersPath . '/' . $ controller ) ) { continue ; } $ filePa...
Returns a module s controllers
16,088
public function getTemplateDataByIdAction ( ) { $ request = $ this -> getRequest ( ) ; $ data = array ( ) ; if ( $ request -> isPost ( ) ) { $ templatesModel = $ this -> getServiceLocator ( ) -> get ( 'MelisEngineTableTemplate' ) ; $ templateId = $ request -> getPost ( 'templateId' ) ; if ( is_numeric ( $ templateId ) ...
Returns all information of the specific template data
16,089
public function ajaxClear ( ) { $ plugin = ! empty ( $ _POST [ 'plugin' ] ) ? sanitize_text_field ( $ _POST [ 'plugin' ] ) : null ; if ( empty ( $ plugin ) ) { wp_send_json_error ( __ ( 'Unknown plugin.' , 'boldgrid-library' ) ) ; } if ( ! current_user_can ( 'manage_options' ) ) { wp_send_json_error ( __ ( 'Access deni...
Handle ajax request to clear license data .
16,090
public function registerScripts ( ) { $ handle = 'bglib-license' ; wp_register_script ( $ handle , Library \ Configs :: get ( 'libraryUrl' ) . 'src/assets/js/license.js' , 'jQuery' ) ; $ translations = array ( 'unknownError' => __ ( 'Unknown error' , 'boldgrid-library' ) , ) ; wp_localize_script ( $ handle , 'bglibLice...
Register scripts .
16,091
private function setLicense ( ) { if ( ! $ this -> getApiKey ( ) ) { $ license = 'Missing Connect Key' ; } else if ( ! ( $ license = $ this -> getTransient ( ) ) || ! $ this -> isVersionValid ( $ license ) ) { delete_site_transient ( $ this -> getKey ( ) ) ; $ license = $ this -> getRemoteLicense ( ) ; } return $ this ...
Set the license class property .
16,092
private function setTransient ( ) { return ! $ this -> getTransient ( ) && set_site_transient ( $ this -> getKey ( ) , $ this -> getLicense ( ) , $ this -> getExpiration ( $ this -> getData ( ) ) ) ; }
Sets the transient for the license data .
16,093
private function isValid ( ) { $ data = $ this -> getTransient ( ) ; $ valid = array ( 'key' , 'cipher' , 'iv' , 'data' ) ; if ( is_object ( $ data ) ) { $ props = array_keys ( get_object_vars ( $ data ) ) ; $ valid = array_diff ( $ valid , $ props ) ; } return empty ( $ valid ) ; }
Check if the current license is valid .
16,094
private function setData ( ) { if ( $ license = $ this -> getLicense ( ) ) { $ data = json_decode ( openssl_decrypt ( $ license -> data , $ license -> cipher , $ license -> key , 0 , urldecode ( $ license -> iv ) ) ) ; } return $ this -> data = $ data ; }
Set the data class property .
16,095
public function deactivate ( ) { if ( ! $ this -> isValid ( ) && Configs :: get ( 'licenseActivate' ) ) { delete_site_transient ( $ this -> getKey ( ) ) ; deactivate_plugins ( Configs :: get ( 'file' ) ) ; } }
Runs plugin deactivation when deactivate_plugins is available .
16,096
private function getRemoteLicense ( ) { $ call = new Api \ Call ( Configs :: get ( 'api' ) . '/api/plugin/getLicense?v=' . $ this -> apiVersion ) ; if ( ! $ response = $ call -> getError ( ) ) { $ response = $ call -> getResponse ( ) -> result -> data ; } return $ response ; }
Get the latest license data from the API server .
16,097
public function initLicense ( ) { $ this -> license = $ this -> setLicense ( ) ; if ( is_object ( $ this -> getLicense ( ) ) ) { $ this -> data = $ this -> setData ( ) ; $ this -> setTransient ( $ this -> getData ( ) ) ; $ licenseData = array ( 'licenseData' => $ this -> getData ( ) ) ; Configs :: set ( $ licenseData ,...
Init the license .
16,098
public function isPremium ( $ product ) { $ isPremium = isset ( $ this -> getData ( ) -> $ product ) ; $ this -> licenseString = $ isPremium ? __ ( 'Premium' , 'boldgrid-connect' ) : __ ( 'Free' , 'boldgrid-library' ) ; return $ isPremium ; }
Checks if product is premium or free .
16,099
public function isVersionValid ( $ license ) { return ( ! empty ( $ license -> version ) && ! empty ( $ license -> iv ) && 16 === strlen ( urldecode ( $ license -> iv ) ) && $ this -> apiVersion === $ license -> version ) ; }
Check if the license version and encoding is correct .