@@ -27,18 +27,18 @@ |
||
27 | 27 | |
28 | 28 | class Validator_Int implements Validator_Base { |
29 | 29 | |
30 | - public function isValide ($value): bool { |
|
31 | - return filter_var($value, FILTER_VALIDATE_INT) !== false; |
|
32 | - } |
|
33 | - |
|
34 | - public function validate ($value) : int { |
|
35 | - return intval($value); |
|
36 | - } |
|
37 | - |
|
38 | - public static function get (string $value) : string { |
|
39 | - $obj = new Validator_Int(); |
|
40 | - return $obj->validate($value); |
|
41 | - } |
|
30 | + public function isValide ($value): bool { |
|
31 | + return filter_var($value, FILTER_VALIDATE_INT) !== false; |
|
32 | + } |
|
33 | + |
|
34 | + public function validate ($value) : int { |
|
35 | + return intval($value); |
|
36 | + } |
|
37 | + |
|
38 | + public static function get (string $value) : string { |
|
39 | + $obj = new Validator_Int(); |
|
40 | + return $obj->validate($value); |
|
41 | + } |
|
42 | 42 | |
43 | 43 | } |
44 | 44 |
@@ -38,53 +38,53 @@ |
||
38 | 38 | |
39 | 39 | class SettingsPage extends PageType { |
40 | 40 | |
41 | - public function getContent(): string { |
|
42 | - $template = new DwooTemplate("plugin_facebookapi_settings"); |
|
43 | - |
|
44 | - $template->assign("form_action", DomainUtils::generateURL("admin/plugins/facebookapi")); |
|
45 | - |
|
46 | - //load preferences |
|
47 | - $prefs = new Preferences("plugin_facebookapi"); |
|
48 | - |
|
49 | - if (isset($_REQUEST['submit'])) { |
|
50 | - //first check csrf token |
|
51 | - if (!Security::checkCSRFToken()) { |
|
52 | - $template->assign("error_message", "Wrong CSRF token!"); |
|
53 | - } else { |
|
54 | - //check values |
|
55 | - if (!isset($_POST['appID']) || empty($_POST['appID'])) { |
|
56 | - $template->assign("error_message", "Please complete form! Field appID is missing!"); |
|
57 | - } else if (!isset($_POST['secret_key']) || empty($_POST['secret_key'])) { |
|
58 | - $template->assign("error_message", "Please complete form! Field secret key is missing!"); |
|
59 | - } else { |
|
60 | - $appID = $_POST['appID']; |
|
61 | - $secret_key = $_POST['secret_key']; |
|
62 | - |
|
63 | - //validate values |
|
64 | - $validator = new Validator_Int(); |
|
65 | - $validator_string = new Validator_String(); |
|
66 | - |
|
67 | - if (!$validator->isValide($appID)) { |
|
68 | - $template->assign("error_message", "appID is invalide!"); |
|
69 | - } else if (!$validator_string->isValide($secret_key)) { |
|
70 | - $template->assign("error_message", "secret key is invalide!"); |
|
71 | - } else { |
|
72 | - //save values |
|
73 | - $prefs->put("appID", $appID); |
|
74 | - $prefs->put("secret", $secret_key); |
|
75 | - $prefs->save(); |
|
76 | - |
|
77 | - $template->assign("success_message", Translator::translate("appID & secret key saved successfully!")); |
|
78 | - } |
|
79 | - } |
|
80 | - } |
|
81 | - } |
|
82 | - |
|
83 | - $template->assign("appID", $prefs->get("appID", "")); |
|
84 | - $template->assign("secret_key", $prefs->get("secret", "")); |
|
85 | - |
|
86 | - return $template->getCode(); |
|
87 | - } |
|
41 | + public function getContent(): string { |
|
42 | + $template = new DwooTemplate("plugin_facebookapi_settings"); |
|
43 | + |
|
44 | + $template->assign("form_action", DomainUtils::generateURL("admin/plugins/facebookapi")); |
|
45 | + |
|
46 | + //load preferences |
|
47 | + $prefs = new Preferences("plugin_facebookapi"); |
|
48 | + |
|
49 | + if (isset($_REQUEST['submit'])) { |
|
50 | + //first check csrf token |
|
51 | + if (!Security::checkCSRFToken()) { |
|
52 | + $template->assign("error_message", "Wrong CSRF token!"); |
|
53 | + } else { |
|
54 | + //check values |
|
55 | + if (!isset($_POST['appID']) || empty($_POST['appID'])) { |
|
56 | + $template->assign("error_message", "Please complete form! Field appID is missing!"); |
|
57 | + } else if (!isset($_POST['secret_key']) || empty($_POST['secret_key'])) { |
|
58 | + $template->assign("error_message", "Please complete form! Field secret key is missing!"); |
|
59 | + } else { |
|
60 | + $appID = $_POST['appID']; |
|
61 | + $secret_key = $_POST['secret_key']; |
|
62 | + |
|
63 | + //validate values |
|
64 | + $validator = new Validator_Int(); |
|
65 | + $validator_string = new Validator_String(); |
|
66 | + |
|
67 | + if (!$validator->isValide($appID)) { |
|
68 | + $template->assign("error_message", "appID is invalide!"); |
|
69 | + } else if (!$validator_string->isValide($secret_key)) { |
|
70 | + $template->assign("error_message", "secret key is invalide!"); |
|
71 | + } else { |
|
72 | + //save values |
|
73 | + $prefs->put("appID", $appID); |
|
74 | + $prefs->put("secret", $secret_key); |
|
75 | + $prefs->save(); |
|
76 | + |
|
77 | + $template->assign("success_message", Translator::translate("appID & secret key saved successfully!")); |
|
78 | + } |
|
79 | + } |
|
80 | + } |
|
81 | + } |
|
82 | + |
|
83 | + $template->assign("appID", $prefs->get("appID", "")); |
|
84 | + $template->assign("secret_key", $prefs->get("secret", "")); |
|
85 | + |
|
86 | + return $template->getCode(); |
|
87 | + } |
|
88 | 88 | |
89 | 89 | } |
90 | 90 |
@@ -32,60 +32,60 @@ |
||
32 | 32 | use Facebook\Facebook; |
33 | 33 | |
34 | 34 | if (!defined('FB_SDK_PATH')) { |
35 | - define('FB_SDK_PATH', PLUGIN_PATH . "facebookapi/facebook-sdk/"); |
|
35 | + define('FB_SDK_PATH', PLUGIN_PATH . "facebookapi/facebook-sdk/"); |
|
36 | 36 | } |
37 | 37 | |
38 | 38 | class FacebookApi { |
39 | 39 | |
40 | - protected $appID = ""; |
|
41 | - protected $secret = ""; |
|
40 | + protected $appID = ""; |
|
41 | + protected $secret = ""; |
|
42 | 42 | |
43 | - //facebook sdk instance |
|
44 | - protected $fb = null; |
|
43 | + //facebook sdk instance |
|
44 | + protected $fb = null; |
|
45 | 45 | |
46 | - public function __construct() { |
|
47 | - //load preferences |
|
48 | - $prefs = new Preferences("plugin_facebookapi"); |
|
46 | + public function __construct() { |
|
47 | + //load preferences |
|
48 | + $prefs = new Preferences("plugin_facebookapi"); |
|
49 | 49 | |
50 | - $this->appID = $prefs->get("appID", ""); |
|
51 | - $this->secret = $prefs->get("secret", ""); |
|
50 | + $this->appID = $prefs->get("appID", ""); |
|
51 | + $this->secret = $prefs->get("secret", ""); |
|
52 | 52 | |
53 | - $config = array(); |
|
54 | - $config['app_id'] = $this->appID; |
|
55 | - $config['app_secret'] = $this->secret; |
|
56 | - $config['default_graph_version'] = 'v2.2'; |
|
53 | + $config = array(); |
|
54 | + $config['app_id'] = $this->appID; |
|
55 | + $config['app_secret'] = $this->secret; |
|
56 | + $config['default_graph_version'] = 'v2.2'; |
|
57 | 57 | |
58 | - $this->fb = new Facebook($config); |
|
59 | - } |
|
58 | + $this->fb = new Facebook($config); |
|
59 | + } |
|
60 | 60 | |
61 | - public static function addFBClassloader (array $params) { |
|
62 | - //add classloader for facebook sdk |
|
63 | - ClassLoader::addLoader("Facebook", function (string $class_name) { |
|
64 | - $path = FB_SDK_PATH . str_replace("\\", "/", $class_name) . ".php"; |
|
61 | + public static function addFBClassloader (array $params) { |
|
62 | + //add classloader for facebook sdk |
|
63 | + ClassLoader::addLoader("Facebook", function (string $class_name) { |
|
64 | + $path = FB_SDK_PATH . str_replace("\\", "/", $class_name) . ".php"; |
|
65 | 65 | |
66 | - if (file_exists($path)) { |
|
67 | - require($path); |
|
68 | - } else { |
|
69 | - echo "Couldnt load facebook class: " . $class_name . " (expected path: " . $path . ")!"; |
|
70 | - exit; |
|
71 | - } |
|
72 | - }); |
|
73 | - } |
|
66 | + if (file_exists($path)) { |
|
67 | + require($path); |
|
68 | + } else { |
|
69 | + echo "Couldnt load facebook class: " . $class_name . " (expected path: " . $path . ")!"; |
|
70 | + exit; |
|
71 | + } |
|
72 | + }); |
|
73 | + } |
|
74 | 74 | |
75 | - public function getSDK () : Facebook { |
|
76 | - return $this->fb; |
|
77 | - } |
|
75 | + public function getSDK () : Facebook { |
|
76 | + return $this->fb; |
|
77 | + } |
|
78 | 78 | |
79 | - public function getPage (string $name) : Page { |
|
80 | - $page = new Page($this); |
|
81 | - $page->loadPage($name); |
|
79 | + public function getPage (string $name) : Page { |
|
80 | + $page = new Page($this); |
|
81 | + $page->loadPage($name); |
|
82 | 82 | |
83 | - return $page; |
|
84 | - } |
|
83 | + return $page; |
|
84 | + } |
|
85 | 85 | |
86 | - public function getAccessToken () : string { |
|
87 | - return $this->appID . "|" . $this->secret; |
|
88 | - } |
|
86 | + public function getAccessToken () : string { |
|
87 | + return $this->appID . "|" . $this->secret; |
|
88 | + } |
|
89 | 89 | |
90 | 90 | } |
91 | 91 |
@@ -35,84 +35,84 @@ |
||
35 | 35 | |
36 | 36 | class Page { |
37 | 37 | |
38 | - protected $fb = null; |
|
39 | - protected $api = null; |
|
40 | - |
|
41 | - protected $pageID = ""; |
|
42 | - |
|
43 | - protected $response = null; |
|
44 | - protected $graphNode = null; |
|
45 | - protected $page = null; |
|
46 | - |
|
47 | - public function __construct (FacebookApi $api) { |
|
48 | - $this->fb = $api->getSDK(); |
|
49 | - $this->api = $api; |
|
50 | - } |
|
51 | - |
|
52 | - public function loadPage (string $name) { |
|
53 | - $this->pageID = $name; |
|
54 | - |
|
55 | - //https://stackoverflow.com/questions/7633234/get-public-page-statuses-using-facebook-graph-api-without-access-token |
|
56 | - |
|
57 | - //get all available fields: /{page-id}?metadata=1 |
|
58 | - |
|
59 | - try { |
|
60 | - // Returns a `Facebook\FacebookResponse` object |
|
61 | - $this->response = $this->fb->get( |
|
62 | - "/" . $this->pageID . "?fields=id,about,fan_count,website,location,name,username,phone,feed.limit(10){child_attachments,application,actions,caption,description,expanded_height,created_time,coordinates,comments_mirroring_domain,backdated_time,event,from,feed_targeting,full_picture,id,is_expired,is_hidden,height,is_popular,is_published,message,message_tags,likes,link,picture,properties,scheduled_publish_time,object_id,type,privacy,name,place,reactions,permalink_url,shares},band_members,best_page,band_interests", |
|
63 | - $this->api->getAccessToken() |
|
64 | - ); |
|
65 | - } catch(FacebookResponseException $e) { |
|
66 | - echo 'Graph returned an error: ' . $e->getMessage(); |
|
67 | - exit; |
|
68 | - } catch(FacebookSDKException $e) { |
|
69 | - echo 'Facebook SDK returned an error: ' . $e->getMessage(); |
|
70 | - exit; |
|
71 | - } |
|
72 | - |
|
73 | - $this->graphNode = $this->response->getGraphNode(); |
|
74 | - $this->page = $this->response->getGraphPage(); |
|
75 | - } |
|
76 | - |
|
77 | - public function listFieldNames () : array { |
|
78 | - return $this->graphNode->getFieldNames(); |
|
79 | - } |
|
80 | - |
|
81 | - public function getGraphNode () : GraphNode { |
|
82 | - return $this->graphNode; |
|
83 | - } |
|
84 | - |
|
85 | - public function getGraphPage () : GraphPage { |
|
86 | - return $this->page; |
|
87 | - } |
|
88 | - |
|
89 | - public function getID () : int { |
|
90 | - return $this->getGraphNode()->getField("id"); |
|
91 | - } |
|
92 | - |
|
93 | - public function getName () : string { |
|
94 | - return $this->getGraphPage()->getName(); |
|
95 | - } |
|
96 | - |
|
97 | - public function getUsername () : string { |
|
98 | - return $this->getGraphNode()->getField("username"); |
|
99 | - } |
|
100 | - |
|
101 | - public function countLikes () : int { |
|
102 | - return $this->getGraphPage()->getField("fan_count"); |
|
103 | - } |
|
104 | - |
|
105 | - public function getAbout () : string { |
|
106 | - return $this->getGraphNode()->getField("about"); |
|
107 | - } |
|
108 | - |
|
109 | - public function getWebsite () : string { |
|
110 | - return $this->getGraphNode()->getField("website"); |
|
111 | - } |
|
112 | - |
|
113 | - public function getAllItems () : array { |
|
114 | - return $this->getGraphNode()->all(); |
|
115 | - } |
|
38 | + protected $fb = null; |
|
39 | + protected $api = null; |
|
40 | + |
|
41 | + protected $pageID = ""; |
|
42 | + |
|
43 | + protected $response = null; |
|
44 | + protected $graphNode = null; |
|
45 | + protected $page = null; |
|
46 | + |
|
47 | + public function __construct (FacebookApi $api) { |
|
48 | + $this->fb = $api->getSDK(); |
|
49 | + $this->api = $api; |
|
50 | + } |
|
51 | + |
|
52 | + public function loadPage (string $name) { |
|
53 | + $this->pageID = $name; |
|
54 | + |
|
55 | + //https://stackoverflow.com/questions/7633234/get-public-page-statuses-using-facebook-graph-api-without-access-token |
|
56 | + |
|
57 | + //get all available fields: /{page-id}?metadata=1 |
|
58 | + |
|
59 | + try { |
|
60 | + // Returns a `Facebook\FacebookResponse` object |
|
61 | + $this->response = $this->fb->get( |
|
62 | + "/" . $this->pageID . "?fields=id,about,fan_count,website,location,name,username,phone,feed.limit(10){child_attachments,application,actions,caption,description,expanded_height,created_time,coordinates,comments_mirroring_domain,backdated_time,event,from,feed_targeting,full_picture,id,is_expired,is_hidden,height,is_popular,is_published,message,message_tags,likes,link,picture,properties,scheduled_publish_time,object_id,type,privacy,name,place,reactions,permalink_url,shares},band_members,best_page,band_interests", |
|
63 | + $this->api->getAccessToken() |
|
64 | + ); |
|
65 | + } catch(FacebookResponseException $e) { |
|
66 | + echo 'Graph returned an error: ' . $e->getMessage(); |
|
67 | + exit; |
|
68 | + } catch(FacebookSDKException $e) { |
|
69 | + echo 'Facebook SDK returned an error: ' . $e->getMessage(); |
|
70 | + exit; |
|
71 | + } |
|
72 | + |
|
73 | + $this->graphNode = $this->response->getGraphNode(); |
|
74 | + $this->page = $this->response->getGraphPage(); |
|
75 | + } |
|
76 | + |
|
77 | + public function listFieldNames () : array { |
|
78 | + return $this->graphNode->getFieldNames(); |
|
79 | + } |
|
80 | + |
|
81 | + public function getGraphNode () : GraphNode { |
|
82 | + return $this->graphNode; |
|
83 | + } |
|
84 | + |
|
85 | + public function getGraphPage () : GraphPage { |
|
86 | + return $this->page; |
|
87 | + } |
|
88 | + |
|
89 | + public function getID () : int { |
|
90 | + return $this->getGraphNode()->getField("id"); |
|
91 | + } |
|
92 | + |
|
93 | + public function getName () : string { |
|
94 | + return $this->getGraphPage()->getName(); |
|
95 | + } |
|
96 | + |
|
97 | + public function getUsername () : string { |
|
98 | + return $this->getGraphNode()->getField("username"); |
|
99 | + } |
|
100 | + |
|
101 | + public function countLikes () : int { |
|
102 | + return $this->getGraphPage()->getField("fan_count"); |
|
103 | + } |
|
104 | + |
|
105 | + public function getAbout () : string { |
|
106 | + return $this->getGraphNode()->getField("about"); |
|
107 | + } |
|
108 | + |
|
109 | + public function getWebsite () : string { |
|
110 | + return $this->getGraphNode()->getField("website"); |
|
111 | + } |
|
112 | + |
|
113 | + public function getAllItems () : array { |
|
114 | + return $this->getGraphNode()->all(); |
|
115 | + } |
|
116 | 116 | |
117 | 117 | } |
118 | 118 |
@@ -33,44 +33,44 @@ |
||
33 | 33 | |
34 | 34 | class SettingsPage extends PageType { |
35 | 35 | |
36 | - public function getContent(): string { |
|
37 | - $template = new DwooTemplate("plugin_facebookfeed_settings"); |
|
38 | - |
|
39 | - $template->assign("form_action", DomainUtils::generateURL($this->getPage()->getAlias())); |
|
40 | - |
|
41 | - $prefs = new Preferences("plugin_facebookfeed"); |
|
42 | - |
|
43 | - if (isset($_REQUEST['submit'])) { |
|
44 | - //first check csrf token |
|
45 | - if (!Security::checkCSRFToken()) { |
|
46 | - $template->assign("error_message", "Wrong CSRF token!"); |
|
47 | - } else { |
|
48 | - //check values |
|
49 | - if (!isset($_POST['pageID']) || empty($_POST['pageID'])) { |
|
50 | - $template->assign("error_message", "Please complete form! Field pageID is missing!"); |
|
51 | - } else { |
|
52 | - $pageID = $_POST['pageID']; |
|
53 | - |
|
54 | - //validate values |
|
55 | - $validator_string = new Validator_String(); |
|
56 | - |
|
57 | - if (!$validator_string->isValide($pageID)) { |
|
58 | - $template->assign("error_message", "pageID is invalide!"); |
|
59 | - } else { |
|
60 | - //save values |
|
61 | - $prefs->put("pageID", $pageID); |
|
62 | - $prefs->save(); |
|
63 | - |
|
64 | - $template->assign("success_message", Translator::translate("pageID saved successfully!")); |
|
65 | - } |
|
66 | - } |
|
67 | - } |
|
68 | - } |
|
69 | - |
|
70 | - $template->assign("pageID", $prefs->get("pageID", "")); |
|
71 | - |
|
72 | - return $template->getCode(); |
|
73 | - } |
|
36 | + public function getContent(): string { |
|
37 | + $template = new DwooTemplate("plugin_facebookfeed_settings"); |
|
38 | + |
|
39 | + $template->assign("form_action", DomainUtils::generateURL($this->getPage()->getAlias())); |
|
40 | + |
|
41 | + $prefs = new Preferences("plugin_facebookfeed"); |
|
42 | + |
|
43 | + if (isset($_REQUEST['submit'])) { |
|
44 | + //first check csrf token |
|
45 | + if (!Security::checkCSRFToken()) { |
|
46 | + $template->assign("error_message", "Wrong CSRF token!"); |
|
47 | + } else { |
|
48 | + //check values |
|
49 | + if (!isset($_POST['pageID']) || empty($_POST['pageID'])) { |
|
50 | + $template->assign("error_message", "Please complete form! Field pageID is missing!"); |
|
51 | + } else { |
|
52 | + $pageID = $_POST['pageID']; |
|
53 | + |
|
54 | + //validate values |
|
55 | + $validator_string = new Validator_String(); |
|
56 | + |
|
57 | + if (!$validator_string->isValide($pageID)) { |
|
58 | + $template->assign("error_message", "pageID is invalide!"); |
|
59 | + } else { |
|
60 | + //save values |
|
61 | + $prefs->put("pageID", $pageID); |
|
62 | + $prefs->save(); |
|
63 | + |
|
64 | + $template->assign("success_message", Translator::translate("pageID saved successfully!")); |
|
65 | + } |
|
66 | + } |
|
67 | + } |
|
68 | + } |
|
69 | + |
|
70 | + $template->assign("pageID", $prefs->get("pageID", "")); |
|
71 | + |
|
72 | + return $template->getCode(); |
|
73 | + } |
|
74 | 74 | |
75 | 75 | } |
76 | 76 |
@@ -95,14 +95,14 @@ discard block |
||
95 | 95 | * add classloader for specific namespace prefix |
96 | 96 | */ |
97 | 97 | public static function addLoader (string $prefix, callable $func) { |
98 | - $prefix = strtolower($prefix); |
|
99 | - self::$namespace_autoloader[$prefix] = $func; |
|
100 | - } |
|
98 | + $prefix = strtolower($prefix); |
|
99 | + self::$namespace_autoloader[$prefix] = $func; |
|
100 | + } |
|
101 | 101 | |
102 | - public static function removeLoader (string $prefix) { |
|
103 | - $prefix = strtolower($prefix); |
|
104 | - unset(self::$namespace_autoloader[$prefix]); |
|
105 | - } |
|
102 | + public static function removeLoader (string $prefix) { |
|
103 | + $prefix = strtolower($prefix); |
|
104 | + unset(self::$namespace_autoloader[$prefix]); |
|
105 | + } |
|
106 | 106 | |
107 | 107 | } |
108 | 108 | |
@@ -122,66 +122,66 @@ discard block |
||
122 | 122 | require(ROOT_PATH . "system/core/classes/" . strtolower($classname) . ".php"); |
123 | 123 | return null; |
124 | 124 | } else if (file_exists(ROOT_PATH . "system/core/exception/" . strtolower($classname) . ".php")) { |
125 | - require(ROOT_PATH . "system/core/exception/" . strtolower($classname) . ".php"); |
|
126 | - return null; |
|
127 | - } else if (file_exists(ROOT_PATH . "system/core/driver/" . strtolower($classname) . ".php")) { |
|
128 | - require(ROOT_PATH . "system/core/driver/" . strtolower($classname) . ".php"); |
|
129 | - return null; |
|
130 | - } |
|
131 | - |
|
132 | - //check, if class belongs to dwoo template engine |
|
125 | + require(ROOT_PATH . "system/core/exception/" . strtolower($classname) . ".php"); |
|
126 | + return null; |
|
127 | + } else if (file_exists(ROOT_PATH . "system/core/driver/" . strtolower($classname) . ".php")) { |
|
128 | + require(ROOT_PATH . "system/core/driver/" . strtolower($classname) . ".php"); |
|
129 | + return null; |
|
130 | + } |
|
131 | + |
|
132 | + //check, if class belongs to dwoo template engine |
|
133 | 133 | if (PHPUtils::startsWith($classname, "Dwoo")) { |
134 | 134 | if (class_exists("DwooAutoloader", true)) { |
135 | 135 | DwooAutoloader::loadClass($classname); |
136 | 136 | return; |
137 | 137 | } else { |
138 | - echo "Could not load Dwoo template engine class " . $classname . "!"; |
|
138 | + echo "Could not load Dwoo template engine class " . $classname . "!"; |
|
139 | 139 | } |
140 | 140 | } |
141 | 141 | |
142 | 142 | //check, if we have to use namespace classloading |
143 | - if (PHPUtils::containsStr($classname, "\\")) { |
|
144 | - //we have to use namespace classloading |
|
145 | - if (PHPUtils::startsWith($classname, "\\")) { |
|
146 | - //use normal class loading |
|
147 | - $classname = substr($classname, 1); |
|
148 | - } else { |
|
149 | - $array = explode("\\", strtolower($classname)); |
|
150 | - |
|
151 | - if ($array[0] === "plugin") { |
|
152 | - $array1 = array(); |
|
153 | - |
|
154 | - for ($i = 2; $i < count($array); $i++) { |
|
155 | - $array1[] = $array[$i]; |
|
156 | - } |
|
157 | - |
|
158 | - $file_name = implode("/", $array1); |
|
159 | - |
|
160 | - //load plugin class |
|
161 | - $path = PLUGIN_PATH . $array[1] . "/classes/" . $file_name . ".php"; |
|
162 | - |
|
163 | - if (file_exists($path)) { |
|
164 | - require($path); |
|
165 | - } else { |
|
166 | - $expected_str = (DEBUG_MODE ? " (expected path: " . $path . ")" : ""); |
|
167 | - echo "Could not load plugin-class with namespace " . $classname . $expected_str . "!"; |
|
168 | - } |
|
169 | - } else { |
|
170 | - //check, if there is a classloader for this prefix |
|
171 | - if (isset(ClassLoader::$namespace_autoloader[$array[0]])) { |
|
172 | - //get function |
|
173 | - $func = ClassLoader::$namespace_autoloader[$array[0]]; |
|
174 | - |
|
175 | - //call func |
|
176 | - $func($classname); |
|
177 | - } else { |
|
178 | - throw new IllegalStateException("Cannot load namespace class '" . $classname . "' with unknown prefix '" . $array[0] . "'!"); |
|
179 | - } |
|
180 | - } |
|
181 | - |
|
182 | - return; |
|
183 | - } |
|
184 | - } |
|
143 | + if (PHPUtils::containsStr($classname, "\\")) { |
|
144 | + //we have to use namespace classloading |
|
145 | + if (PHPUtils::startsWith($classname, "\\")) { |
|
146 | + //use normal class loading |
|
147 | + $classname = substr($classname, 1); |
|
148 | + } else { |
|
149 | + $array = explode("\\", strtolower($classname)); |
|
150 | + |
|
151 | + if ($array[0] === "plugin") { |
|
152 | + $array1 = array(); |
|
153 | + |
|
154 | + for ($i = 2; $i < count($array); $i++) { |
|
155 | + $array1[] = $array[$i]; |
|
156 | + } |
|
157 | + |
|
158 | + $file_name = implode("/", $array1); |
|
159 | + |
|
160 | + //load plugin class |
|
161 | + $path = PLUGIN_PATH . $array[1] . "/classes/" . $file_name . ".php"; |
|
162 | + |
|
163 | + if (file_exists($path)) { |
|
164 | + require($path); |
|
165 | + } else { |
|
166 | + $expected_str = (DEBUG_MODE ? " (expected path: " . $path . ")" : ""); |
|
167 | + echo "Could not load plugin-class with namespace " . $classname . $expected_str . "!"; |
|
168 | + } |
|
169 | + } else { |
|
170 | + //check, if there is a classloader for this prefix |
|
171 | + if (isset(ClassLoader::$namespace_autoloader[$array[0]])) { |
|
172 | + //get function |
|
173 | + $func = ClassLoader::$namespace_autoloader[$array[0]]; |
|
174 | + |
|
175 | + //call func |
|
176 | + $func($classname); |
|
177 | + } else { |
|
178 | + throw new IllegalStateException("Cannot load namespace class '" . $classname . "' with unknown prefix '" . $array[0] . "'!"); |
|
179 | + } |
|
180 | + } |
|
181 | + |
|
182 | + return; |
|
183 | + } |
|
184 | + } |
|
185 | 185 | |
186 | 186 | $array = explode("_", strtolower($classname)); |
187 | 187 | |
@@ -204,32 +204,32 @@ discard block |
||
204 | 204 | } |
205 | 205 | |
206 | 206 | } else if (sizeof($array) == 2) { |
207 | - if ($array[0] == "validator") { |
|
208 | - if (file_exists(ROOT_PATH . "system/core/validator/" . $array[1] . ".php")) { |
|
209 | - require(ROOT_PATH . "system/core/validator/" . $array[1] . ".php"); |
|
210 | - } else { |
|
211 | - echo "Could not load validator class " . $classname . "!"; |
|
212 | - } |
|
213 | - } else if ($array[0] == "datatype") { |
|
214 | - if (file_exists(ROOT_PATH . "system/core/datatype/" . $array[1] . ".php")) { |
|
215 | - require(ROOT_PATH . "system/core/datatype/" . $array[1] . ".php"); |
|
216 | - } else { |
|
217 | - echo "Could not load datatype class " . $classname . "!"; |
|
218 | - } |
|
219 | - } else if (strpos($classname, "Plugin")) { |
|
220 | - //dwoo tries several times to load a class - with and without namespace, so we hide this error message |
|
221 | - } else { |
|
222 | - echo "Could not load class " . $classname . ", unknown prefix '" . $array[0] . "'!"; |
|
207 | + if ($array[0] == "validator") { |
|
208 | + if (file_exists(ROOT_PATH . "system/core/validator/" . $array[1] . ".php")) { |
|
209 | + require(ROOT_PATH . "system/core/validator/" . $array[1] . ".php"); |
|
210 | + } else { |
|
211 | + echo "Could not load validator class " . $classname . "!"; |
|
212 | + } |
|
213 | + } else if ($array[0] == "datatype") { |
|
214 | + if (file_exists(ROOT_PATH . "system/core/datatype/" . $array[1] . ".php")) { |
|
215 | + require(ROOT_PATH . "system/core/datatype/" . $array[1] . ".php"); |
|
216 | + } else { |
|
217 | + echo "Could not load datatype class " . $classname . "!"; |
|
218 | + } |
|
219 | + } else if (strpos($classname, "Plugin")) { |
|
220 | + //dwoo tries several times to load a class - with and without namespace, so we hide this error message |
|
221 | + } else { |
|
222 | + echo "Could not load class " . $classname . ", unknown prefix '" . $array[0] . "'!"; |
|
223 | 223 | } |
224 | - } else if (sizeOf($array) == 1) { |
|
224 | + } else if (sizeOf($array) == 1) { |
|
225 | 225 | |
226 | 226 | if (file_exists(ROOT_PATH . "system/classes/" . strtolower($classname) . ".php")) { |
227 | 227 | include ROOT_PATH . "system/classes/" . strtolower($classname) . ".php"; |
228 | 228 | } else if (file_exists(ROOT_PATH . "system/libs/smarty/sysplugins/" . strtolower($classname) . "php")) { |
229 | 229 | require ROOT_PATH . "system/libs/smarty/sysplugins/" . strtolower($classname) . ".php"; |
230 | 230 | } else if (strpos($classname, "Plugin") !== FALSE) { |
231 | - //dwoo tries several times to load a class - with and without namespace, so we hide this error message |
|
232 | - } else { |
|
231 | + //dwoo tries several times to load a class - with and without namespace, so we hide this error message |
|
232 | + } else { |
|
233 | 233 | echo "Could not load class '" . $classname . "'' (array size 1)!"; |
234 | 234 | } |
235 | 235 |
@@ -32,40 +32,40 @@ |
||
32 | 32 | |
33 | 33 | class FeedApi { |
34 | 34 | |
35 | - public static function listFBFeeds () : array { |
|
36 | - $res = array(); |
|
35 | + public static function listFBFeeds () : array { |
|
36 | + $res = array(); |
|
37 | 37 | |
38 | - //load preferences |
|
39 | - $prefs = new Preferences("plugin_facebookfeed"); |
|
38 | + //load preferences |
|
39 | + $prefs = new Preferences("plugin_facebookfeed"); |
|
40 | 40 | |
41 | - //first check, if pageID is set |
|
42 | - if (empty($prefs->get("pageID", ""))) { |
|
43 | - return array( |
|
44 | - 'error' => "No pageID was set in preferences (plugin settings)", |
|
45 | - "status" => 500 |
|
46 | - ); |
|
47 | - } |
|
41 | + //first check, if pageID is set |
|
42 | + if (empty($prefs->get("pageID", ""))) { |
|
43 | + return array( |
|
44 | + 'error' => "No pageID was set in preferences (plugin settings)", |
|
45 | + "status" => 500 |
|
46 | + ); |
|
47 | + } |
|
48 | 48 | |
49 | - //get pageID |
|
50 | - $pageID = $prefs->get("pageID", ""); |
|
49 | + //get pageID |
|
50 | + $pageID = $prefs->get("pageID", ""); |
|
51 | 51 | |
52 | - //create facebook api |
|
53 | - $fb_api = new FacebookApi(); |
|
52 | + //create facebook api |
|
53 | + $fb_api = new FacebookApi(); |
|
54 | 54 | |
55 | - $fb_page = $fb_api->getPage($pageID); |
|
55 | + $fb_page = $fb_api->getPage($pageID); |
|
56 | 56 | |
57 | - //https://developers.facebook.com/docs/graph-api/reference/v3.0/page/feed |
|
57 | + //https://developers.facebook.com/docs/graph-api/reference/v3.0/page/feed |
|
58 | 58 | |
59 | - //https://stackoverflow.com/questions/28124078/get-latest-facebook-posts-of-page-with-php-sdk |
|
59 | + //https://stackoverflow.com/questions/28124078/get-latest-facebook-posts-of-page-with-php-sdk |
|
60 | 60 | |
61 | - //https://gist.github.com/biojazzard/740551af0455c528f8a9 |
|
61 | + //https://gist.github.com/biojazzard/740551af0455c528f8a9 |
|
62 | 62 | |
63 | - //http://piotrpasich.com/facebook-fanpage-feed/ |
|
63 | + //http://piotrpasich.com/facebook-fanpage-feed/ |
|
64 | 64 | |
65 | - print_r($fb_page->listFieldNames()); |
|
65 | + print_r($fb_page->listFieldNames()); |
|
66 | 66 | |
67 | - return $res; |
|
68 | - } |
|
67 | + return $res; |
|
68 | + } |
|
69 | 69 | |
70 | 70 | } |
71 | 71 |
@@ -29,71 +29,71 @@ |
||
29 | 29 | |
30 | 30 | class Event { |
31 | 31 | |
32 | - protected $row = null; |
|
32 | + protected $row = null; |
|
33 | 33 | |
34 | - public function __construct(array $row) { |
|
35 | - $this->row = $row; |
|
36 | - } |
|
34 | + public function __construct(array $row) { |
|
35 | + $this->row = $row; |
|
36 | + } |
|
37 | 37 | |
38 | - public function getID () : int { |
|
39 | - return $this->row['id']; |
|
40 | - } |
|
38 | + public function getID () : int { |
|
39 | + return $this->row['id']; |
|
40 | + } |
|
41 | 41 | |
42 | - public function getCalenderID () : int { |
|
43 | - return $this->row['calenderID']; |
|
44 | - } |
|
42 | + public function getCalenderID () : int { |
|
43 | + return $this->row['calenderID']; |
|
44 | + } |
|
45 | 45 | |
46 | - public function getTitle () : string { |
|
47 | - return utf8_encode($this->row['title']); |
|
48 | - } |
|
46 | + public function getTitle () : string { |
|
47 | + return utf8_encode($this->row['title']); |
|
48 | + } |
|
49 | 49 | |
50 | - public function getDescription () : string { |
|
51 | - return utf8_encode($this->row['description']); |
|
52 | - } |
|
50 | + public function getDescription () : string { |
|
51 | + return utf8_encode($this->row['description']); |
|
52 | + } |
|
53 | 53 | |
54 | - public function getPriceInfo () : string { |
|
55 | - return (isset($this->row['price_info']) ? $this->row['price_info'] : ""); |
|
56 | - } |
|
54 | + public function getPriceInfo () : string { |
|
55 | + return (isset($this->row['price_info']) ? $this->row['price_info'] : ""); |
|
56 | + } |
|
57 | 57 | |
58 | - public function hasImage () : bool { |
|
59 | - return $this->row['image'] !== "none"; |
|
60 | - } |
|
58 | + public function hasImage () : bool { |
|
59 | + return $this->row['image'] !== "none"; |
|
60 | + } |
|
61 | 61 | |
62 | - public function getImage () : string { |
|
63 | - return $this->row['image']; |
|
64 | - } |
|
62 | + public function getImage () : string { |
|
63 | + return $this->row['image']; |
|
64 | + } |
|
65 | 65 | |
66 | - public function isAllDay () : bool { |
|
67 | - return $this->row['all_day'] == 1; |
|
68 | - } |
|
66 | + public function isAllDay () : bool { |
|
67 | + return $this->row['all_day'] == 1; |
|
68 | + } |
|
69 | 69 | |
70 | - public function getFromTimestamp () : string { |
|
71 | - return $this->row['from_date']; |
|
72 | - } |
|
70 | + public function getFromTimestamp () : string { |
|
71 | + return $this->row['from_date']; |
|
72 | + } |
|
73 | 73 | |
74 | - public function getToTimestamp () : string { |
|
75 | - return $this->row['to_date']; |
|
76 | - } |
|
74 | + public function getToTimestamp () : string { |
|
75 | + return $this->row['to_date']; |
|
76 | + } |
|
77 | 77 | |
78 | - public function getLocation () : string { |
|
79 | - return utf8_encode($this->row['location']); |
|
80 | - } |
|
78 | + public function getLocation () : string { |
|
79 | + return utf8_encode($this->row['location']); |
|
80 | + } |
|
81 | 81 | |
82 | - public function hasColor () : bool { |
|
83 | - return $this->row['color'] !== "none"; |
|
84 | - } |
|
82 | + public function hasColor () : bool { |
|
83 | + return $this->row['color'] !== "none"; |
|
84 | + } |
|
85 | 85 | |
86 | - public function getColor () : string { |
|
87 | - return $this->row['color']; |
|
88 | - } |
|
86 | + public function getColor () : string { |
|
87 | + return $this->row['color']; |
|
88 | + } |
|
89 | 89 | |
90 | - public function isActivated () : bool { |
|
91 | - return $this->row['activated'] == 1; |
|
92 | - } |
|
90 | + public function isActivated () : bool { |
|
91 | + return $this->row['activated'] == 1; |
|
92 | + } |
|
93 | 93 | |
94 | - public static function castEvent (Event $event) : Event { |
|
95 | - return $event; |
|
96 | - } |
|
94 | + public static function castEvent (Event $event) : Event { |
|
95 | + return $event; |
|
96 | + } |
|
97 | 97 | |
98 | 98 | } |
99 | 99 |
@@ -32,99 +32,99 @@ |
||
32 | 32 | |
33 | 33 | class CalenderApi { |
34 | 34 | |
35 | - public static function listMyCalenderIDs () : array { |
|
36 | - $res = array(); |
|
35 | + public static function listMyCalenderIDs () : array { |
|
36 | + $res = array(); |
|
37 | 37 | |
38 | - $array = array(); |
|
38 | + $array = array(); |
|
39 | 39 | |
40 | - $rows = Calenders::listMyCalenderIDs(User::current()->getID()); |
|
40 | + $rows = Calenders::listMyCalenderIDs(User::current()->getID()); |
|
41 | 41 | |
42 | - foreach ($rows as $calenderID=>$row) { |
|
43 | - $array[$calenderID] = $row['value']; |
|
44 | - } |
|
42 | + foreach ($rows as $calenderID=>$row) { |
|
43 | + $array[$calenderID] = $row['value']; |
|
44 | + } |
|
45 | 45 | |
46 | - $res['calender_ids'] = $array; |
|
46 | + $res['calender_ids'] = $array; |
|
47 | 47 | |
48 | - return $res; |
|
49 | - } |
|
48 | + return $res; |
|
49 | + } |
|
50 | 50 | |
51 | - public static function listMyCalenders () : array { |
|
52 | - $res = array(); |
|
51 | + public static function listMyCalenders () : array { |
|
52 | + $res = array(); |
|
53 | 53 | |
54 | - $calenders = array(); |
|
54 | + $calenders = array(); |
|
55 | 55 | |
56 | - foreach (Calenders::listMyCalenders(User::current()->getID()) as $calender) { |
|
57 | - $calender = Calender::castCalender($calender); |
|
56 | + foreach (Calenders::listMyCalenders(User::current()->getID()) as $calender) { |
|
57 | + $calender = Calender::castCalender($calender); |
|
58 | 58 | |
59 | - $calenders[] = array( |
|
60 | - 'id' => $calender->getID(), |
|
61 | - 'title' => $calender->getTitle(), |
|
62 | - 'description' => $calender->getDescription(), |
|
63 | - 'type' => $calender->getType(), |
|
64 | - 'permission' => $calender->getPermission() |
|
65 | - ); |
|
66 | - } |
|
59 | + $calenders[] = array( |
|
60 | + 'id' => $calender->getID(), |
|
61 | + 'title' => $calender->getTitle(), |
|
62 | + 'description' => $calender->getDescription(), |
|
63 | + 'type' => $calender->getType(), |
|
64 | + 'permission' => $calender->getPermission() |
|
65 | + ); |
|
66 | + } |
|
67 | 67 | |
68 | - $res['calenders'] = $calenders; |
|
68 | + $res['calenders'] = $calenders; |
|
69 | 69 | |
70 | - return $res; |
|
71 | - } |
|
70 | + return $res; |
|
71 | + } |
|
72 | 72 | |
73 | - public static function listAllEvents () : array { |
|
74 | - $res = array(); |
|
73 | + public static function listAllEvents () : array { |
|
74 | + $res = array(); |
|
75 | 75 | |
76 | - if (!isset($_REQUEST['calenderID']) || empty($_REQUEST['calenderID'])) { |
|
77 | - $res['status'] = 400; |
|
78 | - $res['error'] = "No parameter 'calenderID' is set. Right usage: api.php?method=list-all-calender-events&calenderID=<CalenderID>"; |
|
76 | + if (!isset($_REQUEST['calenderID']) || empty($_REQUEST['calenderID'])) { |
|
77 | + $res['status'] = 400; |
|
78 | + $res['error'] = "No parameter 'calenderID' is set. Right usage: api.php?method=list-all-calender-events&calenderID=<CalenderID>"; |
|
79 | 79 | |
80 | - return $res; |
|
81 | - } |
|
80 | + return $res; |
|
81 | + } |
|
82 | 82 | |
83 | - $calenderID = intval($_REQUEST['calenderID']); |
|
83 | + $calenderID = intval($_REQUEST['calenderID']); |
|
84 | 84 | |
85 | - $only_current_events = false; |
|
85 | + $only_current_events = false; |
|
86 | 86 | |
87 | - if (isset($_REQUEST['only_current'])) { |
|
88 | - $only_current_events = true; |
|
89 | - } |
|
87 | + if (isset($_REQUEST['only_current'])) { |
|
88 | + $only_current_events = true; |
|
89 | + } |
|
90 | 90 | |
91 | - //create and load calender |
|
92 | - $calender = new Calender(); |
|
91 | + //create and load calender |
|
92 | + $calender = new Calender(); |
|
93 | 93 | |
94 | - try { |
|
95 | - $calender->load($calenderID); |
|
96 | - } catch (IllegalStateException $e) { |
|
97 | - $res['status'] = 404; |
|
98 | - $res['error'] = "Couldnt found calender with id '" . $calenderID . "'!"; |
|
94 | + try { |
|
95 | + $calender->load($calenderID); |
|
96 | + } catch (IllegalStateException $e) { |
|
97 | + $res['status'] = 404; |
|
98 | + $res['error'] = "Couldnt found calender with id '" . $calenderID . "'!"; |
|
99 | 99 | |
100 | - return $res; |
|
101 | - } |
|
100 | + return $res; |
|
101 | + } |
|
102 | 102 | |
103 | - $events = array(); |
|
103 | + $events = array(); |
|
104 | 104 | |
105 | - foreach ($calender->listAllEvents($only_current_events) as $event) { |
|
106 | - //cast event |
|
107 | - $event = Event::castEvent($event); |
|
105 | + foreach ($calender->listAllEvents($only_current_events) as $event) { |
|
106 | + //cast event |
|
107 | + $event = Event::castEvent($event); |
|
108 | 108 | |
109 | - $events[] = array( |
|
110 | - 'id' => $event->getID(), |
|
111 | - 'calenderID' => $event->getCalenderID(), |
|
112 | - 'title' => $event->getTitle(), |
|
113 | - 'description' => $event->getDescription(), |
|
114 | - 'price_info' => $event->getPriceInfo(), |
|
115 | - 'image' => $event->getImage(), |
|
116 | - 'all_day' => $event->isAllDay(), |
|
117 | - 'from' => $event->getFromTimestamp(), |
|
118 | - 'to' => $event->getToTimestamp(), |
|
119 | - 'location' => $event->getLocation(), |
|
120 | - 'color' => $event->getColor() |
|
121 | - ); |
|
122 | - } |
|
109 | + $events[] = array( |
|
110 | + 'id' => $event->getID(), |
|
111 | + 'calenderID' => $event->getCalenderID(), |
|
112 | + 'title' => $event->getTitle(), |
|
113 | + 'description' => $event->getDescription(), |
|
114 | + 'price_info' => $event->getPriceInfo(), |
|
115 | + 'image' => $event->getImage(), |
|
116 | + 'all_day' => $event->isAllDay(), |
|
117 | + 'from' => $event->getFromTimestamp(), |
|
118 | + 'to' => $event->getToTimestamp(), |
|
119 | + 'location' => $event->getLocation(), |
|
120 | + 'color' => $event->getColor() |
|
121 | + ); |
|
122 | + } |
|
123 | 123 | |
124 | - $res['events'] = $events; |
|
124 | + $res['events'] = $events; |
|
125 | 125 | |
126 | - return $res; |
|
127 | - } |
|
126 | + return $res; |
|
127 | + } |
|
128 | 128 | |
129 | 129 | } |
130 | 130 |