Skip to content
This repository has been archived by the owner on Jan 13, 2023. It is now read-only.

Commit

Permalink
wip (#78)
Browse files Browse the repository at this point in the history
  • Loading branch information
astridx committed Jul 31, 2021
1 parent 8fa0f0d commit 8291a83
Show file tree
Hide file tree
Showing 153 changed files with 2,247 additions and 3,203 deletions.
2 changes: 1 addition & 1 deletion jorobo.ini
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
extension = agosms
version = 3.0.3
version = 3.0.5
source = src
target = package

Expand Down
3 changes: 1 addition & 2 deletions src/administrator/components/com_agosms/agosms.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@
defined('_JEXEC') or die;
JHtml::_('behavior.tabstate');

if (!JFactory::getUser()->authorise('core.manage', 'com_agosms'))
{
if (!JFactory::getUser()->authorise('core.manage', 'com_agosms')) {
throw new JAccessExceptionNotallowed(JText::_('JERROR_ALERTNOAUTHOR'), 403);
}

Expand Down
3 changes: 1 addition & 2 deletions src/administrator/components/com_agosms/controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,7 @@ public function display($cacheable = false, $urlparams = false)
$id = $this->input->getInt('id');

// Check for edit form.
if ($view == 'agosm' && $layout == 'edit' && !$this->checkEditId('com_agosms.edit.agosm', $id))
{
if ($view == 'agosm' && $layout == 'edit' && !$this->checkEditId('com_agosms.edit.agosm', $id)) {
// Somehow the person just went to the form - we don't allow that.
$this->setError(JText::sprintf('JLIB_APPLICATION_ERROR_UNHELD_ID', $id));
$this->setMessage($this->getError(), 'error');
Expand Down
23 changes: 9 additions & 14 deletions src/administrator/components/com_agosms/controllers/agosm.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,19 +28,17 @@ class AgosmsControllerAgosm extends JControllerForm
*
* @since 1.0.40
*/
protected function allowAdd($data = array())
protected function allowAdd($data = [])
{
$categoryId = ArrayHelper::getValue($data, 'catid', $this->input->getInt('filter_category_id'), 'int');
$allow = null;

if ($categoryId)
{
if ($categoryId) {
// If the category has been passed in the URL check it.
$allow = JFactory::getUser()->authorise('core.create', $this->option . '.category.' . $categoryId);
}

if ($allow !== null)
{
if ($allow !== null) {
return $allow;
}

Expand All @@ -58,22 +56,20 @@ protected function allowAdd($data = array())
*
* @since 1.0.40
*/
protected function allowEdit($data = array(), $key = 'id')
protected function allowEdit($data = [], $key = 'id')
{
$recordId = (int) isset($data[$key]) ? $data[$key] : 0;

// Since there is no asset tracking, fallback to the component permissions.
if (!$recordId)
{
if (!$recordId) {
return parent::allowEdit($data, $key);
}

// Get the item.
$item = $this->getModel()->getItem($recordId);

// Since there is no item, return false.
if (empty($item))
{
if (empty($item)) {
return false;
}

Expand All @@ -100,7 +96,7 @@ public function batch($model = null)
JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN'));

// Set the model
$model = $this->getModel('Agosm', '', array());
$model = $this->getModel('Agosm', '', []);

// Preset the redirect
$this->setRedirect(JRoute::_('index.php?option=com_agosms&view=agosms' . $this->getRedirectToListAppend(), false));
Expand All @@ -118,12 +114,11 @@ public function batch($model = null)
*
* @since 1.0.40
*/
protected function postSaveHook(JModelLegacy $model, $validData = array())
protected function postSaveHook(JModelLegacy $model, $validData = [])
{
$task = $this->getTask();

if ($task == 'save')
{
if ($task == 'save') {
$this->setRedirect(JRoute::_('index.php?option=com_agosms&view=agosms', false));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class AgosmsControllerAgosms extends JControllerAdmin
*
* @since 1.0.40
*/
public function getModel($name = 'Agosm', $prefix = 'AgosmsModel', $config = array('ignore_request' => true))
public function getModel($name = 'Agosm', $prefix = 'AgosmsModel', $config = ['ignore_request' => true])
{
return parent::getModel($name, $prefix, $config);
}
Expand Down
42 changes: 13 additions & 29 deletions src/administrator/components/com_agosms/helpers/agosms.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,7 @@ public static function addSubmenu($vName = 'agosms')
$vName == 'categories'
);

if (JComponentHelper::isEnabled('com_fields') && JComponentHelper::getParams('com_agosms')->get('custom_fields_enable', '1'))
{
if (JComponentHelper::isEnabled('com_fields') && JComponentHelper::getParams('com_agosms')->get('custom_fields_enable', '1')) {
JHtmlSidebar::addEntry(
JText::_('JGLOBAL_FIELDS'),
'index.php?option=com_fields&context=com_agosms.agosm',
Expand Down Expand Up @@ -69,8 +68,7 @@ public static function countItems(&$items)
{
$db = JFactory::getDbo();

foreach ($items as $item)
{
foreach ($items as $item) {
$item->count_trashed = 0;
$item->count_archived = 0;
$item->count_unpublished = 0;
Expand All @@ -85,22 +83,14 @@ public static function countItems(&$items)
$db->setQuery($query);
$agosms = $db->loadObjectList();

foreach ($agosms as $agosm)
{
if ($agosm->state == 1)
{
foreach ($agosms as $agosm) {
if ($agosm->state == 1) {
$item->count_published = $agosm->count;
}
elseif ($agosm->state == 0)
{
} else if ($agosm->state == 0) {
$item->count_unpublished = $agosm->count;
}
elseif ($agosm->state == 2)
{
} else if ($agosm->state == 2) {
$item->count_archived = $agosm->count;
}
elseif ($agosm->state == -2)
{
} else if ($agosm->state == -2) {
$item->count_trashed = $agosm->count;
}
}
Expand All @@ -123,8 +113,7 @@ public static function countTagItems(&$items, $extension)
{
$db = JFactory::getDbo();

foreach ($items as $item)
{
foreach ($items as $item) {
$item->count_trashed = 0;
$item->count_archived = 0;
$item->count_unpublished = 0;
Expand All @@ -141,25 +130,20 @@ public static function countTagItems(&$items, $extension)
$db->setQuery($query);
$agosms = $db->loadObjectList();

foreach ($agosms as $agosm)
{
if ($agosm->state == 1)
{
foreach ($agosms as $agosm) {
if ($agosm->state == 1) {
$item->count_published = $agosm->count;
}

if ($agosm->state == 0)
{
if ($agosm->state == 0) {
$item->count_unpublished = $agosm->count;
}

if ($agosm->state == 2)
{
if ($agosm->state == 2) {
$item->count_archived = $agosm->count;
}

if ($agosm->state == -2)
{
if ($agosm->state == -2) {
$item->count_trashed = $agosm->count;
}
}
Expand Down
37 changes: 15 additions & 22 deletions src/administrator/components/com_agosms/helpers/associations.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class AgosmsAssociationsHelper extends JAssociationExtensionHelper
*
* @since 1.0.40
*/
protected $itemTypes = array('agosm', 'category');
protected $itemTypes = ['agosm', 'category'];

/**
* Has the extension association support
Expand Down Expand Up @@ -65,8 +65,7 @@ public function getAssociations($typeName, $id)
$context = $this->extension . '.item';
$catidField = 'catid';

if ($typeName === 'category')
{
if ($typeName === 'category') {
$context = 'com_categories.item';
$catidField = '';
}
Expand Down Expand Up @@ -97,15 +96,13 @@ public function getAssociations($typeName, $id)
*/
public function getItem($typeName, $id)
{
if (empty($id))
{
if (empty($id)) {
return null;
}

$table = null;

switch ($typeName)
{
switch ($typeName) {
case 'agosm':
$table = JTable::getInstance('Agosm', 'AgosmsTable');
break;
Expand All @@ -115,8 +112,7 @@ public function getItem($typeName, $id)
break;
}

if (empty($table))
{
if (empty($table)) {
return null;
}

Expand All @@ -137,26 +133,23 @@ public function getItem($typeName, $id)
public function getType($typeName = '')
{
$fields = $this->getFieldsTemplate();
$tables = array();
$joins = array();
$tables = [];
$joins = [];
$support = $this->getSupportTemplate();
$title = '';

if (in_array($typeName, $this->itemTypes))
{
switch ($typeName)
{
if (in_array($typeName, $this->itemTypes)) {
switch ($typeName) {
case 'agosm':

$support['state'] = true;
$support['acl'] = true;
$support['checkout'] = true;
$support['category'] = true;
$support['save2copy'] = true;

$tables = array(
$tables = [
'a' => '#__agosms'
);
];

$title = 'agosm';
break;
Expand All @@ -173,21 +166,21 @@ public function getType($typeName = '')
$support['checkout'] = true;
$support['level'] = true;

$tables = array(
$tables = [
'a' => '#__categories'
);
];

$title = 'category';
break;
}
}

return array(
return [
'fields' => $fields,
'support' => $support,
'tables' => $tables,
'joins' => $joins,
'title' => $title
);
];
}
}
19 changes: 6 additions & 13 deletions src/administrator/components/com_agosms/helpers/html/weblink.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,8 @@ public static function association($agosmid)
$associations = JLanguageAssociations::getAssociations('com_agosms', '#__agosms', 'com_agosms.item', $agosmid);

// Get the associations
if ($associations)
{
foreach ($associations as $tag => $associated)
{
if ($associations) {
foreach ($associations as $tag => $associated) {
$associations[$tag] = (int) $associated->id;
}

Expand All @@ -60,19 +58,14 @@ public static function association($agosmid)
->select('l.title as language_title');
$db->setQuery($query);

try
{
try {
$items = $db->loadObjectList('id');
}
catch (RuntimeException $e)
{
} catch (RuntimeException $e) {
throw new Exception($e->getMessage(), 500, $e);
}

if ($items)
{
foreach ($items as &$item)
{
if ($items) {
foreach ($items as &$item) {
$text = strtoupper($item->lang_sef);
$url = JRoute::_('index.php?option=com_agosms&task=agosm.edit&id=' . (int) $item->id);

Expand Down
Loading

0 comments on commit 8291a83

Please sign in to comment.