From 7367c647e7dd25909926b20200bf332d1a4a99a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9gory=20Mage?= Date: Mon, 28 Dec 2020 14:59:47 +0100 Subject: [PATCH] finalisation social --- class/utility.php | 64 +++++++++++++++---- .../xmsocial/xmsocial_social.tpl | 7 ++ templates/xmsocial_social.tpl | 7 ++ xoops_version.php | 3 +- 4 files changed, 65 insertions(+), 16 deletions(-) create mode 100644 extra/Templates for bootstrap 4/xmsocial/xmsocial_social.tpl create mode 100644 templates/xmsocial_social.tpl diff --git a/class/utility.php b/class/utility.php index 4ba0e0a..d2045e7 100644 --- a/class/utility.php +++ b/class/utility.php @@ -18,10 +18,10 @@ * @author Mage Gregory (AKA Mage) */ use Xmf\Module\Helper; + /** * Class XmsocialUtility */ - class XmsocialUtility{ public static function renderRating($xoTheme, $modulename = '', $itemid = 0, $stars = 5, $rating = 0, $votes = 0, $options = array()) @@ -59,7 +59,12 @@ public static function renderRating($xoTheme, $modulename = '', $itemid = 0, $st return $xmsocial_rating; } - + + /** + * @param int $rating + * @param int $votes + * @return string + */ public static function renderVotes($rating = 0, $votes = 0) { $xmsocialHelper = Helper::getHelper('xmsocial'); @@ -73,7 +78,13 @@ public static function renderVotes($rating = 0, $votes = 0) return $xmsocial_rating; } - + + /** + * @param $modulename + * @param $itemid + * @param $moduleid + * @return bool + */ public static function updateRating($modulename, $itemid, $moduleid) { include __DIR__ . '/../include/common.php'; @@ -99,7 +110,12 @@ public static function updateRating($modulename, $itemid, $moduleid) return false; } } - + + /** + * @param string $modulename + * @param int $itemid + * @return string + */ public static function delRatingdata($modulename = '', $itemid = 0) { include __DIR__ . '/../include/common.php'; @@ -113,7 +129,13 @@ public static function delRatingdata($modulename = '', $itemid = 0) $error_message = $ratingHandler->deleteAll($criteria); return $error_message; } - + + /** + * @param $form + * @param string $modulename + * @param int $itemid + * @return mixed + */ public static function renderSocialForm($form, $modulename = '', $itemid = 0) { include __DIR__ . '/../include/common.php'; @@ -154,6 +176,11 @@ public static function renderSocialForm($form, $modulename = '', $itemid = 0) return $form; } + /** + * @param string $modulename + * @param int $itemid + * @return string + */ public static function saveSocial($modulename = '', $itemid = 0) { include __DIR__ . '/../include/common.php'; @@ -208,7 +235,12 @@ public static function saveSocial($modulename = '', $itemid = 0) } return $error_message; } - + + /** + * @param string $modulename + * @param int $itemid + * @return string + */ public static function delSocialdata($modulename = '', $itemid = 0) { include __DIR__ . '/../include/common.php'; @@ -222,13 +254,18 @@ public static function delSocialdata($modulename = '', $itemid = 0) $error_message = $socialdataHandler->deleteAll($criteria); return $error_message; } - - public static function renderSocial($modulename = '', $itemid = 0, $url = '') + + /** + * @param $xoopsTpl + * @param string $modulename + * @param int $itemid + * @param string $url + */ + public static function renderSocial($xoopsTpl, $modulename = '', $itemid = 0, $url = '') { include __DIR__ . '/../include/common.php'; xoops_load('SocialPlugin', basename(dirname(__DIR__))); - $error_message = ''; - + $helper = Helper::getHelper($modulename); $moduleid = $helper->getModule()->getVar('mid'); $criteria = new CriteriaCompo(); @@ -242,15 +279,14 @@ public static function renderSocial($modulename = '', $itemid = 0, $url = '') $socialdataHandler->field_link = "social_id"; $socialdataHandler->field_object = "socialdata_socialid"; $social_arr = $socialdataHandler->getByLink($criteria); - $social = ''; if (count($social_arr) > 0) { $SocialPlugin = new SocialPlugin(); - foreach (array_keys($social_arr) as $i) { $options = explode(',', $social_arr[$i]->getVar('social_options')); - $social .= $SocialPlugin->render($social_arr[$i]->getVar('social_type'), $url, $options); + $social = $SocialPlugin->render($social_arr[$i]->getVar('social_type'), $url, $options); + $xoopsTpl->append_by_ref('social_arr', $social); + unset($social); } } - return $social; } } diff --git a/extra/Templates for bootstrap 4/xmsocial/xmsocial_social.tpl b/extra/Templates for bootstrap 4/xmsocial/xmsocial_social.tpl new file mode 100644 index 0000000..d62c13e --- /dev/null +++ b/extra/Templates for bootstrap 4/xmsocial/xmsocial_social.tpl @@ -0,0 +1,7 @@ +
+<{foreach item=itemsocial from=$social_arr}> +
+ <{$itemsocial}> +
+<{/foreach}> +
\ No newline at end of file diff --git a/templates/xmsocial_social.tpl b/templates/xmsocial_social.tpl new file mode 100644 index 0000000..38837c0 --- /dev/null +++ b/templates/xmsocial_social.tpl @@ -0,0 +1,7 @@ +
+<{foreach item=itemsocial from=$social_arr}> +
+ <{$itemsocial}> +
+<{/foreach}> +
\ No newline at end of file diff --git a/xoops_version.php b/xoops_version.php index 38164e3..a718dda 100644 --- a/xoops_version.php +++ b/xoops_version.php @@ -58,8 +58,7 @@ // User Templates $modversion['templates'][] = array('file' => 'xmsocial_rating.tpl', 'description' => ''); - - +$modversion['templates'][] = array('file' => 'xmsocial_social.tpl', 'description' => ''); // Configs $modversion['config'] = array();