Progrmatically insert the Uncategorised category
This commit is contained in:
parent
0a08922485
commit
524b2d38bb
|
@ -15,6 +15,7 @@ COM_WEBLINKS_CATEGORY_VIEW_DEFAULT_TITLE="List Web Links in a Category"
|
|||
COM_WEBLINKS_CATEGORIES_VIEW_DEFAULT_DESC="Show all the web link categories within a category."
|
||||
COM_WEBLINKS_CATEGORIES_VIEW_DEFAULT_OPTION="Default"
|
||||
COM_WEBLINKS_CATEGORIES_VIEW_DEFAULT_TITLE="List All Web Link Categories"
|
||||
COM_WEBLINKS_ERROR_INSTALL_CATEGORY="Could not add default 'Uncategorised' category due to an error: %s"
|
||||
COM_WEBLINKS_FORM_VIEW_DEFAULT_DESC="Display a form to submit a web link in the frontend."
|
||||
COM_WEBLINKS_FORM_VIEW_DEFAULT_OPTION="Default"
|
||||
COM_WEBLINKS_FORM_VIEW_DEFAULT_TITLE="Submit a Web Link"
|
||||
|
|
|
@ -0,0 +1,71 @@
|
|||
<?php
|
||||
/**
|
||||
* @package Joomla.Administrator
|
||||
* @subpackage com_weblinks
|
||||
*
|
||||
* @copyright Copyright (C) 2005 - 2014 Open Source Matters, Inc. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
/**
|
||||
* Installation class to perform additional changes during install/uninstall/update
|
||||
*
|
||||
* @package Joomla.Administrator
|
||||
* @subpackage com_weblinks
|
||||
* @since 3.4
|
||||
*/
|
||||
class Com_WeblinksInstallerScript
|
||||
{
|
||||
/**
|
||||
* Function to perform changes during install
|
||||
*
|
||||
* @param JInstallerComponent $parent The class calling this method
|
||||
*
|
||||
* @return void
|
||||
*
|
||||
* @since 3.4
|
||||
*/
|
||||
public function install($parent)
|
||||
{
|
||||
// Initialize a new category
|
||||
/** @type JTableCategory $category */
|
||||
$category = JTable::getInstance('Category');
|
||||
|
||||
// Check if the Uncategorised category exists before adding it
|
||||
if (!$category->load(array('extension' => 'com_weblinks', 'title' => 'Uncategorised')))
|
||||
{
|
||||
$category->extension = 'com_weblinks';
|
||||
$category->title = 'Uncategorised';
|
||||
$category->description = '';
|
||||
$category->published = 1;
|
||||
$category->access = 1;
|
||||
$category->params = '{"category_layout":"","image":""}';
|
||||
$category->metadata = '{"author":"","robots":""}';
|
||||
$category->language = '*';
|
||||
|
||||
// Set the location in the tree
|
||||
$category->setLocation(1, 'last-child');
|
||||
|
||||
// Check to make sure our data is valid
|
||||
if (!$category->check())
|
||||
{
|
||||
JFactory::getApplication()->enqueueMessage(JText::sprintf('COM_WEBLINKS_ERROR_INSTALL_CATEGORY', $category->getError()));
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// Now store the category
|
||||
if (!$category->store(true))
|
||||
{
|
||||
JFactory::getApplication()->enqueueMessage(JText::sprintf('COM_WEBLINKS_ERROR_INSTALL_CATEGORY', $category->getError()));
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// Build the path for our category
|
||||
$category->rebuildPath($category->id);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -3,13 +3,13 @@
|
|||
<name>com_weblinks</name>
|
||||
<author>Joomla! Project</author>
|
||||
<creationDate>April 2006</creationDate>
|
||||
<copyright>(C) 2005 - 2014 Open Source Matters. All rights reserved.
|
||||
</copyright>
|
||||
<copyright>(C) 2005 - 2014 Open Source Matters. All rights reserved.</copyright>
|
||||
<license>GNU General Public License version 2 or later; see LICENSE.txt</license>
|
||||
<authorEmail>admin@joomla.org</authorEmail>
|
||||
<authorUrl>www.joomla.org</authorUrl>
|
||||
<version>3.0.0</version>
|
||||
<description>COM_WEBLINKS_XML_DESCRIPTION</description>
|
||||
<scriptfile>script.php</scriptfile>
|
||||
|
||||
<install>
|
||||
<sql>
|
||||
|
@ -34,7 +34,6 @@
|
|||
</update>
|
||||
|
||||
<files folder="site">
|
||||
<filename>index.html</filename>
|
||||
<filename>weblinks.php</filename>
|
||||
<filename>controller.php</filename>
|
||||
<filename>router.php</filename>
|
||||
|
@ -63,7 +62,6 @@
|
|||
<filename>access.xml</filename>
|
||||
<filename>config.xml</filename>
|
||||
<filename>controller.php</filename>
|
||||
<filename>index.html</filename>
|
||||
<filename>weblinks.php</filename>
|
||||
<folder>controllers</folder>
|
||||
<folder>helpers</folder>
|
||||
|
|
Loading…
Reference in New Issue