Create a new Article

@link   https://help.shopify.com/api/reference/article#create
@param  integer $blogId
@param  Article $article
@return void
769377
public function create($blogId, Article &$article)
    {
        $data = $article->exportData();
        $endpoint = '/admin/blogs/'.$blogId.'/articles.json';
        $response = $this->request(
            $endpoint, 'POST', array(
            'article' => $data
            )
        );
        $article->setData($response['article']);
    }
1010870
public function createNewSite(
        string $createdByUserId,
        string $createdReason = Tracking::UNKNOWN_REASON,
        $siteId = null
    ) {
        if (empty($siteId)) {
            // new site
            /** @var \Rcm\Entity\Site $newSite */
            return new \Rcm\Entity\Site(
                $createdByUserId,
                $createdReason
            );
        }

        return $this->copySiteById(
            $siteId,
            $createdByUserId,
            $createdReason
        );
    }
385087
def create():
    """"""
    if request.method == "POST":
        title = request.form["title"]
        body = request.form["body"]
        error = None

        if not title:
            error = "Title is required."

        if error is not None:
            flash(error)
        else:
            db.session.add(Post(title=title, body=body, author=g.user))
            db.session.commit()
            return redirect(url_for("blog.index"))

    return render_template("blog/create.html")
537077
protected function rssFeed($blogPosts, $link)
    {
        $rss = RSSFeed::create($blogPosts, $link, $this->MetaTitle, $this->MetaDescription);

        $this->extend('updateRss', $rss);

        return $rss->outputToBrowser();
    }
418120
public function update($blogId, $postId, Google_Post $postBody, $optParams = array()) {
      $params = array('blogId' => $blogId, 'postId' => $postId, 'postBody' => $postBody);
      $params = array_merge($params, $optParams);
      $data = $this->__call('update', array($params));
      if ($this->useObjects()) {
        return new Google_Post($data);
      } else {
        return $data;
      }
    }
872129
public function importAuthors($oldArticleId, $article)
    {
        $this->consoleOutput->writeln("Reading authors...");

        $authorSql = "SELECT first_name, last_name, email, seq FROM authors " .
            "WHERE submission_id = :id ORDER BY first_name, last_name, email";
        $authorStatement = $this->dbalConnection->prepare($authorSql);
        $authorStatement->bindValue('id', $oldArticleId);
        $authorStatement->execute();

        $authors = $authorStatement->fetchAll();
        foreach ($authors as $pkpAuthor) {
            $author = new Author();
            $author->setCurrentLocale('en');
            $author->setFirstName(!empty($pkpAuthor['first_name']) ? $pkpAuthor['first_name'] : '-');
            $author->setLastName(!empty($pkpAuthor['last_name']) ? $pkpAuthor['last_name'] : '-');
            $author->setEmail(
                !empty($pkpAuthor['email']) && $pkpAuthor['email'] !== '-' ?
                    $pkpAuthor['email'] :
                    'author@example.com'
            );

            $articleAuthor = new ArticleAuthor();
            $articleAuthor->setAuthor($author);
            $articleAuthor->setArticle($article);
            $articleAuthor->setAuthorOrder(!empty($pkpAuthor['seq']) ? $pkpAuthor['seq'] : 0);
        }
    }
559058
public function create()
    {
        if (!userHasPermission('admin:blog:tag:' . $this->blog->id . ':create')) {

            unauthorised();
        }

        // --------------------------------------------------------------------------

        if ($this->input->post()) {

            $oFormValidation = Factory::service('FormValidation');

            $oFormValidation->set_rules('label', '', 'required');
            $oFormValidation->set_rules('description', '', '');
            $oFormValidation->set_rules('seo_title', '', 'max_length[150]');
            $oFormValidation->set_rules('seo_description', '', 'max_length[300]');
            $oFormValidation->set_rules('seo_keywords', '', 'max_length[150]');

            $oFormValidation->set_message('required', lang('fv_required'));
            $oFormValidation->set_message('max_length', lang('fv_max_length'));

            if ($oFormValidation->run()) {

                $aInsertData                    = array();
                $aInsertData['blog_id']         = $this->blog->id;
                $aInsertData['label']           = $this->input->post('label');
                $aInsertData['description']     = $this->input->post('description');
                $aInsertData['seo_title']       = $this->input->post('seo_title');
                $aInsertData['seo_description'] = $this->input->post('seo_description');
                $aInsertData['seo_keywords']    = $this->input->post('seo_keywords');

                if ($this->blog_tag_model->create($aInsertData)) {

                    $status  = 'success';
                    $message = 'Tag created successfully.';
                    $this->session->set_flashdata($status, $message);
                    redirect('admin/blog/tag/index/' . $this->blog->id . $this->isModal);

                } else {

                    $this->data['error']  = 'There was a problem creating the Tag. ';
                    $this->data['error'] .= $this->blog_tag_model->lastError();
                }

            } else {

                $this->data['error'] = lang('fv_there_were_errors');
            }
        }

        // --------------------------------------------------------------------------

        //  Page data
        $this->data['page']->title = 'Blog &rsaquo; Tags &rsaquo; Create';

        // --------------------------------------------------------------------------

        //  Fetch data
        $this->data['tags'] = $this->blog_tag_model->getAll();

        // --------------------------------------------------------------------------

        //  Load views
        Helper::loadView('edit');
    }
1235394
function saveBook( $blog_id, array $item ) {

		/** @var $wpdb \wpdb */
		global $wpdb;

		unset( $item['users_id'], $item['blogs_id'], $item['deleted'] ); // Don't allow spoofing

		$data = [
			'users_id' => $this->userId,
			'blogs_id' => $blog_id,
			'deleted' => 0,
		];
		$format = [
			'users_id' => $this->dbColumns['users_id'],
			'blogs_id' => $this->dbColumns['blogs_id'],
			'deleted' => $this->dbColumns['deleted'],
		];

		foreach ( $item as $key => $val ) {
			if ( isset( $this->dbColumns[ $key ] ) ) {
				$data[ $key ] = $val;
				$format[ $key ] = $this->dbColumns[ $key ];
			}
		}

		// INSERT ... ON DUPLICATE KEY UPDATE
		// @see http://dev.mysql.com/doc/refman/5.0/en/insert-on-duplicate.html

		$args = [];
		$sql = "INSERT INTO {$this->dbTable} ( ";
		foreach ( $data as $key => $val ) {
			$sql .= "`$key`, ";
		}
		$sql = rtrim( $sql, ', ' ) . ' ) VALUES ( ';

		foreach ( $format as $key => $val ) {
			$sql .= $val . ', ';
			$args[] = $data[ $key ];
		}
		$sql = rtrim( $sql, ', ' ) . ' ) ON DUPLICATE KEY UPDATE ';

		$i = 0;
		foreach ( $data as $key => $val ) {
			if ( 'users_id' === $key || 'blogs_id' === $key ) {
				continue;
			}
			$sql .= "`$key` = {$format[$key]}, ";
			$args[] = $val;
			++$i;
		}
		$sql = rtrim( $sql, ', ' );
		if ( ! $i ) {
			$sql .= ' users_id = users_id '; // Do nothing
		}

		return $wpdb->query( $wpdb->prepare( $sql, $args ) ); // @codingStandardsIgnoreLine
	}
459330
public function create()
	{
		$arrNodes = false;

		if ($this->insideRoot)
		{
			$objContent = \ContentModel::findById($this->data->pid);

			$rootId = Controller::getRootPageId($objContent->ptable, $objContent->pid);

			if (null !== $rootId)
			{
				$objPage = \PageModel::findWithDetails($rootId);

				if ($this->insideLang || empty($objPage->domain))
				{
					$arrNodes = array($rootId);
				}
				else
				{
					$arrNodes = (array) \PageModel::findByDns($objPage->domain)->fetchEach('id');
				}
			}
		}
		
		if ($this->multiArticle)
		{
			$this->generateDCA('multiArticle', array
			(
				'inputType' => 'articleTree',
				'label'		=> array($this->label, $this->description),
				'eval'		=> array
				(
					'multiple'		=>	true,				
					'fieldType'		=>	'checkbox', 
					'orderField'	=>	$this->virtualFieldName('orderArticle'),
					'mandatory'		=> ($this->mandatory) ? true : false, 
					'rootNodes'		=>	$arrNodes,
					'tl_class'		=> 'clr'
				),
				'load_callback'		=> array
				(
					array('tl_content_contentblocks', 'prepareOrderPageValue'),
				),
				'save_callback'		=> array
				(
					array('tl_content_contentblocks', 'saveOrderPageValue'),
				),
			));
		}
		else
		{
			$this->generateDCA('singleArticle', array
			(
				'inputType' => 'articleTree',
				'label'		=> array($this->label, $this->description),
				'eval'		=> array
				(
					'fieldType'		=>	'radio', 
					'mandatory'		=> ($this->mandatory) ? true : false, 
					'rootNodes'		=>	$arrNodes,
					'tl_class'		=> 'clr'
				),
			));
		}
	}
774401
public function createContent() {
    // Create node.
    $node = Node::create([
      'type' => 'page',
      'title' => 'Products',
      'langcode' => LanguageInterface::LANGCODE_NOT_SPECIFIED,
      'uid' => 1,
      'status' => 1,
      'promote' => 0,
      'field_fields' => [],
      'path' => [
        'alias' => '/products',
      ],
    ]);
    $node->save();

    // Create menu link.
    $menuLink = MenuLinkContent::create([
      'title' => 'Products',
      'link' => [
        'uri' => "internal:/node/{$node->id()}",
      ],
      'menu_name' => 'main',
      'weight' => 30,
      'expanded' => TRUE,
    ]);
    $menuLink->save();
  }
922299
public function create(string $tagName, int $tagId = null)
    {
        $params = [
            'tagname' => $tagName,
            'tagid' => $tagId,
        ];

        return $this->httpPostJson('cgi-bin/tag/create', $params);
    }
883653
public function updateArticle($mediaId, $article, $index = 0)
    {
        $params = [
            'media_id' => $mediaId,
            'index' => $index,
            'articles' => isset($article['title']) ? $article : (isset($article[$index]) ? $article[$index] : []),
        ];
        return $this->post(self::API_NEWS_UPDATE, $params);
    }
787933
def create(self, section, article):
        
        return CRUDRequest(self).post(article, create=True, id=section)
1168059
public function load($article)
    {
        $this->setArticle($article);

        $aData = $this->_loadFromDb();

        $this->assignArray($aData);
    }
589071
private function updateArticle(ArticleDocument $article, BasePageDocument $document)
    {
        $locale = $document->getLocale();
        $resourceSegment = $document->getResourceSegment();

        $property = $this->getRoutePathPropertyNameByStructureType($article->getStructureType());
        $propertyName = $this->propertyEncoder->localizedContentName($property->getName(), $locale);

        $node = $this->documentInspector->getNode($article);
        $node->setProperty($propertyName . '-page', $document->getUuid());
        $node->setProperty($propertyName . '-page-path', $resourceSegment);

        $suffix = $node->getPropertyValueWithDefault($propertyName . '-suffix', null);
        if ($suffix) {
            $path = rtrim($resourceSegment, '/') . '/' . $suffix;
            $node->setProperty($propertyName, $path);
            $article->setRoutePath($path);
        }

        $workflowStage = $article->getWorkflowStage();

        $this->documentManager->persist($article, $locale);
        if (WorkflowStage::PUBLISHED === $workflowStage) {
            $this->documentManager->publish($article, $locale);
        }
    }
107494
public function updateArticle(Article $article)
		{
			$form_data = array(
				'article_id' => $article->getId(),
				'article_name' => $article->getName(),
				'article_title' => $article->getTitle(),
				'article_description' => $article->getDescription(),
				'deck' => $article->getDeck(),
				'callout' => $article->getCallout(),
				'author_name' => $article->getAuthorName(),
				'author_bio' => $article->getAuthorBio(),
				'author_email' => $article->getAuthorEmail(),
				'folder_id' => $article->getFolderId(),
				'article_body' => $article->getBody()
			);
			$data = $this->call('updatearticle', $form_data);

			return TRUE;
		}
972356
public void add(Article article) {
		// Get Write Access
		SQLiteDatabase db = this.getWritableDatabase();

		// Build Content Values
		ContentValues values = new ContentValues();
		values.put(KEY_TAGS, TextUtils.join("_PCX_", article.getTags()));
		values.put(KEY_MEDIA_CONTENT, Article.MediaContent.toByteArray(article.getMediaContent()));
		values.put(KEY_SOURCE, article.getSource().toString());
		values.put(KEY_IMAGE, article.getImage().toString());
		values.put(KEY_TITLE, article.getTitle());
		values.put(KEY_DESCRIPTION, article.getDescription());
		values.put(KEY_CONTENT, article.getContent());
		values.put(KEY_COMMENTS, article.getComments());
		values.put(KEY_AUTHOR, article.getAuthor());
		values.put(KEY_DATE, article.getDate());
		values.put(KEY_ID, article.getId());

		// Insert & Close
		db.insert(TABLE_ARTICLES, null, values);
		db.close();
	}