Skip to content

Commit

Permalink
updates
Browse files Browse the repository at this point in the history
  • Loading branch information
mambax7 committed Apr 9, 2018
1 parent e9aa08b commit 7968935
Show file tree
Hide file tree
Showing 11 changed files with 276 additions and 84 deletions.
6 changes: 6 additions & 0 deletions assets/css/module.css
Original file line number Diff line number Diff line change
Expand Up @@ -550,3 +550,9 @@ tr.wfdownloads_mirrors_end {
background-color: #BEC8D1;
border: 2px solid #000000;
}


.wfdownloads_head_catletters {
text-align: center;
font-size: 80%;
}
37 changes: 32 additions & 5 deletions class/Common/LetterChoice.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,9 @@ public function __construct(
$this->criteria = null === $criteria ? new \CriteriaCompo() : $criteria;
$this->field_name = null === $field_name ? $this->objHandler->identifierName : $field_name;
// $this->alphabet = (count($alphabet) > 0) ? $alphabet : range('a', 'z'); // is there a way to get locale alphabet?
$this->alphabet = getLocalAlphabet();

// $this->alphabet = getLocalAlphabet();
$this->alphabet = include __DIR__ . '/../../language/'.$GLOBALS['xoopsConfig']['language'] .'/alphabet.php';
// $this->helper->loadLanguage('alphabet');
$this->arg_name = $arg_name;
$this->url = null === $url ? $_SERVER['PHP_SELF'] : $url;
if ('' !== $extra_arg && ('&' !== substr($extra_arg, -5) || '&' !== substr($extra_arg, -1))) {
Expand All @@ -97,10 +98,20 @@ public function __construct(
/**
* Create choice by letter
*
* @param null $alphaCount
* @param null $howmanyother
* @return string
*/
public function render()
public function render($alphaCount = null, $howmanyother = null)
{
$moduleDirName = basename(dirname(dirname(__DIR__)));
$moduleDirNameUpper = strtoupper($moduleDirName);
xoops_loadLanguage('common', $moduleDirName);
xoops_loadLanguage('alphabet', $moduleDirName);
$all = constant('CO_' . $moduleDirNameUpper . '_ALL');
$other = constant('CO_' . $moduleDirNameUpper . '_OTHER');


$ret = '';
//
if (!$this->caseSensitive) {
Expand All @@ -111,6 +122,15 @@ public function render()
$countsByLetters = $this->objHandler->getCounts($this->criteria);
// fill alphabet array
$alphabetArray = [];
$letter_array = [];

$letter = 'All';
$letter_array['letter'] = $all;
$letter_array['count'] = $alphaCount;
$letter_array['url'] = $this->url ;
$alphabetArray[$letter] = $letter_array;


foreach ($this->alphabet as $letter) {
$letter_array = [];
if (!$this->caseSensitive) {
Expand All @@ -137,16 +157,23 @@ public function render()
$alphabetArray[$letter] = $letter_array;
unset($letter_array);
}


$letter_array['letter'] = $other;
$letter_array['count'] = $howmanyother;
$letter_array['url'] = $this->url. '?init=Other' ;
$alphabetArray[$letter] = $letter_array;

// render output
if (!isset($GLOBALS['xoTheme']) || !is_object($GLOBALS['xoTheme'])) {
require_once $GLOBALS['xoops']->path('/class/theme.php');
$GLOBALS['xoTheme'] = new \xos_opal_Theme();
}
require_once $GLOBALS['xoops']->path('/class/template.php');
$choiceByLetterTpl = new \XoopsTpl();
$choiceByLetterTpl->caching = false; // Disable cache
$choiceByLetterTpl->caching = 0; // Disable cache
$choiceByLetterTpl->assign('alphabet', $alphabetArray);
$ret .= $choiceByLetterTpl->fetch("db:{$this->helper->getDirname()}_co_letterschoice.tpl");
$ret .= $choiceByLetterTpl->fetch("db:{$this->helper->getDirname()}_letterschoice.tpl");
unset($choiceByLetterTpl);

return $ret;
Expand Down
6 changes: 6 additions & 0 deletions docs/todo.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
TODO: Planned features in the future
=====================================

Features that are being considered/planned for the future releases:

- fixing some of the problems with alphabet view, as it does not work consistently
28 changes: 21 additions & 7 deletions index.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@

$categoryCriteria = new \CriteriaCompo();
$categoryCriteria->setSort('weight ASC, title');
$categoryObjs = $helper->getHandler('Category')->getObjects($categoryCriteria);
$categoryObjs = $helper->getHandler('category')->getObjects($categoryCriteria);
unset($categoryCriteria);

$categoryObjsTree = new Wfdownloads\ObjectTree($categoryObjs, 'cid', 'pid');
Expand All @@ -100,15 +100,29 @@
$breaks = $head_arr['nobreak'] ? 1 : 0;
$catarray['indexheader'] =& $myts->displayTarea($head_arr['indexheader'], $html, $smiley, $xcodes, $images, $breaks);
$catarray['indexfooter'] =& $myts->displayTarea($head_arr['indexfooter'], $html, $smiley, $xcodes, $images, $breaks);
$catarray['letters'] = Wfdownloads\Utility::lettersChoice();

//----------------------
//$catarray['letters'] = Wfdownloads\Utility::lettersChoice();


// Letter Choice Start ---------------------------------------

XoopsModules\Wfdownloads\Helper::getInstance()->loadLanguage('common');
$xoopsTpl->assign('letterChoiceTitle', constant('CO_'.$moduleDirNameUpper.'_'.'BROWSETOTOPIC'));
/** @var \XoopsDatabase $db */
$db = \XoopsDatabaseFactory::getDatabaseConnection();
$db = \XoopsDatabaseFactory::getDatabaseConnection();
$objHandler = new Wfdownloads\DownloadHandler($db);
$choicebyletter = new Wfdownloads\Common\LetterChoice($objHandler, null, null, range('a', 'z'), 'letter');
//$catarray['letters'] = $choicebyletter->render();
//--------------------------
$choicebyletter = new Wfdownloads\Common\LetterChoice($objHandler, null, null, range('a', 'z'), 'letter', 'viewcat.php');
//$choicebyletter = new Wfdownloads\Common\LetterChoice($objHandler, null, null, range('a', 'z'), 'init', XOOPSTUBE_URL . '/letter.php');
//render the LetterChoice partial and story as part of the Category array
//$catarray['letters'] = $choicebyletter->render($alphaCount, $howmanyother);

$catarray['letters'] = $choicebyletter->render();

//now assign it to the Smarty variable
$xoopsTpl->assign('catarray', $catarray);

// Letter Choice End ------------------------------------


$catarray['toolbar'] = Wfdownloads\Utility::toolbar();
$xoopsTpl->assign('catarray', $catarray);
Expand Down
41 changes: 41 additions & 0 deletions language/english/alphabet.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?php

return [
'0',
'1',
'2',
'3',
'4',
'5',
'6',
'7',
'8',
'9',
'A',
'B',
'C',
'D',
'E',
'F',
'G',
'H',
'I',
'J',
'K',
'L',
'M',
'N',
'O',
'P',
'Q',
'R',
'S',
'T',
'U',
'V',
'W',
'X',
'Y',
'Z',
'Other'
];
8 changes: 8 additions & 0 deletions language/english/common.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,3 +93,11 @@
define('CO_' . $moduleDirNameUpper . '_' . 'EXPORT_SCHEMA', 'Export DB Schema to YAML');
define('CO_' . $moduleDirNameUpper . '_' . 'EXPORT_SCHEMA_SUCCESS', 'Export DB Schema to YAML was a success');
define('CO_' . $moduleDirNameUpper . '_' . 'EXPORT_SCHEMA_ERROR', 'ERROR: Export of DB Schema to YAML failed');

//letter choice
define(
'CO_'.$moduleDirNameUpper.'_'.'BROWSETOTOPIC',
"<span style='font-weight: bold;'>Browse items alphabetically</span>"
);
define('CO_'.$moduleDirNameUpper.'_'.'OTHER', 'Other');
define('CO_'.$moduleDirNameUpper.'_'.'ALL', 'All');
49 changes: 0 additions & 49 deletions language/english/main.php
Original file line number Diff line number Diff line change
Expand Up @@ -284,55 +284,6 @@
define('_MD_WFDOWNLOADS_FFS_BACK', 'Back');
define('_MD_WFDOWNLOADS_FFS_DOWNLOADTITLE', "Submitting a '{category}' file.");
// Added Formulize module support (2006/05/04) jpc - end

// 3.23
/**
* @return array
*/
function getLocalAlphabet()
{
$alphabet = [
'0',
'1',
'2',
'3',
'4',
'5',
'6',
'7',
'8',
'9',
'A',
'B',
'C',
'D',
'E',
'F',
'G',
'H',
'I',
'J',
'K',
'L',
'M',
'N',
'O',
'P',
'Q',
'R',
'S',
'T',
'U',
'V',
'W',
'X',
'Y',
'Z',
];

return $alphabet;
}

define('_MD_WFDOWNLOADS_MIRROR_HOMEURLTITLE_DESC', '');
define('_MD_WFDOWNLOADS_MIRROR_HOMEURL_DESC', 'Enter your home page URL.');
define('_MD_WFDOWNLOADS_MIRROR_UPLOADMIRRORIMAGE_DESC', 'A small logo representing your website.');
Expand Down
97 changes: 97 additions & 0 deletions templates/wfdownloads_letterschoice.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
<style type="text/css">
.button_green {
-moz-box-shadow: inset 0 1px 0 0 #d9fbbe;
-webkit-box-shadow: inset 0 1px 0 0 #d9fbbe;
box-shadow: inset 0 1px 0 0 #d9fbbe;
background: -webkit-gradient(linear, left top, left bottom, color-stop(0.05, #d9fbbe), color-stop(1, #d9fbbe));
background: -moz-linear-gradient(, center top, #a5cc52 5%, #d9fbbe 100%);
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#d9fbbe', endColorstr='#b8e356');
background-color: #d9fbbe;
-webkit-border-radius: 2px;
-moz-border-radius: 2px;
border-radius: 2px;
text-indent: 0;
border: 1px solid #83c41a;
display: inline-block;
color: inherit;
font-family: inherit;
font-size: 12px;
font-weight: bold;
font-style: normal;
height: 20px;
line-height: 20px;
width: auto;
min-width: 10px;
text-decoration: none;
text-align: center;
text-shadow: 1px 1px 0 #d9fbbe;
margin: 2px 0;
padding: 0 4px;
}
.button_green:hover {
background: -webkit-gradient(linear, left top, left bottom, color-stop(0.05, #b8e356), color-stop(1, #a5cc52));
background: -moz-linear-gradient(, center top, #b8e356 5%, #a5cc52 100%);
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#b8e356', endColorstr='#a5cc52');
background-color: #86ae47;
}
.button_green:active {
position: relative;
top: 1px;
}
.button_grey {
background: -webkit-gradient(linear, left top, left bottom, color-stop(0.05, #ededed), color-stop(1, #dfdfdf));
background: -moz-linear-gradient(, center top, #ededed 5%, #dfdfdf 100%);
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ededed', endColorstr='#dfdfdf');
background-color: #ededed;
-webkit-border-radius: 2px;
-moz-border-radius: 2px;
border-radius: 2px;
text-indent: 0;
border: 1px solid #dcdcdc;
display: inline-block;
color: inherit;
font-family: inherit;
font-size: 12px;
font-weight: bold;
font-style: normal;
height: 20px;
line-height: 20px;
width: auto;
min-width: 10px;
text-decoration: none;
text-align: center;
text-shadow: 1px 1px 0 #ffffff;
margin: 2px 0;
padding: 0 4px;
}
.button_grey:hover {
background: -webkit-gradient(linear, left top, left bottom, color-stop(0.05, #dfdfdf), color-stop(1, #ededed));
background: -moz-linear-gradient(, center top, #dfdfdf 5%, #ededed 100%);
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#dfdfdf', endColorstr='#ededed');
background-color: #dfdfdf;
}
.button_grey:active {
position: relative;
top: 1px;
}
</style>
<{*<{$smarty.const._MD_XOOPSTUBE_BROWSETOTOPIC}>*}>
<{*<{$letterChoiceTitle}>*}>
<br>
<div>
<{assign var="alphabetcount" value=$alphabet|@count}>
<{foreach name=letters item=letter from=$alphabet}>
<{if ($letter.count > 0)}>
<a class='button_green' href='<{$letter.url}>' title='<{$letter.count}>'><{$letter.letter}></a>
<{else}>
<span class='button_grey'><{$letter.letter}></span>
<{/if}>
<{if ($smarty.foreach.letters.iteration == (round($alphabetcount/2))+1)}></div>
<div><{else}><{/if}>
<{/foreach}>
</div>
Loading

0 comments on commit 7968935

Please sign in to comment.