1<?php 2/* 3 hyphenation 1.1 for MoreCSS 1.0 BETA 4 4 Developed by yellowgreen designbüro published under MIT License. 5 6 http://morecss.yellowgreen.de/documentation/plugins/hyphenation/ 7 http://morecss.yellowgreen.de/documentation/information/legal/ 8*/ 9 10 // Standard settings (see hyphenation.php for other settings) 11 $GLOBALS["path_to_patterns"] = "patterns/"; 12 $GLOBALS["dictionary"] = "dictionary.txt"; 13 $GLOBALS["hyphen"] = "­"; 14 $GLOBALS["exclude_tags"] = array("code", "pre", "script", "style"); 15 16 // MoreCSS settings 17 if(isset($_POST["language"])) switch($_POST["language"]) { 18 case "german" : case "de" : $GLOBALS["language"] = "de"; break; 19 case "english" : case "en" : $GLOBALS["language"] = "en"; break; 20 case "spanish" : case "es" : $GLOBALS["language"] = "es"; break; 21 case "french" : case "fr" : $GLOBALS["language"] = "fr"; break; 22 case "dutch" : case "nl" : $GLOBALS["language"] = "nl"; break; 23 case "swedish" : case "sv" : $GLOBALS["language"] = "sv"; break; 24 default : $GLOBALS["language"] = "en"; break; 25 } 26 27// OUTPUT PHP 28 29 if(isset($_POST["text"])) { 30 header('content-type: text/html; charset=utf-8'); 31 32 if(isset($_POST["restrict"])) switch($_POST["restrict"]) { 33 case "large-words" : $GLOBALS["leftmin"] = 4; $GLOBALS["rightmin"] = 4; $GLOBALS["charmin"] = 10; break; 34 case "normal" : $GLOBALS["leftmin"] = 2; $GLOBALS["rightmin"] = 3; $GLOBALS["charmin"] = 6; break; 35 case "none" : default : $GLOBALS["leftmin"] = 2; $GLOBALS["rightmin"] = 2; $GLOBALS["charmin"] = 2; break; 36 } 37 38 // Get hyphenated content 39 include("hyphenation.php"); 40 echo hyphenation(stripslashes($_POST["text"])); 41 } else { 42 43// OUTPUT JAVASCRIPT 44 45 header('content-type: text/javascript; charset=utf-8'); 46 47 echo ' 48 MoreCSS.properties["hyphenation"] = "hyphenation"; 49 50 // hyphenation 51 MoreCSS.hyphenation = function(element, properties) { 52 var mode = MoreCSS.getPropertyValue(properties, "hyphenation", "english"); 53 var restrict = MoreCSS.getPropertyValue(properties, "hyphenation-restrict", "normal"); 54 55 if(mode != "no-hyphenation") { 56 var hyphContent = MoreCSS.createXMLHttpRequest(); 57 hyphContent.open("post", "' . $_SERVER['PHP_SELF'] . '", true); 58 hyphContent.setRequestHeader("content-type", "application/x-www-form-urlencoded"); 59 hyphContent.send("text=" + encodeURIComponent(element.innerHTML) + "&language=" + mode + "&restrict=" + restrict); 60 hyphContent.onreadystatechange = function() { 61 if(hyphContent.readyState == 4 && hyphContent.status == 200) element.innerHTML = decodeURIComponent(hyphContent.responseText); 62 }; 63 } else { 64 html_entity_decode = function(string) { 65 var tempElement = document.createElement("textarea"); 66 tempElement.innerHTML = string.replace(/</g, "<").replace(/>/g, ">"); 67 return tempElement.value; 68 } 69 70 if(element.innerHTML.search(new RegExp(html_entity_decode("' . $GLOBALS["hyphen"] . '"))) > 0) 71 element.innerHTML = element.innerHTML.split(html_entity_decode("' . $GLOBALS["hyphen"] . '")).join(""); 72 } 73 }; 74 75 '; 76 } 77?>