/** * Create a new Article Type. Creates a new table in the database. * @return boolean */ public function create() { global $g_ado_db; if (strlen($this->m_dbTableName) <= 1) { return false; } $queryStr = "CREATE TABLE `".$this->m_dbTableName."` (\n" . " NrArticle INT UNSIGNED NOT NULL,\n" . " IdLanguage INT UNSIGNED NOT NULL,\n" . " PRIMARY KEY(NrArticle, IdLanguage)\n" . ") DEFAULT CHARSET=utf8"; $success = $g_ado_db->Execute($queryStr); if ($success) { $metadata = new ArticleTypeField($this->getTypeName(), 'NULL'); $success = $metadata->create(null); } else { return false; } if ($success) { if (function_exists("camp_load_translation_strings")) { camp_load_translation_strings("api"); } $logtext = getGS('The article type "$1" has been added.', $this->m_name); Log::Message($logtext, null, 61); CampCache::singleton()->clear('user'); } else { $queryStr = "DROP TABLE `" . $this->m_dbTableName . "`"; $result = $g_ado_db->Execute($queryStr); } return $success; } // fn create
/** * Create a new Article Type. Creates a new table in the database. * @return boolean */ public function create() { global $g_ado_db; if (strlen($this->m_dbTableName) <= 1) { return false; } $queryStr = 'DROP TABLE IF EXISTS `' . $this->m_dbTableName . '`'; $g_ado_db->Execute($queryStr); $queryStr = "CREATE TABLE `" . $this->m_dbTableName . "` (\n" . " NrArticle INT NOT NULL,\n" . " IdLanguage INT NOT NULL,\n" . " PRIMARY KEY(NrArticle, IdLanguage)\n" . ") DEFAULT CHARSET=utf8"; $success = $g_ado_db->Execute($queryStr); if ($success) { $metadata = new ArticleTypeField($this->getTypeName(), 'NULL'); $success = $metadata->create(null); } else { return false; } if ($success) { CampCache::singleton()->clear('user'); } else { $queryStr = "DROP TABLE `" . $this->m_dbTableName . "`"; $result = $g_ado_db->Execute($queryStr); } return $success; }
if ($editorSize == 'medium') { $editorSize = ArticleTypeField::BODY_ROWS_MEDIUM; } else { if ($editorSize == 'large') { $editorSize = ArticleTypeField::BODY_ROWS_LARGE; } else { if ($editorSize == 'custom') { $editorSize = $editorSizeCustom; } else { $editorSize = ArticleTypeField::BODY_ROWS_MEDIUM; } } } } $params = array('root_topic_id' => $rootTopicId, 'is_content' => strtolower($isContent) == 'on', 'precision' => $precision, 'maxsize' => $maxsize, 'editor_size' => $editorSize, 'event_color' => $eventColor, 'show_in_editor' => $showInEditor); $field->create($fieldType, $params); $cacheService = \Zend_Registry::get('container')->getService('newscoop.cache'); $cacheService->clearNamespace('article_type'); camp_html_goto_page("/{$ADMIN}/article_types/fields/?f_article_type=" . urlencode($articleTypeName)); } $crumbs = array(); $crumbs[] = array($translator->trans('Configure'), ""); $crumbs[] = array($translator->trans('Article Types'), "/{$ADMIN}/article_types/"); $crumbs[] = array($articleTypeName, ''); $crumbs[] = array($translator->trans("Article type fields", array(), 'article_type_fields'), "/{$ADMIN}/article_types/fields/?f_article_type=" . urlencode($articleTypeName)); $crumbs[] = array($translator->trans("Adding new field", array(), 'article_type_fields'), ""); echo camp_html_breadcrumbs($crumbs); ?> <P> <TABLE BORDER="0" CELLSPACING="0" CELLPADDING="8" class="message_box">
/** * Create article type if does not exist * * @param string $typeName * @return ArticleType */ private function getArticleType($typeName) { $requiredFields = array('guid' => 'text', 'version' => 'text', 'urgency' => 'text', 'copyright' => 'text', 'provider' => 'text', 'description' => 'body', 'dateline' => 'text', 'byline' => 'text', 'creditline' => 'text', 'inlinecontent' => 'body'); $type = new \ArticleType($typeName); if (!$type->exists()) { $type->create(); } $missingFields = array_diff(array_keys($requiredFields), $this->getFieldNames($type)); foreach ($missingFields as $fieldName) { $field = new \ArticleTypeField($type->getTypeName(), $fieldName); $field->create($requiredFields[$fieldName]); } return $type; }