<commit_before><?php
/*
 * Copyright (c) 2014 <NAME> (https://chriswells.io)
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 */

use \CWA\DB\DatabaseException;
use \CWA\MVC\Controllers\InvalidArgumentException;

require_once 'BaseDBController.php';

class BlogPostController extends BaseDBController
{
	/* Constructor */
	public function __construct() {
		if ($GLOBALS['app']->getCurrentUser()->hasRole('ADMIN')) {
			$this->adminSort = 'Published IS NULL DESC, Published DESC';
			$this->indexSort = 'Published IS NULL DESC, Published DESC';
		} else {
			$this->indexSort = 'Published DESC';
			$this->indexClauses = "WHERE Published IS NOT NULL ORDER BY $this->indexSort";
		}

		parent::__construct();

		$this->viewInfo['add']['title'] = 'Add Blog Post';
		$this->viewInfo['admin']['title'] = 'Blog Admin';
		$this->viewInfo['admin']['description'] = 'Blog Admin on ' . DOMAIN . '.';
		$this->viewInfo['edit']['title'] = 'Edit Blog Post';
		$this->viewInfo['index']['title'] = 'Blog';
		$this->viewInfo['index']['description'] = 'Recent blog posts by '. SITE_AUTHOR . ' on ' . SITE_DOMAIN . '.';
		$this->viewInfo['page']['title'] = 'Blog - Page {PageNumber}';
		$this->viewInfo['page']['description'] = 'Older blog posts by '. SITE_AUTHOR . ' on ' . SITE_DOMAIN . '.';
		$this->viewInfo['save']['title'] = 'Save Blog Post';
		$this->viewInfo['view']['title'] = '{Title} :: Blog';
		$this->viewInfo['view']['description'] = '{Summary}';
		$this->viewInfo['view']['canonicalURL'] = PROTOCOL_HOST_PORT . "$this->pathInURL/view/{Slug}";
	}


	/* Public methods: */

	public function add($properties = null) {
		parent::add($properties);
		$itemTagIDs = array();
		$tags = $this->db->selectAll('Tag', 'ORDER BY Value');<commit_msg>Do not show unpublished blog entries on index page even for admins.<commit_after><?php
/*
 * Copyright (c) 2014 <NAME> (https://chriswells.io)
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 */

use \CWA\DB\DatabaseException;
use \CWA\MVC\Controllers\InvalidArgumentException;

require_once 'BaseDBController.php';

class BlogPostController extends BaseDBController
{
	/* Constructor */
	public function __construct() {
		$this->adminSort = 'Published IS NULL DESC, Published DESC';
		$this->indexSort = 'Published DESC';
		$this->indexClauses = "WHERE Published IS NOT NULL ORDER BY $this->indexSort";

		parent::__construct();

		$this->viewInfo['add']['title'] = 'Add Blog Post';
		$this->viewInfo['admin']['title'] = 'Blog Admin';
		$this->viewInfo['admin']['description'] = 'Blog Admin on ' . DOMAIN . '.';
		$this->viewInfo['edit']['title'] = 'Edit Blog Post';
		$this->viewInfo['index']['title'] = 'Blog';
		$this->viewInfo['index']['description'] = 'Recent blog posts by '. SITE_AUTHOR . ' on ' . SITE_DOMAIN . '.';
		$this->viewInfo['page']['title'] = 'Blog - Page {PageNumber}';
		$this->viewInfo['page']['description'] = 'Older blog posts by '. SITE_AUTHOR . ' on ' . SITE_DOMAIN . '.';
		$this->viewInfo['save']['title'] = 'Save Blog Post';
		$this->viewInfo['view']['title'] = '{Title} :: Blog';
		$this->viewInfo['view']['description'] = '{Summary}';
		$this->viewInfo['view']['canonicalURL'] = PROTOCOL_HOST_PORT . "$this->pathInURL/view/{Slug}";
	}


	/* Public methods: */

	public function add($properties = null) {
		parent::add($properties);
		$itemTagIDs = array();
		$tags = $this->db->selectAll('Tag', 'ORDER BY Value');
{'fraction_non_alphanumeric': 0.17260958437429025, 'fraction_numerical': 0.0036338859868271633, 'mean_word_length': 4.49812734082397, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 46, 'https://': 2, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5891811', 'n_tokens_mistral': 1410, 'n_tokens_neox': 1332, 'n_words': 384}