Exemple #1
0
 /**
  * Create edit fields from xml property
  */
 protected function toEditFields(&$textbox1)
 {
     global $wgOut, $wgScriptPath;
     // add javascript functions
     $wgOut->addScript("<script type=\"text/javascript\" src=\"{$wgScriptPath}/autocomplete.10.js\"></script>");
     //$tm = new TipManager();
     $source = '';
     $result = '';
     $invalidStyle = ' style="background-color:#fdd;"';
     $surnames = '';
     $places = '';
     $fromYear = '';
     $fromYearStyle = '';
     $toYear = '';
     $toYearStyle = '';
     $sourceStyle = '';
     if (isset($this->xml)) {
         $source = htmlspecialchars((string) $this->xml->source);
         if ($source && !StructuredData::titleExists(NS_SOURCE, $source)) {
             $sourceStyle = $invalidStyle;
             $result .= "<p><font color=red>Please enter the title of a Source page</font></p>";
         }
         foreach ($this->xml->surname as $surname) {
             $surnames .= htmlspecialchars($surname) . "\n";
         }
         foreach ($this->xml->place as $place) {
             $places .= htmlspecialchars($place) . "\n";
         }
         $fromYear = htmlspecialchars((string) $this->xml->from_year);
         $toYear = htmlspecialchars((string) $this->xml->to_year);
         if (!StructuredData::isValidYear($fromYear) || !StructuredData::isValidYear($toYear)) {
             if (!StructuredData::isValidYear($fromYear)) {
                 $fromYearStyle = $invalidStyle;
             }
             if (!StructuredData::isValidYear($toYear)) {
                 $toYearStyle = $invalidStyle;
             }
             $result .= "<p><font color=red>The year range is not valid</font></p>";
         }
     }
     // display edit fields
     $result .= "<h2>Transcript information</h2><table>" . "<tr><td align=right>Source:</td><td align=left><input tabindex=\"1\" class=\"source_input\" name=\"source\" value=\"{$source}\" size=\"60\"{$sourceStyle}/></td></tr></table>" . "<br><label for=\"surnames\">Surnames (one per line):</label><br><textarea tabindex=\"1\" name=\"surnames\" rows=\"3\" cols=\"60\">{$surnames}</textarea>" . "<br><label for=\"places\">Places (one per line):</label><br><textarea class=\"place_input\" tabindex=\"1\" name=\"places\" rows=\"3\" cols=\"60\">{$places}</textarea>" . "<table><tr>" . "<td align=left>Year range:</td><td align=left><input tabindex=\"1\" name=\"fromYear\" value=\"{$fromYear}\" size=\"5\"{$fromYearStyle}/>" . "&nbsp;&nbsp;-&nbsp;<input tabindex=\"1\" name=\"toYear\" value=\"{$toYear}\" size=\"5\"{$toYearStyle}/>" . "</td></tr></table>" . "<br/>Text:<br/>";
     return $result;
 }
Exemple #2
0
 /**
  * Return true if xml property is valid
  */
 protected function validateData()
 {
     if (isset($this->xml)) {
         return StructuredData::isValidYear((string) $this->xml->from_year) && StructuredData::isValidYear((string) $this->xml->to_year) && StructuredData::isValidUrl((string) $this->xml->url);
     }
     return true;
 }
Exemple #3
0
 /**
  * Create edit fields from xml property
  */
 protected function toEditFields(&$textbox1)
 {
     global $wgOut, $wgScriptPath;
     // add javascript functions
     $wgOut->addScript("<script type=\"text/javascript\" src=\"{$wgScriptPath}/autocomplete.10.js\"></script>");
     $invalidStyle = ' style="background-color:#fdd;"';
     $result = '';
     $surnames = '';
     $places = '';
     $fromYear = '';
     $fromYearStyle = '';
     $toYear = '';
     $toYearStyle = '';
     $exists = isset($this->xml);
     if (isset($this->xml)) {
         foreach ($this->xml->surname as $surname) {
             $surnames .= htmlspecialchars($surname) . "\n";
         }
         foreach ($this->xml->place as $place) {
             $places .= htmlspecialchars($place) . "\n";
         }
         $fromYear = htmlspecialchars((string) $this->xml->from_year);
         $toYear = htmlspecialchars((string) $this->xml->to_year);
         if (!StructuredData::isValidYear($fromYear) || !StructuredData::isValidYear($toYear)) {
             if (!StructuredData::isValidYear($fromYear)) {
                 $fromYearStyle = $invalidStyle;
             }
             if (!StructuredData::isValidYear($toYear)) {
                 $toYearStyle = $invalidStyle;
             }
             $result .= "<p><font color=red>The year range is not valid</font></p>";
         }
     } else {
         // new article
         if (preg_match('/^\\S+(\\s+\\S+)? in /', $this->titleString)) {
             // surname in place
             $pos = mb_strpos($this->titleString, ' in ');
             $surnames = htmlspecialchars(mb_substr($this->titleString, 0, $pos));
             $places = htmlspecialchars(mb_substr($this->titleString, $pos + 4));
             if (mb_strpos($textbox1, '[[Category:Surname in place]]') === false) {
                 $textbox1 .= "\n\n[[Category:Surname in place]]";
                 // add to category
             }
         } else {
             if (preg_match('/research guide/i', $this->titleString)) {
                 // research guide
                 if (mb_strpos($textbox1, '[[Category:Research guides]]') === false) {
                     $textbox1 .= "\n\n[[Category:Research guides]]";
                     // add to category
                 }
             } else {
                 if (preg_match('/how to/i', $this->titleString)) {
                     // how to
                     if (mb_strpos($textbox1, '[[Category:How to]]') === false) {
                         $textbox1 .= "\n\n[[Category:How to]]";
                         // add to category
                     }
                 }
             }
         }
     }
     $result .= "<br><label for=\"surnames\">Surnames (one per line):</label><br><textarea tabindex=\"1\" name=\"surnames\" rows=\"3\" cols=\"60\">{$surnames}</textarea>";
     $result .= "<br><label for=\"places\">Places (one per line):</label><br><textarea class=\"place_input\" tabindex=\"1\" name=\"places\" rows=\"3\" cols=\"60\">{$places}</textarea>";
     $result .= "<table><tr>";
     $result .= "<td align=left>Year range:</td><td align=left><input tabindex=\"1\" name=\"fromYear\" value=\"{$fromYear}\" size=\"5\"{$fromYearStyle}/>";
     $result .= "&nbsp;&nbsp;-&nbsp;<input tabindex=\"1\" name=\"toYear\" value=\"{$toYear}\" size=\"5\"{$toYearStyle}/>";
     $result .= "</td></tr></table>Text:<br>";
     return $result;
 }
Exemple #4
0
 /**
  * Returns an error if there is something wrong with one of the previous parents in the array
  * Returns null if everything is fine
  * @return string
  */
 private static function isInvalidAlsoLocatedIn($values)
 {
     foreach ($values as $value) {
         $title = Title::newFromText((string) $value['place'], NS_PLACE);
         if (!$title || !$title->exists()) {
             return "Also located in place: {$value['place']} not found";
         }
         if (!StructuredData::isValidYear((string) $value['from_year'], true) || !StructuredData::isValidYear((string) $value['to_year'], true)) {
             return "Also located in year range not valid: enter year, ?, or present";
         }
     }
     return null;
 }
Exemple #5
0
 /**
  * Return true if xml property is valid
  */
 protected function validateData(&$textbox1)
 {
     if (!StructuredData::isRedirect($textbox1)) {
         foreach ($this->xml->repository as $repository) {
             if (!(string) $repository['availability']) {
                 return false;
             }
         }
         return StructuredData::isValidYear((string) $this->xml->from_year) && StructuredData::isValidYear((string) $this->xml->to_year);
     }
     return true;
 }
Exemple #6
0
 /**
  * Create edit fields from xml property
  */
 protected function toEditFields(&$textbox1)
 {
     global $wgOut, $wgScriptPath;
     // add javascript functions
     $wgOut->addScript("<script type=\"text/javascript\" src=\"{$wgScriptPath}/autocomplete.10.js\"></script>");
     $wgOut->addScript("<script type=\"text/javascript\" src=\"{$wgScriptPath}/userpage.4.js\"></script>");
     $tm = new TipManager();
     $invalidStyle = ' style="background-color:#fdd;"';
     $result = '';
     if ($this->isSubpage) {
         $surnames = '';
         $places = '';
         $fromYear = '';
         $toYear = '';
         $fromYearStyle = '';
         $toYearStyle = '';
         if (isset($this->xml)) {
             $fromYear = htmlspecialchars((string) $this->xml->from_year);
             $toYear = htmlspecialchars((string) $this->xml->to_year);
             foreach ($this->xml->surname as $surname) {
                 $surnames .= htmlspecialchars($surname) . "\n";
             }
             foreach ($this->xml->place as $place) {
                 $places .= htmlspecialchars($place) . "\n";
             }
             if (!StructuredData::isValidYear($fromYear) || !StructuredData::isValidYear($toYear)) {
                 if (!StructuredData::isValidYear($fromYear)) {
                     $fromYearStyle = $invalidStyle;
                 }
                 if (!StructuredData::isValidYear($toYear)) {
                     $toYearStyle = $invalidStyle;
                 }
                 $result .= "<p><font color=red>The year range is not valid</font></p>";
             }
         }
         $result .= "<br><label for=\"surnames\">Surnames (one per line):</label><br><textarea tabindex=\"1\" name=\"surnames\" rows=\"3\" cols=\"60\">{$surnames}</textarea>";
         $result .= "<br><label for=\"places\">Places (one per line):</label><br><textarea class=\"place_input\" tabindex=\"1\" name=\"places\" rows=\"3\" cols=\"60\">{$places}</textarea>";
         $result .= "<table><tr>";
         $result .= "<td align=left>Year range:</td><td align=left><input tabindex=\"1\" name=\"fromYear\" value=\"{$fromYear}\" size=\"5\"{$fromYearStyle}/>";
         $result .= "&nbsp;&nbsp;-&nbsp;<input tabindex=\"1\" name=\"toYear\" value=\"{$toYear}\" size=\"5\"{$toYearStyle}/>";
         $result .= "</td></tr></table>Text:<br>";
     } else {
         $display = 'none';
         $rows = '';
         $i = 0;
         if (isset($this->xml)) {
             foreach ($this->xml->researching as $researching) {
                 $display = 'block';
                 $rows .= "<tr><td><input type=\"hidden\" name=\"researching_id{$i}\" value=\"" . ($i + 1) . "\"/>" . "<input tabindex=\"1\" type=\"text\" size=20 name=\"researching_surname{$i}\" value=\"" . htmlspecialchars((string) $researching['surname']) . "\"/></td>" . "<td><input class=\"place_input\" tabindex=\"1\" type=\"text\" size=30 name=\"researching_place{$i}\" value=\"" . htmlspecialchars((string) $researching['place']) . "\"/></td></tr>\n";
                 $i++;
             }
         }
         $result .= '<h2>Surnames and/or places you are researching' . $tm->addMsgTip('UserResearching') . '</h2>' . "<table id=\"researching_table\" border=0 width=\"500px\" style=\"display:{$display}\"><tr><th>Surname</th><th>Place (state, province, or country)</th></tr>" . "{$rows}</table><a href=\"javascript:void(0)\" onClick=\"addResearchInput(); return preventDefaultAction(event);\">Add Surname and/or Place</a>";
         $result .= '<br><br><h2>Text' . $tm->addMsgTip('UserText') . '</h2>';
         $result .= $tm->getTipTexts();
     }
     return $result;
 }