1 : <?php
2 : /**
3 : * Roman de Renart
4 : *
5 : * PHP version 5
6 : *
7 : * @category Rdr
8 : * @package Edit
9 : * @author Michel Corne <mcorne@yahoo.com>
10 : * @copyright 2010 Michel Corne
11 : * @license http://www.opensource.org/licenses/bsd-license.php The BSD License
12 : * @link http://roman-de-renart.blogspot.com/
13 : * @version SVN: $Id$
14 : */
15 :
16 : require_once 'Episode.php';
17 :
18 : /**
19 : * Loading an episode from a blog message
20 : *
21 : * @category Rdr
22 : * @package Edit
23 : * @author Michel Corne <mcorne@yahoo.com>
24 : * @copyright 2010 Michel Corne
25 : * @license http://www.opensource.org/licenses/bsd-license.php The BSD License
26 : */
27 :
28 : class Load extends Episode
29 : {
30 :
31 : /**
32 : * The error message reported when the episode cannot be extracted
33 : */
34 : const ERR_EXTRACT_EPISODE = 'cannot extract episode';
35 :
36 : /**
37 : * The message reported when the episode is loaded
38 : */
39 : const MSG_FILE_LOADED = 'Episode: %s loaded into: %s';
40 :
41 : /**
42 : * Loads the episode from the blog into the HTML input file
43 : *
44 : * @return string a message reporting that the table of contents is loaded
45 : */
46 : public function loadEpisode()
47 : {
48 : // the path and domain of the blog message may be passed for testing purposes
49 1 : ($path = @func_get_arg(0)) === false and $path = $this->episode['path'];
50 1 : ($domain = @func_get_arg(1)) === false and $domain = null;
51 1 : $blogContent = $this->readBlog($path, $domain);
52 :
53 : // extracts the episode HTML
54 1 : $pattern = $this->completePattern(Episode::CONTAINER_TPL);
55 1 : $episodeContent = $this->extract($pattern, $blogContent, self::ERR_EXTRACT_EPISODE);
56 :
57 : // writes the episode into the input file
58 1 : $this->writeFile($this->inputFile, $episodeContent);
59 :
60 1 : return sprintf(self::MSG_FILE_LOADED, $this->episode['id'], basename($this->inputFile));
61 : }
|