From add6e6f7ede89b921a5e59bcb77750ce76c7eab0 Mon Sep 17 00:00:00 2001 From: Yorick Terweijden Date: Mon, 21 Jul 2014 17:12:31 +0200 Subject: [PATCH] Extends the ArticleType adding a showInEditor option --- newscoop/classes/ArticleTypeField.php | 23 ++++++++++++++ .../sql/upgrade/4.3.x/2014.07.21/tables.sql | 1 + .../Newscoop/Entity/ArticleTypeField.php | 31 ++++++++++++++++++- .../serializer/newscoop/ArticleTypeField.yml | 9 +++++- 4 files changed, 62 insertions(+), 2 deletions(-) create mode 100644 newscoop/install/Resources/sql/upgrade/4.3.x/2014.07.21/tables.sql diff --git a/newscoop/classes/ArticleTypeField.php b/newscoop/classes/ArticleTypeField.php index edb52e36ea..89937a8486 100644 --- a/newscoop/classes/ArticleTypeField.php +++ b/newscoop/classes/ArticleTypeField.php @@ -44,6 +44,7 @@ class ArticleTypeField extends DatabaseObject { 'field_type', 'field_type_param', 'is_content_field', + 'show_in_editor', 'max_size'); private $m_rootTopicId = null; private $m_precision = null; @@ -285,6 +286,7 @@ public function create($p_type, array $p_params = array()) if ($p_type == self::TYPE_TEXT && isset($p_params['maxsize'])) { $data['max_size'] = (int)$p_params['maxsize']; } + $data['show_in_editor'] = (int)$p_params['show_in_editor']; $data['field_type'] = $p_type; $data['field_weight'] = $this->getNextOrder(); } @@ -755,6 +757,27 @@ public function setIsContent($p_isContent) } + /** + * Returns int for where to show the field + * @return int + */ + public function showInEditor() { + return $this->m_data['show_in_editor']; + } + + + + /** + * Sets the int for where to show the field + * @param $p_showInEditor + * @return int + */ + public function setShowInEditor($p_showInEditor) + { + return $this->setProperty('show_in_editor', (int)$p_showInEditor); + } + + /** * Quick lookup to see if the current language is already translated for this article type: used by delete and update in setName * returns 0 if no translation or the phrase_id if there is one. diff --git a/newscoop/install/Resources/sql/upgrade/4.3.x/2014.07.21/tables.sql b/newscoop/install/Resources/sql/upgrade/4.3.x/2014.07.21/tables.sql new file mode 100644 index 0000000000..f7975b06c2 --- /dev/null +++ b/newscoop/install/Resources/sql/upgrade/4.3.x/2014.07.21/tables.sql @@ -0,0 +1 @@ +ALTER TABLE `ArticleTypeMetadata` ADD COLUMN `show_in_editor` int(1) NOT NULL DEFAULT '1'; diff --git a/newscoop/library/Newscoop/Entity/ArticleTypeField.php b/newscoop/library/Newscoop/Entity/ArticleTypeField.php index 4970b85cd5..4759d4e660 100644 --- a/newscoop/library/Newscoop/Entity/ArticleTypeField.php +++ b/newscoop/library/Newscoop/Entity/ArticleTypeField.php @@ -86,6 +86,12 @@ class ArticleTypeField */ protected $isContentField; + /** + * @ORM\Column(type="integer", name="show_in_editor", nullable=False) + * @var int + */ + protected $showInEditor; + /** * Get the article type * @return \Newscoop\Entity\ArticleType @@ -307,5 +313,28 @@ public function setIsContentField($isContentField) return $this; } -} + /** + * Getter for showInEditor + * + * @return int + */ + public function getShowInEditor() + { + return $this->showInEditor; + } + + /** + * Setter for showInEditor + * + * @param int $showInEditor Value to set + * + * @return self + */ + public function setShowInEditor($showInEditor) + { + $this->showInEditor = $showInEditor; + + return $this; + } +} diff --git a/newscoop/src/Newscoop/GimmeBundle/Resources/config/serializer/newscoop/ArticleTypeField.yml b/newscoop/src/Newscoop/GimmeBundle/Resources/config/serializer/newscoop/ArticleTypeField.yml index 8787b465b0..695ad64b10 100644 --- a/newscoop/src/Newscoop/GimmeBundle/Resources/config/serializer/newscoop/ArticleTypeField.yml +++ b/newscoop/src/Newscoop/GimmeBundle/Resources/config/serializer/newscoop/ArticleTypeField.yml @@ -56,4 +56,11 @@ Newscoop\Entity\ArticleTypeField: type: integer groups: ["details"] serialized_name: isContentField - since_version: 1.1 \ No newline at end of file + since_version: 1.1 + showInEditor: + expose: true + read_only: true + type: integer + groups: ["details"] + serialized_name: showInEditor + since_version: 1.1