Skip to content
General Revolution Evolution Add-ons International
Login | Register | MODX.com
MODX Open Source Content Management System, Framework, Platform and More.
Find a Partner | Hosts + SaaS | Jobs | Donate
  • RegisterSign Up with the MODX Community
  • LoginUse Your MODX.com Account
  • MODX Community Forums
  • Add-ons
  • Manager, Parser & the Core
  • YAMS
  •  
  • <
  • 1
  • 2
  • >
  • Integrating YAMS with Easy 2 Gallery#

  • 11055
    2,536
    Rico
    Genius is one percent inspiration and ninety-nine percent perspiration. Thomas A. Edison MODx is great, but knowing how to use it well makes it perfect!
    Security, security, security!
    Indonesia MODx Forum
    MODx Revo's cheatsheets
    MODx Evo's cheatsheets
    IE 6 must die !
    Easy 2 Gallery 1.4.x
    spiefeed
    Tutorial links
    PING ME ON TWITTER @_goldsky

    goldsky Reply #1, 1 year, 11 months ago

    Reply
    • Link to this post#1
    Hello PMS,

    Recently, someone asked me about multilangual ability in Easy 2 Gallery.
    The first thought in my mind was about integrating the YAMS and E2G.
    One thing you should realized is that E2G does not have any relation to the document parsing data, while YAMS runs on it.
    E2G's snippet retrieves all data from its own database.

    I've dug the YAMS's code, and it seems that all the language configurations are stored inside the yams.config.inc.php, which is called by the yams.class.inc.php (Initialise() function).

    I do not need more field in YAMS's module.
    What I'd like to ask is that will you get YAMS provides some CONSTANT values, so when E2G sniffs:
    if(defined(YAMS_CONSTANT_...))

    then the E2G's snippet will make the language conversion itself.
    If you don't mind to do that, then it will be easier for snippets like E2G to integrate the language selection trigger.

    From what I can feel right now, the priority constants are (the names are only to desribe my thought):
      [list]
    • ..._LANGS_LIST
    • ..._LANGS_ACTIVE
    • ..._LANGS_DEFAULT
    [/list]

    If you can provide these, then I can set E2G's module to have more language fields according to that options.

    What do you think?


  • 22851
    805
    YAMS: Yet Another Multilingual Solution for MODx
    YAMS Forums | Latest: YAMS 1.1.9 | YAMS Documentation
    Please consider donating if you appreciate the time and effort spent developing and supporting YAMS.

    PaulSuckling Reply #2, 1 year, 11 months ago

    Reply
    • Link to this post#2
    The best way to get the information you want is to use the getters on the YAMS class:
    global $modx;
    require( $modx->config['base_path'] . 'assets/modules/yams/class/yams.class.inc.php');
    // get an instance of the YAMS singleton class
    $yams = YAMS::GetInstance();
    // get an array of activated language ids
    $activeLangIds = $yams->GetActiveLangIds();
    // get an array of defined but disabled language ids
    $inactiveLangIds = $yams->GetInactiveLangIds();
    // get an array of all language ids
    $allLangIds = array_merge( $activeLangIds, $inactiveLangIds );
    // get the default language id
    $defaultLangId = $yams->GetDefaultLangId();
    

    Not sure about defining constants; they aren't constant since the user can update the configuration and change them.


  • 11055
    2,536
    Rico
    Genius is one percent inspiration and ninety-nine percent perspiration. Thomas A. Edison MODx is great, but knowing how to use it well makes it perfect!
    Security, security, security!
    Indonesia MODx Forum
    MODx Revo's cheatsheets
    MODx Evo's cheatsheets
    IE 6 must die !
    Easy 2 Gallery 1.4.x
    spiefeed
    Tutorial links
    PING ME ON TWITTER @_goldsky

    goldsky Reply #3, 1 year, 11 months ago

    Reply
    • Link to this post#3
    OK,
    I'll try it in my public class, then.


  • 28042
    15,113
    How MODx Evo Works

    Log in to an Evo Manager username guest, password guestuser.

    sottwell Reply #4, 1 year, 11 months ago

    Reply
    • Link to this post#4
    Not sure about defining constants; they aren't constant since the user can update the configuration and change them.
    That's not what makes a constant; and they are properly called "constant variables", which should give the idea that while they can be changed, they aren't easily changed.

    The whole point is to have a variable value that can't be changed programmatically by accident. It can be changed in configuration or by editing the code (I suppose changing a config file is editing the code), but not during run-time. Well, it could be by having code to re-define it, but you get the general idea.

    If the user updates the configuration, then the next time the script is run the constant variable would have the new value, but it wouldn't change during the run of the script.


  • 22851
    805
    YAMS: Yet Another Multilingual Solution for MODx
    YAMS Forums | Latest: YAMS 1.1.9 | YAMS Documentation
    Please consider donating if you appreciate the time and effort spent developing and supporting YAMS.

    PaulSuckling Reply #5, 1 year, 11 months ago

    Reply
    • Link to this post#5
    Hi Sottwell.

    I do understand what you are saying. I normally use PHP's define to define 'true' constants that are potentially shared between multiple source files/classes and instead use attributes/access control on class members/methods to prevent users from changing values they shouldn't where possible. However, in certain circumstances defined constants can also be used for extra protection from alteration, like you say.

    One problem that arises in this instance is that arrays can't be declared as defined constants. This can be overcome however, by defining a serialized string representation of the array, but this would require the user to unserialize it first. At this point it becomes a standard variable which could be altered and so it's questionable how much added protection is actually being provided by this method.

    Nevertheless, to my development version of YAMS, available via svn from from svn://nashi.podzone.org/yams/trunk/, I have added a file assets/modules/yams/yams.constants.inc.php. This file can be require_once'd in order to define the following four constants that can be accessed as folllows:

    unserialize(YAMS_ACTIVE_LANG_IDS_SERIALIZED)
    unserialize(YAMS_INACTIVE_LANG_IDS_SERIALIZED)
    unserialize(YAMS_ALL_LANG_IDS_SERIALIZED)
    YAMS_DEFAULT_LANG_ID

    If anyone knows of a better way of defining constant arrays, I'd be happy to hear it. Cheers.


  • 11055
    2,536
    Rico
    Genius is one percent inspiration and ninety-nine percent perspiration. Thomas A. Edison MODx is great, but knowing how to use it well makes it perfect!
    Security, security, security!
    Indonesia MODx Forum
    MODx Revo's cheatsheets
    MODx Evo's cheatsheets
    IE 6 must die !
    Easy 2 Gallery 1.4.x
    spiefeed
    Tutorial links
    PING ME ON TWITTER @_goldsky

    goldsky Reply #6, 1 year, 11 months ago

    Reply
    • Link to this post#6
    you can look how SMF prepares CONSTANTs for CMS integration:
    http://www.simplemachines.org/community/index.php?topic=173483.0


  • 22851
    805
    YAMS: Yet Another Multilingual Solution for MODx
    YAMS Forums | Latest: YAMS 1.1.9 | YAMS Documentation
    Please consider donating if you appreciate the time and effort spent developing and supporting YAMS.

    PaulSuckling Reply #7, 1 year, 11 months ago

    Reply
    • Link to this post#7
    Thanks for the link. SMF uses the same approach to defining object-based constants; serialize. However, it combines all its constants into a single array rather than one constant for each parameter. I can set it up in whichever way you prefer.


  • 11055
    2,536
    Rico
    Genius is one percent inspiration and ninety-nine percent perspiration. Thomas A. Edison MODx is great, but knowing how to use it well makes it perfect!
    Security, security, security!
    Indonesia MODx Forum
    MODx Revo's cheatsheets
    MODx Evo's cheatsheets
    IE 6 must die !
    Easy 2 Gallery 1.4.x
    spiefeed
    Tutorial links
    PING ME ON TWITTER @_goldsky

    goldsky Reply #8, 1 year, 11 months ago

    Reply
    • Link to this post#8
    I think it's better single constant with array.
    Easier to debug.


  • 22851
    805
    YAMS: Yet Another Multilingual Solution for MODx
    YAMS Forums | Latest: YAMS 1.1.9 | YAMS Documentation
    Please consider donating if you appreciate the time and effort spent developing and supporting YAMS.

    PaulSuckling Reply #9, 1 year, 11 months ago

    Reply
    • Link to this post#9
    I've updated my RC1 development version of YAMS.

    It now includes a file assets/modules/yams/yams.integration.inc.php that defines a single serialized constant to help integration of YAMS with other software with multilingual capabilities, such as Easy 2 Gallery

    To use, require the file at the top of the relevant PHP source file and a constant called YAMS_INTEGRATION_SETTINGS will be defined containing a 'serialized' array of YAMS configuration parameters.

    The array must be unserialised before use. So, for example:
      require_once "....../assets/modules/yams/yams.integration.inc.php"
      $yamsParams = unserialize(YAMS_INTEGRATION_SETTINGS);
      // an array of language ids for languages which are defined
      // and activated
      $yamsParams['active_lang_ids']
      // an array of language ids for languages which are defined
      // but not activated
      $yamsParams['inactive_lang_ids']
      // an array of language ids for all languages
      $yamsParams['all_lang_ids']
      // the default language id
      $yamsParams['default_lang_id']
    


  • 11055
    2,536
    Rico
    Genius is one percent inspiration and ninety-nine percent perspiration. Thomas A. Edison MODx is great, but knowing how to use it well makes it perfect!
    Security, security, security!
    Indonesia MODx Forum
    MODx Revo's cheatsheets
    MODx Evo's cheatsheets
    IE 6 must die !
    Easy 2 Gallery 1.4.x
    spiefeed
    Tutorial links
    PING ME ON TWITTER @_goldsky

    goldsky Reply #10, 1 year, 11 months ago

    Reply
    • Link to this post#10
    PMS, just a consideration, try to use <link /> rather than <link></link>, and

    Now, I'm starting to connect these out.
    I will surely ask you for some more questions.


  • <
  • 1
  • 2
  • >



Actions

Login to Post

Other Support Options

To file a bug or make a feature request visit our issue tracker, or you can also purchase commercial support.

Love MODX?

If you build sites for a living with MODX or just love using it, why not give back?

Information

Posted in this thread:
Mproject, PaulSuckling, goldsky, sottwell

 
Back to Top

MODX Global HQ

1333 N Stemmons Fwy, Ste 110
Dallas, TX 75207
United States

+1 (469) 777-MODX (6639)

The MODX Company

  • Contact
  • Media Center
  • Careers at MODX
  • Wall of Fame
  • The MODX Blog

Sponsors

SoftLayer Firehost: Secure Cloud Hosting

Stay Connected

Read our previous email newsletters.

Twitter Facebook Google+ LinkedIn github Feeds

Privacy Policy | Terms of Service | Pixels by AKTA Web Studio© 2005-2012 MODX. All rights reserved. Trademark Policy