| Author |  | 
      
        | mcoelho80 Newbie
 
  
 
 Joined: 03 April 2014
 Location: Brazil
 Online Status: Offline
 Posts: 28
 | 
          Hi,
           | Posted: 09 April 2014 at 6:10am | IP Logged |   |  
           | 
 |  
 I'm writing a plugin that will add a setting tab with another set of tabs:
 http://picpaste.com/Screen_Shot_2014-04-09_at_10.05.11_AM-6wk8cj3E.png
 
 I noticed that AppData and Utils javascript objects aren't available when I try to call them from a plugin .js file:
 
 Example
 
 CAntiSpamSettings.prototype.TabTitle = Utils.i18n('PLUGINS/ANTISPAM_TITLE');
 
 The same code above works if used in app.js file.
 
 How to make AppData and Utils objects available to plugin scripts?
 
 Thank you in advance.
 | 
       
        | Back to Top |     | 
       
       
        |  | 
        | Igor AfterLogic Support
 
  
 
 Joined: 24 June 2008
 Location: United States
 Online Status: Offline
 Posts: 6168
 | 
          We certainly agree that i18n function should be available to plugins. To enable that, insert the following code to app.js file:
           | Posted: 10 April 2014 at 2:53am | IP Logged |   |  
           | 
 |  
 
 
| Code: 
 
    
    | 
      
       | /** * @param {string} sKey
 * @param {?Object=} oValueList
 * @param {?string=} sDefaultValue
 * @param {number=} nPluralCount
 *
 * @return {string}
 */
 AfterLogicApi.i18n = function (sKey, oValueList, sDefaultValue, nPluralCount)
 {
 return Utils.i18n(sKey);
 };
 |  |  |  
 It's recommended to insert it somewhere after this:
 
 
 
| Code: 
 
    
    | 
      
       | /** * @param {string} sRecipients
 *
 * @return {Array}
 */
 
 AfterLogicApi.getArrayRecipients = function (sRecipients)
 {
 return Utils.getArrayRecipients(sRecipients);
 };
 |  |  |  
 Of course, this will be included in next product update.
 
 For security reasons, we believe plugins shouldn't have access to entire AppData and Utils objects available. But if you need some particular properties or method available externally, that can be done similarly to the above item.
 
 --
 Regards,
 Igor, AfterLogic Support
 | 
       
        | Back to Top |     | 
       
       
        |  | 
        | mcoelho80 Newbie
 
  
 
 Joined: 03 April 2014
 Location: Brazil
 Online Status: Offline
 Posts: 28
 | 
          Thank you for your response.
           | Posted: 11 April 2014 at 2:26pm | IP Logged |   |  
           | 
 |  
 You could create a method to allow a plugin specify an extra language directory to be processed.
 
 That would help us to create a multi-language plugin without having to modify the main language files directly, making the webmail easier to get updates in the future.
 
 | 
       
        | Back to Top |     | 
       
       
        |  | 
        | Igor AfterLogic Support
 
  
 
 Joined: 24 June 2008
 Location: United States
 Online Status: Offline
 Posts: 6168
 | 
          Sure, I've forwarded the suggestion to the developers team, they will consider adding that in subsequent releases.
           | Posted: 14 April 2014 at 4:35am | IP Logged |   |  
           | 
 |  
 --
 Regards,
 Igor, AfterLogic Support
 | 
       
        | Back to Top |     | 
       
       
        |  | 
        | whuhacker Newbie
 
  
 
 Joined: 12 May 2014
 Location: Hong Kong
 Online Status: Offline
 Posts: 10
 | 
          Is plugin language directory added to version 7.3?
           | Posted: 14 May 2014 at 2:35am | IP Logged |   |  
           | 
 |  | 
       
        | Back to Top |     | 
       
       
        |  | 
        | Igor AfterLogic Support
 
  
 
 Joined: 24 June 2008
 Location: United States
 Online Status: Offline
 Posts: 6168
 | 
          No, that wasn't added to it, will probably become available in next version.
           | Posted: 14 May 2014 at 2:40am | IP Logged |   |  
           | 
 |  
 --
 Regards,
 Igor, AfterLogic Support
 | 
       
        | Back to Top |     | 
       
       
        |  | 
        | whuhacker Newbie
 
  
 
 Joined: 12 May 2014
 Location: Hong Kong
 Online Status: Offline
 Posts: 10
 | 
          
           | Posted: 14 May 2014 at 7:11pm | IP Logged |   |  
           | 
 |  
| Igor wrote: 
 
    
    | 
      
       | No, that wasn't added to it, will probably become available in next version. 
 |  |  |  Could you post the plugin folder structure while the i18n is ready? I want my codebase be compatible with the future updates.
 
 Currently my plugin folder is
 antispam-setting/
 ├── index.php
 ├── js
 │   ├── antispamSetting.js
 │   └── include.js
 └── templates
 └── antispamSetting.html
 
 Will it be the following?
 antispam-setting/
 ├── index.php
 ├── js
 │   ├── antispamSetting.js
 │   └── include.js
 └── templates
 └── antispamSetting.html
 └── i18n
 └── English.ini
 └── French.ini
 
 | 
       
        | Back to Top |     | 
       
       
        |  | 
        | Igor AfterLogic Support
 
  
 
 Joined: 24 June 2008
 Location: United States
 Online Status: Offline
 Posts: 6168
 | 
          Sorry, I've rechecked that and looks like the feature is there in 7.3 indeed. Shortly we'll publish a sample plugin which demonstrates how to set different texts based on the current interface language, the key property is set in the plugin as follows:
           | Posted: 14 May 2014 at 11:48pm | IP Logged |   |  
           | 
 |  
 
 
 and method used for getting localized text is AfterLogicApi.i18n('text-constant-name').
 
 And yes, it's i18n subdirectory with language-name.ini files there.
 
 --
 Regards,
 Igor, AfterLogic Support
 | 
       
        | Back to Top |     | 
       
       
        |  | 
        | whuhacker Newbie
 
  
 
 Joined: 12 May 2014
 Location: Hong Kong
 Online Status: Offline
 Posts: 10
 | 
          Igor, thanks for your reply. Looking forward to the sample plugin.
           | Posted: 15 May 2014 at 2:44am | IP Logged |   |  
           | 
 |  
 I would also like to know what is the proper way to post form data to server with my plugin, and how plugin's php script can get such form data. It looks like that you are using frontend MVC framework, which is not quite straight forward. More documentation and sample code is in great need.
 
 Thank you so much.
 | 
       
        | Back to Top |     | 
       
       
        |  | 
        | Igor AfterLogic Support
 
  
 
 Joined: 24 June 2008
 Location: United States
 Online Status: Offline
 Posts: 6168
 | 
          That kind of things is achieved by sending AJAX calls, and we plan to provide documentation on using AJAX in plugins in the near future.
           | Posted: 15 May 2014 at 2:49am | IP Logged |   |  
           | 
 |  
 Sample plugin demonstrating localization in plugins will probably become available later today or tomorrow.
 
 --
 Regards,
 Igor, AfterLogic Support
 | 
       
        | Back to Top |     | 
       
       
        |  | 
        | whuhacker Newbie
 
  
 
 Joined: 12 May 2014
 Location: Hong Kong
 Online Status: Offline
 Posts: 10
 | 
          Hi Igor, is the sample plugin ready?
           | Posted: 15 May 2014 at 7:33pm | IP Logged |   |  
           | 
 |  Where can I download it?
 | 
       
        | Back to Top |     | 
       
       
        |  | 
        | Igor AfterLogic Support
 
  
 
 Joined: 24 June 2008
 Location: United States
 Online Status: Offline
 Posts: 6168
 | 
          Yes, have just published it:
           | Posted: 15 May 2014 at 11:50pm | IP Logged |   |  
           | 
 |  
 Add and override language constants
 
 Hope it helps!
 
 --
 Regards,
 Igor, AfterLogic Support
 | 
       
        | Back to Top |     | 
       
       
        |  | 
        | whuhacker Newbie
 
  
 
 Joined: 12 May 2014
 Location: Hong Kong
 Online Status: Offline
 Posts: 10
 | 
          Excellent! It works and helps me a lot. Thanks a lot.
           | Posted: 16 May 2014 at 12:07am | IP Logged |   |  
           | 
 |  Looking forward to the AJAX form demo.
 | 
       
        | Back to Top |     | 
       
       
        |  | 
        | whuhacker Newbie
 
  
 
 Joined: 12 May 2014
 Location: Hong Kong
 Online Status: Offline
 Posts: 10
 | 
          Hi, I am able to make Ajax request with my plugin finally. The request looks like the following:
           | Posted: 18 May 2014 at 7:39pm | IP Logged |   |  
           | 
 |  
 Request URL:http://mydomain.com/aurora/?/Ajax/
 Request Method:POST
 Status Code:200 OK
 
 Form Data
 Action:UpdateAntispamUserSettings
 ReceiveReport:1
 ReportLanguage:1
 DeliveryAddress:1
 UsharkAntispam:1
 EnableAutoDelete:1
 AccountID:7
 Token:284551d6bb7091820cdbe2dd2e2f14a9
 
 
 However, I still don't know how to get such data with PHP code of plugin. Seems that I need add some hooks?
 
 Please help~ Thank you
 | 
       
        | Back to Top |     | 
       
       
        |  | 
        | Igor AfterLogic Support
 
  
 
 Joined: 24 June 2008
 Location: United States
 Online Status: Offline
 Posts: 6168
 | 
          Indeed, you'll need to add a hook, and new sample plugin shows how to achieve that.
           | Posted: 19 May 2014 at 4:34am | IP Logged |   |  
           | 
 |  
 --
 Regards,
 Igor, AfterLogic Support
 | 
       
        | Back to Top |     | 
       
       
        |  | 
        | whuhacker Newbie
 
  
 
 Joined: 12 May 2014
 Location: Hong Kong
 Online Status: Offline
 Posts: 10
 | 
          Thank you.
           | Posted: 20 May 2014 at 2:28am | IP Logged |   |  
           | 
 |  I found a bug that caused javascript error in the new plugin.
 
 "getAjaxData" in CAboutViewModel.js should be "getVersion".
 
 BTW, can I pass parameters to the callback function in AddJsonHook('hookName', 'callback')?
 | 
       
        | Back to Top |     | 
       
       
        |  | 
        | Igor AfterLogic Support
 
  
 
 Joined: 24 June 2008
 Location: United States
 Online Status: Offline
 Posts: 6168
 | 
          
           | Posted: 20 May 2014 at 2:41am | IP Logged |   |  
           | 
 |  
| Code: 
 
    
    | 
      
       | "getAjaxData" in CAboutViewModel.js should be "getVersion". |  |  |  
 Good point, thanks. Fixed.
 
 
 
| Code: 
 
    
    | 
      
       | can I pass parameters to the callback function in AddJsonHook('hookName', 'callback')? |  |  |  
 No, but you can pass data using properties of CAboutPlugin class.
 
 --
 Regards,
 Igor, AfterLogic Support
 | 
       
        | Back to Top |     | 
       
       
        |  | 
        | iSofia Newbie
 
  
  
 Joined: 24 May 2014
 Location: Singapore
 Online Status: Offline
 Posts: 35
 | 
          
           | Posted: 16 October 2014 at 9:50am | IP Logged |   |  
           | 
 |  
| Igor wrote: 
 
    
    | 
      
       | 
| Code: 
 
    
    | 
      
       | can I pass parameters to the callback function in AddJsonHook('hookName', 'callback')? |  |  |  No, but you can pass data using properties of CAboutPlugin class.
 |  |  |  Hello Igor. How do we pass values between JavaScript and the PHP class through properties? I tried setting up a public property in the PHP class:
 
 Then I tried setting it's value from JavaScript like this:
 
 
| Code: 
 
    
    | 
      
       | $this->classVar = "Hello"; |  |  |  but the class variable is not set.
 | 
       
        | Back to Top |     | 
       
       
        |  | 
        | Igor AfterLogic Support
 
  
 
 Joined: 24 June 2008
 Location: United States
 Online Status: Offline
 Posts: 6168
 | 
          It doesn't work that way, you'll need to use AJAX calls as shown here:
           | Posted: 17 October 2014 at 3:38am | IP Logged |   |  
           | 
 |  
 http://www.afterlogic.com/forum/forum_posts.asp?TID=5904
 
 --
 Regards,
 Igor, AfterLogic Support
 | 
       
        | Back to Top |     | 
       
       
        |  | 
        | iSofia Newbie
 
  
  
 Joined: 24 May 2014
 Location: Singapore
 Online Status: Offline
 Posts: 35
 | 
          
           | Posted: 17 October 2014 at 4:00am | IP Logged |   |  
           | 
 |  I know, it's embarrassing. Some of the other stuff that I've been trying out is even more embarrassing; in fact downright pathetic.
   
 Thank you.
 | 
       
        | Back to Top |     | 
       
       
        |  |