3 * Handles the "setup".
\r
5 * This class provides all methods neccessary to "setup" Phpdoc and check the
\r
8 * @version $Id: PhpdocSetupHandler.php,v 1.5 2000/12/03 20:30:42 uw Exp $
\r
9 * @author Ulf Wendel <ulf@redsys.de>
\r
11 class PhpdocSetupHandler extends PhpdocArgvHandler {
\r
14 * Name of the target directory.
\r
16 * @var string $target
\r
22 * Name of the application parsed
\r
24 * @var string $application
\r
25 * @see setApplication()
\r
27 var $application = "PHPDoc";
\r
30 * Basedir for all file operations
\r
32 * @var string $basedir
\r
33 * @see setApplication()
\r
38 * Suffix for all rendered files in the application (except for the xml files).
\r
40 * @var string targetFileSuffix
\r
41 * @see setTargetFileSuffix()
\r
43 var $targetFileSuffix = ".html";
\r
46 * Suffix of all source code files in the application
\r
48 * If you used other file suffixes than ".php" in you have to override this.
\r
50 * variable using setSourceFileSuffix()
\r
51 * @var array sourceFileSuffix
\r
52 * @see setSourceFileSuffix()
\r
54 var $sourceFileSuffix = array ( "php" );
\r
57 * Directory with the php sources to parse.
\r
60 * @see setSourceDirectory()
\r
62 var $sourceDirectory = "";
\r
65 * Sets the name of the directory with the source to scan.
\r
70 function setSourceDirectory($sourcedir) {
\r
71 $this->sourceDirectory = $this->getCheckedDirname($sourcedir);
\r
72 } // end end func setSourceDirectory
\r
75 * Sets the name of the directory with the templates.
\r
80 function setTemplateDirectory($sourcedir) {
\r
81 $this->templateRoot = $this->getCheckedDirname($sourcedir);
\r
82 } // end func setTemplateDirectory
\r
85 * Sets the name of your application.
\r
87 * The application name gets used on many places in the default templates.
\r
89 * @param string $application name of the application
\r
91 * @throws PhpdocError
\r
94 function setApplication($application) {
\r
95 if (""==$application) {
\r
96 $this->err[] = new PhpdocError("No application name given.", __FILE__, __LINE__);
\r
100 $this->application = $application;
\r
102 } // end func setApplication
\r
105 * Suffix for all rendered files in the application (not for the xml files)
\r
107 * By default the the suffix is set to ".html".
\r
109 * @param string $suffix string with the suffix
\r
111 * @see $targetFileSuffix
\r
112 * @author Thomas Weinert <subjective@subjective.de>
\r
114 function setTargetFileSuffix($suffix) {
\r
115 if ("" != $suffix && "." != $suffix[0]) {
\r
116 $this->err[] = new PhpdocError("Make sure that the file extension starts with a dot.", __FILE__, __LINE__);
\r
120 $this->targetFileSuffix = $suffix;
\r
125 * Suffix of all source code files in the application
\r
127 * By default only files with the suffix ".php" are recognized as
\r
128 * php source code files and parsed. If you used other
\r
129 * suffixes such as ".inc" you have to tell phpdoc to parse
\r
132 * @param mixed $suffix string with one suffix or array of suffixes
\r
134 * @throws PhpdocError
\r
135 * @see $sourceFileSuffix
\r
137 function setSourceFileSuffix($suffix) {
\r
138 if ( (!is_array($suffix) && "" == $suffix) || (is_array($suffix) && 0 == count($suffix)) ) {
\r
139 $this->err[] = new PhpdocError("No suffix specified.", __FILE__, __LINE__);
\r
142 if (!is_array($suffix))
\r
143 $suffix = array($suffix);
\r
145 $this->sourceFileSuffix = $suffix;
\r
147 } // end func setSourceFileSuffix
\r
150 * Sets the target where the generated files are saved.
\r
152 * @param string $target
\r
153 * @return bool $ok
\r
154 * @throws PhpdocError
\r
157 function setTarget($target) {
\r
158 if ("" == $target) {
\r
159 $this->err[] = new PhpdocError("No target specified.", __FILE__, __LINE__);
\r
163 if (!is_dir($target)) {
\r
164 $ok = mkdir($target, 0755);
\r
166 $this->err[] = new PhpdocError("setTarget(), can't create a directory '$target'.", __FILE__, __LINE__);
\r
171 $this->target = $this->getCheckedDirname($target);
\r
173 } // end func setTarget
\r
176 * Checks the current status of the object. Are all necessary informations to start parsing available?
\r
177 * @param mixed $errors
\r
178 * @return array $errors
\r
180 function checkStatus($errors = "") {
\r
181 if (!is_array($errors))
\r
185 if (0==count($this->files) && ""==$this->directory)
\r
186 $errors[] = array (
\r
187 "msg" => "No source files or source directory specified.",
\r
188 "type" => "misconfiguration",
\r
192 if (0!=count($this->files) && ""!=$this->directory)
\r
194 "msg" => "Define eighter some files or a diretory.",
\r
195 "type" => "misconfiguration",
\r
200 } // end func checkStatus
\r
203 * Adds a slash at the end of the given filename if neccessary.
\r
205 * @param string Directoryname
\r
206 * @return string Directoryname
\r
208 function getCheckedDirname($dirname) {
\r
210 if ("" != $dirname && "/" != substr($dirname, -1))
\r
214 } // end func getCheckedDirname
\r
216 } // end class PhpdocSetupHandler
\r