Вопросы есть. Итак, я создал таблицу в БД, которая повторяет структуру docx файла (в ней то и будут храниться шаблоны).
Код:
CREATE TABLE old_ecollege.docx_templates (
id int UNSIGNED NOT NULL AUTO_INCREMENT,
name varchar(50) NOT NULL,
_rels_rels_xml text NOT NULL,
docProps_app_xml text NOT NULL,
docProps_core_xml text NOT NULL,
word_rels_document_xml_rels text NOT NULL,
word_theme_theme1_xml text NOT NULL,
word_document_xml text NOT NULL,
word_fontTable_xml text NOT NULL,
word_settings_xml text NOT NULL,
word_styles_xml text NOT NULL,
word_stylesWithEffects_xml text NOT NULL,
word_webSettings_xml text NOT NULL,
PRIMARY KEY (id)
)
ENGINE = INNODB
COMMENT = 'таблица docx шаблонов системы';
В папке kohana.my/modules создал след. структуру каталогов:
kohanadocxkohanadocx/classeskohanadocx/classes/controllerkohanadocx/classes/modelkohanadocx/configkohanadocx/vendorkohanadocx/viewesСоздал необходимые файлы:
kohanadocx/init.phpКод:
<?php defined('SYSPATH') or die('No direct script access.');
//Роут для работы с docx шаблонами
Route::set ('docx', 'docx')
->defaults(array(
'controller' => 'docx',
'action' => 'index',
)
);
kohanadocx/classes/controller/docx.phpКод:
<?php defined('SYSPATH') or die('No direct script access.');
class Controller_Docx extends Controller{
public function action_index()
{
$template = new Model_Template();
return $template->get_template();
}
}
kohanadocx/classes/model/Template.phpКод:
<?php defined('SYSPATH') or die('No direct script access.');
class Model_Template extends ORM
{
protected $_table_name = 'docx_templates';
protected $_primary_key = 'id';
public $templates_array;
public function get_template($template_id = NULL){
if(is_null($template_id)):
$templates = DB::select('*')
->from('docx_templates')
->execute()
->as_array();
return $templates;
endif;
}
}
В bootstrap'e написал:
Код:
Kohana::modules(array(
'auth' => MODPATH.'auth', // Basic authentication
// 'cache' => MODPATH.'cache', // Caching with multiple backends
// 'codebench' => MODPATH.'codebench', // Benchmarking tool
'database' => MODPATH.'database', // Database access
// 'image' => MODPATH.'image', // Image manipulation
// 'minion' => MODPATH.'minion', // CLI Tasks
'orm' => MODPATH.'orm', // Object Relationship Mapping
// 'unittest' => MODPATH.'unittest', // Unit testing
'userguide' => MODPATH.'userguide', // User guide and API documentation
// 'uuid' => MODPATH.'uuid', // UUID Generator plugin
'kohanadocx' => MODPATH.'kohanadocx',
));
Но при заходе по адресу
http://kohana.my/docx я лицезрею такую ошибку:
Цитата:
Kohana_HTTP_Exception [ 404 ]: The requested URL docx was not found on this server.
UPD1Поправиль файл init.php модуля (по аналогии с codebench):
Код:
<?php defined('SYSPATH') or die('No direct script access.');
//Роут для работы с docx шаблонами
Route::set ('docx', 'docx(/class)')
->defaults(array(
'controller' => 'docx',
'action' => 'index',
'class' => NULL));