Exemplo n.º 1
0
<?php

include 'classes/JwTranslations_TemplateHandler.php';
include 'classes/JwTranslations_Loader.php';
PerchSystem::register_template_handler('JwTranslations_TemplateHandler');
/**
 * Get translation string
 *
 * @param $id
 * @param array $opts
 * @param bool|false $return
 * @return array|mixed|null
 */
function get_translation($id, array $opts = array(), $return = false)
{
    $defaults = array('default' => null, 'lang' => PERCH_TRANSLATION_LANG, 'placeholders' => false);
    $opts = array_merge($defaults, $opts);
    $TranslationHelper = JwTranslations_Loader::fetch();
    $value_string = $TranslationHelper->get_translation($id, $opts['lang'], $opts['default']);
    if ($opts['placeholders']) {
        $s = '/:\\w+/';
        $count = preg_match_all($s, $value_string, $matches, PREG_SET_ORDER);
        if ($count > 0) {
            foreach ($matches as $match) {
                $replacement = $match[0];
                $placeholder = str_replace('-', '_', trim($match[0], ':'));
                if (array_key_exists($placeholder, $opts['placeholders'])) {
                    $value_string = str_replace($replacement, $opts['placeholders'][$placeholder], $value_string);
                }
            }
        }
Exemplo n.º 2
0
<?php

if (!defined('PERCH_MEMBERS_SESSION_TIME')) {
    define('PERCH_MEMBERS_SESSION_TIME', '5 DAYS');
}
if (!defined('PERCH_MEMBERS_COOKIE')) {
    define('PERCH_MEMBERS_COOKIE', 'p_m');
}
spl_autoload_register(function ($class_name) {
    if (strpos($class_name, 'PerchMembers') === 0) {
        include __DIR__ . '/' . $class_name . '.class.php';
        return true;
    }
    return false;
});
PerchSystem::register_template_handler('PerchMembers_Template');
if (PERCH_RUNWAY) {
    $members_init = function () {
        $API = new PerchAPI(1.0, 'perch_members');
        $API->on('page.loaded', 'perch_members_init');
    };
    $members_init();
} else {
    perch_members_init();
}
function perch_members_init()
{
    perch_members_recover_session();
    perch_members_check_page_access();
}
function perch_members_form_handler($SubmittedForm)