forked from joomla/Component-Builder
Added Joomla Module builder (JMB) Compiler and improved the JMB GUI
This commit is contained in:
parent
e4d1917c19
commit
6c2ca03ebc
13
admin/assets/css/component_modules.css
Normal file
13
admin/assets/css/component_modules.css
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
/**
|
||||||
|
* @package Joomla.Component.Builder
|
||||||
|
*
|
||||||
|
* @created 30th April, 2015
|
||||||
|
* @author Llewellyn van der Merwe <http://www.joomlacomponentbuilder.com>
|
||||||
|
* @github Joomla Component Builder <https://github.com/vdm-io/Joomla-Component-Builder>
|
||||||
|
* @copyright Copyright (C) 2015 - 2019 Vast Development Method. All rights reserved.
|
||||||
|
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* CSS Document */
|
||||||
|
|
||||||
|
|
13
admin/assets/css/components_modules.css
Normal file
13
admin/assets/css/components_modules.css
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
/**
|
||||||
|
* @package Joomla.Component.Builder
|
||||||
|
*
|
||||||
|
* @created 30th April, 2015
|
||||||
|
* @author Llewellyn van der Merwe <http://www.joomlacomponentbuilder.com>
|
||||||
|
* @github Joomla Component Builder <https://github.com/vdm-io/Joomla-Component-Builder>
|
||||||
|
* @copyright Copyright (C) 2015 - 2019 Vast Development Method. All rights reserved.
|
||||||
|
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* CSS Document */
|
||||||
|
|
||||||
|
|
321
admin/controllers/component_modules.php
Normal file
321
admin/controllers/component_modules.php
Normal file
@ -0,0 +1,321 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* @package Joomla.Component.Builder
|
||||||
|
*
|
||||||
|
* @created 30th April, 2015
|
||||||
|
* @author Llewellyn van der Merwe <http://www.joomlacomponentbuilder.com>
|
||||||
|
* @github Joomla Component Builder <https://github.com/vdm-io/Joomla-Component-Builder>
|
||||||
|
* @copyright Copyright (C) 2015 - 2019 Vast Development Method. All rights reserved.
|
||||||
|
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||||
|
*/
|
||||||
|
|
||||||
|
// No direct access to this file
|
||||||
|
defined('_JEXEC') or die('Restricted access');
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Component_modules Controller
|
||||||
|
*/
|
||||||
|
class ComponentbuilderControllerComponent_modules extends JControllerForm
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Current or most recently performed task.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
* @since 12.2
|
||||||
|
* @note Replaces _task.
|
||||||
|
*/
|
||||||
|
protected $task;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Class constructor.
|
||||||
|
*
|
||||||
|
* @param array $config A named array of configuration variables.
|
||||||
|
*
|
||||||
|
* @since 1.6
|
||||||
|
*/
|
||||||
|
public function __construct($config = array())
|
||||||
|
{
|
||||||
|
$this->view_list = 'Components_modules'; // safeguard for setting the return view listing to the main view.
|
||||||
|
parent::__construct($config);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method override to check if you can add a new record.
|
||||||
|
*
|
||||||
|
* @param array $data An array of input data.
|
||||||
|
*
|
||||||
|
* @return boolean
|
||||||
|
*
|
||||||
|
* @since 1.6
|
||||||
|
*/
|
||||||
|
protected function allowAdd($data = array())
|
||||||
|
{
|
||||||
|
// Get user object.
|
||||||
|
$user = JFactory::getUser();
|
||||||
|
// Access check.
|
||||||
|
$access = $user->authorise('component_modules.access', 'com_componentbuilder');
|
||||||
|
if (!$access)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// In the absense of better information, revert to the component permissions.
|
||||||
|
return $user->authorise('component_modules.create', $this->option);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method override to check if you can edit an existing record.
|
||||||
|
*
|
||||||
|
* @param array $data An array of input data.
|
||||||
|
* @param string $key The name of the key for the primary key.
|
||||||
|
*
|
||||||
|
* @return boolean
|
||||||
|
*
|
||||||
|
* @since 1.6
|
||||||
|
*/
|
||||||
|
protected function allowEdit($data = array(), $key = 'id')
|
||||||
|
{
|
||||||
|
// get user object.
|
||||||
|
$user = JFactory::getUser();
|
||||||
|
// get record id.
|
||||||
|
$recordId = (int) isset($data[$key]) ? $data[$key] : 0;
|
||||||
|
|
||||||
|
|
||||||
|
// Access check.
|
||||||
|
$access = ($user->authorise('component_modules.access', 'com_componentbuilder.component_modules.' . (int) $recordId) && $user->authorise('component_modules.access', 'com_componentbuilder'));
|
||||||
|
if (!$access)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($recordId)
|
||||||
|
{
|
||||||
|
// The record has been set. Check the record permissions.
|
||||||
|
$permission = $user->authorise('component_modules.edit', 'com_componentbuilder.component_modules.' . (int) $recordId);
|
||||||
|
if (!$permission)
|
||||||
|
{
|
||||||
|
if ($user->authorise('component_modules.edit.own', 'com_componentbuilder.component_modules.' . $recordId))
|
||||||
|
{
|
||||||
|
// Now test the owner is the user.
|
||||||
|
$ownerId = (int) isset($data['created_by']) ? $data['created_by'] : 0;
|
||||||
|
if (empty($ownerId))
|
||||||
|
{
|
||||||
|
// Need to do a lookup from the model.
|
||||||
|
$record = $this->getModel()->getItem($recordId);
|
||||||
|
|
||||||
|
if (empty($record))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
$ownerId = $record->created_by;
|
||||||
|
}
|
||||||
|
|
||||||
|
// If the owner matches 'me' then allow.
|
||||||
|
if ($ownerId == $user->id)
|
||||||
|
{
|
||||||
|
if ($user->authorise('component_modules.edit.own', 'com_componentbuilder'))
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Since there is no permission, revert to the component permissions.
|
||||||
|
return $user->authorise('component_modules.edit', $this->option);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the URL arguments to append to an item redirect.
|
||||||
|
*
|
||||||
|
* @param integer $recordId The primary key id for the item.
|
||||||
|
* @param string $urlVar The name of the URL variable for the id.
|
||||||
|
*
|
||||||
|
* @return string The arguments to append to the redirect URL.
|
||||||
|
*
|
||||||
|
* @since 1.6
|
||||||
|
*/
|
||||||
|
protected function getRedirectToItemAppend($recordId = null, $urlVar = 'id')
|
||||||
|
{
|
||||||
|
// get the referral options (old method use return instead see parent)
|
||||||
|
$ref = $this->input->get('ref', 0, 'string');
|
||||||
|
$refid = $this->input->get('refid', 0, 'int');
|
||||||
|
|
||||||
|
// get redirect info.
|
||||||
|
$append = parent::getRedirectToItemAppend($recordId, $urlVar);
|
||||||
|
|
||||||
|
// set the referral options
|
||||||
|
if ($refid && $ref)
|
||||||
|
{
|
||||||
|
$append = '&ref=' . (string)$ref . '&refid='. (int)$refid . $append;
|
||||||
|
}
|
||||||
|
elseif ($ref)
|
||||||
|
{
|
||||||
|
$append = '&ref='. (string)$ref . $append;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $append;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method to run batch operations.
|
||||||
|
*
|
||||||
|
* @param object $model The model.
|
||||||
|
*
|
||||||
|
* @return boolean True if successful, false otherwise and internal error is set.
|
||||||
|
*
|
||||||
|
* @since 2.5
|
||||||
|
*/
|
||||||
|
public function batch($model = null)
|
||||||
|
{
|
||||||
|
JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN'));
|
||||||
|
|
||||||
|
// Set the model
|
||||||
|
$model = $this->getModel('Component_modules', '', array());
|
||||||
|
|
||||||
|
// Preset the redirect
|
||||||
|
$this->setRedirect(JRoute::_('index.php?option=com_componentbuilder&view=components_modules' . $this->getRedirectToListAppend(), false));
|
||||||
|
|
||||||
|
return parent::batch($model);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method to cancel an edit.
|
||||||
|
*
|
||||||
|
* @param string $key The name of the primary key of the URL variable.
|
||||||
|
*
|
||||||
|
* @return boolean True if access level checks pass, false otherwise.
|
||||||
|
*
|
||||||
|
* @since 12.2
|
||||||
|
*/
|
||||||
|
public function cancel($key = null)
|
||||||
|
{
|
||||||
|
// get the referral options
|
||||||
|
$this->ref = $this->input->get('ref', 0, 'word');
|
||||||
|
$this->refid = $this->input->get('refid', 0, 'int');
|
||||||
|
|
||||||
|
// Check if there is a return value
|
||||||
|
$return = $this->input->get('return', null, 'base64');
|
||||||
|
|
||||||
|
$cancel = parent::cancel($key);
|
||||||
|
|
||||||
|
if (!is_null($return) && JUri::isInternal(base64_decode($return)))
|
||||||
|
{
|
||||||
|
$redirect = base64_decode($return);
|
||||||
|
|
||||||
|
// Redirect to the return value.
|
||||||
|
$this->setRedirect(
|
||||||
|
JRoute::_(
|
||||||
|
$redirect, false
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
elseif ($this->refid && $this->ref)
|
||||||
|
{
|
||||||
|
$redirect = '&view=' . (string)$this->ref . '&layout=edit&id=' . (int)$this->refid;
|
||||||
|
|
||||||
|
// Redirect to the item screen.
|
||||||
|
$this->setRedirect(
|
||||||
|
JRoute::_(
|
||||||
|
'index.php?option=' . $this->option . $redirect, false
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
elseif ($this->ref)
|
||||||
|
{
|
||||||
|
$redirect = '&view='.(string)$this->ref;
|
||||||
|
|
||||||
|
// Redirect to the list screen.
|
||||||
|
$this->setRedirect(
|
||||||
|
JRoute::_(
|
||||||
|
'index.php?option=' . $this->option . $redirect, false
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return $cancel;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method to save a record.
|
||||||
|
*
|
||||||
|
* @param string $key The name of the primary key of the URL variable.
|
||||||
|
* @param string $urlVar The name of the URL variable if different from the primary key (sometimes required to avoid router collisions).
|
||||||
|
*
|
||||||
|
* @return boolean True if successful, false otherwise.
|
||||||
|
*
|
||||||
|
* @since 12.2
|
||||||
|
*/
|
||||||
|
public function save($key = null, $urlVar = null)
|
||||||
|
{
|
||||||
|
// get the referral options
|
||||||
|
$this->ref = $this->input->get('ref', 0, 'word');
|
||||||
|
$this->refid = $this->input->get('refid', 0, 'int');
|
||||||
|
|
||||||
|
// Check if there is a return value
|
||||||
|
$return = $this->input->get('return', null, 'base64');
|
||||||
|
$canReturn = (!is_null($return) && JUri::isInternal(base64_decode($return)));
|
||||||
|
|
||||||
|
if ($this->ref || $this->refid || $canReturn)
|
||||||
|
{
|
||||||
|
// to make sure the item is checkedin on redirect
|
||||||
|
$this->task = 'save';
|
||||||
|
}
|
||||||
|
|
||||||
|
$saved = parent::save($key, $urlVar);
|
||||||
|
|
||||||
|
// This is not needed since parent save already does this
|
||||||
|
// Due to the ref and refid implementation we need to add this
|
||||||
|
if ($canReturn)
|
||||||
|
{
|
||||||
|
$redirect = base64_decode($return);
|
||||||
|
|
||||||
|
// Redirect to the return value.
|
||||||
|
$this->setRedirect(
|
||||||
|
JRoute::_(
|
||||||
|
$redirect, false
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
elseif ($this->refid && $this->ref)
|
||||||
|
{
|
||||||
|
$redirect = '&view=' . (string)$this->ref . '&layout=edit&id=' . (int)$this->refid;
|
||||||
|
|
||||||
|
// Redirect to the item screen.
|
||||||
|
$this->setRedirect(
|
||||||
|
JRoute::_(
|
||||||
|
'index.php?option=' . $this->option . $redirect, false
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
elseif ($this->ref)
|
||||||
|
{
|
||||||
|
$redirect = '&view=' . (string)$this->ref;
|
||||||
|
|
||||||
|
// Redirect to the list screen.
|
||||||
|
$this->setRedirect(
|
||||||
|
JRoute::_(
|
||||||
|
'index.php?option=' . $this->option . $redirect, false
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return $saved;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Function that allows child controller access to model data
|
||||||
|
* after the data has been saved.
|
||||||
|
*
|
||||||
|
* @param JModel &$model The data model object.
|
||||||
|
* @param array $validData The validated data.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*
|
||||||
|
* @since 11.1
|
||||||
|
*/
|
||||||
|
protected function postSaveHook(JModelLegacy $model, $validData = array())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
43
admin/controllers/components_modules.php
Normal file
43
admin/controllers/components_modules.php
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* @package Joomla.Component.Builder
|
||||||
|
*
|
||||||
|
* @created 30th April, 2015
|
||||||
|
* @author Llewellyn van der Merwe <http://www.joomlacomponentbuilder.com>
|
||||||
|
* @github Joomla Component Builder <https://github.com/vdm-io/Joomla-Component-Builder>
|
||||||
|
* @copyright Copyright (C) 2015 - 2019 Vast Development Method. All rights reserved.
|
||||||
|
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||||
|
*/
|
||||||
|
|
||||||
|
// No direct access to this file
|
||||||
|
defined('_JEXEC') or die('Restricted access');
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Components_modules Controller
|
||||||
|
*/
|
||||||
|
class ComponentbuilderControllerComponents_modules extends JControllerAdmin
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* The prefix to use with controller messages.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
* @since 1.6
|
||||||
|
*/
|
||||||
|
protected $text_prefix = 'COM_COMPONENTBUILDER_COMPONENTS_MODULES';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method to get a model object, loading it if required.
|
||||||
|
*
|
||||||
|
* @param string $name The model name. Optional.
|
||||||
|
* @param string $prefix The class prefix. Optional.
|
||||||
|
* @param array $config Configuration array for model. Optional.
|
||||||
|
*
|
||||||
|
* @return JModelLegacy The model.
|
||||||
|
*
|
||||||
|
* @since 1.6
|
||||||
|
*/
|
||||||
|
public function getModel($name = 'Component_modules', $prefix = 'ComponentbuilderModel', $config = array('ignore_request' => true))
|
||||||
|
{
|
||||||
|
return parent::getModel($name, $prefix, $config);
|
||||||
|
}
|
||||||
|
}
|
1
admin/layouts/component_modules/index.html
Normal file
1
admin/layouts/component_modules/index.html
Normal file
@ -0,0 +1 @@
|
|||||||
|
<html><body bgcolor="#FFFFFF"></body></html>
|
44
admin/layouts/component_modules/modules_above.php
Normal file
44
admin/layouts/component_modules/modules_above.php
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* @package Joomla.Component.Builder
|
||||||
|
*
|
||||||
|
* @created 30th April, 2015
|
||||||
|
* @author Llewellyn van der Merwe <http://www.joomlacomponentbuilder.com>
|
||||||
|
* @github Joomla Component Builder <https://github.com/vdm-io/Joomla-Component-Builder>
|
||||||
|
* @copyright Copyright (C) 2015 - 2019 Vast Development Method. All rights reserved.
|
||||||
|
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||||
|
*/
|
||||||
|
|
||||||
|
// No direct access to this file
|
||||||
|
defined('_JEXEC') or die('Restricted access');
|
||||||
|
|
||||||
|
// get the form
|
||||||
|
$form = $displayData->getForm();
|
||||||
|
|
||||||
|
// get the layout fields override method name (from layout path/ID)
|
||||||
|
$layout_path_array = explode('.', $this->getLayoutId());
|
||||||
|
// Since we cannot pass the layout and tab names as parameters to the model method
|
||||||
|
// this name combination of tab and layout in the method name is the only work around
|
||||||
|
// seeing that JCB uses those two values (tab_name & layout_name) as the layout file name.
|
||||||
|
// example of layout name: details_left.php
|
||||||
|
// example of method name: getFields_details_left()
|
||||||
|
$fields_tab_layout = 'fields_' . $layout_path_array[1];
|
||||||
|
|
||||||
|
// get the fields
|
||||||
|
$fields = $displayData->get($fields_tab_layout) ?: array(
|
||||||
|
'joomla_component'
|
||||||
|
);
|
||||||
|
|
||||||
|
$hiddenFields = $displayData->get('hidden_fields') ?: array();
|
||||||
|
|
||||||
|
?>
|
||||||
|
<?php if ($fields && count((array) $fields)) :?>
|
||||||
|
<div class="form-inline form-inline-header">
|
||||||
|
<?php foreach($fields as $field): ?>
|
||||||
|
<?php if (in_array($field, $hiddenFields)) : ?>
|
||||||
|
<?php $form->setFieldAttribute($field, 'type', 'hidden'); ?>
|
||||||
|
<?php endif; ?>
|
||||||
|
<?php echo $form->renderField($field, null, null, array('class' => 'control-wrapper-' . $field)); ?>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
</div>
|
||||||
|
<?php endif; ?>
|
45
admin/layouts/component_modules/modules_fullwidth.php
Normal file
45
admin/layouts/component_modules/modules_fullwidth.php
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* @package Joomla.Component.Builder
|
||||||
|
*
|
||||||
|
* @created 30th April, 2015
|
||||||
|
* @author Llewellyn van der Merwe <http://www.joomlacomponentbuilder.com>
|
||||||
|
* @github Joomla Component Builder <https://github.com/vdm-io/Joomla-Component-Builder>
|
||||||
|
* @copyright Copyright (C) 2015 - 2019 Vast Development Method. All rights reserved.
|
||||||
|
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||||
|
*/
|
||||||
|
|
||||||
|
// No direct access to this file
|
||||||
|
defined('_JEXEC') or die('Restricted access');
|
||||||
|
|
||||||
|
// get the form
|
||||||
|
$form = $displayData->getForm();
|
||||||
|
|
||||||
|
// get the layout fields override method name (from layout path/ID)
|
||||||
|
$layout_path_array = explode('.', $this->getLayoutId());
|
||||||
|
// Since we cannot pass the layout and tab names as parameters to the model method
|
||||||
|
// this name combination of tab and layout in the method name is the only work around
|
||||||
|
// seeing that JCB uses those two values (tab_name & layout_name) as the layout file name.
|
||||||
|
// example of layout name: details_left.php
|
||||||
|
// example of method name: getFields_details_left()
|
||||||
|
$fields_tab_layout = 'fields_' . $layout_path_array[1];
|
||||||
|
|
||||||
|
// get the fields
|
||||||
|
$fields = $displayData->get($fields_tab_layout) ?: array(
|
||||||
|
'note_on_joomla_modules',
|
||||||
|
'addjoomla_modules'
|
||||||
|
);
|
||||||
|
|
||||||
|
$hiddenFields = $displayData->get('hidden_fields') ?: array();
|
||||||
|
|
||||||
|
?>
|
||||||
|
<?php if ($fields && count((array) $fields)) :?>
|
||||||
|
<div class="form-vertical">
|
||||||
|
<?php foreach($fields as $field): ?>
|
||||||
|
<?php if (in_array($field, $hiddenFields)) : ?>
|
||||||
|
<?php $form->setFieldAttribute($field, 'type', 'hidden'); ?>
|
||||||
|
<?php endif; ?>
|
||||||
|
<?php echo $form->renderField($field, null, null, array('class' => 'control-wrapper-' . $field)); ?>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
</div>
|
||||||
|
<?php endif; ?>
|
45
admin/layouts/component_modules/publishing.php
Normal file
45
admin/layouts/component_modules/publishing.php
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* @package Joomla.Component.Builder
|
||||||
|
*
|
||||||
|
* @created 30th April, 2015
|
||||||
|
* @author Llewellyn van der Merwe <http://www.joomlacomponentbuilder.com>
|
||||||
|
* @github Joomla Component Builder <https://github.com/vdm-io/Joomla-Component-Builder>
|
||||||
|
* @copyright Copyright (C) 2015 - 2019 Vast Development Method. All rights reserved.
|
||||||
|
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||||
|
*/
|
||||||
|
|
||||||
|
// No direct access to this file
|
||||||
|
defined('_JEXEC') or die('Restricted access');
|
||||||
|
|
||||||
|
// get the form
|
||||||
|
$form = $displayData->getForm();
|
||||||
|
|
||||||
|
// get the layout fields override method name (from layout path/ID)
|
||||||
|
$layout_path_array = explode('.', $this->getLayoutId());
|
||||||
|
// Since we cannot pass the layout and tab names as parameters to the model method
|
||||||
|
// this name combination of tab and layout in the method name is the only work around
|
||||||
|
// seeing that JCB uses those two values (tab_name & layout_name) as the layout file name.
|
||||||
|
// example of layout name: details_left.php
|
||||||
|
// example of method name: getFields_details_left()
|
||||||
|
$fields_tab_layout = 'fields_' . $layout_path_array[1];
|
||||||
|
|
||||||
|
// get the fields
|
||||||
|
$fields = $displayData->get($fields_tab_layout) ?: array(
|
||||||
|
'created',
|
||||||
|
'created_by',
|
||||||
|
'modified',
|
||||||
|
'modified_by'
|
||||||
|
);
|
||||||
|
|
||||||
|
$hiddenFields = $displayData->get('hidden_fields') ?: array();
|
||||||
|
|
||||||
|
?>
|
||||||
|
<?php if ($fields && count((array) $fields)) :?>
|
||||||
|
<?php foreach($fields as $field): ?>
|
||||||
|
<?php if (in_array($field, $hiddenFields)) : ?>
|
||||||
|
<?php $form->setFieldAttribute($field, 'type', 'hidden'); ?>
|
||||||
|
<?php endif; ?>
|
||||||
|
<?php echo $form->renderField($field, null, null, array('class' => 'control-wrapper-' . $field)); ?>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
<?php endif; ?>
|
47
admin/layouts/component_modules/publlshing.php
Normal file
47
admin/layouts/component_modules/publlshing.php
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* @package Joomla.Component.Builder
|
||||||
|
*
|
||||||
|
* @created 30th April, 2015
|
||||||
|
* @author Llewellyn van der Merwe <http://www.joomlacomponentbuilder.com>
|
||||||
|
* @github Joomla Component Builder <https://github.com/vdm-io/Joomla-Component-Builder>
|
||||||
|
* @copyright Copyright (C) 2015 - 2019 Vast Development Method. All rights reserved.
|
||||||
|
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||||
|
*/
|
||||||
|
|
||||||
|
// No direct access to this file
|
||||||
|
defined('_JEXEC') or die('Restricted access');
|
||||||
|
|
||||||
|
// get the form
|
||||||
|
$form = $displayData->getForm();
|
||||||
|
|
||||||
|
// get the layout fields override method name (from layout path/ID)
|
||||||
|
$layout_path_array = explode('.', $this->getLayoutId());
|
||||||
|
// Since we cannot pass the layout and tab names as parameters to the model method
|
||||||
|
// this name combination of tab and layout in the method name is the only work around
|
||||||
|
// seeing that JCB uses those two values (tab_name & layout_name) as the layout file name.
|
||||||
|
// example of layout name: details_left.php
|
||||||
|
// example of method name: getFields_details_left()
|
||||||
|
$fields_tab_layout = 'fields_' . $layout_path_array[1];
|
||||||
|
|
||||||
|
// get the fields
|
||||||
|
$fields = $displayData->get($fields_tab_layout) ?: array(
|
||||||
|
'published',
|
||||||
|
'ordering',
|
||||||
|
'access',
|
||||||
|
'version',
|
||||||
|
'hits',
|
||||||
|
'id'
|
||||||
|
);
|
||||||
|
|
||||||
|
$hiddenFields = $displayData->get('hidden_fields') ?: array();
|
||||||
|
|
||||||
|
?>
|
||||||
|
<?php if ($fields && count((array) $fields)) :?>
|
||||||
|
<?php foreach($fields as $field): ?>
|
||||||
|
<?php if (in_array($field, $hiddenFields)) : ?>
|
||||||
|
<?php $form->setFieldAttribute($field, 'type', 'hidden'); ?>
|
||||||
|
<?php endif; ?>
|
||||||
|
<?php echo $form->renderField($field, null, null, array('class' => 'control-wrapper-' . $field)); ?>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
<?php endif; ?>
|
45
admin/layouts/joomla_module/helper_fullwidth.php
Normal file
45
admin/layouts/joomla_module/helper_fullwidth.php
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* @package Joomla.Component.Builder
|
||||||
|
*
|
||||||
|
* @created 30th April, 2015
|
||||||
|
* @author Llewellyn van der Merwe <http://www.joomlacomponentbuilder.com>
|
||||||
|
* @github Joomla Component Builder <https://github.com/vdm-io/Joomla-Component-Builder>
|
||||||
|
* @copyright Copyright (C) 2015 - 2019 Vast Development Method. All rights reserved.
|
||||||
|
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||||
|
*/
|
||||||
|
|
||||||
|
// No direct access to this file
|
||||||
|
defined('_JEXEC') or die('Restricted access');
|
||||||
|
|
||||||
|
// get the form
|
||||||
|
$form = $displayData->getForm();
|
||||||
|
|
||||||
|
// get the layout fields override method name (from layout path/ID)
|
||||||
|
$layout_path_array = explode('.', $this->getLayoutId());
|
||||||
|
// Since we cannot pass the layout and tab names as parameters to the model method
|
||||||
|
// this name combination of tab and layout in the method name is the only work around
|
||||||
|
// seeing that JCB uses those two values (tab_name & layout_name) as the layout file name.
|
||||||
|
// example of layout name: details_left.php
|
||||||
|
// example of method name: getFields_details_left()
|
||||||
|
$fields_tab_layout = 'fields_' . $layout_path_array[1];
|
||||||
|
|
||||||
|
// get the fields
|
||||||
|
$fields = $displayData->get($fields_tab_layout) ?: array(
|
||||||
|
'class_helper_header',
|
||||||
|
'class_helper_code'
|
||||||
|
);
|
||||||
|
|
||||||
|
$hiddenFields = $displayData->get('hidden_fields') ?: array();
|
||||||
|
|
||||||
|
?>
|
||||||
|
<?php if ($fields && count((array) $fields)) :?>
|
||||||
|
<div class="form-vertical">
|
||||||
|
<?php foreach($fields as $field): ?>
|
||||||
|
<?php if (in_array($field, $hiddenFields)) : ?>
|
||||||
|
<?php $form->setFieldAttribute($field, 'type', 'hidden'); ?>
|
||||||
|
<?php endif; ?>
|
||||||
|
<?php echo $form->renderField($field, null, null, array('class' => 'control-wrapper-' . $field)); ?>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
</div>
|
||||||
|
<?php endif; ?>
|
42
admin/layouts/joomla_module/helper_left.php
Normal file
42
admin/layouts/joomla_module/helper_left.php
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* @package Joomla.Component.Builder
|
||||||
|
*
|
||||||
|
* @created 30th April, 2015
|
||||||
|
* @author Llewellyn van der Merwe <http://www.joomlacomponentbuilder.com>
|
||||||
|
* @github Joomla Component Builder <https://github.com/vdm-io/Joomla-Component-Builder>
|
||||||
|
* @copyright Copyright (C) 2015 - 2019 Vast Development Method. All rights reserved.
|
||||||
|
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||||
|
*/
|
||||||
|
|
||||||
|
// No direct access to this file
|
||||||
|
defined('_JEXEC') or die('Restricted access');
|
||||||
|
|
||||||
|
// get the form
|
||||||
|
$form = $displayData->getForm();
|
||||||
|
|
||||||
|
// get the layout fields override method name (from layout path/ID)
|
||||||
|
$layout_path_array = explode('.', $this->getLayoutId());
|
||||||
|
// Since we cannot pass the layout and tab names as parameters to the model method
|
||||||
|
// this name combination of tab and layout in the method name is the only work around
|
||||||
|
// seeing that JCB uses those two values (tab_name & layout_name) as the layout file name.
|
||||||
|
// example of layout name: details_left.php
|
||||||
|
// example of method name: getFields_details_left()
|
||||||
|
$fields_tab_layout = 'fields_' . $layout_path_array[1];
|
||||||
|
|
||||||
|
// get the fields
|
||||||
|
$fields = $displayData->get($fields_tab_layout) ?: array(
|
||||||
|
'add_class_helper'
|
||||||
|
);
|
||||||
|
|
||||||
|
$hiddenFields = $displayData->get('hidden_fields') ?: array();
|
||||||
|
|
||||||
|
?>
|
||||||
|
<?php if ($fields && count((array) $fields)) :?>
|
||||||
|
<?php foreach($fields as $field): ?>
|
||||||
|
<?php if (in_array($field, $hiddenFields)) : ?>
|
||||||
|
<?php $form->setFieldAttribute($field, 'type', 'hidden'); ?>
|
||||||
|
<?php endif; ?>
|
||||||
|
<?php echo $form->renderField($field, null, null, array('class' => 'control-wrapper-' . $field)); ?>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
<?php endif; ?>
|
42
admin/layouts/joomla_module/helper_right.php
Normal file
42
admin/layouts/joomla_module/helper_right.php
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* @package Joomla.Component.Builder
|
||||||
|
*
|
||||||
|
* @created 30th April, 2015
|
||||||
|
* @author Llewellyn van der Merwe <http://www.joomlacomponentbuilder.com>
|
||||||
|
* @github Joomla Component Builder <https://github.com/vdm-io/Joomla-Component-Builder>
|
||||||
|
* @copyright Copyright (C) 2015 - 2019 Vast Development Method. All rights reserved.
|
||||||
|
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||||
|
*/
|
||||||
|
|
||||||
|
// No direct access to this file
|
||||||
|
defined('_JEXEC') or die('Restricted access');
|
||||||
|
|
||||||
|
// get the form
|
||||||
|
$form = $displayData->getForm();
|
||||||
|
|
||||||
|
// get the layout fields override method name (from layout path/ID)
|
||||||
|
$layout_path_array = explode('.', $this->getLayoutId());
|
||||||
|
// Since we cannot pass the layout and tab names as parameters to the model method
|
||||||
|
// this name combination of tab and layout in the method name is the only work around
|
||||||
|
// seeing that JCB uses those two values (tab_name & layout_name) as the layout file name.
|
||||||
|
// example of layout name: details_left.php
|
||||||
|
// example of method name: getFields_details_left()
|
||||||
|
$fields_tab_layout = 'fields_' . $layout_path_array[1];
|
||||||
|
|
||||||
|
// get the fields
|
||||||
|
$fields = $displayData->get($fields_tab_layout) ?: array(
|
||||||
|
'add_class_helper_header'
|
||||||
|
);
|
||||||
|
|
||||||
|
$hiddenFields = $displayData->get('hidden_fields') ?: array();
|
||||||
|
|
||||||
|
?>
|
||||||
|
<?php if ($fields && count((array) $fields)) :?>
|
||||||
|
<?php foreach($fields as $field): ?>
|
||||||
|
<?php if (in_array($field, $hiddenFields)) : ?>
|
||||||
|
<?php $form->setFieldAttribute($field, 'type', 'hidden'); ?>
|
||||||
|
<?php endif; ?>
|
||||||
|
<?php echo $form->renderField($field, null, null, array('class' => 'control-wrapper-' . $field)); ?>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
<?php endif; ?>
|
898
admin/models/component_modules.php
Normal file
898
admin/models/component_modules.php
Normal file
@ -0,0 +1,898 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* @package Joomla.Component.Builder
|
||||||
|
*
|
||||||
|
* @created 30th April, 2015
|
||||||
|
* @author Llewellyn van der Merwe <http://www.joomlacomponentbuilder.com>
|
||||||
|
* @github Joomla Component Builder <https://github.com/vdm-io/Joomla-Component-Builder>
|
||||||
|
* @copyright Copyright (C) 2015 - 2019 Vast Development Method. All rights reserved.
|
||||||
|
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||||
|
*/
|
||||||
|
|
||||||
|
// No direct access to this file
|
||||||
|
defined('_JEXEC') or die('Restricted access');
|
||||||
|
|
||||||
|
use Joomla\Registry\Registry;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Componentbuilder Component_modules Model
|
||||||
|
*/
|
||||||
|
class ComponentbuilderModelComponent_modules extends JModelAdmin
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* The tab layout fields array.
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
*/
|
||||||
|
protected $tabLayoutFields = array(
|
||||||
|
'modules' => array(
|
||||||
|
'fullwidth' => array(
|
||||||
|
'note_on_joomla_modules',
|
||||||
|
'addjoomla_modules'
|
||||||
|
),
|
||||||
|
'above' => array(
|
||||||
|
'joomla_component'
|
||||||
|
)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var string The prefix to use with controller messages.
|
||||||
|
* @since 1.6
|
||||||
|
*/
|
||||||
|
protected $text_prefix = 'COM_COMPONENTBUILDER';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The type alias for this content type.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
* @since 3.2
|
||||||
|
*/
|
||||||
|
public $typeAlias = 'com_componentbuilder.component_modules';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a Table object, always creating it
|
||||||
|
*
|
||||||
|
* @param type $type The table type to instantiate
|
||||||
|
* @param string $prefix A prefix for the table class name. Optional.
|
||||||
|
* @param array $config Configuration array for model. Optional.
|
||||||
|
*
|
||||||
|
* @return JTable A database object
|
||||||
|
*
|
||||||
|
* @since 1.6
|
||||||
|
*/
|
||||||
|
public function getTable($type = 'component_modules', $prefix = 'ComponentbuilderTable', $config = array())
|
||||||
|
{
|
||||||
|
// add table path for when model gets used from other component
|
||||||
|
$this->addTablePath(JPATH_ADMINISTRATOR . '/components/com_componentbuilder/tables');
|
||||||
|
// get instance of the table
|
||||||
|
return JTable::getInstance($type, $prefix, $config);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method to get a single record.
|
||||||
|
*
|
||||||
|
* @param integer $pk The id of the primary key.
|
||||||
|
*
|
||||||
|
* @return mixed Object on success, false on failure.
|
||||||
|
*
|
||||||
|
* @since 1.6
|
||||||
|
*/
|
||||||
|
public function getItem($pk = null)
|
||||||
|
{
|
||||||
|
if ($item = parent::getItem($pk))
|
||||||
|
{
|
||||||
|
if (!empty($item->params) && !is_array($item->params))
|
||||||
|
{
|
||||||
|
// Convert the params field to an array.
|
||||||
|
$registry = new Registry;
|
||||||
|
$registry->loadString($item->params);
|
||||||
|
$item->params = $registry->toArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!empty($item->metadata))
|
||||||
|
{
|
||||||
|
// Convert the metadata field to an array.
|
||||||
|
$registry = new Registry;
|
||||||
|
$registry->loadString($item->metadata);
|
||||||
|
$item->metadata = $registry->toArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!empty($item->addjoomla_modules))
|
||||||
|
{
|
||||||
|
// Convert the addjoomla_modules field to an array.
|
||||||
|
$addjoomla_modules = new Registry;
|
||||||
|
$addjoomla_modules->loadString($item->addjoomla_modules);
|
||||||
|
$item->addjoomla_modules = $addjoomla_modules->toArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!empty($item->id))
|
||||||
|
{
|
||||||
|
$item->tags = new JHelperTags;
|
||||||
|
$item->tags->getTagIds($item->id, 'com_componentbuilder.component_modules');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $item;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method to get the record form.
|
||||||
|
*
|
||||||
|
* @param array $data Data for the form.
|
||||||
|
* @param boolean $loadData True if the form is to load its own data (default case), false if not.
|
||||||
|
* @param array $options Optional array of options for the form creation.
|
||||||
|
*
|
||||||
|
* @return mixed A JForm object on success, false on failure
|
||||||
|
*
|
||||||
|
* @since 1.6
|
||||||
|
*/
|
||||||
|
public function getForm($data = array(), $loadData = true, $options = array('control' => 'jform'))
|
||||||
|
{
|
||||||
|
// set load data option
|
||||||
|
$options['load_data'] = $loadData;
|
||||||
|
// // check if xpath was set in options
|
||||||
|
$xpath = false;
|
||||||
|
if (isset($options['xpath']))
|
||||||
|
{
|
||||||
|
$xpath = $options['xpath'];
|
||||||
|
unset($options['xpath']);
|
||||||
|
}
|
||||||
|
// // check if clear form was set in options
|
||||||
|
$clear = false;
|
||||||
|
if (isset($options['clear']))
|
||||||
|
{
|
||||||
|
$clear = $options['clear'];
|
||||||
|
unset($options['clear']);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get the form.
|
||||||
|
$form = $this->loadForm('com_componentbuilder.component_modules', 'component_modules', $options, $clear, $xpath);
|
||||||
|
|
||||||
|
if (empty($form))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
$jinput = JFactory::getApplication()->input;
|
||||||
|
|
||||||
|
// The front end calls this model and uses a_id to avoid id clashes so we need to check for that first.
|
||||||
|
if ($jinput->get('a_id'))
|
||||||
|
{
|
||||||
|
$id = $jinput->get('a_id', 0, 'INT');
|
||||||
|
}
|
||||||
|
// The back end uses id so we use that the rest of the time and set it to 0 by default.
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$id = $jinput->get('id', 0, 'INT');
|
||||||
|
}
|
||||||
|
|
||||||
|
$user = JFactory::getUser();
|
||||||
|
|
||||||
|
// Check for existing item.
|
||||||
|
// Modify the form based on Edit State access controls.
|
||||||
|
if ($id != 0 && (!$user->authorise('component_modules.edit.state', 'com_componentbuilder.component_modules.' . (int) $id))
|
||||||
|
|| ($id == 0 && !$user->authorise('component_modules.edit.state', 'com_componentbuilder')))
|
||||||
|
{
|
||||||
|
// Disable fields for display.
|
||||||
|
$form->setFieldAttribute('ordering', 'disabled', 'true');
|
||||||
|
$form->setFieldAttribute('published', 'disabled', 'true');
|
||||||
|
// Disable fields while saving.
|
||||||
|
$form->setFieldAttribute('ordering', 'filter', 'unset');
|
||||||
|
$form->setFieldAttribute('published', 'filter', 'unset');
|
||||||
|
}
|
||||||
|
// If this is a new item insure the greated by is set.
|
||||||
|
if (0 == $id)
|
||||||
|
{
|
||||||
|
// Set the created_by to this user
|
||||||
|
$form->setValue('created_by', null, $user->id);
|
||||||
|
}
|
||||||
|
// Modify the form based on Edit Creaded By access controls.
|
||||||
|
if ($id != 0 && (!$user->authorise('component_modules.edit.created_by', 'com_componentbuilder.component_modules.' . (int) $id))
|
||||||
|
|| ($id == 0 && !$user->authorise('component_modules.edit.created_by', 'com_componentbuilder')))
|
||||||
|
{
|
||||||
|
// Disable fields for display.
|
||||||
|
$form->setFieldAttribute('created_by', 'disabled', 'true');
|
||||||
|
// Disable fields for display.
|
||||||
|
$form->setFieldAttribute('created_by', 'readonly', 'true');
|
||||||
|
// Disable fields while saving.
|
||||||
|
$form->setFieldAttribute('created_by', 'filter', 'unset');
|
||||||
|
}
|
||||||
|
// Modify the form based on Edit Creaded Date access controls.
|
||||||
|
if ($id != 0 && (!$user->authorise('component_modules.edit.created', 'com_componentbuilder.component_modules.' . (int) $id))
|
||||||
|
|| ($id == 0 && !$user->authorise('component_modules.edit.created', 'com_componentbuilder')))
|
||||||
|
{
|
||||||
|
// Disable fields for display.
|
||||||
|
$form->setFieldAttribute('created', 'disabled', 'true');
|
||||||
|
// Disable fields while saving.
|
||||||
|
$form->setFieldAttribute('created', 'filter', 'unset');
|
||||||
|
}
|
||||||
|
// Only load these values if no id is found
|
||||||
|
if (0 == $id)
|
||||||
|
{
|
||||||
|
// Set redirected view name
|
||||||
|
$redirectedView = $jinput->get('ref', null, 'STRING');
|
||||||
|
// Set field name (or fall back to view name)
|
||||||
|
$redirectedField = $jinput->get('field', $redirectedView, 'STRING');
|
||||||
|
// Set redirected view id
|
||||||
|
$redirectedId = $jinput->get('refid', 0, 'INT');
|
||||||
|
// Set field id (or fall back to redirected view id)
|
||||||
|
$redirectedValue = $jinput->get('field_id', $redirectedId, 'INT');
|
||||||
|
if (0 != $redirectedValue && $redirectedField)
|
||||||
|
{
|
||||||
|
// Now set the local-redirected field default value
|
||||||
|
$form->setValue($redirectedField, null, $redirectedValue);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $form;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method to get the script that have to be included on the form
|
||||||
|
*
|
||||||
|
* @return string script files
|
||||||
|
*/
|
||||||
|
public function getScript()
|
||||||
|
{
|
||||||
|
return 'administrator/components/com_componentbuilder/models/forms/component_modules.js';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method to test whether a record can be deleted.
|
||||||
|
*
|
||||||
|
* @param object $record A record object.
|
||||||
|
*
|
||||||
|
* @return boolean True if allowed to delete the record. Defaults to the permission set in the component.
|
||||||
|
*
|
||||||
|
* @since 1.6
|
||||||
|
*/
|
||||||
|
protected function canDelete($record)
|
||||||
|
{
|
||||||
|
if (!empty($record->id))
|
||||||
|
{
|
||||||
|
if ($record->published != -2)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$user = JFactory::getUser();
|
||||||
|
// The record has been set. Check the record permissions.
|
||||||
|
return $user->authorise('component_modules.delete', 'com_componentbuilder.component_modules.' . (int) $record->id);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method to test whether a record can have its state edited.
|
||||||
|
*
|
||||||
|
* @param object $record A record object.
|
||||||
|
*
|
||||||
|
* @return boolean True if allowed to change the state of the record. Defaults to the permission set in the component.
|
||||||
|
*
|
||||||
|
* @since 1.6
|
||||||
|
*/
|
||||||
|
protected function canEditState($record)
|
||||||
|
{
|
||||||
|
$user = JFactory::getUser();
|
||||||
|
$recordId = (!empty($record->id)) ? $record->id : 0;
|
||||||
|
|
||||||
|
if ($recordId)
|
||||||
|
{
|
||||||
|
// The record has been set. Check the record permissions.
|
||||||
|
$permission = $user->authorise('component_modules.edit.state', 'com_componentbuilder.component_modules.' . (int) $recordId);
|
||||||
|
if (!$permission && !is_null($permission))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// In the absense of better information, revert to the component permissions.
|
||||||
|
return $user->authorise('component_modules.edit.state', 'com_componentbuilder');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method override to check if you can edit an existing record.
|
||||||
|
*
|
||||||
|
* @param array $data An array of input data.
|
||||||
|
* @param string $key The name of the key for the primary key.
|
||||||
|
*
|
||||||
|
* @return boolean
|
||||||
|
* @since 2.5
|
||||||
|
*/
|
||||||
|
protected function allowEdit($data = array(), $key = 'id')
|
||||||
|
{
|
||||||
|
// Check specific edit permission then general edit permission.
|
||||||
|
$user = JFactory::getUser();
|
||||||
|
|
||||||
|
return $user->authorise('component_modules.edit', 'com_componentbuilder.component_modules.'. ((int) isset($data[$key]) ? $data[$key] : 0)) or $user->authorise('component_modules.edit', 'com_componentbuilder');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Prepare and sanitise the table data prior to saving.
|
||||||
|
*
|
||||||
|
* @param JTable $table A JTable object.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*
|
||||||
|
* @since 1.6
|
||||||
|
*/
|
||||||
|
protected function prepareTable($table)
|
||||||
|
{
|
||||||
|
$date = JFactory::getDate();
|
||||||
|
$user = JFactory::getUser();
|
||||||
|
|
||||||
|
if (isset($table->name))
|
||||||
|
{
|
||||||
|
$table->name = htmlspecialchars_decode($table->name, ENT_QUOTES);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($table->alias) && empty($table->alias))
|
||||||
|
{
|
||||||
|
$table->generateAlias();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (empty($table->id))
|
||||||
|
{
|
||||||
|
$table->created = $date->toSql();
|
||||||
|
// set the user
|
||||||
|
if ($table->created_by == 0 || empty($table->created_by))
|
||||||
|
{
|
||||||
|
$table->created_by = $user->id;
|
||||||
|
}
|
||||||
|
// Set ordering to the last item if not set
|
||||||
|
if (empty($table->ordering))
|
||||||
|
{
|
||||||
|
$db = JFactory::getDbo();
|
||||||
|
$query = $db->getQuery(true)
|
||||||
|
->select('MAX(ordering)')
|
||||||
|
->from($db->quoteName('#__componentbuilder_component_modules'));
|
||||||
|
$db->setQuery($query);
|
||||||
|
$max = $db->loadResult();
|
||||||
|
|
||||||
|
$table->ordering = $max + 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$table->modified = $date->toSql();
|
||||||
|
$table->modified_by = $user->id;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!empty($table->id))
|
||||||
|
{
|
||||||
|
// Increment the items version number.
|
||||||
|
$table->version++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method to get the data that should be injected in the form.
|
||||||
|
*
|
||||||
|
* @return mixed The data for the form.
|
||||||
|
*
|
||||||
|
* @since 1.6
|
||||||
|
*/
|
||||||
|
protected function loadFormData()
|
||||||
|
{
|
||||||
|
// Check the session for previously entered form data.
|
||||||
|
$data = JFactory::getApplication()->getUserState('com_componentbuilder.edit.component_modules.data', array());
|
||||||
|
|
||||||
|
if (empty($data))
|
||||||
|
{
|
||||||
|
$data = $this->getItem();
|
||||||
|
// run the perprocess of the data
|
||||||
|
$this->preprocessData('com_componentbuilder.component_modules', $data);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $data;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method to get the unique fields of this table.
|
||||||
|
*
|
||||||
|
* @return mixed An array of field names, boolean false if none is set.
|
||||||
|
*
|
||||||
|
* @since 3.0
|
||||||
|
*/
|
||||||
|
protected function getUniqeFields()
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method to delete one or more records.
|
||||||
|
*
|
||||||
|
* @param array &$pks An array of record primary keys.
|
||||||
|
*
|
||||||
|
* @return boolean True if successful, false if an error occurs.
|
||||||
|
*
|
||||||
|
* @since 12.2
|
||||||
|
*/
|
||||||
|
public function delete(&$pks)
|
||||||
|
{
|
||||||
|
if (!parent::delete($pks))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method to change the published state of one or more records.
|
||||||
|
*
|
||||||
|
* @param array &$pks A list of the primary keys to change.
|
||||||
|
* @param integer $value The value of the published state.
|
||||||
|
*
|
||||||
|
* @return boolean True on success.
|
||||||
|
*
|
||||||
|
* @since 12.2
|
||||||
|
*/
|
||||||
|
public function publish(&$pks, $value = 1)
|
||||||
|
{
|
||||||
|
if (!parent::publish($pks, $value))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method to perform batch operations on an item or a set of items.
|
||||||
|
*
|
||||||
|
* @param array $commands An array of commands to perform.
|
||||||
|
* @param array $pks An array of item ids.
|
||||||
|
* @param array $contexts An array of item contexts.
|
||||||
|
*
|
||||||
|
* @return boolean Returns true on success, false on failure.
|
||||||
|
*
|
||||||
|
* @since 12.2
|
||||||
|
*/
|
||||||
|
public function batch($commands, $pks, $contexts)
|
||||||
|
{
|
||||||
|
// Sanitize ids.
|
||||||
|
$pks = array_unique($pks);
|
||||||
|
JArrayHelper::toInteger($pks);
|
||||||
|
|
||||||
|
// Remove any values of zero.
|
||||||
|
if (array_search(0, $pks, true))
|
||||||
|
{
|
||||||
|
unset($pks[array_search(0, $pks, true)]);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (empty($pks))
|
||||||
|
{
|
||||||
|
$this->setError(JText::_('JGLOBAL_NO_ITEM_SELECTED'));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
$done = false;
|
||||||
|
|
||||||
|
// Set some needed variables.
|
||||||
|
$this->user = JFactory::getUser();
|
||||||
|
$this->table = $this->getTable();
|
||||||
|
$this->tableClassName = get_class($this->table);
|
||||||
|
$this->contentType = new JUcmType;
|
||||||
|
$this->type = $this->contentType->getTypeByTable($this->tableClassName);
|
||||||
|
$this->canDo = ComponentbuilderHelper::getActions('component_modules');
|
||||||
|
$this->batchSet = true;
|
||||||
|
|
||||||
|
if (!$this->canDo->get('core.batch'))
|
||||||
|
{
|
||||||
|
$this->setError(JText::_('JLIB_APPLICATION_ERROR_INSUFFICIENT_BATCH_INFORMATION'));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($this->type == false)
|
||||||
|
{
|
||||||
|
$type = new JUcmType;
|
||||||
|
$this->type = $type->getTypeByAlias($this->typeAlias);
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->tagsObserver = $this->table->getObserverOfClass('JTableObserverTags');
|
||||||
|
|
||||||
|
if (!empty($commands['move_copy']))
|
||||||
|
{
|
||||||
|
$cmd = JArrayHelper::getValue($commands, 'move_copy', 'c');
|
||||||
|
|
||||||
|
if ($cmd == 'c')
|
||||||
|
{
|
||||||
|
$result = $this->batchCopy($commands, $pks, $contexts);
|
||||||
|
|
||||||
|
if (is_array($result))
|
||||||
|
{
|
||||||
|
foreach ($result as $old => $new)
|
||||||
|
{
|
||||||
|
$contexts[$new] = $contexts[$old];
|
||||||
|
}
|
||||||
|
$pks = array_values($result);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
elseif ($cmd == 'm' && !$this->batchMove($commands, $pks, $contexts))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
$done = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!$done)
|
||||||
|
{
|
||||||
|
$this->setError(JText::_('JLIB_APPLICATION_ERROR_INSUFFICIENT_BATCH_INFORMATION'));
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Clear the cache
|
||||||
|
$this->cleanCache();
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Batch copy items to a new category or current.
|
||||||
|
*
|
||||||
|
* @param integer $values The new values.
|
||||||
|
* @param array $pks An array of row IDs.
|
||||||
|
* @param array $contexts An array of item contexts.
|
||||||
|
*
|
||||||
|
* @return mixed An array of new IDs on success, boolean false on failure.
|
||||||
|
*
|
||||||
|
* @since 12.2
|
||||||
|
*/
|
||||||
|
protected function batchCopy($values, $pks, $contexts)
|
||||||
|
{
|
||||||
|
if (empty($this->batchSet))
|
||||||
|
{
|
||||||
|
// Set some needed variables.
|
||||||
|
$this->user = JFactory::getUser();
|
||||||
|
$this->table = $this->getTable();
|
||||||
|
$this->tableClassName = get_class($this->table);
|
||||||
|
$this->canDo = ComponentbuilderHelper::getActions('component_modules');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!$this->canDo->get('component_modules.create') && !$this->canDo->get('component_modules.batch'))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// get list of uniqe fields
|
||||||
|
$uniqeFields = $this->getUniqeFields();
|
||||||
|
// remove move_copy from array
|
||||||
|
unset($values['move_copy']);
|
||||||
|
|
||||||
|
// make sure published is set
|
||||||
|
if (!isset($values['published']))
|
||||||
|
{
|
||||||
|
$values['published'] = 0;
|
||||||
|
}
|
||||||
|
elseif (isset($values['published']) && !$this->canDo->get('component_modules.edit.state'))
|
||||||
|
{
|
||||||
|
$values['published'] = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
$newIds = array();
|
||||||
|
// Parent exists so let's proceed
|
||||||
|
while (!empty($pks))
|
||||||
|
{
|
||||||
|
// Pop the first ID off the stack
|
||||||
|
$pk = array_shift($pks);
|
||||||
|
|
||||||
|
$this->table->reset();
|
||||||
|
|
||||||
|
// only allow copy if user may edit this item.
|
||||||
|
if (!$this->user->authorise('component_modules.edit', $contexts[$pk]))
|
||||||
|
{
|
||||||
|
// Not fatal error
|
||||||
|
$this->setError(JText::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND', $pk));
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check that the row actually exists
|
||||||
|
if (!$this->table->load($pk))
|
||||||
|
{
|
||||||
|
if ($error = $this->table->getError())
|
||||||
|
{
|
||||||
|
// Fatal error
|
||||||
|
$this->setError($error);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Not fatal error
|
||||||
|
$this->setError(JText::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND', $pk));
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Only for strings
|
||||||
|
if (ComponentbuilderHelper::checkString($this->table->joomla_component) && !is_numeric($this->table->joomla_component))
|
||||||
|
{
|
||||||
|
$this->table->joomla_component = $this->generateUniqe('joomla_component',$this->table->joomla_component);
|
||||||
|
}
|
||||||
|
|
||||||
|
// insert all set values
|
||||||
|
if (ComponentbuilderHelper::checkArray($values))
|
||||||
|
{
|
||||||
|
foreach ($values as $key => $value)
|
||||||
|
{
|
||||||
|
if (strlen($value) > 0 && isset($this->table->$key))
|
||||||
|
{
|
||||||
|
$this->table->$key = $value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// update all uniqe fields
|
||||||
|
if (ComponentbuilderHelper::checkArray($uniqeFields))
|
||||||
|
{
|
||||||
|
foreach ($uniqeFields as $uniqeField)
|
||||||
|
{
|
||||||
|
$this->table->$uniqeField = $this->generateUniqe($uniqeField,$this->table->$uniqeField);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Reset the ID because we are making a copy
|
||||||
|
$this->table->id = 0;
|
||||||
|
|
||||||
|
// TODO: Deal with ordering?
|
||||||
|
// $this->table->ordering = 1;
|
||||||
|
|
||||||
|
// Check the row.
|
||||||
|
if (!$this->table->check())
|
||||||
|
{
|
||||||
|
$this->setError($this->table->getError());
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!empty($this->type))
|
||||||
|
{
|
||||||
|
$this->createTagsHelper($this->tagsObserver, $this->type, $pk, $this->typeAlias, $this->table);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Store the row.
|
||||||
|
if (!$this->table->store())
|
||||||
|
{
|
||||||
|
$this->setError($this->table->getError());
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get the new item ID
|
||||||
|
$newId = $this->table->get('id');
|
||||||
|
|
||||||
|
// Add the new ID to the array
|
||||||
|
$newIds[$pk] = $newId;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Clean the cache
|
||||||
|
$this->cleanCache();
|
||||||
|
|
||||||
|
return $newIds;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Batch move items to a new category
|
||||||
|
*
|
||||||
|
* @param integer $value The new category ID.
|
||||||
|
* @param array $pks An array of row IDs.
|
||||||
|
* @param array $contexts An array of item contexts.
|
||||||
|
*
|
||||||
|
* @return boolean True if successful, false otherwise and internal error is set.
|
||||||
|
*
|
||||||
|
* @since 12.2
|
||||||
|
*/
|
||||||
|
protected function batchMove($values, $pks, $contexts)
|
||||||
|
{
|
||||||
|
if (empty($this->batchSet))
|
||||||
|
{
|
||||||
|
// Set some needed variables.
|
||||||
|
$this->user = JFactory::getUser();
|
||||||
|
$this->table = $this->getTable();
|
||||||
|
$this->tableClassName = get_class($this->table);
|
||||||
|
$this->canDo = ComponentbuilderHelper::getActions('component_modules');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!$this->canDo->get('component_modules.edit') && !$this->canDo->get('component_modules.batch'))
|
||||||
|
{
|
||||||
|
$this->setError(JText::_('JLIB_APPLICATION_ERROR_BATCH_CANNOT_EDIT'));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// make sure published only updates if user has the permission.
|
||||||
|
if (isset($values['published']) && !$this->canDo->get('component_modules.edit.state'))
|
||||||
|
{
|
||||||
|
unset($values['published']);
|
||||||
|
}
|
||||||
|
// remove move_copy from array
|
||||||
|
unset($values['move_copy']);
|
||||||
|
|
||||||
|
// Parent exists so we proceed
|
||||||
|
foreach ($pks as $pk)
|
||||||
|
{
|
||||||
|
if (!$this->user->authorise('component_modules.edit', $contexts[$pk]))
|
||||||
|
{
|
||||||
|
$this->setError(JText::_('JLIB_APPLICATION_ERROR_BATCH_CANNOT_EDIT'));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check that the row actually exists
|
||||||
|
if (!$this->table->load($pk))
|
||||||
|
{
|
||||||
|
if ($error = $this->table->getError())
|
||||||
|
{
|
||||||
|
// Fatal error
|
||||||
|
$this->setError($error);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Not fatal error
|
||||||
|
$this->setError(JText::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND', $pk));
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// insert all set values.
|
||||||
|
if (ComponentbuilderHelper::checkArray($values))
|
||||||
|
{
|
||||||
|
foreach ($values as $key => $value)
|
||||||
|
{
|
||||||
|
// Do special action for access.
|
||||||
|
if ('access' === $key && strlen($value) > 0)
|
||||||
|
{
|
||||||
|
$this->table->$key = $value;
|
||||||
|
}
|
||||||
|
elseif (strlen($value) > 0 && isset($this->table->$key))
|
||||||
|
{
|
||||||
|
$this->table->$key = $value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Check the row.
|
||||||
|
if (!$this->table->check())
|
||||||
|
{
|
||||||
|
$this->setError($this->table->getError());
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!empty($this->type))
|
||||||
|
{
|
||||||
|
$this->createTagsHelper($this->tagsObserver, $this->type, $pk, $this->typeAlias, $this->table);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Store the row.
|
||||||
|
if (!$this->table->store())
|
||||||
|
{
|
||||||
|
$this->setError($this->table->getError());
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Clean the cache
|
||||||
|
$this->cleanCache();
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method to save the form data.
|
||||||
|
*
|
||||||
|
* @param array $data The form data.
|
||||||
|
*
|
||||||
|
* @return boolean True on success.
|
||||||
|
*
|
||||||
|
* @since 1.6
|
||||||
|
*/
|
||||||
|
public function save($data)
|
||||||
|
{
|
||||||
|
$input = JFactory::getApplication()->input;
|
||||||
|
$filter = JFilterInput::getInstance();
|
||||||
|
|
||||||
|
// set the metadata to the Item Data
|
||||||
|
if (isset($data['metadata']) && isset($data['metadata']['author']))
|
||||||
|
{
|
||||||
|
$data['metadata']['author'] = $filter->clean($data['metadata']['author'], 'TRIM');
|
||||||
|
|
||||||
|
$metadata = new JRegistry;
|
||||||
|
$metadata->loadArray($data['metadata']);
|
||||||
|
$data['metadata'] = (string) $metadata;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set the addjoomla_modules items to data.
|
||||||
|
if (isset($data['addjoomla_modules']) && is_array($data['addjoomla_modules']))
|
||||||
|
{
|
||||||
|
$addjoomla_modules = new JRegistry;
|
||||||
|
$addjoomla_modules->loadArray($data['addjoomla_modules']);
|
||||||
|
$data['addjoomla_modules'] = (string) $addjoomla_modules;
|
||||||
|
}
|
||||||
|
elseif (!isset($data['addjoomla_modules']))
|
||||||
|
{
|
||||||
|
// Set the empty addjoomla_modules to data
|
||||||
|
$data['addjoomla_modules'] = '';
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set the Params Items to data
|
||||||
|
if (isset($data['params']) && is_array($data['params']))
|
||||||
|
{
|
||||||
|
$params = new JRegistry;
|
||||||
|
$params->loadArray($data['params']);
|
||||||
|
$data['params'] = (string) $params;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Alter the uniqe field for save as copy
|
||||||
|
if ($input->get('task') === 'save2copy')
|
||||||
|
{
|
||||||
|
// Automatic handling of other uniqe fields
|
||||||
|
$uniqeFields = $this->getUniqeFields();
|
||||||
|
if (ComponentbuilderHelper::checkArray($uniqeFields))
|
||||||
|
{
|
||||||
|
foreach ($uniqeFields as $uniqeField)
|
||||||
|
{
|
||||||
|
$data[$uniqeField] = $this->generateUniqe($uniqeField,$data[$uniqeField]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (parent::save($data))
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method to generate a uniqe value.
|
||||||
|
*
|
||||||
|
* @param string $field name.
|
||||||
|
* @param string $value data.
|
||||||
|
*
|
||||||
|
* @return string New value.
|
||||||
|
*
|
||||||
|
* @since 3.0
|
||||||
|
*/
|
||||||
|
protected function generateUniqe($field,$value)
|
||||||
|
{
|
||||||
|
|
||||||
|
// set field value uniqe
|
||||||
|
$table = $this->getTable();
|
||||||
|
|
||||||
|
while ($table->load(array($field => $value)))
|
||||||
|
{
|
||||||
|
$value = JString::increment($value);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $value;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method to change the title
|
||||||
|
*
|
||||||
|
* @param string $title The title.
|
||||||
|
*
|
||||||
|
* @return array Contains the modified title and alias.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
protected function _generateNewTitle($title)
|
||||||
|
{
|
||||||
|
|
||||||
|
// Alter the title
|
||||||
|
$table = $this->getTable();
|
||||||
|
|
||||||
|
while ($table->load(array('title' => $title)))
|
||||||
|
{
|
||||||
|
$title = JString::increment($title);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $title;
|
||||||
|
}
|
||||||
|
}
|
243
admin/models/components_modules.php
Normal file
243
admin/models/components_modules.php
Normal file
@ -0,0 +1,243 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* @package Joomla.Component.Builder
|
||||||
|
*
|
||||||
|
* @created 30th April, 2015
|
||||||
|
* @author Llewellyn van der Merwe <http://www.joomlacomponentbuilder.com>
|
||||||
|
* @github Joomla Component Builder <https://github.com/vdm-io/Joomla-Component-Builder>
|
||||||
|
* @copyright Copyright (C) 2015 - 2019 Vast Development Method. All rights reserved.
|
||||||
|
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||||
|
*/
|
||||||
|
|
||||||
|
// No direct access to this file
|
||||||
|
defined('_JEXEC') or die('Restricted access');
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Components_modules Model
|
||||||
|
*/
|
||||||
|
class ComponentbuilderModelComponents_modules extends JModelList
|
||||||
|
{
|
||||||
|
public function __construct($config = array())
|
||||||
|
{
|
||||||
|
if (empty($config['filter_fields']))
|
||||||
|
{
|
||||||
|
$config['filter_fields'] = array(
|
||||||
|
'a.id','id',
|
||||||
|
'a.published','published',
|
||||||
|
'a.ordering','ordering',
|
||||||
|
'a.created_by','created_by',
|
||||||
|
'a.modified_by','modified_by'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
parent::__construct($config);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method to auto-populate the model state.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
protected function populateState($ordering = null, $direction = null)
|
||||||
|
{
|
||||||
|
$app = JFactory::getApplication();
|
||||||
|
|
||||||
|
// Adjust the context to support modal layouts.
|
||||||
|
if ($layout = $app->input->get('layout'))
|
||||||
|
{
|
||||||
|
$this->context .= '.' . $layout;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
$sorting = $this->getUserStateFromRequest($this->context . '.filter.sorting', 'filter_sorting', 0, 'int');
|
||||||
|
$this->setState('filter.sorting', $sorting);
|
||||||
|
|
||||||
|
$access = $this->getUserStateFromRequest($this->context . '.filter.access', 'filter_access', 0, 'int');
|
||||||
|
$this->setState('filter.access', $access);
|
||||||
|
|
||||||
|
$search = $this->getUserStateFromRequest($this->context . '.filter.search', 'filter_search');
|
||||||
|
$this->setState('filter.search', $search);
|
||||||
|
|
||||||
|
$published = $this->getUserStateFromRequest($this->context . '.filter.published', 'filter_published', '');
|
||||||
|
$this->setState('filter.published', $published);
|
||||||
|
|
||||||
|
$created_by = $this->getUserStateFromRequest($this->context . '.filter.created_by', 'filter_created_by', '');
|
||||||
|
$this->setState('filter.created_by', $created_by);
|
||||||
|
|
||||||
|
$created = $this->getUserStateFromRequest($this->context . '.filter.created', 'filter_created');
|
||||||
|
$this->setState('filter.created', $created);
|
||||||
|
|
||||||
|
// List state information.
|
||||||
|
parent::populateState($ordering, $direction);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method to get an array of data items.
|
||||||
|
*
|
||||||
|
* @return mixed An array of data items on success, false on failure.
|
||||||
|
*/
|
||||||
|
public function getItems()
|
||||||
|
{
|
||||||
|
// check in items
|
||||||
|
$this->checkInNow();
|
||||||
|
|
||||||
|
// load parent items
|
||||||
|
$items = parent::getItems();
|
||||||
|
|
||||||
|
// Set values to display correctly.
|
||||||
|
if (ComponentbuilderHelper::checkArray($items))
|
||||||
|
{
|
||||||
|
// Get the user object if not set.
|
||||||
|
if (!isset($user) || !ComponentbuilderHelper::checkObject($user))
|
||||||
|
{
|
||||||
|
$user = JFactory::getUser();
|
||||||
|
}
|
||||||
|
foreach ($items as $nr => &$item)
|
||||||
|
{
|
||||||
|
// Remove items the user can't access.
|
||||||
|
$access = ($user->authorise('component_modules.access', 'com_componentbuilder.component_modules.' . (int) $item->id) && $user->authorise('component_modules.access', 'com_componentbuilder'));
|
||||||
|
if (!$access)
|
||||||
|
{
|
||||||
|
unset($items[$nr]);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// return items
|
||||||
|
return $items;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method to build an SQL query to load the list data.
|
||||||
|
*
|
||||||
|
* @return string An SQL query
|
||||||
|
*/
|
||||||
|
protected function getListQuery()
|
||||||
|
{
|
||||||
|
// Get the user object.
|
||||||
|
$user = JFactory::getUser();
|
||||||
|
// Create a new query object.
|
||||||
|
$db = JFactory::getDBO();
|
||||||
|
$query = $db->getQuery(true);
|
||||||
|
|
||||||
|
// Select some fields
|
||||||
|
$query->select('a.*');
|
||||||
|
|
||||||
|
// From the componentbuilder_item table
|
||||||
|
$query->from($db->quoteName('#__componentbuilder_component_modules', 'a'));
|
||||||
|
|
||||||
|
// From the componentbuilder_joomla_component table.
|
||||||
|
$query->select($db->quoteName('g.system_name','joomla_component_system_name'));
|
||||||
|
$query->join('LEFT', $db->quoteName('#__componentbuilder_joomla_component', 'g') . ' ON (' . $db->quoteName('a.joomla_component') . ' = ' . $db->quoteName('g.id') . ')');
|
||||||
|
|
||||||
|
// Filter by published state
|
||||||
|
$published = $this->getState('filter.published');
|
||||||
|
if (is_numeric($published))
|
||||||
|
{
|
||||||
|
$query->where('a.published = ' . (int) $published);
|
||||||
|
}
|
||||||
|
elseif ($published === '')
|
||||||
|
{
|
||||||
|
$query->where('(a.published = 0 OR a.published = 1)');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Join over the asset groups.
|
||||||
|
$query->select('ag.title AS access_level');
|
||||||
|
$query->join('LEFT', '#__viewlevels AS ag ON ag.id = a.access');
|
||||||
|
// Filter by access level.
|
||||||
|
if ($access = $this->getState('filter.access'))
|
||||||
|
{
|
||||||
|
$query->where('a.access = ' . (int) $access);
|
||||||
|
}
|
||||||
|
// Implement View Level Access
|
||||||
|
if (!$user->authorise('core.options', 'com_componentbuilder'))
|
||||||
|
{
|
||||||
|
$groups = implode(',', $user->getAuthorisedViewLevels());
|
||||||
|
$query->where('a.access IN (' . $groups . ')');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add the list ordering clause.
|
||||||
|
$orderCol = $this->state->get('list.ordering', 'a.id');
|
||||||
|
$orderDirn = $this->state->get('list.direction', 'asc');
|
||||||
|
if ($orderCol != '')
|
||||||
|
{
|
||||||
|
$query->order($db->escape($orderCol . ' ' . $orderDirn));
|
||||||
|
}
|
||||||
|
|
||||||
|
return $query;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method to get a store id based on model configuration state.
|
||||||
|
*
|
||||||
|
* @return string A store id.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
protected function getStoreId($id = '')
|
||||||
|
{
|
||||||
|
// Compile the store id.
|
||||||
|
$id .= ':' . $this->getState('filter.id');
|
||||||
|
$id .= ':' . $this->getState('filter.search');
|
||||||
|
$id .= ':' . $this->getState('filter.published');
|
||||||
|
$id .= ':' . $this->getState('filter.ordering');
|
||||||
|
$id .= ':' . $this->getState('filter.created_by');
|
||||||
|
$id .= ':' . $this->getState('filter.modified_by');
|
||||||
|
|
||||||
|
return parent::getStoreId($id);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Build an SQL query to checkin all items left checked out longer then a set time.
|
||||||
|
*
|
||||||
|
* @return a bool
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
protected function checkInNow()
|
||||||
|
{
|
||||||
|
// Get set check in time
|
||||||
|
$time = JComponentHelper::getParams('com_componentbuilder')->get('check_in');
|
||||||
|
|
||||||
|
if ($time)
|
||||||
|
{
|
||||||
|
|
||||||
|
// Get a db connection.
|
||||||
|
$db = JFactory::getDbo();
|
||||||
|
// reset query
|
||||||
|
$query = $db->getQuery(true);
|
||||||
|
$query->select('*');
|
||||||
|
$query->from($db->quoteName('#__componentbuilder_component_modules'));
|
||||||
|
$db->setQuery($query);
|
||||||
|
$db->execute();
|
||||||
|
if ($db->getNumRows())
|
||||||
|
{
|
||||||
|
// Get Yesterdays date
|
||||||
|
$date = JFactory::getDate()->modify($time)->toSql();
|
||||||
|
// reset query
|
||||||
|
$query = $db->getQuery(true);
|
||||||
|
|
||||||
|
// Fields to update.
|
||||||
|
$fields = array(
|
||||||
|
$db->quoteName('checked_out_time') . '=\'0000-00-00 00:00:00\'',
|
||||||
|
$db->quoteName('checked_out') . '=0'
|
||||||
|
);
|
||||||
|
|
||||||
|
// Conditions for which records should be updated.
|
||||||
|
$conditions = array(
|
||||||
|
$db->quoteName('checked_out') . '!=0',
|
||||||
|
$db->quoteName('checked_out_time') . '<\''.$date.'\''
|
||||||
|
);
|
||||||
|
|
||||||
|
// Check table
|
||||||
|
$query->update($db->quoteName('#__componentbuilder_component_modules'))->set($fields)->where($conditions);
|
||||||
|
|
||||||
|
$db->setQuery($query);
|
||||||
|
|
||||||
|
$db->execute();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
11
admin/models/forms/component_modules.js
Normal file
11
admin/models/forms/component_modules.js
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
/**
|
||||||
|
* @package Joomla.Component.Builder
|
||||||
|
*
|
||||||
|
* @created 30th April, 2015
|
||||||
|
* @author Llewellyn van der Merwe <http://www.joomlacomponentbuilder.com>
|
||||||
|
* @github Joomla Component Builder <https://github.com/vdm-io/Joomla-Component-Builder>
|
||||||
|
* @copyright Copyright (C) 2015 - 2019 Vast Development Method. All rights reserved.
|
||||||
|
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
167
admin/models/forms/component_modules.xml
Normal file
167
admin/models/forms/component_modules.xml
Normal file
@ -0,0 +1,167 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<form
|
||||||
|
addrulepath="/administrator/components/com_componentbuilder/models/rules"
|
||||||
|
addfieldpath="/administrator/components/com_componentbuilder/models/fields"
|
||||||
|
>
|
||||||
|
<fieldset name="details">
|
||||||
|
<!-- Default Fields. -->
|
||||||
|
<!-- Id Field. Type: Text (joomla) -->
|
||||||
|
<field
|
||||||
|
name="id"
|
||||||
|
type="text" class="readonly" label="JGLOBAL_FIELD_ID_LABEL"
|
||||||
|
description ="JGLOBAL_FIELD_ID_DESC" size="10" default="0"
|
||||||
|
readonly="true"
|
||||||
|
/>
|
||||||
|
<!-- Date Created Field. Type: Calendar (joomla) -->
|
||||||
|
<field
|
||||||
|
name="created"
|
||||||
|
type="calendar"
|
||||||
|
label="COM_COMPONENTBUILDER_COMPONENT_MODULES_CREATED_DATE_LABEL"
|
||||||
|
description="COM_COMPONENTBUILDER_COMPONENT_MODULES_CREATED_DATE_DESC"
|
||||||
|
size="22"
|
||||||
|
format="%Y-%m-%d %H:%M:%S"
|
||||||
|
filter="user_utc"
|
||||||
|
/>
|
||||||
|
<!-- User Created Field. Type: User (joomla) -->
|
||||||
|
<field
|
||||||
|
name="created_by"
|
||||||
|
type="user"
|
||||||
|
label="COM_COMPONENTBUILDER_COMPONENT_MODULES_CREATED_BY_LABEL"
|
||||||
|
description="COM_COMPONENTBUILDER_COMPONENT_MODULES_CREATED_BY_DESC"
|
||||||
|
/>
|
||||||
|
<!-- Published Field. Type: List (joomla) -->
|
||||||
|
<field name="published" type="list" label="JSTATUS"
|
||||||
|
description="JFIELD_PUBLISHED_DESC" class="chzn-color-state"
|
||||||
|
filter="intval" size="1" default="1" >
|
||||||
|
<option value="1">
|
||||||
|
JPUBLISHED</option>
|
||||||
|
<option value="0">
|
||||||
|
JUNPUBLISHED</option>
|
||||||
|
<option value="2">
|
||||||
|
JARCHIVED</option>
|
||||||
|
<option value="-2">
|
||||||
|
JTRASHED</option>
|
||||||
|
</field>
|
||||||
|
<!-- Date Modified Field. Type: Calendar (joomla) -->
|
||||||
|
<field name="modified" type="calendar" class="readonly"
|
||||||
|
label="COM_COMPONENTBUILDER_COMPONENT_MODULES_MODIFIED_DATE_LABEL" description="COM_COMPONENTBUILDER_COMPONENT_MODULES_MODIFIED_DATE_DESC"
|
||||||
|
size="22" readonly="true" format="%Y-%m-%d %H:%M:%S" filter="user_utc" />
|
||||||
|
<!-- User Modified Field. Type: User (joomla) -->
|
||||||
|
<field name="modified_by" type="user"
|
||||||
|
label="COM_COMPONENTBUILDER_COMPONENT_MODULES_MODIFIED_BY_LABEL"
|
||||||
|
description="COM_COMPONENTBUILDER_COMPONENT_MODULES_MODIFIED_BY_DESC"
|
||||||
|
class="readonly"
|
||||||
|
readonly="true"
|
||||||
|
filter="unset"
|
||||||
|
/>
|
||||||
|
<!-- Access Field. Type: Accesslevel (joomla) -->
|
||||||
|
<field name="access"
|
||||||
|
type="accesslevel"
|
||||||
|
label="JFIELD_ACCESS_LABEL"
|
||||||
|
description="JFIELD_ACCESS_DESC"
|
||||||
|
default="1"
|
||||||
|
required="false"
|
||||||
|
/>
|
||||||
|
<!-- Ordering Field. Type: Numbers (joomla) -->
|
||||||
|
<field
|
||||||
|
name="ordering"
|
||||||
|
type="number"
|
||||||
|
class="inputbox validate-ordering"
|
||||||
|
label="COM_COMPONENTBUILDER_COMPONENT_MODULES_ORDERING_LABEL"
|
||||||
|
description=""
|
||||||
|
default="0"
|
||||||
|
size="6"
|
||||||
|
required="false"
|
||||||
|
/>
|
||||||
|
<!-- Version Field. Type: Text (joomla) -->
|
||||||
|
<field
|
||||||
|
name="version"
|
||||||
|
type="text"
|
||||||
|
class="readonly"
|
||||||
|
label="COM_COMPONENTBUILDER_COMPONENT_MODULES_VERSION_LABEL"
|
||||||
|
description="COM_COMPONENTBUILDER_COMPONENT_MODULES_VERSION_DESC"
|
||||||
|
size="6"
|
||||||
|
readonly="true"
|
||||||
|
filter="unset"
|
||||||
|
/>
|
||||||
|
<!-- Dynamic Fields. -->
|
||||||
|
<!-- Joomla_component Field. Type: Joomlacomponents. (custom) -->
|
||||||
|
<field
|
||||||
|
type="joomlacomponents"
|
||||||
|
name="joomla_component"
|
||||||
|
label="COM_COMPONENTBUILDER_COMPONENT_MODULES_JOOMLA_COMPONENT_LABEL"
|
||||||
|
description="COM_COMPONENTBUILDER_COMPONENT_MODULES_JOOMLA_COMPONENT_DESCRIPTION"
|
||||||
|
class="list_class"
|
||||||
|
multiple="false"
|
||||||
|
default=""
|
||||||
|
required="true"
|
||||||
|
readonly="true"
|
||||||
|
button="false"
|
||||||
|
/>
|
||||||
|
<!-- Addjoomla_modules Field. Type: Subform. (joomla) -->
|
||||||
|
<field
|
||||||
|
type="subform"
|
||||||
|
name="addjoomla_modules"
|
||||||
|
label="COM_COMPONENTBUILDER_COMPONENT_MODULES_ADDJOOMLA_MODULES_LABEL"
|
||||||
|
layout="joomla.form.field.subform.repeatable-table"
|
||||||
|
multiple="true"
|
||||||
|
description="COM_COMPONENTBUILDER_COMPONENT_MODULES_ADDJOOMLA_MODULES_DESCRIPTION"
|
||||||
|
default=""
|
||||||
|
icon="list"
|
||||||
|
min="1">
|
||||||
|
<form hidden="true" name="list_addjoomla_modules_modal" repeat="true">
|
||||||
|
<!-- Module Field. Type: Joomlamodules. (custom) -->
|
||||||
|
<field
|
||||||
|
type="joomlamodules"
|
||||||
|
name="module"
|
||||||
|
label="COM_COMPONENTBUILDER_COMPONENT_MODULES_MODULE_LABEL"
|
||||||
|
class="list_class span12"
|
||||||
|
multiple="false"
|
||||||
|
default="0"
|
||||||
|
button="false"
|
||||||
|
/>
|
||||||
|
<!-- Target Field. Type: List. (joomla) -->
|
||||||
|
<field
|
||||||
|
type="list"
|
||||||
|
name="target"
|
||||||
|
label="COM_COMPONENTBUILDER_COMPONENT_MODULES_TARGET_LABEL"
|
||||||
|
description="COM_COMPONENTBUILDER_COMPONENT_MODULES_TARGET_DESCRIPTION"
|
||||||
|
class="list_class"
|
||||||
|
multiple="false"
|
||||||
|
default="0">
|
||||||
|
<!-- Option Set. -->
|
||||||
|
<option value="1">
|
||||||
|
COM_COMPONENTBUILDER_COMPONENT_MODULES_COMPILE_ONLY</option>
|
||||||
|
<option value="2">
|
||||||
|
COM_COMPONENTBUILDER_COMPONENT_MODULES_EXPORT_ONLY</option>
|
||||||
|
<option value="0">
|
||||||
|
COM_COMPONENTBUILDER_COMPONENT_MODULES_COMPILE_AMP_EXPORT</option>
|
||||||
|
</field>
|
||||||
|
</form>
|
||||||
|
</field>
|
||||||
|
<!-- Note_on_joomla_modules Field. Type: Note. A None Database Field. (joomla) -->
|
||||||
|
<field type="note" name="note_on_joomla_modules" label="COM_COMPONENTBUILDER_COMPONENT_MODULES_NOTE_ON_JOOMLA_MODULES_LABEL" description="COM_COMPONENTBUILDER_COMPONENT_MODULES_NOTE_ON_JOOMLA_MODULES_DESCRIPTION" heading="h4" class="alert alert-info note_on_joomla_modules" />
|
||||||
|
</fieldset>
|
||||||
|
|
||||||
|
<!-- Access Control Fields. -->
|
||||||
|
<fieldset name="accesscontrol">
|
||||||
|
<!-- Asset Id Field. Type: Hidden (joomla) -->
|
||||||
|
<field
|
||||||
|
name="asset_id"
|
||||||
|
type="hidden"
|
||||||
|
filter="unset"
|
||||||
|
/>
|
||||||
|
<!-- Rules Field. Type: Rules (joomla) -->
|
||||||
|
<field
|
||||||
|
name="rules"
|
||||||
|
type="rules"
|
||||||
|
label="Permissions in relation to this component_modules"
|
||||||
|
translate_label="false"
|
||||||
|
filter="rules"
|
||||||
|
validate="rules"
|
||||||
|
class="inputbox"
|
||||||
|
component="com_componentbuilder"
|
||||||
|
section="component_modules"
|
||||||
|
/>
|
||||||
|
</fieldset>
|
||||||
|
</form>
|
33
admin/sql/updates/mysql/2.10.6.sql
Normal file
33
admin/sql/updates/mysql/2.10.6.sql
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
CREATE TABLE IF NOT EXISTS `#__componentbuilder_component_modules` (
|
||||||
|
`id` INT(11) NOT NULL AUTO_INCREMENT,
|
||||||
|
`asset_id` INT(10) unsigned NOT NULL DEFAULT 0 COMMENT 'FK to the #__assets table.',
|
||||||
|
`addjoomla_modules` TEXT NOT NULL,
|
||||||
|
`joomla_component` INT(11) NOT NULL DEFAULT 0,
|
||||||
|
`params` text NOT NULL,
|
||||||
|
`published` TINYINT(3) NOT NULL DEFAULT 1,
|
||||||
|
`created_by` INT(10) unsigned NOT NULL DEFAULT 0,
|
||||||
|
`modified_by` INT(10) unsigned NOT NULL DEFAULT 0,
|
||||||
|
`created` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
|
||||||
|
`modified` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
|
||||||
|
`checked_out` int(11) unsigned NOT NULL DEFAULT 0,
|
||||||
|
`checked_out_time` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
|
||||||
|
`version` INT(10) unsigned NOT NULL DEFAULT 1,
|
||||||
|
`hits` INT(10) unsigned NOT NULL DEFAULT 0,
|
||||||
|
`access` INT(10) unsigned NOT NULL DEFAULT 0,
|
||||||
|
`ordering` INT(11) NOT NULL DEFAULT 0,
|
||||||
|
PRIMARY KEY (`id`),
|
||||||
|
KEY `idx_joomla_component` (`joomla_component`),
|
||||||
|
KEY `idx_access` (`access`),
|
||||||
|
KEY `idx_checkout` (`checked_out`),
|
||||||
|
KEY `idx_createdby` (`created_by`),
|
||||||
|
KEY `idx_modifiedby` (`modified_by`),
|
||||||
|
KEY `idx_state` (`published`)
|
||||||
|
) ENGINE=InnoDB AUTO_INCREMENT=0 DEFAULT CHARSET=utf8mb4 DEFAULT COLLATE=utf8mb4_general_ci ROW_FORMAT=DYNAMIC;
|
||||||
|
|
||||||
|
ALTER TABLE `#__componentbuilder_joomla_module` CHANGE `add_abstract_class_helper` `add_class_helper` TINYINT(1) NOT NULL DEFAULT 0;
|
||||||
|
|
||||||
|
ALTER TABLE `#__componentbuilder_joomla_module` CHANGE `add_custom_abstract_class_helper_header` `add_class_helper_header` TINYINT(1) NOT NULL DEFAULT 0;
|
||||||
|
|
||||||
|
ALTER TABLE `#__componentbuilder_joomla_module` CHANGE `abstract_class_helper_code` `class_helper_code` MEDIUMTEXT NOT NULL;
|
||||||
|
|
||||||
|
ALTER TABLE `#__componentbuilder_joomla_module` CHANGE `abstract_class_helper_header` `class_helper_header` TEXT NOT NULL;
|
1
admin/sql/updates/mysql/2.10.7.sql
Normal file
1
admin/sql/updates/mysql/2.10.7.sql
Normal file
@ -0,0 +1 @@
|
|||||||
|
ALTER TABLE `#__componentbuilder_joomla_module` ADD `mod_code` TEXT NOT NULL AFTER `libraries`;
|
321
admin/tables/component_modules.php
Normal file
321
admin/tables/component_modules.php
Normal file
@ -0,0 +1,321 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* @package Joomla.Component.Builder
|
||||||
|
*
|
||||||
|
* @created 30th April, 2015
|
||||||
|
* @author Llewellyn van der Merwe <http://www.joomlacomponentbuilder.com>
|
||||||
|
* @github Joomla Component Builder <https://github.com/vdm-io/Joomla-Component-Builder>
|
||||||
|
* @copyright Copyright (C) 2015 - 2019 Vast Development Method. All rights reserved.
|
||||||
|
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||||
|
*/
|
||||||
|
|
||||||
|
// No direct access to this file
|
||||||
|
defined('_JEXEC') or die('Restricted access');
|
||||||
|
|
||||||
|
use Joomla\Registry\Registry;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Components_modules Table class
|
||||||
|
*/
|
||||||
|
class ComponentbuilderTableComponent_modules extends JTable
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Ensure the params and metadata in json encoded in the bind method
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
* @since 3.3
|
||||||
|
*/
|
||||||
|
protected $_jsonEncode = array('params', 'metadata');
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor
|
||||||
|
*
|
||||||
|
* @param object Database connector object
|
||||||
|
*/
|
||||||
|
function __construct(&$db)
|
||||||
|
{
|
||||||
|
parent::__construct('#__componentbuilder_component_modules', 'id', $db);
|
||||||
|
|
||||||
|
// Adding History Options
|
||||||
|
JTableObserverContenthistory::createObserver($this, array('typeAlias' => 'com_componentbuilder.component_modules'));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function bind($array, $ignore = '')
|
||||||
|
{
|
||||||
|
|
||||||
|
if (isset($array['params']) && is_array($array['params']))
|
||||||
|
{
|
||||||
|
$registry = new JRegistry;
|
||||||
|
$registry->loadArray($array['params']);
|
||||||
|
$array['params'] = (string) $registry;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($array['metadata']) && is_array($array['metadata']))
|
||||||
|
{
|
||||||
|
$registry = new JRegistry;
|
||||||
|
$registry->loadArray($array['metadata']);
|
||||||
|
$array['metadata'] = (string) $registry;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Bind the rules.
|
||||||
|
if (isset($array['rules']) && is_array($array['rules']))
|
||||||
|
{
|
||||||
|
$rules = new JAccessRules($array['rules']);
|
||||||
|
$this->setRules($rules);
|
||||||
|
}
|
||||||
|
return parent::bind($array, $ignore);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Overload the store method for the Component_modules table.
|
||||||
|
*
|
||||||
|
* @param boolean Toggle whether null values should be updated.
|
||||||
|
* @return boolean True on success, false on failure.
|
||||||
|
* @since 1.6
|
||||||
|
*/
|
||||||
|
public function store($updateNulls = false)
|
||||||
|
{
|
||||||
|
$date = JFactory::getDate();
|
||||||
|
$user = JFactory::getUser();
|
||||||
|
|
||||||
|
if ($this->id)
|
||||||
|
{
|
||||||
|
// Existing item
|
||||||
|
$this->modified = $date->toSql();
|
||||||
|
$this->modified_by = $user->get('id');
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// New component_modules. A component_modules created and created_by field can be set by the user,
|
||||||
|
// so we don't touch either of these if they are set.
|
||||||
|
if (!(int) $this->created)
|
||||||
|
{
|
||||||
|
$this->created = $date->toSql();
|
||||||
|
}
|
||||||
|
if (empty($this->created_by))
|
||||||
|
{
|
||||||
|
$this->created_by = $user->get('id');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($this->alias))
|
||||||
|
{
|
||||||
|
// Verify that the alias is unique
|
||||||
|
$table = JTable::getInstance('component_modules', 'ComponentbuilderTable');
|
||||||
|
|
||||||
|
if ($table->load(array('alias' => $this->alias)) && ($table->id != $this->id || $this->id == 0))
|
||||||
|
{
|
||||||
|
$this->setError(JText::_('COM_COMPONENTBUILDER_COMPONENT_MODULES_ERROR_UNIQUE_ALIAS'));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isset($this->url))
|
||||||
|
{
|
||||||
|
// Convert IDN urls to punycode
|
||||||
|
$this->url = JStringPunycode::urlToPunycode($this->url);
|
||||||
|
}
|
||||||
|
if (isset($this->website))
|
||||||
|
{
|
||||||
|
// Convert IDN urls to punycode
|
||||||
|
$this->website = JStringPunycode::urlToPunycode($this->website);
|
||||||
|
}
|
||||||
|
|
||||||
|
return parent::store($updateNulls);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Overloaded check method to ensure data integrity.
|
||||||
|
*
|
||||||
|
* @return boolean True on success.
|
||||||
|
*/
|
||||||
|
public function check()
|
||||||
|
{
|
||||||
|
if (isset($this->alias))
|
||||||
|
{
|
||||||
|
// Generate a valid alias
|
||||||
|
$this->generateAlias();
|
||||||
|
|
||||||
|
$table = JTable::getInstance('component_modules', 'componentbuilderTable');
|
||||||
|
|
||||||
|
while ($table->load(array('alias' => $this->alias)) && ($table->id != $this->id || $this->id == 0))
|
||||||
|
{
|
||||||
|
$this->alias = JString::increment($this->alias, 'dash');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Clean up keywords -- eliminate extra spaces between phrases
|
||||||
|
* and cr (\r) and lf (\n) characters from string.
|
||||||
|
* Only process if not empty.
|
||||||
|
*/
|
||||||
|
if (!empty($this->metakey))
|
||||||
|
{
|
||||||
|
// Array of characters to remove.
|
||||||
|
$bad_characters = array("\n", "\r", "\"", "<", ">");
|
||||||
|
|
||||||
|
// Remove bad characters.
|
||||||
|
$after_clean = JString::str_ireplace($bad_characters, "", $this->metakey);
|
||||||
|
|
||||||
|
// Create array using commas as delimiter.
|
||||||
|
$keys = explode(',', $after_clean);
|
||||||
|
$clean_keys = array();
|
||||||
|
|
||||||
|
foreach ($keys as $key)
|
||||||
|
{
|
||||||
|
// Ignore blank keywords.
|
||||||
|
if (trim($key))
|
||||||
|
{
|
||||||
|
$clean_keys[] = trim($key);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Put array back together delimited by ", "
|
||||||
|
$this->metakey = implode(", ", $clean_keys);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Clean up description -- eliminate quotes and <> brackets
|
||||||
|
if (!empty($this->metadesc))
|
||||||
|
{
|
||||||
|
// Only process if not empty
|
||||||
|
$bad_characters = array("\"", "<", ">");
|
||||||
|
$this->metadesc = JString::str_ireplace($bad_characters, "", $this->metadesc);
|
||||||
|
}
|
||||||
|
|
||||||
|
// If we don't have any access rules set at this point just use an empty JAccessRules class
|
||||||
|
if (!$this->getRules())
|
||||||
|
{
|
||||||
|
$rules = $this->getDefaultAssetValues('com_componentbuilder.component_modules.'.$this->id);
|
||||||
|
$this->setRules($rules);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set ordering
|
||||||
|
if ($this->published < 0)
|
||||||
|
{
|
||||||
|
// Set ordering to 0 if state is archived or trashed
|
||||||
|
$this->ordering = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the default asset values for a component.
|
||||||
|
*
|
||||||
|
* @param $string $component The component asset name to search for
|
||||||
|
*
|
||||||
|
* @return JAccessRules The JAccessRules object for the asset
|
||||||
|
*/
|
||||||
|
protected function getDefaultAssetValues($component, $try = true)
|
||||||
|
{
|
||||||
|
// Need to find the asset id by the name of the component.
|
||||||
|
$db = JFactory::getDbo();
|
||||||
|
$query = $db->getQuery(true)
|
||||||
|
->select($db->quoteName('id'))
|
||||||
|
->from($db->quoteName('#__assets'))
|
||||||
|
->where($db->quoteName('name') . ' = ' . $db->quote($component));
|
||||||
|
$db->setQuery($query);
|
||||||
|
$db->execute();
|
||||||
|
if ($db->loadRowList())
|
||||||
|
{
|
||||||
|
// asset alread set so use saved rules
|
||||||
|
$assetId = (int) $db->loadResult();
|
||||||
|
return JAccess::getAssetRules($assetId); // (TODO) instead of keeping inherited Allowed it becomes Allowed.
|
||||||
|
}
|
||||||
|
// try again
|
||||||
|
elseif ($try)
|
||||||
|
{
|
||||||
|
$try = explode('.',$component);
|
||||||
|
$result = $this->getDefaultAssetValues($try[0], false);
|
||||||
|
if ($result instanceof JAccessRules)
|
||||||
|
{
|
||||||
|
if (isset($try[1]))
|
||||||
|
{
|
||||||
|
$_result = (string) $result;
|
||||||
|
$_result = json_decode($_result);
|
||||||
|
foreach ($_result as $name => &$rule)
|
||||||
|
{
|
||||||
|
$v = explode('.', $name);
|
||||||
|
if ($try[1] !== $v[0])
|
||||||
|
{
|
||||||
|
// remove since it is not part of this view
|
||||||
|
unset($_result->$name);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// clear the value since we inherit
|
||||||
|
$rule = array();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// check if there are any view values remaining
|
||||||
|
if (count( (array) $_result))
|
||||||
|
{
|
||||||
|
$_result = json_encode($_result);
|
||||||
|
$_result = array($_result);
|
||||||
|
// Instantiate and return the JAccessRules object for the asset rules.
|
||||||
|
$rules = new JAccessRules;
|
||||||
|
$rules->mergeCollection($_result);
|
||||||
|
|
||||||
|
return $rules;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return JAccess::getAssetRules(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method to compute the default name of the asset.
|
||||||
|
* The default name is in the form 'table_name.id'
|
||||||
|
* where id is the value of the primary key of the table.
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
* @since 2.5
|
||||||
|
*/
|
||||||
|
protected function _getAssetName()
|
||||||
|
{
|
||||||
|
$k = $this->_tbl_key;
|
||||||
|
return 'com_componentbuilder.component_modules.'.(int) $this->$k;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method to return the title to use for the asset table.
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
* @since 2.5
|
||||||
|
*/
|
||||||
|
protected function _getAssetTitle()
|
||||||
|
{
|
||||||
|
if (isset($this->title))
|
||||||
|
{
|
||||||
|
return $this->title;
|
||||||
|
}
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the parent asset id for the record
|
||||||
|
*
|
||||||
|
* @return int
|
||||||
|
* @since 2.5
|
||||||
|
*/
|
||||||
|
protected function _getAssetParentId(JTable $table = NULL, $id = NULL)
|
||||||
|
{
|
||||||
|
$asset = JTable::getInstance('Asset');
|
||||||
|
$asset->loadByName('com_componentbuilder');
|
||||||
|
|
||||||
|
return $asset->id;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This view does not actually have an alias
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function generateAlias()
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
25
admin/views/component_modules/submitbutton.js
Normal file
25
admin/views/component_modules/submitbutton.js
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
/**
|
||||||
|
* @package Joomla.Component.Builder
|
||||||
|
*
|
||||||
|
* @created 30th April, 2015
|
||||||
|
* @author Llewellyn van der Merwe <http://www.joomlacomponentbuilder.com>
|
||||||
|
* @github Joomla Component Builder <https://github.com/vdm-io/Joomla-Component-Builder>
|
||||||
|
* @copyright Copyright (C) 2015 - 2019 Vast Development Method. All rights reserved.
|
||||||
|
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||||
|
*/
|
||||||
|
|
||||||
|
Joomla.submitbutton = function(task)
|
||||||
|
{
|
||||||
|
if (task == ''){
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
var action = task.split('.');
|
||||||
|
if (action[1] == 'cancel' || action[1] == 'close' || document.formvalidator.isValid(document.getElementById("adminForm"))){
|
||||||
|
Joomla.submitform(task, document.getElementById("adminForm"));
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
alert(Joomla.JText._('component_modules, some values are not acceptable.','Some values are unacceptable'));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
122
admin/views/component_modules/tmpl/edit.php
Normal file
122
admin/views/component_modules/tmpl/edit.php
Normal file
@ -0,0 +1,122 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* @package Joomla.Component.Builder
|
||||||
|
*
|
||||||
|
* @created 30th April, 2015
|
||||||
|
* @author Llewellyn van der Merwe <http://www.joomlacomponentbuilder.com>
|
||||||
|
* @github Joomla Component Builder <https://github.com/vdm-io/Joomla-Component-Builder>
|
||||||
|
* @copyright Copyright (C) 2015 - 2019 Vast Development Method. All rights reserved.
|
||||||
|
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||||
|
*/
|
||||||
|
|
||||||
|
// No direct access to this file
|
||||||
|
defined('_JEXEC') or die('Restricted access');
|
||||||
|
|
||||||
|
JHtml::addIncludePath(JPATH_COMPONENT.'/helpers/html');
|
||||||
|
JHtml::_('behavior.tooltip');
|
||||||
|
JHtml::_('behavior.formvalidation');
|
||||||
|
JHtml::_('formbehavior.chosen', 'select');
|
||||||
|
JHtml::_('behavior.keepalive');
|
||||||
|
$componentParams = $this->params; // will be removed just use $this->params instead
|
||||||
|
?>
|
||||||
|
<script type="text/javascript">
|
||||||
|
// waiting spinner
|
||||||
|
var outerDiv = jQuery('body');
|
||||||
|
jQuery('<div id="loading"></div>')
|
||||||
|
.css("background", "rgba(255, 255, 255, .8) url('components/com_componentbuilder/assets/images/import.gif') 50% 15% no-repeat")
|
||||||
|
.css("top", outerDiv.position().top - jQuery(window).scrollTop())
|
||||||
|
.css("left", outerDiv.position().left - jQuery(window).scrollLeft())
|
||||||
|
.css("width", outerDiv.width())
|
||||||
|
.css("height", outerDiv.height())
|
||||||
|
.css("position", "fixed")
|
||||||
|
.css("opacity", "0.80")
|
||||||
|
.css("-ms-filter", "progid:DXImageTransform.Microsoft.Alpha(Opacity = 80)")
|
||||||
|
.css("filter", "alpha(opacity = 80)")
|
||||||
|
.css("display", "none")
|
||||||
|
.appendTo(outerDiv);
|
||||||
|
jQuery('#loading').show();
|
||||||
|
// when page is ready remove and show
|
||||||
|
jQuery(window).load(function() {
|
||||||
|
jQuery('#componentbuilder_loader').fadeIn('fast');
|
||||||
|
jQuery('#loading').hide();
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
<div id="componentbuilder_loader" style="display: none;">
|
||||||
|
<form action="<?php echo JRoute::_('index.php?option=com_componentbuilder&layout=edit&id='. (int) $this->item->id . $this->referral); ?>" method="post" name="adminForm" id="adminForm" class="form-validate" enctype="multipart/form-data">
|
||||||
|
|
||||||
|
<?php echo JLayoutHelper::render('component_modules.modules_above', $this); ?>
|
||||||
|
<div class="form-horizontal">
|
||||||
|
|
||||||
|
<?php echo JHtml::_('bootstrap.startTabSet', 'component_modulesTab', array('active' => 'modules')); ?>
|
||||||
|
|
||||||
|
<?php echo JHtml::_('bootstrap.addTab', 'component_modulesTab', 'modules', JText::_('COM_COMPONENTBUILDER_COMPONENT_MODULES_MODULES', true)); ?>
|
||||||
|
<div class="row-fluid form-horizontal-desktop">
|
||||||
|
</div>
|
||||||
|
<div class="row-fluid form-horizontal-desktop">
|
||||||
|
<div class="span12">
|
||||||
|
<?php echo JLayoutHelper::render('component_modules.modules_fullwidth', $this); ?>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<?php echo JHtml::_('bootstrap.endTab'); ?>
|
||||||
|
|
||||||
|
<?php $this->ignore_fieldsets = array('details','metadata','vdmmetadata','accesscontrol'); ?>
|
||||||
|
<?php $this->tab_name = 'component_modulesTab'; ?>
|
||||||
|
<?php echo JLayoutHelper::render('joomla.edit.params', $this); ?>
|
||||||
|
|
||||||
|
<?php if ($this->canDo->get('component_modules.delete') || $this->canDo->get('component_modules.edit.created_by') || $this->canDo->get('component_modules.edit.state') || $this->canDo->get('component_modules.edit.created')) : ?>
|
||||||
|
<?php echo JHtml::_('bootstrap.addTab', 'component_modulesTab', 'publishing', JText::_('COM_COMPONENTBUILDER_COMPONENT_MODULES_PUBLISHING', true)); ?>
|
||||||
|
<div class="row-fluid form-horizontal-desktop">
|
||||||
|
<div class="span6">
|
||||||
|
<?php echo JLayoutHelper::render('component_modules.publishing', $this); ?>
|
||||||
|
</div>
|
||||||
|
<div class="span6">
|
||||||
|
<?php echo JLayoutHelper::render('component_modules.publlshing', $this); ?>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<?php echo JHtml::_('bootstrap.endTab'); ?>
|
||||||
|
<?php endif; ?>
|
||||||
|
|
||||||
|
<?php if ($this->canDo->get('core.admin')) : ?>
|
||||||
|
<?php echo JHtml::_('bootstrap.addTab', 'component_modulesTab', 'permissions', JText::_('COM_COMPONENTBUILDER_COMPONENT_MODULES_PERMISSION', true)); ?>
|
||||||
|
<div class="row-fluid form-horizontal-desktop">
|
||||||
|
<div class="span12">
|
||||||
|
<fieldset class="adminform">
|
||||||
|
<div class="adminformlist">
|
||||||
|
<?php foreach ($this->form->getFieldset('accesscontrol') as $field): ?>
|
||||||
|
<div>
|
||||||
|
<?php echo $field->label; echo $field->input;?>
|
||||||
|
</div>
|
||||||
|
<div class="clearfix"></div>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
</div>
|
||||||
|
</fieldset>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<?php echo JHtml::_('bootstrap.endTab'); ?>
|
||||||
|
<?php endif; ?>
|
||||||
|
|
||||||
|
<?php echo JHtml::_('bootstrap.endTabSet'); ?>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<input type="hidden" name="task" value="component_modules.edit" />
|
||||||
|
<?php echo JHtml::_('form.token'); ?>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<script type="text/javascript">
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
jQuery(document).ready(function(){
|
||||||
|
jQuery(document).on('subform-row-add', function(event, row){
|
||||||
|
var group_key = jQuery(row).context.dataset.group;
|
||||||
|
jQuery(row).find('#jform_addadmin_views__' + group_key + '__submenu').prop('checked', true);
|
||||||
|
jQuery(row).find('#jform_addadmin_views__' + group_key + '__checkin').prop('checked', true);
|
||||||
|
jQuery(row).find('#jform_addadmin_views__' + group_key + '__history').prop('checked', true);
|
||||||
|
jQuery(row).find('#jform_addadmin_views__' + group_key + '__access').prop('checked', true);
|
||||||
|
jQuery(row).find('#jform_addadmin_views__' + group_key + '__port').prop('checked', true);
|
||||||
|
})
|
||||||
|
});
|
||||||
|
</script>
|
1
admin/views/component_modules/tmpl/index.html
Normal file
1
admin/views/component_modules/tmpl/index.html
Normal file
@ -0,0 +1 @@
|
|||||||
|
<html><body bgcolor="#FFFFFF"></body></html>
|
195
admin/views/component_modules/view.html.php
Normal file
195
admin/views/component_modules/view.html.php
Normal file
@ -0,0 +1,195 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* @package Joomla.Component.Builder
|
||||||
|
*
|
||||||
|
* @created 30th April, 2015
|
||||||
|
* @author Llewellyn van der Merwe <http://www.joomlacomponentbuilder.com>
|
||||||
|
* @github Joomla Component Builder <https://github.com/vdm-io/Joomla-Component-Builder>
|
||||||
|
* @copyright Copyright (C) 2015 - 2019 Vast Development Method. All rights reserved.
|
||||||
|
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||||
|
*/
|
||||||
|
|
||||||
|
// No direct access to this file
|
||||||
|
defined('_JEXEC') or die('Restricted access');
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Component_modules View class
|
||||||
|
*/
|
||||||
|
class ComponentbuilderViewComponent_modules extends JViewLegacy
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* display method of View
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function display($tpl = null)
|
||||||
|
{
|
||||||
|
// set params
|
||||||
|
$this->params = JComponentHelper::getParams('com_componentbuilder');
|
||||||
|
// Assign the variables
|
||||||
|
$this->form = $this->get('Form');
|
||||||
|
$this->item = $this->get('Item');
|
||||||
|
$this->script = $this->get('Script');
|
||||||
|
$this->state = $this->get('State');
|
||||||
|
// get action permissions
|
||||||
|
$this->canDo = ComponentbuilderHelper::getActions('component_modules', $this->item);
|
||||||
|
// get input
|
||||||
|
$jinput = JFactory::getApplication()->input;
|
||||||
|
$this->ref = $jinput->get('ref', 0, 'word');
|
||||||
|
$this->refid = $jinput->get('refid', 0, 'int');
|
||||||
|
$return = $jinput->get('return', null, 'base64');
|
||||||
|
// set the referral string
|
||||||
|
$this->referral = '';
|
||||||
|
if ($this->refid && $this->ref)
|
||||||
|
{
|
||||||
|
// return to the item that referred to this item
|
||||||
|
$this->referral = '&ref=' . (string)$this->ref . '&refid=' . (int)$this->refid;
|
||||||
|
}
|
||||||
|
elseif($this->ref)
|
||||||
|
{
|
||||||
|
// return to the list view that referred to this item
|
||||||
|
$this->referral = '&ref=' . (string)$this->ref;
|
||||||
|
}
|
||||||
|
// check return value
|
||||||
|
if (!is_null($return))
|
||||||
|
{
|
||||||
|
// add the return value
|
||||||
|
$this->referral .= '&return=' . (string)$return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set the toolbar
|
||||||
|
$this->addToolBar();
|
||||||
|
|
||||||
|
// Check for errors.
|
||||||
|
if (count($errors = $this->get('Errors')))
|
||||||
|
{
|
||||||
|
throw new Exception(implode("\n", $errors), 500);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Display the template
|
||||||
|
parent::display($tpl);
|
||||||
|
|
||||||
|
// Set the document
|
||||||
|
$this->setDocument();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Setting the toolbar
|
||||||
|
*/
|
||||||
|
protected function addToolBar()
|
||||||
|
{
|
||||||
|
JFactory::getApplication()->input->set('hidemainmenu', true);
|
||||||
|
$user = JFactory::getUser();
|
||||||
|
$userId = $user->id;
|
||||||
|
$isNew = $this->item->id == 0;
|
||||||
|
|
||||||
|
JToolbarHelper::title( JText::_($isNew ? 'COM_COMPONENTBUILDER_COMPONENT_MODULES_NEW' : 'COM_COMPONENTBUILDER_COMPONENT_MODULES_EDIT'), 'pencil-2 article-add');
|
||||||
|
// Built the actions for new and existing records.
|
||||||
|
if (ComponentbuilderHelper::checkString($this->referral))
|
||||||
|
{
|
||||||
|
if ($this->canDo->get('component_modules.create') && $isNew)
|
||||||
|
{
|
||||||
|
// We can create the record.
|
||||||
|
JToolBarHelper::save('component_modules.save', 'JTOOLBAR_SAVE');
|
||||||
|
}
|
||||||
|
elseif ($this->canDo->get('component_modules.edit'))
|
||||||
|
{
|
||||||
|
// We can save the record.
|
||||||
|
JToolBarHelper::save('component_modules.save', 'JTOOLBAR_SAVE');
|
||||||
|
}
|
||||||
|
if ($isNew)
|
||||||
|
{
|
||||||
|
// Do not creat but cancel.
|
||||||
|
JToolBarHelper::cancel('component_modules.cancel', 'JTOOLBAR_CANCEL');
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// We can close it.
|
||||||
|
JToolBarHelper::cancel('component_modules.cancel', 'JTOOLBAR_CLOSE');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if ($isNew)
|
||||||
|
{
|
||||||
|
// For new records, check the create permission.
|
||||||
|
if ($this->canDo->get('component_modules.create'))
|
||||||
|
{
|
||||||
|
JToolBarHelper::apply('component_modules.apply', 'JTOOLBAR_APPLY');
|
||||||
|
JToolBarHelper::save('component_modules.save', 'JTOOLBAR_SAVE');
|
||||||
|
JToolBarHelper::custom('component_modules.save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false);
|
||||||
|
};
|
||||||
|
JToolBarHelper::cancel('component_modules.cancel', 'JTOOLBAR_CANCEL');
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if ($this->canDo->get('component_modules.edit'))
|
||||||
|
{
|
||||||
|
// We can save the new record
|
||||||
|
JToolBarHelper::apply('component_modules.apply', 'JTOOLBAR_APPLY');
|
||||||
|
JToolBarHelper::save('component_modules.save', 'JTOOLBAR_SAVE');
|
||||||
|
// We can save this record, but check the create permission to see
|
||||||
|
// if we can return to make a new one.
|
||||||
|
if ($this->canDo->get('component_modules.create'))
|
||||||
|
{
|
||||||
|
JToolBarHelper::custom('component_modules.save2new', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$canVersion = ($this->canDo->get('core.version') && $this->canDo->get('component_modules.version'));
|
||||||
|
if ($this->state->params->get('save_history', 1) && $this->canDo->get('component_modules.edit') && $canVersion)
|
||||||
|
{
|
||||||
|
JToolbarHelper::versions('com_componentbuilder.component_modules', $this->item->id);
|
||||||
|
}
|
||||||
|
if ($this->canDo->get('component_modules.create'))
|
||||||
|
{
|
||||||
|
JToolBarHelper::custom('component_modules.save2copy', 'save-copy.png', 'save-copy_f2.png', 'JTOOLBAR_SAVE_AS_COPY', false);
|
||||||
|
}
|
||||||
|
JToolBarHelper::cancel('component_modules.cancel', 'JTOOLBAR_CLOSE');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
JToolbarHelper::divider();
|
||||||
|
// set help url for this view if found
|
||||||
|
$help_url = ComponentbuilderHelper::getHelpUrl('component_modules');
|
||||||
|
if (ComponentbuilderHelper::checkString($help_url))
|
||||||
|
{
|
||||||
|
JToolbarHelper::help('COM_COMPONENTBUILDER_HELP_MANAGER', false, $help_url);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Escapes a value for output in a view script.
|
||||||
|
*
|
||||||
|
* @param mixed $var The output to escape.
|
||||||
|
*
|
||||||
|
* @return mixed The escaped value.
|
||||||
|
*/
|
||||||
|
public function escape($var)
|
||||||
|
{
|
||||||
|
if(strlen($var) > 30)
|
||||||
|
{
|
||||||
|
// use the helper htmlEscape method instead and shorten the string
|
||||||
|
return ComponentbuilderHelper::htmlEscape($var, $this->_charset, true, 30);
|
||||||
|
}
|
||||||
|
// use the helper htmlEscape method instead.
|
||||||
|
return ComponentbuilderHelper::htmlEscape($var, $this->_charset);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method to set up the document properties
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
protected function setDocument()
|
||||||
|
{
|
||||||
|
$isNew = ($this->item->id < 1);
|
||||||
|
if (!isset($this->document))
|
||||||
|
{
|
||||||
|
$this->document = JFactory::getDocument();
|
||||||
|
}
|
||||||
|
$this->document->setTitle(JText::_($isNew ? 'COM_COMPONENTBUILDER_COMPONENT_MODULES_NEW' : 'COM_COMPONENTBUILDER_COMPONENT_MODULES_EDIT'));
|
||||||
|
$this->document->addStyleSheet(JURI::root() . "administrator/components/com_componentbuilder/assets/css/component_modules.css", (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/css');
|
||||||
|
$this->document->addScript(JURI::root() . $this->script, (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript');
|
||||||
|
$this->document->addScript(JURI::root() . "administrator/components/com_componentbuilder/views/component_modules/submitbutton.js", (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/javascript');
|
||||||
|
JText::script('view not acceptable. Error');
|
||||||
|
}
|
||||||
|
}
|
1
admin/views/components_modules/index.html
Normal file
1
admin/views/components_modules/index.html
Normal file
@ -0,0 +1 @@
|
|||||||
|
<html><body bgcolor="#FFFFFF"></body></html>
|
85
admin/views/components_modules/tmpl/default.php
Normal file
85
admin/views/components_modules/tmpl/default.php
Normal file
@ -0,0 +1,85 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* @package Joomla.Component.Builder
|
||||||
|
*
|
||||||
|
* @created 30th April, 2015
|
||||||
|
* @author Llewellyn van der Merwe <http://www.joomlacomponentbuilder.com>
|
||||||
|
* @github Joomla Component Builder <https://github.com/vdm-io/Joomla-Component-Builder>
|
||||||
|
* @copyright Copyright (C) 2015 - 2019 Vast Development Method. All rights reserved.
|
||||||
|
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||||
|
*/
|
||||||
|
|
||||||
|
// No direct access to this file
|
||||||
|
defined('_JEXEC') or die('Restricted access');
|
||||||
|
|
||||||
|
// load tooltip behavior
|
||||||
|
JHtml::_('behavior.tooltip');
|
||||||
|
JHtml::_('behavior.multiselect');
|
||||||
|
JHtml::_('dropdown.init');
|
||||||
|
JHtml::_('formbehavior.chosen', 'select');
|
||||||
|
|
||||||
|
if ($this->saveOrder)
|
||||||
|
{
|
||||||
|
$saveOrderingUrl = 'index.php?option=com_componentbuilder&task=components_modules.saveOrderAjax&tmpl=component';
|
||||||
|
JHtml::_('sortablelist.sortable', 'component_modulesList', 'adminForm', strtolower($this->listDirn), $saveOrderingUrl);
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
|
<script type="text/javascript">
|
||||||
|
Joomla.orderTable = function()
|
||||||
|
{
|
||||||
|
table = document.getElementById("sortTable");
|
||||||
|
direction = document.getElementById("directionTable");
|
||||||
|
order = table.options[table.selectedIndex].value;
|
||||||
|
if (order != '<?php echo $this->listOrder; ?>')
|
||||||
|
{
|
||||||
|
dirn = 'asc';
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
dirn = direction.options[direction.selectedIndex].value;
|
||||||
|
}
|
||||||
|
Joomla.tableOrdering(order, dirn, '');
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
<form action="<?php echo JRoute::_('index.php?option=com_componentbuilder&view=components_modules'); ?>" method="post" name="adminForm" id="adminForm">
|
||||||
|
<?php if(!empty( $this->sidebar)): ?>
|
||||||
|
<div id="j-sidebar-container" class="span2">
|
||||||
|
<?php echo $this->sidebar; ?>
|
||||||
|
</div>
|
||||||
|
<div id="j-main-container" class="span10">
|
||||||
|
<?php else : ?>
|
||||||
|
<div id="j-main-container">
|
||||||
|
<?php endif; ?>
|
||||||
|
<?php if (empty($this->items)): ?>
|
||||||
|
<?php echo $this->loadTemplate('toolbar');?>
|
||||||
|
<div class="alert alert-no-items">
|
||||||
|
<?php echo JText::_('JGLOBAL_NO_MATCHING_RESULTS'); ?>
|
||||||
|
</div>
|
||||||
|
<?php else : ?>
|
||||||
|
<?php echo $this->loadTemplate('toolbar');?>
|
||||||
|
<table class="table table-striped" id="component_modulesList">
|
||||||
|
<thead><?php echo $this->loadTemplate('head');?></thead>
|
||||||
|
<tfoot><?php echo $this->loadTemplate('foot');?></tfoot>
|
||||||
|
<tbody><?php echo $this->loadTemplate('body');?></tbody>
|
||||||
|
</table>
|
||||||
|
<?php //Load the batch processing form. ?>
|
||||||
|
<?php if ($this->canCreate && $this->canEdit) : ?>
|
||||||
|
<?php echo JHtml::_(
|
||||||
|
'bootstrap.renderModal',
|
||||||
|
'collapseModal',
|
||||||
|
array(
|
||||||
|
'title' => JText::_('COM_COMPONENTBUILDER_COMPONENTS_MODULES_BATCH_OPTIONS'),
|
||||||
|
'footer' => $this->loadTemplate('batch_footer')
|
||||||
|
),
|
||||||
|
$this->loadTemplate('batch_body')
|
||||||
|
); ?>
|
||||||
|
<?php endif; ?>
|
||||||
|
<input type="hidden" name="filter_order" value="" />
|
||||||
|
<input type="hidden" name="filter_order_Dir" value="" />
|
||||||
|
<input type="hidden" name="boxchecked" value="0" />
|
||||||
|
</div>
|
||||||
|
<?php endif; ?>
|
||||||
|
<input type="hidden" name="task" value="" />
|
||||||
|
<?php echo JHtml::_('form.token'); ?>
|
||||||
|
</form>
|
18
admin/views/components_modules/tmpl/default_batch_body.php
Normal file
18
admin/views/components_modules/tmpl/default_batch_body.php
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* @package Joomla.Component.Builder
|
||||||
|
*
|
||||||
|
* @created 30th April, 2015
|
||||||
|
* @author Llewellyn van der Merwe <http://www.joomlacomponentbuilder.com>
|
||||||
|
* @github Joomla Component Builder <https://github.com/vdm-io/Joomla-Component-Builder>
|
||||||
|
* @copyright Copyright (C) 2015 - 2019 Vast Development Method. All rights reserved.
|
||||||
|
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||||
|
*/
|
||||||
|
|
||||||
|
// No direct access to this file
|
||||||
|
defined('_JEXEC') or die('Restricted access');
|
||||||
|
|
||||||
|
?>
|
||||||
|
|
||||||
|
<p><?php echo JText::_('COM_COMPONENTBUILDER_COMPONENTS_MODULES_BATCH_TIP'); ?></p>
|
||||||
|
<?php echo $this->batchDisplay; ?>
|
23
admin/views/components_modules/tmpl/default_batch_footer.php
Normal file
23
admin/views/components_modules/tmpl/default_batch_footer.php
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* @package Joomla.Component.Builder
|
||||||
|
*
|
||||||
|
* @created 30th April, 2015
|
||||||
|
* @author Llewellyn van der Merwe <http://www.joomlacomponentbuilder.com>
|
||||||
|
* @github Joomla Component Builder <https://github.com/vdm-io/Joomla-Component-Builder>
|
||||||
|
* @copyright Copyright (C) 2015 - 2019 Vast Development Method. All rights reserved.
|
||||||
|
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||||
|
*/
|
||||||
|
|
||||||
|
// No direct access to this file
|
||||||
|
defined('_JEXEC') or die('Restricted access');
|
||||||
|
|
||||||
|
?>
|
||||||
|
<!-- clear the batch values if cancel -->
|
||||||
|
<button class="btn" type="button" onclick="" data-dismiss="modal">
|
||||||
|
<?php echo JText::_('JCANCEL'); ?>
|
||||||
|
</button>
|
||||||
|
<!-- post the batch values if process -->
|
||||||
|
<button class="btn btn-success" type="submit" onclick="Joomla.submitbutton('component_modules.batch');">
|
||||||
|
<?php echo JText::_('JGLOBAL_BATCH_PROCESS'); ?>
|
||||||
|
</button>
|
94
admin/views/components_modules/tmpl/default_body.php
Normal file
94
admin/views/components_modules/tmpl/default_body.php
Normal file
@ -0,0 +1,94 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* @package Joomla.Component.Builder
|
||||||
|
*
|
||||||
|
* @created 30th April, 2015
|
||||||
|
* @author Llewellyn van der Merwe <http://www.joomlacomponentbuilder.com>
|
||||||
|
* @github Joomla Component Builder <https://github.com/vdm-io/Joomla-Component-Builder>
|
||||||
|
* @copyright Copyright (C) 2015 - 2019 Vast Development Method. All rights reserved.
|
||||||
|
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||||
|
*/
|
||||||
|
|
||||||
|
// No direct access to this file
|
||||||
|
defined('_JEXEC') or die('Restricted access');
|
||||||
|
|
||||||
|
$edit = "index.php?option=com_componentbuilder&view=components_modules&task=component_modules.edit";
|
||||||
|
|
||||||
|
?>
|
||||||
|
<?php foreach ($this->items as $i => $item): ?>
|
||||||
|
<?php
|
||||||
|
$canCheckin = $this->user->authorise('core.manage', 'com_checkin') || $item->checked_out == $this->user->id || $item->checked_out == 0;
|
||||||
|
$userChkOut = JFactory::getUser($item->checked_out);
|
||||||
|
$canDo = ComponentbuilderHelper::getActions('component_modules',$item,'components_modules');
|
||||||
|
?>
|
||||||
|
<tr class="row<?php echo $i % 2; ?>">
|
||||||
|
<td class="order nowrap center hidden-phone">
|
||||||
|
<?php if ($canDo->get('component_modules.edit.state')): ?>
|
||||||
|
<?php
|
||||||
|
if ($this->saveOrder)
|
||||||
|
{
|
||||||
|
$iconClass = ' inactive';
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$iconClass = ' inactive tip-top" hasTooltip" title="' . JHtml::tooltipText('JORDERINGDISABLED');
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
<span class="sortable-handler<?php echo $iconClass; ?>">
|
||||||
|
<i class="icon-menu"></i>
|
||||||
|
</span>
|
||||||
|
<?php if ($this->saveOrder) : ?>
|
||||||
|
<input type="text" style="display:none" name="order[]" size="5"
|
||||||
|
value="<?php echo $item->ordering; ?>" class="width-20 text-area-order " />
|
||||||
|
<?php endif; ?>
|
||||||
|
<?php else: ?>
|
||||||
|
⋮
|
||||||
|
<?php endif; ?>
|
||||||
|
</td>
|
||||||
|
<td class="nowrap center">
|
||||||
|
<?php if ($canDo->get('component_modules.edit')): ?>
|
||||||
|
<?php if ($item->checked_out) : ?>
|
||||||
|
<?php if ($canCheckin) : ?>
|
||||||
|
<?php echo JHtml::_('grid.id', $i, $item->id); ?>
|
||||||
|
<?php else: ?>
|
||||||
|
□
|
||||||
|
<?php endif; ?>
|
||||||
|
<?php else: ?>
|
||||||
|
<?php echo JHtml::_('grid.id', $i, $item->id); ?>
|
||||||
|
<?php endif; ?>
|
||||||
|
<?php else: ?>
|
||||||
|
□
|
||||||
|
<?php endif; ?>
|
||||||
|
</td>
|
||||||
|
<td class="nowrap">
|
||||||
|
<div class="name">
|
||||||
|
<?php if ($canDo->get('component_modules.edit')): ?>
|
||||||
|
<a href="<?php echo $edit; ?>&id=<?php echo $item->id; ?>"><?php echo $this->escape($item->joomla_component_system_name); ?></a>
|
||||||
|
<?php if ($item->checked_out): ?>
|
||||||
|
<?php echo JHtml::_('jgrid.checkedout', $i, $userChkOut->name, $item->checked_out_time, 'components_modules.', $canCheckin); ?>
|
||||||
|
<?php endif; ?>
|
||||||
|
<?php else: ?>
|
||||||
|
<?php echo $this->escape($item->joomla_component_system_name); ?>
|
||||||
|
<?php endif; ?>
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
<td class="center">
|
||||||
|
<?php if ($canDo->get('component_modules.edit.state')) : ?>
|
||||||
|
<?php if ($item->checked_out) : ?>
|
||||||
|
<?php if ($canCheckin) : ?>
|
||||||
|
<?php echo JHtml::_('jgrid.published', $item->published, $i, 'components_modules.', true, 'cb'); ?>
|
||||||
|
<?php else: ?>
|
||||||
|
<?php echo JHtml::_('jgrid.published', $item->published, $i, 'components_modules.', false, 'cb'); ?>
|
||||||
|
<?php endif; ?>
|
||||||
|
<?php else: ?>
|
||||||
|
<?php echo JHtml::_('jgrid.published', $item->published, $i, 'components_modules.', true, 'cb'); ?>
|
||||||
|
<?php endif; ?>
|
||||||
|
<?php else: ?>
|
||||||
|
<?php echo JHtml::_('jgrid.published', $item->published, $i, 'components_modules.', false, 'cb'); ?>
|
||||||
|
<?php endif; ?>
|
||||||
|
</td>
|
||||||
|
<td class="nowrap center hidden-phone">
|
||||||
|
<?php echo $item->id; ?>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<?php endforeach; ?>
|
18
admin/views/components_modules/tmpl/default_foot.php
Normal file
18
admin/views/components_modules/tmpl/default_foot.php
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* @package Joomla.Component.Builder
|
||||||
|
*
|
||||||
|
* @created 30th April, 2015
|
||||||
|
* @author Llewellyn van der Merwe <http://www.joomlacomponentbuilder.com>
|
||||||
|
* @github Joomla Component Builder <https://github.com/vdm-io/Joomla-Component-Builder>
|
||||||
|
* @copyright Copyright (C) 2015 - 2019 Vast Development Method. All rights reserved.
|
||||||
|
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||||
|
*/
|
||||||
|
|
||||||
|
// No direct access to this file
|
||||||
|
defined('_JEXEC') or die('Restricted access');
|
||||||
|
|
||||||
|
?>
|
||||||
|
<tr>
|
||||||
|
<td colspan="5"><?php echo $this->pagination->getListFooter(); ?></td>
|
||||||
|
</tr>
|
47
admin/views/components_modules/tmpl/default_head.php
Normal file
47
admin/views/components_modules/tmpl/default_head.php
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* @package Joomla.Component.Builder
|
||||||
|
*
|
||||||
|
* @created 30th April, 2015
|
||||||
|
* @author Llewellyn van der Merwe <http://www.joomlacomponentbuilder.com>
|
||||||
|
* @github Joomla Component Builder <https://github.com/vdm-io/Joomla-Component-Builder>
|
||||||
|
* @copyright Copyright (C) 2015 - 2019 Vast Development Method. All rights reserved.
|
||||||
|
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||||
|
*/
|
||||||
|
|
||||||
|
// No direct access to this file
|
||||||
|
defined('_JEXEC') or die('Restricted access');
|
||||||
|
|
||||||
|
?>
|
||||||
|
<tr>
|
||||||
|
<?php if ($this->canEdit&& $this->canState): ?>
|
||||||
|
<th width="1%" class="nowrap center hidden-phone">
|
||||||
|
<?php echo JHtml::_('grid.sort', '<i class="icon-menu-2"></i>', 'ordering', $this->listDirn, $this->listOrder, null, 'asc', 'JGRID_HEADING_ORDERING'); ?>
|
||||||
|
</th>
|
||||||
|
<th width="20" class="nowrap center">
|
||||||
|
<?php echo JHtml::_('grid.checkall'); ?>
|
||||||
|
</th>
|
||||||
|
<?php else: ?>
|
||||||
|
<th width="20" class="nowrap center hidden-phone">
|
||||||
|
▾
|
||||||
|
</th>
|
||||||
|
<th width="20" class="nowrap center">
|
||||||
|
■
|
||||||
|
</th>
|
||||||
|
<?php endif; ?>
|
||||||
|
<th class="nowrap" >
|
||||||
|
<?php echo JText::_('COM_COMPONENTBUILDER_COMPONENT_MODULES_JOOMLA_COMPONENT_LABEL'); ?>
|
||||||
|
</th>
|
||||||
|
<?php if ($this->canState): ?>
|
||||||
|
<th width="10" class="nowrap center" >
|
||||||
|
<?php echo JHtml::_('grid.sort', 'COM_COMPONENTBUILDER_COMPONENT_MODULES_STATUS', 'published', $this->listDirn, $this->listOrder); ?>
|
||||||
|
</th>
|
||||||
|
<?php else: ?>
|
||||||
|
<th width="10" class="nowrap center" >
|
||||||
|
<?php echo JText::_('COM_COMPONENTBUILDER_COMPONENT_MODULES_STATUS'); ?>
|
||||||
|
</th>
|
||||||
|
<?php endif; ?>
|
||||||
|
<th width="5" class="nowrap center hidden-phone" >
|
||||||
|
<?php echo JHtml::_('grid.sort', 'COM_COMPONENTBUILDER_COMPONENT_MODULES_ID', 'id', $this->listDirn, $this->listOrder); ?>
|
||||||
|
</th>
|
||||||
|
</tr>
|
45
admin/views/components_modules/tmpl/default_toolbar.php
Normal file
45
admin/views/components_modules/tmpl/default_toolbar.php
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* @package Joomla.Component.Builder
|
||||||
|
*
|
||||||
|
* @created 30th April, 2015
|
||||||
|
* @author Llewellyn van der Merwe <http://www.joomlacomponentbuilder.com>
|
||||||
|
* @github Joomla Component Builder <https://github.com/vdm-io/Joomla-Component-Builder>
|
||||||
|
* @copyright Copyright (C) 2015 - 2019 Vast Development Method. All rights reserved.
|
||||||
|
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||||
|
*/
|
||||||
|
|
||||||
|
// No direct access to this file
|
||||||
|
defined('_JEXEC') or die('Restricted access');
|
||||||
|
|
||||||
|
?>
|
||||||
|
<div id="filter-bar" class="btn-toolbar">
|
||||||
|
<div class="filter-search btn-group pull-left">
|
||||||
|
<label for="filter_search" class="element-invisible"><?php echo JText::_('Search');?></label>
|
||||||
|
<input type="text" name="filter_search" id="filter_search" placeholder="<?php echo JText::_('JSEARCH_FILTER'); ?>" value="<?php echo $this->escape($this->state->get('filter.search')); ?>" class="hasTooltip" title="<?php echo JHtml::tooltipText('Search Components_modules'); ?>" />
|
||||||
|
</div>
|
||||||
|
<div class="btn-group pull-left">
|
||||||
|
<button type="submit" class="btn hasTooltip" title="<?php echo JHtml::tooltipText('JSEARCH_FILTER_SUBMIT'); ?>"><i class="icon-search"></i></button>
|
||||||
|
<button type="button" class="btn hasTooltip" title="<?php echo JHtml::tooltipText('JSEARCH_FILTER_CLEAR'); ?>" onclick="document.id('filter_search').value='';this.form.submit();"><i class="icon-remove"></i></button>
|
||||||
|
</div>
|
||||||
|
<div class="btn-group pull-right hidden-phone">
|
||||||
|
<label for="limit" class="element-invisible"><?php echo JText::_('JFIELD_PLG_SEARCH_SEARCHLIMIT_DESC');?></label>
|
||||||
|
<?php echo $this->pagination->getLimitBox(); ?>
|
||||||
|
</div>
|
||||||
|
<div class="btn-group pull-right hidden-phone">
|
||||||
|
<label for="directionTable" class="element-invisible"><?php echo JText::_('JFIELD_ORDERING_DESC');?></label>
|
||||||
|
<select name="directionTable" id="directionTable" class="input-medium" onchange="Joomla.orderTable()">
|
||||||
|
<option value=""><?php echo JText::_('JFIELD_ORDERING_DESC');?></option>
|
||||||
|
<option value="asc" <?php if ($this->listDirn == 'asc') echo 'selected="selected"'; ?>><?php echo JText::_('JGLOBAL_ORDER_ASCENDING');?></option>
|
||||||
|
<option value="desc" <?php if ($this->listDirn == 'desc') echo 'selected="selected"'; ?>><?php echo JText::_('JGLOBAL_ORDER_DESCENDING');?></option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
<div class="btn-group pull-right">
|
||||||
|
<label for="sortTable" class="element-invisible"><?php echo JText::_('JGLOBAL_SORT_BY');?></label>
|
||||||
|
<select name="sortTable" id="sortTable" class="input-medium" onchange="Joomla.orderTable()">
|
||||||
|
<option value=""><?php echo JText::_('JGLOBAL_SORT_BY');?></option>
|
||||||
|
<?php echo JHtml::_('select.options', $this->getSortFields(), 'value', 'text', $this->listOrder);?>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="clearfix"> </div>
|
1
admin/views/components_modules/tmpl/index.html
Normal file
1
admin/views/components_modules/tmpl/index.html
Normal file
@ -0,0 +1 @@
|
|||||||
|
<html><body bgcolor="#FFFFFF"></body></html>
|
226
admin/views/components_modules/view.html.php
Normal file
226
admin/views/components_modules/view.html.php
Normal file
@ -0,0 +1,226 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* @package Joomla.Component.Builder
|
||||||
|
*
|
||||||
|
* @created 30th April, 2015
|
||||||
|
* @author Llewellyn van der Merwe <http://www.joomlacomponentbuilder.com>
|
||||||
|
* @github Joomla Component Builder <https://github.com/vdm-io/Joomla-Component-Builder>
|
||||||
|
* @copyright Copyright (C) 2015 - 2019 Vast Development Method. All rights reserved.
|
||||||
|
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||||
|
*/
|
||||||
|
|
||||||
|
// No direct access to this file
|
||||||
|
defined('_JEXEC') or die('Restricted access');
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Componentbuilder View class for the Components_modules
|
||||||
|
*/
|
||||||
|
class ComponentbuilderViewComponents_modules extends JViewLegacy
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Components_modules view display method
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
function display($tpl = null)
|
||||||
|
{
|
||||||
|
if ($this->getLayout() !== 'modal')
|
||||||
|
{
|
||||||
|
// Include helper submenu
|
||||||
|
ComponentbuilderHelper::addSubmenu('components_modules');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Assign data to the view
|
||||||
|
$this->items = $this->get('Items');
|
||||||
|
$this->pagination = $this->get('Pagination');
|
||||||
|
$this->state = $this->get('State');
|
||||||
|
$this->user = JFactory::getUser();
|
||||||
|
$this->listOrder = $this->escape($this->state->get('list.ordering'));
|
||||||
|
$this->listDirn = $this->escape($this->state->get('list.direction'));
|
||||||
|
$this->saveOrder = $this->listOrder == 'ordering';
|
||||||
|
// set the return here value
|
||||||
|
$this->return_here = urlencode(base64_encode((string) JUri::getInstance()));
|
||||||
|
// get global action permissions
|
||||||
|
$this->canDo = ComponentbuilderHelper::getActions('component_modules');
|
||||||
|
$this->canEdit = $this->canDo->get('component_modules.edit');
|
||||||
|
$this->canState = $this->canDo->get('component_modules.edit.state');
|
||||||
|
$this->canCreate = $this->canDo->get('component_modules.create');
|
||||||
|
$this->canDelete = $this->canDo->get('component_modules.delete');
|
||||||
|
$this->canBatch = $this->canDo->get('core.batch');
|
||||||
|
|
||||||
|
// We don't need toolbar in the modal window.
|
||||||
|
if ($this->getLayout() !== 'modal')
|
||||||
|
{
|
||||||
|
$this->addToolbar();
|
||||||
|
$this->sidebar = JHtmlSidebar::render();
|
||||||
|
// load the batch html
|
||||||
|
if ($this->canCreate && $this->canEdit && $this->canState)
|
||||||
|
{
|
||||||
|
$this->batchDisplay = JHtmlBatch_::render();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check for errors.
|
||||||
|
if (count($errors = $this->get('Errors')))
|
||||||
|
{
|
||||||
|
throw new Exception(implode("\n", $errors), 500);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Display the template
|
||||||
|
parent::display($tpl);
|
||||||
|
|
||||||
|
// Set the document
|
||||||
|
$this->setDocument();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Setting the toolbar
|
||||||
|
*/
|
||||||
|
protected function addToolBar()
|
||||||
|
{
|
||||||
|
JToolBarHelper::title(JText::_('COM_COMPONENTBUILDER_COMPONENTS_MODULES'), 'joomla');
|
||||||
|
JHtmlSidebar::setAction('index.php?option=com_componentbuilder&view=components_modules');
|
||||||
|
JFormHelper::addFieldPath(JPATH_COMPONENT . '/models/fields');
|
||||||
|
|
||||||
|
if ($this->canCreate)
|
||||||
|
{
|
||||||
|
JToolBarHelper::addNew('component_modules.add');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Only load if there are items
|
||||||
|
if (ComponentbuilderHelper::checkArray($this->items))
|
||||||
|
{
|
||||||
|
if ($this->canEdit)
|
||||||
|
{
|
||||||
|
JToolBarHelper::editList('component_modules.edit');
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($this->canState)
|
||||||
|
{
|
||||||
|
JToolBarHelper::publishList('components_modules.publish');
|
||||||
|
JToolBarHelper::unpublishList('components_modules.unpublish');
|
||||||
|
JToolBarHelper::archiveList('components_modules.archive');
|
||||||
|
|
||||||
|
if ($this->canDo->get('core.admin'))
|
||||||
|
{
|
||||||
|
JToolBarHelper::checkin('components_modules.checkin');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add a batch button
|
||||||
|
if ($this->canBatch && $this->canCreate && $this->canEdit && $this->canState)
|
||||||
|
{
|
||||||
|
// Get the toolbar object instance
|
||||||
|
$bar = JToolBar::getInstance('toolbar');
|
||||||
|
// set the batch button name
|
||||||
|
$title = JText::_('JTOOLBAR_BATCH');
|
||||||
|
// Instantiate a new JLayoutFile instance and render the batch button
|
||||||
|
$layout = new JLayoutFile('joomla.toolbar.batch');
|
||||||
|
// add the button to the page
|
||||||
|
$dhtml = $layout->render(array('title' => $title));
|
||||||
|
$bar->appendButton('Custom', $dhtml, 'batch');
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($this->state->get('filter.published') == -2 && ($this->canState && $this->canDelete))
|
||||||
|
{
|
||||||
|
JToolbarHelper::deleteList('', 'components_modules.delete', 'JTOOLBAR_EMPTY_TRASH');
|
||||||
|
}
|
||||||
|
elseif ($this->canState && $this->canDelete)
|
||||||
|
{
|
||||||
|
JToolbarHelper::trash('components_modules.trash');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// set help url for this view if found
|
||||||
|
$help_url = ComponentbuilderHelper::getHelpUrl('components_modules');
|
||||||
|
if (ComponentbuilderHelper::checkString($help_url))
|
||||||
|
{
|
||||||
|
JToolbarHelper::help('COM_COMPONENTBUILDER_HELP_MANAGER', false, $help_url);
|
||||||
|
}
|
||||||
|
|
||||||
|
// add the options comp button
|
||||||
|
if ($this->canDo->get('core.admin') || $this->canDo->get('core.options'))
|
||||||
|
{
|
||||||
|
JToolBarHelper::preferences('com_componentbuilder');
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($this->canState)
|
||||||
|
{
|
||||||
|
JHtmlSidebar::addFilter(
|
||||||
|
JText::_('JOPTION_SELECT_PUBLISHED'),
|
||||||
|
'filter_published',
|
||||||
|
JHtml::_('select.options', JHtml::_('jgrid.publishedOptions'), 'value', 'text', $this->state->get('filter.published'), true)
|
||||||
|
);
|
||||||
|
// only load if batch allowed
|
||||||
|
if ($this->canBatch)
|
||||||
|
{
|
||||||
|
JHtmlBatch_::addListSelection(
|
||||||
|
JText::_('COM_COMPONENTBUILDER_KEEP_ORIGINAL_STATE'),
|
||||||
|
'batch[published]',
|
||||||
|
JHtml::_('select.options', JHtml::_('jgrid.publishedOptions', array('all' => false)), 'value', 'text', '', true)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
JHtmlSidebar::addFilter(
|
||||||
|
JText::_('JOPTION_SELECT_ACCESS'),
|
||||||
|
'filter_access',
|
||||||
|
JHtml::_('select.options', JHtml::_('access.assetgroups'), 'value', 'text', $this->state->get('filter.access'))
|
||||||
|
);
|
||||||
|
|
||||||
|
if ($this->canBatch && $this->canCreate && $this->canEdit)
|
||||||
|
{
|
||||||
|
JHtmlBatch_::addListSelection(
|
||||||
|
JText::_('COM_COMPONENTBUILDER_KEEP_ORIGINAL_ACCESS'),
|
||||||
|
'batch[access]',
|
||||||
|
JHtml::_('select.options', JHtml::_('access.assetgroups'), 'value', 'text')
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Method to set up the document properties
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
protected function setDocument()
|
||||||
|
{
|
||||||
|
if (!isset($this->document))
|
||||||
|
{
|
||||||
|
$this->document = JFactory::getDocument();
|
||||||
|
}
|
||||||
|
$this->document->setTitle(JText::_('COM_COMPONENTBUILDER_COMPONENTS_MODULES'));
|
||||||
|
$this->document->addStyleSheet(JURI::root() . "administrator/components/com_componentbuilder/assets/css/components_modules.css", (ComponentbuilderHelper::jVersion()->isCompatible('3.8.0')) ? array('version' => 'auto') : 'text/css');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Escapes a value for output in a view script.
|
||||||
|
*
|
||||||
|
* @param mixed $var The output to escape.
|
||||||
|
*
|
||||||
|
* @return mixed The escaped value.
|
||||||
|
*/
|
||||||
|
public function escape($var)
|
||||||
|
{
|
||||||
|
if(strlen($var) > 50)
|
||||||
|
{
|
||||||
|
// use the helper htmlEscape method instead and shorten the string
|
||||||
|
return ComponentbuilderHelper::htmlEscape($var, $this->_charset, true);
|
||||||
|
}
|
||||||
|
// use the helper htmlEscape method instead.
|
||||||
|
return ComponentbuilderHelper::htmlEscape($var, $this->_charset);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns an array of fields the table can be sorted by
|
||||||
|
*
|
||||||
|
* @return array Array containing the field name to sort by as the key and display text as value
|
||||||
|
*/
|
||||||
|
protected function getSortFields()
|
||||||
|
{
|
||||||
|
return array(
|
||||||
|
'a.sorting' => JText::_('JGRID_HEADING_ORDERING'),
|
||||||
|
'a.published' => JText::_('JSTATUS'),
|
||||||
|
'a.id' => JText::_('JGRID_HEADING_ID')
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
1
media/uikit-v3/css/index.html
Normal file
1
media/uikit-v3/css/index.html
Normal file
@ -0,0 +1 @@
|
|||||||
|
<html><body bgcolor="#FFFFFF"></body></html>
|
1
media/uikit-v3/css/uikit.min.css
vendored
Normal file
1
media/uikit-v3/css/uikit.min.css
vendored
Normal file
File diff suppressed because one or more lines are too long
1
media/uikit-v3/index.html
Normal file
1
media/uikit-v3/index.html
Normal file
@ -0,0 +1 @@
|
|||||||
|
<html><body bgcolor="#FFFFFF"></body></html>
|
1
media/uikit-v3/js/index.html
Normal file
1
media/uikit-v3/js/index.html
Normal file
@ -0,0 +1 @@
|
|||||||
|
<html><body bgcolor="#FFFFFF"></body></html>
|
3
media/uikit-v3/js/uikit-icons.min.js
vendored
Normal file
3
media/uikit-v3/js/uikit-icons.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
3
media/uikit-v3/js/uikit.min.js
vendored
Normal file
3
media/uikit-v3/js/uikit.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user