Skip to content

Commit

Permalink
Merge pull request #4 from mambax7/master
Browse files Browse the repository at this point in the history
1.02 RC-3
  • Loading branch information
mambax7 committed Nov 14, 2015
2 parents e87c404 + c499e8d commit 3745b3a
Show file tree
Hide file tree
Showing 134 changed files with 8,145 additions and 8,039 deletions.
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
publisher
=========
#Publisher
[![Software License](https://img.shields.io/badge/license-GPL-brightgreen.svg?style=flat)](LICENSE)

Publishing module for XOOPS for static/HTML content and articles stored and provided in a hierarchical manner
3 changes: 1 addition & 2 deletions publisher/admin/about.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,12 @@
$aboutAdmin = new ModuleAdmin();

echo $aboutAdmin->addNavigation('about.php');
echo $aboutAdmin->renderabout('6KJ7RW5DR3VTJ', false);
echo $aboutAdmin->renderAbout('6KJ7RW5DR3VTJ', false);

// if (version_compare(PHP_VERSION, '5.4.0') >= 0) {
// echo 'I am at least PHP version 5.4.0, my version: ' . PHP_VERSION . "\n";
// } else {
// echo 'I am using PHP lower than 5.4, my version: ' . PHP_VERSION . "\n";
// }


xoops_cp_footer();
3 changes: 1 addition & 2 deletions publisher/admin/admin_header.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@
'editimg' => "<img src='" . PUBLISHER_IMAGES_URL . "/button_edit.png' alt='" . _AM_PUBLISHER_ICO_EDIT . "' align='middle' />",
'deleteimg' => "<img src='" . PUBLISHER_IMAGES_URL . "/button_delete.png' alt='" . _AM_PUBLISHER_ICO_DELETE . "' align='middle' />",
'online' => "<img src='" . PUBLISHER_IMAGES_URL . "/on.png' alt='" . _AM_PUBLISHER_ICO_ONLINE . "' align='middle' />",
'offline' => "<img src='" . PUBLISHER_IMAGES_URL . "/off.png' alt='" . _AM_PUBLISHER_ICO_OFFLINE . "' align='middle' />",
);
'offline' => "<img src='" . PUBLISHER_IMAGES_URL . "/off.png' alt='" . _AM_PUBLISHER_ICO_OFFLINE . "' align='middle' />");
include_once $GLOBALS['xoops']->path('Frameworks/moduleclasses/moduleadmin/moduleadmin.php');

/*
Expand Down
101 changes: 52 additions & 49 deletions publisher/admin/category.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

include_once __DIR__ . '/admin_header.php';

$op = XoopsRequest::getString('op', '', 'GET');
$op = XoopsRequest::getString('op', (XoopsRequest::getString('op', '', 'POST')), 'GET');

$op = (XoopsRequest::getString('editor', '', 'POST')) ? 'mod' : $op;
$op = (XoopsRequest::getString('addcategory', '', 'POST')) ? 'addcategory' : $op;
Expand All @@ -31,60 +31,61 @@
$categoryid = XoopsRequest::getInt('categoryid');

switch ($op) {

case "del":
$categoryObj = $publisher->getHandler('category')->get($categoryid);
case 'del':
$categoryObj =& $publisher->getHandler('category')->get($categoryid);
$confirm = XoopsRequest::getInt('confirm', '', 'POST');
$name = XoopsRequest::getString('name', '', 'POST');
if ($confirm) {
if (!$publisher->getHandler('category')->delete($categoryObj)) {
redirect_header("category.php", 1, _AM_PUBLISHER_DELETE_CAT_ERROR);
// exit();
redirect_header('category.php', 1, _AM_PUBLISHER_DELETE_CAT_ERROR);
// exit();
}
redirect_header("category.php", 1, sprintf(_AM_PUBLISHER_COLISDELETED, $name));
// exit();
redirect_header('category.php', 1, sprintf(_AM_PUBLISHER_COLISDELETED, $name));
// exit();
} else {
xoops_cp_header();
xoops_confirm(array('op' => 'del', 'categoryid' => $categoryObj->categoryid(), 'confirm' => 1, 'name' => $categoryObj->name()), 'category.php', _AM_PUBLISHER_DELETECOL . " '" . $categoryObj->name() . "'. <br /> <br />" . _AM_PUBLISHER_DELETE_CAT_CONFIRM, _AM_PUBLISHER_DELETE);
xoops_cp_footer();
}
break;

case "mod":
case 'mod':
//Added by fx2024
$nb_subcats = XoopsRequest::getInt('nb_subcats', 0, 'POST');
$nb_subcats = $nb_subcats + (XoopsRequest::getInt('nb_sub_yet', 4, 'POST'));
$nb_subcats += (XoopsRequest::getInt('nb_sub_yet', 4, 'POST'));
//end of fx2024 code

publisherCpHeader();
PublisherUtilities::editCategory(true, $categoryid, $nb_subcats);
break;

case "addcategory":
case 'addcategory':
global $modify;

$parentid = XoopsRequest::getInt('parentid');

if ($categoryid != 0) {
$categoryObj = $publisher->getHandler('category')->get($categoryid);
$categoryObj =& $publisher->getHandler('category')->get($categoryid);
} else {
$categoryObj = $publisher->getHandler('category')->create();
$categoryObj =& $publisher->getHandler('category')->create();
}

// Uploading the image, if any
// Retreive the filename to be uploaded
if ($image_file = XoopsRequest::getArray('image_file', '', 'FILES')['name']) {
// $filename = XoopsRequest::getArray('xoops_upload_file', array(), 'POST')[0];
if ($filename = XoopsRequest::getArray('xoops_upload_file', array(), 'POST')[0]) {
$temp = XoopsRequest::getArray('image_file', '', 'FILES');
if ($image_file = $temp['name']) {
// $filename = XoopsRequest::getArray('xoops_upload_file', array(), 'POST')[0];
$temp2 = XoopsRequest::getArray('xoops_upload_file', array(), 'POST');
if ($filename = $temp2[0]) {
// TODO : implement publisher mimetype management
$max_size = $publisher->getConfig('maximum_filesize');
$max_imgwidth = $publisher->getConfig('maximum_image_width');
$max_imgheight = $publisher->getConfig('maximum_image_height');
$allowed_mimetypes = publisherGetAllowedImagesTypes();

if (!($tmp_name = (XoopsRequest::getArray('filename', array(), 'FILES')['tmp_name'])) || !is_readable($tmp_name)) {
$temp3 = XoopsRequest::getArray('filename', array(), 'FILES');
if (!is_readable($tmp_name) || !($tmp_name = $temp3['tmp_name'])) {
redirect_header('javascript:history.go(-1)', 2, _AM_PUBLISHER_FILEUPLOAD_ERROR);
// exit();
// exit();
}

xoops_load('XoopsMediaUploader');
Expand All @@ -93,11 +94,11 @@
$categoryObj->setVar('image', $uploader->getSavedFileName());
} else {
redirect_header('javascript:history.go(-1)', 2, _AM_PUBLISHER_FILEUPLOAD_ERROR . $uploader->getErrors());
// exit();
// exit();
}
}
} else {
$categoryObj->setVar('image', XoopsRequest::getString('image', '', 'POST'));
$categoryObj->setVar('image', XoopsRequest::getString('image', '', 'POST'));
}
$categoryObj->setVar('parentid', (XoopsRequest::getInt('parentid', 0, 'POST')));

Expand Down Expand Up @@ -129,8 +130,8 @@
}

if (!$categoryObj->store()) {
redirect_header("javascript:history.go(-1)", 3, _AM_PUBLISHER_CATEGORY_SAVE_ERROR . publisherFormatErrors($categoryObj->getErrors()));
// exit;
redirect_header('javascript:history.go(-1)', 3, _AM_PUBLISHER_CATEGORY_SAVE_ERROR . publisherFormatErrors($categoryObj->getErrors()));
// exit;
}
// TODO : put this function in the category class
publisherSaveCategoryPermissions($grpread, $categoryObj->categoryid(), 'category_read');
Expand All @@ -141,14 +142,16 @@
$parentCat = $categoryObj->categoryid();
$sizeof = count(XoopsRequest::getString('scname', '', 'POST'));
for ($i = 0; $i < $sizeof; ++$i) {
if (XoopsRequest::getArray('scname', array(), 'POST')[$i] != '') {
$categoryObj = $publisher->getHandler('category')->create();
$categoryObj->setVar('name', XoopsRequest::getArray('scname', array(), 'POST')[$i]);
$temp = XoopsRequest::getArray('scname', array(), 'POST');
if ($temp[$i] != '') {
$categoryObj =& $publisher->getHandler('category')->create();
$temp2 = XoopsRequest::getArray('scname', array(), 'POST');
$categoryObj->setVar('name', $temp2[$i]);
$categoryObj->setVar('parentid', $parentCat);

if (!$categoryObj->store()) {
redirect_header("javascript:history.go(-1)", 3, _AM_PUBLISHER_SUBCATEGORY_SAVE_ERROR . publisherFormatErrors($categoryObj->getErrors()));
// exit;
redirect_header('javascript:history.go(-1)', 3, _AM_PUBLISHER_SUBCATEGORY_SAVE_ERROR . publisherFormatErrors($categoryObj->getErrors()));
// exit;
}
// TODO : put this function in the category class
publisherSaveCategoryPermissions($grpread, $categoryObj->categoryid(), 'category_read');
Expand All @@ -158,16 +161,16 @@
}
//end of fx2024 code
redirect_header($redirect_to, 2, $redirect_msg);
// exit();
// exit();
break;

//Added by fx2024

case "addsubcats":
case 'addsubcats':
$categoryid = 0;
$nb_subcats = XoopsRequest::getInt('nb_subcats', 0, 'POST') + XoopsRequest::getInt('nb_sub_yet', 0, 'POST');

$categoryObj = $publisher->getHandler('category')->create();
$categoryObj =& $publisher->getHandler('category')->create();
$categoryObj->setVar('name', XoopsRequest::getString('name', '', 'POST'));
$categoryObj->setVar('description', XoopsRequest::getString('description', '', 'POST'));
$categoryObj->setVar('weight', XoopsRequest::getInt('weight', 0, 'POST'));
Expand All @@ -181,11 +184,11 @@
break;
//end of fx2024 code

case "cancel":
redirect_header("category.php", 1, sprintf(_AM_PUBLISHER_BACK2IDX, ''));
// exit();
case 'cancel':
redirect_header('category.php', 1, sprintf(_AM_PUBLISHER_BACK2IDX, ''));
// exit();
break;
case "default":
case 'default':
default:
publisherCpHeader();
//publisher_adminMenu(1, _AM_PUBLISHER_CATEGORIES);
Expand All @@ -194,39 +197,39 @@
echo "<form><div style=\"margin-bottom: 12px;\">";
echo "<input type='button' name='button' onclick=\"location='category.php?op=mod'\" value='" . _AM_PUBLISHER_CATEGORY_CREATE . "'>&nbsp;&nbsp;";
//echo "<input type='button' name='button' onclick=\"location='item.php?op=mod'\" value='" . _AM_PUBLISHER_CREATEITEM . "'>&nbsp;&nbsp;";
echo "</div></form>";
echo '</div></form>';

// Creating the objects for top categories
$categoriesObj = $publisher->getHandler('category')->getCategories($publisher->getConfig('idxcat_perpage'), $startcategory, 0);
$categoriesObj =& $publisher->getHandler('category')->getCategories($publisher->getConfig('idxcat_perpage'), $startcategory, 0);

publisherOpenCollapsableBar('createdcategories', 'createdcategoriesicon', _AM_PUBLISHER_CATEGORIES_TITLE, _AM_PUBLISHER_CATEGORIES_DSC);

echo "<table width='100%' cellspacing=1 cellpadding=3 border=0 class = outer>";
echo "<tr>";
echo "<th width='20' class='bg3' align='center'><strong>" . _AM_PUBLISHER_ITEMCATEGORY_ID . "</strong></td>";
echo "<th class='bg3' align='left'><strong>" . _AM_PUBLISHER_ITEMCATEGORYNAME . "</strong></td>";
echo "<th width='60' class='bg3' width='65' align='center'><strong>" . _CO_PUBLISHER_WEIGHT . "</strong></td>";
echo "<th width='60' class='bg3' align='center'><strong>" . _AM_PUBLISHER_ACTION . "</strong></td>";
echo "</tr>";
$totalCategories = $publisher->getHandler('category')->getCategoriesCount(0);
echo '<tr>';
echo "<th width='20' class='bg3' align='center'><strong>" . _AM_PUBLISHER_ITEMCATEGORY_ID . '</strong></td>';
echo "<th class='bg3' align='left'><strong>" . _AM_PUBLISHER_ITEMCATEGORYNAME . '</strong></td>';
echo "<th width='60' class='bg3' width='65' align='center'><strong>" . _CO_PUBLISHER_WEIGHT . '</strong></td>';
echo "<th width='60' class='bg3' align='center'><strong>" . _AM_PUBLISHER_ACTION . '</strong></td>';
echo '</tr>';
$totalCategories =& $publisher->getHandler('category')->getCategoriesCount(0);
if (count($categoriesObj) > 0) {
foreach ($categoriesObj as $key => $thiscat) {
PublisherUtilities::displayCategory($thiscat);
}
unset($key, $thiscat);
} else {
echo "<tr>";
echo "<td class='head' align='center' colspan= '7'>" . _AM_PUBLISHER_NOCAT . "</td>";
echo "</tr>";
echo '<tr>';
echo "<td class='head' align='center' colspan= '7'>" . _AM_PUBLISHER_NOCAT . '</td>';
echo '</tr>';
$categoryid = '0';
}
echo "</table>\n";
include_once $GLOBALS['xoops']->path('class/pagenav.php');
$pagenav = new XoopsPageNav($totalCategories, $publisher->getConfig('idxcat_perpage'), $startcategory, 'startcategory');
echo '<div style="text-align:right;">' . $pagenav->renderNav() . '</div>';
echo "<br />";
echo '<br />';
publisherCloseCollapsableBar('createdcategories', 'createdcategoriesicon');
echo "<br>";
echo '<br>';
//editcat(false);
break;
}
Expand Down
47 changes: 23 additions & 24 deletions publisher/admin/clone.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,25 +18,25 @@
* @version $Id: clone.php 10374 2012-12-12 23:39:48Z trabis $
*/

include_once __DIR__ . "/admin_header.php";
include_once __DIR__ . '/admin_header.php';

publisherCpHeader();
//publisher_adminMenu(-1, _AM_PUBLISHER_CLONE);
publisherOpenCollapsableBar('clone', 'cloneicon', _AM_PUBLISHER_CLONE, _AM_PUBLISHER_CLONE_DSC);

if ('submit' == XoopsRequest::getString('op', '', 'POST')) {
if ('submit' === XoopsRequest::getString('op', '', 'POST')) {
if (!$GLOBALS['xoopsSecurity']->check()) {
redirect_header('clone.php', 3, implode('<br />', $GLOBALS['xoopsSecurity']->getErrors()));
// exit();
// exit();
}

// $clone = $_POST['clone'];
// $clone = $_POST['clone'];
$clone = XoopsRequest::getString('clone', '', 'POST');

//check if name is valid
if (empty($clone) || preg_match('/[^a-zA-Z0-9\_\-]/', $clone)) {
redirect_header('clone.php', 3, sprintf(_AM_PUBLISHER_CLONE_INVALIDNAME, $clone));
// exit();
// exit();
}

// Check wether the cloned module exists or not
Expand All @@ -47,17 +47,16 @@
$patterns = array(
strtolower(PUBLISHER_DIRNAME) => strtolower($clone),
strtoupper(PUBLISHER_DIRNAME) => strtoupper($clone),
ucfirst(strtolower(PUBLISHER_DIRNAME)) => ucfirst(strtolower($clone))
);
ucfirst(strtolower(PUBLISHER_DIRNAME)) => ucfirst(strtolower($clone)));

$patKeys = array_keys($patterns);
$patValues = array_values($patterns);
PublisherClone::cloneFileFolder(PUBLISHER_ROOT_PATH);
$logocreated = PublisherClone::createLogo(strtolower($clone));

$msg = "";
$msg = '';
if (is_dir($GLOBALS['xoops']->path('modules/' . strtolower($clone)))) {
$msg .= sprintf(_AM_PUBLISHER_CLONE_CONGRAT, "<a href='" . XOOPS_URL . "/modules/system/admin.php?fct=modulesadmin'>" . ucfirst(strtolower($clone)) . "</a>") . "<br />\n";
$msg .= sprintf(_AM_PUBLISHER_CLONE_CONGRAT, "<a href='" . XOOPS_URL . "/modules/system/admin.php?fct=modulesadmin'>" . ucfirst(strtolower($clone)) . '</a>') . "<br />\n";
if (!$logocreated) {
$msg .= _AM_PUBLISHER_CLONE_IMAGEFAIL;
}
Expand Down Expand Up @@ -100,14 +99,14 @@ function file_put_contents($filename, $data, $file_append = false)
class PublisherClone
{

// recursive clonning script
// recursive clonning script
/**
* @param $path
*/
public static function cloneFileFolder($path)
{
global $patKeys;
global $patValues;
global $patKeys;
global $patValues;

$newPath = str_replace($patKeys[0], $patValues[0], $path);

Expand All @@ -118,7 +117,7 @@ public static function cloneFileFolder($path)
// check all files in dir, and process it
if ($handle == opendir($path)) {
while (($file = readdir($handle)) !== false) {
if ($file != '.' && $file != '..' && $file != '.svn') {
if ($file !== '.' && $file !== '..' && $file !== '.svn') {
self::cloneFileFolder("{$path}/{$file}");
}
}
Expand All @@ -144,38 +143,38 @@ public static function cloneFileFolder($path)
*/
public static function createLogo($dirname)
{
if (!extension_loaded("gd")) {
if (!extension_loaded('gd')) {
return false;
} else {
$required_functions = array("imagecreatetruecolor", "imagecolorallocate", "imagefilledrectangle", "imagejpeg", "imagedestroy", "imageftbbox");
foreach ($required_functions as $func) {
$requiredFunctions = array('imagecreatetruecolor', 'imagecolorallocate', 'imagefilledrectangle', 'imagejpeg', 'imagedestroy', 'imageftbbox');
foreach ($requiredFunctions as $func) {
if (!function_exists($func)) {
return false;
}
}
unset($func);
// unset($func);
}

if (!file_exists($imageBase = $GLOBALS['xoops']->path("modules/" . $dirname . "/assets/images/module_logo.png")) || !file_exists($font = $GLOBALS['xoops']->path("modules/" . $dirname . "/assets/images/VeraBd.ttf"))) {
if (!file_exists($imageBase = $GLOBALS['xoops']->path('modules/' . $dirname . '/assets/images/module_logo.png')) || !file_exists($font = $GLOBALS['xoops']->path('modules/' . $dirname . '/assets/images/VeraBd.ttf'))) {
return false;
}

$imageModule = imagecreatefrompng($imageBase);

//Erase old text
$grey_color = imagecolorallocate($imageModule, 237, 237, 237);
imagefilledrectangle($imageModule, 5, 35, 85, 46, $grey_color);
$greyColor = imagecolorallocate($imageModule, 237, 237, 237);
imagefilledrectangle($imageModule, 5, 35, 85, 46, $greyColor);

// Write text
$text_color = imagecolorallocate($imageModule, 0, 0, 0);
$space_to_border = (80 - strlen($dirname) * 6.5) / 2;
imagefttext($imageModule, 8.5, 0, $space_to_border, 45, $text_color, $font, ucfirst($dirname), array());
$textColor = imagecolorallocate($imageModule, 0, 0, 0);
$spaceToBorder = (80 - strlen($dirname) * 6.5) / 2;
imagefttext($imageModule, 8.5, 0, $spaceToBorder, 45, $textColor, $font, ucfirst($dirname), array());

// Set transparency color
$white = imagecolorallocatealpha($imageModule, 255, 255, 255, 127);
imagefill($imageModule, 0, 0, $white);
imagecolortransparent($imageModule, $white);
imagepng($imageModule, $GLOBALS['xoops']->path("modules/" . $dirname . "/assets/images/module_logo.png"));
imagepng($imageModule, $GLOBALS['xoops']->path('modules/' . $dirname . '/assets/images/module_logo.png'));
imagedestroy($imageModule);

return true;
Expand Down
Loading

0 comments on commit 3745b3a

Please sign in to comment.