view controllers/extractapp.php @ 73:2daef8e36214 extractapp

minor modification
author Zoe Hong <zhong@mpiwg-berlin.mpg.de>
date Wed, 08 Apr 2015 16:17:50 +0200
parents 26d8c4c43d86
children 60b5a94163c3
line wrap: on
line source

<?php

class Extractapp extends BaseController {
	protected function Index() {
		$viewmodel = new ExtractappModel();
        $this->ReturnView($viewmodel->Index(), true);
	}
    protected $viewmodel;

       
    public function __construct($action, $urlvalues, $postdata){
        parent::__construct($action, $urlvalues, $postdata); 
        $this->viewmodel = new ExtractappModel();
    }

    protected function TaggingText() {
        $viewmodel = $this->viewmodel;
        
        if (isset($this->postdata['func'])) {
            $func = $this->postdata['func'];
        }
        switch ($func) {
            case 'SaveFullText':
                $viewmodel->SaveFullText($this->postdata);          
                $this->ReturnView($viewmodel->StartTagging(), true); 
                break;   
            case 'SaveFullTextToLGService':
                $viewmodel->messages['info'] .= "SaveFullTextToLGService! ";
                $viewmodel->GetInfoFromPreviousPage($this->postdata);
                $response = $viewmodel->SaveFullTextToLGService($this->postdata);
                $viewmodel->UpdateInfoByResponseFromLGService($response);    // update file_id, branch_id, user_id
                $viewmodel->GetTextFromFileId();     
                $this->ReturnView($viewmodel->StartTagging(), true); 
                break;

            case 'SmartRegexLoad':
                $viewmodel->SmartRegexLoad($this->postdata['topic_id']);
                break;
            case 'SmartRegexSave':
                $viewmodel->SmartRegexSave($this->postdata);
                break;
            case 'ReloadText':
                $viewmodel->messages['info'] .= "Reload the latest text ";
                $viewmodel->GetInfoFromPreviousPage($this->postdata);
                $viewmodel->ReloadSetting();    // set file_id = current_fileId, current_fileId = 0
                $viewmodel->GetTextFromFileId();
                $this->ReturnView($viewmodel->StartTagging(), true);
                break;

            case 'ContinueTagging':
                $viewmodel->messages['info'] .= "(Countinue tagging) ";
                if ($this->postdata['topic']) {
                    $viewmodel->SetTopic($this->postdata['topic']);
                }
                $viewmodel->GetInfoFromPreviousPage($this->postdata);
                $this->ReturnView($viewmodel->StartTagging(), true); 
                break;


            default:    // first time visit extraction interface from LGService
                $viewmodel->messages['info'] .= "Welcome to Extraction Interface. ";

                if (isset($this->postdata['fileId'])) {
                    if ($this->postdata['fileId'] != 0) { // ($this->postdata['branchId'] != 0) {
                        // --- Existing branch case ---
                        $viewmodel->GetInfoFromPreviousPage($this->postdata);
                        // get text by fileId, from LGService
                        $viewmodel->GetTextFromFileId();
                    }

                } else if ($this->postdata['sectionId'] != 0 && $this->postdata['userId'] != 0) {
                    // --- New branch case ---
                    $viewmodel->GetInfoFromPreviousPage($this->postdata);
                    $viewmodel->SetBookMetaDataBySectionId();
                    // get text by sectionId from LGService
                    $viewmodel->GetTextFromSectionId();  

                } else if ($this->postdata['sectionId'] != 0) { 
                    $viewmodel->GetTextFromLocal($this->postdata['sectionId']);

                } else if (is_numeric($this->urlvalues['id'])) {
                    // get text from local file system (for development stage only)
                    $viewmodel->GetTextFromLocal($this->urlvalues['id']);
                    $this->ReturnView_localtest($viewmodel->StartTagging(), true); 
                    break;                    

                } else {
                    $viewmodel->messages['error'] .= "wrong url!!";
                    return;
                }

                $this->ReturnView($viewmodel->StartTagging(), true); 
                break;
        }

       
        
    }

    protected function ExportTable() {
        $viewmodel = $this->viewmodel;
        $this->ReturnView($viewmodel->ExportTable($this->postdata), true);

    }

    protected function EditWordlist() {
        $viewmodel = $this->viewmodel;
        if (isset($this->postdata['func'])) {
            $func = $this->postdata['func'];
        }
        switch ($func) {
            case 'AddNewList':
                $this->ReturnView($viewmodel->AddNewList($this->postdata), true);
                break;
            case 'SaveWordlist':
                $this->ReturnView($viewmodel->SaveWordlist($this->postdata), true);
                break;
            default:    // EditWordlist
                $this->ReturnView($viewmodel->EditWordlist(), true);    
            break;
         } 
    }


    protected function EditTaglist() {
        $viewmodel = $this->viewmodel;
        if (isset($this->postdata['func'])) {
            $func = $this->postdata['func'];
        }
        switch ($func) {
            case 'NewTagElement':
                $this->ReturnView($viewmodel->NewTagElement($this->postdata), true);
                break;
            case 'SaveTagElement':
                $this->ReturnView($viewmodel->SaveTagElement($this->postdata), true);
                break;
            case 'DeleteTag':
                $this->ReturnView($viewmodel->DeleteTag($this->postdata), true);
                break;
            default:    // EditTaglist
                $this->ReturnView($viewmodel->EditTaglist($this->postdata), true);
                break;
        }
    }

 
    protected function ConfigTagsInTopic() {
        $viewmodel = $this->viewmodel;
        if (isset($this->postdata['func'])) {
            $func = $this->postdata['func'];
        }
        switch ($func) {
            case 'Update':
                $viewmodel->UpdateTagsInTopic($this->postdata);
                break;
            default:    
                $this->ReturnView($viewmodel->ConfigTagsInTopic($this->postdata), true);  
                break;
         } 
    }

    protected function TestAction() {
        $this->ReturnView($viewmodel->Test(), true);
    }


    
	
}


?>