1
|
|
|
<?php |
2
|
|
|
App::uses('Utility', 'SocialMedia.Lib'); |
3
|
|
|
App::uses('Helper', 'View'); |
4
|
|
|
|
5
|
|
|
/** |
6
|
|
|
* Social Media helper |
7
|
|
|
* |
8
|
|
|
* @property HtmlHelper $Html |
9
|
|
|
*/ |
10
|
|
|
class SocialMediaHelper extends AppHelper { |
|
|
|
|
11
|
|
|
|
12
|
|
|
/** |
13
|
|
|
* A so called "feed dialog" url for Facebook. |
14
|
|
|
* |
15
|
|
|
*/ |
16
|
|
|
const FACEBOOK_FEED_DIALOG_URL = 'https://www.facebook.com/dialog/feed'; |
17
|
|
|
|
18
|
|
|
/** |
19
|
|
|
* A so called "tweet" url for Twitter. |
20
|
|
|
* |
21
|
|
|
*/ |
22
|
|
|
const TWITTER_TWEET_URL = 'https://twitter.com/share'; |
23
|
|
|
|
24
|
|
|
/** |
25
|
|
|
* An array of names of helpers to load. |
26
|
|
|
* |
27
|
|
|
* @var array |
28
|
|
|
*/ |
29
|
|
|
public $helpers = ['Html']; |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* Creates a Facebook feed dialog link. |
33
|
|
|
* |
34
|
|
|
* - Url parameters: |
35
|
|
|
* - `app_id` Your application's identifier. Defaults to the configured SocialMedia.facebookAppId |
36
|
|
|
* - `redirect_uri` The URL to redirect to after the user clicks a button on the dialog. Defaults to the current url. |
37
|
|
|
* - `link` The link attached to this post. Defaults to the current url. |
38
|
|
|
* - `picture` The URL of a picture attached to this post. |
39
|
|
|
* The picture must be at least 50px by 50px (though minimum 200px by 200px is preferred) |
40
|
|
|
* and have a maximum aspect ratio of 3:1 |
41
|
|
|
* - `name` The name of the link attachment. |
42
|
|
|
* - `caption` The caption of the link (appears beneath the link name). |
43
|
|
|
* If not specified, this field is automatically populated with the URL of the link. |
44
|
|
|
* - `description` The description of the link (appears beneath the link caption). |
45
|
|
|
* If not specified, this field is automatically populated by information scraped from the link, |
46
|
|
|
* typically the title of the page. |
47
|
|
|
* |
48
|
|
|
* - Options: |
49
|
|
|
* - `escape` Set to false to disable escaping of title and attributes. |
50
|
|
|
* |
51
|
|
|
* @param string $title The content to be wrapped by <a> tags. |
52
|
|
|
* @param array $urlParameters An array of URL parameters |
53
|
|
|
* @param array $options An array of HTML attributes. |
54
|
|
|
* @param string $confirmMessage A javaScript confirmation message. |
55
|
|
|
* @return string An `<a />` element. |
56
|
|
|
*/ |
57
|
|
|
public function facebook($title, $urlParameters = [], $options = [], $confirmMessage = '') { |
58
|
|
|
$defaults = [ |
59
|
|
|
'app_id' => Configure::read('SocialMedia.facebookAppId'), |
|
|
|
|
60
|
|
|
'redirect_uri' => $this->Html->url('', true), |
61
|
|
|
'link' => $this->Html->url('', true) |
62
|
|
|
]; |
63
|
|
|
$urlParameters = array_merge($defaults, $urlParameters); |
64
|
|
|
|
65
|
|
|
return $this->Html->link( |
66
|
|
|
$title, SocialMediaHelper::FACEBOOK_FEED_DIALOG_URL . '?' . http_build_query($urlParameters), $options, $confirmMessage |
67
|
|
|
); |
68
|
|
|
} |
69
|
|
|
|
70
|
|
|
/** |
71
|
|
|
* Creates a Twitter Tweet link. |
72
|
|
|
* |
73
|
|
|
* - Url parameters: |
74
|
|
|
* - `url` URL of the page to share |
75
|
|
|
* - `via` Screen name of the user to attribute the Tweet to |
76
|
|
|
* - `text` Default Tweet text |
77
|
|
|
* |
78
|
|
|
* - Options: |
79
|
|
|
* - `escape` Set to false to disable escaping of title and attributes. |
80
|
|
|
* |
81
|
|
|
* @param string $title The content to be wrapped by <a> tags. |
82
|
|
|
* @param array $urlParameters An array of URL parameters |
83
|
|
|
* @param array $options An array of HTML attributes. |
84
|
|
|
* @param string $confirmMessage A javaScript confirmation message. |
85
|
|
|
* @return string An `<a />` element. |
86
|
|
|
*/ |
87
|
|
|
public function twitter($title, $urlParameters = [], $options = [], $confirmMessage = '') { |
88
|
|
|
$defaults = [ |
89
|
|
|
'url' => $this->Html->url('', true) |
90
|
|
|
]; |
91
|
|
|
$urlParameters = array_merge($defaults, $urlParameters); |
92
|
|
|
|
93
|
|
|
return $this->Html->link( |
94
|
|
|
$title, SocialMediaHelper::TWITTER_TWEET_URL . '?' . http_build_query($urlParameters), $options, $confirmMessage |
95
|
|
|
); |
96
|
|
|
} |
97
|
|
|
} |
98
|
|
|
|
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:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths