Create a new Blog Article.

@Route("/new/{id}", name="victoire_blog_article_new_post")
@Method("POST")
@ParamConverter("blog", class="VictoireBlogBundle:Blog")

@return JsonResponse
767863
public function newPostAction(Request $request, Blog $blog)
    {
        $article = new Article();
        $article->setBlog($blog);
        $form = $this->createForm(ArticleType::class, $article);

        $form->handleRequest($request);
        if ($form->isValid()) {
            $page = $this->get('victoire_blog.manager.article')->create(
                $article,
                $this->getUser()
            );

            $dispatcher = $this->get('event_dispatcher');
            $event = new ArticleEvent($article);
            $dispatcher->dispatch(VictoireBlogEvents::CREATE_ARTICLE, $event);

            if (null === $response = $event->getResponse()) {
                $response = new JsonResponse([
                    'success' => true,
                    'url'     => $this->generateUrl('victoire_core_page_show', [
                        '_locale' => $request->getLocale(),
                        'url'     => $page->getUrl(),
                    ]),
                ]);
            }

            return $response;
        }

        return new JsonResponse([
            'success' => false,
            'message' => $this->container->get('victoire_form.error_helper')->getRecursiveReadableErrors($form),
            'html'    => $this->container->get('templating')->render(
                'VictoireBlogBundle:Article:new.html.twig',
                [
                    'form'   => $form->createView(),
                    'blogId' => $blog->getId(),
                ]
            ),
        ]);
    }
417335
public function actionCreate()
    {
        $model = new Article();
        if ($model->load(Yii::$app->request->post()) && $model->save()) {
            return $this->redirect(['view', 'uuid' => $model->uuid]);
        } else {
            return $this->render('create', [
                'model' => $model,
            ]);
        }
    }
231209
public function create()
    {
        $this->authorize(PostsPolicy::PERMISSION_CREATE);

        $categories = Category::getSelectData();
        $tags       = Tag::getSelectData();
        $statuses   = Post::getStatuses();

        $this->setTitle($title = trans('blog::posts.titles.create-post'));
        $this->addBreadcrumb($title);

        return $this->view('admin.posts.create', compact('categories', 'tags', 'statuses'));
    }
1252425
public function actionCreate()
    {
        Yii::$app->getResponse()->format = 'json';
        $routes = Yii::$app->getRequest()->post('route', '');
        $routes = preg_split('/\s*,\s*/', trim($routes), -1, PREG_SPLIT_NO_EMPTY);
        $this->saveNew($routes);
        Helper::invalidate();
        return $this->getRoutes();
    }
1094867
public function create()
    {
        if (!userHasPermission('admin:blog:post:' . $this->blog->id . ':create')) {

            unauthorised();
        }

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

        //  Set method info
        $this->data['page']->title = 'Create New ' . ucfirst($this->data['postName']);

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

        //  Process POST
        if ($this->input->post()) {

            //  Are we running in preview mode?
            $bIsPreview = (bool) $this->input->post('isPreview');

            //  Only validate non-previews
            if (empty($bIsPreview)) {

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

                $oFormValidation->set_rules('is_published', '', '');
                $oFormValidation->set_rules('published', '', '');
                $oFormValidation->set_rules('title', '', 'required');
                $oFormValidation->set_rules('type', '', 'required');
                $oFormValidation->set_rules('body', '', 'required');
                $oFormValidation->set_rules('excerpt', '', '');
                $oFormValidation->set_rules('image_id', '', '');
                $oFormValidation->set_rules('video_url', '', '');
                $oFormValidation->set_rules('audio_url', '', '');
                $oFormValidation->set_rules('seo_description', '', '');
                $oFormValidation->set_rules('seo_keywords', '', '');

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

                    $sTable = $this->blog_post_model->getTableName();
                    $oFormValidation->set_rules(
                        'slug',
                        '',
                        'trim|alpha_dash|is_unique[' . $sTable . '.slug]'
                    );
                }

                if ($this->input->post('type') === 'PHOTO') {

                    $oFormValidation->set_rules('image_id', '', 'required');

                } elseif ($this->input->post('type') === 'VIDEO') {

                    $oFormValidation->set_rules('video_url', '', 'required');

                } elseif ($this->input->post('type') === 'AUDIO') {

                    $oFormValidation->set_rules('audio_url', '', 'required');
                }

                $oFormValidation->set_message('required', lang('fv_required'));
                $oFormValidation->set_message('alpha_dash', lang('fv_alpha_dash'));
                $oFormValidation->set_message('is_unique', 'A post using this slug already exists.');

            }

            if (!empty($bIsPreview) || $oFormValidation->run($this)) {

                //  Prepare data
                $aData                     = array();
                $aData['blog_id']          = $this->blog->id;
                $aData['title']            = $this->input->post('title');
                $aData['type']             = $this->input->post('type');
                $aData['slug']             = $this->input->post('slug');
                $aData['excerpt']          = $this->input->post('excerpt');
                $aData['image_id']         = (int) $this->input->post('image_id');
                $aData['image_id']         = $aData['image_id'] ? $aData['image_id'] : null;
                $aData['video_url']        = trim($this->input->post('video_url'));
                $aData['video_url']        = $aData['video_url'] ? $aData['video_url'] : null;
                $aData['audio_url']        = trim($this->input->post('audio_url'));
                $aData['audio_url']        = $aData['audio_url'] ? $aData['audio_url'] : null;
                $aData['body']             = $this->input->post('body');
                $aData['seo_description']  = $this->input->post('seo_description');
                $aData['seo_keywords']     = $this->input->post('seo_keywords');
                $aData['is_published']     = (bool) $this->input->post('is_published');
                $aData['published']        = $this->input->post('published');
                $aData['associations']     = $this->input->post('associations');
                $aData['gallery']          = $this->input->post('gallery');
                $aData['comments_enabled'] = $this->input->post('comments_enabled');
                $aData['comments_expire']  = $this->input->post('comments_expire');

                if (appSetting('categories_enabled', 'blog-' . $this->blog->id)) {

                    $aData['categories'] = $this->input->post('categories');
                }

                if (appSetting('tags_enabled', 'blog-' . $this->blog->id)) {

                    $aData['tags'] = $this->input->post('tags');
                }

                //  Are we running in preview mode?
                if (!empty($bIsPreview)) {

                    //  Previewing, set the preview tables and create a new one
                    $aData['blog_id'] = $this->blog->id;
                    $this->blog_post_model->usePreviewTables(true);
                    $iPostId = $this->blog_post_model->create($aData);

                } else {

                    //  Normal behaviour
                    $iPostId = $this->blog_post_model->create($aData);
                }

                if (!empty($iPostId)) {

                    //  Behave slightly differently depending on whether we're previewing or not
                    if (empty($bIsPreview)) {

                        //  Update admin changelog
                        $this->oChangeLogModel->add(
                            'created',
                            'a',
                            'blog post',
                            $iPostId,
                            $aData['title'],
                            'admin/blog/post/edit/' . $this->blog->id . '/' . $iPostId
                        );

                        $this->session->set_flashdata('success', ucfirst($this->data['postName']) . ' was created.');
                        $sRedirectUrl = 'admin/blog/post/edit/' . $this->blog->id . '/' . $iPostId;

                    } else {

                        $sRedirectUrl = $this->blog->url . '/preview/' . $iPostId;
                    }

                    redirect($sRedirectUrl);

                } else {

                    $this->data['error']  = 'An error occurred and the post could not be created. ';
                    $this->data['error'] .= $this->blog_post_model->lastError();
                }

            } else {

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

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

        //  Load Categories and Tags
        if (appSetting('categories_enabled', 'blog-' . $this->blog->id)) {

            $aData            = array();
            $aData['where']   = array();
            $aData['where'][] = array('column' => 'blog_id', 'value' => $this->blog->id);

            $this->data['categories'] = $this->blog_category_model->getAll(null, null, $aData);
        }

        if (appSetting('tags_enabled', 'blog-' . $this->blog->id)) {

            $aData            = array();
            $aData['where']   = array();
            $aData['where'][] = array('column' => 'blog_id', 'value' => $this->blog->id);

            $this->data['tags'] = $this->blog_tag_model->getAll(null, null, $aData);
        }

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

        //  Load other data
        $oCdn                            = Factory::service('Cdn', 'nails/module-cdn');
        $this->data['associations']      = $this->blog_model->getAssociations();
        $this->data['cdnUrlScaleScheme'] = $oCdn->urlScaleScheme();

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

        //  Load assets
        $oAsset = Factory::service('Asset');
        $oAsset->library('uploadify');
        $oAsset->library('MUSTACHE');
        $oAsset->load('moment/moment.js', 'NAILS-BOWER');
        $oAsset->load('admin.post.edit.min.js', 'nails/module-blog');

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

        $sInlineJs  = 'var _EDIT;';
        $sInlineJs .= '$(function()';
        $sInlineJs .= '{';
        $sInlineJs .= '    _EDIT = new NAILS_Admin_Blog_Create_Edit(\'CREATE\');';
        $sInlineJs .= '    _EDIT.init(' . $this->blog->id . ', "' . $oCdn->generateApiUploadToken() . '");';
        $sInlineJs .= '});';

        $oAsset->inline($sInlineJs, 'JS');

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

        Helper::loadView('edit');
    }
915319
public function create()
	{
		if ( Shinobi::can( config('watchtower.acl.role.create', false) ) ) {
			return view( config('watchtower.views.roles.create') )
				->with('route', $this->route);
		}

		return view( config('watchtower.views.layouts.unauthorized'), [ 'message' => 'create new roles' ]);
	}
413714
public static function create()
    {
        $ob = new stdClass;
        $ob->value = self::DEFAULT_CONTENT_TYPE;

        return new self(null, $ob);
    }
54215
function requestNew()
    {
        $db = new Db;

        //Search from first register with [article.status] 5 and [article.editdate] <= datetime - 24 hours.
        $result = $db->query('SELECT MIN(id)id, (SELECT MAX(id+1) FROM article)nid
                              FROM article
                              WHERE status = 6
                              OR (status = 5 AND editdate <=  STR_TO_DATE(\''.date('Y-m-d H:i:s', time()-86400).'\', \'%Y-%m-%d %H:%i:%s\'))');

        if (isset($result[0])) {
            $this->editdate = date('Y-m-d H:i:s');
            $this->pubdate = $this->editdate;


            //Criando novo registro
            if ($result[0]->get('id') == null) {
                $this->id = $result[0]->get('nid');

                $db->query('INSERT INTO articlecontent
                           SET article = '.$this->id.',
                           	   content = "",
            				   editdate = "'.$this->editdate.'"');

                $db->query('INSERT INTO article
                           SET id = '.$this->id.',
                               status = 5,
                               editdate = \''.$this->editdate.'\'');

            //Atualizando o registro
            } else {
                $this->id = $result[0]->get('id');

                $db->query('UPDATE article
                           SET status = 5,
                               pubdate = \''.$this->pubdate.'\',
            				   editdate = \''.$this->editdate.'\',
            				   rateup = 0,
            				   ratedown = 0,
            				   access = 0,
            				   link = "",
            				   tags = "",
            				   title = "",
            				   media = "{}",
            				   resume = ""
            				   
            			 WHERE id = '.$this->id.'');

                $db->query('UPDATE articlecontent
                           SET content = "",
            				   editdate = \''.$this->editdate.'\'
            			 WHERE article = '.$this->id.'');
            }

                //Make dir clean (delete all files)
                $this->clearDir();
                return $this;
        }

            return false;
    }
583351
def create
      service = Blogo::CreatePostService.new(blogo_current_user, post_params)

      if service.create!
        @post = service.post
        flash[:notice] = I18n.translate('blogo.admin.post_created')
        redirect_to blogo_admin_posts_path
      else
        @post = service.post
        render 'new'
      end
    end
810544
public function newAction()
    {
        $form = $this->getServiceLocator()->get('playgrounddesign_theme_form');

        $request = $this->getRequest();
        $themeEntity = new themeEntity;

        if ($request->isPost()) {
            $data = array_merge(
                $request->getPost()->toArray(),
                $request->getFiles()->toArray()
            );

            $theme = $this->getAdminThemeService()->create($data, 'playgrounddesign_theme_form');
            if ($theme) {
                $this->flashMessenger()->addMessage('The theme "'.$theme->getTitle().'" was created');

                return $this->redirect()->toRoute('admin/playgrounddesign_themeadmin');
            } else {
                $this->flashMessenger()->addMessage('The theme was not created');

                return $this->redirect()->toRoute('admin/playgrounddesign_themeadmin');
            }
        }

        $viewModel = new ViewModel();
        $viewModel->setTemplate('playground-design/theme-admin/theme');

        return $viewModel->setVariables(array('form'           => $form,
                                              'automaticTheme' => 0));
    }
872970
public function actionCreate()
    {
        if (($source = $this->findModel(Yii::$app->request->post('model_id'))) != null) {
            $model = new ArticleComment();
            $model->scenario = ArticleComment::SCENARIO_CREATE;
            if ($model->load(Yii::$app->request->post(), '') && $model->save()) {
                $source->updateCounters(['comments' => 1]);
                if ($model->to_user_id > 0) {
                    //notify(Yii::$app->user->id, $model->to_user_id, 'reply_comment', $source->title, $source->id, $model->content, 'article', $source->id);
                } else {
                    //notify(Yii::$app->user->id, $source->user_id, 'comment_article', $source->title, $source->id, $model->content, 'article', $source->id);
                }
                return $this->renderPartial('detail', ['model' => $model]);
            }
        }
        throw new NotFoundHttpException(Yii::t('yii', 'The requested page does not exist'));
    }
787933
def create(self, section, article):
        
        return CRUDRequest(self).post(article, create=True, id=section)
980690
public function newAction()
    {
        $entity = new MessageType();
        $form   = $this->createCreateForm($entity);

        return $this->render(
            'BisonLabSakonninBundle:MessageType:edit.html.twig', array(
            'entity' => $entity,
            'edit_form'   => $form->createView(),
        ));
    }
467925
public function rss()
    {
        $this->blogPosts = $this->getBlogPosts()->limit($this->PostsPerPage);

        $rss = new RSSFeed($this->blogPosts, $this->Link(), $this->Title, $this->MetaDescription);

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

        return $rss->outputToBrowser();
    }
385235
public function newAction()
    {
        $entity = new Category();
        $form   = $this->createForm(new CategoryType(), $entity);

        return array(
            'entity' => $entity,
            'form'   => $form->createView(),
        );
    }
321972
public function newAction()
    {
        $scope = new Scope();
        $form   = $this->createCreateForm($scope);

        return $this->render('ChillMainBundle:Scope:new.html.twig', array(
            'entity' => $scope,
            'form'   => $form->createView(),
        ));
    }
684024
public function actionCreate()
    {
        $model = new Article();
        if ($model->load(Yii::$app->request->post()) && $model->save()) {
            Yii::$app->getSession()->setFlash('success', Yii::t('article', 'Create success.'));
            return $this->redirect(['view', 'id' => $model->id]);
        }
        return $this->render('create', [
            'model' => $model,
        ]);
    }