Completed
Push — develop ( 8d0058...8a4838 )
by Daniel
06:26
created
services/form/field/image.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
52 52
 		$value = $this->request->variable($data['field_name'], $data['field_value']);
53 53
 		$value = $this->get_image_src($value);
54 54
 
55
-		return ($value) ? '[img]' . $value . '[/img]' : '';
55
+		return ($value) ? '[img]'.$value.'[/img]' : '';
56 56
 	}
57 57
 
58 58
 	/**
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
 
78 78
 		$this->set_filemanager($data);
79 79
 		$this->ptemplate->assign_vars($data);
80
-		$field = $this->ptemplate->render_view('blitze/content', "fields/image.html", $field . '_field');
80
+		$field = $this->ptemplate->render_view('blitze/content', "fields/image.html", $field.'_field');
81 81
 
82 82
 		$data['field_value'] = $bbcode_value;
83 83
 
@@ -137,14 +137,14 @@  discard block
 block discarded – undo
137 137
 	 */
138 138
 	private function get_image_html($image, $mode, $title, array $field_props)
139 139
 	{
140
-		$image = $image ?: '<img src="' . $field_props['default'] . '" class="postimage" alt="' . $title . '" />';
140
+		$image = $image ?: '<img src="'.$field_props['default'].'" class="postimage" alt="'.$title.'" />';
141 141
 
142
-		$html = '<figure class="img-ui">' . $image . '</figure>';
142
+		$html = '<figure class="img-ui">'.$image.'</figure>';
143 143
 		if ($mode !== 'block')
144 144
 		{
145
-			$view_props = array_fill_keys(array($mode . '_size', $mode . '_align'), '');
145
+			$view_props = array_fill_keys(array($mode.'_size', $mode.'_align'), '');
146 146
 			$image_props = array_filter(array_intersect_key($field_props, $view_props));
147
-			$html = '<div class="' . join(' ', $image_props) . '">' . $html . '</div>';
147
+			$html = '<div class="'.join(' ', $image_props).'">'.$html.'</div>';
148 148
 		}
149 149
 		return $html;
150 150
 	}
@@ -159,7 +159,7 @@  discard block
 block discarded – undo
159 159
 		{
160 160
 			$data['filemanager_path'] = append_sid("{$this->phpbb_root_path}ResponsiveFilemanager/filemanager/dialog.$this->php_ext", array(
161 161
 				'type'			=> 1,
162
-				'field_id'		=> 'smc-' . $data['field_name'],
162
+				'field_id'		=> 'smc-'.$data['field_name'],
163 163
 				'akey'			=> $this->filemanager->get_access_key(),
164 164
 			));
165 165
 		}
Please login to merge, or discard this patch.
services/form/field/share.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -58,22 +58,22 @@
 block discarded – undo
58 58
 				'@blitze_content/assets/fields/display.min.js',
59 59
 			),
60 60
 			'css'	=> array(
61
-				'@blitze_content/assets/fields/share/' . $props['theme'] . '.min.css',
61
+				'@blitze_content/assets/fields/share/'.$props['theme'].'.min.css',
62 62
 			)
63 63
 		));
64 64
 
65 65
 		$classes = ['social-share', $props['corners'], $props['placement']];
66 66
 		$attributes = [
67
-			'class="' . join(' ', array_filter($classes)) . '"',
68
-			'data-show-label="' . $props['show_label'] . '"',
69
-			'data-show-count="' . $props['show_count'] . '"',
70
-			'data-share-in="' . $props['sharein'] . '"',
71
-			'data-shares="' . join(',', $props['defaults']) . '"',
72
-			'data-url="' . $topic_data['PERMA_LINK'] . '"',
73
-			'style="font-size: ' . $props['size'] . 'px"',
67
+			'class="'.join(' ', array_filter($classes)).'"',
68
+			'data-show-label="'.$props['show_label'].'"',
69
+			'data-show-count="'.$props['show_count'].'"',
70
+			'data-share-in="'.$props['sharein'].'"',
71
+			'data-shares="'.join(',', $props['defaults']).'"',
72
+			'data-url="'.$topic_data['PERMA_LINK'].'"',
73
+			'style="font-size: '.$props['size'].'px"',
74 74
 		];
75 75
 
76
-		return '<div ' . join(' ', $attributes) . '></div>';
76
+		return '<div '.join(' ', $attributes).'></div>';
77 77
 	}
78 78
 
79 79
 	/**
Please login to merge, or discard this patch.
services/form/field/telephone.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -36,7 +36,7 @@
 block discarded – undo
36 36
 	 */
37 37
 	public function display_field(array $data, array $topic_data, $view_mode)
38 38
 	{
39
-		return $data['field_value'] ? '<a href="tel:' . $data['field_value'] . '">' . preg_replace("/^1?(\d{3})(\d{3})(\d{4})$/", "$1-$2-$3", $data['field_value']) . '</a>' : '';
39
+		return $data['field_value'] ? '<a href="tel:'.$data['field_value'].'">'.preg_replace("/^1?(\d{3})(\d{3})(\d{4})$/", "$1-$2-$3", $data['field_value']).'</a>' : '';
40 40
 	}
41 41
 
42 42
 	/**
Please login to merge, or discard this patch.
blocks/swiper.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -56,7 +56,7 @@
 block discarded – undo
56 56
 				'pagination'		=> array('lang' => 'SWIPER_PAGINATION', 'validate' => 'string', 'type' => 'select', 'options' => $pagination_options, 'default' => 1),
57 57
 				'effect'			=> array('lang' => 'SWIPER_EFFECT', 'validate' => 'string', 'type' => 'select', 'options' => $effect_options, 'default' => 'slide'),
58 58
 				'parallax'			=> array('lang' => 'SWIPER_PARALLAX_IMAGE_URL', 'validate' => 'string', 'type' => 'text', 'default' => ''),
59
-				'direction'			=> array('lang' => 'SWIPER_DIRECTION', 'validate' => 'string', 'type' => 'select:1:0:direction', 'options' => $direction_options, 'default' => 'horizontal', 'append' => '<div id="direction-vertical" class="error small">' . $this->language->lang('SWIPER_HEIGHT_REQUIRED') . '</div>'),
59
+				'direction'			=> array('lang' => 'SWIPER_DIRECTION', 'validate' => 'string', 'type' => 'select:1:0:direction', 'options' => $direction_options, 'default' => 'horizontal', 'append' => '<div id="direction-vertical" class="error small">'.$this->language->lang('SWIPER_HEIGHT_REQUIRED').'</div>'),
60 60
 				'height'			=> array('lang' => 'SWIPER_HEIGHT', 'validate' => 'int:0', 'type' => 'number:0', 'default' => 0, 'append' => 'PIXEL'),
61 61
 				'thumbs'			=> array('lang' => 'SWIPER_THUMBNAILS', 'validate' => 'bool', 'type' => 'radio:yes_no', 'default' => 0),
62 62
 				'loop'				=> array('lang' => 'SWIPER_LOOP', 'validate' => 'bool', 'type' => 'radio:yes_no', 'default' => 1),
Please login to merge, or discard this patch.
blocks/recent.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -171,17 +171,17 @@  discard block
 block discarded – undo
171 171
 			$topic_tracking_info = $this->forum->get_topic_tracking_info($forum_id);
172 172
 			$block_fields = $this->get_block_fields($entity->get_field_types());
173 173
 
174
-			$this->fields->prepare_to_show($entity, array_keys($topics_data), $block_fields, $this->settings['block_tpl'], 'block', $block_id . '_block');
174
+			$this->fields->prepare_to_show($entity, array_keys($topics_data), $block_fields, $this->settings['block_tpl'], 'block', $block_id.'_block');
175 175
 
176 176
 			$update_count = array();
177 177
 			foreach ($topics_data as $topic_id => $topic_data)
178 178
 			{
179
-				$post_data	= array_shift($posts_data[$topic_id]);
179
+				$post_data = array_shift($posts_data[$topic_id]);
180 180
 				$this->ptemplate->assign_block_vars('topicrow', $this->fields->show($type, $topic_data, $post_data, $users_cache, $attachments, $update_count, $topic_tracking_info));
181 181
 			}
182 182
 			unset($topics_data, $posts_data, $users_cache, $attachments, $topic_tracking_info);
183 183
 
184
-			$content = $this->ptemplate->render_view('blitze/content', "blocks/{$this->tpl_name}.html", $this->tpl_name . '_block');
184
+			$content = $this->ptemplate->render_view('blitze/content', "blocks/{$this->tpl_name}.html", $this->tpl_name.'_block');
185 185
 		}
186 186
 
187 187
 		return array(
@@ -202,7 +202,7 @@  discard block
 block discarded – undo
202 202
 			POST_STICKY		=> 'CONTENT_STICKY_POSTS',
203 203
 		);
204 204
 
205
-		return $this->language->lang((isset($topic_types[$this->settings['topic_type']])) ? $topic_types[$this->settings['topic_type']] : 'CONTENT_' . $this->sort_options[$this->settings['sort_key']], $content_langname);
205
+		return $this->language->lang((isset($topic_types[$this->settings['topic_type']])) ? $topic_types[$this->settings['topic_type']] : 'CONTENT_'.$this->sort_options[$this->settings['sort_key']], $content_langname);
206 206
 	}
207 207
 
208 208
 	/**
@@ -269,7 +269,7 @@  discard block
 block discarded – undo
269 269
 		foreach ($content_types as $value => $title)
270 270
 		{
271 271
 			$selected = ($type == $value) ? ' selected="selected"' : '';
272
-			$html .= '<option value="' . $value . '"' . $selected . ' data-toggle-setting="#fields-col-' . $value . '">' . $title . '</option>';
272
+			$html .= '<option value="'.$value.'"'.$selected.' data-toggle-setting="#fields-col-'.$value.'">'.$title.'</option>';
273 273
 		}
274 274
 
275 275
 		return $html;
Please login to merge, or discard this patch.
event/listener.php 2 patches
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -33,7 +33,7 @@  discard block
 block discarded – undo
33 33
 	 * @param \phpbb\language\language				$language			Language object
34 34
 	 * @param \blitze\content\services\types		$content_types		Content types object
35 35
 	 * @param string								$php_ext			php file extension
36
-	*/
36
+	 */
37 37
 	public function __construct(\phpbb\controller\helper $helper, \phpbb\language\language $language, \blitze\content\services\types $content_types, $php_ext)
38 38
 	{
39 39
 		$this->helper = $helper;
@@ -130,8 +130,8 @@  discard block
 block discarded – undo
130 130
 
131 131
 		foreach ($list as $type => $entity)
132 132
 		{
133
-            /** @var \blitze\content\model\entity\type $entity */
134
-            $text .= "\t" . $entity->get_content_langname() . '|';
133
+			/** @var \blitze\content\model\entity\type $entity */
134
+			$text .= "\t" . $entity->get_content_langname() . '|';
135 135
 			$text .= $this->helper->route('blitze_content_type', array('type' => $type), false, '', UrlGeneratorInterface::RELATIVE_PATH) . "\n";
136 136
 		}
137 137
 
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
 	 */
87 87
 	public function add_viewonline_location(\phpbb\event\data $event)
88 88
 	{
89
-		if ($event['on_page'][1] == 'app' && strrpos($event['row']['session_page'], 'app.' . $this->php_ext . '/content/') === 0)
89
+		if ($event['on_page'][1] == 'app' && strrpos($event['row']['session_page'], 'app.'.$this->php_ext.'/content/') === 0)
90 90
 		{
91 91
 			$types = join('|', $this->content_types->get_forum_types());
92 92
 			preg_match("/\/content\/($types)(\/[0-9]\/.*)?/is", $event['row']['session_page'], $match);
@@ -126,13 +126,13 @@  discard block
 block discarded – undo
126 126
 	{
127 127
 		$list = $this->content_types->get_all_types();
128 128
 
129
-		$text = $this->language->lang('CONTENT_TYPES') . '|' . $this->helper->route('blitze_content_types', array(), false, '', UrlGeneratorInterface::RELATIVE_PATH) . "\n";
129
+		$text = $this->language->lang('CONTENT_TYPES').'|'.$this->helper->route('blitze_content_types', array(), false, '', UrlGeneratorInterface::RELATIVE_PATH)."\n";
130 130
 
131 131
 		foreach ($list as $type => $entity)
132 132
 		{
133 133
             /** @var \blitze\content\model\entity\type $entity */
134
-            $text .= "\t" . $entity->get_content_langname() . '|';
135
-			$text .= $this->helper->route('blitze_content_type', array('type' => $type), false, '', UrlGeneratorInterface::RELATIVE_PATH) . "\n";
134
+            $text .= "\t".$entity->get_content_langname().'|';
135
+			$text .= $this->helper->route('blitze_content_type', array('type' => $type), false, '', UrlGeneratorInterface::RELATIVE_PATH)."\n";
136 136
 		}
137 137
 
138 138
 		return trim($text);
Please login to merge, or discard this patch.
services/views/driver/views_interface.php 1 patch
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -48,10 +48,10 @@  discard block
 block discarded – undo
48 48
 	 * @param \blitze\content\model\entity\type $entity
49 49
 	 * @param int $page
50 50
 	 * @param array $filters
51
-     * @param array $topic_data_overwrite
51
+	 * @param array $topic_data_overwrite
52 52
 	 * @return int
53 53
 	 */
54
-    public function render_index(\blitze\content\model\entity\type $entity, $page, array $filters, array $topic_data_overwrite = array());
54
+	public function render_index(\blitze\content\model\entity\type $entity, $page, array $filters, array $topic_data_overwrite = array());
55 55
 
56 56
 	/**
57 57
 	 * Show topic details
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
 	 * @param \blitze\content\model\entity\type $entity
60 60
 	 * @param int $topic_id
61 61
 	 * @param array $update_count
62
-     * @param array $topic_data_overwrite
62
+	 * @param array $topic_data_overwrite
63 63
 	 * @return array
64 64
 	 */
65 65
 	public function render_detail(\blitze\content\model\entity\type $entity, $topic_id, array &$update_count, array $topic_data_overwrite = array());
Please login to merge, or discard this patch.
services/views/driver/base_view.php 2 patches
Indentation   +384 added lines, -384 removed lines patch added patch discarded remove patch
@@ -11,388 +11,388 @@
 block discarded – undo
11 11
 
12 12
 abstract class base_view implements views_interface
13 13
 {
14
-    /** @var \phpbb\event\dispatcher_interface */
15
-    protected $phpbb_dispatcher;
16
-
17
-    /** @var\phpbb\language\language */
18
-    protected $language;
19
-
20
-    /** @var \phpbb\pagination */
21
-    protected $pagination;
22
-
23
-    /** @var \phpbb\template\template */
24
-    protected $template;
25
-
26
-    /* @var \blitze\content\services\fields */
27
-    protected $fields;
28
-
29
-    /** @var \blitze\sitemaker\services\forum\data */
30
-    protected $forum;
31
-
32
-    /* @var \blitze\content\services\helper */
33
-    protected $helper;
34
-
35
-    /* @var \blitze\content\services\quickmod */
36
-    protected $quickmod;
37
-
38
-    /** @var \blitze\content\services\topic\blocks_factory */
39
-    protected $topic_blocks_factory;
40
-
41
-    /**
42
-     * Constructor
43
-     *
44
-     * @param \phpbb\event\dispatcher_interface					$phpbb_dispatcher		Event dispatcher object
45
-     * @param \phpbb\language\language							$language				Language Object
46
-     * @param \phpbb\pagination									$pagination				Pagination object
47
-     * @param \phpbb\template\template							$template				Template object
48
-     * @param \blitze\content\services\fields					$fields					Content fields object
49
-     * @param \blitze\sitemaker\services\forum\data				$forum					Forum Data object
50
-     * @param \blitze\content\services\helper					$helper					Content helper object
51
-     * @param \blitze\content\services\quickmod					$quickmod				Quick moderator tools
52
-     * @param \blitze\content\services\topic\blocks_factory		$topic_blocks_factory	Topic blocks factory object
53
-     */
54
-    public function __construct(\phpbb\event\dispatcher_interface $phpbb_dispatcher, \phpbb\language\language $language, \phpbb\pagination $pagination, \phpbb\template\template $template, \blitze\content\services\fields $fields, \blitze\sitemaker\services\forum\data $forum, \blitze\content\services\helper $helper, \blitze\content\services\quickmod $quickmod, \blitze\content\services\topic\blocks_factory $topic_blocks_factory)
55
-    {
56
-        $this->phpbb_dispatcher = $phpbb_dispatcher;
57
-        $this->language = $language;
58
-        $this->pagination = $pagination;
59
-        $this->template = $template;
60
-        $this->fields = $fields;
61
-        $this->forum = $forum;
62
-        $this->helper = $helper;
63
-        $this->quickmod = $quickmod;
64
-        $this->topic_blocks_factory = $topic_blocks_factory;
65
-    }
66
-
67
-    /**
68
-     * {@inheritdoc}
69
-     */
70
-    public function get_detail_template()
71
-    {
72
-        return 'views/content_detail.html';
73
-    }
74
-
75
-    /**
76
-     * {@inheritdoc}
77
-     */
78
-    public function build_index_query(array $filters, \blitze\content\model\entity\type $entity = null)
79
-    {
80
-        $forum_id = $entity ? $entity->get_forum_id() : 0;
81
-        $sql_array = $this->get_filter_sql($filters, $forum_id);
82
-
83
-        $this->forum->query()
84
-            ->fetch_forum($forum_id)
85
-            ->fetch_custom($sql_array)
86
-            ->set_sorting('t.topic_time')
87
-            ->build(true, false, false);
88
-    }
89
-
90
-    /**
91
-     * {@inheritdoc}
92
-     */
93
-    public function render_index(\blitze\content\model\entity\type $entity, $page, array $filters, array $topic_data_overwrite = array())
94
-    {
95
-        $content_type = $entity->get_content_name();
96
-        $items_per_page = $entity->get_items_per_page();
97
-        $start = ($page - 1) * $items_per_page;
98
-
99
-        $this->build_index_query($filters, $entity);
100
-        $this->set_mcp_url($entity->get_forum_id());
101
-
102
-        if ($entity->get_show_pagination())
103
-        {
104
-            $filter_type = key($filters);
105
-            $filter_value = (array) current($filter_value);
106
-
107
-            $total_topics = $this->forum->get_topics_count();
108
-            $this->generate_pagination('summary', $total_topics, $start, $items_per_page, array(
109
-                'type'			=> $content_type,
110
-                'filter_type'	=> $filter_type,
111
-                'filter_value'	=> current($filter_value),
112
-            ));
113
-        }
114
-
115
-        return $this->display_topics($entity, $items_per_page, $start, $topic_data_overwrite);
116
-    }
117
-
118
-    /**
119
-     * @param \blitze\content\model\entity\type $entity
120
-     * @param int $items_per_page
121
-     * @param int $start
122
-     * @param array $topic_data_overwrite
123
-     * @return int
124
-     */
125
-    protected function display_topics(\blitze\content\model\entity\type $entity, $items_per_page = 1, $start = 0, array $topic_data_overwrite = array())
126
-    {
127
-        $content_type = $entity->get_content_name();
128
-        $topics_data = $this->forum->get_topic_data($items_per_page, $start);
129
-        $posts_data = $this->forum->get_post_data('first');
130
-        $topic_tracking_info = $this->forum->get_topic_tracking_info($entity->get_forum_id());
131
-        $users_cache = $this->forum->get_posters_info();
132
-        $attachments = $this->forum->get_attachments($entity->get_forum_id());
133
-
134
-        $this->fields->prepare_to_show($entity, array_keys($topics_data), $entity->get_summary_fields(), $entity->get_summary_tpl(), 'summary');
135
-
136
-        $update_count = array();
137
-        $max_update_time = 0;
138
-
139
-        foreach ($posts_data as $topic_id => $posts)
140
-        {
141
-            $post_data	= array_shift($posts);
142
-            $topic_data	= $topics_data[$topic_id];
143
-            $topic_data = array_merge(
144
-                $this->fields->show($content_type, $topic_data, $post_data, $users_cache, $attachments, $update_count, $topic_tracking_info),
145
-                $topic_data_overwrite
146
-            );
147
-
148
-            $this->template->assign_block_vars('topicrow', $topic_data);
149
-            $max_update_time = max($max_update_time, $topic_data['UPDATED']);
150
-        }
151
-        unset($topics_data, $posts_data, $users_cache, $attachments, $topic_tracking_info);
152
-
153
-        return $max_update_time;
154
-    }
155
-
156
-    /**
157
-     * {@inheritdoc}
158
-     */
159
-    public function render_detail(\blitze\content\model\entity\type $entity, $topic_id, array &$update_count, array $topic_data_overwrite = array())
160
-    {
161
-        $this->language->add_lang('viewtopic');
162
-        $this->language->add_lang('content', 'blitze/content');
163
-        $this->set_mcp_url($entity->get_forum_id(), $topic_id);
164
-
165
-        $this->forum->query()
166
-            ->fetch_topic($topic_id)
167
-            ->fetch_watch_status()
168
-            ->fetch_bookmark_status()
169
-            ->build(true, true, false);
170
-
171
-        return $this->display_topic($topic_id, $entity, $update_count, $topic_data_overwrite);
172
-    }
173
-
174
-    /**
175
-     * @param int $topic_id
176
-     * @param \blitze\content\model\entity\type $entity
177
-     * @param array $update_count
178
-     * @param array $topic_data_overwrite
179
-     * @return array
180
-     * @throws \Exception
181
-     */
182
-    protected function display_topic($topic_id, \blitze\content\model\entity\type $entity, array &$update_count, array $topic_data_overwrite)
183
-    {
184
-        $forum_id = $entity->get_forum_id();
185
-        $content_type = $entity->get_content_name();
186
-
187
-        $topics_data = $this->forum->get_topic_data();
188
-        $post_data = $this->forum->get_post_data('first');
189
-        $topic_tracking_info = $this->forum->get_topic_tracking_info($forum_id);
190
-        $users_cache = $this->forum->get_posters_info();
191
-        $attachments = $this->forum->get_attachments($forum_id);
192
-
193
-        if (!sizeof($post_data))
194
-        {
195
-            throw new \Exception($this->language->lang('CONTENT_NO_EXIST'));
196
-        }
197
-
198
-        $this->fields->prepare_to_show($entity, array_keys($topics_data), $entity->get_detail_fields(), $entity->get_detail_tpl(), 'detail');
199
-
200
-        $topic_data = array_shift($topics_data);
201
-        $post_data = array_shift($post_data[$topic_id]);
202
-        $tpl_data = array_merge($topic_data,
203
-            $this->fields->show($content_type, $topic_data, $post_data, $users_cache, $attachments, $update_count, $topic_tracking_info, $topic_data_overwrite),
204
-            $this->fields->get_topic_tools_data($topic_data)
205
-        );
206
-
207
-        $this->template->assign_vars(array_change_key_case($tpl_data, CASE_UPPER));
208
-        $this->fields->show_attachments($attachments, $post_data['post_id']);
209
-        $this->show_topic_blocks($entity, $topic_data, $post_data, array_shift($users_cache));
210
-        $this->quickmod->show_tools($topic_data);
211
-        $this->set_meta_tags($entity->get_detail_fields(), $tpl_data);
212
-
213
-        return array_merge($topic_data, array(
214
-            'topic_title'		=> $tpl_data['TOPIC_TITLE'],
215
-            'total_comments'	=> $tpl_data['TOPIC_COMMENTS'],
216
-            'topic_url'			=> $tpl_data['TOPIC_URL'],
217
-        ));
218
-    }
219
-
220
-    /**
221
-     * @param array $attachments
222
-     * @param int $post_id
223
-     * @return void
224
-     */
225
-    protected function show_attachments(array $attachments, $post_id)
226
-    {
227
-        if (!empty($attachments[$post_id]))
228
-        {
229
-            foreach ($attachments[$post_id] as $attachment)
230
-            {
231
-                $this->template->assign_block_vars('attachment', array(
232
-                        'DISPLAY_ATTACHMENT'	=> $attachment)
233
-                );
234
-            }
235
-        }
236
-    }
237
-
238
-    /**
239
-     * @param string $view_mode
240
-     * @param int $total_topics
241
-     * @param int $start
242
-     * @param int $items_per_page
243
-     * @param array $params
244
-     */
245
-    protected function generate_pagination($view_mode, $total_topics, &$start, $items_per_page, array $params)
246
-    {
247
-        $params = array_filter($params);
248
-        $route_type = $this->get_route_type($view_mode, $params);
249
-        $start = $this->pagination->validate_start($start, $items_per_page, $total_topics);
250
-        $this->pagination->generate_template_pagination(
251
-            array(
252
-                'routes' => array(
253
-                    'blitze_content_' . $route_type,
254
-                    'blitze_content_' . $route_type . '_page',
255
-                ),
256
-                'params' => $params,
257
-            ),
258
-            'pagination', 'page', $total_topics, $items_per_page, $start
259
-        );
260
-    }
261
-
262
-    /**
263
-     * @param string $view_mode
264
-     * @param array $params
265
-     * @return string
266
-     */
267
-    protected function get_route_type($view_mode, array $params)
268
-    {
269
-        $types = array(
270
-            'show'		=> 'show',
271
-            'summary'	=> join('_', array_filter(array(
272
-                (!empty($params['type'])) ? 'type' : '',
273
-                (!empty($params['filters'])) ? 'multi' : '',
274
-                (!empty($params['filter_type'])) ? 'filter' : '',
275
-            ))),
276
-        );
277
-
278
-        return $types[$view_mode];
279
-    }
280
-
281
-    /**
282
-     * {@inheritdoc}
283
-     */
284
-    protected function get_filter_sql(array $filters, $forum_id)
285
-    {
286
-        $sql_array = array();
287
-
288
-        /**
289
-         * Event to filter topics by field value e.g category/food
290
-         *
291
-         * @event blitze.content.view.filter
292
-         * @var mixed								forum_id		Forum id, if available
293
-         * @var array								filters			Filters
294
-         * @var array								sql_array		Array to modify sql query to get topics
295
-         */
296
-        $vars = array('forum_id', 'filters', 'sql_array');
297
-        extract($this->phpbb_dispatcher->trigger_event('blitze.content.view.filter', compact($vars)));
298
-
299
-        return $sql_array;
300
-    }
301
-
302
-    /**
303
-     * @param \blitze\content\model\entity\type $entity
304
-     * @param array $topic_data
305
-     * @param array $post_data
306
-     * @param array $user_cache
307
-     * @return void
308
-     */
309
-    protected function show_topic_blocks(\blitze\content\model\entity\type $entity, array $topic_data, array $post_data, array $user_cache)
310
-    {
311
-        $topic_blocks = $entity->get_topic_blocks();
312
-        foreach ($topic_blocks as $service_name)
313
-        {
314
-            /** @var \blitze\content\services\topic\driver\block_interface $block */
315
-            if ($block = $this->topic_blocks_factory->get($service_name))
316
-            {
317
-                $block->show_block($entity, $topic_data, $post_data, $user_cache);
318
-            }
319
-        }
320
-    }
321
-
322
-    /**
323
-     * @param int $forum_id
324
-     * @param int $topic_id
325
-     * @return void
326
-     */
327
-    protected function set_mcp_url($forum_id, $topic_id = 0)
328
-    {
329
-        $this->template->assign_var('U_MCP', $this->helper->get_mcp_url($forum_id, $topic_id));
330
-    }
331
-
332
-    /**
333
-     * @param array $field_types
334
-     * @param array $topic_data
335
-     * @return void
336
-     */
337
-    protected function set_meta_tags(array $field_types, array $topic_data)
338
-    {
339
-        $image_url = $this->get_topic_image_url($field_types, $topic_data['FIELDS']['all']);
340
-        $description = $this->get_topic_description($field_types, $topic_data['FIELDS']['all']);
341
-
342
-        $meta = "<meta name=\"description\" content=\"$description\" />\n";
343
-        $meta .= "<meta name=\"twitter:card\" value=\"summary\">\n";
344
-        $meta .= "<meta property=\"og:title\" content=\"{$topic_data['TOPIC_TITLE']}\" />\n";
345
-        $meta .= "<meta property=\"og:type\" content=\"article\" />\n";
346
-        $meta .= "<meta property=\"og:url\" content=\"{$topic_data['PERMA_LINK']}\" />\n";
347
-        $meta .= "<meta property=\"og:image\" content=\"$image_url\" />\n";
348
-        $meta .= "<meta property=\"og:description\" content=\"$description\" />";
349
-
350
-        $this->template->assign_var('META', $meta);
351
-    }
352
-
353
-    /**
354
-     * @param array $field_types
355
-     * @param array $fields_data
356
-     * @return string
357
-     */
358
-    protected function get_topic_image_url(array $field_types, array $fields_data)
359
-    {
360
-        $image_url = '';
361
-
362
-        $image_field = $this->get_field_name($field_types, 'image');
363
-        if (null !== ($figure = $fields_data[$image_field]) && preg_match('/src="(.*?)"/i', $figure, $matches))
364
-        {
365
-            $image_url = $matches[1];
366
-        }
367
-
368
-        return $image_url;
369
-    }
370
-
371
-    /**
372
-     * @param array $field_types
373
-     * @param array $fields_data
374
-     * @return string
375
-     */
376
-    protected function get_topic_description(array $field_types, array $fields_data)
377
-    {
378
-        $desc_field = $this->get_field_name($field_types, 'textarea');
379
-
380
-        if (null !== ($description = $fields_data[$desc_field]))
381
-        {
382
-            $description = implode(' ', array_slice(explode(' ', strip_tags($description)), 1, 20));
383
-        }
384
-
385
-        return $description;
386
-    }
387
-
388
-    /**
389
-     * @param array $field_types
390
-     * @param string $search_field
391
-     * @return string
392
-     */
393
-    protected function get_field_name(array $field_types, $search_field)
394
-    {
395
-        $results = array_keys($field_types, $search_field);
396
-        return array_shift($results);
397
-    }
14
+	/** @var \phpbb\event\dispatcher_interface */
15
+	protected $phpbb_dispatcher;
16
+
17
+	/** @var\phpbb\language\language */
18
+	protected $language;
19
+
20
+	/** @var \phpbb\pagination */
21
+	protected $pagination;
22
+
23
+	/** @var \phpbb\template\template */
24
+	protected $template;
25
+
26
+	/* @var \blitze\content\services\fields */
27
+	protected $fields;
28
+
29
+	/** @var \blitze\sitemaker\services\forum\data */
30
+	protected $forum;
31
+
32
+	/* @var \blitze\content\services\helper */
33
+	protected $helper;
34
+
35
+	/* @var \blitze\content\services\quickmod */
36
+	protected $quickmod;
37
+
38
+	/** @var \blitze\content\services\topic\blocks_factory */
39
+	protected $topic_blocks_factory;
40
+
41
+	/**
42
+	 * Constructor
43
+	 *
44
+	 * @param \phpbb\event\dispatcher_interface					$phpbb_dispatcher		Event dispatcher object
45
+	 * @param \phpbb\language\language							$language				Language Object
46
+	 * @param \phpbb\pagination									$pagination				Pagination object
47
+	 * @param \phpbb\template\template							$template				Template object
48
+	 * @param \blitze\content\services\fields					$fields					Content fields object
49
+	 * @param \blitze\sitemaker\services\forum\data				$forum					Forum Data object
50
+	 * @param \blitze\content\services\helper					$helper					Content helper object
51
+	 * @param \blitze\content\services\quickmod					$quickmod				Quick moderator tools
52
+	 * @param \blitze\content\services\topic\blocks_factory		$topic_blocks_factory	Topic blocks factory object
53
+	 */
54
+	public function __construct(\phpbb\event\dispatcher_interface $phpbb_dispatcher, \phpbb\language\language $language, \phpbb\pagination $pagination, \phpbb\template\template $template, \blitze\content\services\fields $fields, \blitze\sitemaker\services\forum\data $forum, \blitze\content\services\helper $helper, \blitze\content\services\quickmod $quickmod, \blitze\content\services\topic\blocks_factory $topic_blocks_factory)
55
+	{
56
+		$this->phpbb_dispatcher = $phpbb_dispatcher;
57
+		$this->language = $language;
58
+		$this->pagination = $pagination;
59
+		$this->template = $template;
60
+		$this->fields = $fields;
61
+		$this->forum = $forum;
62
+		$this->helper = $helper;
63
+		$this->quickmod = $quickmod;
64
+		$this->topic_blocks_factory = $topic_blocks_factory;
65
+	}
66
+
67
+	/**
68
+	 * {@inheritdoc}
69
+	 */
70
+	public function get_detail_template()
71
+	{
72
+		return 'views/content_detail.html';
73
+	}
74
+
75
+	/**
76
+	 * {@inheritdoc}
77
+	 */
78
+	public function build_index_query(array $filters, \blitze\content\model\entity\type $entity = null)
79
+	{
80
+		$forum_id = $entity ? $entity->get_forum_id() : 0;
81
+		$sql_array = $this->get_filter_sql($filters, $forum_id);
82
+
83
+		$this->forum->query()
84
+			->fetch_forum($forum_id)
85
+			->fetch_custom($sql_array)
86
+			->set_sorting('t.topic_time')
87
+			->build(true, false, false);
88
+	}
89
+
90
+	/**
91
+	 * {@inheritdoc}
92
+	 */
93
+	public function render_index(\blitze\content\model\entity\type $entity, $page, array $filters, array $topic_data_overwrite = array())
94
+	{
95
+		$content_type = $entity->get_content_name();
96
+		$items_per_page = $entity->get_items_per_page();
97
+		$start = ($page - 1) * $items_per_page;
98
+
99
+		$this->build_index_query($filters, $entity);
100
+		$this->set_mcp_url($entity->get_forum_id());
101
+
102
+		if ($entity->get_show_pagination())
103
+		{
104
+			$filter_type = key($filters);
105
+			$filter_value = (array) current($filter_value);
106
+
107
+			$total_topics = $this->forum->get_topics_count();
108
+			$this->generate_pagination('summary', $total_topics, $start, $items_per_page, array(
109
+				'type'			=> $content_type,
110
+				'filter_type'	=> $filter_type,
111
+				'filter_value'	=> current($filter_value),
112
+			));
113
+		}
114
+
115
+		return $this->display_topics($entity, $items_per_page, $start, $topic_data_overwrite);
116
+	}
117
+
118
+	/**
119
+	 * @param \blitze\content\model\entity\type $entity
120
+	 * @param int $items_per_page
121
+	 * @param int $start
122
+	 * @param array $topic_data_overwrite
123
+	 * @return int
124
+	 */
125
+	protected function display_topics(\blitze\content\model\entity\type $entity, $items_per_page = 1, $start = 0, array $topic_data_overwrite = array())
126
+	{
127
+		$content_type = $entity->get_content_name();
128
+		$topics_data = $this->forum->get_topic_data($items_per_page, $start);
129
+		$posts_data = $this->forum->get_post_data('first');
130
+		$topic_tracking_info = $this->forum->get_topic_tracking_info($entity->get_forum_id());
131
+		$users_cache = $this->forum->get_posters_info();
132
+		$attachments = $this->forum->get_attachments($entity->get_forum_id());
133
+
134
+		$this->fields->prepare_to_show($entity, array_keys($topics_data), $entity->get_summary_fields(), $entity->get_summary_tpl(), 'summary');
135
+
136
+		$update_count = array();
137
+		$max_update_time = 0;
138
+
139
+		foreach ($posts_data as $topic_id => $posts)
140
+		{
141
+			$post_data	= array_shift($posts);
142
+			$topic_data	= $topics_data[$topic_id];
143
+			$topic_data = array_merge(
144
+				$this->fields->show($content_type, $topic_data, $post_data, $users_cache, $attachments, $update_count, $topic_tracking_info),
145
+				$topic_data_overwrite
146
+			);
147
+
148
+			$this->template->assign_block_vars('topicrow', $topic_data);
149
+			$max_update_time = max($max_update_time, $topic_data['UPDATED']);
150
+		}
151
+		unset($topics_data, $posts_data, $users_cache, $attachments, $topic_tracking_info);
152
+
153
+		return $max_update_time;
154
+	}
155
+
156
+	/**
157
+	 * {@inheritdoc}
158
+	 */
159
+	public function render_detail(\blitze\content\model\entity\type $entity, $topic_id, array &$update_count, array $topic_data_overwrite = array())
160
+	{
161
+		$this->language->add_lang('viewtopic');
162
+		$this->language->add_lang('content', 'blitze/content');
163
+		$this->set_mcp_url($entity->get_forum_id(), $topic_id);
164
+
165
+		$this->forum->query()
166
+			->fetch_topic($topic_id)
167
+			->fetch_watch_status()
168
+			->fetch_bookmark_status()
169
+			->build(true, true, false);
170
+
171
+		return $this->display_topic($topic_id, $entity, $update_count, $topic_data_overwrite);
172
+	}
173
+
174
+	/**
175
+	 * @param int $topic_id
176
+	 * @param \blitze\content\model\entity\type $entity
177
+	 * @param array $update_count
178
+	 * @param array $topic_data_overwrite
179
+	 * @return array
180
+	 * @throws \Exception
181
+	 */
182
+	protected function display_topic($topic_id, \blitze\content\model\entity\type $entity, array &$update_count, array $topic_data_overwrite)
183
+	{
184
+		$forum_id = $entity->get_forum_id();
185
+		$content_type = $entity->get_content_name();
186
+
187
+		$topics_data = $this->forum->get_topic_data();
188
+		$post_data = $this->forum->get_post_data('first');
189
+		$topic_tracking_info = $this->forum->get_topic_tracking_info($forum_id);
190
+		$users_cache = $this->forum->get_posters_info();
191
+		$attachments = $this->forum->get_attachments($forum_id);
192
+
193
+		if (!sizeof($post_data))
194
+		{
195
+			throw new \Exception($this->language->lang('CONTENT_NO_EXIST'));
196
+		}
197
+
198
+		$this->fields->prepare_to_show($entity, array_keys($topics_data), $entity->get_detail_fields(), $entity->get_detail_tpl(), 'detail');
199
+
200
+		$topic_data = array_shift($topics_data);
201
+		$post_data = array_shift($post_data[$topic_id]);
202
+		$tpl_data = array_merge($topic_data,
203
+			$this->fields->show($content_type, $topic_data, $post_data, $users_cache, $attachments, $update_count, $topic_tracking_info, $topic_data_overwrite),
204
+			$this->fields->get_topic_tools_data($topic_data)
205
+		);
206
+
207
+		$this->template->assign_vars(array_change_key_case($tpl_data, CASE_UPPER));
208
+		$this->fields->show_attachments($attachments, $post_data['post_id']);
209
+		$this->show_topic_blocks($entity, $topic_data, $post_data, array_shift($users_cache));
210
+		$this->quickmod->show_tools($topic_data);
211
+		$this->set_meta_tags($entity->get_detail_fields(), $tpl_data);
212
+
213
+		return array_merge($topic_data, array(
214
+			'topic_title'		=> $tpl_data['TOPIC_TITLE'],
215
+			'total_comments'	=> $tpl_data['TOPIC_COMMENTS'],
216
+			'topic_url'			=> $tpl_data['TOPIC_URL'],
217
+		));
218
+	}
219
+
220
+	/**
221
+	 * @param array $attachments
222
+	 * @param int $post_id
223
+	 * @return void
224
+	 */
225
+	protected function show_attachments(array $attachments, $post_id)
226
+	{
227
+		if (!empty($attachments[$post_id]))
228
+		{
229
+			foreach ($attachments[$post_id] as $attachment)
230
+			{
231
+				$this->template->assign_block_vars('attachment', array(
232
+						'DISPLAY_ATTACHMENT'	=> $attachment)
233
+				);
234
+			}
235
+		}
236
+	}
237
+
238
+	/**
239
+	 * @param string $view_mode
240
+	 * @param int $total_topics
241
+	 * @param int $start
242
+	 * @param int $items_per_page
243
+	 * @param array $params
244
+	 */
245
+	protected function generate_pagination($view_mode, $total_topics, &$start, $items_per_page, array $params)
246
+	{
247
+		$params = array_filter($params);
248
+		$route_type = $this->get_route_type($view_mode, $params);
249
+		$start = $this->pagination->validate_start($start, $items_per_page, $total_topics);
250
+		$this->pagination->generate_template_pagination(
251
+			array(
252
+				'routes' => array(
253
+					'blitze_content_' . $route_type,
254
+					'blitze_content_' . $route_type . '_page',
255
+				),
256
+				'params' => $params,
257
+			),
258
+			'pagination', 'page', $total_topics, $items_per_page, $start
259
+		);
260
+	}
261
+
262
+	/**
263
+	 * @param string $view_mode
264
+	 * @param array $params
265
+	 * @return string
266
+	 */
267
+	protected function get_route_type($view_mode, array $params)
268
+	{
269
+		$types = array(
270
+			'show'		=> 'show',
271
+			'summary'	=> join('_', array_filter(array(
272
+				(!empty($params['type'])) ? 'type' : '',
273
+				(!empty($params['filters'])) ? 'multi' : '',
274
+				(!empty($params['filter_type'])) ? 'filter' : '',
275
+			))),
276
+		);
277
+
278
+		return $types[$view_mode];
279
+	}
280
+
281
+	/**
282
+	 * {@inheritdoc}
283
+	 */
284
+	protected function get_filter_sql(array $filters, $forum_id)
285
+	{
286
+		$sql_array = array();
287
+
288
+		/**
289
+		 * Event to filter topics by field value e.g category/food
290
+		 *
291
+		 * @event blitze.content.view.filter
292
+		 * @var mixed								forum_id		Forum id, if available
293
+		 * @var array								filters			Filters
294
+		 * @var array								sql_array		Array to modify sql query to get topics
295
+		 */
296
+		$vars = array('forum_id', 'filters', 'sql_array');
297
+		extract($this->phpbb_dispatcher->trigger_event('blitze.content.view.filter', compact($vars)));
298
+
299
+		return $sql_array;
300
+	}
301
+
302
+	/**
303
+	 * @param \blitze\content\model\entity\type $entity
304
+	 * @param array $topic_data
305
+	 * @param array $post_data
306
+	 * @param array $user_cache
307
+	 * @return void
308
+	 */
309
+	protected function show_topic_blocks(\blitze\content\model\entity\type $entity, array $topic_data, array $post_data, array $user_cache)
310
+	{
311
+		$topic_blocks = $entity->get_topic_blocks();
312
+		foreach ($topic_blocks as $service_name)
313
+		{
314
+			/** @var \blitze\content\services\topic\driver\block_interface $block */
315
+			if ($block = $this->topic_blocks_factory->get($service_name))
316
+			{
317
+				$block->show_block($entity, $topic_data, $post_data, $user_cache);
318
+			}
319
+		}
320
+	}
321
+
322
+	/**
323
+	 * @param int $forum_id
324
+	 * @param int $topic_id
325
+	 * @return void
326
+	 */
327
+	protected function set_mcp_url($forum_id, $topic_id = 0)
328
+	{
329
+		$this->template->assign_var('U_MCP', $this->helper->get_mcp_url($forum_id, $topic_id));
330
+	}
331
+
332
+	/**
333
+	 * @param array $field_types
334
+	 * @param array $topic_data
335
+	 * @return void
336
+	 */
337
+	protected function set_meta_tags(array $field_types, array $topic_data)
338
+	{
339
+		$image_url = $this->get_topic_image_url($field_types, $topic_data['FIELDS']['all']);
340
+		$description = $this->get_topic_description($field_types, $topic_data['FIELDS']['all']);
341
+
342
+		$meta = "<meta name=\"description\" content=\"$description\" />\n";
343
+		$meta .= "<meta name=\"twitter:card\" value=\"summary\">\n";
344
+		$meta .= "<meta property=\"og:title\" content=\"{$topic_data['TOPIC_TITLE']}\" />\n";
345
+		$meta .= "<meta property=\"og:type\" content=\"article\" />\n";
346
+		$meta .= "<meta property=\"og:url\" content=\"{$topic_data['PERMA_LINK']}\" />\n";
347
+		$meta .= "<meta property=\"og:image\" content=\"$image_url\" />\n";
348
+		$meta .= "<meta property=\"og:description\" content=\"$description\" />";
349
+
350
+		$this->template->assign_var('META', $meta);
351
+	}
352
+
353
+	/**
354
+	 * @param array $field_types
355
+	 * @param array $fields_data
356
+	 * @return string
357
+	 */
358
+	protected function get_topic_image_url(array $field_types, array $fields_data)
359
+	{
360
+		$image_url = '';
361
+
362
+		$image_field = $this->get_field_name($field_types, 'image');
363
+		if (null !== ($figure = $fields_data[$image_field]) && preg_match('/src="(.*?)"/i', $figure, $matches))
364
+		{
365
+			$image_url = $matches[1];
366
+		}
367
+
368
+		return $image_url;
369
+	}
370
+
371
+	/**
372
+	 * @param array $field_types
373
+	 * @param array $fields_data
374
+	 * @return string
375
+	 */
376
+	protected function get_topic_description(array $field_types, array $fields_data)
377
+	{
378
+		$desc_field = $this->get_field_name($field_types, 'textarea');
379
+
380
+		if (null !== ($description = $fields_data[$desc_field]))
381
+		{
382
+			$description = implode(' ', array_slice(explode(' ', strip_tags($description)), 1, 20));
383
+		}
384
+
385
+		return $description;
386
+	}
387
+
388
+	/**
389
+	 * @param array $field_types
390
+	 * @param string $search_field
391
+	 * @return string
392
+	 */
393
+	protected function get_field_name(array $field_types, $search_field)
394
+	{
395
+		$results = array_keys($field_types, $search_field);
396
+		return array_shift($results);
397
+	}
398 398
 }
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -138,7 +138,7 @@  discard block
 block discarded – undo
138 138
 
139 139
         foreach ($posts_data as $topic_id => $posts)
140 140
         {
141
-            $post_data	= array_shift($posts);
141
+            $post_data = array_shift($posts);
142 142
             $topic_data	= $topics_data[$topic_id];
143 143
             $topic_data = array_merge(
144 144
                 $this->fields->show($content_type, $topic_data, $post_data, $users_cache, $attachments, $update_count, $topic_tracking_info),
@@ -250,8 +250,8 @@  discard block
 block discarded – undo
250 250
         $this->pagination->generate_template_pagination(
251 251
             array(
252 252
                 'routes' => array(
253
-                    'blitze_content_' . $route_type,
254
-                    'blitze_content_' . $route_type . '_page',
253
+                    'blitze_content_'.$route_type,
254
+                    'blitze_content_'.$route_type.'_page',
255 255
                 ),
256 256
                 'params' => $params,
257 257
             ),
Please login to merge, or discard this patch.
services/views/driver/tiles.php 1 patch
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -27,7 +27,7 @@  discard block
 block discarded – undo
27 27
 	 * @param \blitze\content\services\quickmod					$quickmod				Quick moderator tools
28 28
 	 * @param \blitze\content\services\topic\blocks_factory		$topic_blocks_factory	Topic blocks factory object
29 29
 	 * @param \phpbb\request\request_interface					$request				Request object
30
-	*/
30
+	 */
31 31
 	public function __construct(\phpbb\event\dispatcher_interface $phpbb_dispatcher, \phpbb\language\language $language, \phpbb\pagination $pagination, \phpbb\template\template $template, \blitze\content\services\fields $fields, \blitze\sitemaker\services\forum\data $forum, \blitze\content\services\helper $helper, \blitze\content\services\quickmod $quickmod, \blitze\content\services\topic\blocks_factory $topic_blocks_factory, \phpbb\request\request_interface $request)
32 32
 	{
33 33
 		parent::__construct($phpbb_dispatcher, $language, $pagination, $template, $fields, $forum, $helper, $quickmod, $topic_blocks_factory);
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
 	/**
63 63
 	 * @inheritdoc
64 64
 	 */
65
-    public function render_index(\blitze\content\model\entity\type $entity, $page, array $filters, array $topic_data_overwrite = array())
65
+	public function render_index(\blitze\content\model\entity\type $entity, $page, array $filters, array $topic_data_overwrite = array())
66 66
 	{
67 67
 		parent::render_index($entity, $page, $filters);
68 68
 
Please login to merge, or discard this patch.