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

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
martynassateika committed Apr 4, 2017
2 parents 0e3c906 + 3a99de6 commit 0bd9fef
Show file tree
Hide file tree
Showing 23 changed files with 518 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.idea
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# FUEL CMS Translatable Module

The Translatable Module is a module for the FUEL CMS content management system that allows setting up translatable fields for existing models.

## Attributions
* The module is built for use with [FUEL CMS](https://github.com/daylightstudio/FUEL-CMS), a framework built by David McReynolds, licenced under [Apache 2](http://www.apache.org/licenses/LICENSE-2.0.html).
* The module uses icons from several icon sets by [FamFamFam](http://www.famfamfam.com/):
* [FamFamFam Silk Icon Set](http://www.famfamfam.com/lab/icons/silk/) (licenced under a [Creative Commons Attribution 2.5 licence](http://creativecommons.org/licenses/by/2.5/))
* [Flag Icons Set](http://www.famfamfam.com/lab/icons/flags/).

## Licence
The Translatable module for FUEL CMS is licenced under [Apache 2](http://www.apache.org/licenses/LICENSE-2.0).
5 changes: 5 additions & 0 deletions assets/css/translatable.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.ico_translatable_item { background-image: url(../images/ico_translatable_item.png); }
.ico_translatable_item_translation {
background-image: url(../images/ico_translatable_item_translation.png);
background-position-y: 4px;
}
Binary file added assets/images/ico_cog.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/ico_translatable_item.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/images/ico_translatable_item_translation.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 15 additions & 0 deletions assets/js/TranslatableController.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// jqx.load('plugin', 'date');

TranslatableController = jqx.createController(fuel.controller.BaseFuelController, {

init: function(initObj){
this._super(initObj);
},

add_edit : function(){
var _this = this;
// do this first so that the fillin is in the checksaved value
//fuel.controller.BaseFuelController.prototype.add_edit.call(this, false);
this._super();
}
});
17 changes: 17 additions & 0 deletions config/translatable.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php
/*
|--------------------------------------------------------------------------
| FUEL NAVIGATION: An array of navigation items for the left menu
|--------------------------------------------------------------------------
*/
$config['nav']['translatable'] = array(
'translatable_item' => 'Items',
'translatable_item_translation' => 'Item translations',
);


/*
|--------------------------------------------------------------------------
| ADDITIONAL SETTINGS:
|--------------------------------------------------------------------------
*/
4 changes: 4 additions & 0 deletions config/translatable_constants.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?php
define('TRANSLATABLE_VERSION', '0.1');
define('TRANSLATABLE_FOLDER', 'translatable');
define('TRANSLATABLE_PATH', MODULES_PATH.TRANSLATABLE_FOLDER.'/');
11 changes: 11 additions & 0 deletions config/translatable_fuel_modules.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php

$config['modules']['translatable_item'] = array(
'preview_path' => '',
'model_location' => 'translatable_item',
);

$config['modules']['translatable_item_translation'] = array(
'preview_path' => '',
'model_location' => 'translatable_item_translation',
);
6 changes: 6 additions & 0 deletions config/translatable_routes.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?php
$route[FUEL_ROUTE.'translatable_item'] = FUEL_FOLDER.'/module';
$route[FUEL_ROUTE.'translatable_item/(.*)'] = FUEL_FOLDER.'/module/$1';

$route[FUEL_ROUTE.'translatable_item_translation'] = FUEL_FOLDER.'/module';
$route[FUEL_ROUTE.'translatable_item_translation/(.*)'] = FUEL_FOLDER.'/module/$1';
21 changes: 21 additions & 0 deletions controllers/Translatable_module.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php
require_once(FUEL_PATH.'/libraries/Fuel_base_controller.php');

class Translatable_module extends Fuel_base_controller {

public $nav_selected = 'translatable';

function __construct()
{
parent::__construct();
}

function index()
{
$vars['page_title'] = $this->fuel->admin->page_title(array(lang('module_translatable')), FALSE);
$crumbs = array('tools' => lang('section_tools'), lang('module_translatable'));

$this->fuel->admin->set_titlebar($crumbs, 'ico_translatable');
$this->fuel->admin->render('_admin/translatable', $vars, '', TRANSLATABLE_FOLDER);
}
}
31 changes: 31 additions & 0 deletions helpers/translatable_helper.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php
/**
* FUEL CMS
* http://www.getfuelcms.com
*
* An open source Content Management System based on the
* Codeigniter framework (http://codeigniter.com)
*
* @package FUEL CMS
* @author David McReynolds @ Daylight Studio
* @copyright Copyright (c) 2017, Daylight Studio LLC.
* @license http://docs.getfuelcms.com/general/license
* @link http://www.getfuelcms.com
*/

// ------------------------------------------------------------------------

/**
* Translatable Helper
*
* Contains functions for the Translatable module
*
* @package User Guide
* @subpackage Helpers
* @category Helpers
*/

// --------------------------------------------------------------------


// put your helper functions here
26 changes: 26 additions & 0 deletions install/fuel_translatable_install.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET NAMES utf8 */;
/*!50503 SET NAMES utf8mb4 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;

CREATE TABLE IF NOT EXISTS `translatable_item` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`title` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
`date_added` datetime DEFAULT NULL,
`last_modified` timestamp NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

CREATE TABLE IF NOT EXISTS `translatable_item_translation` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`translatable_item_id` int(10) unsigned NOT NULL,
`text` longtext COLLATE utf8_unicode_ci NOT NULL,
`language` varchar(50) COLLATE utf8_unicode_ci NOT NULL,
PRIMARY KEY (`id`),
UNIQUE KEY `translatable_item_id_language` (`translatable_item_id`,`language`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;

/*!40101 SET SQL_MODE=IFNULL(@OLD_SQL_MODE, '') */;
/*!40014 SET FOREIGN_KEY_CHECKS=IF(@OLD_FOREIGN_KEY_CHECKS IS NULL, 1, @OLD_FOREIGN_KEY_CHECKS) */;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
10 changes: 10 additions & 0 deletions install/fuel_translatable_permissions_install.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
INSERT INTO `fuel_permissions` (`description`, `name`, `active`)
VALUES
('Translatable items', 'translatable_item', 'yes'),
('Translatable items: Create', 'translatable_item/create', 'yes'),
('Translatable items: Delete', 'translatable_item/delete', 'yes'),
('Translatable items: Edit', 'translatable_item/edit', 'yes'),
('Translatable item translations', 'translatable_item_translation', 'yes'),
('Translatable item translations: Create', 'translatable_item_translation/create', 'yes'),
('Translatable item translations: Delete', 'translatable_item_translation/delete', 'yes'),
('Translatable item translations: Edit', 'translatable_item_translation/edit', 'yes');
2 changes: 2 additions & 0 deletions install/fuel_translatable_uninstall.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
DROP TABLE `translatable_item`;
DROP TABLE `translatable_item_translation`;
16 changes: 16 additions & 0 deletions install/install.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php
$config['name'] = 'Translatable Module';
$config['version'] = TRANSLATABLE_VERSION;
$config['author'] = 'Martynas Šateika';
$config['company'] = '';
$config['license'] = 'Apache 2';
$config['copyright'] = '2017';
$config['author_url'] = 'https://www.martynassateika.lt';
$config['description'] = 'The Translatable module allows setting up translatable fields in your models.';
$config['compatibility'] = '1.0';
$config['instructions'] = '';
$config['permissions'] = 'translatable';
$config['migration_version'] = 0;
$config['install_sql'] = 'fuel_translatable_install.sql';
$config['uninstall_sql'] = 'fuel_translatable_uninstall.sql';
$config['repo'] = '';
15 changes: 15 additions & 0 deletions language/english/translatable_lang.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php
$lang['module_translatable'] = 'Translatable';

/**
* Translatable item model
*/
$lang['translation_item_model_notification_save_before_adding_translations'] = 'Save the item before adding translations.';
$lang['translation_item_model_translations'] = 'Translations';
$lang['translation_item_model_add_translation'] = 'Add translation';

/**
* Translatable item translation model
*/
$lang['translatable_item_translation_model_exists_for_language'] = 'There already exists a translation for this language.';
$lang['translatable_item_translation_model_create_via_translatable'] = 'Translations can only be added by editing translatable items.';
61 changes: 61 additions & 0 deletions libraries/Fuel_translatable.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
/**
* FUEL CMS
* http://www.getfuelcms.com
*
* An open source Content Management System based on the
* Codeigniter framework (http://codeigniter.com)
*/

// ------------------------------------------------------------------------

/**
* Fuel Translatable object
*
* @package FUEL CMS
* @subpackage Libraries
* @category Libraries
*/

// ------------------------------------------------------------------------

class Fuel_translatable extends Fuel_advanced_module {

public $name = "translatable"; // the folder name of the module

/**
* Constructor - Sets preferences
*
* The constructor can be passed an array of config values
*/
public function __construct($params = array())
{
parent::__construct();
$this->initialize($params);
}

// --------------------------------------------------------------------

/**
* Initialize the backup object
*
* Accepts an associative array as input, containing preferences.
* Also will set the values in the config as properties of this object
*
* @access public
* @param array config preferences
* @return void
*/
public function initialize($params = array())
{
parent::initialize($params);
$this->set_params($this->_config);
}

// --------------------------------------------------------------------

/**
* Add your custom methods for this advanced module below.
* You will be able to access it via $this->fuel->translatable->my_method()
*/
}
Loading

0 comments on commit 0bd9fef

Please sign in to comment.