view develop/controllers/extractapp.php @ 25:4b6d2d7e706e

update for the integration
author Zoe Hong <zhong@mpiwg-berlin.mpg.de>
date Mon, 02 Mar 2015 16:16:54 +0100
parents b55f5d3564c4
children e6e9bdc4f256
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 = new ExtractappModel();
        $viewmodel = $this->viewmodel;
               
        switch ($this->postdata['func']) {
            case 'SaveFullText':
                $viewmodel->SaveFullText($this->postdata);          
                $this->ReturnView($viewmodel->StartTagging(), true); 
                break;   
            case 'SaveFullTextToLGService':
                $viewmodel->messages .= "SaveFullTextToLGService! "."<br>";
                $viewmodel->GetInfoFromPreviousPage($this->postdata);
                $response = $viewmodel->SaveFullTextToLGService($this->postdata);
                
                $viewmodel->UpdateInfoByResponseFromLGService($response);    // update file_id, branch_id, user_id
                
                $this->ReturnView($viewmodel->StartTagging(), true); 
                break;

            case 'SmartRegexLoad':
                $viewmodel->SmartRegexLoad($this->postdata['topic_id']);
                break;
            case 'SmartRegexSave':
                $viewmodel->SmartRegexSave($this->postdata);
                break;

            case 'ContinueTagging':
                $viewmodel->messages .= "(Countinue tagging) "."<br>";
                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 .= "Welcome to Extraction Interface. "."<br>";

                if ($this->postdata['fileId'] != 0) { // ($this->postdata['branchId'] != 0) {
                    // get text from fileId, from LGService
                    $viewmodel->GetTextFromFileId($this->postdata);
                } else if ($this->postdata['sectionId'] != 0 && $this->postdata['userId'] != 0) {
                    // get text from sectionId from LGService
                    $viewmodel->GetTextFromSectionId($this->postdata); 
                } 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 .= "wrong url!!";
                    return;
                }

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

       
        
    }

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

    }

    protected function EditWordlist() {
        // $viewmodel = new ExtractappModel();
        $viewmodel = $this->viewmodel;
        switch ($this->postdata['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 = new ExtractappModel();
        $viewmodel = $this->viewmodel;
        switch ($this->postdata['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 = new ExtractappModel();
        $viewmodel = $this->viewmodel;
        switch ($this->postdata['func']) {
            case 'Update':
                $viewmodel->UpdateTagsInTopic($this->postdata);
                break;
            default:    
                $this->ReturnView($viewmodel->ConfigTagsInTopic($this->postdata), true);  
                break;
         } 
    }

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


    
	
}


?>