Create a new blog tag
@return void
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');
    }
420752
def add_tag(self, new_tags):
        

        tags = self.get_tags()
        orig_tag_cnt = len(tags)
        # print("self.get_tags() {}".format(tags))

        if isinstance(new_tags, six.string_types):
            new_tags = new_tags.split(',')
            # print("spliting tags :: {}".format(new_tags))

        for tag in new_tags:
            if not tag in tags:
                tags.append(tag.strip())

        if len(tags) > orig_tag_cnt:
            xml_tags = escape(",".join(tags))
            post_data = TAGS_TEMPLATE.format(connectware_id=self.get_connectware_id(),
                                             tags=xml_tags)
            self._conn.put('/ws/DeviceCore', post_data)

            # Invalidate cache
            self._device_json = None
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']);
    }
1104876
protected function addBBCodeEndTag()
	{
		return $this->parser->addEndTag($this->getTagName(), $this->startPos, $this->pos - $this->startPos);
	}
381729
protected static function formTags() {

		check_admin_referer( 'pb-user-catalog' );

		if ( ! empty( $_REQUEST['ID'] ) ) {
			list( $user_id, $blog_id ) = explode( ':', $_REQUEST['ID'] );
		} else {
			$user_id = '';
			$blog_id = '';
		}
		if ( ! empty( $_REQUEST['user_id'] ) ) {
			$user_id = absint( $_REQUEST['user_id'] );
		}
		if ( ! empty( $_REQUEST['blog_id'] ) ) {
			$blog_id = absint( $_REQUEST['blog_id'] );
		}

		if ( ! $user_id || ! current_user_can( 'edit_user', $user_id ) ) {
			wp_die( __( 'You do not have permission to do that.', 'pressbooks' ) );
		}

		// Set Redirect URL
		if ( get_current_user_id() !== $user_id ) {
			$redirect_url = get_admin_url( get_current_blog_id(), '/index.php?page=pb_catalog&user_id=' . $user_id );
		} else {
			$redirect_url = get_admin_url( get_current_blog_id(), '/index.php?page=pb_catalog' );
		}

		/* Go! */
		$catalog = new static( $user_id );
		$featured = ( isset( $_REQUEST['featured'] ) ) ? absint( $_REQUEST['featured'] ) : 0;
		$catalog->saveBook(
			$blog_id, [
				'featured' => $featured,
			]
		);

		// Tags
		for ( $i = 1; $i <= self::MAX_TAGS_GROUP; ++$i ) {
			$catalog->deleteTags( $blog_id, $i );
			$tags = ( isset( $_REQUEST[ "tags_$i" ] ) ) ? $_REQUEST[ "tags_$i" ] : [];
			foreach ( $tags as $tag ) {
				$catalog->saveTag( $tag, $blog_id, $i );
			}
		}

		$catalog->deleteCache();

		// Ok!
		$_SESSION['pb_notices'][] = __( 'Settings saved.' );

		// Redirect back to form
		\Pressbooks\Redirect\location( $redirect_url );
	}
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(),
                ]
            ),
        ]);
    }
65513
public function tag()
    {
        if (!appSetting('tags_enabled', 'blog-' . $this->oBlog->id) || !$this->uri->rsegment(4)) {

            show404();
        }

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

        //  Get tag
        $this->data['tag'] = $this->blog_tag_model->getBySlug($this->uri->rsegment(4));

        if (!$this->data['tag']) {

            show404();
        }

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

        //  Widgets
        $this->fetchSidebarWidgets();

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

        //  Meta
        $this->data['page']->title = $this->oBlog->label . ': ' . ucfirst($this->data['postNamePlural']) . ' tagged with "' . $this->data['tag']->label . '"';
        $this->data['page']->seo->description = 'All ' . $this->data['postNamePlural'] . ' tagged with  ' . $this->data['tag']->label . ' ';
        $this->data['page']->seo->keywords    = '';

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

        //  Handle pagination
        $page     = $this->uri->rsegment(5);
        $perPage = appSetting('home_per_page', 'blog-' . $this->oBlog->id);
        $perPage = $perPage ? $perPage : 10;

        $this->data['pagination']           = new stdClass();
        $this->data['pagination']->page     = $page;
        $this->data['pagination']->per_page = $perPage;

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

        //  Send any additional data
        $data                    = array();
        $data['include_body']    = !appSetting('use_excerpts', 'blog-' . $this->oBlog->id);
        $data['include_gallery'] = appSetting('home_show_gallery', 'blog-' . $this->oBlog->id);
        $data['sort']            = array('bp.published', 'desc');

        //  Only published items which are not schduled for the future
        $data['where']   = array();
        $data['where'][] = array('column' => 'bp.blog_id',   'value' => $this->oBlog->id);
        $data['where'][] = array('column' => 'is_published', 'value' => true);
        $data['where'][] = array('column' => 'published <=', 'value' => 'NOW()', 'escape' => false);

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

        //  Load posts and count
        $this->data['posts'] = $this->blog_post_model->getWithTag($this->data['tag']->id, $page, $perPage, $data);
        $this->data['pagination']->total = $this->blog_post_model->countAll($data);

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

        //  Any SEO data?
        if (!empty($this->data['tag']->seo_title)) {

            $this->data['page']->title = $this->data['tag']->seo_title;
        }

        if (!empty($this->data['tag']->seo_description)) {

            $this->data['page']->seo->description = $this->data['tag']->seo_description;
        }

        if (!empty($this->data['tag']->seo_keywords)) {

            $this->data['page']->seo->keywords = $this->data['tag']->seo_keywords;
        }

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

        //  Finally, let the views know this is an 'archive' type page
        $this->data['archive_title']       = ucfirst($this->data['postNamePlural']) . ' in tag "' . $this->data['tag']->label . '"';
        $this->data['archive_description'] = $this->data['tag']->description;
        $this->data['isTag']               = true;

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

        $oView = Factory::service('View');
        $oView->load('structure/header', $this->data);
        $this->loadView('browse', $this->data);
        $oView->load('structure/footer', $this->data);
    }
999193
protected function addBBCodeSelfClosingTag()
	{
		$tag = $this->parser->addSelfClosingTag($this->getTagName(), $this->startPos, $this->pos - $this->startPos);
		$tag->setAttributes($this->attributes);

		return $tag;
	}
88409
public static function createFromToken(TagToken $token) : Tag
    {
        $tagName = $token->getTagName();
        $attribute = $token->getAttribute();
        return new Tag($tagName, $attribute);
    }
253592
protected function setUp()
	{
		if (isset($this->configurator->tags[$this->tagName]))
		{
			return;
		}

		// Create tag
		$tag = $this->configurator->tags->add($this->tagName);

		// Create attribute
		$tag->attributes->add($this->attrName);

		// Create a template that replaces its content with the replacement char
		$tag->template
			= '<xsl:value-of select="@' . htmlspecialchars($this->attrName) . '"/>';
	}
968279
public function run()
    {
        factory(\App\Entities\Admin\Categoria::class, 6)->create();

        factory(\App\Entities\Admin\Tag::class, 10)->create();

        factory(\App\Entities\Admin\Noticia::class, 20)->create()->each(function ($n){{
            $tags = \App\Entities\Admin\Tag::all()->random()->id;
            $n->tags()->sync($tags);
        }});
    }
698551
def create_tags(self, entry):
        """"""
        tag_list = [t.lower().strip() for t in entry.tag_string.split(',')]
        for t in tag_list:
            tag, created = self.get_or_create(name=t)
            entry.tags.add(tag)
719554
def new_tag(self, label, cfrom=None, cto=None, tagtype=None, **kwargs):
        '''  '''
        if cfrom is None:
            cfrom = self.cfrom
        if cto is None:
            cto = self.cto
        tag = Tag(label=label, cfrom=cfrom, cto=cto, tagtype=tagtype, **kwargs)
        return self.add_tag(tag)
1050460
public static function announce()
    {
        //  Fetch the blogs, each blog should have its own admin section
        $ci =& get_instance();
        $ci->load->model('blog/blog_model');
        $blogs = $ci->blog_model->getAll();

        $out = array();

        if (!empty($blogs)) {

            foreach ($blogs as $blog) {

                //  Categories enabled for this blog?
                if (!appSetting('tags_enabled', 'blog-' . $blog->id)) {
                    continue;
                }

                if (!userHasPermission('admin:blog:tag:' . $blog->id . ':manage')) {
                    continue;
                }

                //  Clear group naming
                $sGroupLabel = count($blogs) > 1 ? 'Blog: ' . $blog->label : $blog->label;

                //  Create the navGrouping
                $oNavGroup = Factory::factory('Nav', 'nails/module-admin');
                $oNavGroup->setLabel($sGroupLabel);
                $oNavGroup->setIcon('fa-pencil-square-o');
                $oNavGroup->addAction('Manage Tags', 'index/' . $blog->id);

                $out[] = $oNavGroup;
            }
        }

        return $out;
    }
907204
public function newAction(): void
    {
        try {
            $maximumFileUploadSize = $this->getMaximumFileUploadSize();
        } catch (FilesException $e) {
            $maximumFileUploadSize = null;
        }

        $this->view->assignMultiple([
            'tags' => $this->tagRepository->findAll(),
            'assetCollections' => $this->assetCollectionRepository->findAll(),
            'maximumFileUploadSize' => $maximumFileUploadSize,
            'humanReadableMaximumFileUploadSize' => Files::bytesToSizeString($maximumFileUploadSize)
        ]);
    }
955360
private function setTag()
    {
        $Params = $this->getURLParams();
        $tag = Tag::get()
            ->filter(array('URLSegment' => Convert::raw2sql($Params['ID'])))->first();
        $this->current_tag = $tag;
    }
646779
private function createFromCommand()
    {
        $command = TagCommand::getInstance($this->getRepository())->listTags();
        $outputLines = $this->getCaller()->execute($command, true, $this->getRepository()->getPath())->getOutputLines();
        $this->parseOutputLines($outputLines);
    }