Skip to content

Commit

Permalink
Merge pull request #71 from bitcero/helium
Browse files Browse the repository at this point in the history
Helium
  • Loading branch information
bitcero committed May 31, 2016
2 parents 2edd269 + 3bde008 commit 40fa8e5
Show file tree
Hide file tree
Showing 65 changed files with 650 additions and 1,425 deletions.
15 changes: 13 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ More security, more stability and the last features with every module.
---

### Requirements
* PHP >= 5.3
* XOOPS >= 2.5 installed and running
* PHP >= 5.6+
* XOOPS >= 2.5.8 installed and running

---

Expand Down Expand Up @@ -46,6 +46,17 @@ between rmcommon and XOOPS.

---

### Update

Common Utilities includes its own integrated updates system. You can update the module directly from _Updates Manager_, however, if you are upgrading from a XOOPS version prior to **2.5.8** then follow next instructions in order to prevent any issue.

1. Upgrade XOOPS version to 2.5.8 by following the instructions. If you experience any problem you can follow next steps:
1. If you have installed protector: open file xoops_lib/modules/protector/include/precheck.inc.php and change line #6 from `require __DIR__ . '/postcheck.inc.php';` to `require_once __DIR__ . '/postcheck.inc.php';`
2. Save file and continue the upgarde process.
2. Go to modules management and update Common Utilities.

---

### A brief list of its features

Next is a brief list of the current features of Common Utilities. Note that new features and improvements are added frequently.
Expand Down
3 changes: 2 additions & 1 deletion rmcommon/about.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@
Welcome to Common Utilities
</h1>
<p class="lead">
Thanks for using <strong><?php echo RMModules::get_module_version('rmcommon'); ?></strong>.
Thanks for using <strong><?php echo RMModules::get_module_version('rmcommon'); ?></strong> for
<a href="http://xoops.org/modules/news/article.php?storyid=6762" target="_blank">XOOPS 2.5.8</a>.
This version has a lot of improvements and new features to make your work more productive and pleasing.
</p>
</div>
Expand Down
1 change: 1 addition & 0 deletions rmcommon/ajax/blocks.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ function insert_block(){
$block->setVar('widget', $id);
$block->setVar('options', is_array($bk['options']) ? serialize($bk['options']) : serialize(explode("|", $bk['options'])));
$block->setVar('template', $bk['template']);
$block->setVar('bcachetime', 0);
$block->sections(array(0));

if(!$block->save())
Expand Down
4 changes: 2 additions & 2 deletions rmcommon/blocks.php
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ function show_rm_blocks()
RMTemplate::getInstance()->add_style('blocks.min.css', 'rmcommon', ['id' => 'cu-blocks-css']);
RMTemplate::getInstance()->add_script('blocks.min.js', 'rmcommon');
RMTemplate::getInstance()->add_script('jkmenu.js', 'rmcommon');
RMTemplate::getInstance()->add_style('forms.css', 'rmcommon');
RMTemplate::getInstance()->add_style('forms.min.css', 'rmcommon', ['id' => 'forms-css']);
RMTemplate::getInstance()->add_script('jquery-ui.min.js', 'rmcommon', array('directory' => 'include'));

if (!$rmc_config['blocks_enable']) {
Expand All @@ -151,7 +151,7 @@ function show_rm_blocks()

xoops_cp_header();

// Available Widgets
// Available blocks

$blocks = RMBlocksFunctions::get_available_list($modules);

Expand Down
2 changes: 1 addition & 1 deletion rmcommon/class/config-item.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public function __construct( $name = '', $mod = 0 ){
$this->ownerName = 'rmcommon';
$this->ownerType = 'module';

$this->db =& XoopsDatabaseFactory::getDatabaseConnection();
$this->db = XoopsDatabaseFactory::getDatabaseConnection();
$this->_dbtable = $this->db->prefix("config");
$this->setNew();
$this->initVarsFromTable();
Expand Down
17 changes: 1 addition & 16 deletions rmcommon/class/fields/button.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -129,22 +129,7 @@ public function addButton($name, $value, $type = 'button', $extra='', $ok=false)
public function getButtons(){
return $this->buttons;
}
/**
* Establece el contenido extra para un determinado bot?n.
* El par?metro pasado a esta funci?n puede contener c?digo JavaScript o
* cualquier otro dato que se desee pasar a la etiqueta <input .. />
* @param string $name Identificado del bot?n
* @param string $extra Contenido a insertar
*/
public function setExtra($name, $extra){
//if (!isset($this->buttons[$name])) return;
foreach ($this->buttons as $index => $button){
if ($button->getName()==$name){
$this->buttons[$index]->setExtra($extra);
break;
}
}
}

/**
* Genera el c?digo HTML para el grupo de botones.
* Lo que esta funci?n hace es llamar al m?todo render() de cada
Expand Down
2 changes: 1 addition & 1 deletion rmcommon/class/fields/checks.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public function addOption($caption, $name, $value, $state = 0)
$rtn = array();
$rtn['caption'] = TextCleaner::getInstance()->clean_disabled_tags($caption);
$rtn['value'] = TextCleaner::getInstance()->clean_disabled_tags($value);
$rtn['selected'] = $state == 1 ? 'selected' : '';
$rtn['selected'] = $state ? 'selected' : '';
$rtn['name'] = $name;
$this->_options[] = $rtn;
}
Expand Down
2 changes: 1 addition & 1 deletion rmcommon/class/fields/editor.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ private function renderHTML()

$rtn .= "<div class=\"quicktags\"><div id=\"ed_toolbar_" . $this->get('id') . "\"></div></div>" . (!empty
($plugins) ? "<div class='ed-qt-plugins'><span class='plugin'>" . implode('</span><span class="plugin">', $plugins) . "</span></div>" : '') . "
<div class='txtarea-container' style='height: " . $this->get('height') . ";'><textarea id='" . $this->get('id') . "' name='" . $this->get('name') . "' class='" . $this->get('class') . "'>" . $this->get('default') . "</textarea></div>
<div class='txtarea-container' style='height: " . $this->get('height') . ";'><textarea id='" . $this->get('id') . "' name='" . $this->get('name') . "' class='" . $this->get('class') . "'>" . $this->get('value') . "</textarea></div>
</div>";
return $rtn;
}
Expand Down
6 changes: 3 additions & 3 deletions rmcommon/class/fields/formuser.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,9 @@ public function onChange($action){
*/
public function render(){

RMTemplate::get()->add_script('forms.js', 'rmcommon', array('footer' => 1));
RMTemplate::get()->add_script('jquery.validate.min.js', 'rmcommon', array('directory' => 'include', 'footer' => 1));
RMTemplate::get()->add_style('forms.css','rmcommon');
RMTemplate::getInstance()->add_script('forms.js', 'rmcommon', array('footer' => 1));
RMTemplate::getInstance()->add_script('jquery.validate.min.js', 'rmcommon', array('directory' => 'include', 'footer' => 1));
RMTemplate::getInstance()->add_style('forms.min.css','rmcommon', ['id' => 'forms-css']);

if (function_exists("xoops_cp_header")){
RMTemplate::get()->add_style('jquery.css','rmcommon');
Expand Down
30 changes: 17 additions & 13 deletions rmcommon/class/fields/groups.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ function __construct($caption, $name, $multi=0, $type=0, $cols=2, $selected=arra
$this->setWithDefaults('multiple', null, null);
}
$this->setWithDefaults('type', $type == 0 ? 'select' : 'radio', 'select');
$this->setWithDefaults('selected', $selected, []);
$this->setWithDefaults('value', $selected, []);
}

$this->setIfNotSet('type', 'select');
Expand Down Expand Up @@ -155,7 +155,8 @@ public function render(){

$typeinput = $this->get('type');
$name = $this->getName();
$selected = $this->get('selected');
$selected = $this->get('value');
$selected = is_array($selected) ? $selected : array($selected);

if ($typeinput == 'radio' || $typeinput == 'checkbox'){

Expand All @@ -167,13 +168,17 @@ public function render(){
$attributes = $this->renderAttributeString();

$rtn = "<ul class='groups_field_list ".$this->id()."_groups'>";
$rtn .= "<li><label><input $attributes value='0'";
if (is_array($selected)){
if (in_array(0, $selected)){
$rtn .= " checked";
}
}
$rtn .= ">".__('All','rmcommon')."</label></li>";

if($typeinput == 'checkbox'){
$rtn .= "<li><label><input $attributes value='0'";
if (is_array($selected)){
if (in_array(0, $selected)){
$rtn .= " checked";
}
}
$rtn .= ">".__('All','rmcommon')."</label></li>";
}

while ($row = $db->fetchArray($result)){

$rtn .= "<li><label><input $attributes value='$row[groupid]'";
Expand All @@ -196,6 +201,7 @@ public function render(){
$rtn .= "</ul>";
} else {

$this->setIfNotSet('class', 'form-control');
$attributes = $this->renderAttributeString();
$rtn = "<select $attributes\"><option value='0'";
if (is_array($selected)){
Expand All @@ -204,14 +210,12 @@ public function render(){
}
}

$rtn .= ">".__('All','rmcommon')."</option>";
$rtn .= ">".__('Select...','rmcommon')."</option>";

while ($row = $db->fetchArray($result)){
$rtn .= "<option value='$row[groupid]'";
if (is_array($this->_select)){
if (in_array($row['groupid'], $selected)){
if (in_array($row['groupid'], $selected)){
$rtn .= " selected";
}
}
$rtn .= ">".$row['name']."</option>";
}
Expand Down
1 change: 1 addition & 0 deletions rmcommon/class/fields/language.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ function render()

$rtn .= "</ul></div>";
} else {
$this->setIfNotSet('class', 'form-control');
$attributes = $this->renderAttributeString();
$rtn = "<select $attributes>";
foreach ($langs as $k) {
Expand Down
20 changes: 15 additions & 5 deletions rmcommon/class/fields/modules.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,10 @@ function render()
$criteria->add(new Criteria('isactive', 1));
if ($this->get('subpages')) $criteria->add(new Criteria('dirname', 'system'), 'OR');
$modules = array();
$modules[-1] = __('All', 'rmcommon');

if($this->get('type') != 'radio'){
$modules[-1] = __('All', 'rmcommon');
}

if (is_array($this->get('insert'))) {
$modules = $this->get('insert');
Expand Down Expand Up @@ -211,9 +214,13 @@ function render()
$app = RMModules::load_module($k);

$rtn .= "<li>";
$rtn .= "<input $attributes name=\"".sprintf($name, $k)."\" value='$k'" . ($k == 0 ? "
data-checkbox='module-item-$k'" : " data-oncheck='module-item'") . "
id='" . $this->get('id') . "-$k'" . (is_array($selected) && in_array($k, $selected) ? " checked" : '') . ($k != -1 ? " data-checkbox='module-item-" . $k . "'" : '') . "> ";
$rtn .= "<input $attributes name=\"".sprintf($name, $k)."\"
value='$k'" .
($k == -1 ? "data-checkbox='" . $this->get('id') . "-module-item'" : " data-oncheck='" . $this->get('id') . "-module-item'") . "
id='" . $this->get('id') . "-$k'" .
(is_array($selected) && in_array($k, $selected) ? " checked" : '') .
($this->has('subpages') ? " data-checkbox='" . $this->get('id') . "-module-item-$k'" : '') . "> ";

if ($this->has('subpages') && $k>-1)
$rtn .= '<a href="#">' . $v . '</a>';
else
Expand Down Expand Up @@ -246,7 +253,9 @@ function render()
if (!is_array($subpages)) $subpages = array();

foreach ($subpages as $page => $caption) {
$rtns .= "<li class='checkbox'><label><input type='checkbox' data-oncheck='module-item-" . $k . "' name='" . sprintf($name, $k) . "[subpages][$page]' id='subpages-$k-$page' value='$page'" . (is_array($subpages) && @in_array($page, $selectedSubs[$k]) ? " checked='checked'" : '') . " /> $caption</label></li>";
$rtns .= "<li class='checkbox'>
<label>
<input type='checkbox' data-oncheck='".$this->get('id')."-module-item-" . $k . "' name='" . sprintf($name, $k) . "[subpages][$page]' id='subpages-$k-$page' value='$page'" . (is_array($subpages) && @in_array($page, $selectedSubs[$k]) ? " checked='checked'" : '') . " /> $caption</label></li>";
$j++;
$cr++;
}
Expand Down Expand Up @@ -282,6 +291,7 @@ function render()
if ($this->has('multiple')) {
$this->set('name', $this->get('name') . '[' . $k . ']');
}
$this->setIfNotSet('class', 'form-control');
$attributes = $this->renderAttributeString();

$rtn = "<select $attributes>";
Expand Down
2 changes: 1 addition & 1 deletion rmcommon/class/fields/select.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ public function addGroup($label, $id)
*/
function render()
{

$this->setIfNotSet('class', 'form-control');
$attributes = $this->renderAttributeString();
$selected = $this->get('value');

Expand Down
1 change: 1 addition & 0 deletions rmcommon/class/fields/text.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ function __construct($caption, $name = null, $size = 10, $maxlength = 0, $value

$this->setIfNotSet('type', 'text');
$this->setIfNotSet('value', '');
$this->setIfNotSet('class', 'form-control');
}

/**
Expand Down
2 changes: 1 addition & 1 deletion rmcommon/class/fields/theme.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ function render()
}
$rtn .= "</ul>";
} else {
$this->add('class', 'form-control');
$this->setIfNotSet('class', 'form-control');
$attributes = $this->renderAttributeString();
$rtn = "<select $attributes>";
foreach ($themes as $k => $name) {
Expand Down
66 changes: 38 additions & 28 deletions rmcommon/class/fields/timezone.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,23 @@ class RMFormTimeZoneField extends RMFormElement
private $size = 5;

public function __construct($caption, $name, $type = 0, $multi = 0, $selected = null, $size=5){
$this->setName($name);
$this->setCaption($caption);
$this->multi = $multi;
$this->type = $type;
$this->selected = $selected;

if (is_array($caption)) {
parent::__construct($caption);
} else {
parent::__construct([]);
$this->setWithDefaults('caption', $caption, '');
$this->setWithDefaults('name', $name, 'name_error');
$this->setWithDefaults('type', $type == 0 ? 'select' : ($multi == 0 ? 'radio' : 'checkbox'), 'select');
if($multi == 1){
$this->setWithDefaults('multiple', null);
}
$this->setWithDefaults('selected', $selected, []);
}

$this->setIfNotSet('class', 'form-control');

$this->suppressRender(['caption','name','multiple','selected']);
}
public function multi(){
return $this->multi;
Expand Down Expand Up @@ -50,36 +62,34 @@ public function setSize($value){
public function render(){
include_once XOOPS_ROOT_PATH."/class/xoopslists.php";
$zonas = XoopsLists::getTimeZoneList();
$selected = $this->get('selected');

if ($this->get('type') == 'readio' || $this->get('type') == 'checkbox'){

$this->suppressRender('class');
$attributes = $this->renderAttributeString();

if ($this->type){
$rtn = "<table cellpadding='2' cellspacing='1' border='0'>";
$rtn = "<div class='checkbox'>";
foreach ($zonas as $k => $v){
$rtn .= "<tr><td>";
if ($this->multi){
if (!is_array($this->selected)) $this->selected=array($this->selected);
$rtn .= "<label><input type='checkbox' value='$k' name='".$this->getName()."[]' id='".$this->id()."[]'".(is_array($this->selected) ? (in_array($k, $this->selected) ? " checked='checked'" : '') : '')." /> $v</label>";
if ($this->has('multiple')){
if (!is_array($selected)) $selected=array($selected);
$rtn .= "<label><input $attributes value='$k' ".(is_array($selected) ? (in_array($k, $selected) ? " checked='checked'" : '') : '')."> $v</label>";
} else {
$rtn .= "<label><input type='radio' value='$k' name='".$this->getName()."' id='".$this->id()."'".($k == $this->selected ? " checked='checked'" : '')." /> $v</label>";
$rtn .= "<label><input $attributes value='$k' ".($k == $selected ? " checked='checked'" : '')."> $v</label>";
}
$rtn .= "</td></tr>";
$i++;
}
$rtn .= "</table>";
$rtn .= "</div>";
} else {
if ($this->multi){
if (!is_array($this->selected)) $this->selected=array($this->selected);
$rtn = "<select name='".$this->getName()."[]' id='".$this->id()."[]' size='$this->size' multiple='multiple' class=\"form-control ". $this->getClass() . "\">";
foreach ($zonas as $k => $v){
$rtn .= "<option value='$k'".(is_array($this->selected) ? (in_array($k, $this->selected) ? " selected='selected'" : '') : '').">$v</option>";
}
$rtn .= "</select>";
} else {
$rtn = "<select name='".$this->getName()."' id='".$this->id()."' class=\"form-control ". $this->getClass() . "\">";
foreach ($zonas as $k => $v){
$rtn .= "<option value='$k'".($k==$this->selected ? " selected='selected'" : '').">$v</option>";
}
$rtn .= "</select>";
}

$attributes = $this->renderAttributeString();

if (!is_array($selected)) $selected=array($selected);
$rtn = "<select $attributes>";
foreach ($zonas as $k => $v){
$rtn .= "<option value='$k'".(is_array($selected) ? (in_array($k, $selected) ? " selected='selected'" : '') : '').">$v</option>";
}
$rtn .= "</select>";
}

return $rtn;
Expand Down
Loading

0 comments on commit 40fa8e5

Please sign in to comment.