Skip to content

Commit 9443d12

Browse files
committed
trello start
1 parent e54f1bd commit 9443d12

File tree

10 files changed

+338
-3
lines changed

10 files changed

+338
-3
lines changed

admin/menu.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
$moduleDirName = basename(dirname(__DIR__));
2727
$moduleDirNameUpper = mb_strtoupper($moduleDirName);
2828

29-
/** @var Publisher\Helper $helper */
3029
$helper = Publisher\Helper::getInstance();
3130
$helper->loadLanguage('common');
3231
$helper->loadLanguage('feedback');
@@ -61,6 +60,15 @@
6160
'link' => 'admin/item.php',
6261
'icon' => $pathIcon32 . '/content.png',
6362
];
63+
64+
// Trello
65+
$adminmenu[] = [
66+
'title' => _MI_PUBLISHER_ADMENU7,
67+
'link' => 'admin/trello.php',
68+
'icon' => $pathIcon32 . '/extention.png',
69+
];
70+
71+
6472
// Permissions
6573
$adminmenu[] = [
6674
'title' => _MI_PUBLISHER_ADMENU4,

admin/trello.php

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<?php declare(strict_types=1);
2+
3+
use Xmf\Request;
4+
use XoopsModules\Publisher;
5+
use XoopsModules\Publisher\Constants;
6+
use XoopsModules\Publisher\TrelloManagement;
7+
8+
$GLOBALS['xoopsOption']['template_main'] = 'publisher_trello.tpl';
9+
require_once __DIR__ . '/admin_header.php';
10+
11+
xoops_cp_header();
12+
13+
$adminObject->displayNavigation(basename(__FILE__));
14+
15+
$statusArray = [
16+
Constants::PUBLISHER_STATUS_SUBMITTED => \_CO_PUBLISHER_SUBMITTED,
17+
Constants::PUBLISHER_STATUS_PUBLISHED => \_CO_PUBLISHER_PUBLISHED,
18+
Constants::PUBLISHER_STATUS_OFFLINE => \_CO_PUBLISHER_OFFLINE,
19+
Constants::PUBLISHER_STATUS_REJECTED => \_CO_PUBLISHER_REJECTED,
20+
];
21+
22+
$projectName = 'StartTuts';
23+
$projectManagement = new TrelloManagement();
24+
$statusResult = $projectManagement->getAllStatus();
25+
26+
foreach ($statusResult as $statusRow) {
27+
// $itemResult[] = $projectManagement->getProjectTaskByStatus($statusRow['id'], $projectName);
28+
// $itemResult[] = $projectManagement->getProjectTaskByStatus($statusRow['itemid'], $statusRow['itemid']);
29+
}
30+
31+
//$xoopsTpl->assign('taskResult', $itemResult);
32+
$xoopsTpl->assign('statusResult', $statusResult);
33+
$xoopsTpl->assign('itemResult', $statusResult);
34+
$xoopsTpl->assign('statusArray', $statusArray);
35+
$xoopsTpl->assign('publisher_url', PUBLISHER_URL);
36+
37+
38+
require_once __DIR__ . '/admin_footer.php';

assets/css/trello.css

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
body {
2+
font-family: arial;
3+
}
4+
.task-board {
5+
background: #2c7cbc;
6+
display: inline-block;
7+
padding: 12px;
8+
border-radius: 3px;
9+
width: 98%;
10+
white-space: nowrap;
11+
overflow-x: scroll;
12+
min-height: 300px;
13+
}
14+
15+
.status-card {
16+
width: 250px;
17+
margin-right: 8px;
18+
background: #e2e4e6;
19+
border-radius: 3px;
20+
display: inline-block;
21+
vertical-align: top;
22+
font-size: 0.9em;
23+
}
24+
25+
.status-card:last-child {
26+
margin-right: 0px;
27+
}
28+
29+
.card-header {
30+
width: 100%;
31+
padding: 10px 10px 0px 10px;
32+
box-sizing: border-box;
33+
border-radius: 3px;
34+
display: block;
35+
font-weight: bold;
36+
}
37+
38+
.card-header-text {
39+
display: block;
40+
}
41+
42+
ul.sortable {
43+
padding-bottom: 10px;
44+
}
45+
46+
ul.sortable li:last-child {
47+
margin-bottom: 0px;
48+
}
49+
50+
ul {
51+
list-style: none;
52+
margin: 0;
53+
padding: 0px;
54+
}
55+
56+
.text-row {
57+
padding: 15px 10px;
58+
margin: 10px;
59+
background: #fff;
60+
box-sizing: border-box;
61+
border-radius: 3px;
62+
border-bottom: 1px solid #ccc;
63+
cursor: pointer;
64+
font-size: 0.8em;
65+
white-space: normal;
66+
line-height: 20px;
67+
}
68+
69+
.ui-sortable-placeholder {
70+
visibility: inherit !important;
71+
background: transparent;
72+
border: #666 2px dashed;
73+
}

assets/js/trello.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
$( function() {
2+
var url = 'edit-status.php';
3+
$('ul[itemid^="sort"]').sortable({
4+
connectWith: ".sortable",
5+
receive: function (e, ui) {
6+
var status_id = $(ui.item).parent(".sortable").data("status-id");
7+
var item_id = $(ui.item).data("item-id");
8+
$.ajax({
9+
url: url+'?status_id='+status_id+'&item_id='+item_id,
10+
success: function(response){
11+
}
12+
});
13+
}
14+
15+
}).disableSelection();
16+
} );

class/TrelloDBController.php

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
<?php declare(strict_types=1);
2+
3+
namespace XoopsModules\Publisher;
4+
5+
/**
6+
* Class TrelloDBController
7+
* @package XoopsModules\Publisher
8+
*/
9+
class TrelloDBController
10+
{
11+
/** @var \XoopsMySQLDatabase $db */
12+
private $db;
13+
14+
public function __construct()
15+
{
16+
$this->db = \XoopsDatabaseFactory::getDatabaseConnection();
17+
}
18+
19+
/**
20+
* @param $query
21+
* @return mixed
22+
*/
23+
public function runBaseQuery($query)
24+
{
25+
$result = $this->db->conn->query($query);
26+
if ($result->num_rows > 0) {
27+
while (null !== ($row = $result->fetch_assoc())) {
28+
$resultset[] = $row;
29+
}
30+
}
31+
32+
return $resultset;
33+
}
34+
35+
/**
36+
* @param $query
37+
* @param $paramType
38+
* @param $paramValueArray
39+
* @return mixed
40+
*/
41+
public function runQuery($query, $paramType, $paramValueArray)
42+
{
43+
$sql = $this->db->conn->prepare($query);
44+
$this->bindQueryParams($sql, $paramType, $paramValueArray);
45+
$sql->execute();
46+
$result = $sql->get_result();
47+
48+
if ($result->num_rows > 0) {
49+
while (null !== ($row = $result->fetch_assoc())) {
50+
$resultset[] = $row;
51+
}
52+
}
53+
54+
if (!empty($resultset)) {
55+
return $resultset;
56+
}
57+
}
58+
59+
/**
60+
* @param $sql
61+
* @param $paramType
62+
* @param $paramValueArray
63+
*/
64+
public function bindQueryParams($sql, $paramType, $paramValueArray)
65+
{
66+
$paramValueReference[] = &$paramType;
67+
for ($i = 0, $iMax = count($paramValueArray); $i < $iMax; ++$i) {
68+
$paramValueReference[] = &$paramValueArray[$i];
69+
}
70+
call_user_func_array([
71+
$sql,
72+
'bind_param',
73+
], $paramValueReference);
74+
}
75+
76+
/**
77+
* @param $query
78+
* @param $paramType
79+
* @param $paramValueArray
80+
*/
81+
public function insert($query, $paramType, $paramValueArray)
82+
{
83+
$sql = $this->db->conn->prepare($query);
84+
$this->bindQueryParams($sql, $paramType, $paramValueArray);
85+
$sql->execute();
86+
}
87+
88+
/**
89+
* @param $query
90+
* @param $paramType
91+
* @param $paramValueArray
92+
*/
93+
public function update($query, $paramType, $paramValueArray)
94+
{
95+
$sql = $this->db->conn->prepare($query);
96+
$this->bindQueryParams($sql, $paramType, $paramValueArray);
97+
$sql->execute();
98+
}
99+
}

class/TrelloManagement.php

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
<?php declare(strict_types=1);
2+
3+
4+
namespace XoopsModules\Publisher;
5+
6+
use XoopsModules\Publisher\Helper;
7+
8+
/**
9+
* Class TrelloManagement
10+
* @package XoopsModules\Publisher
11+
*/
12+
class TrelloManagement
13+
{
14+
/**
15+
* @param $statusId
16+
* @param $itemId
17+
* @return mixed
18+
*/
19+
public function getProjectTaskByStatus($statusId, $itemId)
20+
{
21+
$helper = Helper::getInstance();
22+
$dbHandle = new TrelloDBController();
23+
$query = 'SELECT * FROM ' . $GLOBALS['xoopsDB']->prefix($helper->getDirname() . '_items') . 'WHERE status= ? AND itemid = ?';
24+
$result = $dbHandle->runQuery($query, 'ii', [$statusId, $itemId]);
25+
26+
return $result;
27+
}
28+
29+
/**
30+
* @return mixed
31+
*/
32+
public function getAllStatus()
33+
{
34+
$helper = Helper::getInstance();
35+
$dbHandle = new TrelloDBController();
36+
$query = 'SELECT itemid, title, status FROM ' . $GLOBALS['xoopsDB']->prefix($helper->getDirname() . '_items');
37+
$result = $dbHandle->runBaseQuery($query);
38+
39+
return $result;
40+
}
41+
42+
/**
43+
* @param $statusId
44+
* @param $itemId
45+
*/
46+
public function editTaskStatus($statusId, $itemId)
47+
{
48+
$helper = Helper::getInstance();
49+
$dbHandle = new TrelloDBController();
50+
$query = 'UPDATE ' . $GLOBALS['xoopsDB']->prefix($helper->getDirname() . '_items') . 'SET status = ? WHERE itemid = ?';
51+
$result = $dbHandle->update($query, 'ii', [$statusId, $itemId]);
52+
53+
return $result;
54+
}
55+
}

language/english/modinfo.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@
309309

310310
// The name of this module
311311
define('_MI_PUBLISHER_NAME', 'Publisher');
312-
define('_MI_PUBLISHER_DIRNAME', basename(dirname(dirname(__DIR__))));
312+
define('_MI_PUBLISHER_DIRNAME', basename(dirname(__DIR__, 2)));
313313
define('_MI_PUBLISHER_HELP_HEADER', __DIR__ . '/help/helpheader.tpl');
314314
define('_MI_PUBLISHER_BACK_2_ADMIN', 'Back to Administration of ');
315315

@@ -457,3 +457,6 @@
457457
define('_MI_PUBLISHER_DISPRATING', 'Display Rating');
458458
define('_MI_PUBLISHER_AUTHORPAGE_RATINGDSC', 'Select “Yes” to display the rating in the Item by Same Author page');
459459

460+
461+
define('_MI_PUBLISHER_ADMENU7', 'Trello');
462+
define('_MI_PUBLISHER_TRELLO_DSC', 'Trello Management');

templates/admin/index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<script>history.go(-1);</script>

templates/admin/publisher_trello.tpl

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<title>Trello Like Drag and Drop Cards for Project Management Software</title>
2+
3+
<{* <link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">*}>
4+
<{* <script src="https://code.jquery.com/jquery-1.12.4.js"></script>*}>
5+
<{* <script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>*}>
6+
7+
8+
<script src="<{xoAppUrl browse.php?Frameworks/jquery/jquery.js}>"></script>
9+
<script src="<{xoAppUrl browse.php?Frameworks/jquery/plugins/jquery.ui.js}>"></script>
10+
<script src="<{$publisher_url}>/assets/js/trello.js"></script>
11+
12+
<link rel="stylesheet" href="<{$xoops_url}>/modules/system/css/ui/base/ui.all.css" type="text/css">
13+
<link rel="stylesheet" type="text/css" href="<{$publisher_url}>/assets/css/trello.css">
14+
15+
16+
<div class="task-board">
17+
<{foreach from=$statusArray key=k item=v}>
18+
<div class="status-card">
19+
<div class="card-header">
20+
<span class="card-header-text"><{$v}></span>
21+
</div>
22+
23+
<{foreach item=item from=$statusResult}>
24+
<ul class="sortable ui-sortable"
25+
id="sort<{$item.itemid}>"
26+
data-status-id="<{$item.status}>">
27+
<{if $item.status == $k}>
28+
<li class="text-row ui-sortable-handle"
29+
data-task-id="<{$item.itemid}>">
30+
<{$item.itemid}> <{$item.title}>
31+
</li>
32+
<{/if}>
33+
</ul>
34+
<{/foreach}>
35+
36+
</div>
37+
<{/foreach}>
38+
</div>
39+
40+

xoops_version.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,9 @@
266266
['file' => 'publisher_addfile.tpl', 'description' => '_MI_PUBLISHER_ADDFILE_DSC'],
267267
['file' => 'publisher_search.tpl', 'description' => '_MI_PUBLISHER_SEARCH_DSC'],
268268
['file' => 'publisher_author_items.tpl', 'description' => '_MI_PUBLISHER_AUTHOR_ITEMS_DSC'],
269-
['file' => 'publisher_archive.tpl', 'description' => '_MI_PUBLISHER_ARCHIVE__DSC'],
269+
['file' => 'publisher_archive.tpl', 'description' => '_MI_PUBLISHER_ARCHIVE_DSC'],
270+
//admin
271+
['file' => 'publisher_trello.tpl', 'description' => '_MI_PUBLISHER_TRELLO_DSC', 'type' => 'admin'],
270272
];
271273

272274
// Config categories

0 commit comments

Comments
 (0)