Internal documentation for portal

This section describes how to add new functionality to the portal. In most cases, it will be a question of finding a suitable way to wrap command-line functionality. We start by presenting a couple of illustrative examples related to multiword expressions.

Adding a new control to the Advanced Options menu

As a very simple example of adding new functionality, we show how to add a new control to the Advanced Options menu on the Create resources screen. Specifically, we want to be able to set the value of the "mwe_word_in_colour" option so that it can be either "no" (default) or "yes". We need to make the following changes:

  • In the file $LARA/Code/PHP/class/Content.class.php, we add a component to the Content class to represent the value of our new option. Specifically, we add the line

    public $MWEWordsInColour;

in the list of components, i.e.

(...)
public $LinguisticsArticleComments;
public $ColouredWords;
public $AudioWordsInColour;
public $MweWordsInColour;
(...)
  • Corresponding to the new component, we add a new field in the database.

  • In $LARA/Code/PHP/view/NewLARAContent.php, we add HTML for the new radio button. We copy and edit the HTML for a similar control:

    <div class="tr">
    <div class="tdTitle">MWE words in colour:</div>
    <div class="tdInput">
    <input type="radio" id="MweWordsInColour_Y" name="MweWordsInColour"  value="YES" >Yes
    <input type="radio" id="MweWordsInColour_N" name="MweWordsInColour"  value="NO" >No &nbsp;
    </div>
    
  • In LARA/Code/PHP/data/Content.data.php, we add references to MWEWordsInColour in three places: MakeEmptyContent()

    (...)
    $contentObj->AudioWordsInColour = 'NO';
    $contentObj->MweWordsInColour = 'NO';
    $contentObj->MaxExamplesPerWordPage = '10';
    (...)
    

CreateConfigFile:

$local_config_data .= '"mwe_words_in_colour" : "' . strtolower($contentObj->MweWordsInColour) . '",';

and FulfillContentObj

$ContentConfigIndexes = array("id",
     (...)
     "mwe_words_in_colour"
     );

 $ContentIndexes = array("ContentName",
     (...)
     "MweWordsInColour"
     );

Adding full MWE processing

First, we have two new types of entry that we are going to add to the config file, to declare the MWE lexicon and the MWE annotations. These will be the values of "mwe_file" and "mwe_annotations_file" respectively. "mwe_file" points to the MWE lexicon for the L2, a text file that will be put in the relevant language corpus directory. "mwe_annotations_file" points to the MWE annotations file, a JSON-formatted file that will be put in the text corpus directory.

We start by adding lines to CreateConfigFile in LARA/Code/PHP/data/Content.data.php:

$local_config_data .= '"mwe_file" : "' . LaraContentDir . $L2Name . '/' . SubDirNames["corpus"] . '/mwe_defs.txt",';
$configObj->mwe_file = LaraContentDir . $L2Name . '/' . SubDirNames["corpus"] . '/mwe_defs.txt';
$local_config_data .= '"mwe_annotations_file" : "' . LaraContentDir . $contentObj->DirName . '/' . SubDirNames["corpus"] . '/' . $contentObj->DirName . '_mwe_annotations.json",';
$configObj->mwe_annotations_file = LaraContentDir . $contentObj->DirName . '/' . SubDirNames["corpus"] . '/' . $contentObj->DirName . '_mwe_annotations.json' ;