Edit a blog tag
@return void
163465
public function edit()
    {
        if (!userHasPermission('admin:blog:tag:' . $this->blog->id . ':edit')) {

            unauthorised();
        }

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

        $this->data['tag'] = $this->blog_tag_model->getById($this->uri->segment(6));

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

            show404();
        }

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

        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()) {

                $aUpdateData                    = array();
                $aUpdateData['label']           = $this->input->post('label');
                $aUpdateData['description']     = $this->input->post('description');
                $aUpdateData['seo_title']       = $this->input->post('seo_title');
                $aUpdateData['seo_description'] = $this->input->post('seo_description');
                $aUpdateData['seo_keywords']    = $this->input->post('seo_keywords');

                if ($this->blog_tag_model->update($this->data['tag']->id, $aUpdateData)) {

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

                } else {

                    $this->data['error']  = 'There was a problem saving 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; Catrgories &rsaquo; Edit &rsaquo; ' . $this->data['tag']->label;

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

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

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

        //  Load views
        Helper::loadView('edit');
    }
702731
private function createTags()
    {
        if($this->option('tags') || $this->option('tags_per_post_type') || $this->option('all')) {
            $this->comment('Creating dummy tags...');

            $output = (new \TagSeeder())
                ->setCommand($this)
                ->run(
                    ($this->getDefaultOption('tags_per_post_type') ? $this->getDefaultOption('tags_per_post_type') : $this->getDefaultOption('tags')),
                    $this->getDefaultOption('post_type'),
                    ($this->getDefaultOption('tags_per_post_type') ? true : false)
                );

            $this->info($output);
        }

        return $this;
    }
1368921
public function addTags(): void
    {
        $tags = $this->getTags();
        $currentStructureUuid = $this->getCurrentStructureUuid();
        if ($currentStructureUuid && !in_array($currentStructureUuid, $tags)) {
            $tags[] = $currentStructureUuid;
        }

        if (count($tags) <= 0) {
            return;
        }

        $this->symfonyResponseTagger->addTags($tags);
    }
730821
public function parseOutsideTag() : void
    {
        if (!count($this->stream->getTokens())) {
            return;
        }

        if ($this->accept(Token::T_TEXT)) {
            $this->insert(new TextNode($this->getCurrentToken()->getValue()));
            $this->advance();
        }

        if ($this->skip(Token::T_OPENING_TAG)) {
            $this->parseStatement();
        }
    }
553273
protected function handleTag_li()
    {
        if ($this->parent() == 'ol') {
            $parent =& $this->getStacked('ol');
            if ($this->parser->isStartTag) {
                $parent['num']++;
                $this->out(str_repeat(' ', 3 - strlen($parent['num'])) . $parent['num'] . '. ', true);
            }
        } else {
            if ($this->parser->isStartTag) {
                $this->out('  * ', true);
            }
        }
        $this->indent('    ', false);
        if (!$this->parser->isStartTag) {
            $this->setLineBreaks(1);
        }
    }
1205161
public function UpdateTags()
    {
        $siteTree = DataObject::getSchema()->tableName(SiteTree::class);
        $taxonomy = DataObject::getSchema()->tableName(TaxonomyTerm::class);

        $tags = TaxonomyTerm::get()
            ->innerJoin('BasePage_Terms', sprintf('"%s"."ID"="BasePage_Terms"."TaxonomyTermID"', $taxonomy))
            ->innerJoin(
                $siteTree,
                sprintf(
                    '"%s"."ID" = "BasePage_Terms"."BasePageID" AND "%s"."ParentID" = \'%d\'',
                    $siteTree,
                    $siteTree,
                    $this->ID
                )
            )
            ->sort('Name');

        return $tags;
    }
1364045
protected function replaceMarkerWithContent($node, $tag)
    {
        $content = $this->getShortcodeReplacementText($tag);

        if ($content) {
            /** @var HTMLValue $parsed */
            $parsed = HTMLValue::create($content);
            $body = $parsed->getBody();
            if ($body) {
                $this->insertListAfter($body->childNodes, $node);
            }
        }

        $this->removeNode($node);
    }
756574
function handleTag_table() {
    if ($this->parser->isStartTag) {
      # check if upcoming table can be converted
      if ($this->keepHTML) {
        if (preg_match($this->tableLookaheadHeader, $this->parser->html, $matches)) {
          # header seems good, now check body
          # get align & number of cols
          preg_match_all('#<th(?:\s+align=("|\')(left|right|center)\1)?\s*>#si', $matches[0], $cols);
          $regEx = '';
          $i = 1;
          $aligns = array();
          foreach ($cols[2] as $align) {
            $align = strtolower($align);
            array_push($aligns, $align);
            if (empty($align)) {
              $align = 'left'; # default value
            }
            $td = '\s+align=("|\')'.$align.'\\'.$i;
            $i++;
            if ($align == 'left') {
              # look for empty align or left
              $td = '(?:'.$td.')?';
            }
            $td = '<td'.$td.'\s*>';
            $regEx .= $td.$this->tdSubstitute;
          }
          $regEx = sprintf($this->tableLookaheadBody, $regEx);
          if (preg_match($regEx, $this->parser->html, $matches, null, strlen($matches[0]))) {
            # this is a markdownable table tag!
            $this->table = array(
              'rows' => array(),
              'col_widths' => array(),
              'aligns' => $aligns,
            );
            $this->row = 0;
          } else {
            # non markdownable table
            $this->handleTagToText();
          }
        } else {
          # non markdownable table
          $this->handleTagToText();
        }
      } else {
        $this->table = array(
          'rows' => array(),
          'col_widths' => array(),
          'aligns' => array(),
        );
        $this->row = 0;
      }
    } else {
      # finally build the table in Markdown Extra syntax
      $separator = array();
      # seperator with correct align identifikators
      foreach($this->table['aligns'] as $col => $align) {
        if (!$this->keepHTML && !isset($this->table['col_widths'][$col])) {
          break;
        }
        $left = ' ';
        $right = ' ';
        switch ($align) {
          case 'left':
            $left = ':';
            break;
          case 'center':
            $right = ':';
            $left = ':';
          case 'right':
            $right = ':';
            break;
        }
        array_push($separator, $left.str_repeat('-', $this->table['col_widths'][$col]).$right);
      }
      $separator = '|'.implode('|', $separator).'|';

      $rows = array();
      # add padding
      array_walk_recursive($this->table['rows'], array(&$this, 'alignTdContent'));
      $header = array_shift($this->table['rows']);
      array_push($rows, '| '.implode(' | ', $header).' |');
      array_push($rows, $separator);
      foreach ($this->table['rows'] as $row) {
        array_push($rows, '| '.implode(' | ', $row).' |');
      }
      $this->out(implode("\n".$this->indent, $rows));
      $this->table = array();
      $this->setLineBreaks(2);
    }
  }
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');
    }
977785
public function UpdateTagsWithLinks()
    {
        $tags = $this->UpdateTags();

        $processed = ArrayList::create();

        foreach ($tags as $tag) {
            // Build the link - keep the tag, and date range, but reset month, year and pagination.
            $link = HTTP::setGetVar('tag', $tag->ID, null, '&');
            $link = HTTP::setGetVar('month', null, $link, '&');
            $link = HTTP::setGetVar('year', null, $link, '&');
            $link = HTTP::setGetVar('start', null, $link, '&');

            $tag->Link = $link;
            $processed->push($tag);
        }

        return $processed;
    }
1303892
protected function setOgTags()
    {
        if ($this->arResult['OG_TAGS']['TITLE'])
        {
            Asset::getInstance()->addString('<meta property="og:title" content="'.$this->arResult['OG_TAGS']['TITLE'].'" />', true);
        }

        if ($this->arResult['OG_TAGS']['DESCRIPTION'])
        {
            Asset::getInstance()->addString('<meta property="og:description" content="'.$this->arResult['OG_TAGS']['DESCRIPTION'].'" />', true);
        }

        if ($this->arResult['OG_TAGS']['URL'])
        {
            Asset::getInstance()->addString('<meta property="og:url" content="'.$this->arResult['OG_TAGS']['URL'].'" />', true);
        }

        if ($this->arResult['OG_TAGS']['IMAGE'])
        {
            Asset::getInstance()->addString('<meta property="og:image" content="'.$this->arResult['OG_TAGS']['IMAGE'].'" />', true);
        }
    }
637607
public function edit()
    {
        if (!userHasPermission('admin:blog:post:' . $this->blog->id . ':edit')) {

            unauthorised();
        }

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

        //  Fetch and check post
        $iPostId = (int) $this->uri->segment(6);

        $this->data['post'] = $this->blog_post_model->getById($iPostId);

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

            show404();
        }

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

        //  Set method info
        $this->data['page']->title = 'Edit ' . $this->data['postName'] . ' &rsaquo; ' . $this->data['post']->title;

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

        //  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_keywords', '', '');

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

                    $sTable = $this->blog_post_model->getTableName();
                    $oFormValidation->set_rules(
                        'slug',
                        '',
                        'alpha_dash|unique_if_diff[' . $sTable . '.slug.' . $this->data['post']->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|callback_callbackValidVideoUrl');

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

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

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

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

                //  Prepare data
                $aData                     = array();
                $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);
                    $mResult = $this->blog_post_model->create($aData);

                } else {

                    //  Normal behaviour
                    $mResult = $this->blog_post_model->update($iPostId, $aData);
                }

                if (!empty($mResult)) {

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

                        //  Update admin change log
                        foreach ($aData as $field => $value) {

                            if (isset($this->data['post']->$field)) {

                                switch ($field) {

                                    case 'associations':

                                        //  @TODO: changelog associations
                                        break;

                                    case 'categories':

                                        $aOldCategories = array();
                                        $aNewCategories = array();

                                        foreach ($this->data['post']->$field as $v) {

                                            $aOldCategories[] = $v->label;
                                        }

                                        if (is_array($value)) {

                                            foreach ($value as $v) {

                                                $temp = $this->blog_category_model->getById($v);

                                                if ($temp) {

                                                    $aNewCategories[] = $temp->label;
                                                }
                                            }
                                        }

                                        asort($aOldCategories);
                                        asort($aNewCategories);

                                        $aOldCategories = implode(',', $aOldCategories);
                                        $aNewCategories = implode(',', $aNewCategories);

                                        $this->oChangeLogModel->add(
                                            'updated',
                                            'a',
                                            'blog post',
                                            $iPostId,
                                            $aData['title'],
                                            'admin/blog/post/create/' . $this->blog->id . '/' . $iPostId,
                                            $field,
                                            $aOldCategories,
                                            $aNewCategories,
                                            false
                                        );
                                        break;

                                    case 'tags':

                                        $aOldTags = array();
                                        $aNewTags = array();

                                        foreach ($this->data['post']->$field as $v) {

                                            $aOldTags[] = $v->label;
                                        }

                                        if (is_array($value)) {

                                            foreach ($value as $v) {

                                                $temp = $this->blog_tag_model->getById($v);

                                                if ($temp) {

                                                    $aNewTags[] = $temp->label;
                                                }
                                            }
                                        }

                                        asort($aOldTags);
                                        asort($aNewTags);

                                        $aOldTags = implode(',', $aOldTags);
                                        $aNewTags = implode(',', $aNewTags);

                                        $this->oChangeLogModel->add(
                                            'updated',
                                            'a',
                                            'blog post',
                                            $iPostId,
                                            $aData['title'],
                                            'admin/blog/post/create/' . $this->blog->id . '/' . $iPostId,
                                            $field,
                                            $aOldTags,
                                            $aNewTags,
                                            false
                                        );
                                        break;

                                    default :

                                        $this->oChangeLogModel->add(
                                            'updated',
                                            'a',
                                            'blog post',
                                            $iPostId,
                                            $aData['title'],
                                            'admin/blog/post/create/' . $this->blog->id . '/' . $iPostId,
                                            $field,
                                            $this->data['post']->$field,
                                            $value,
                                            false
                                        );
                                        break;
                                }
                            }
                        }

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

                    } else {

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

                    redirect($sRedirectUrl);

                } else {

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

            } else {

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

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

        //  Load Categories and Tags
        $aData = array(
            'where' => array(
                array('column' => 'blog_id', 'value' => $this->blog->id)
            )
        );

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

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

        if (appSetting('tags_enabled', 'blog-' . $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['post']->id);
        $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');

        if ($this->data['post']->is_published) {

            $oNow = new \DateTime();
            $oPublished = new \DateTime($this->data['post']->published);

            if ($oPublished > $oNow) {
                $sInitalPublishState = 'SCHEDULED';
            } else {
                $sInitalPublishState = 'PUBLISHED';
            }

        } else {
            $sInitalPublishState = 'DRAFT';
        }

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

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

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

        Helper::loadView('edit');
    }
1130162
public function index()
    {
        if (!userHasPermission('admin:blog:settings:\d+:update')) {

            unauthorised();
        }

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

        //  Load models
        $this->load->model('blog/blog_model');
        $oSkinModel = Factory::model('Skin', 'nails/module-blog');

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

        $this->data['blogs'] = $this->blog_model->getAllFlat();

        if (empty($this->data['blogs'])) {

            if (userHasPermission('admin:blog:blog:create')) {

                $status   = 'message';
                $message  = '<strong>You don\'t have a blog!</strong> Create a new blog ';
                $message .= 'in order to configure blog settings.';
                $oSession = Factory::service('Session', 'nails/module-auth');
                $oSession->setFlashData($status, $message);
                redirect('admin/blog/blog/create');

            } else {

                show404();
            }
        }

        if (count($this->data['blogs']) == 1) {

            reset($this->data['blogs']);
            $this->data['selectedBlogId'] = key($this->data['blogs']);

        } elseif ($this->input->get('blog_id')) {

            if (!empty($this->data['blogs'][$this->input->get('blog_id')])) {

                $this->data['selectedBlogId'] = $this->input->get('blog_id');
            }

            if (empty($this->data['selectedBlogId'])) {

                $this->data['error'] = 'There is no blog by that ID.';
            }
        }

        //  Check user has permission
        if (!empty($this->data['selectedBlogId'])) {

            if (!userHasPermission('admin:blog:settings:' . $this->data['selectedBlogId'] . ':update')) {

                unauthorised();
            }
        }

        //  Set up the skin model for this blog
        //  @todo; work out a cleaner way of handling this
        $oSkinModel->init($this->data['selectedBlogId']);

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

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

            //  Prepare update
            $settings                       = array();
            $settings['name']               = $this->input->post('name');
            $settings['url']                = $this->input->post('url');
            $settings['postName']           = strtolower($this->input->post('postName'));
            $settings['postNamePlural']     = strtolower($this->input->post('postNamePlural'));
            $settings['use_excerpts']       = (bool) $this->input->post('use_excerpts');
            $settings['gallery_enabled']    = (bool) $this->input->post('gallery_enabled');
            $settings['categories_enabled'] = (bool) $this->input->post('categories_enabled');
            $settings['tags_enabled']       = (bool) $this->input->post('tags_enabled');
            $settings['rss_enabled']        = (bool) $this->input->post('rss_enabled');

            //  Skin settings
            $settings['skin'] = $this->input->post('skin');

            //  Commenting settings
            $settings['comments_enabled']          = $this->input->post('comments_enabled');
            $settings['comments_engine']           = $this->input->post('comments_engine');
            $settings['comments_disqus_shortname'] = $this->input->post('comments_disqus_shortname');

            //  Social settings
            $settings['social_facebook_enabled']   = (bool) $this->input->post('social_facebook_enabled');
            $settings['social_twitter_enabled']    = (bool) $this->input->post('social_twitter_enabled');
            $settings['social_twitter_via']        = $this->input->post('social_twitter_via');
            $settings['social_googleplus_enabled'] = (bool) $this->input->post('social_googleplus_enabled');
            $settings['social_pinterest_enabled']  = (bool) $this->input->post('social_pinterest_enabled');
            $settings['social_skin']               = $this->input->post('social_skin');
            $settings['social_layout']             = $this->input->post('social_layout');
            $settings['social_layout_single_text'] = $this->input->post('social_layout_single_text');
            $settings['social_counters']           = (bool) $this->input->post('social_counters');

            //  If any of the above are enabled, then social is enabled.
            $settings['social_enabled'] = $settings['social_facebook_enabled'] || $settings['social_twitter_enabled'] || $settings['social_googleplus_enabled'] || $settings['social_pinterest_enabled'];

            //  Sidebar
            $settings['sidebar_latest_posts']  = (bool) $this->input->post('sidebar_latest_posts');
            $settings['sidebar_categories']    = (bool) $this->input->post('sidebar_categories');
            $settings['sidebar_tags']          = (bool) $this->input->post('sidebar_tags');
            $settings['sidebar_popular_posts'] = (bool) $this->input->post('sidebar_popular_posts');

            //  @todo: Associations

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

            //  Sanitize blog url
            $settings['url'] .= substr($settings['url'], -1) != '/' ? '/' : '';

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

            //  Save
            $oAppSettingService = Factory::service('AppSetting');

            if ($oAppSettingService->set($settings, 'blog-' . $this->input->get('blog_id'))) {

                $this->data['success'] = 'Blog settings have been saved.';

                $oRoutesService = Factory::service('Routes');

                if (!$oRoutesService->update()) {

                    $this->data['warning']  = '<strong>Warning:</strong> while the blog settings were updated, the ';
                    $this->data['warning'] .= 'routes file could not be updated. The blog may not behave as expected,';
                }

            } else {

                $this->data['error'] = 'There was a problem saving settings.';
            }
        }

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

        //  Get data
        $this->data['skins']        = $oSkinModel->getAll();
        $this->data['skinSelected'] = $oSkinModel->getEnabled();

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

            $this->data['settings'] = appSetting(null, 'blog-' . $this->data['selectedBlogId'], true);
        }

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

        //  Load assets
        $oAsset = Factory::service('Asset');
        $oAsset->load('admin.settings.min.js', 'nails/module-blog');

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

        //  Set page title
        $this->data['page']->title = 'Settings &rsaquo; Blog';

        if (!empty($this->data['blogs'][$this->input->get('blog_id')])) {

            $this->data['page']->title .= ' &rsaquo; ' . $this->data['blogs'][$this->input->get('blog_id')];
        }

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

        //  Add a header button
        if (userHasPermission('admin:blog:blog:manage')) {
            Helper::addHeaderButton(
                'admin/blog/blog/index',
                'Manage Blogs'
            );
        }

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

        Helper::loadView('index');
    }
462581
function deleteTags( $blog_id, $tag_group ) {

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

		$result = $wpdb->delete(
			$this->dbLinkTable, [
				'users_id' => $this->userId,
				'blogs_id' => $blog_id,
				'tags_group' => $tag_group,
			], [ '%d', '%d', '%d' ]
		);

		// TODO:
		// Optimize the links table: $wpdb->query( "OPTIMIZE TABLE {$this->dbLinkTable} " );

		return $result;

	}
606199
public function editAction()
    {
        $this->editParameters      = $this->editParameters + $this->defaultTokenParameters;
        $this->createEditSnippets  = $this->getToken()->getEditSnippetNames();

        parent::editAction();
    }
113748
protected function processTags()
	{
		if (empty($this->tagStack))
		{
			return;
		}

		// Initialize the count tables
		foreach (array_keys($this->tagsConfig) as $tagName)
		{
			$this->cntOpen[$tagName]  = 0;
			$this->cntTotal[$tagName] = 0;
		}

		// Process the tag stack, close tags that were left open and repeat until done
		do
		{
			while (!empty($this->tagStack))
			{
				if (!$this->tagStackIsSorted)
				{
					$this->sortTags();
				}

				$this->currentTag = array_pop($this->tagStack);
				$this->processCurrentTag();
			}

			// Close tags that were left open
			foreach ($this->openTags as $startTag)
			{
				// NOTE: we add tags in hierarchical order (ancestors to descendants) but since
				//       the stack is processed in LIFO order, it means that tags get closed in
				//       the correct order, from descendants to ancestors
				$this->addMagicEndTag($startTag, $this->textLen);
			}
		}
		while (!empty($this->tagStack));
	}
329713
public function execute()
    {
        $this->query("ALTER TABLE `{{NAILS_DB_PREFIX}}blog_post` ADD `commentsEnabled` TINYINT(1)  UNSIGNED  NOT NULL  DEFAULT '1'  AFTER `seo_keywords`;");
        $this->query("ALTER TABLE `{{NAILS_DB_PREFIX}}blog_post` ADD `commentsExpire` DATETIME  NULL  AFTER `commentsEnabled`;");
        $this->query("ALTER TABLE `{{NAILS_DB_PREFIX}}blog_post` ADD `type` ENUM('TEXT','AUDIO','VIDEO','PHOTO')  NOT NULL  DEFAULT 'PHOTO'  AFTER `slug`;");
        $this->query("ALTER TABLE `{{NAILS_DB_PREFIX}}blog_post` ADD `video_url` VARCHAR(255)  NULL  DEFAULT NULL  AFTER `image_id`;");
        $this->query("ALTER TABLE `{{NAILS_DB_PREFIX}}blog_post` ADD `audio_url` VARCHAR(255)  NULL  DEFAULT NULL  AFTER `video_url`;");
        $this->query("UPDATE `{{NAILS_DB_PREFIX}}blog_post` SET type = 'TEXT' WHERE image_id IS NULL;");
    }