@@ -29,111 +29,111 @@ |
||
29 | 29 | */ |
30 | 30 | class referencesTwitterAction extends references_action |
31 | 31 | { |
32 | - public function registerEvents() |
|
33 | - { |
|
34 | - /** |
|
35 | - * La liste des évènements traités par le plugin se présente sous la forme d'un tableau compposé comme ceci : |
|
36 | - * |
|
37 | - * Indice Signification |
|
38 | - * ---------------------- |
|
39 | - * 0 Evènement sur lequel se raccrocher (voir class/references_plugins.php::EVENT_ON_PRODUCT_CREATE |
|
40 | - * 1 Priorité du plugin (de 1 à 5) |
|
41 | - * 2 Script Php à inclure |
|
42 | - * 3 Classe à instancier |
|
43 | - * 4 Méthode à appeler |
|
44 | - */ |
|
45 | - $events = array(); |
|
46 | - $events[] = array( |
|
47 | - references_plugins::EVENT_ON_REFERENCE_CREATE, |
|
48 | - references_plugins::EVENT_PRIORITY_1, |
|
49 | - basename(__FILE__), |
|
50 | - __CLASS__, |
|
51 | - 'fireNewReference' |
|
52 | - ); |
|
53 | - $events[] = array( |
|
54 | - references_plugins::EVENT_ON_CATEGORY_CREATE, |
|
55 | - references_plugins::EVENT_PRIORITY_1, |
|
56 | - basename(__FILE__), |
|
57 | - __CLASS__, |
|
58 | - 'fireNewCategory' |
|
59 | - ); |
|
60 | - return $events; |
|
61 | - } |
|
32 | + public function registerEvents() |
|
33 | + { |
|
34 | + /** |
|
35 | + * La liste des évènements traités par le plugin se présente sous la forme d'un tableau compposé comme ceci : |
|
36 | + * |
|
37 | + * Indice Signification |
|
38 | + * ---------------------- |
|
39 | + * 0 Evènement sur lequel se raccrocher (voir class/references_plugins.php::EVENT_ON_PRODUCT_CREATE |
|
40 | + * 1 Priorité du plugin (de 1 à 5) |
|
41 | + * 2 Script Php à inclure |
|
42 | + * 3 Classe à instancier |
|
43 | + * 4 Méthode à appeler |
|
44 | + */ |
|
45 | + $events = array(); |
|
46 | + $events[] = array( |
|
47 | + references_plugins::EVENT_ON_REFERENCE_CREATE, |
|
48 | + references_plugins::EVENT_PRIORITY_1, |
|
49 | + basename(__FILE__), |
|
50 | + __CLASS__, |
|
51 | + 'fireNewReference' |
|
52 | + ); |
|
53 | + $events[] = array( |
|
54 | + references_plugins::EVENT_ON_CATEGORY_CREATE, |
|
55 | + references_plugins::EVENT_PRIORITY_1, |
|
56 | + basename(__FILE__), |
|
57 | + __CLASS__, |
|
58 | + 'fireNewCategory' |
|
59 | + ); |
|
60 | + return $events; |
|
61 | + } |
|
62 | 62 | |
63 | - /** |
|
64 | - * Méthode générique chargée d'envoyer un texte sur un compte twitter avec une url |
|
65 | - * |
|
66 | - * @param string $textToSend Le texte à envoyer |
|
67 | - * @param string $mask Le masque à utiliser |
|
68 | - * @param string $elementUrl L'url de l'élément concerné |
|
69 | - * @return string Le texte qui a été envoyé à twitter |
|
70 | - */ |
|
71 | - private function sendTextToTwitter($textToSend, $mask, $elementUrl) |
|
72 | - { |
|
73 | - if (!defined('REFERENCES_TWITTER_PLUGIN_PATH')) { |
|
74 | - define('REFERENCES_TWITTER_PLUGIN_PATH', REFERENCES_PLUGINS_PATH . 'actions' . DIRECTORY_SEPARATOR . 'twitter' . DIRECTORY_SEPARATOR); |
|
75 | - } |
|
76 | - require_once REFERENCES_TWITTER_PLUGIN_PATH . 'config.php'; |
|
77 | - //require_once REFERENCES_TWITTER_PLUGIN_PATH.'twitter.php'; |
|
78 | - require_once REFERENCES_TWITTER_PLUGIN_PATH . 'Twitter.class.php'; |
|
79 | - require_once REFERENCES_TWITTER_PLUGIN_PATH . 'bitly.class.php'; |
|
80 | - if (REFERENCES_BITLY_LOGIN == '') { |
|
81 | - return ''; |
|
82 | - } |
|
83 | - $sentText = ''; |
|
84 | - $bitly = new Bitly(REFERENCES_BITLY_LOGIN, REFERENCES_BITLY_API_KEY); |
|
85 | - $shortUrl = $bitly->shortenSingle($elementUrl); |
|
86 | - $searches = array('[itemname]', '[url]'); |
|
87 | - $replaces = array($textToSend, $shortUrl); |
|
88 | - $sentText = str_replace($searches, $replaces, $mask); |
|
89 | - $totalLength = strlen($sentText); |
|
90 | - if ($totalLength > REFERENCES_TWITTER_TWIT_MAX_LENGTH) { |
|
91 | - $tooLongOf = $totalLength - REFERENCES_TWITTER_TWIT_MAX_LENGTH; |
|
92 | - $searches = array('[itemname]', '[url]'); |
|
93 | - $replaces = array(substr($textToSend, 0, strlen($textToSend) - $tooLongOf), $shortUrl); |
|
94 | - $sentText = str_replace($searches, $replaces, $mask); |
|
95 | - } |
|
96 | - if (trim($sentText) != '') { |
|
97 | - // $twitter = new Twitter(REFERENCES_TWITTER_USERNAME, REFERENCES_TWITTER_PASSWORD); |
|
98 | - // $twitter->setUserAgent('references'); |
|
99 | - // $twitter->updateStatus($sentText); |
|
100 | - $tweet = new Twitter(REFERENCES_TWITTER_USERNAME, REFERENCES_TWITTER_PASSWORD); |
|
101 | - $tweet->update($sentText); |
|
102 | - } |
|
103 | - return $sentText; |
|
104 | - } |
|
63 | + /** |
|
64 | + * Méthode générique chargée d'envoyer un texte sur un compte twitter avec une url |
|
65 | + * |
|
66 | + * @param string $textToSend Le texte à envoyer |
|
67 | + * @param string $mask Le masque à utiliser |
|
68 | + * @param string $elementUrl L'url de l'élément concerné |
|
69 | + * @return string Le texte qui a été envoyé à twitter |
|
70 | + */ |
|
71 | + private function sendTextToTwitter($textToSend, $mask, $elementUrl) |
|
72 | + { |
|
73 | + if (!defined('REFERENCES_TWITTER_PLUGIN_PATH')) { |
|
74 | + define('REFERENCES_TWITTER_PLUGIN_PATH', REFERENCES_PLUGINS_PATH . 'actions' . DIRECTORY_SEPARATOR . 'twitter' . DIRECTORY_SEPARATOR); |
|
75 | + } |
|
76 | + require_once REFERENCES_TWITTER_PLUGIN_PATH . 'config.php'; |
|
77 | + //require_once REFERENCES_TWITTER_PLUGIN_PATH.'twitter.php'; |
|
78 | + require_once REFERENCES_TWITTER_PLUGIN_PATH . 'Twitter.class.php'; |
|
79 | + require_once REFERENCES_TWITTER_PLUGIN_PATH . 'bitly.class.php'; |
|
80 | + if (REFERENCES_BITLY_LOGIN == '') { |
|
81 | + return ''; |
|
82 | + } |
|
83 | + $sentText = ''; |
|
84 | + $bitly = new Bitly(REFERENCES_BITLY_LOGIN, REFERENCES_BITLY_API_KEY); |
|
85 | + $shortUrl = $bitly->shortenSingle($elementUrl); |
|
86 | + $searches = array('[itemname]', '[url]'); |
|
87 | + $replaces = array($textToSend, $shortUrl); |
|
88 | + $sentText = str_replace($searches, $replaces, $mask); |
|
89 | + $totalLength = strlen($sentText); |
|
90 | + if ($totalLength > REFERENCES_TWITTER_TWIT_MAX_LENGTH) { |
|
91 | + $tooLongOf = $totalLength - REFERENCES_TWITTER_TWIT_MAX_LENGTH; |
|
92 | + $searches = array('[itemname]', '[url]'); |
|
93 | + $replaces = array(substr($textToSend, 0, strlen($textToSend) - $tooLongOf), $shortUrl); |
|
94 | + $sentText = str_replace($searches, $replaces, $mask); |
|
95 | + } |
|
96 | + if (trim($sentText) != '') { |
|
97 | + // $twitter = new Twitter(REFERENCES_TWITTER_USERNAME, REFERENCES_TWITTER_PASSWORD); |
|
98 | + // $twitter->setUserAgent('references'); |
|
99 | + // $twitter->updateStatus($sentText); |
|
100 | + $tweet = new Twitter(REFERENCES_TWITTER_USERNAME, REFERENCES_TWITTER_PASSWORD); |
|
101 | + $tweet->update($sentText); |
|
102 | + } |
|
103 | + return $sentText; |
|
104 | + } |
|
105 | 105 | |
106 | - /** |
|
107 | - * Méthode appelée pour indiquer qu'une nouvelle référence a été publié |
|
108 | - * |
|
109 | - * @param object $parameters La référence qui vient d'être publiée |
|
110 | - * @return void |
|
111 | - */ |
|
112 | - public function fireNewReference($parameters) |
|
113 | - { |
|
114 | - if (!defined('REFERENCES_TWITTER_PLUGIN_PATH')) { |
|
115 | - define('REFERENCES_TWITTER_PLUGIN_PATH', REFERENCES_PLUGINS_PATH . 'actions' . DIRECTORY_SEPARATOR . 'twitter' . DIRECTORY_SEPARATOR); |
|
116 | - } |
|
117 | - require_once REFERENCES_TWITTER_PLUGIN_PATH . 'config.php'; |
|
118 | - $reference = $parameters['reference']; |
|
119 | - $this->sendTextToTwitter(utf8_encode($reference->getVar('article_title', 'n')), utf8_encode(REFERENCES_TWITTER_NEW_REFERENCE_INTRO), $reference->getUrl()); |
|
120 | - } |
|
106 | + /** |
|
107 | + * Méthode appelée pour indiquer qu'une nouvelle référence a été publié |
|
108 | + * |
|
109 | + * @param object $parameters La référence qui vient d'être publiée |
|
110 | + * @return void |
|
111 | + */ |
|
112 | + public function fireNewReference($parameters) |
|
113 | + { |
|
114 | + if (!defined('REFERENCES_TWITTER_PLUGIN_PATH')) { |
|
115 | + define('REFERENCES_TWITTER_PLUGIN_PATH', REFERENCES_PLUGINS_PATH . 'actions' . DIRECTORY_SEPARATOR . 'twitter' . DIRECTORY_SEPARATOR); |
|
116 | + } |
|
117 | + require_once REFERENCES_TWITTER_PLUGIN_PATH . 'config.php'; |
|
118 | + $reference = $parameters['reference']; |
|
119 | + $this->sendTextToTwitter(utf8_encode($reference->getVar('article_title', 'n')), utf8_encode(REFERENCES_TWITTER_NEW_REFERENCE_INTRO), $reference->getUrl()); |
|
120 | + } |
|
121 | 121 | |
122 | - /** |
|
123 | - * Méthode appelée pour indiquer qu'une nouvelle catégorie de références a été créée |
|
124 | - * |
|
125 | - * @param object $parameters La catégorie qui vient d'être publiée |
|
126 | - * @return void |
|
127 | - */ |
|
128 | - public function fireNewCategory($parameters) |
|
129 | - { |
|
130 | - if (!defined('REFERENCES_TWITTER_PLUGIN_PATH')) { |
|
131 | - define('REFERENCES_TWITTER_PLUGIN_PATH', REFERENCES_PLUGINS_PATH . 'actions' . DIRECTORY_SEPARATOR . 'twitter' . DIRECTORY_SEPARATOR); |
|
132 | - } |
|
133 | - require_once REFERENCES_TWITTER_PLUGIN_PATH . 'config.php'; |
|
134 | - if (trim(REFERENCES_TWITTER_NEW_CATEGORY_INTRO) != '') { |
|
135 | - $category = $parameters['category']; |
|
136 | - $this->sendTextToTwitter(utf8_encode($category->getVar('category_title', 'n')), utf8_encode(REFERENCES_TWITTER_NEW_CATEGORY_INTRO), $category->getUrl()); |
|
137 | - } |
|
138 | - } |
|
122 | + /** |
|
123 | + * Méthode appelée pour indiquer qu'une nouvelle catégorie de références a été créée |
|
124 | + * |
|
125 | + * @param object $parameters La catégorie qui vient d'être publiée |
|
126 | + * @return void |
|
127 | + */ |
|
128 | + public function fireNewCategory($parameters) |
|
129 | + { |
|
130 | + if (!defined('REFERENCES_TWITTER_PLUGIN_PATH')) { |
|
131 | + define('REFERENCES_TWITTER_PLUGIN_PATH', REFERENCES_PLUGINS_PATH . 'actions' . DIRECTORY_SEPARATOR . 'twitter' . DIRECTORY_SEPARATOR); |
|
132 | + } |
|
133 | + require_once REFERENCES_TWITTER_PLUGIN_PATH . 'config.php'; |
|
134 | + if (trim(REFERENCES_TWITTER_NEW_CATEGORY_INTRO) != '') { |
|
135 | + $category = $parameters['category']; |
|
136 | + $this->sendTextToTwitter(utf8_encode($category->getVar('category_title', 'n')), utf8_encode(REFERENCES_TWITTER_NEW_CATEGORY_INTRO), $category->getUrl()); |
|
137 | + } |
|
138 | + } |
|
139 | 139 | } |
@@ -71,12 +71,12 @@ discard block |
||
71 | 71 | private function sendTextToTwitter($textToSend, $mask, $elementUrl) |
72 | 72 | { |
73 | 73 | if (!defined('REFERENCES_TWITTER_PLUGIN_PATH')) { |
74 | - define('REFERENCES_TWITTER_PLUGIN_PATH', REFERENCES_PLUGINS_PATH . 'actions' . DIRECTORY_SEPARATOR . 'twitter' . DIRECTORY_SEPARATOR); |
|
74 | + define('REFERENCES_TWITTER_PLUGIN_PATH', REFERENCES_PLUGINS_PATH.'actions'.DIRECTORY_SEPARATOR.'twitter'.DIRECTORY_SEPARATOR); |
|
75 | 75 | } |
76 | - require_once REFERENCES_TWITTER_PLUGIN_PATH . 'config.php'; |
|
76 | + require_once REFERENCES_TWITTER_PLUGIN_PATH.'config.php'; |
|
77 | 77 | //require_once REFERENCES_TWITTER_PLUGIN_PATH.'twitter.php'; |
78 | - require_once REFERENCES_TWITTER_PLUGIN_PATH . 'Twitter.class.php'; |
|
79 | - require_once REFERENCES_TWITTER_PLUGIN_PATH . 'bitly.class.php'; |
|
78 | + require_once REFERENCES_TWITTER_PLUGIN_PATH.'Twitter.class.php'; |
|
79 | + require_once REFERENCES_TWITTER_PLUGIN_PATH.'bitly.class.php'; |
|
80 | 80 | if (REFERENCES_BITLY_LOGIN == '') { |
81 | 81 | return ''; |
82 | 82 | } |
@@ -112,9 +112,9 @@ discard block |
||
112 | 112 | public function fireNewReference($parameters) |
113 | 113 | { |
114 | 114 | if (!defined('REFERENCES_TWITTER_PLUGIN_PATH')) { |
115 | - define('REFERENCES_TWITTER_PLUGIN_PATH', REFERENCES_PLUGINS_PATH . 'actions' . DIRECTORY_SEPARATOR . 'twitter' . DIRECTORY_SEPARATOR); |
|
115 | + define('REFERENCES_TWITTER_PLUGIN_PATH', REFERENCES_PLUGINS_PATH.'actions'.DIRECTORY_SEPARATOR.'twitter'.DIRECTORY_SEPARATOR); |
|
116 | 116 | } |
117 | - require_once REFERENCES_TWITTER_PLUGIN_PATH . 'config.php'; |
|
117 | + require_once REFERENCES_TWITTER_PLUGIN_PATH.'config.php'; |
|
118 | 118 | $reference = $parameters['reference']; |
119 | 119 | $this->sendTextToTwitter(utf8_encode($reference->getVar('article_title', 'n')), utf8_encode(REFERENCES_TWITTER_NEW_REFERENCE_INTRO), $reference->getUrl()); |
120 | 120 | } |
@@ -128,9 +128,9 @@ discard block |
||
128 | 128 | public function fireNewCategory($parameters) |
129 | 129 | { |
130 | 130 | if (!defined('REFERENCES_TWITTER_PLUGIN_PATH')) { |
131 | - define('REFERENCES_TWITTER_PLUGIN_PATH', REFERENCES_PLUGINS_PATH . 'actions' . DIRECTORY_SEPARATOR . 'twitter' . DIRECTORY_SEPARATOR); |
|
131 | + define('REFERENCES_TWITTER_PLUGIN_PATH', REFERENCES_PLUGINS_PATH.'actions'.DIRECTORY_SEPARATOR.'twitter'.DIRECTORY_SEPARATOR); |
|
132 | 132 | } |
133 | - require_once REFERENCES_TWITTER_PLUGIN_PATH . 'config.php'; |
|
133 | + require_once REFERENCES_TWITTER_PLUGIN_PATH.'config.php'; |
|
134 | 134 | if (trim(REFERENCES_TWITTER_NEW_CATEGORY_INTRO) != '') { |
135 | 135 | $category = $parameters['category']; |
136 | 136 | $this->sendTextToTwitter(utf8_encode($category->getVar('category_title', 'n')), utf8_encode(REFERENCES_TWITTER_NEW_CATEGORY_INTRO), $category->getUrl()); |
@@ -25,49 +25,49 @@ |
||
25 | 25 | */ |
26 | 26 | class referencesNewreferenceAction extends references_action |
27 | 27 | { |
28 | - public function registerEvents() |
|
29 | - { |
|
30 | - /** |
|
31 | - * La liste des évènements traités par le plugin se présente sous la forme d'un tableau compposé comme ceci : |
|
32 | - * |
|
33 | - * Indice Signification |
|
34 | - * ---------------------- |
|
35 | - * 0 Evènement sur lequel se raccrocher (voir class/references_plugins.php::EVENT_ON_PRODUCT_CREATE |
|
36 | - * 1 Priorité du plugin (de 1 à 5) |
|
37 | - * 2 Script Php à inclure |
|
38 | - * 3 Classe à instancier |
|
39 | - * 4 Méthode à appeler |
|
40 | - */ |
|
41 | - $events = array(); |
|
42 | - $events[] = array( |
|
43 | - references_plugins::EVENT_ON_REFERENCE_CREATE, |
|
44 | - references_plugins::EVENT_PRIORITY_1, |
|
45 | - basename(__FILE__), |
|
46 | - __CLASS__, |
|
47 | - 'fireNewReference' |
|
48 | - ); |
|
28 | + public function registerEvents() |
|
29 | + { |
|
30 | + /** |
|
31 | + * La liste des évènements traités par le plugin se présente sous la forme d'un tableau compposé comme ceci : |
|
32 | + * |
|
33 | + * Indice Signification |
|
34 | + * ---------------------- |
|
35 | + * 0 Evènement sur lequel se raccrocher (voir class/references_plugins.php::EVENT_ON_PRODUCT_CREATE |
|
36 | + * 1 Priorité du plugin (de 1 à 5) |
|
37 | + * 2 Script Php à inclure |
|
38 | + * 3 Classe à instancier |
|
39 | + * 4 Méthode à appeler |
|
40 | + */ |
|
41 | + $events = array(); |
|
42 | + $events[] = array( |
|
43 | + references_plugins::EVENT_ON_REFERENCE_CREATE, |
|
44 | + references_plugins::EVENT_PRIORITY_1, |
|
45 | + basename(__FILE__), |
|
46 | + __CLASS__, |
|
47 | + 'fireNewReference' |
|
48 | + ); |
|
49 | 49 | |
50 | - return $events; |
|
51 | - } |
|
50 | + return $events; |
|
51 | + } |
|
52 | 52 | |
53 | - /** |
|
54 | - * Méthode appelée pour indiquer qu'une nouvelle référence a été créée |
|
55 | - * |
|
56 | - * @param object $parameters La référence qui vient d'être publiée |
|
57 | - * @return void |
|
58 | - */ |
|
59 | - public function fireNewReference($parameters) |
|
60 | - { |
|
61 | - $article = $parameters['reference']; |
|
62 | - $notification_handler = xoops_getHandler('notification'); |
|
63 | - $articleForTemplate = array(); |
|
64 | - $originalArticle = $article->toArray('n'); |
|
53 | + /** |
|
54 | + * Méthode appelée pour indiquer qu'une nouvelle référence a été créée |
|
55 | + * |
|
56 | + * @param object $parameters La référence qui vient d'être publiée |
|
57 | + * @return void |
|
58 | + */ |
|
59 | + public function fireNewReference($parameters) |
|
60 | + { |
|
61 | + $article = $parameters['reference']; |
|
62 | + $notification_handler = xoops_getHandler('notification'); |
|
63 | + $articleForTemplate = array(); |
|
64 | + $originalArticle = $article->toArray('n'); |
|
65 | 65 | |
66 | - foreach ($originalArticle as $key => $value) { |
|
67 | - @$articleForTemplate[strtoupper($key)] = strip_tags($value); |
|
68 | - } |
|
69 | - $articleForTemplate['REFERENCES_URL'] = $article->getUrl(); |
|
70 | - $articleForTemplate['ARTICLE_SHORT_TEXT'] = references_utils::truncate_tagsafe($article->getVar('article_text'), REFERENCES_SHORTEN_TEXT); |
|
71 | - $notification_handler->triggerEvent('global', 0, 'new_article', $articleForTemplate); |
|
72 | - } |
|
66 | + foreach ($originalArticle as $key => $value) { |
|
67 | + @$articleForTemplate[strtoupper($key)] = strip_tags($value); |
|
68 | + } |
|
69 | + $articleForTemplate['REFERENCES_URL'] = $article->getUrl(); |
|
70 | + $articleForTemplate['ARTICLE_SHORT_TEXT'] = references_utils::truncate_tagsafe($article->getVar('article_text'), REFERENCES_SHORTEN_TEXT); |
|
71 | + $notification_handler->triggerEvent('global', 0, 'new_article', $articleForTemplate); |
|
72 | + } |
|
73 | 73 | } |
@@ -23,14 +23,14 @@ |
||
23 | 23 | * Every action plugin must extend this class |
24 | 24 | */ |
25 | 25 | if (!defined('XOOPS_ROOT_PATH')) { |
26 | - die('XOOPS root path not defined'); |
|
26 | + die('XOOPS root path not defined'); |
|
27 | 27 | } |
28 | 28 | |
29 | 29 | abstract class references_action |
30 | 30 | { |
31 | - /** |
|
32 | - * Retourne la liste des évènements traités par le plugin |
|
33 | - * @return array |
|
34 | - */ |
|
35 | - abstract public function registerEvents(); |
|
31 | + /** |
|
32 | + * Retourne la liste des évènements traités par le plugin |
|
33 | + * @return array |
|
34 | + */ |
|
35 | + abstract public function registerEvents(); |
|
36 | 36 | } |
@@ -23,14 +23,14 @@ |
||
23 | 23 | * Every filter plugin must extend this class |
24 | 24 | */ |
25 | 25 | if (!defined('XOOPS_ROOT_PATH')) { |
26 | - die('XOOPS root path not defined'); |
|
26 | + die('XOOPS root path not defined'); |
|
27 | 27 | } |
28 | 28 | |
29 | 29 | abstract class references_filter |
30 | 30 | { |
31 | - /** |
|
32 | - * Retourne la liste des évènements traités par le plugin |
|
33 | - * @return array |
|
34 | - */ |
|
35 | - abstract public function registerEvents(); |
|
31 | + /** |
|
32 | + * Retourne la liste des évènements traités par le plugin |
|
33 | + * @return array |
|
34 | + */ |
|
35 | + abstract public function registerEvents(); |
|
36 | 36 | } |
@@ -20,16 +20,16 @@ |
||
20 | 20 | */ |
21 | 21 | function b_sitemap_references() |
22 | 22 | { |
23 | - require XOOPS_ROOT_PATH . '/modules/references/include/common.php'; |
|
24 | - $sitemap = array(); |
|
25 | - $categories = $h_references_categories->getCategories(); |
|
26 | - $i = 0; |
|
27 | - foreach ($categories as $category) { |
|
28 | - $sitemap['parent'][$i]['id'] = $category->getVar('category_id'); |
|
29 | - $sitemap['parent'][$i]['title'] = $category->getVar('category_title'); |
|
30 | - $sitemap['parent'][$i]['url'] = $category->getUrl(true); |
|
31 | - ++$i; |
|
32 | - } |
|
23 | + require XOOPS_ROOT_PATH . '/modules/references/include/common.php'; |
|
24 | + $sitemap = array(); |
|
25 | + $categories = $h_references_categories->getCategories(); |
|
26 | + $i = 0; |
|
27 | + foreach ($categories as $category) { |
|
28 | + $sitemap['parent'][$i]['id'] = $category->getVar('category_id'); |
|
29 | + $sitemap['parent'][$i]['title'] = $category->getVar('category_title'); |
|
30 | + $sitemap['parent'][$i]['url'] = $category->getUrl(true); |
|
31 | + ++$i; |
|
32 | + } |
|
33 | 33 | |
34 | - return $sitemap; |
|
34 | + return $sitemap; |
|
35 | 35 | } |
@@ -20,7 +20,7 @@ |
||
20 | 20 | */ |
21 | 21 | function b_sitemap_references() |
22 | 22 | { |
23 | - require XOOPS_ROOT_PATH . '/modules/references/include/common.php'; |
|
23 | + require XOOPS_ROOT_PATH.'/modules/references/include/common.php'; |
|
24 | 24 | $sitemap = array(); |
25 | 25 | $categories = $h_references_categories->getCategories(); |
26 | 26 | $i = 0; |
@@ -19,53 +19,53 @@ |
||
19 | 19 | * **************************************************************************** |
20 | 20 | */ |
21 | 21 | if (!defined('RSSFIT_ROOT_PATH')) { |
22 | - exit(); |
|
22 | + exit(); |
|
23 | 23 | } |
24 | 24 | |
25 | 25 | class RssfitReferences |
26 | 26 | { |
27 | - public $dirname = 'references'; |
|
28 | - public $modname; |
|
29 | - public $grab; |
|
27 | + public $dirname = 'references'; |
|
28 | + public $modname; |
|
29 | + public $grab; |
|
30 | 30 | |
31 | - public function __construct() |
|
32 | - { |
|
33 | - } |
|
31 | + public function __construct() |
|
32 | + { |
|
33 | + } |
|
34 | 34 | |
35 | - public function loadModule() |
|
36 | - { |
|
37 | - $mod =& $GLOBALS['module_handler']->getByDirname($this->dirname); |
|
38 | - if (!$mod || !$mod->getVar('isactive')) { |
|
39 | - return false; |
|
40 | - } |
|
41 | - $this->modname = $mod->getVar('name'); |
|
35 | + public function loadModule() |
|
36 | + { |
|
37 | + $mod =& $GLOBALS['module_handler']->getByDirname($this->dirname); |
|
38 | + if (!$mod || !$mod->getVar('isactive')) { |
|
39 | + return false; |
|
40 | + } |
|
41 | + $this->modname = $mod->getVar('name'); |
|
42 | 42 | |
43 | - return $mod; |
|
44 | - } |
|
43 | + return $mod; |
|
44 | + } |
|
45 | 45 | |
46 | - public function &grabEntries(&$obj) |
|
47 | - { |
|
48 | - $ret = false; |
|
49 | - require XOOPS_ROOT_PATH . '/modules/references/include/common.php'; |
|
50 | - $start = 0; |
|
51 | - $limit = $this->grab; |
|
52 | - $items = $h_references_articles->getRecentArticles($start, $limit); |
|
53 | - $i = 0; |
|
54 | - $categories = $h_references_categories->getCategories(); |
|
46 | + public function &grabEntries(&$obj) |
|
47 | + { |
|
48 | + $ret = false; |
|
49 | + require XOOPS_ROOT_PATH . '/modules/references/include/common.php'; |
|
50 | + $start = 0; |
|
51 | + $limit = $this->grab; |
|
52 | + $items = $h_references_articles->getRecentArticles($start, $limit); |
|
53 | + $i = 0; |
|
54 | + $categories = $h_references_categories->getCategories(); |
|
55 | 55 | |
56 | - if (false != $items && count($items) > 0) { |
|
57 | - foreach ($items as $item) { |
|
58 | - $ret[$i]['link'] = $item->getUrl(); |
|
59 | - $ret[$i]['title'] = $item->getVar('article_title'); |
|
60 | - $ret[$i]['timestamp'] = $item->getVar('article_timestamp'); |
|
61 | - $ret[$i]['description'] = references_utils::truncate_tagsafe($item->getVar('article_text'), REFERENCES_SHORTEN_TEXT); |
|
62 | - $categoryId = $item->getVar('article_category_id'); |
|
63 | - $ret[$i]['category'] = isset($categories[$categoryId]) ? $categories[$categoryId]->getVar('category_title') : ''; |
|
64 | - $ret[$i]['domain'] = XOOPS_URL . '/modules/' . $this->dirname . '/'; |
|
65 | - ++$i; |
|
66 | - } |
|
67 | - } |
|
56 | + if (false != $items && count($items) > 0) { |
|
57 | + foreach ($items as $item) { |
|
58 | + $ret[$i]['link'] = $item->getUrl(); |
|
59 | + $ret[$i]['title'] = $item->getVar('article_title'); |
|
60 | + $ret[$i]['timestamp'] = $item->getVar('article_timestamp'); |
|
61 | + $ret[$i]['description'] = references_utils::truncate_tagsafe($item->getVar('article_text'), REFERENCES_SHORTEN_TEXT); |
|
62 | + $categoryId = $item->getVar('article_category_id'); |
|
63 | + $ret[$i]['category'] = isset($categories[$categoryId]) ? $categories[$categoryId]->getVar('category_title') : ''; |
|
64 | + $ret[$i]['domain'] = XOOPS_URL . '/modules/' . $this->dirname . '/'; |
|
65 | + ++$i; |
|
66 | + } |
|
67 | + } |
|
68 | 68 | |
69 | - return $ret; |
|
70 | - } |
|
69 | + return $ret; |
|
70 | + } |
|
71 | 71 | } |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | |
35 | 35 | public function loadModule() |
36 | 36 | { |
37 | - $mod =& $GLOBALS['module_handler']->getByDirname($this->dirname); |
|
37 | + $mod = & $GLOBALS['module_handler']->getByDirname($this->dirname); |
|
38 | 38 | if (!$mod || !$mod->getVar('isactive')) { |
39 | 39 | return false; |
40 | 40 | } |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | public function &grabEntries(&$obj) |
47 | 47 | { |
48 | 48 | $ret = false; |
49 | - require XOOPS_ROOT_PATH . '/modules/references/include/common.php'; |
|
49 | + require XOOPS_ROOT_PATH.'/modules/references/include/common.php'; |
|
50 | 50 | $start = 0; |
51 | 51 | $limit = $this->grab; |
52 | 52 | $items = $h_references_articles->getRecentArticles($start, $limit); |
@@ -61,7 +61,7 @@ discard block |
||
61 | 61 | $ret[$i]['description'] = references_utils::truncate_tagsafe($item->getVar('article_text'), REFERENCES_SHORTEN_TEXT); |
62 | 62 | $categoryId = $item->getVar('article_category_id'); |
63 | 63 | $ret[$i]['category'] = isset($categories[$categoryId]) ? $categories[$categoryId]->getVar('category_title') : ''; |
64 | - $ret[$i]['domain'] = XOOPS_URL . '/modules/' . $this->dirname . '/'; |
|
64 | + $ret[$i]['domain'] = XOOPS_URL.'/modules/'.$this->dirname.'/'; |
|
65 | 65 | ++$i; |
66 | 66 | } |
67 | 67 | } |
@@ -15,11 +15,11 @@ discard block |
||
15 | 15 | // Define your mapping here |
16 | 16 | // ########################################################## |
17 | 17 | $patterns = array( // first one must be module directory name |
18 | - 'references' => 'clients', |
|
19 | - 'REFERENCES' => 'CLIENTS', |
|
20 | - 'References' => 'Clients', |
|
21 | - 'References' => 'Clients', |
|
22 | - 'Reference' => 'Client' |
|
18 | + 'references' => 'clients', |
|
19 | + 'REFERENCES' => 'CLIENTS', |
|
20 | + 'References' => 'Clients', |
|
21 | + 'References' => 'Clients', |
|
22 | + 'Reference' => 'Client' |
|
23 | 23 | ); |
24 | 24 | |
25 | 25 | $excludedFiles = array('PersistableObjectHandler.php'); |
@@ -28,52 +28,52 @@ discard block |
||
28 | 28 | |
29 | 29 | // work around for PHP < 5.0.x |
30 | 30 | if (!function_exists('file_put_contents')) { |
31 | - function file_put_contents($filename, $data, $file_append = false) |
|
32 | - { |
|
33 | - $fp = fopen($filename, (!$file_append ? 'w+' : 'a+')); |
|
34 | - if (!$fp) { |
|
35 | - trigger_error('file_put_contents cannot write in file.', E_USER_ERROR); |
|
31 | + function file_put_contents($filename, $data, $file_append = false) |
|
32 | + { |
|
33 | + $fp = fopen($filename, (!$file_append ? 'w+' : 'a+')); |
|
34 | + if (!$fp) { |
|
35 | + trigger_error('file_put_contents cannot write in file.', E_USER_ERROR); |
|
36 | 36 | |
37 | - return; |
|
38 | - } |
|
39 | - fwrite($fp, $data); |
|
40 | - fclose($fp); |
|
41 | - } |
|
37 | + return; |
|
38 | + } |
|
39 | + fwrite($fp, $data); |
|
40 | + fclose($fp); |
|
41 | + } |
|
42 | 42 | } |
43 | 43 | |
44 | 44 | // recursive clonning script |
45 | 45 | function cloneFileFolder($path) |
46 | 46 | { |
47 | - global $patKeys, $patValues, $excludedFiles; |
|
47 | + global $patKeys, $patValues, $excludedFiles; |
|
48 | 48 | |
49 | - $newPath = str_replace($patKeys[0], $patValues[0], $path); |
|
50 | - if (isset($patKeys[5]) && isset($patValues[5])) { |
|
51 | - $newPath = str_replace($patKeys[5], $patValues[5], $newPath); |
|
52 | - } |
|
49 | + $newPath = str_replace($patKeys[0], $patValues[0], $path); |
|
50 | + if (isset($patKeys[5]) && isset($patValues[5])) { |
|
51 | + $newPath = str_replace($patKeys[5], $patValues[5], $newPath); |
|
52 | + } |
|
53 | 53 | |
54 | - if (is_dir($path)) { |
|
55 | - // create new dir |
|
56 | - mkdir($newPath); |
|
54 | + if (is_dir($path)) { |
|
55 | + // create new dir |
|
56 | + mkdir($newPath); |
|
57 | 57 | |
58 | - // check all files in dir, and process it |
|
59 | - if ($handle = opendir($path)) { |
|
60 | - while ($file = readdir($handle)) { |
|
61 | - if ($file !== '.' && $file !== '..') { |
|
62 | - cloneFileFolder("$path/$file"); |
|
63 | - } |
|
64 | - } |
|
65 | - closedir($handle); |
|
66 | - } |
|
67 | - } else { |
|
68 | - if (preg_match('/(.jpg|.gif|.png|.zip|.swf)$/i', $path) || in_array($path, $excludedFiles)) { |
|
69 | - copy($path, $newPath); |
|
70 | - } else { |
|
71 | - // file, read it |
|
72 | - $content = file_get_contents($path); |
|
73 | - $content = str_replace($patKeys, $patValues, $content); |
|
74 | - file_put_contents($newPath, $content); |
|
75 | - } |
|
76 | - } |
|
58 | + // check all files in dir, and process it |
|
59 | + if ($handle = opendir($path)) { |
|
60 | + while ($file = readdir($handle)) { |
|
61 | + if ($file !== '.' && $file !== '..') { |
|
62 | + cloneFileFolder("$path/$file"); |
|
63 | + } |
|
64 | + } |
|
65 | + closedir($handle); |
|
66 | + } |
|
67 | + } else { |
|
68 | + if (preg_match('/(.jpg|.gif|.png|.zip|.swf)$/i', $path) || in_array($path, $excludedFiles)) { |
|
69 | + copy($path, $newPath); |
|
70 | + } else { |
|
71 | + // file, read it |
|
72 | + $content = file_get_contents($path); |
|
73 | + $content = str_replace($patKeys, $patValues, $content); |
|
74 | + file_put_contents($newPath, $content); |
|
75 | + } |
|
76 | + } |
|
77 | 77 | } |
78 | 78 | |
79 | 79 | cloneFileFolder('modules/references'); |
@@ -79,5 +79,5 @@ |
||
79 | 79 | cloneFileFolder('modules/references'); |
80 | 80 | |
81 | 81 | echo "Happy cloning...\n"; |
82 | -echo 'check directory modules/' . $patterns['references'] . " for cloned module \n"; |
|
82 | +echo 'check directory modules/'.$patterns['references']." for cloned module \n"; |
|
83 | 83 | echo "Consider modifying new module by editing language/english/modinfo.php and assets/images/catads2-4.png manually (if you care)\n"; |
@@ -18,5 +18,5 @@ |
||
18 | 18 | * |
19 | 19 | * **************************************************************************** |
20 | 20 | */ |
21 | -require __DIR__ . '/header.php'; |
|
22 | -require XOOPS_ROOT_PATH . '/modules/tag/view.tag.php'; |
|
21 | +require __DIR__.'/header.php'; |
|
22 | +require XOOPS_ROOT_PATH.'/modules/tag/view.tag.php'; |