Skip to content

Commit

Permalink
finalisation social
Browse files Browse the repository at this point in the history
  • Loading branch information
GregMage committed Dec 28, 2020
1 parent 8390af2 commit 7367c64
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 16 deletions.
64 changes: 50 additions & 14 deletions class/utility.php
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down Expand Up @@ -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');
Expand All @@ -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';
Expand All @@ -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';
Expand All @@ -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';
Expand Down Expand Up @@ -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';
Expand Down Expand Up @@ -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';
Expand All @@ -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();
Expand All @@ -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;
}
}
7 changes: 7 additions & 0 deletions extra/Templates for bootstrap 4/xmsocial/xmsocial_social.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<div class="row">
<{foreach item=itemsocial from=$social_arr}>
<div class="col-6 col-md-4 col-lg-3">
<{$itemsocial}>
</div>
<{/foreach}>
</div>
7 changes: 7 additions & 0 deletions templates/xmsocial_social.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<div class="row">
<{foreach item=itemsocial from=$social_arr}>
<div class="col-xs-6 col-sm-4 col-md-3">
<{$itemsocial}>
</div>
<{/foreach}>
</div>
3 changes: 1 addition & 2 deletions xoops_version.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit 7367c64

Please sign in to comment.