Просмотр исходного кода

Merge pull request #588 from visuddhinanda/master

修改已知bug
visuddhinanda 4 лет назад
Родитель
Сommit
f7e4c10733

+ 1 - 0
.gitignore

@@ -15,6 +15,7 @@
 /composer.lock
 /app/phpinfo.php
 /app/config.php
+/app/config.js
 # dependencies
 /vendor/
 /node_modules/

+ 4 - 0
app/article/article.js

@@ -44,6 +44,10 @@ function articel_load(id, collection_id) {
 						}
 						
 						$("#article_author").html( article_author );
+
+						//将绝对链接转换为 用户连接的主机链接
+						result.content = result.content.replace(/[A-z]*.wikipali.org/g,WWW_DOMAIN_NAME);
+
 						$("#contents").html(note_init(result.content,"",result.owner,result.lang));
 						note_refresh_new();
 						guide_init();

+ 100 - 0
app/article/export.php

@@ -0,0 +1,100 @@
+<?php
+require_once '../../vendor/autoload.php';
+require_once '../path.php';
+require_once '../public/function.php';
+
+
+// Creating the new document...
+$phpWord = new \PhpOffice\PhpWord\PhpWord();
+
+
+
+$phpWord->addTitleStyle(1, array('size' => 16), array('numStyle' => 'hNum', 'numLevel' => 0));
+$phpWord->addTitleStyle(2, array('size' => 14), array('numStyle' => 'hNum', 'numLevel' => 1));
+$phpWord->addTitleStyle(3, array('size' => 12), array('numStyle' => 'hNum', 'numLevel' => 2));
+
+/* Note: any element you append to a document must reside inside of a Section. */
+
+// Adding an empty Section to the document...
+$section = $phpWord->addSection();
+
+$section->addTitle('Article Title', 1);
+
+// Adding Text element to the Section having font styled by default...
+$section->addText(
+    '"Learn from yesterday, live for today, hope for tomorrow. '
+        . 'The important thing is not to stop questioning." '
+        . '(Albert Einstein)'
+);
+
+/*
+ * Note: it's possible to customize font style of the Text element you add in three ways:
+ * - inline;
+ * - using named font style (new font style object will be implicitly created);
+ * - using explicitly created font style object.
+ */
+
+// Adding Text element with font customized inline...
+$section->addText(
+    '"Great achievement is usually born of great sacrifice, '
+        . 'and is never the result of selfishness." '
+        . '(Napoleon Hill)',
+    array('name' => 'Tahoma', 'size' => 10)
+);
+
+$textrun = $section->addTextRun();
+$textrun->addText('Lead text.');
+$footnote = $textrun->addFootnote();
+$footnote->addText('Footnote text can have ');
+$footnote->addLink('http://test.com', 'links');
+$footnote->addText('.');
+$footnote->addTextBreak();
+$footnote->addText('And text break.');
+$textrun->addText('Trailing text.');
+
+// Adding Text element with font customized using named font style...
+$fontStyleName = 'oneUserDefinedStyle';
+$phpWord->addFontStyle(
+    $fontStyleName,
+    array('name' => 'Tahoma', 'size' => 10, 'color' => '1B2232', 'bold' => true)
+);
+$section->addText(
+    '"The greatest accomplishment is not in never falling, '
+        . 'but in rising again after you fall." '
+        . '(Vince Lombardi)',
+    $fontStyleName
+);
+
+// Adding Text element with font customized using explicitly created font style object...
+$fontStyle = new \PhpOffice\PhpWord\Style\Font();
+$fontStyle->setBold(true);
+$fontStyle->setName('Tahoma');
+$fontStyle->setSize(13);
+$myTextElement = $section->addText('"Believe you can and you\'re halfway there." (Theodor Roosevelt)');
+$myTextElement->setFontStyle($fontStyle);
+
+// Saving the document as OOXML file...
+$objWriter = \PhpOffice\PhpWord\IOFactory::createWriter($phpWord, 'Word2007');
+$tmpFileName = _DIR_TMP_EXPORT.'/'.UUID::v4().'.docx';
+$objWriter->save($tmpFileName);
+
+//4.从浏览器下载
+ob_clean();
+ob_start();
+$fp = fopen($tmpFileName,"r");
+$file_size = filesize($tmpFileName);
+Header("Content-type:application/octet-stream");
+Header("Accept-Ranges:bytes");
+Header("Accept-Length:".$file_size);
+Header("Content-Disposition:attchment; filename=".'wikipali.docx');
+$buffer = 1024;
+$file_count = 0;
+while (!feof($fp) && $file_count < $file_size){
+    $file_con = fread($fp,$buffer);
+    $file_count += $buffer;
+    echo $file_con;
+}
+fclose($fp);
+ob_end_flush();
+
+unlink($tmpFileName);

+ 1 - 1
app/article/my_article.js

@@ -52,7 +52,7 @@ function my_article_list() {
 						html += "</a></div>";
 						html += "<div style='flex:1;'>";
 						html +=
-							"<button class='icon_btn' onclick=\"copy_to_clipboard('www.wikipali.org/app/article/?id=" +
+							"<button class='icon_btn' onclick=\"copy_to_clipboard('"+WWW_DOMAIN_NAME+"/app/article/?id=" +
 							iterator.id +
 							"')\" title='" +
 							gLocal.gui.copy_link +

+ 2 - 0
app/config.sample.js

@@ -0,0 +1,2 @@
+var WWW_DOMAIN_NAME="sg.wikipali.org";
+var RPC_DOMAIN_NAME="rpc.wikipali.org";

+ 3 - 1
app/config.sample.php

@@ -2,7 +2,9 @@
 // Require Composer's autoloader.
 require_once '../../vendor/autoload.php';
 
-
+#域名设置
+define(WWW_DOMAIN_NAME,"sg.wikipali.org");
+define(RPC_DOMAIN_NAME,"rpc.wikipali.org");
 /*
 电子邮件设置
 PHPMailer

+ 2 - 2
app/db/user.php

@@ -175,8 +175,8 @@ class User extends Table
 			$ok = $this->_update(["reset_password_token"=>$resetToken],["reset_password_token"],["email"=>$email]);
 			if($ok){
 				#send email
-				$resetLink="https://www.wikipali.org/app/ucenter/reset.php?token=".$resetToken;
-				$resetString="https://www.wikipali.org/app/ucenter/reset.php";
+				$resetLink=WWW_DOMAIN_NAME."/app/ucenter/reset.php?token=".$resetToken;
+				$resetString=WWW_DOMAIN_NAME."/app/ucenter/reset.php";
 		
 				// 打开文件并读取数据
 				$irow=0;

+ 2 - 2
app/dict/dict_lookup.php

@@ -1,4 +1,4 @@
-<?php
+<?php
 //查询参考字典
 include("../log/pref_log.php");
 require_once '../path.php';
@@ -594,7 +594,7 @@ function GrmAbbr($input,$dictid){
 
 	foreach (GRM_ABBR as $key => $value) {
 		# code...
-		if($value["dictid"]==$dictid ){
+		if($value["dictid"]==$dictid && strpos($input,$value["abbr"]."</guide>") == false){
 			$mean = str_replace($value["abbr"],"<guide gid='grammar_{$value["replace"]}' class='grammar_tag' style='display:unset;'>{$value["abbr"]}</guide>",$mean);
 		}
 

+ 10 - 6
app/pali_text/function.php

@@ -25,16 +25,20 @@ class PaliText extends Table
 			$stmt = $this->dbh->prepare($query);
 			$stmt->execute(array($book, $parent));
 			$FetParent = $stmt->fetch(PDO::FETCH_ASSOC);
+			if($FetParent){
+				$toc =array("book"=>$book,"para"=>$parent,"level"=>$FetParent["level"],"title"=>$FetParent["toc"]);
 
-			$toc =array("book"=>$book,"para"=>$parent,"level"=>$FetParent["level"],"title"=>$FetParent["toc"]);
+				$path[] = $toc;
 
-			$path[] = $toc;
-
-			$parent = $FetParent["parent"];
-			$deep++;
-			if ($deep > 5) {
+				$parent = $FetParent["parent"];
+				$deep++;
+				if ($deep > 5) {
+					break;
+				}				
+			}else{
 				break;
 			}
+
 		}
 		if($this->redis){
 			$this->redis->hSet("pali_text://path",$book."-".$para,json_encode($path,JSON_UNESCAPED_UNICODE));

+ 2 - 0
app/pcdl/html_head.php

@@ -75,6 +75,8 @@ if (isset($_GET["language"])) {
 
 	<title id="page_title">wikipāḷi</title>
 
+	<script src="../config.js"></script>
+
 	<script src="../../node_modules/jquery/dist/jquery.js"></script>
 	<script src="../public/js/comm.js"></script>
 	<script src="../studio/js/fixedsticky.js"></script>

+ 40 - 13
app/reader/right_tool_bar.php

@@ -17,42 +17,69 @@
 .main_view_right_float_max #right_pannal {
 	display: none;
 }
+.btn_main {
+    background-color: var(--link-hover-color);
+    color: var(--btn-hover-color);
+}
+.btn_main:hover {
+    background-color: var(--link-color);
+}
+
+.btn_group {
+    display: inline-block;
+    background-color: var(--border-line-color);
+    border-radius: 4px;
+    padding: 3px 2px;
+    margin: 0 3px;
+}
+.btn_focus {
+    background-color: var(--bg-color);
+}
+
 	</style>
 			<select name="direction" onchange='setDirection(this)' class="show_pc">
 			<option value="row"><?php echo $_local->gui->row_compare; ?></option>
 			<option value="column"><?php echo $_local->gui->column_compare; ?></option>
 		</select>
+		
 <?php
 		if($_mode == "read"){
 			echo "<select onchange='setDisplay(this)'>";
 			echo "<option value='para'>{$_local->gui->each_paragraph}</option>";
-			echo "<option value='sent'>{$_local->gui->each_sentence}</option>";
+			echo "<option value='sent' ";
+			if($_display=="sent"){
+				echo "selected";
+			}
+			echo ">{$_local->gui->each_sentence}</option>";
 			echo "</select>";
 		}
+?>
+<div class="btn_group">
+<?php
 		if($_mode == "read"){
-			echo "<button class='icon_btn active' title='{$_local->gui->show} {$_local->gui->each_paragraph}'>";
+			echo "<span class='icon_btn btn_focus'  ";
+			echo " title='{$_local->gui->show} {$_local->gui->read}'>";
 			echo $_local->gui->read;
-			echo "</button>";
+			echo "</span>";
 
-			echo "<button class='icon_btn'>";
-			echo "<a onclick=\"setMode('edit')\"";
-
-			echo " title='{$_local->gui->show} {$_local->gui->edit}'>{$_local->gui->edit}</a></button>";
+			echo "<button class='icon_btn' onclick=\"setMode('edit')\" ";
+			echo " title='{$_local->gui->show} {$_local->gui->edit}'>";
+			echo $_local->gui->translate;
+			echo "</button>";
 		}
 		else{
-			echo "<button class='icon_btn'>";
-			echo "<a onclick=\"setMode('read')\"";
+			echo "<button class='icon_btn' onclick=\"setMode('read')\" ";
 			echo " title='{$_local->gui->show} {$_local->gui->read}'>";		
 			echo $_local->gui->read;
-			echo "</a>";
 			echo "</button>";
 
-			echo "<button class='icon_btn active'  title='{$_local->gui->show} {$_local->gui->edit}'>";
+			echo "<span class='icon_btn btn_focus'  ";
+			echo " title='{$_local->gui->show} {$_local->gui->edit}'>";
 			echo $_local->gui->edit;
-			echo "</button>";
+			echo "</span>";
 		}
 ?>
-
+</div>
 				<button id="btn_show_dict" class='icon_btn' onclick="show_dict(this)">
 				<?php echo $_local->gui->dict; ?>
 				</button>

+ 2 - 0
app/studio/index_head.php

@@ -47,6 +47,8 @@ require_once '../public/load_lang.php';
 	
 	<title id="page_title"><?php echo $_local->gui->pcd_studio; ?></title>
 
+	<script src="../config.js"></script>
+
 	<script src="../studio/js/common.js"></script>
 	<script src="../public/js/jquery.js"></script>	
 	<script src="../studio/js/fixedsticky.js"></script>	

+ 1 - 1
app/studio/js/index_mydoc.js

@@ -225,7 +225,7 @@ function title_change(id, title) {
 	}
 }
 function share_link_copy_to_clipboard(id) {
-	copy_to_clipboard("https://www.wikipali.org/app/studio/project.php?op=open&doc_id=" + id);
+	copy_to_clipboard(WWW_DOMAIN_NAME+"/app/studio/project.php?op=open&doc_id=" + id);
 }
 function mydoc_file_select(doSelect) {
 	if (doSelect) {

+ 3 - 3
app/studio/pc_get_word_num.php

@@ -3,9 +3,9 @@
 require_once "../path.php";
 require_once "../public/_pdo.php";
 
-$get_book = $_GET["book"];
-$get_par_begin = $_GET["begin"];
-$get_par_end = $_GET["end"];
+$get_book = (int)$_GET["book"];
+$get_par_begin = (int)$_GET["begin"];
+$get_par_end = (int)$_GET["end"];
 
 $db_file = _DIR_PALICANON_TEMPLET_ . "/p" . $get_book . "_tpl.db3";
 

+ 2 - 0
app/term/my_dict_list.php

@@ -2,6 +2,8 @@
 require_once '../studio/index_head.php';
 ?>
 <body id="file_list_body" onLoad="my_term_onload()">
+	<script src="../channal/channal.js"></script>
+
     <script src="../term/my_term.js"></script>
     <script src="../term/term_edit_dlg.js"></script>
 	<link type="text/css" rel="stylesheet" href="../term/term_edit_dlg.css"/>

+ 15 - 2
app/term/note.js

@@ -255,7 +255,12 @@ function render_read_mode_sent(iterator) {
 			.parent()
 			.parent()
 			.prepend(
-				"<div class='para_div'><div class='palitext_div'><div class='palitext palitext1'></div><div class='palitext palitext2'></div></div><div class='para_tran_div'>" +
+				"<div class='para_div'>"+
+				"<div class='palitext_div'>"+
+				"<div class='palitext palitext1'></div>"+
+				"<div class='palitext palitext2'></div>"+
+				"</div>"+
+				"<div class='para_tran_div'>" +
 					tranDivHtml +
 					"</div></div>"
 			);
@@ -281,6 +286,10 @@ function render_read_mode_sent(iterator) {
 	htmlSent += "<div class='sent_tran_div'>";
 	for (const oneTran of iterator.translation) {
 		let html = "<span class='tran_sent' lang='" + oneTran.lang + "' channal='" + oneTran.channal + "'>";
+
+		//将绝对链接转换为 用户连接的主机链接
+		oneTran.text = oneTran.text.replace(/[A-z]*.wikipali.org/g,WWW_DOMAIN_NAME);
+
 		html += marked(term_std_str_to_tran(oneTran.text, oneTran.channal, oneTran.editor, oneTran.lang));
 		html += "</span>";
 		htmlSent += html;
@@ -886,6 +895,10 @@ function render_one_sent_tran_a(iterator, diff = false) {
 
 	let tranText;
 	let sid = iterator.book + "-" + iterator.para + "-" + iterator.begin + "-" + iterator.end;
+
+	//将绝对链接转换为 用户连接的主机链接
+	let showText = iterator.text.replace(/[A-z]*.wikipali.org/g,WWW_DOMAIN_NAME);
+
 	if (iterator.text == "") {
 		if (typeof iterator.channalinfo == "undefined") {
 			tranText =
@@ -924,7 +937,7 @@ function render_one_sent_tran_a(iterator, diff = false) {
 			tranText = str_diff(orgText, iterator.text);
 		} else {
 			//note_init处理句子链接
-			tranText = note_init(term_std_str_to_tran(iterator.text, iterator.channal, iterator.editor, iterator.lang));
+			tranText = note_init(term_std_str_to_tran(showText, iterator.channal, iterator.editor, iterator.lang));
 		}
 	}
 	let html = "";

+ 1 - 1
app/term/popup_note.css

@@ -1,4 +1,4 @@
-.tran_sent code {
+.tran_sent code ,.sent_tran  code {
 	position: relative;
 	display: inline-block;
 	width: auto;

+ 2 - 1
app/term/term_edit_dlg.js

@@ -119,8 +119,9 @@ function term_edit_dlg_render(word = "") {
 	output += "<legend>" + gLocal.gui.channel + "</legend>";
 	output += "<select id='term_edit_form_channal' name='channal'>";
 	output += "<option value=''>通用于所有版本</option>";
+	word.channel = word.channal;
 	for (const iterator of _my_channal) {
-		if(iterator.id==word.channel){
+		if(word.channel=="" || (word.channel!="" && iterator.id==word.channel)){
 		output += "<option value='"+iterator.id+"'>仅用于"+iterator.name+"</option>";
 		}
 	}

+ 2 - 2
app/ucenter/invite.php

@@ -23,8 +23,8 @@ if (PHP_SAPI == "cli") {
 		$invitecode = "invitecode://".$uuid;
 		$redis->set($invitecode,$email);
 		$redis->expire($invitecode,7*20*3600);
-		$SignUpLink="https://www.wikipali.org/app/ucenter/sign_up.php?invite=".$uuid;
-		$SignUpString="www.wikipali.org/app/ucenter/sign_up.php";
+		$SignUpLink=WWW_DOMAIN_NAME . "/app/ucenter/sign_up.php?invite=".$uuid;
+		$SignUpString=WWW_DOMAIN_NAME . "/app/ucenter/sign_up.php";
 
 			// 打开文件并读取数据
 		$irow=0;