add   A
last analyzed

Complexity

Total Complexity 8

Size/Duplication

Total Lines 104
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 43
c 1
b 0
f 0
dl 0
loc 104
ccs 37
cts 37
cp 1
rs 10
wmc 8

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 12 1
A execute() 0 20 5
A get_field_options() 0 12 2
1
<?php
2
/**
3
 *
4
 * @package sitemaker
5
 * @copyright (c) 2016 Daniel A. (blitze)
6
 * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
7
 *
8
 */
9
10
namespace blitze\content\services\actions\type;
11
12
use blitze\content\services\actions\action_interface;
13
14
class add implements action_interface
15
{
16
	/** @var \phpbb\auth\auth */
17
	protected $auth;
18
19
	/** @var \phpbb\controller\helper */
20
	protected $controller_helper;
21
22
	/** @var\phpbb\language\language */
23
	protected $language;
24
25
	/** @var \phpbb\template\template */
26
	protected $template;
27
28
	/** @var \phpbb\user */
29
	protected $user;
30
31
	/** @var \blitze\sitemaker\services\auto_lang */
0 ignored issues
show
Bug introduced by
The type blitze\sitemaker\services\auto_lang was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
32
	protected $auto_lang;
33
34
	/** @var \blitze\content\services\comments\factory */
35
	protected $comments_factory;
36
37
	/** @var \blitze\content\services\form\fields_factory */
38
	protected $fields_factory;
39
40
	/** @var \blitze\content\services\topic\blocks_factory */
41
	protected $topic_blocks_factory;
42
43
	/** @var \blitze\content\services\views\views_factory */
44
	protected $views_factory;
45
46
	/** @var int */
47
	protected $forum_id = 0;
48
49
	/**
50
	 * Constructor
51
	 *
52
	 * @param \phpbb\auth\auth									$auth					Auth object
53
	 * @param \phpbb\controller\helper							$controller_helper		Controller Helper object
54
	 * @param \phpbb\language\language							$language				Language Object
55
	 * @param \phpbb\template\template							$template				Template object
56
	 * @param \phpbb\user										$user					User object
57
	 * @param \blitze\sitemaker\services\auto_lang				$auto_lang				Auto add lang file
58
	 * @param \blitze\content\services\comments\factory			$comments_factory		Comments factory
59 3
	 * @param \blitze\content\services\form\fields_factory		$fields_factory			Fields factory  object
60
	 * @param \blitze\content\services\topic\blocks_factory		$topic_blocks_factory	Topic blocks factory object
61 3
	 * @param \blitze\content\services\views\views_factory		$views_factory			Views factory object
62 3
	*/
63 3
	public function __construct(\phpbb\auth\auth $auth, \phpbb\controller\helper $controller_helper, \phpbb\language\language $language, \phpbb\template\template $template, \phpbb\user $user, \blitze\sitemaker\services\auto_lang $auto_lang, \blitze\content\services\comments\factory $comments_factory, \blitze\content\services\form\fields_factory $fields_factory, \blitze\content\services\topic\blocks_factory $topic_blocks_factory, \blitze\content\services\views\views_factory $views_factory)
64 3
	{
65 3
		$this->auth = $auth;
66 3
		$this->controller_helper = $controller_helper;
67 3
		$this->language = $language;
68 3
		$this->template = $template;
69 3
		$this->user = $user;
70 3
		$this->auto_lang = $auto_lang;
71
		$this->comments_factory = $comments_factory;
72
		$this->fields_factory = $fields_factory;
73
		$this->topic_blocks_factory = $topic_blocks_factory;
74
		$this->views_factory = $views_factory;
75
	}
76
77
	/**
78
	 * @inheritdoc
79 2
	 */
80
	public function execute($u_action, $type = '')
81 2
	{
82
		$this->auto_lang->add('form_fields');
83 2
84
		$this->template->assign_vars(array(
85 2
			'CONTENT_VIEWS'		=> $this->views_factory->get_all_views(),
86 2
			'COMMENT_TYPES'		=> $this->comments_factory->get_all_types(),
87 2
			'COMMENTS'			=> 'blitze.content.comments',	// default comment system
88 2
			'POST_AUTHOR'		=> $this->user->data['username'],
89 2
			'POST_DATE'			=> $this->user->format_date(time()),
90 2
			'TOPIC_BLOCK_OPS'	=> $this->topic_blocks_factory->get_all(),
91 2
			'ITEMS_PER_PAGE'	=> 10,
92
93 2
			'U_ACTION'			=> $u_action . "&amp;do=save&amp;type=$type",
94 2
			'UA_AJAX_URL'		=> $this->controller_helper->route('blitze_content_field_settings', array(), false),
95
96 2
			'S_TYPE_OPS'				=> $this->get_field_options(),
97 2
			'S_FORUM_OPTIONS'			=> make_forum_select(false, $this->forum_id, true, false, false),
98 2
			'S_CAN_COPY_PERMISSIONS'	=> ($this->auth->acl_get('a_fauth') && $this->auth->acl_get('a_authusers') && $this->auth->acl_get('a_authgroups') && $this->auth->acl_get('a_mauth')) ? true : false,
99 2
			'S_EDIT'					=> true,
100 2
		));
101 2
	}
102
103
	/**
104
	 * @pram string
105
	 */
106 2
	protected function get_field_options()
107
	{
108 2
		$fields = $this->fields_factory->get_all();
109 2
		unset($fields['hidden']);
110
111 2
		$options = '';
112 2
		foreach ($fields as $field => $object)
113
		{
114 2
			$options .= '<option value="' . $field . '">' . $this->language->lang($object->get_langname()) . '</option>';
115 2
		}
116
117 2
		return $options;
118
	}
119
}
120