Update Blog Article settings.

@param Article $article

@throws ViewReferenceNotFoundException

@return View
501741
public function updateSettings(Article $article)
    {
        //Update Tags
        /** @var Tag[] $tags */
        $tags = $article->getTags();
        if (is_array($tags)) {
            foreach ($tags as $tag) {
                $tag->setBlog($article->getBlog());
                $this->entityManager->persist($tag);
            }
        }

        //Update BusinessPage
        $businessPage = $this->pageHelper->findPageByParameters([
            'viewId'   => $article->getTemplate()->getId(),
            'entityId' => $article->getId(),
        ]);
        $template = $article->getTemplate();
        $businessPage->setTemplate($template);

        //Update Page
        $page = $this->pageHelper->findPageByParameters([
            'viewId'   => $template->getId(),
            'entityId' => $article->getId(),
        ]);
        $page->setName($article->getName());
        $page->setSlug($article->getSlug());
        $page->setStatus($article->getStatus());

        $this->entityManager->flush();

        //Set ViewReference for Page redirection
        $viewReference = $this->viewReferenceRepo->getOneReferenceByParameters(
            ['viewId' => $page->getId()]
        );
        $page->setReference($viewReference);

        return $page;
    }
1197279
public function run(Article $article): self {
        $this->document($article->getDoc());

        $this->removeXPath('//comment()');
        $this->replace('em, strong, b, i, strike, del, ins', function($node) {
            return !$node->find('img')->count();
        });
        $this->replace('span[class~=dropcap], span[class~=drop_cap]');
        $this->remove('script, style');
        $this->remove('header, footer, input, form, button, aside');
        $this->removeBadTags();
        $this->remove("[id='caption'],[class='caption']");
        $this->remove("[id*=' google '],[class*=' google ']");
        $this->remove("[id*='more']:not([id^=entry-]),[class*='more']:not([class^=entry-])");
        $this->remove("[id*='facebook']:not([id*='-facebook']),[class*='facebook']:not([class*='-facebook'])");
        $this->remove("[id*='facebook-broadcasting'],[class*='facebook-broadcasting']");
        $this->remove("[id*='twitter']:not([id*='-twitter']),[class*='twitter']:not([class*='-twitter'])");
        $this->replace('span', function($node) {
            if (is_null($node->parent())) {
                return false;
            }

            return $node->parent()->is('p');
        });
        $this->convertToParagraph('div, span, article');

        return $this;
    }
1022498
public function addArticle(Article $article)
    {
        $article->setBlog($this);
        $this->articles->add($article);

        return $this;
    }
61057
public function addArticle($article)
    {
        if (!$this->articles->contains($article)) {
            $this->articles->add($article);
        }
    }
633434
public function getArticleById(Article &$article)
		{
			$form_data = array(
				'article_id' => $article->getId()
			);
			$xml = $this->call('getarticlewithid', $form_data);

			$article
				->setName((string)$xml->name)
				->setTitle((string)$xml->title)
				->setDescription((string)$xml->article_description)
				->setDeck((string)$xml->deck)
				->setCallout((string)$xml->callout)
				->setBody((string)$xml->article_body)
				->setAuthorName((string)$xml->author_name)
				->setAuthorBio((string)$xml->author_bio)
				->setAuthorEmail((string)$xml->author_email)
				->setFolderId((int)$xml->folder_id);

			//return $article;
		}
873757
public function featured(Article $article)
    {
        $article->toggleFeaturedState();

        return $this->notifySuccess(trans(
                'cms::article.update.featured', [
                'task' => $article->published ? 'featured' : 'unfeatured',
            ])
        );
    }
1253963
public function update(Article $article, ArticlesFormRequest $request)
    {
        $article->fill($request->all());
        $article->published     = $request->get('published', false);
        $article->featured      = $request->get('featured', false);
        $article->authenticated = $request->get('authenticated', false);
        $article->is_page       = $request->get('is_page', false);
        $article->save();

        $article->permissions()->sync($request->get('permissions', []));
        if ($request->tags) {
            $article->retag(explode(',', $request->tags));
        }

        event(new ArticleWasUpdated($article));

        flash()->success(trans('cms::article.update.success'));

        return redirect()->route('administrator.articles.index');
    }
151360
protected function _getReviewList($article)
    {
        $database = \OxidEsales\Eshop\Core\DatabaseProvider::getDb();
        $query = "select oxreviews.* from oxreviews
                     where oxreviews.OXOBJECTID = " . $database->quote($article->oxarticles__oxid->value) . "
                     and oxreviews.oxtype = 'oxarticle'";

        $variantList = $article->getVariants();

        if (\OxidEsales\Eshop\Core\Registry::getConfig()->getConfigParam('blShowVariantReviews') && count($variantList)) {
            // verifying rights
            foreach ($variantList as $variant) {
                $query .= "or oxreviews.oxobjectid = " . $database->quote($variant->oxarticles__oxid->value) . " ";
            }
        }

        //$sSelect .= "and oxreviews.oxtext".\OxidEsales\Eshop\Core\Registry::getLang()->getLanguageTag($this->_iEditLang)." != ''";
        $query .= "and oxreviews.oxlang = '" . $this->_iEditLang . "'";
        $query .= "and oxreviews.oxtext != '' ";

        // all reviews
        $reviewList = oxNew(\OxidEsales\Eshop\Core\Model\ListModel::class);
        $reviewList->init("oxreview");
        $reviewList->selectString($query);

        return $reviewList;
    }
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);
    }
1315133
public function updateContent(string $content)
    {
        // Unregister old definitions
        if (isset($this->definitions)) {
            foreach ($this->definitions as $fqn => $definition) {
                $this->index->removeDefinition($fqn);
            }
        }

        // Unregister old references
        if (isset($this->referenceNodes)) {
            foreach ($this->referenceNodes as $fqn => $node) {
                $this->index->removeReferenceUri($fqn, $this->uri);
            }
        }

        $this->referenceNodes = null;
        $this->definitions = null;
        $this->definitionNodes = null;

        $treeAnalyzer = new TreeAnalyzer($this->parser, $content, $this->docBlockFactory, $this->definitionResolver, $this->uri);

        $this->diagnostics = $treeAnalyzer->getDiagnostics();

        $this->definitions = $treeAnalyzer->getDefinitions();

        $this->definitionNodes = $treeAnalyzer->getDefinitionNodes();

        $this->referenceNodes = $treeAnalyzer->getReferenceNodes();

        foreach ($this->definitions as $fqn => $definition) {
            $this->index->setDefinition($fqn, $definition);
        }

        // Register this document on the project for references
        foreach ($this->referenceNodes as $fqn => $nodes) {
            // Cast the key to string. If (string)'2' is set as an array index, it will read out as (int)2. We must
            // deal with incorrect code, so this is a valid scenario.
            $this->index->addReferenceUri((string)$fqn, $this->uri);
        }

        $this->sourceFileNode = $treeAnalyzer->getSourceFileNode();
    }
1351287
public function getArticleByName(Article &$article)
		{
			$form_data = array(
				'article_name' => $article->getName()
			);
			$xml = $this->call('getarticlewithname', $form_data);

			$article
				->setId((int)$xml->article_id)
				->setTitle((string)$xml->title)
				->setDescription((string)$xml->article_description)
				->setDeck((string)$xml->deck)
				->setCallout((string)$xml->callout)
				->setBody((string)$xml->article_body)
				->setAuthorName((string)$xml->author_name)
				->setAuthorBio((string)$xml->author_bio)
				->setAuthorEmail((string)$xml->author_email)
				->setFolderId((int)$xml->folder_id);

			//return $article;
		}
359725
private function addAndUpdateTitles($item)
    {
        if (isset($item['id']) && !empty($item['id'])) {
            /* @var ContactTitle $title */
            $title = $this->getDoctrine()
                ->getRepository(self::$entityName)
                ->find($item['id']);

            if (null == $title) {
                throw new EntityNotFoundException(self::$entityName, $item['id']);
            } else {
                $title->setTitle($item['title']);
            }
        } else {
            $title = new ContactTitle();
            $title->setTitle($item['title']);
            $this->getDoctrine()->getManager()->persist($title);
        }

        return $title;
    }
262513
public function findPageByReference($viewReference)
    {
        $page = null;
        if ($viewReference instanceof BusinessPageReference) {
            if ($viewReference->getViewId()) { //BusinessPage
                $page = $this->entityManager->getRepository('VictoireCoreBundle:View')
                    ->findOneBy([
                        'id' => $viewReference->getViewId(),
                    ]);
                $page->setCurrentLocale($viewReference->getLocale());
            } else { //VirtualBusinessPage
                $page = $this->entityManager->getRepository('VictoireCoreBundle:View')
                    ->findOneBy([
                        'id' => $viewReference->getTemplateId(),
                    ]);
                if ($entity = $this->findEntityByReference($viewReference)) {
                    if ($page instanceof BusinessTemplate) {
                        $page = $this->updatePageWithEntity($page, $entity);
                    }
                    if ($page instanceof BusinessPage) {
                        if ($page->getSeo()) {
                            $page->getSeo()->setCurrentLocale($viewReference->getLocale());
                        }
                        $this->pageSeoHelper->updateSeoByEntity($page, $entity);
                    }
                }
            }
        } elseif ($viewReference instanceof ViewReference) {
            $page = $this->entityManager->getRepository('VictoireCoreBundle:View')
                ->findOneBy([
                    'id' => $viewReference->getViewId(),
                ]);
            $page->setCurrentLocale($viewReference->getLocale());
        } else {
            throw new \Exception(sprintf('Oh no! Cannot find a page for this ViewReference (%s)', ClassUtils::getClass($viewReference)));
        }

        return $page;
    }
729084
public function uploadArticle($articles)
    {
        if (!empty($articles['title']) || $articles instanceof Article) {
            $articles = [$articles];
        }

        $params = ['articles' => array_map(function ($article) {
            if ($article instanceof Article) {
                return $article->only([
                    'title', 'thumb_media_id', 'author', 'digest',
                    'show_cover_pic', 'content', 'content_source_url',
                ]);
            }

            return $article;
        }, $articles)];

        return $this->parseJSON('json', [self::API_NEWS_UPLOAD, $params]);
    }
890010
private function update()
    {
        $db = new Db();

        //Insert into article table
        $row = $db->query('UPDATE article
                            SET   category = :category,
                                  author = :author,
                                  pubdate = :pubdate,
                                  editdate = :editdate,
                                  tags = :tags,
                                  status = :status,
                                  title = :title,
                                  media = :media,
                                  resume = :resume
                            WHERE id = :id',

                        [':id'=>$this->id,
                         ':category' => $this->category,
                         ':author' => $this->author,
                         ':pubdate' => $this->pubdate,
                         ':editdate' => $this->editdate,
                         ':tags' => $this->tags,
                         ':status' => $this->status,
                         ':title' => $this->title,
                         ':media' => $this->media,
                         ':resume' => $this->resume
                        ]);
        //check update
        if (!$row) {
            return false;
        }

        //Insert into content table
        $row = $db->query('UPDATE articlecontent
                            SET   editdate = :editdate,
                                  content = :content
                            WHERE article = :article',
                            
                        [':article' => $this->id,
                         ':editdate' => $this->editdate,
                         ':content' => $this->content]);
        return $row;

        
        $cols = '';
        $vals = [];
        foreach ($this as $k => $v) {
            if ($k == 'table' || $k == 'where') {
                continue;
            }echo '<br><b>'.$k.': </b>'.$v;
            if ($k !== 'id') {
                $cols .= $k.' = :'.$k.',';
            }
            $vals[':'.$k] = $v;
        }
        
        $cols = substr($cols, 0, -1); //tirando a ultima vírgula

        $where = ' WHERE id = :id ';
        if ($this->where != null) {
            $where .= ' and '.$this->where;
        }

        $db = new Db();
        return $db->query('UPDATE '.$this->table.' SET '.$cols.$where, $vals);
    }
32662
protected function article(Article $article = null): ?Article {
        if ($article === null) {
            return $this->article;
        }

        $this->article = $article;

        return $this->article;
    }
1212020
public function edit(Article $article)
    {
        $tags         = Article::existingTags()->pluck('name');
        $selectedTags = implode(',', $article->tagNames());

        return view('administrator.articles.edit', compact('article', 'tags', 'selectedTags'));
    }