sergiovilar/kindle-periodical

一个PHP类,帮助构建Kindle期刊

dev-master 2014-07-27 05:10 UTC

This package is not auto-updated.

Last update: 2024-09-24 05:26:10 UTC


README

一个PHP类,帮助构建Kindle期刊

重要:您需要将KindleGen添加为命令以运行KindlePeriodical

用法

(示例可以在example.php中找到)

首先,您需要创建一个包含期刊内容的数组

$content = array(

	// Array of sections
	array(
		'id' => '0',
		'name' => 'My first section',
		'content' => array(

			// Array of articles
			array(
				'title' => 'Title of my first article',
				'content' => 'content of my article' // HTML is allowed
			)
		)
	),

	array(
		'id' => '1',
		'name' => 'My toher section',
		'content' => array(

			// Array of articles
			array(
				'title' => 'Title of my other article',
				'content' => 'content of my article'
			)
		)
	)


);

有了这个,现在您可以使用KindlePeriodical生成您的.mobi文件

 $ebook = new \Kindle\Periodical(array(

    "outputFolder" => "out",

    // Optional arguments:
    "shell" => false, // KindlePeriodical will use exec instead of shell_exec
    "debug" => true

));

$ebook->setMeta(array(
    'title' => 'My Kindle Periodical',
    'creator' => "sergiovilar",
    'publisher' => "sergiovilar",
    'subject' => 'Sample Periodical',
    'description' => 'Set of articles in one .mobi file'
));

// Generates the file
$content = $ebook->setContent($content);

// Return the file name
$file = $ebook->getFilename();

// Download the file
$ebook->downloadFile();

// Remove the file and directory
$ebook->deleteFile();