| Current Path : /home/nicholsonsmith/public_html/plugins/system/mojoomdisclaimer/ |
| Current File : /home/nicholsonsmith/public_html/plugins/system/mojoomdisclaimer/assignment.php |
<?php
/**
* MOJoomDisclaimer Extension for Joomla By MO'WebCreation
*
*
* @copyright Copyright (C) 2014 MO'WebCreation. Mickaël Gerard André Outhier. All rights reserved.
* @license GNU General Public License version 2. Please check the "read me" file provided in the package
*
* @Website http://www.mo-web-creation.com/
* @Support https://github.com/MOWebCreation
*
*/
// No direct access
defined( '_JEXEC' ) or die( 'Restricted access' );
class JFormFieldAssignment extends JFormField
{
public function getInput() {
require_once(JPATH_ADMINISTRATOR.'/components/com_menus/helpers/menus.php');
require_once(JPATH_ADMINISTRATOR.'/components/com_modules/helpers/modules.php');
JHtml::addIncludePath(JPATH_COMPONENT . '/helpers/html');
JHtml::_('behavior.formvalidation');
JHtml::_('behavior.combobox');
JHtml::_('script', 'jui/treeselectmenu.jquery.min.js', false, true);
$menus = MenusHelper::getMenuLinks();
$moplg_params = @ json_decode(JPluginHelper::getPlugin('system','mojoomdisclaimer')->params, TRUE);
if(!is_array($moplg_params)) {
print '<b>'.JText::_('PLG_SYSTEM_MOJOOMDISCLAIMER_ERROR_NOT_ACTIVED').'</b>';
return FALSE;
}
$assignment = (string) JArrayHelper::getValue($moplg_params, 'assignment');
if(preg_match('#SeG#', $assignment)) {
$assignment_segs = explode('SeG', $moplg_params['assignment']);
$assignment = explode(',', $assignment_segs[1]);
}
else {
$moplg_params['assignment'] = '0SeG';
$assignment_segs = explode('SeG', '0SeG');
$assignment = explode(',', $assignment_segs[1]);
}
$assignment_select_options = array('0' => JText::_('PLG_SYSTEM_MOJOOMDISCLAIM_ASSIGNMENT_SELECT_ALL'),
'-2' => JText::_('PLG_SYSTEM_MOJOOMDISCLAIM_ASSIGNMENT_SELECT_NONE'),
'1' => JText::_('PLG_SYSTEM_MOJOOMDISCLAIM_ASSIGNMENT_SELECT_ONLYSELECTED'),
'-1' => JText::_('PLG_SYSTEM_MOJOOMDISCLAIM_ASSIGNMENT_SELECT_UNSELECTED'));
?>
<div class="control-group">
<div class="control-label"><label title="" class="hasTooltip required" for="jform_params_assignment_select" id="jform_params_assignment_select-lbl" data-original-title="<strong><?php print JText::_('PLG_SYSTEM_MOJOOMDISCLAIM_ASSIGNMENT_SELECT_LABEL');?></strong><br /><?php print JText::_('PLG_SYSTEM_MOJOOMDISCLAIM_ASSIGNMENT_SELECT_DESC');?>"><?php print JText::_('PLG_SYSTEM_MOJOOMDISCLAIM_ASSIGNMENT_SELECT_LABEL');?><span class="star"> *</span></label></div>
<div class="controls">
<select aria-required="true" required="" name="jform[params][assignment_select]" id="jform_params_assignment_select">
<?php foreach($assignment_select_options as $option_key => $option_val) : ?>
<?php if($option_key == $assignment_segs[0]) : ?>
<option value="<?php print $option_key;?>" selected="selected"><?php print $option_val;?></option>
<?php else : ?>
<option value="<?php print $option_key;?>"><?php print $option_val;?></option>
<?php endif; ?>
<?php endforeach; ?>
</select>
</div>
</div>
<fieldset id="assignment-menu-panel" class="well well-small">
<div class="form-inline">
<span class="small"><?php echo JText::_('JSELECT'); ?>:
<a id="treeCheckAll" href="#"><?php echo JText::_('JALL'); ?></a>,
<a id="treeUncheckAll" href="#"><?php echo JText::_('JNONE'); ?></a>
</span>
<span class="width-20">|</span>
<span class="small"><?php echo JText::_('PLG_SYSTEM_MOJOOMDISCLAIMER_ASSIGNMENT_EXPAND'); ?>:
<a id="treeExpandAll" href="#"><?php echo JText::_('JALL'); ?></a>,
<a id="treeCollapseAll" href="#"><?php echo JText::_('JNONE'); ?></a>
</span>
</div>
<?php foreach($menus as $menu) : ?>
<div class="menu-panel">
<i class="pull-left icon-plus nodys"></i>
<i class="pull-left icon-minus"></i>
<h3 class="nav-header"><?php print $menu->title;?></h3>
<ul class="treeselect">
<?php foreach($menu->links as $link) :
if(in_array($link->value, $assignment)) : //checked ?>
<li class="menu-item checked" id="id-<?php print $link->value;?>">
<input type="checkbox" class="pull-left item-menu checked" checked="checked" id="jform_assignment<?php print $link->value;?>" name="jform[assignment_items][<?php print $link->value;?>]" value="1" />
<label class="pull-left" for="jform_assignment<?php print $link->value;?>"><?php print $link->text;?><span class="small">(<span>Alias</span> : <?php print $link->alias;?>)</span></label>
<span class="clearfix"></span>
</li>
<?php else : //not checked ?>
<li class="menu-item" id="id-<?php print $link->value;?>">
<input type="checkbox" class="pull-left item-menu" id="jform_assignment<?php print $link->value;?>" name="jform[assignment_items][<?php print $link->value;?>]" value="1" />
<label class="pull-left" for="jform_assignment<?php print $link->value;?>"><?php print $link->text;?><span class="small">(<span>Alias</span> : <?php print $link->alias;?>)</span></label>
<span class="clearfix"></span>
</li>
<?php endif; ?>
<?php endforeach; ?>
</ul>
</div>
<?php endforeach; ?>
</fieldset>
<input id="jform_assignment" name="jform[params][assignment]" type="hidden" value="<?php print $moplg_params['assignment'];?>" />
<input id="jform_assignement_select_val" name="jform[assignment_select][val]" type="hidden" value="<?php print $assignment_segs[0];?>" />
<?php
}
}
?>