<commit_before><?php defined('SYSPATH') or die('No direct access allowed.');
/**
 * Anqh Blog controller
 *
 * @package    Blog
 * @author     <NAME>
 * @copyright  (c) 2010 <NAME>
 * @license    http://www.opensource.org/licenses/mit-license.php MIT license
 */
class Anqh_Controller_Blog extends Controller_Template {

	/**
	 * Action: add new blog entry
	 */
	public function action_add() {
		return $this->_edit_entry();
	}


	/**
	 * Action: comment
	 */
	public function action_comment() {
		$comment_id = (int)$this->request->param('id');
		$action     = $this->request->param('commentaction');

		// Load blog_comment
		$comment = Jelly::select('blog_comment')->load($comment_id);
		if (($action == 'delete' || $action == 'private') && Security::csrf_valid() && $comment->loaded()) {
			$entry = $comment->blog_entry;
			switch ($action) {

				// Delete comment
				case 'delete':
			    if (Permission::has($comment, Model_Blog_Comment::PERMISSION_DELETE, self::$user)) {
				    $comment->delete();
				    $entry->num_comments--;
				    $entry->save();
			    }
			    break;

				// Set comment as private
			  case 'private':
				  if (Permission::has($comment, Model_Blog_Comment::PERMISSION_UPDATE, self::$user)) {
					  $comment->private = true;
					  $comment->save();
				  }
			    break;

			}
			if (!$this->ajax) {
				$this->request->redirect(Route::model($entry));
			}
		}

		if (!$this->ajax) {
			Request::back('blogs');
		}
	}


	/**
	 * Action: edit blog entry
	 */
	public function action_edit() {
		return $this->_edit_entry((int)$this->request->param('id'));
	}


	/**
	 * Action: blog entry
	 */
	public function action_entry() {
		$entry_id = (int)$this->request->param('id');

		// Load blog entry
		$entry = Jelly::select('blog_entry')->load($entry_id);
		if (!$entry->loaded()) {
			throw new Model_Exception($entry, $entry_id);
		}
		Permission::required($entry, Model_Blog_Entry::PERMISSION_READ, self::$user);

		// Set title
		$this->page_title    = HTML::chars($entry->name);
		$this->page_subtitle = __('By :user :ago', array(
			':user'  => HTML::user($entry->author),
			':ago'   => HTML::time(Date::fuzzy_span($entry->created), $entry->created)
		));

		// Set actions
		if (Permission::has(new Model_Blog_Entry, Model_Blog_Entry::PERMISSION_UPDATE, self::$user)) {
			$this->page_actions[] = array('link' => Route::model($entry, 'edit'), 'text' => __('Edit blog entry'), 'class' => 'blog-edit');
		}

		Widget::add('main', View_Module::factory('blog/entry', array(
			'entry' => $entry
		)));

		// Comments section
		if (Permission::has($entry, Model_Blog_Entry::PERMISSION_COMMENTS, self::$user)) {
			$errors = array();
			$values = array();

			// Handle comment
			if (Permission::has($entry, Model_Blog_Entry::PERMISSION_COMMENT, self::$user) && $_POST) {
				$comment = Jelly::factory('blog_comment');
				$comment->blog_entry = $entry;
				$comment->user       = $entry->author;
				$comment->author     = self::$user;
				$comment->set(Arr::extract($_POST, Model_Blog_Comment::$editable_fields));
				try {
					$comment->save();
					$entry->num_comments++;
					$entry->new_comments++;
					$entry->save();

					// Newsfeed
					if (!$comment->private) {
						NewsfeedItem_Blog::comment(self::$user, $entry);
					}

					if (!$this->ajax) {
						$this->request->redirect(Route::model($entry));
					}
				} catch (Validate_Exception $e) {
					$errors = $e->array->errors('validation');
					$values = $comment;
				}

			}

			$comments = $entry->comments;
			$view = View_Module::factory('generic/comments', array(
				'delete'     => Route::get('blog_comment')->uri(array('id' => '%d', 'commentaction' => 'delete')) . '?token=' . Security::csrf(),
				'private'    => Route::get('blog_comment')->uri(array('id' => '%d', 'commentaction' => 'private')) . '?token=' . Security::csrf(),
				'comments'   => $comments,
				'errors'     => $errors,
				'values'     => $values,
				'pagination' => null,
				'user'       => self::$user,
			));

			if ($this->ajax) {
				echo $view;
				return;
			}
			Widget::add('main', $view);
		}

	}<commit_msg>Disable some features without proper fallback in old klubitus<commit_after><?php defined('SYSPATH') or die('No direct access allowed.');
/**
 * Anqh Blog controller
 *
 * @package    Blog
 * @author     <NAME>
 * @copyright  (c) 2010 <NAME>
 * @license    http://www.opensource.org/licenses/mit-license.php MIT license
 */
class Anqh_Controller_Blog extends Controller_Template {

	/**
	 * Action: add new blog entry
	 */
	public function action_add() {
		return $this->_edit_entry();
	}


	/**
	 * Action: comment
	 */
	public function action_comment() {
		$comment_id = (int)$this->request->param('id');
		$action     = $this->request->param('commentaction');

		// Load blog_comment
		$comment = Jelly::select('blog_comment')->load($comment_id);
		if (($action == 'delete' || $action == 'private') && Security::csrf_valid() && $comment->loaded()) {
			$entry = $comment->blog_entry;
			switch ($action) {

				// Delete comment
				case 'delete':
			    if (Permission::has($comment, Model_Blog_Comment::PERMISSION_DELETE, self::$user)) {
				    $comment->delete();
				    $entry->num_comments--;
				    $entry->save();
			    }
			    break;

				// Set comment as private
			  case 'private':
				  if (Permission::has($comment, Model_Blog_Comment::PERMISSION_UPDATE, self::$user)) {
					  $comment->private = true;
					  $comment->save();
				  }
			    break;

			}
			if (!$this->ajax) {
				$this->request->redirect(Route::model($entry));
			}
		}

		if (!$this->ajax) {
			Request::back('blogs');
		}
	}


	/**
	 * Action: edit blog entry
	 */
	public function action_edit() {
		return $this->_edit_entry((int)$this->request->param('id'));
	}


	/**
	 * Action: blog entry
	 */
	public function action_entry() {
		$entry_id = (int)$this->request->param('id');

		// Load blog entry
		$entry = Jelly::select('blog_entry')->load($entry_id);
		if (!$entry->loaded()) {
			throw new Model_Exception($entry, $entry_id);
		}
		Permission::required($entry, Model_Blog_Entry::PERMISSION_READ, self::$user);

		// Set title
		$this->page_title    = HTML::chars($entry->name);
		$this->page_subtitle = __('By :user :ago', array(
			':user'  => HTML::user($entry->author),
			':ago'   => HTML::time(Date::fuzzy_span($entry->created), $entry->created)
		));

		// Set actions
		if (Permission::has(new Model_Blog_Entry, Model_Blog_Entry::PERMISSION_UPDATE, self::$user)) {
			$this->page_actions[] = array('link' => Route::model($entry, 'edit'), 'text' => __('Edit blog entry'), 'class' => 'blog-edit');
		}

		Widget::add('main', View_Module::factory('blog/entry', array(
			'entry' => $entry
		)));

		// Comments section
		if (Permission::has($entry, Model_Blog_Entry::PERMISSION_COMMENTS, self::$user)) {
			$errors = array();
			$values = array();

			// Handle comment
			if (Permission::has($entry, Model_Blog_Entry::PERMISSION_COMMENT, self::$user) && $_POST) {
				$comment = Jelly::factory('blog_comment');
				$comment->blog_entry = $entry;
				$comment->user       = $entry->author;
				$comment->author     = self::$user;
				$comment->set(Arr::extract($_POST, Model_Blog_Comment::$editable_fields));
				try {
					$comment->save();
					$entry->num_comments++;
					$entry->new_comments++;
					$entry->save();

					// Newsfeed
					if (!$comment->private) {
						NewsfeedItem_Blog::comment(self::$user, $entry);
					}

					if (!$this->ajax) {
						$this->request->redirect(Route::model($entry));
					}
				} catch (Validate_Exception $e) {
					$errors = $e->array->errors('validation');
					$values = $comment;
				}

			}

			$comments = $entry->comments;
			$view = View_Module::factory('generic/comments', array(
				'delete'     => Route::get('blog_comment')->uri(array('id' => '%d', 'commentaction' => 'delete')) . '?token=' . Security::csrf(),
				'private'    => false, //Route::get('blog_comment')->uri(array('id' => '%d', 'commentaction' => 'private')) . '?token=' . Security::csrf(),
				'comments'   => $comments,
				'errors'     => $errors,
				'values'     => $values,
				'pagination' => null,
				'user'       => self::$user,
			));

			if ($this->ajax) {
				echo $view;
				return;
			}
			Widget::add('main', $view);
		}

	}
{'fraction_non_alphanumeric': 0.20270433417843775, 'fraction_numerical': 0.0009658336351563443, 'mean_word_length': 3.453763440860215, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 141, 'https://': 0, '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': '1188225', 'n_tokens_mistral': 3213, 'n_tokens_neox': 2683, 'n_words': 493}