Skip to content

Commit

Permalink
add support to transtale widgets and fixes some bugs on widget module
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcosCoelho committed Apr 15, 2011
1 parent c432188 commit e49799f
Show file tree
Hide file tree
Showing 17 changed files with 284 additions and 127 deletions.
2 changes: 1 addition & 1 deletion system/pyrocms/config/migrations.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
|
*/

$config['migrations_version'] = 19;
$config['migrations_version'] = 20;


/*
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php defined('BASEPATH') OR exit('No direct script access allowed');

class Migration_Alter_widget_fields_for_translation extends Migration {

function up()
{
$this->dbforge->modify_column('widgets', array(
'title' => array(
'type' => 'TEXT',
'null' => FALSE
)
));
}

function down()
{
$this->dbforge->modify_column('widgets', array(
'title' => array(
'type' => 'VARCHAR',
'constraint' => '100',
'null' => FALSE
)
));
}
}
4 changes: 2 additions & 2 deletions system/pyrocms/modules/widgets/controllers/admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public function index()
{
// Firstly, install any uninstalled widgets
$uninstalled_widgets = $this->widgets->list_uninstalled_widgets();
foreach($uninstalled_widgets as $widget)
foreach ($uninstalled_widgets as $widget)
{
$this->widgets->add_widget((array)$widget);
}
Expand All @@ -45,7 +45,7 @@ public function index()
$this->data->widget_areas = $this->widgets->list_areas();

// Go through all widget areas
foreach($this->data->widget_areas as &$area)
foreach ($this->data->widget_areas as &$area)
{
$area->widgets = $this->widgets->list_area_instances($area->slug);
}
Expand Down
25 changes: 19 additions & 6 deletions system/pyrocms/modules/widgets/controllers/ajax.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,18 +85,31 @@ public function delete_widget_area()
*/
public function add_widget_instance_form()
{
if ( ! ($this->input->post('widget_slug') OR $this->input->post('area_slug')))
if ( ! ($this->input->post('widget_slug') && $this->input->post('area_slug')))
{
return;
return print( json_encode((object) array(
'status' => 'error',
'message' => ''
)) );
}

$widget = $this->widgets->get_widget($this->input->post('widget_slug'));
$widget_area = $this->widgets->get_area($this->input->post('area_slug'));
$this->load->view('admin/ajax/instance_form', array(

$html = $this->load->view('admin/ajax/instance_form', array(
'widget' => $widget,
'widget_area' => $widget_area
));
), TRUE);

if ($this->is_ajax())
{
return print( json_encode((object) array(
'status' => 'success',
'html' => $html
)) );
}

echo $html;
}

/**
Expand All @@ -115,7 +128,7 @@ public function edit_widget_instance_form()

$widget_areas = $this->widgets->list_areas();
$widget_areas = array_for_select($widget_areas, 'id', 'title');

$this->load->view('admin/ajax/instance_form', array(
'widget' => $widget,
'widget_area' => $widget_area,
Expand Down
53 changes: 45 additions & 8 deletions system/pyrocms/modules/widgets/css/widgets.css
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,18 @@
#available-widgets h3,
.ui-draggable-dragging h3 {
font-size: 14px;
width: 150px;
padding-right: 25px;
width: 180px;
padding-right: 20px;
height: 100%;
text-align: right;
float: left;
margin-bottom: 0;
}
#available-widgets p,
.ui-draggable-dragging p {
margin-bottom: 0;
line-height: 1.5;
margin-left: 200px; /* h3 size */
}
#available-widgets li:hover {
background-color: #e6e6e6;
Expand Down Expand Up @@ -137,14 +139,22 @@
margin: 15px 0 10px 0;
padding-left: 5px;
color: #999;
cursor: auto;
}

.no-sortable,
.no-sortable li,
.no-sortable header {
cursor: auto !important;
}
.widget-instance ol {
margin-bottom: 0;
}
.widget-instance textarea.uniform {
.widget-list textarea.uniform {
width: 97% !important;
resize: none;
}
.widget-list textarea.inline {
width: 60% !important;
resize: none;
}

.widget-instance form.crud label{
Expand Down Expand Up @@ -195,9 +205,6 @@
margin-top: 7px;
}

.widget-list textarea {
width: 98%;
}

.widget-area-header {
background-color: #f2f2f2;
Expand All @@ -207,6 +214,7 @@
}
.widget-area-header h3 {
font-size: 16px;
display: inline-block;
}
.widget-area-header a.button {
font-size: 100%;
Expand All @@ -228,10 +236,21 @@
cursor: auto;
padding: 0 10px;
}
.widget-list fieldset ol {
padding: 0;
}
.widget-list fieldset li li {
padding-left: 0;
padding-rigth: 0;
}
.widget-list ol li {
margin: 0 0 10px;
cursor: move;
}
.widget-list ol li label {
text-align: right;
color: #666;
}
li.empty-drop-item {
border: 2px dashed #666;
height: 24px;
Expand All @@ -245,4 +264,22 @@ p.tag {
font-family: monospace;
text-align: center;
color: #999;
}
.box-container header h3 {
font-size: 14px;
padding: 6px 0;
}
.box-container h3 {
font-size: 14px;
}
.box-container fieldset h4 {
font-size: 13px;
font-style: italic;
margin: 10px 0 12px;
text-shadow: none;
background: #eee;
padding: 4px 8px;
-webkit-border-radius: 5px;
-moz-border-radius: 5px;
border-radius: 5px;
}
2 changes: 1 addition & 1 deletion system/pyrocms/modules/widgets/details.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public function install()
CREATE TABLE `widgets` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`slug` varchar(100) COLLATE utf8_unicode_ci NOT NULL DEFAULT '',
`title` varchar(100) COLLATE utf8_unicode_ci NOT NULL DEFAULT '',
`title` text COLLATE utf8_unicode_ci NOT NULL,
`description` text COLLATE utf8_unicode_ci NOT NULL,
`author` varchar(100) COLLATE utf8_unicode_ci NOT NULL DEFAULT '',
`website` varchar(255) COLLATE utf8_unicode_ci NOT NULL DEFAULT '',
Expand Down
25 changes: 15 additions & 10 deletions system/pyrocms/modules/widgets/js/widgets.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@

// Widget Areas Accordion
$(".accordion").accordion({
collapsible: true,
header: 'header',
autoHeight: true,
clearStyle: true
collapsible : true,
header : 'header',
autoHeight : true,
clearStyle : true
});

//Init Sortable
Expand Down Expand Up @@ -98,7 +98,7 @@
// Re-bind the droppable areas
pyro.widgets.set_droppable();

});
}, 'html');
});

$('#edit-area-box form').live('submit', function(e){
Expand Down Expand Up @@ -284,7 +284,9 @@
$('.widget-list .empty-drop-item').css('display', 'none');

pyro.widgets.edit_instance.css('display', 'block').slideDown(function(){
$('#widget-areas .accordion').accordion('resize');
setTimeout(function(){
$('#widget-areas .accordion').accordion('resize');
}, 10);
});
},

Expand Down Expand Up @@ -347,11 +349,14 @@
var area_slug = $(this).parent().attr('id').replace(/^area-/, ''),
widget_slug = ui.draggable.attr('id').replace(/^widget-/, '');

$.post(BASE_URI + 'index.php/widgets/ajax/add_widget_instance_form', { area_slug: area_slug, widget_slug: widget_slug}, function(html){
$('form', pyro.widgets.add_instance).html(html);
$.post(BASE_URI + 'index.php/widgets/ajax/add_widget_instance_form', { area_slug: area_slug, widget_slug: widget_slug}, function(data){
if (data.status == 'success')
{
$('form', pyro.widgets.add_instance).html(data.html);

pyro.widgets.show_add_instance(area_slug);
});
pyro.widgets.show_add_instance(area_slug);
}
}, 'json');
}
});
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

// sidebar
$lang['widgets.available_title'] = 'Widgets disponíveis';
$lang['widgets.widget_area_wrapper'] = 'Áreas disponíveis';
$lang['widgets.instructions'] = 'Arraste para instalar o widget';

// Widgets
$lang['widgets.widget'] = 'Widget';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php
<?php defined('BASEPATH') OR exit('No direct script access allowed');

// sidebar
$lang['widgets.available_title'] = 'Dostupné widgety';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php
<?php defined('BASEPATH') OR exit('No direct script access allowed');

// sidebar
$lang['widgets.available_title'] = 'Beschikbare widgets';
Expand All @@ -14,7 +14,7 @@
// Widget area titles
$lang['widgets.add_area'] = 'Voeg een widgetgebied toe';
$lang['widgets.delete_area'] = 'Verwijder gebied';
$lang['widgets.edit_area'] = 'Edit area';#translate
$lang['widgets.edit_area'] = 'Edit area';#translate

// Widget area field names
$lang['widgets.widget_area'] = 'Gebied';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php
<?php defined('BASEPATH') OR exit('No direct script access allowed');

// sidebar
$lang['widgets.available_title'] = 'Available widgets';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

// sidebar
$lang['widgets.available_title'] = 'Widgets disponibles';
$lang['widgets.widget_area_wrapper'] = 'Available Areas'; #translate
$lang['widgets.instructions'] = 'Glisser-déposer pour installer le widget';

// Widgets
Expand Down
Loading

0 comments on commit e49799f

Please sign in to comment.