changeset 71:26d8c4c43d86 extractapp

minor checking for variable/index in php
author Zoe Hong <zhong@mpiwg-berlin.mpg.de>
date Wed, 08 Apr 2015 14:57:01 +0200
parents 359f48d58cbc
children 6974309983d1
files controllers/extractapp.php models/extractapp.php
diffstat 2 files changed, 31 insertions(+), 20 deletions(-) [+]
line wrap: on
line diff
--- a/controllers/extractapp.php	Wed Apr 08 14:22:44 2015 +0200
+++ b/controllers/extractapp.php	Wed Apr 08 14:57:01 2015 +0200
@@ -15,8 +15,11 @@
 
     protected function TaggingText() {
         $viewmodel = $this->viewmodel;
-               
-        switch ($this->postdata['func']) {
+        
+        if (isset($this->postdata['func'])) {
+            $func = $this->postdata['func'];
+        }
+        switch ($func) {
             case 'SaveFullText':
                 $viewmodel->SaveFullText($this->postdata);          
                 $this->ReturnView($viewmodel->StartTagging(), true); 
@@ -100,7 +103,10 @@
 
     protected function EditWordlist() {
         $viewmodel = $this->viewmodel;
-        switch ($this->postdata['func']) {
+        if (isset($this->postdata['func'])) {
+            $func = $this->postdata['func'];
+        }
+        switch ($func) {
             case 'AddNewList':
                 $this->ReturnView($viewmodel->AddNewList($this->postdata), true);
                 break;
@@ -108,7 +114,6 @@
                 $this->ReturnView($viewmodel->SaveWordlist($this->postdata), true);
                 break;
             default:    // EditWordlist
-                
                 $this->ReturnView($viewmodel->EditWordlist(), true);    
             break;
          } 
@@ -117,7 +122,10 @@
 
     protected function EditTaglist() {
         $viewmodel = $this->viewmodel;
-        switch ($this->postdata['func']) {
+        if (isset($this->postdata['func'])) {
+            $func = $this->postdata['func'];
+        }
+        switch ($func) {
             case 'NewTagElement':
                 $this->ReturnView($viewmodel->NewTagElement($this->postdata), true);
                 break;
@@ -136,7 +144,10 @@
  
     protected function ConfigTagsInTopic() {
         $viewmodel = $this->viewmodel;
-        switch ($this->postdata['func']) {
+        if (isset($this->postdata['func'])) {
+            $func = $this->postdata['func'];
+        }
+        switch ($func) {
             case 'Update':
                 $viewmodel->UpdateTagsInTopic($this->postdata);
                 break;
--- a/models/extractapp.php	Wed Apr 08 14:22:44 2015 +0200
+++ b/models/extractapp.php	Wed Apr 08 14:57:01 2015 +0200
@@ -41,7 +41,7 @@
         $stringInput = $lg_text;
         $stringInput = preg_replace("/ /u", "○", $stringInput);
         $stringInput = preg_replace("/\n/u", "<br>", $stringInput);
-        $stringInput = preg_replace("/【(.*?)】/u", "【<a href=\"review_index_xml_images.php?books_id=".$bookId."&pages=\\1&entry=0\" target=\"_bookImg\">\\1</a>】", $stringInput);
+        $stringInput = preg_replace("/【(.*?)】/u", "【<a href=\"review_index_xml_images.php?books_id=".$this->book_id."&pages=\\1&entry=0\" target=\"_bookImg\">\\1</a>】", $stringInput);
         $lg_text = $stringInput;
 
         $this->lg_text = $lg_text;
@@ -106,41 +106,41 @@
 
     public function GetInfoFromPreviousPage($_postdata) {
 
-        if ($_postdata['fileId']) {
+        if (isset($_postdata['fileId'])) {
             $this->file_id = $_postdata['fileId'];
         }
-        if ($_postdata['sectionId']) {
+        if (isset($_postdata['sectionId'])) {
             $this->section_id = $_postdata['sectionId'];
         }
-        if ($_postdata['text']) {
+        if (isset($_postdata['text'])) {
             $this->lg_text = $_postdata['text'];
         }
-        if ($_postdata['branchId']) {
+        if (isset($_postdata['branchId'])) {
             $this->branch_id = $_postdata['branchId'];
         }
-        if ($_postdata['userId']) {
+        if (isset($_postdata['userId'])) {
             $this->user_id = $_postdata['userId'];
         }
-        if ($_postdata['topic_id']) {
+        if (isset($_postdata['topic_id'])) {
             $this->topic = $_postdata['topic_id'];
         }
 
-        if ($_postdata['sectionName']) {
+        if (isset($_postdata['sectionName'])) {
             $this->section_name = $_postdata['sectionName'];
         }
-        if ($_postdata['bookName']) {
+        if (isset($_postdata['bookName'])) {
             $this->book_name = $_postdata['bookName'];
         }
-        if ($_postdata['bookId']) {
+        if (isset($_postdata['bookId'])) {
             $this->book_id = $_postdata['bookId'];
         }
-        if ($_postdata['currentFileId']) {
+        if (isset($_postdata['currentFileId'])) {
             $this->current_fileId = $_postdata['currentFileId'];
         }
-        if ($_postdata['taglistArray']) {
+        if (isset($_postdata['taglistArray'])) {
             $this->taglist_infile = json_decode($_postdata['taglistArray']);
         }
-        if ($_postdata['book_meta']) {
+        if (isset($_postdata['book_meta'])) {
             $this->book_meta = json_decode($_postdata['book_meta']);
         }
 
@@ -1246,7 +1246,7 @@
             //$listString = preg_replace("/\n/u", "|", $listString);
             
             $wordlistArray2 = explode( "\n", $listString );
-            usort($wordlistArray2,'sortFunction');
+            //usort($wordlistArray2,'sortFunction');
             foreach ( $wordlistArray2 as $index=>$value ) {
                 $wordlistArray2[$index] = implode("○?", preg_split("/(?<!^)(?!$)/u", $value));
             }