<?php
/*"******************************************************************************************************
*   (c) 2007-2013 by Kajona, www.kajona.de                                                              *
*       Published under the GNU LGPL v2.1, see /system/licence_lgpl.txt                                 *
*-------------------------------------------------------------------------------------------------------*
*	$Id: class_scriptlet_lang.php 5409 2012-12-30 13:09:07Z sidler $                               *
********************************************************************************************************/

/**
 * The lang-scriptlet may be used to embed language-file entries into a
 * template. The placeholder is replaced with the matching element from the lang-files.
 * Therefore, the following syntax may be used:
 *  [lang,title,module]
 *
 *
 * @package module_system
 * @since 4.0
 * @author sidler@mulchprod.de
 */
class class_scriptlet_lang implements interface_scriptlet {

    /**
     * Processes the content.
     * Make sure to return the string again, otherwise the output will remain blank.
     *
     * @param string $strContent
     *
     * @return string
     */
    public function processContent($strContent) {

        $objLang = class_carrier::getInstance()->getObjLang();

        $arrTemp = array();
        preg_match_all("#\[lang,([A-Za-z0-9_]+),([0-9A-Za-z_]+)\]#i", $strContent, $arrTemp);

        foreach($arrTemp[0] as $intKey => $strSearchString) {
            $strContent = uniStrReplace($strSearchString, $objLang->getLang($arrTemp[1][$intKey], $arrTemp[2][$intKey]), $strContent);
        }

        return $strContent;
    }

}
