diff --git a/.php_cs.cache b/.php_cs.cache index d105383..f71465c 100644 --- a/.php_cs.cache +++ b/.php_cs.cache @@ -1 +1 @@ -{"php":"5.6.35","version":"2.16.1","indent":" ","lineEnding":"\n","rules":{"blank_line_after_namespace":true,"braces":true,"class_definition":true,"constant_case":true,"elseif":true,"function_declaration":true,"indentation_type":true,"line_ending":true,"lowercase_keywords":true,"method_argument_space":{"on_multiline":"ensure_fully_multiline"},"no_break_comment":true,"no_closing_tag":true,"no_spaces_after_function_name":true,"no_spaces_inside_parenthesis":true,"no_trailing_whitespace":true,"no_trailing_whitespace_in_comment":true,"single_blank_line_at_eof":true,"single_class_element_per_statement":{"elements":["property"]},"single_import_per_statement":true,"single_line_after_imports":true,"switch_case_semicolon_to_colon":true,"switch_case_space":true,"visibility_required":true,"encoding":true,"full_opening_tag":true},"hashes":{"index.php":3351273838,"src\/App.php":2229694930,"src\/config.php":2514023755,"src\/request.php":1078107796,"src\/WorldlangDictUtils.php":387099823,"src\/Parsedown.php":3204335427,"src\/test-ipa.php":3271240354,"templates\/boilerplate\/index.php":2301605749,"templates\/menalar\/index.php":3806569683,"templates\/identity\/index.php":544792056,"templates\/photon\/index.php":4187379909,"models\/WordList.php":2484934148,"models\/Word.php":2613674344,"models\/Request.php":1680315779,"controllers\/ToolController.php":2710750231,"controllers\/IndexController.php":580255643,"controllers\/SearchController.php":2541276491,"controllers\/WordListController.php":3775586406,"src\/router.php":3067629955,"models\/Page.php":4038198180,"models\/WorldlangDictConfig.php":677662292,"views\/IndexView.php":2999675711,"views\/WordView.php":2610577676,"views\/SearchView.php":501353686,"views\/indexView.php":2882736464,"views\/ToolView.php":1292037398,"views\/WordListView.php":633425177,"controllers\/WordController.php":323154340}} \ No newline at end of file +{"php":"5.6.35","version":"2.16.1","indent":" ","lineEnding":"\n","rules":{"blank_line_after_namespace":true,"braces":true,"class_definition":true,"constant_case":true,"elseif":true,"function_declaration":true,"indentation_type":true,"line_ending":true,"lowercase_keywords":true,"method_argument_space":{"on_multiline":"ensure_fully_multiline"},"no_break_comment":true,"no_closing_tag":true,"no_spaces_after_function_name":true,"no_spaces_inside_parenthesis":true,"no_trailing_whitespace":true,"no_trailing_whitespace_in_comment":true,"single_blank_line_at_eof":true,"single_class_element_per_statement":{"elements":["property"]},"single_import_per_statement":true,"single_line_after_imports":true,"switch_case_semicolon_to_colon":true,"switch_case_space":true,"visibility_required":true,"encoding":true,"full_opening_tag":true},"hashes":{"index.php":3662487177,"src\/App.php":2229694930,"src\/config.php":2514023755,"src\/request.php":1078107796,"src\/WorldlangDictUtils.php":387099823,"src\/Parsedown.php":3204335427,"src\/test-ipa.php":3271240354,"templates\/boilerplate\/index.php":2301605749,"templates\/menalar\/index.php":2281042646,"templates\/identity\/index.php":544792056,"templates\/photon\/index.php":4187379909,"models\/WordList.php":2484934148,"models\/Word.php":1557902953,"models\/Request.php":177841749,"controllers\/ToolController.php":155173001,"controllers\/IndexController.php":905856578,"controllers\/SearchController.php":307256060,"controllers\/WordListController.php":2768928106,"src\/router.php":3067629955,"models\/Page.php":4038198180,"models\/WorldlangDictConfig.php":677662292,"views\/IndexView.php":2377744807,"views\/WordView.php":555201782,"views\/SearchView.php":2364620608,"views\/indexView.php":2882736464,"views\/ToolView.php":2465482814,"views\/WordListView.php":633425177,"controllers\/WordController.php":808365098,"config.php":106939348,"WorldlangDictUtils.php":3740432248,"models\/Tool.php":2087329458,"router.php":445095620,"bootstrap.php":2008436989}} \ No newline at end of file diff --git a/WorldlangDictUtils.php b/WorldlangDictUtils.php index b7028c4..bb18128 100644 --- a/WorldlangDictUtils.php +++ b/WorldlangDictUtils.php @@ -8,14 +8,13 @@ public static function makeUri($config, $controller) return $config->siteUri.$config->lang.'/'.$controller.$request->linkQuery; } - public static function changeLangUri($config, $request, $lang) { + public static function changeLangUri($config, $request, $lang) + { if (is_null($request->arguments)) { $args = ''; - } - else if (sizeof($request->arguments) == 1) { + } elseif (sizeof($request->arguments) == 1) { $args = $request->arguments[0]; - } - else { + } else { $args = implode('/', $request->arguments); } return $config->siteUri.$lang.'/' diff --git a/bootstrap.php b/bootstrap.php index 0f77716..843b1b6 100644 --- a/bootstrap.php +++ b/bootstrap.php @@ -22,4 +22,4 @@ include_once './controllers/IndexController.php'; $config = new WorldlangDictConfig(); -include_once './config.php'; \ No newline at end of file +include_once './config.php'; diff --git a/controllers/ToolController.php b/controllers/ToolController.php index 9b70ff6..d51b565 100644 --- a/controllers/ToolController.php +++ b/controllers/ToolController.php @@ -19,16 +19,17 @@ public static function run($config, $request, &$page) $page->setTitle($config->getTrans('tools button')); } - public static function minimalPairDetector($config, $request, &$page) { + public static function minimalPairDetector($config, $request, &$page) + { $nearMatches = Tool::minimalPairDetector($config, $request); ToolView::minimalPairDetector($config, $request, $nearMatches, $page); $page->setTitle($config->getTrans('minimum pair title')); } - public static function homonymTerminator($config, $request, &$page) { + public static function homonymTerminator($config, $request, &$page) + { $genWords = Tool::homonymTerminator($config, $request); ToolView::homonymTerminator($config, $request, $genWords, $page); $page->setTitle($config->getTrans('homonym terminator title')); } - } diff --git a/index.php b/index.php index 5e6a16f..6eee6c7 100644 --- a/index.php +++ b/index.php @@ -1,4 +1,5 @@ options['root']) && !empty($request->options['root'])) { + $root[] = $newRoot = $request->options['root']; + $genList[$newRoot][$newRoot] = "|$newRoot|"; + } + + // Create arrays for 3 category types, put all roots in genList. foreach ($config->dictionary[$config->worldlang] as $word=>$entry) { if ($entry['Category']=='root') { $root[]=$word; - $genList[$word][$currentRoot] = 'Root'; + $genList[$word]["|$word|"] = "|$word|"; } elseif ($entry['Category']=='affix' && $word[0]=='-') { $suffix[]= $word; } elseif ($entry['Category']=='affix') { $prefix[] = $word; } } - - // Add the new root - if (isset($request->options['root']) && !empty($request->options['root'])) { - $root[] = $request->options['root']; - } - - // Generate all word combinations + + // Generate all combinations, duplicate if combos on duplicate letter foreach ($root as $currentRoot) { - foreach ($suffix as $currentSuffix) { - $genWord = $currentRoot.substr($currentSuffix, 1); - $genList[$genWord][$currentRoot] = "$currentRoot-$currentSuffix"; - } foreach ($prefix as $currentPrefix) { $genWord = substr($currentPrefix, 0, -1).$currentRoot; - $genList[$genWord][$currentRoot] = "$currentPrefix-$currentRoot"; + $genList[$genWord][$currentRoot] = "$currentPrefix-|$currentRoot|"; + + if (substr($currentPrefix, -2, 1) == $currentRoot[0]) { + $genWord = substr($currentPrefix, 0, -2) . $currentRoot; + $genList[$genWord][$currentRoot] = "$currentPrefix-|$currentRoot|"; + } + } + foreach ($suffix as $currentSuffix) { + $genWord = $currentRoot.substr($currentSuffix, 1); + $genList[$genWord][$currentRoot] = "|$currentRoot|-$currentSuffix"; + + if (substr($currentRoot, -1) == $currentSuffix[1]) { + $genWord = $currentRoot.substr($currentSuffix, 2); + $genList[$genWord][$currentRoot] = "|$currentRoot|-$currentSuffix"; + } } } ksort($genList); - + return $genList; } - - public static function minimalPairDetector ($config, $request) { + + public static function minimalPairDetector($config, $request) + { $words = array_keys($config->dictionary[$config->worldlang]); $numWords = sizeof($words); $nearMatches = []; $checkWord = isset($request->options['word']) ? strtolower($request->options['word']) : null; - + if (empty($checkWord)) { for ($i = 0; $i < $numWords; $i++) { for ($j = $i+1; $j < $numWords; $j++) { @@ -61,7 +74,7 @@ public static function minimalPairDetector ($config, $request) { } } } - + return $nearMatches; } -} \ No newline at end of file +} diff --git a/models/Word.php b/models/Word.php index b42c74d..b86ac45 100644 --- a/models/Word.php +++ b/models/Word.php @@ -26,10 +26,11 @@ public function __construct($config, $data) $this->ipa($config); } - private function processEtymology($config) { - if(strpos($this->etymology, '+')) { + private function processEtymology($config) + { + if (strpos($this->etymology, '+')) { $words = explode(' + ', $this->etymology); - foreach($words as $word) { + foreach ($words as $word) { $links[] = WorldlangDictUtils::makeLink($config, 'leksi/'.$word, $word); } $this->etymology = implode(' + ', $links); diff --git a/templates/menalar/index.php b/templates/menalar/index.php index ad30a60..3763c72 100644 --- a/templates/menalar/index.php +++ b/templates/menalar/index.php @@ -1,5 +1,6 @@ diff --git a/views/ToolView.php b/views/ToolView.php index de5429b..9bf685a 100644 --- a/views/ToolView.php +++ b/views/ToolView.php @@ -6,7 +6,7 @@ class ToolView public static function toolList($config, &$page) { $page->content .= '

'.$config->getTrans('tools button').'

- +

'.$config->getTrans('homonym terminator title').'

@@ -14,7 +14,7 @@ public static function toolList($config, &$page)

'.$config->getTrans('homonym terminator description').'

- +

'.$config->getTrans('minimum pair title').'

@@ -24,8 +24,9 @@ public static function toolList($config, &$page)
'; } - - public static function homonymTerminator($config, $request, $genList, &$page) { + + public static function homonymTerminator($config, $request, $genList, &$page) + { $page->content .= '

'.$config->getTrans('homonym terminator title').'

'; $page->content .= '
@@ -34,25 +35,26 @@ public static function homonymTerminator($config, $request, $genList, &$page) {
'; - - foreach ($genList as $genWord=>$genRoots) { - if (sizeof($genRoots)>1 && (!isset($request->options['root']) || isset($genRoots[$request->options['root']]))) { + + foreach ($genList as $genWord=>$sources) { + // Show all or only show ones related to the root. + if (sizeof($sources)>1 && (!isset($request->options['root']) || isset($sources[$request->options['root']]))) { if (isset($config->dictionary['glb'][$genWord])) { $definition = '
'.$config->dictionary['glb'][$genWord][DefinitionEng]; } else { $definition = ""; } - $page->content .= '
  • '.$genWord."
    ".$config->getTrans('homonym terminator conflicting msg'). - " ". implode($genRoots, ', ').$definition."
  • "; + $page->content .= '
  • ['.$genWord."]
    ".$config->getTrans('homonym terminator conflicting msg'). + " ". implode($sources, ', ').$definition."
  • "; } } $page->content .= ""; } - - public static function minimalPairDetector ($config, $request, $nearMatches, &$page) { - + + public static function minimalPairDetector($config, $request, $nearMatches, &$page) + { $searchTerm = isset($request->options['word']) ? $request->options['word'] : ""; - + $page->content = ''; $page->content .= '

    '.$config->getTrans('minimum pair title').'

    '; $page->content .= ' @@ -63,9 +65,9 @@ public static function minimalPairDetector ($config, $request, $nearMatches, &$p '; - + $numWords = sizeof($words); - + foreach ($nearMatches as $word=>$data) { foreach ($data as $match=>$distance) { if ($distance == 1) { @@ -76,7 +78,7 @@ public static function minimalPairDetector ($config, $request, $nearMatches, &$p } } } - + $page->content .='

    '.sprintf($config->getTrans('minimum pair result diff', '1')).'

    '.sprintf($config->getTrans('minimum pair result diff', '2')).'