Esempio n. 1
0
 function _import_fixed_lang()
 {
     # 	Scans the articles, creating a group for each and adding it and setting the
     # language to the site default...
     $where = "1";
     $rs = @safe_rows_start('ID , Title , ' . L10N_COL_LANG . ' , `' . L10N_COL_GROUP . '`', 'textpattern', $where);
     $count = @mysql_num_rows($rs);
     $i = 0;
     if ($rs && $count > 0) {
         while ($a = nextRow($rs)) {
             $title = $a['Title'];
             $lang = $a[L10N_COL_LANG];
             $article_id = $a[L10N_COL_GROUP];
             $id = $a['ID'];
             if ($lang !== '-' and $article_id !== 0) {
                 #
                 #	Use any existing Lang/Group data there might be...
                 #
                 if (true === MLPArticles::add_rendition($article_id, $id, $lang, true, true, $title)) {
                     $i++;
                 }
             } else {
                 #
                 #	Create a fresh group and add the info...
                 #
                 if (MLPArticles::create_article_and_add($a)) {
                     $i++;
                 }
             }
         }
     }
     if ($i === $count) {
         return true;
     }
     return "{$i} of {$count}";
 }
Esempio n. 2
0
function _l10n_add_rendition_to_article_cb($event, $step)
{
    require_privs('article');
    global $vars;
    $new_vars = array_merge($vars, array(L10N_COL_LANG, L10N_COL_GROUP, 'original_ID'));
    $save = gps('save');
    if ($save) {
        $step = 'save';
    }
    $publish = gps('publish');
    if ($publish) {
        $step = 'publish';
    }
    $incoming = gpsa($new_vars);
    $default = MLPLanguageHandler::get_site_default_lang();
    $new_lang = @$incoming[L10N_COL_LANG] ? $incoming[L10N_COL_LANG] : $default;
    switch (strtolower($step)) {
        case 'publish':
            #
            #	Create a group for this article
            #
            MLPArticles::create_article_and_add($incoming);
            #
            #	Update the language table for the target language...
            #
            _l10n_replace_rendition($new_lang);
            #
            #	Read the variables to continue the edit...
            #
            _l10n_setup_vars($event, $step);
            break;
        case 'save':
            #
            #	Record the old and new languages, if there are any changes we need to update
            # both the old and new tables after moving the group/lang over...
            #
            $rendition_id = $incoming['ID'];
            $info = safe_row('*', 'textpattern', "`ID`='{$rendition_id}'");
            if ($info !== false) {
                $current_lang = $info[L10N_COL_LANG];
            }
            #
            #	Check for changes to the article language and groups ...
            #
            MLPArticles::move_to_article($incoming);
            #
            #	Now we can setup the tables again...
            #
            _l10n_replace_rendition($new_lang, true, $rendition_id);
            if ($new_lang != $current_lang) {
                _l10n_remove_rendition($current_lang, $rendition_id);
            }
            #
            #	If this rendition is in the default language then update the article
            # title...
            #
            $default_lang = MLPLanguageHandler::get_site_default_lang();
            if (isset($info['Title']) and isset($info[L10N_COL_GROUP]) and $current_lang === $default_lang) {
                MLPArticles::retitle_article($info[L10N_COL_GROUP], $info['Title']);
            }
            #
            #	Read the variables to continue the edit...
            #
            _l10n_setup_vars($event, $step);
            break;
    }
}