Skip to content

Commit

Permalink
Merge pull request #455 from joomdonation/master
Browse files Browse the repository at this point in the history
CS
  • Loading branch information
joomdonation authored Aug 29, 2021
2 parents 5ae2866 + 06c13b6 commit 17fb026
Show file tree
Hide file tree
Showing 12 changed files with 42 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -146,14 +146,17 @@ public static function countTagItems(&$items, $extension)
{
$item->count_published = $weblink->count;
}

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

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

if ($weblink->state == -2)
{
$item->count_trashed = $weblink->count;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ protected function getInput()
function jSelectWeblink_" . $this->id . "(id, title, catid, object, url, language) {
window.processModalSelect('Weblink', '" . $this->id . "', id, title, catid, object, url, language);
}
");
"
);
$scriptSelect[$this->id] = true;
}
}
Expand Down Expand Up @@ -94,6 +95,7 @@ function jSelectWeblink_" . $this->id . "(id, title, catid, object, url, languag
->from($db->quoteName('#__weblinks'))
->where($db->quoteName('id') . ' = ' . (int) $value);
$db->setQuery($query);

try
{
$title = $db->loadResult();
Expand All @@ -103,6 +105,7 @@ function jSelectWeblink_" . $this->id . "(id, title, catid, object, url, languag
JError::raiseWarning(500, $e->getMessage());
}
}

$title = empty($title) ? JText::_('COM_WEBLINKS_SELECT_A_WEBLINK') : htmlspecialchars($title, ENT_QUOTES, 'UTF-8');

// The current weblink display field.
Expand All @@ -122,6 +125,7 @@ function jSelectWeblink_" . $this->id . "(id, title, catid, object, url, languag
. '<span class="icon-file" aria-hidden="true"></span> ' . JText::_('JSELECT')
. '</a>';
}

// New weblink button
if ($allowNew)
{
Expand All @@ -135,6 +139,7 @@ function jSelectWeblink_" . $this->id . "(id, title, catid, object, url, languag
. '<span class="icon-new" aria-hidden="true"></span> ' . JText::_('JACTION_CREATE')
. '</a>';
}

// Edit weblink button
if ($allowEdit)
{
Expand All @@ -148,6 +153,7 @@ function jSelectWeblink_" . $this->id . "(id, title, catid, object, url, languag
. '<span class="icon-edit" aria-hidden="true"></span> ' . JText::_('JACTION_EDIT')
. '</a>';
}

// Clear weblink button
if ($allowClear)
{
Expand All @@ -159,6 +165,7 @@ function jSelectWeblink_" . $this->id . "(id, title, catid, object, url, languag
. '<span class="icon-remove" aria-hidden="true"></span>' . JText::_('JCLEAR')
. '</a>';
}

$html .= '</span>';

// Select weblink modal
Expand Down Expand Up @@ -236,10 +243,12 @@ function jSelectWeblink_" . $this->id . "(id, title, catid, object, url, languag
)
);
}

// Note: class='required' for client side validation.
$class = $this->required ? ' class="required modal-value"' : '';
$html .= '<input type="hidden" id="' . $this->id . '_id" ' . $class . ' data-required="' . (int) $this->required . '" name="' . $this->name
. '" data-text="' . htmlspecialchars(JText::_('COM_WEBLINKS_SELECT_A_WEBLINK', true), ENT_COMPAT, 'UTF-8') . '" value="' . $value . '" />';

return $html;
}

Expand Down
18 changes: 12 additions & 6 deletions src/administrator/components/com_weblinks/script.php
Original file line number Diff line number Diff line change
Expand Up @@ -153,15 +153,17 @@ private function insertMissingUcmRecords()
. $db->quote('com_weblinks.weblink') . ', '
. $db->quote(
'{"special":{"dbtable":"#__weblinks","key":"id","type":"Weblink","prefix":"WeblinksTable","config":"array()"},
"common":{"dbtable":"#__ucm_content","key":"ucm_id","type":"Corecontent","prefix":"JTable","config":"array()"}}') . ', '
"common":{"dbtable":"#__ucm_content","key":"ucm_id","type":"Corecontent","prefix":"JTable","config":"array()"}}'
) . ', '
. $db->quote('') . ', '
. $db->quote(
'{"common":{"core_content_item_id":"id","core_title":"title","core_state":"state","core_alias":"alias",
"core_created_time":"created","core_modified_time":"modified","core_body":"description", "core_hits":"hits",
"core_publish_up":"publish_up","core_publish_down":"publish_down","core_access":"access", "core_params":"params",
"core_featured":"featured", "core_metadata":"metadata", "core_language":"language", "core_images":"images", "core_urls":"url",
"core_version":"version", "core_ordering":"ordering", "core_metakey":"metakey", "core_metadesc":"metadesc",
"core_catid":"catid", "core_xreference":"xreference", "asset_id":"null"}, "special":{}}') . ', '
"core_catid":"catid", "core_xreference":"xreference", "asset_id":"null"}, "special":{}}'
) . ', '
. $db->quote('WeblinksHelperRoute::getWeblinkRoute') . ', '
. $db->quote(
'{"formFile":"administrator\\/components\\/com_weblinks\\/models\\/forms\\/weblink.xml",
Expand All @@ -170,7 +172,8 @@ private function insertMissingUcmRecords()
"ordering"], "displayLookup":[{"sourceColumn":"catid","targetTable":"#__categories","targetColumn":"id","displayColumn":"title"},
{"sourceColumn":"created_by","targetTable":"#__users","targetColumn":"id","displayColumn":"name"},
{"sourceColumn":"access","targetTable":"#__viewlevels","targetColumn":"id","displayColumn":"title"},
{"sourceColumn":"modified_by","targetTable":"#__users","targetColumn":"id","displayColumn":"name"} ]}')
{"sourceColumn":"modified_by","targetTable":"#__users","targetColumn":"id","displayColumn":"name"} ]}'
)
);

$db->setQuery($query);
Expand All @@ -189,7 +192,8 @@ private function insertMissingUcmRecords()
. $db->quote('com_weblinks.category') . ', '
. $db->quote('
{"special":{"dbtable":"#__categories","key":"id","type":"Category","prefix":"JTable","config":"array()"},
"common":{"dbtable":"#__ucm_content","key":"ucm_id","type":"Corecontent","prefix":"JTable","config":"array()"}}') . ', '
"common":{"dbtable":"#__ucm_content","key":"ucm_id","type":"Corecontent","prefix":"JTable","config":"array()"}}'
) . ', '
. $db->quote('') . ', '
. $db->quote('
{"common":{"core_content_item_id":"id","core_title":"title","core_state":"published","core_alias":"alias",
Expand All @@ -198,7 +202,8 @@ private function insertMissingUcmRecords()
"core_params":"params", "core_featured":"null", "core_metadata":"metadata", "core_language":"language",
"core_images":"null", "core_urls":"null", "core_version":"version", "core_ordering":"null", "core_metakey":"metakey",
"core_metadesc":"metadesc", "core_catid":"parent_id", "core_xreference":"null", "asset_id":"asset_id"},
"special":{"parent_id":"parent_id","lft":"lft","rgt":"rgt","level":"level","path":"path","extension":"extension","note":"note"}}') . ', '
"special":{"parent_id":"parent_id","lft":"lft","rgt":"rgt","level":"level","path":"path","extension":"extension","note":"note"}}'
) . ', '
. $db->quote('WeblinksHelperRoute::getCategoryRoute') . ', '
. $db->quote('
{"formFile":"administrator\\/components\\/com_categories\\/models\\/forms\\/category.xml",
Expand All @@ -209,7 +214,8 @@ private function insertMissingUcmRecords()
"displayColumn":"name"},{"sourceColumn":"access","targetTable":"#__viewlevels","targetColumn":"id",
"displayColumn":"title"},{"sourceColumn":"modified_user_id","targetTable":"#__users","targetColumn":"id",
"displayColumn":"name"},{"sourceColumn":"parent_id","targetTable":"#__categories","targetColumn":"id",
"displayColumn":"title"}]}')
"displayColumn":"title"}]}'
)
);

$db->setQuery($query);
Expand Down
3 changes: 2 additions & 1 deletion src/administrator/components/com_weblinks/tables/weblink.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public function __construct(&$db)
// Set the published column alias
$this->setColumnAlias('published', 'state');

if (version_compare(JVERSION, '4.0', '<' ) == 1)
if (version_compare(JVERSION, '4.0', '<') == 1)
{
JTableObserverTags::createObserver($this, array('typeAlias' => 'com_weblinks.weblink'));
JTableObserverContenthistory::createObserver($this, array('typeAlias' => 'com_weblinks.weblink'));
Expand Down Expand Up @@ -130,6 +130,7 @@ public function check()
if (trim($this->title) == '')
{
$this->setError(JText::_('COM_WEBLINKS_ERR_TABLES_TITLE'));

return false;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ public function display($tpl = null)
if (count($errors = $this->get('Errors')))
{
JError::raiseError(500, implode("\n", $errors));

return false;
}

Expand Down
2 changes: 1 addition & 1 deletion src/components/com_weblinks/models/category.php
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ protected function getListQuery()
$search = $db->quote('%' . $db->escape($search, true) . '%');
$query->where('(a.title LIKE ' . $search . ')');
}

// If grouping by subcategory, add the subcategory list ordering clause.
if ($this->getState('category.group', 0))
{
Expand Down
4 changes: 2 additions & 2 deletions src/components/com_weblinks/router.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public function build(&$query)
}

// Are we dealing with an weblink that is attached to a menu item?
if (isset($query['view']) && ($mView == $query['view']) and (isset($query['id'])) and ($mId == (int) $query['id']))
if (isset($query['view']) && ($mView == $query['view']) && isset($query['id']) && ($mId == (int) $query['id']))
{
unset($query['view']);
unset($query['catid']);
Expand All @@ -74,7 +74,7 @@ public function build(&$query)
return $segments;
}

if (isset($view) and ($view == 'category' or $view == 'weblink'))
if (isset($view) && ($view == 'category' || $view == 'weblink'))
{
if ($mId != (int) $query['id'] || $mView != $view)
{
Expand Down
1 change: 1 addition & 0 deletions src/components/com_weblinks/views/categories/view.html.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ public function display($tpl = null)
if (count($errors = $this->get('Errors')))
{
JError::raiseWarning(500, implode("\n", $errors));

return false;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@
<?php echo JHtml::_('content.prepare', $child->description, '', 'com_weblinks.category'); ?>
</div>
<?php endif; ?>
<?php endif; ?>
<?php endif; ?>

<?php if ($this->params->get('show_cat_num_links') == 1) :?>
<?php if ($this->params->get('show_cat_num_links') == 1) :?>
<dl class="weblink-count"><dt>
<?php echo JText::_('COM_WEBLINKS_NUM'); ?></dt>
<dd><?php echo $child->numitems; ?></dd>
Expand Down
2 changes: 1 addition & 1 deletion src/components/com_weblinks/views/category/view.html.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public function display($tpl = null)

$temp = new JRegistry;
$temp->loadString($item->params);
$item->params = clone($this->params);
$item->params = clone $this->params;
$item->params->merge($temp);
}

Expand Down
2 changes: 1 addition & 1 deletion src/plugins/finder/weblinks/weblinks.php
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ public function onFinderAfterDelete($context, $table)
public function onFinderAfterSave($context, $row, $isNew)
{
// We only want to handle web links here. We need to handle front end and back end editing.
if ($context == 'com_weblinks.weblink' || $context == 'com_weblinks.form' )
if ($context == 'com_weblinks.weblink' || $context == 'com_weblinks.form')
{
// Check if the access levels are different.
if (!$isNew && $this->old_access != $row->access)
Expand Down
12 changes: 6 additions & 6 deletions src/plugins/search/weblinks/weblinks.php
Original file line number Diff line number Diff line change
Expand Up @@ -175,12 +175,12 @@ public function onContentSearch($text, $phrase = '', $ordering = '', $areas = nu
$case_when1 .= $c_id . ' END as catslug';

$query->select('a.title AS title, a.created AS created, a.url, a.description AS text, ' . $case_when . "," . $case_when1)
->select($query->concatenate(array($db->quote($searchWeblinks), 'c.title'), " / ") . ' AS section')
->select('\'1\' AS browsernav')
->from('#__weblinks AS a')
->join('INNER', '#__categories as c ON c.id = a.catid')
->where('(' . $where . ') AND a.state IN (' . implode(',', $state) . ') AND c.published = 1 AND c.access IN (' . $groups . ')')
->order($order);
->select($query->concatenate(array($db->quote($searchWeblinks), 'c.title'), " / ") . ' AS section')
->select('\'1\' AS browsernav')
->from('#__weblinks AS a')
->join('INNER', '#__categories as c ON c.id = a.catid')
->where('(' . $where . ') AND a.state IN (' . implode(',', $state) . ') AND c.published = 1 AND c.access IN (' . $groups . ')')
->order($order);

// Filter by language.
if (JFactory::getApplication()->isClient('site') && JLanguageMultilang::isEnabled())
Expand Down

0 comments on commit 17fb026

Please sign in to comment.