From: Michael M Slusarz Date: Wed, 22 Sep 2010 06:00:42 +0000 (-0600) Subject: Collect duplicative code into base Builtin classes. X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=c32f06fea763374b5ce749d3f97cbd1d49427253;p=horde.git Collect duplicative code into base Builtin classes. --- diff --git a/imp/config/prefs.php.dist b/imp/config/prefs.php.dist index 113e7f869..476031223 100644 --- a/imp/config/prefs.php.dist +++ b/imp/config/prefs.php.dist @@ -394,7 +394,7 @@ $_prefs['vfolder'] = array( // 'disable' => true // )) // )) - 'value' => 'a:1:{i:0;C:25:"IMP_Search_Vfolder_Vinbox":175:{a:3:{s:1:"c";a:2:{i:0;C:23:"IMP_Search_Element_Flag":24:{[1,{"f":"\\seen","s":0}]}i:1;C:23:"IMP_Search_Element_Flag":27:{[1,{"f":"\\deleted","s":0}]}}s:1:"e";i:1;s:1:"v";i:1;}}}' + 'value' => 'a:1:{i:0;C:25:"IMP_Search_Vfolder_Vinbox":30:{a:2:{s:1:"e";i:1;s:1:"v";i:1;}}}' ); $_prefs['filter'] = array( @@ -408,7 +408,7 @@ $_prefs['filter'] = array( // 'disable' => false // )) // )) - 'value' => 'a:2:{i:0;C:22:"IMP_Search_Filter_Bulk":88:{a:3:{s:1:"c";a:1:{i:0;C:23:"IMP_Search_Element_Bulk":5:{[1,0]}}s:1:"e";i:1;s:1:"v";i:1;}}i:1;C:29:"IMP_Search_Filter_Mailinglist":95:{a:3:{s:1:"c";a:1:{i:0;C:30:"IMP_Search_Element_Mailinglist":5:{[1,0]}}s:1:"e";i:1;s:1:"v";i:1;}}}' + 'value' => 'a:2:{i:0;C:22:"IMP_Search_Filter_Bulk":30:{a:2:{s:1:"e";i:1;s:1:"v";i:1;}}i:1;C:29:"IMP_Search_Filter_Mailinglist":30:{a:2:{s:1:"e";i:1;s:1:"v";i:1;}}}' ); diff --git a/imp/lib/Search/Filter/Builtin.php b/imp/lib/Search/Filter/Builtin.php new file mode 100644 index 000000000..ee970905e --- /dev/null +++ b/imp/lib/Search/Filter/Builtin.php @@ -0,0 +1,63 @@ + + * @category Horde + * @license http://www.fsf.org/copyleft/gpl.html GPL + * @package IMP + */ +abstract class IMP_Search_Filter_Builtin extends IMP_Search_Filter +{ + /** + * Can this query be edited? + * + * @var boolean + */ + protected $_canEdit = false; + + /** + * List of serialize entries not to save. + * + * @var array + */ + protected $_nosave = array('c', 'i', 'l'); + + /** + * Constructor. + * + * The 'add', 'id', 'label', and 'mboxes' parameters are ignored. + * + * @see parent::__construct() + */ + public function __construct(array $opts = array()) + { + $this->enabled = empty($opts['disable']); + + $this->_init(); + } + + /** + * Initialization tasks. + */ + abstract protected function _init(); + + /** + * Unserialization. + * + * @param string $data Serialized data. + * + * @throws Exception + */ + public function unserialize($data) + { + parent::unserialize($data); + $this->_init(); + } + +} diff --git a/imp/lib/Search/Filter/Bulk.php b/imp/lib/Search/Filter/Bulk.php index 4fde711f5..098b89038 100644 --- a/imp/lib/Search/Filter/Bulk.php +++ b/imp/lib/Search/Filter/Bulk.php @@ -12,58 +12,17 @@ * @license http://www.fsf.org/copyleft/gpl.html GPL * @package IMP */ -class IMP_Search_Filter_Bulk extends IMP_Search_Filter +class IMP_Search_Filter_Bulk extends IMP_Search_Filter_Builtin { /** - * Can this query be edited? - * - * @var boolean - */ - protected $_canEdit = false; - - /** - * List of serialize entries not to save. - * - * @var array - */ - protected $_nosave = array('i', 'l'); - - /** - * Constructor. - * - * The 'add', 'id', 'label', and 'mboxes' parameters are ignored. - * - * @see parent::__construct() - */ - public function __construct(array $opts = array()) - { - $this->enabled = empty($opts['disable']); - - $this->add(new IMP_Search_Element_Bulk()); - - $this->_init(); - } - - /** * Initialization tasks. */ protected function _init() { $this->_id = 'filter_bulk'; $this->_label = _("Bulk Messages"); - } - /** - * Unserialization. - * - * @param string $data Serialized data. - * - * @throws Exception - */ - public function unserialize($data) - { - parent::unserialize($data); - $this->_init(); + $this->add(new IMP_Search_Element_Bulk()); } } diff --git a/imp/lib/Search/Filter/Mailinglist.php b/imp/lib/Search/Filter/Mailinglist.php index 9ebde46d9..3fc936ab7 100644 --- a/imp/lib/Search/Filter/Mailinglist.php +++ b/imp/lib/Search/Filter/Mailinglist.php @@ -12,58 +12,17 @@ * @license http://www.fsf.org/copyleft/gpl.html GPL * @package IMP */ -class IMP_Search_Filter_Mailinglist extends IMP_Search_Filter +class IMP_Search_Filter_Mailinglist extends IMP_Search_Filter_Builtin { /** - * Can this query be edited? - * - * @var boolean - */ - protected $_canEdit = false; - - /** - * List of serialize entries not to save. - * - * @var array - */ - protected $_nosave = array('i', 'l'); - - /** - * Constructor. - * - * The 'add', 'id', 'label', and 'mboxes' parameters are ignored. - * - * @see parent::__construct() - */ - public function __construct(array $opts = array()) - { - $this->enabled = empty($opts['disable']); - - $this->add(new IMP_Search_Element_Mailinglist()); - - $this->_init(); - } - - /** * Initialization tasks. */ protected function _init() { $this->_id = 'filter_mlist'; $this->_label = _("Mailing List Messages"); - } - /** - * Unserialization. - * - * @param string $data Serialized data. - * - * @throws Exception - */ - public function unserialize($data) - { - parent::unserialize($data); - $this->_init(); + $this->add(new IMP_Search_Element_Mailinglist()); } } diff --git a/imp/lib/Search/Vfolder/Builtin.php b/imp/lib/Search/Vfolder/Builtin.php new file mode 100644 index 000000000..a9b88adf6 --- /dev/null +++ b/imp/lib/Search/Vfolder/Builtin.php @@ -0,0 +1,63 @@ + + * @category Horde + * @license http://www.fsf.org/copyleft/gpl.html GPL + * @package IMP + */ +abstract class IMP_Search_Vfolder_Builtin extends IMP_Search_Vfolder +{ + /** + * Can this query be edited? + * + * @var boolean + */ + protected $_canEdit = false; + + /** + * List of serialize entries not to save. + * + * @var array + */ + protected $_nosave = array('c', 'i', 'l', 'm'); + + /** + * Constructor. + * + * The 'add', 'id', 'label', and 'mboxes' parameters are not honored. + * + * @see parent::__construct() + */ + public function __construct(array $opts = array()) + { + $this->enabled = empty($opts['disable']); + + $this->_init(); + } + + /** + * Initialization tasks. + */ + abstract protected function _init(); + + /** + * Unserialization. + * + * @param string $data Serialized data. + * + * @throws Exception + */ + public function unserialize($data) + { + parent::unserialize($data); + $this->_init(); + } + +} diff --git a/imp/lib/Search/Vfolder/Vinbox.php b/imp/lib/Search/Vfolder/Vinbox.php index c42c6f0fb..31e73ab80 100644 --- a/imp/lib/Search/Vfolder/Vinbox.php +++ b/imp/lib/Search/Vfolder/Vinbox.php @@ -12,32 +12,15 @@ * @license http://www.fsf.org/copyleft/gpl.html GPL * @package IMP */ -class IMP_Search_Vfolder_Vinbox extends IMP_Search_Vfolder +class IMP_Search_Vfolder_Vinbox extends IMP_Search_Vfolder_Builtin { /** - * Can this query be edited? - * - * @var boolean - */ - protected $_canEdit = false; - - /** - * List of serialize entries not to save. - * - * @var array - */ - protected $_nosave = array('i', 'l', 'm'); - - /** - * Constructor. - * - * The 'add', 'id', 'label', and 'mboxes' parameters are not honored. - * - * @see parent::__construct() + * Initialization tasks. */ - public function __construct(array $opts = array()) + protected function _init() { - $this->enabled = empty($opts['disable']); + $this->_id = 'vinbox'; + $this->_label = _("Virtual Inbox"); $this->add(new IMP_Search_Element_Flag( '\\seen', @@ -47,17 +30,6 @@ class IMP_Search_Vfolder_Vinbox extends IMP_Search_Vfolder '\\deleted', false )); - - $this->_init(); - } - - /** - * Initialization tasks. - */ - protected function _init() - { - $this->_id = 'vinbox'; - $this->_label = _("Virtual Inbox"); } /** @@ -76,17 +48,4 @@ class IMP_Search_Vfolder_Vinbox extends IMP_Search_Vfolder return parent::__get($name); } - /** - * Unserialization. - * - * @param string $data Serialized data. - * - * @throws Exception - */ - public function unserialize($data) - { - parent::unserialize($data); - $this->_init(); - } - } diff --git a/imp/lib/Search/Vfolder/Vtrash.php b/imp/lib/Search/Vfolder/Vtrash.php index e9a343bc7..1f4cca949 100644 --- a/imp/lib/Search/Vfolder/Vtrash.php +++ b/imp/lib/Search/Vfolder/Vtrash.php @@ -12,16 +12,9 @@ * @license http://www.fsf.org/copyleft/gpl.html GPL * @package IMP */ -class IMP_Search_Vfolder_Vtrash extends IMP_Search_Vfolder +class IMP_Search_Vfolder_Vtrash extends IMP_Search_Vfolder_Builtin { /** - * Can this query be edited? - * - * @var boolean - */ - public $canEdit = false; - - /** * Display this virtual folder in the preferences screen? * * @var boolean @@ -29,38 +22,17 @@ class IMP_Search_Vfolder_Vtrash extends IMP_Search_Vfolder public $prefDisplay = false; /** - * List of serialize entries not to save. - * - * @var array - */ - protected $_nosave = array('i', 'l', 'm'); - - /** - * Constructor. - * - * The 'add', 'id', 'label', and 'mboxes' parameters are not honored. - * - * @see parent::__construct() + * Initialization tasks. */ - public function __construct(array $opts = array()) + protected function _init() { - $this->enabled = empty($opts['disable']); + $this->_id = 'vtrash'; + $this->_label = _("Virtual Trash"); $this->add(new IMP_Search_Element_Flag( '\\deleted', true )); - - $this->_init(); - } - - /** - * Initialization tasks. - */ - protected function _init() - { - $this->_id = 'vtrash'; - $this->_label = _("Virtual Trash"); } /** @@ -79,17 +51,4 @@ class IMP_Search_Vfolder_Vtrash extends IMP_Search_Vfolder return parent::__get($name); } - /** - * Unserialization. - * - * @param string $data Serialized data. - * - * @throws Exception - */ - public function unserialize($data) - { - parent::unserialize($data); - $this->_init(); - } - }