Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Moves Options-Class up one level

Also additions to the build-script and the documentation have been made.
  • Loading branch information...
commit 52de2c34c3290e21534f4825b1ed6547104b7821 1 parent 07d7e16
@heiglandreas authored
View
8 README
@@ -1,6 +1,6 @@
README:
-Copyright (c) 2009 Andreas Heigl<andreas@heigl.org>
+Copyright (c) 2011 Andreas Heigl<andreas@heigl.org>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
@@ -30,13 +30,13 @@ This package has the following requirements:
* Input has to be UTF8-encoded.
On loading the \Org\Heigl\Hyphenator\Hyphenator-class the internal encoding for
-the Multibyte-String-Extension will be set to UTF8.
+the Multibyte-String-Extension will be set to UTF8.
+----------------------------------------------------------------------------+
| Installation: |
+----------------------------------------------------------------------------+
-Copy at least the 'Hyphenator'-folder somewhere to your PHP-include-directory
+Copy the 'Org/Heigl/Hyphenator'-folder somewhere to your PHP-include-directory
+----------------------------------------------------------------------------+
| Usage: |
@@ -55,4 +55,4 @@ echo $hyphenatedText;
+----------------------------------------------------------------------------+
| Documentation: |
+----------------------------------------------------------------------------+
-Use the included documentation from the 'doc/api'-folder
+More documentation can be found in the 'documentation'-folder
View
20 build.xml
@@ -38,15 +38,20 @@
<!-- This target deletes all temporary files from the directory -->
<target name="clean">
- <delete dir="doc/" />
- <delete dir="build" />
+ <delete includeemptydirs="true">
+ <fileset dir="${basedir}/build">
+ <include name="**/*" />
+ </fileset>
+ </delete>
</target>
<target name="build"
- depends="clean, doc, test, distribute" />
+ depends="clean, doc, test, docbook, distribute" />
<target name="test">
<mkdir dir="${basedir}/build/logs"/>
+ <mkdir dir="${basedir}/build/phpunit"/>
+ <mkdir dir="${basedir}/build/phpunit/coverage"/>
<delete includeemptydirs="true" verbose="false">
<fileset dir="${basedir}/build/phpunit/coverage">
<include name="**/*" />
@@ -68,9 +73,10 @@
<property file="build.number" />
<mkdir dir="${basedir}/dist"/>
<zip destfile="dist/Org_Heigl_Hyphenator-Build_${build.number}.zip">
- <zipfileset dir="build/api" prefix="doc/api" />
- <zipfileset dir="build/doc" prefix="doc/manuals" />
- <zipfileset dir="src" />
+ <zipfileset dir="build/api" prefix="documentation/api" />
+ <zipfileset dir="build/doc" prefix="documentation/manual" />
+ <zipfileset dir="build/phpunit/coverage" prefix="documentation/coverage" />
+ <zipfileset dir="src/Org/Heigl/Hyphenator" prefix="library/Org/Heigl/Hyphenator"/>
<fileset dir="." includes="CHANGELOG" />
<fileset dir="." includes="LICENSE" />
<fileset dir="." includes="README" />
@@ -86,7 +92,7 @@
</fileset>
</delete>
<exec executable="xsltproc" dir="${basedir}">
- <arg line="--xinclude --output build/doc/index.html --stringparam html.stylesheet css/style.css doc/main.xml "/>
+ <arg line="--output build/doc/index.html doc/hyphenator.xsl doc/main.xml "/>
</exec>
<copy todir="${basedir}/build/doc/">
<fileset dir="${basedir}/doc/inc/"/>
View
1  build/.gitignore
@@ -1 +0,0 @@
-*
View
47 doc/configuration.xml
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<chapter id="hyphenator.configuration">
+ <title>Configuration-Options</title>
+ <para>
+ The <classname>Org\Heigl\Hyphenator</classname>-Package can be configured
+ using the <filename>Hyphenator.properties</filename>-File inside
+ the defined <varname>HYPHENATOR_HOME</varname>-Directory.
+ </para>
+ <para>
+ The <varname>HYPHENATOR_HOME</varname>-Directory will be retrieved on
+ Instantiation of the <package>Hyphenator</package> by checking
+ the following possibilities.
+ <orderedlist>
+ <listitem>Check for a folder defined via <methodname>Org\Heigl\Hyphenator::setDefaultHomePath</methodname>.</listitem>
+ <listitem>Check for a PHP-constant <varname>HYPHENATOR_HOME</varname>.</listitem>
+ <listitem>Check for an environment-variable <varname>HYPHENATOR_HOME</varname>.</listitem>
+ <listitem>Use the in the package included <filename>share</filename>-folder</listitem>
+ </orderedlist>
+ </para>
+ <para>
+ You can also configure the <package>Hyphenator</package> via an
+ <classname>Org\Heigl\Hyphenator\Options\Options</classname>-Instance
+ that can either be retrieved from or replace an existing
+ Options-Instance in an existing Hyphenator-Object;
+ <programlisting language="php" id="hyphenator.configuration.setorgetoptions"><![CDATA[$hyphenator = Hyphenator::factory();
+// Retrieve an existing Options-Instance
+$options = $hyphenator->getOptions();
+// Set an Options
+$options->setLeftMin(3);
+// You can also cascade that.
+$hyphenator->getOptions()->setLeftMin(3);
+// Or you can create a new Options-Object
+$options = new \Org\Heigl\Hyphenator\Options\Options();
+$options->setLeftMin(3);
+$hyphenator->setOptions($options);
+// CAVEAT: This will also set all other Options to the default values!]]></programlisting>
+ </para>
+ <para>
+ The following configuration-Options can be used in the
+ </para>
+ <para>
+ These are
+ </para>
+ <definitionlist>
+ <listitem></listitem>
+ </definitionlist>
+</chapter>
View
34 doc/examples.xml
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<chapter id="hyphenator.examples">
+ <title>Usage-Examples</title>
+ <sect1>
+ <title>Simple Example</title>
+ <para>
+ <programlisting language="php" id="example.simple">
+ <![CDATA[use \Org\Heigl\Hyphenator as h;
+$hyphenator = h\Hyphenator::factory();
+$result = $hyphenator->hyphenate('This is your text to be hyphenated');]]>
+ </programlisting>
+ </para>
+ <para>
+ Plainly create a <classname>Hyphenator</classname>-Object via the
+ factory-method and invoke its <methodname>hyphenate</methodname>-method.
+ </para>
+ <para>
+ It will be hard to make it more simple.
+ </para>
+ </sect1>
+ <sect1>
+ <title>Simple example with non-standard Hyphenator-Home-folder</title>
+ <para>
+ <programlisting language="php"><![CDATA[use \Org\Heigl\Hyphenator as h;
+$hyphenator = h\Hyphenator::factory('/path/to/home/directory');
+$result = $hyphenator->hyphenate('This is your text to be hyphenated');]]></programlisting>
+ </para>
+ <para>
+ Of course the Hyphenators home-folder has to be available in the
+ given location and has to be writeable to hte user executing the
+ hyphenator (normaly the webserver-user).
+ </para>
+ </sect1>
+</chapter>
View
19 doc/hyphenator.xsl
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xsl:stylesheet
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ xmlns:fo="http://www.w3.org/1999/XSL/Format"
+ version="1.0">
+
+ <xsl:import href="http://www.heigl.org/docbook/xsl/html/chunk.xsl"/>
+
+ <xsl:param name="html.stylesheet">css/style.css</xsl:param>
+ <xsl:param name="admon.graphics" select="1"/>
+ <xsl:param name="chunker.output.encoding" select="'UTF-8'"/>
+ <xsl:param name="chunk.section.depth" select="0"/>
+
+ <xsl:template match="lineannotation">
+ <fo:inline font-style="italic">
+ <xsl:call-template name="inline.charseq"/>
+ </fo:inline>
+ </xsl:template>
+</xsl:stylesheet>
View
102 doc/inc/css/style.css
@@ -35,26 +35,21 @@ PRE.PROGRAMLISTING
{
font-family:monospace;
white-space: pre;
- width: 100%;
- background-color: #ffffcc;
+ background-color: #dddddd;
border:solid;
color: #000000;
- border-color: #009999;
- border-left: solid #009999 2px;
- border-right: solid #009999 2px;
- border-top: solid #009999 2px;
- border-bottom: solid #009999 2px;
-
- padding-left: 15pt;
+ border: 1px solid #888888;
+ padding: 1em;
}
-H1
-{
+h1{
color: #cccccc;
- background-color: #ffffff;
+ background-color: #000000;
font-variant: small-caps;
- padding: 0.5em;
+ line-height: 1.5em;
+ padding-left:0.5em;
}
+.book h1 {background-color: transparent;}
H1.TITLE
{
@@ -85,7 +80,7 @@ h2
color: #cccccc ;
font-style: italic;
background-color: #ffffff;
- padding: 0.5em
+ padding: 0.5em 0;
}
TABLE.IMPORTANT
@@ -144,7 +139,7 @@ DIV.VARIABLELIST {
PADDING: 1px
}
a{
- text-decoration:none;
+ text-decoration:none;
color: inherit;
}
a:link{
@@ -211,22 +206,22 @@ hr {
}
div.navfooter td[align=right] a,div.navheader td[align=right] a {
- background: transparent url(../img/right.png) right center no-repeat;
- text-indent:-10000px;
- display:inline-block;
- height:20px;
- width:20px;
- color:transparent;
- text-shadow: transparent 0 0 0;
+ background: transparent url(../img/right.png) right center no-repeat;
+ text-indent:-10000px;
+ display:inline-block;
+ height:20px;
+ width:20px;
+ color:transparent;
+ text-shadow: transparent 0 0 0;
}
div.navfooter td[align=left] a,div.navheader td[align=left] a {
- background: transparent url(../img/left.png) right center no-repeat;
- text-indent:-10000px;
- display:inline-block;
- height:20px;
- width:20px;
- color:transparent;
- text-shadow: transparent 0 0 0;
+ background: transparent url(../img/left.png) right center no-repeat;
+ text-indent:-10000px;
+ display:inline-block;
+ height:20px;
+ width:20px;
+ color:transparent;
+ text-shadow: transparent 0 0 0;
}
DIV.NUKEFOOTER {
@@ -264,36 +259,49 @@ DIV.EXAMPLE{
}
div.toc{
- background-color:transparent;
- padding: 10px;
+ background-color:transparent;
+ padding: 10px;
}
div.toc dl {
- padding-left: 10px;
+ padding-left: 10px;
}
div.chapter .toc {
- margin-left: 20px;
- margin-bottom: 20px;
- width: 150px;
- position:absolute;
- top: 0;
- right:0;
- background-color: lightgoldenrodyellow;
- border: 1px solid gray;
-}
-
-UL {
- list-style: url("images/tux-bullet.png") disc;
+ display:none;
+ margin-left: 20px;
+ margin-bottom: 20px;
+ width: 150px;
+ position:absolute;
+ top: 0;
+ right:0;
+ background-color: lightgoldenrodyellow;
+ border: 1px solid gray;
+}
+
+div.titlepage .copyright, div.titlepage div.author{
+ padding: 0 2em;
+}
+
+UL, OL, DL {
+ list-style-position: inside;
+}
+ul,ol {
+ padding-left: 2em;
+ text-indent:-2em;
}
-
-div.chapter {
+ul {
+ list-style-type: circle;
+}
+
+div.chapter, div.toc {
position:relative;
top:0;
left: 0;
+ padding: 1em 2em;
}
div.chapter p {
- padding: 0.5em 20px;
+ padding: 0.5em 0;
line-height: 1.3em;
}
View
25 doc/installation.xml
@@ -1,10 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<chapter id="hyphenator.installation">
<title>Installation</title>
- <sect1 id="hyphenator.installation.reauirements">
- <title>Requirements</title>
- </sect1>
- <sect1 id="hyphenator.installation.installation">
- <title>Installation</title>
- </sect1>
+ <para>
+ Installation is fairly simple.
+ <orderedlist>
+ <listitem>Take the <filename>Org</filename>-Folder and place it somewhere
+ your include-path reaches it.</listitem>
+ <listitem>Make the folder <filename>Org/Heigl/Hyphenator/shared</filename>
+ writeable. As an alternative you can also copy that folder to any
+ location you like and set the <varname>HYPHERNATOR_HOME</varname>-Environment
+ Variable or PHP-constant to that path before invoking the Hyphenator
+ for the first time.
+ </listitem>
+ <listitem>
+ Register the autoloader by calling <code>Org\Heigl\Hyphenator\Hyphenator::registerAutoload()</code>
+ </listitem>
+ <listitem>
+ Hyphenate!
+ </listitem>
+ </orderedlist>
+ </para>
</chapter>
View
19 doc/introduction.xml
@@ -1,19 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-
- -->
-<chapter id="hyphenator.introduction">
- <title>Introduction</title>
- <para>
- <classname>Org\Heigl\Hyphenator</classname> is a package to enable
- word-hyphenation in PHP. It uses the algorithms described by Marc Liang
- in his thesis Word Hyphenation by computer and the extensions described
- by ?? in his work ??.
- </para>
- <para>
- These algorithms are based on matching words against certain patterns
- that describe places inside a word where hyphenation is possible or
- must not occur. This Hyphenator uses the pattern-files from OpenOffice
- which are based on the pattern-files created for TeX.
- </para>
-</chapter>
View
2  doc/license.xml
@@ -2,6 +2,7 @@
<chapter id="hyphenator.license">
<title>Licenses</title>
<sect1 id="hyphenator.license.package">
+ <title>Hyphenator-Package</title>
<para>
<classname>Org\Heigl\Hyphenator</classname> is released unter the
<ulink url="http://www.opensource.org/licenses/mit-license.php">
@@ -35,6 +36,7 @@
</para>
</sect1>
<sect1 id="hyphenator.license.pattern">
+ <title>Hyphenation-Patterns</title>
<para>
The pattern files located in the folder share/files/dictionaries
are licensed under the <ulink url="http://www.opensource.org/licenses/lgpl-license.php">
View
34 doc/main.xml
@@ -1,13 +1,37 @@
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="http://www.heigl.org/docbook/xsl/html/chunk.xsl" ?>
<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN" "http://www.heigl.org/docbook/dtd/docbookx.dtd"[
-<!ENTITY introduction SYSTEM "introduction.xml">
+<!ENTITY prerequisites SYSTEM "prerequisites.xml">
<!ENTITY installation SYSTEM "installation.xml">
+<!ENTITY examples SYSTEM "examples.xml">
+<!ENTITY configuration SYSTEM "configuration.xml">
<!ENTITY licenses SYSTEM "license.xml">
]>
<book id="hyphenator" lang="en">
- <title>Org\Heigl\Hyphenator</title>
- &introduction;
- &installation;
- &licenses;
+ <bookinfo>
+ <title>Org\Heigl\Hyphenator - Manual</title>
+ <author><firstname>Andreas</firstname><surname>Heigl</surname></author>
+ <copyright><year>2011</year><holder>Andreas Heigl</holder></copyright>
+ </bookinfo>
+ <chapter id="hyphenator.introduction">
+ <title>Introduction</title>
+ <para>
+ <classname>Org\Heigl\Hyphenator</classname> is a package to enable
+ word-hyphenation in PHP. It uses the algorithms described by Marc Liang
+ in his thesis Word Hyphenation by computer and the extensions described
+ by ?? in his work ??.
+ </para>
+ <para>
+ These algorithms are based on matching words against certain patterns
+ that describe places inside a word where hyphenation is possible or
+ must not occur. This Hyphenator uses the pattern-files from OpenOffice
+ which are based on the pattern-files created for TeX.
+ </para>
+</chapter>
+ &prerequisites;
+ &installation;
+ &examples;
+ &configuration;
+ &licenses;
+
</book>
View
15 doc/prerequisites.xml
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ -->
+<chapter id="hyphenator.prerequisites">
+ <title>Prerequisites</title>
+ <para>
+ This Hyphenation-Package has the following requirements:
+ <itemizedlist>
+ <listitem>PHP >= 5.3</listitem>
+ <listitem>mbstring-extension</listitem>
+ <listitem>Currently all input has to be UTF-8 encoded</listitem>
+ </itemizedlist>
+ </para>
+</chapter>
View
8 docblox.dist.xml
@@ -4,7 +4,7 @@
<directory>src/</directory>
</files>
<parser>
- <target>doc/api/</target>
+ <target>build/api/</target>
<markers>
<item>TODO</item>
<item>FIXME</item>
@@ -16,13 +16,13 @@
<visibility>public</visibility>
</parser>
<transformer>
- <target>doc/api/</target>
+ <target>build/api/</target>
</transformer>
<logging>
<level>warn</level>
<paths>
- <default>{APP_ROOT}/doc/api/docblox.{DATE}.log</default>
- <errors>{APP_ROOT}/doc/api/docblox.{DATE}.errors.log</errors>
+ <default>{APP_ROOT}/build/api/docblox.{DATE}.log</default>
+ <errors>{APP_ROOT}/build/api/docblox.{DATE}.errors.log</errors>
</paths>
</logging>
<transformations>
View
8 src/Org/Heigl/Hyphenator/Filter/Filter.php
@@ -54,18 +54,18 @@
/**
* Storage of the options-object
*
- * @var \Org\Heigl\Hyphenator\Options\Options $_options
+ * @var \Org\Heigl\Hyphenator\Options $_options
*/
protected $_options = null;
/**
* Set the options-object for this filter
*
- * @param \Org\Heigl\Hyphenator\Options\Options $options The options to set
+ * @param \Org\Heigl\Hyphenator\Options $options The options to set
*
* @return Filter
*/
- public function setOptions(\Org\Heigl\Hyphenator\Options\Options $options)
+ public function setOptions(\Org\Heigl\Hyphenator\Options $options)
{
$this->_options=$options;
return $this;
@@ -74,7 +74,7 @@ public function setOptions(\Org\Heigl\Hyphenator\Options\Options $options)
/**
* Get the currently defined Options
*
- * @return \Org\Heigl\Hyphenator\Options\Options
+ * @return \Org\Heigl\Hyphenator\Options
*/
public function getOptions()
{
View
10 src/Org/Heigl/Hyphenator/Hyphenator.php
@@ -166,7 +166,7 @@
/**
* Storage for the Options-Object.
*
- * @var Options\Options $_options
+ * @var Options $_options
*/
private $_options = null;
@@ -194,11 +194,11 @@
/**
* Set the Options
*
- * @param \Org\Heigl\Hyphenator\Options\Options $options The options to set
+ * @param \Org\Heigl\Hyphenator\Options $options The options to set
*
* @return \Org\Heigl\Hyphenator\Hyphenator
*/
- public function setOptions(Options\Options $options)
+ public function setOptions(Options $options)
{
$this->_options = $options;
$this->_tokenizers->cleanup();
@@ -213,13 +213,13 @@ public function setOptions(Options\Options $options)
/**
* Get the Options
*
- * @return \Org\Heigl\Hyphenator\Options\Options
+ * @return \Org\Heigl\Hyphenator\Options
*/
public function getOptions()
{
if ( null === $this->_options ) {
$optFile = $this->getHomePath() . DIRECTORY_SEPARATOR . 'Hyphenator.properties';
- $this->setOptions(Options\Options::factory($optFile));
+ $this->setOptions(Options::factory($optFile));
}
return $this->_options;
}
View
10 src/Org/Heigl/Hyphenator/Options/Options.php → src/Org/Heigl/Hyphenator/Options.php
@@ -31,7 +31,7 @@
* @since 07.09.2011
*/
-namespace Org\Heigl\Hyphenator\Options;
+namespace Org\Heigl\Hyphenator;
use \Org\Heigl\Hyphenator\Exception;
@@ -245,7 +245,7 @@ public function setMinWordLength($minLength)
*
* @param int $wordLength The minimum word Length
*
- * @return \Org\Heigl\Hyphenator\Options\Options
+ * @return \Org\Heigl\Hyphenator\Options
*/
public function setWordMin($wordLength)
{
@@ -257,7 +257,7 @@ public function setWordMin($wordLength)
*
* @param int $quality
*
- * @return \Org\Heigl\Hyphenator\Options\Options
+ * @return \Org\Heigl\Hyphenator\Options
*/
public function setQuality($quality)
{
@@ -398,7 +398,7 @@ public function getTokenizers()
*
* @param string $file The config-file to be parsed
*
- * @return \Org\Heigl\Hyphenator\Options\Options
+ * @return \Org\Heigl\Hyphenator\Options
*/
public static function factory($file)
{
@@ -428,7 +428,7 @@ public static function factory($file)
*
* @param string $locale The locale to be set
*
- * @return \Org\Heigl\Hyphenator\Options\Options
+ * @return \Org\Heigl\Hyphenator\Options
*/
public function setDefaultLocale($locale)
{
View
2  tests/Org/Heigl/Hyphenator/Filter/FilterTest.php
@@ -33,7 +33,7 @@
namespace Org\Heigl\HyphenatorTest\Filter;
use \Org\Heigl\Hyphenator\Filter\Filter;
-use \Org\Heigl\Hyphenator\Options\Options;
+use \Org\Heigl\Hyphenator\Options;
use \Org\Heigl\Hyphenator\Tokenizer as t;
/**
View
6 tests/Org/Heigl/Hyphenator/OptionsTest.php
@@ -32,7 +32,7 @@
namespace Org\Heigl\HyphenatorTest;
-use \Org\Heigl\Hyphenator\Options\Options;
+use \Org\Heigl\Hyphenator\Options;
/**
@@ -189,9 +189,9 @@ public function testCreatingOptionViaFactory()
$this->assertTrue(true);
}
$o = Options::factory(__DIR__ . '/../share/onlydist.ini');
- $this->assertInstanceof('\Org\Heigl\Hyphenator\Options\Options', $o );
+ $this->assertInstanceof('\Org\Heigl\Hyphenator\Options', $o );
$o = Options::factory(__DIR__ . '/../share/parseable.ini');
- $this->assertInstanceof('\Org\Heigl\Hyphenator\Options\Options', $o );
+ $this->assertInstanceof('\Org\Heigl\Hyphenator\Options', $o );
$this->assertAttributeEquals('test', '_hyphen', $o);
$this->assertAttributeEquals('test', '_noHyphenateString', $o);
$this->assertAttributeEquals(5, '_leftMin', $o);
View
4 tests/Org/Heigl/HyphenatorTest.php
@@ -58,7 +58,7 @@ public function testCreatingHyphenatorReturnsInstance()
public function testSettingOptions()
{
$hyphenator = new h\Hyphenator();
- $options = new h\Options\Options();
+ $options = new h\Options();
$this->assertAttributeEquals(null,'_options', $hyphenator);
$hyphenator->setOptions($options);
$this->assertAttributeSame($options, '_options', $hyphenator);
@@ -75,7 +75,7 @@ public function testGettingOption()
{
$h = new h\Hyphenator();
$o = $h->getOptions();
- $this->assertInstanceOf('\ORg\Heigl\Hyphenator\Options\Options', $o);
+ $this->assertInstanceOf('\ORg\Heigl\Hyphenator\Options', $o);
$this->assertSame($o,$h->getOptions());
}

0 comments on commit 52de2c3

Please sign in to comment.
Something went wrong with that request. Please try again.