/**
 * Get translation strings from the POST array
 * and prepare to insert or update into the table according to the specified fields
 *
 * @param array  $post   The POST array
 * @param array  $fields The array of field name and input name mapping, e.g., array('fieldName' => 'inputName')
 * @param string $lang   The language code to fetch (if it is not provided, all languages will be fetched)
 *
 * @return array The data array
 */
function _postTranslationStrings($post, $fields, $lang = null)
{
    global $lc_defaultLang;
    global $lc_languages;
    $data = array();
    foreach ($fields as $key => $name) {
        if ($lang) {
            $lcode = _queryLang($lang);
            if (isset($post[$name . '_' . $lcode])) {
                $data[$key . '_' . $lcode] = $post[$name . '_' . $lcode];
            }
        } else {
            if (isset($post[$name])) {
                $data[$key . '_' . _defaultLang()] = $post[$name];
            }
            foreach ($lc_languages as $lcode => $lname) {
                $lcode = _queryLang($lcode);
                if (isset($post[$name . '_' . $lcode])) {
                    $data[$key . '_' . $lcode] = $post[$name . '_' . $lcode];
                }
            }
        }
    }
    return $data;
}
Exemple #2
0
<?php

$get = _get($_GET);
# Count query for the pager
$rowCount = db_count('category')->where()->condition('deleted', null)->fetch();
# Prerequisite for the Pager
$pager = _pager()->set('itemsPerPage', $lc_itemsPerPage)->set('pageNumLimit', $lc_pageNumLimit)->set('total', $rowCount)->set('ajax', true)->calculate();
# List query
$qb = db_select('category', 'c')->where()->condition('deleted', null)->orderBy('catName')->limit($pager->get('offset'), $pager->get('itemsPerPage'));
if ($qb->getNumRows()) {
    $langs = _langs(_defaultLang());
    ?>
    <table cellpadding="0" cellspacing="0" border="0" class="list">
        <tr class="label">
            <td class="tableLeft" colspan="2"><?php 
    echo _t('Actions');
    ?>
</td>
            <td>
                <span>Name</span>
                <label class="lang">(<?php 
    echo _langName();
    ?>
)</label>
            </td>
            <?php 
    if ($langs) {
        ?>
                <?php 
        foreach ($langs as $lcode => $lname) {
            ?>
<?php

include _i('inc/authenticate.php');
$lang = _getLang();
$pageTitle = _t('Add New Post');
$id = 0;
$id = _arg(3);
if ($id) {
    $pageTitle = _t('Edit Post');
} else {
    if ($lang != _defaultLang()) {
        _redirect('admin/post/setup/', null, _defaultLang());
    }
}
include 'query.php';
?>
<!DOCTYPE html>
<html lang="<?php 
echo _lang();
?>
">
<head>
    <title><?php 
echo _title($pageTitle);
?>
</title>
    <?php 
include _i('inc/tpl/head.php');
?>
    <?php 
_css('base.' . _getLang() . '.css');