| 1 |  |  | <?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  | /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  |  * File containing the {@see Mailcode_Commands_Command_Comment} class. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  |  * @package Mailcode | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  |  * @subpackage Commands | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  |  * @see Mailcode_Commands_Command_Comment | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  |  */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  | declare(strict_types=1); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  | namespace Mailcode; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 14 |  |  | /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 15 |  |  |  * Mailcode command: Add a comment. | 
            
                                                                                                            
                            
            
                                    
            
            
                | 16 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 17 |  |  |  * @package Mailcode | 
            
                                                                                                            
                            
            
                                    
            
            
                | 18 |  |  |  * @subpackage Commands | 
            
                                                                                                            
                            
            
                                    
            
            
                | 19 |  |  |  * @author Sebastian Mordziol <[email protected]> | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 20 |  |  |  */ | 
            
                                                                        
                            
            
                                    
            
            
                | 21 |  |  | class Mailcode_Commands_Command_Comment extends Mailcode_Commands_Command implements Mailcode_Commands_Command_Type_Standalone | 
            
                                                                        
                            
            
                                    
            
            
                | 22 |  |  | { | 
            
                                                                        
                            
            
                                    
            
            
                | 23 |  |  |    /** | 
            
                                                                        
                            
            
                                    
            
            
                | 24 |  |  |     * @var string | 
            
                                                                        
                            
            
                                    
            
            
                | 25 |  |  |     */ | 
            
                                                                        
                            
            
                                    
            
            
                | 26 |  |  |     private $commentString = ''; | 
            
                                                                        
                            
            
                                    
            
            
                | 27 |  |  |      | 
            
                                                                                                            
                            
            
                                    
            
            
                | 28 |  |  |     protected function init() : void | 
            
                                                                                                            
                            
            
                                    
            
            
                | 29 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 30 |  |  |         $this->commentString = trim(trim($this->paramsString), '"'); | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 31 |  |  |         $this->commentString = str_replace('\"', '"', $this->commentString); | 
            
                                                                        
                            
            
                                    
            
            
                | 32 |  |  |     } | 
            
                                                                        
                            
            
                                    
            
            
                | 33 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 34 |  |  |     public function hasFreeformParameters() : bool | 
            
                                                                        
                            
            
                                    
            
            
                | 35 |  |  |     { | 
            
                                                                        
                            
            
                                    
            
            
                | 36 |  |  |         return true; | 
            
                                                                        
                            
            
                                    
            
            
                | 37 |  |  |     } | 
            
                                                                        
                            
            
                                    
            
            
                | 38 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 39 |  |  |     public function getName() : string | 
            
                                                                        
                            
            
                                    
            
            
                | 40 |  |  |     { | 
            
                                                                        
                            
            
                                    
            
            
                | 41 |  |  |         return 'comment'; | 
            
                                                                        
                            
            
                                    
            
            
                | 42 |  |  |     } | 
            
                                                                        
                            
            
                                    
            
            
                | 43 |  |  |      | 
            
                                                                        
                            
            
                                    
            
            
                | 44 |  |  |     public function getLabel() : string | 
            
                                                                        
                            
            
                                    
            
            
                | 45 |  |  |     { | 
            
                                                                        
                            
            
                                    
            
            
                | 46 |  |  |         return t('Add a comment'); | 
            
                                                                        
                            
            
                                    
            
            
                | 47 |  |  |     } | 
            
                                                                        
                            
            
                                    
            
            
                | 48 |  |  |      | 
            
                                                                        
                            
            
                                    
            
            
                | 49 |  |  |     public function supportsType(): bool | 
            
                                                                        
                            
            
                                    
            
            
                | 50 |  |  |     { | 
            
                                                                        
                            
            
                                    
            
            
                | 51 |  |  |         return false; | 
            
                                                                        
                            
            
                                    
            
            
                | 52 |  |  |     } | 
            
                                                                        
                            
            
                                    
            
            
                | 53 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 54 |  |  |     public function supportsURLEncoding(): bool | 
            
                                                                        
                            
            
                                    
            
            
                | 55 |  |  |     { | 
            
                                                                        
                            
            
                                    
            
            
                | 56 |  |  |         return false; | 
            
                                                                        
                            
            
                                    
            
            
                | 57 |  |  |     } | 
            
                                                                        
                            
            
                                    
            
            
                | 58 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 59 |  |  |     public function getDefaultType() : string | 
            
                                                                        
                            
            
                                    
            
            
                | 60 |  |  |     { | 
            
                                                                        
                            
            
                                    
            
            
                | 61 |  |  |         return ''; | 
            
                                                                        
                            
            
                                    
            
            
                | 62 |  |  |     } | 
            
                                                                        
                            
            
                                    
            
            
                | 63 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 64 |  |  |     public function requiresParameters(): bool | 
            
                                                                        
                            
            
                                    
            
            
                | 65 |  |  |     { | 
            
                                                                        
                            
            
                                    
            
            
                | 66 |  |  |         return true; | 
            
                                                                        
                            
            
                                    
            
            
                | 67 |  |  |     } | 
            
                                                                        
                            
            
                                    
            
            
                | 68 |  |  |      | 
            
                                                                                                            
                            
            
                                    
            
            
                | 69 |  |  |     public function supportsLogicKeywords() : bool | 
            
                                                                                                            
                            
            
                                    
            
            
                | 70 |  |  |     { | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 71 |  |  |         return false; | 
            
                                                                        
                                                                
            
                                    
            
            
                | 72 |  |  |     } | 
            
                                                                        
                                                                
            
                                    
            
            
                | 73 |  |  |  | 
            
                                                                        
                                                                
            
                                    
            
            
                | 74 |  |  |     protected function getValidations() : array | 
            
                                                                        
                                                                
            
                                    
            
            
                | 75 |  |  |     { | 
            
                                                                        
                                                                
            
                                    
            
            
                | 76 |  |  |         return array( | 
            
                                                                        
                                                                
            
                                    
            
            
                | 77 |  |  |             'comment' | 
            
                                                                        
                                                                
            
                                    
            
            
                | 78 |  |  |         ); | 
            
                                                                        
                                                                
            
                                    
            
            
                | 79 |  |  |     } | 
            
                                                                        
                            
            
                                    
            
            
                | 80 |  |  |      | 
            
                                                                        
                            
            
                                    
            
            
                | 81 |  |  |     public function generatesContent() : bool | 
            
                                                                        
                            
            
                                    
            
            
                | 82 |  |  |     { | 
            
                                                                        
                            
            
                                    
            
            
                | 83 |  |  |         return false; | 
            
                                                                        
                            
            
                                    
            
            
                | 84 |  |  |     } | 
            
                                                                        
                            
            
                                    
            
            
                | 85 |  |  |      | 
            
                                                                        
                            
            
                                    
            
            
                | 86 |  |  |     public function getCommentString() : string | 
            
                                                                        
                            
            
                                    
            
            
                | 87 |  |  |     { | 
            
                                                                        
                            
            
                                    
            
            
                | 88 |  |  |         return $this->commentString; | 
            
                                                                        
                            
            
                                    
            
            
                | 89 |  |  |     } | 
            
                                                                        
                            
            
                                    
            
            
                | 90 |  |  |      | 
            
                                                                                                            
                            
            
                                    
            
            
                | 91 |  |  |     protected function validateSyntax_comment() : void | 
            
                                                                                                            
                            
            
                                    
            
            
                | 92 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 93 |  |  |         if(empty($this->commentString)) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 94 |  |  |         { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 95 |  |  |             $this->validationResult->makeError( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 96 |  |  |                 t('The comment text ist empty.'), | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 97 |  |  |                 Mailcode_Commands_CommonConstants::VALIDATION_COMMENT_MISSING | 
            
                                                                        
                                                                
            
                                    
            
            
                | 98 |  |  |             ); | 
            
                                                                        
                                                                
            
                                    
            
            
                | 99 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 100 |  |  |     } | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 101 |  |  | } | 
            
                                                        
            
                                    
            
            
                | 102 |  |  |  |