From 330156e7b6ea45c7e1e7c7dd652e0b250dbfbe02 Mon Sep 17 00:00:00 2001 From: zYne Date: Tue, 24 Jul 2007 20:38:42 +0000 Subject: [PATCH] --- lib/Doctrine/File.php | 53 +++++++++++++++++++++++++++++++++++ lib/Doctrine/File/Index.php | 56 +++++++++++++++++++++++++++++++++++++ 2 files changed, 109 insertions(+) create mode 100644 lib/Doctrine/File.php create mode 100644 lib/Doctrine/File/Index.php diff --git a/lib/Doctrine/File.php b/lib/Doctrine/File.php new file mode 100644 index 000000000..03216dce1 --- /dev/null +++ b/lib/Doctrine/File.php @@ -0,0 +1,53 @@ +. + */ + +/** + * Doctrine_File + * + * @author Konsta Vesterinen + * @package Doctrine + * @license http://www.opensource.org/licenses/lgpl-license.php LGPL + * @version $Revision$ + * @category Object Relational Mapping + * @link www.phpdoctrine.com + * @since 1.0 + */ +class Doctrine_File extends Doctrine_Record +{ + public function setTableDefinition() + { + $this->hasColumn('url', 'string', 255); + } + public function setUp() + { + $this->actAs('Searchable', array('className' => 'Doctrine_File_Index', + 'fields' => array('url', 'content'))); + + $this->index('url', array('fields' => array('url'))); + } + public function get($name, $load = true) + { + if ($name === 'content') { + return file_get_contents(parent::get('url')); + } + return parent::get($name, $load); + } +} diff --git a/lib/Doctrine/File/Index.php b/lib/Doctrine/File/Index.php new file mode 100644 index 000000000..65df4afb6 --- /dev/null +++ b/lib/Doctrine/File/Index.php @@ -0,0 +1,56 @@ +. + */ + +/** + * Doctrine_File_Index + * + * @author Konsta Vesterinen + * @package Doctrine + * @license http://www.opensource.org/licenses/lgpl-license.php LGPL + * @version $Revision$ + * @category Object Relational Mapping + * @link www.phpdoctrine.com + * @since 1.0 + */ +class Doctrine_File_Index extends Doctrine_Record +{ + public function setTableDefinition() + { + $this->hasColumn('keyword', 'string', 255, array('notnull' => true, + 'primary' => true)); + + $this->hasColumn('field', 'string', 50, array('notnull' => true, + 'primary' => true)); + + $this->hasColumn('position', 'string', 255, array('notnull' => true, + 'primary' => true)); + + $this->hasColumn('file_id', 'integer', 8, array('notnull' => true, + 'primary' => true)); + } + public function setUp() + { + $this->hasOne('Doctrine_File', array('local' => 'file_id', + 'foreign' => 'id', + 'onDelete' => 'CASCADE', + 'onUpdate' => 'CASCADE')); + } +}