Skip to content

Commit

Permalink
Merge branch 'category' into 3.6.x
Browse files Browse the repository at this point in the history
  • Loading branch information
wilsonge committed Apr 9, 2016
2 parents f1c0128 + 0d3eda7 commit d39f4ad
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 4 deletions.
11 changes: 8 additions & 3 deletions administrator/components/com_newsfeeds/models/forms/newsfeed.xml
Expand Up @@ -30,9 +30,14 @@
JTRASHED</option>
</field>

<field name="catid" type="categoryedit" extension="com_newsfeeds"
label="JCATEGORY" description="COM_NEWSFEEDS_FIELD_CATEGORY_DESC"
required="true"
<field name="catid"
type="categoryedit"
extension="com_newsfeeds"
label="JCATEGORY"
description="COM_NEWSFEEDS_FIELD_CATEGORY_DESC"
required="true"
allowAdd="true"
default=""
>
</field>

Expand Down
25 changes: 25 additions & 0 deletions administrator/components/com_newsfeeds/models/newsfeed.php
Expand Up @@ -302,6 +302,31 @@ public function save($data)
{
$input = JFactory::getApplication()->input;

JLoader::register('CategoriesHelper', JPATH_ADMINISTRATOR . '/components/com_categories/helpers/categories.php');

// Cast catid to integer for comparison
$catid = (int) $data['catid'];

// Check if New Category exists
if ($catid > 0)
{
$catid = CategoriesHelper::validateCategoryId($data['catid'], 'com_newsfeeds');
}

// Save New Category
if ($catid == 0)
{
$table = array();
$table['title'] = $data['catid'];
$table['parent_id'] = 1;
$table['extension'] = 'com_newsfeeds';
$table['language'] = $data['language'];
$table['published'] = 1;

// Create new category and get catid back
$data['catid'] = CategoriesHelper::createCategory($table);
}

// Alter the name for save as copy
if ($input->get('task') == 'save2copy')
{
Expand Down
Expand Up @@ -14,7 +14,7 @@

JHtml::_('behavior.formvalidator');
JHtml::_('behavior.keepalive');
JHtml::_('formbehavior.chosen', 'select');
JHtml::_('formbehavior.chosen', 'select', null, array('disable_search_threshold' => 0 ));

$app = JFactory::getApplication();
$input = $app->input;
Expand Down

0 comments on commit d39f4ad

Please sign in to comment.