Beispiel #1
0
function add_lang()
{
    global $smarty, $lang;
    $chinese_name = post('chinese_name');
    $foreign_name = post('foreign_name');
    $pack_name = post('pack_name');
    $short_name = post('short_name');
    $index_entrance = post('index_entrance');
    $admin_entrance = post('admin_entrance');
    if ($chinese_name != '' && $foreign_name != '' && $pack_name != '' && $index_entrance != '' && $admin_entrance != '' && $index_entrance != 'index.php' && $admin_entrance != 'admin.php') {
        $var_value = $pack_name . '{v}' . $index_entrance . '{v}' . $admin_entrance . '{v}' . $chinese_name . '{v}' . $foreign_name;
        $obj = new varia();
        $obj->add_var_value('languages', $var_value);
        $site = get_site_info();
        $obj->add_var_value('site_title', $site['title'], $pack_name);
        $obj->add_var_value('site_name', $site['name'], $pack_name);
        $obj->add_var_value('site_record', $site['record'], $pack_name);
        $obj->add_var_value('site_tech', $site['tech'], $pack_name);
        $obj->add_var_value('site_keywords', $site['keywords'], $pack_name);
        $obj->add_var_value('site_description', $site['description'], $pack_name);
        $obj->add_var_value('notice', '', $pack_name, true);
        $obj->add_var_value('service_code', '', $pack_name, true);
        $obj->add_var_value('user_agreement', '', $pack_name, true);
        $obj = new channel();
        $obj->set_where('cha_original = 0');
        $list = $obj->get_list();
        for ($i = 0; $i < count($list); $i++) {
            $obj->clear_value();
            $obj->set_value('cha_lang', $pack_name);
            $obj->set_value('cha_code', $list[$i]['cha_code']);
            $obj->set_value('cha_name', $list[$i]['cha_name']);
            $obj->set_value('cha_original', $list[$i]['cha_original']);
            $obj->add();
        }
        if (!file_exists('languages/' . $pack_name)) {
            copy_dir('languages/' . S_LANG, 'languages/' . $pack_name);
        }
        if (S_MULTILINGUAL) {
            $file = file_get_contents('admin/index.txt');
            $file = str_replace('{$pack_name}', $pack_name, $file);
            $file = str_replace('{$index_entrance}', $index_entrance, $file);
            $file = str_replace('{$admin_entrance}', $admin_entrance, $file);
            file_put_contents($index_entrance, $file);
            $file = file_get_contents('admin/admin.txt');
            $file = str_replace('{$pack_name}', $pack_name, $file);
            $file = str_replace('{$index_entrance}', $index_entrance, $file);
            $file = str_replace('{$admin_entrance}', $admin_entrance, $file);
            file_put_contents($admin_entrance, $file);
        }
        $info_text = '添加语言成功';
    } else {
        $info_text = '的输入不合法,添加语言失败';
    }
    $smarty->assign('info_text', $info_text);
    $smarty->assign('link_text', $lang['return_list']);
    $smarty->assign('link_href', url(array('channel' => 'file', 'mod' => 'lang_lists')));
}
Beispiel #2
0
function do_add_channel($original, $cha_code, $cha_name, $word_1, $word_2)
{
    //判断频道是否已存在
    $obj = new channel();
    $obj->set_where('');
    $obj->set_where("cha_code = '{$cha_code}'");
    $channel = $obj->get_one();
    if (count($channel)) {
        return 0;
    }
    //添加频道记录
    $cha_original = get_id('channel', 'cha_code', $original);
    $obj = new channel();
    $obj->set_value('cha_code', $cha_code);
    $obj->set_value('cha_name', $cha_name);
    $obj->set_value('cha_original', $cha_original);
    $obj->set_value('cha_lang', S_LANG);
    $obj->add();
    $obj = new varia();
    //添加前台导航(导航管理)
    if ($original == 'about') {
        $obj->set_value('var_name', 'nav_stage_' . $cha_code);
        $obj->set_value('var_value', $cha_name);
        $obj->add();
    }
    //添加后台导航(导航管理)
    $obj->clear_value();
    $obj->set_value('var_name', 'nav_admin_' . $cha_code);
    $obj->set_value('var_value', $cha_name);
    $obj->add();
    //添加后台导航菜单
    $obj = new menu();
    $obj->set_value('men_type', 'admin_header');
    $obj->set_value('men_name', $cha_name);
    $obj->set_value('men_url', $cha_code . '/mod-sheet/');
    $obj->add();
    $obj->clear_value();
    $obj->set_value('men_type', 'admin_' . $cha_code);
    $obj->set_value('men_name', $cha_name . '列表');
    $obj->set_value('men_url', $cha_code . '/mod-sheet/');
    $obj->add();
    $obj->clear_value();
    $obj->set_value('men_type', 'admin_' . $cha_code);
    $obj->set_value('men_name', '添加' . $cha_name);
    $obj->set_value('men_url', $cha_code . '/mod-add/');
    $obj->add();
    if ($original == 'article' || $original == 'goods') {
        $obj->clear_value();
        $obj->set_value('men_type', 'admin_' . $cha_code);
        $obj->set_value('men_name', $cha_name . '分类');
        $obj->set_value('men_url', $cha_code . '/mod-cat_list/');
        $obj->add();
    }
    if ($original == 'goods') {
        $obj->clear_value();
        $obj->set_value('men_type', 'admin_' . $cha_code);
        $obj->set_value('men_name', $cha_name . '属性');
        $obj->set_value('men_url', $cha_code . '/mod-att_list/');
        $obj->add();
    }
    //添加前台导航菜单
    $obj = new menu();
    $obj->set_value('men_lang', S_LANG);
    $obj->set_value('men_type', 'header');
    $obj->set_value('men_name', $cha_name);
    $obj->set_value('men_url', $cha_code . '/');
    $obj->add();
    //添加属性
    if ($original == 'download') {
        $obj = new att_art();
        $obj->set_where('');
        $obj->set_where("att_channel_id = {$cha_original}");
        $list = $obj->get_list();
        $channel_id = get_id('channel', 'cha_code', $cha_code);
        for ($i = 0; $i < count($list); $i++) {
            $obj->clear_value();
            $obj->set_value('att_channel_id', $channel_id);
            $obj->set_value('att_lang', $list[$i]['att_lang']);
            $obj->set_value('att_code', $list[$i]['att_code']);
            $obj->set_value('att_name', $list[$i]['att_name']);
            $obj->add();
        }
    }
    //创建语言包
    $path = 'languages/' . S_LANG . '/admin/';
    if (file_exists($path . $original . '.txt')) {
        $str = file_get_contents($path . $original . '.txt');
        $str = str_replace($word_1, $word_2, $str);
        file_put_contents($path . $cha_code . '.txt', $str);
    }
    $path = 'languages/' . S_LANG . '/index/';
    if (file_exists($path . $original . '.txt')) {
        $str = file_get_contents($path . $original . '.txt');
        $str = str_replace($word_1, $word_2, $str);
        file_put_contents($path . $cha_code . '.txt', $str);
    }
    //修改伪静态文件
    $path = 'admin/module/basic/htaccess.txt';
    if (file_exists($path)) {
        $str = file_get_contents($path);
        $str .= "\n" . 'RewriteRule ^' . $cha_code . '/(.*)$ index.php?/' . $cha_code . '/$1';
        $str = str_replace("\n\n", "\n", $str);
        file_put_contents($path, $str);
    }
    return 1;
}
Beispiel #3
0
     $req->setURL($url->getURL());
     channel::validate($req, $chan);
     if (channel::exists($project_name->getValue())) {
         throw new Exception("Already exists");
     }
     $text = sprintf("[Channels] Please activate %s (%s) on the channel index.", $project_name->getValue(), $project_link->getValue());
     $from = sprintf('"%s" <%s>', $contact_name->getValue(), $contact_email->getValue());
     $logger = new Damblan_Log();
     $observer = new Damblan_Log_Mail();
     $observer->setRecipients(PEAR_WEBMASTER_EMAIL);
     $observer->setHeader("From", $from);
     $observer->setHeader("Subject", "Channel link submission");
     $logger->attach($observer);
     $logger->log($text);
     // Add the channel to the DB, but not yet activated
     channel::add($project_name->getValue());
     channel::edit($project_name->getValue(), $project_label->getValue(), $project_link->getValue(), $contact_name->getValue(), $contact_email->getValue());
     echo "<div class=\"success\">Thanks for your submission.  It will ";
     echo "be reviewed as soon as possible.</div>\n";
 } catch (Exception $exception) {
     echo '<div class="errors">';
     switch ($exception->getMessage()) {
         case "Invalid channel site":
         case "Empty channel.xml":
             echo "The submitted URL does not ";
             echo "appear to point to a valid channel site.  You will ";
             echo "have to make sure that <tt>/channel.xml</tt> at least ";
             echo "exists and is valid.";
         default:
             echo $exception->getMessage();
             break;