Version Notes
Using this extension you can easily add news with start and end date and upload a image on each news. For news content you can easily enter or modify your text uisng wysiwyg editor.
Features:
1. No core file changed.
2. Small useful extension for merchants.
3. Works on Magento 1.6 and above.
Download this release
Release Info
Developer | Greenpackages |
Extension | Greenpackages_News_Blog |
Version | 0.1.0 |
Comparing to | |
See all releases |
Version 0.1.0
- app/code/local/GreenPackages/News/Block/Adminhtml/News.php +12 -0
- app/code/local/GreenPackages/News/Block/Adminhtml/News/Edit.php +51 -0
- app/code/local/GreenPackages/News/Block/Adminhtml/News/Edit/Form.php +19 -0
- app/code/local/GreenPackages/News/Block/Adminhtml/News/Edit/Tab/Form.php +83 -0
- app/code/local/GreenPackages/News/Block/Adminhtml/News/Edit/Tabs.php +25 -0
- app/code/local/GreenPackages/News/Block/Adminhtml/News/Grid.php +136 -0
- app/code/local/GreenPackages/News/Block/Adminhtml/News/Renderer/Image.php +12 -0
- app/code/local/GreenPackages/News/Block/Breadcrumbs.php +19 -0
- app/code/local/GreenPackages/News/Block/Detalle.php +50 -0
- app/code/local/GreenPackages/News/Block/Links.php +15 -0
- app/code/local/GreenPackages/News/Block/Listado.php +71 -0
- app/code/local/GreenPackages/News/Block/News.php +23 -0
- app/code/local/GreenPackages/News/Block/Toolbar.php +42 -0
- app/code/local/GreenPackages/News/Helper/Data.php +6 -0
- app/code/local/GreenPackages/News/Model/Mysql4/News.php +73 -0
- app/code/local/GreenPackages/News/Model/Mysql4/News/Collection.php +38 -0
- app/code/local/GreenPackages/News/Model/News.php +13 -0
- app/code/local/GreenPackages/News/Model/Status.php +15 -0
- app/code/local/GreenPackages/News/controllers/Adminhtml/NewsController.php +237 -0
- app/code/local/GreenPackages/News/controllers/DetalleController.php +11 -0
- app/code/local/GreenPackages/News/controllers/ListadoController.php +22 -0
- app/code/local/GreenPackages/News/etc/config.xml +134 -0
- app/code/local/GreenPackages/News/sql/news_setup/mysql4-install-0.1.0.php +24 -0
- app/design/adminhtml/default/default/layout/news.xml +11 -0
- app/design/frontend/default/default/layout/news.xml +34 -0
- app/design/frontend/default/default/template/news/detalle.phtml +42 -0
- app/design/frontend/default/default/template/news/left.phtml +31 -0
- app/design/frontend/default/default/template/news/listado.phtml +33 -0
- app/design/frontend/default/default/template/news/toolbar.phtml +48 -0
- app/etc/modules/GreenPackages_News.xml +9 -0
- package.xml +28 -0
- skin/frontend/default/default/greenpackages/news/news.css +8 -0
app/code/local/GreenPackages/News/Block/Adminhtml/News.php
ADDED
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class GreenPackages_News_Block_Adminhtml_News extends Mage_Adminhtml_Block_Widget_Grid_Container
|
3 |
+
{
|
4 |
+
public function __construct()
|
5 |
+
{
|
6 |
+
$this->_controller = 'adminhtml_news';
|
7 |
+
$this->_blockGroup = 'news';
|
8 |
+
$this->_headerText = Mage::helper('news')->__('News Manager');
|
9 |
+
$this->_addButtonLabel = Mage::helper('news')->__('Add News');
|
10 |
+
parent::__construct();
|
11 |
+
}
|
12 |
+
}
|
app/code/local/GreenPackages/News/Block/Adminhtml/News/Edit.php
ADDED
@@ -0,0 +1,51 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class GreenPackages_News_Block_Adminhtml_News_Edit extends Mage_Adminhtml_Block_Widget_Form_Container
|
4 |
+
{
|
5 |
+
public function __construct()
|
6 |
+
{
|
7 |
+
parent::__construct();
|
8 |
+
|
9 |
+
$this->_objectId = 'id';
|
10 |
+
$this->_blockGroup = 'news';
|
11 |
+
$this->_controller = 'adminhtml_news';
|
12 |
+
|
13 |
+
$this->_updateButton('save', 'label', Mage::helper('news')->__('Save News'));
|
14 |
+
$this->_updateButton('delete', 'label', Mage::helper('news')->__('Delete News'));
|
15 |
+
|
16 |
+
$this->_addButton('saveandcontinue', array(
|
17 |
+
'label' => Mage::helper('adminhtml')->__('Save And Continue Edit'),
|
18 |
+
'onclick' => 'saveAndContinueEdit()',
|
19 |
+
'class' => 'save',
|
20 |
+
), -100);
|
21 |
+
|
22 |
+
$this->_formScripts[] = "
|
23 |
+
function toggleEditor() {
|
24 |
+
if (tinyMCE.getInstanceById('news_content') == null) {
|
25 |
+
tinyMCE.execCommand('mceAddControl', false, 'news_content');
|
26 |
+
} else {
|
27 |
+
tinyMCE.execCommand('mceRemoveControl', false, 'news_content');
|
28 |
+
}
|
29 |
+
}
|
30 |
+
|
31 |
+
function saveAndContinueEdit(){
|
32 |
+
editForm.submit($('edit_form').action+'back/edit/');
|
33 |
+
}
|
34 |
+
";
|
35 |
+
}
|
36 |
+
|
37 |
+
public function getHeaderText()
|
38 |
+
{
|
39 |
+
if( Mage::registry('news_data') && Mage::registry('news_data')->getId() ) {
|
40 |
+
return Mage::helper('news')->__("Edit News '%s'", $this->htmlEscape(Mage::registry('news_data')->getTitle()));
|
41 |
+
} else {
|
42 |
+
return Mage::helper('news')->__('Add Item');
|
43 |
+
}
|
44 |
+
}
|
45 |
+
protected function _prepareLayout() {
|
46 |
+
parent::_prepareLayout();
|
47 |
+
if (Mage::getSingleton('cms/wysiwyg_config')->isEnabled()) {
|
48 |
+
$this->getLayout()->getBlock('head')->setCanLoadTinyMce(true);
|
49 |
+
}
|
50 |
+
}
|
51 |
+
}
|
app/code/local/GreenPackages/News/Block/Adminhtml/News/Edit/Form.php
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class GreenPackages_News_Block_Adminhtml_News_Edit_Form extends Mage_Adminhtml_Block_Widget_Form
|
4 |
+
{
|
5 |
+
protected function _prepareForm()
|
6 |
+
{
|
7 |
+
$form = new Varien_Data_Form(array(
|
8 |
+
'id' => 'edit_form',
|
9 |
+
'action' => $this->getUrl('*/*/save', array('id' => $this->getRequest()->getParam('id'))),
|
10 |
+
'method' => 'post',
|
11 |
+
'enctype' => 'multipart/form-data'
|
12 |
+
)
|
13 |
+
);
|
14 |
+
|
15 |
+
$form->setUseContainer(true);
|
16 |
+
$this->setForm($form);
|
17 |
+
return parent::_prepareForm();
|
18 |
+
}
|
19 |
+
}
|
app/code/local/GreenPackages/News/Block/Adminhtml/News/Edit/Tab/Form.php
ADDED
@@ -0,0 +1,83 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class GreenPackages_News_Block_Adminhtml_News_Edit_Tab_Form extends Mage_Adminhtml_Block_Widget_Form
|
4 |
+
{
|
5 |
+
protected function _prepareForm()
|
6 |
+
{
|
7 |
+
$form = new Varien_Data_Form();
|
8 |
+
$this->setForm($form);
|
9 |
+
$fieldset = $form->addFieldset('news_form', array('legend'=>Mage::helper('news')->__('News information')));
|
10 |
+
$wysiwygConfig = Mage::getSingleton('cms/wysiwyg_config')->getConfig(array('add_variables' => false, 'add_widgets' => false,'files_browser_window_url'=>$this->getBaseUrl().'admin/cms_wysiwyg_images/index/'));
|
11 |
+
$fieldset->addField('title', 'text', array(
|
12 |
+
'label' => Mage::helper('news')->__('Title'),
|
13 |
+
'class' => 'required-entry',
|
14 |
+
'required' => true,
|
15 |
+
'name' => 'title',
|
16 |
+
));
|
17 |
+
|
18 |
+
$fieldset->addField('filename', 'image', array(
|
19 |
+
'label' => Mage::helper('news')->__('File'),
|
20 |
+
'required' => false,
|
21 |
+
'name' => 'filename',
|
22 |
+
));
|
23 |
+
|
24 |
+
$dateFormatIso = Mage::app()->getLocale()->getDateFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT);
|
25 |
+
|
26 |
+
$fieldset->addField('datefrom', 'date', array(
|
27 |
+
'name' => 'datefrom',
|
28 |
+
'label' => Mage::helper('news')->__('Date From'),
|
29 |
+
'title' => Mage::helper('news')->__('Date From'),
|
30 |
+
'image' => $this->getSkinUrl('images/grid-cal.gif'),
|
31 |
+
'input_format' => Varien_Date::DATE_INTERNAL_FORMAT,
|
32 |
+
'format' => $dateFormatIso,
|
33 |
+
'required' => true
|
34 |
+
));
|
35 |
+
$fieldset->addField('dateto', 'date', array(
|
36 |
+
'name' => 'dateto',
|
37 |
+
'label' => Mage::helper('news')->__('Date To'),
|
38 |
+
'title' => Mage::helper('news')->__('Date To'),
|
39 |
+
'image' => $this->getSkinUrl('images/grid-cal.gif'),
|
40 |
+
'input_format' => Varien_Date::DATE_INTERNAL_FORMAT,
|
41 |
+
'format' => $dateFormatIso,
|
42 |
+
'required' => true
|
43 |
+
));
|
44 |
+
|
45 |
+
$fieldset->addField('status', 'select', array(
|
46 |
+
'label' => Mage::helper('news')->__('Status'),
|
47 |
+
'name' => 'status',
|
48 |
+
'values' => array(
|
49 |
+
array(
|
50 |
+
'value' => 1,
|
51 |
+
'label' => Mage::helper('news')->__('Enabled'),
|
52 |
+
),
|
53 |
+
|
54 |
+
array(
|
55 |
+
'value' => 2,
|
56 |
+
'label' => Mage::helper('news')->__('Disabled'),
|
57 |
+
),
|
58 |
+
),
|
59 |
+
));
|
60 |
+
|
61 |
+
$fieldset->addField('texto', 'editor', array(
|
62 |
+
'name' => 'texto',
|
63 |
+
'label' => Mage::helper('news')->__('Content'),
|
64 |
+
'title' => Mage::helper('news')->__('Content'),
|
65 |
+
'style' => 'width:700px; height:500px;',
|
66 |
+
|
67 |
+
|
68 |
+
'required' => true,
|
69 |
+
'disabled' => $isElementDisabled,
|
70 |
+
'config' => $wysiwygConfig
|
71 |
+
));
|
72 |
+
|
73 |
+
if ( Mage::getSingleton('adminhtml/session')->getNewsData() )
|
74 |
+
{
|
75 |
+
$form->setValues(Mage::getSingleton('adminhtml/session')->getNewsData());
|
76 |
+
Mage::getSingleton('adminhtml/session')->setNewsData(null);
|
77 |
+
} elseif ( Mage::registry('news_data') ) {
|
78 |
+
$form->setValues(Mage::registry('news_data')->getData());
|
79 |
+
}
|
80 |
+
|
81 |
+
return parent::_prepareForm();
|
82 |
+
}
|
83 |
+
}
|
app/code/local/GreenPackages/News/Block/Adminhtml/News/Edit/Tabs.php
ADDED
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class GreenPackages_News_Block_Adminhtml_News_Edit_Tabs extends Mage_Adminhtml_Block_Widget_Tabs
|
4 |
+
{
|
5 |
+
|
6 |
+
public function __construct()
|
7 |
+
{
|
8 |
+
parent::__construct();
|
9 |
+
$this->setId('news_tabs');
|
10 |
+
$this->setDestElementId('edit_form');
|
11 |
+
$this->setTitle(Mage::helper('news')->__('News Information'));
|
12 |
+
}
|
13 |
+
|
14 |
+
protected function _beforeToHtml()
|
15 |
+
{
|
16 |
+
$this->addTab('form_section', array(
|
17 |
+
'label' => Mage::helper('news')->__('News Information'),
|
18 |
+
'title' => Mage::helper('news')->__('News Information'),
|
19 |
+
'content' => $this->getLayout()->createBlock('news/adminhtml_news_edit_tab_form')->toHtml(),
|
20 |
+
));
|
21 |
+
|
22 |
+
|
23 |
+
return parent::_beforeToHtml();
|
24 |
+
}
|
25 |
+
}
|
app/code/local/GreenPackages/News/Block/Adminhtml/News/Grid.php
ADDED
@@ -0,0 +1,136 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class GreenPackages_News_Block_Adminhtml_News_Grid extends Mage_Adminhtml_Block_Widget_Grid
|
4 |
+
{
|
5 |
+
public function __construct()
|
6 |
+
{
|
7 |
+
parent::__construct();
|
8 |
+
$this->setId('newsGrid');
|
9 |
+
$this->setDefaultSort('news_id');
|
10 |
+
$this->setDefaultDir('ASC');
|
11 |
+
$this->setSaveParametersInSession(true);
|
12 |
+
}
|
13 |
+
|
14 |
+
protected function _prepareCollection()
|
15 |
+
{
|
16 |
+
$collection = Mage::getModel('news/news')->getCollection();
|
17 |
+
$this->setCollection($collection);
|
18 |
+
|
19 |
+
return parent::_prepareCollection();
|
20 |
+
}
|
21 |
+
|
22 |
+
protected function _prepareColumns()
|
23 |
+
{
|
24 |
+
$this->addColumn('news_id', array(
|
25 |
+
'header' => Mage::helper('news')->__('ID'),
|
26 |
+
'align' =>'right',
|
27 |
+
'width' => '50px',
|
28 |
+
'index' => 'news_id',
|
29 |
+
));
|
30 |
+
|
31 |
+
$this->addColumn('title', array(
|
32 |
+
'header' => Mage::helper('news')->__('Title'),
|
33 |
+
'align' =>'left',
|
34 |
+
'index' => 'title',
|
35 |
+
));
|
36 |
+
|
37 |
+
$this->addColumn('texto', array(
|
38 |
+
'header' => Mage::helper('news')->__('Content'),
|
39 |
+
'align' =>'left',
|
40 |
+
'index' => 'texto',
|
41 |
+
'renderer' => 'adminhtml/widget_grid_column_renderer_longtext',
|
42 |
+
'string_limit' => '100',
|
43 |
+
));
|
44 |
+
|
45 |
+
$this->addColumn('filename', array(
|
46 |
+
'header' => Mage::helper('news')->__('Image'),
|
47 |
+
'align' =>'left',
|
48 |
+
'index' => 'filename',
|
49 |
+
'renderer' => 'GreenPackages_News_Block_Adminhtml_News_Renderer_Image',
|
50 |
+
));
|
51 |
+
|
52 |
+
$this->addColumn('datefrom',
|
53 |
+
array(
|
54 |
+
'header'=>Mage::helper('news')->__('Date From'),
|
55 |
+
'index'=>'datefrom',
|
56 |
+
'gmtoffset' => false,
|
57 |
+
'type'=>'date'
|
58 |
+
));
|
59 |
+
|
60 |
+
$this->addColumn('dateto',
|
61 |
+
array(
|
62 |
+
'header'=>Mage::helper('news')->__('Date To'),
|
63 |
+
'index'=>'dateto',
|
64 |
+
'gmtoffset' => false,
|
65 |
+
'type'=>'date'
|
66 |
+
));
|
67 |
+
|
68 |
+
$this->addColumn('status', array(
|
69 |
+
'header' => Mage::helper('news')->__('Status'),
|
70 |
+
'align' => 'left',
|
71 |
+
'width' => '80px',
|
72 |
+
'index' => 'status',
|
73 |
+
'type' => 'options',
|
74 |
+
'options' => array(
|
75 |
+
1 => 'Enabled',
|
76 |
+
2 => 'Disabled',
|
77 |
+
),
|
78 |
+
));
|
79 |
+
$this->addColumn('action',
|
80 |
+
array(
|
81 |
+
'header' => Mage::helper('news')->__('Action'),
|
82 |
+
'width' => '100',
|
83 |
+
'type' => 'action',
|
84 |
+
'getter' => 'getId',
|
85 |
+
'actions' => array(
|
86 |
+
array(
|
87 |
+
'caption' => Mage::helper('news')->__('Edit'),
|
88 |
+
'url' => array('base'=> '*/*/edit'),
|
89 |
+
'field' => 'id'
|
90 |
+
)
|
91 |
+
),
|
92 |
+
'filter' => false,
|
93 |
+
'sortable' => false,
|
94 |
+
'index' => 'stores',
|
95 |
+
'is_system' => true,
|
96 |
+
));
|
97 |
+
|
98 |
+
$this->addExportType('*/*/exportCsv', Mage::helper('news')->__('CSV'));
|
99 |
+
$this->addExportType('*/*/exportXml', Mage::helper('news')->__('XML'));
|
100 |
+
|
101 |
+
return parent::_prepareColumns();
|
102 |
+
}
|
103 |
+
|
104 |
+
protected function _prepareMassaction()
|
105 |
+
{
|
106 |
+
$this->setMassactionIdField('news_id');
|
107 |
+
$this->getMassactionBlock()->setFormFieldName('news');
|
108 |
+
|
109 |
+
$this->getMassactionBlock()->addItem('delete', array(
|
110 |
+
'label' => Mage::helper('news')->__('Delete'),
|
111 |
+
'url' => $this->getUrl('*/*/massDelete'),
|
112 |
+
'confirm' => Mage::helper('news')->__('Are you sure?')
|
113 |
+
));
|
114 |
+
|
115 |
+
$statuses = Mage::getSingleton('news/status')->getOptionArray();
|
116 |
+
|
117 |
+
array_unshift($statuses, array('label'=>'', 'value'=>''));
|
118 |
+
$this->getMassactionBlock()->addItem('status', array(
|
119 |
+
'label'=> Mage::helper('news')->__('Change status'),
|
120 |
+
'url' => $this->getUrl('*/*/massStatus', array('_current'=>true)),
|
121 |
+
'additional' => array(
|
122 |
+
'visibility' => array(
|
123 |
+
'name' => 'status',
|
124 |
+
'type' => 'select',
|
125 |
+
'class' => 'required-entry',
|
126 |
+
'label' => Mage::helper('news')->__('Status'),
|
127 |
+
'values' => $statuses
|
128 |
+
)
|
129 |
+
)
|
130 |
+
));
|
131 |
+
return $this;
|
132 |
+
}
|
133 |
+
|
134 |
+
|
135 |
+
|
136 |
+
}
|
app/code/local/GreenPackages/News/Block/Adminhtml/News/Renderer/Image.php
ADDED
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class GreenPackages_News_Block_Adminhtml_News_Renderer_Image extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract
|
3 |
+
{
|
4 |
+
public function render(Varien_Object $row)
|
5 |
+
{
|
6 |
+
$image = $row->getFilename();
|
7 |
+
|
8 |
+
|
9 |
+
return '<img src="'.$image.'" height="40" width="60" />';
|
10 |
+
}
|
11 |
+
}
|
12 |
+
?>
|
app/code/local/GreenPackages/News/Block/Breadcrumbs.php
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class GreenPackages_News_Block_Breadcrumbs extends Mage_Core_Block_Template
|
3 |
+
{
|
4 |
+
protected function _prepareLayout()
|
5 |
+
{
|
6 |
+
if ($breadcrumbsBlock = $this->getLayout()->getBlock('breadcrumbs')) {
|
7 |
+
$breadcrumbsBlock->addCrumb('home',
|
8 |
+
array('label'=>Mage::helper('news')->__('Home'), 'title'=>Mage::helper('news')->__('Go to Home Page'), 'link'=>Mage::getBaseUrl())
|
9 |
+
);
|
10 |
+
$breadcrumbsBlock->addCrumb('listado',
|
11 |
+
array('label'=>Mage::helper('news')->__('News & Innovations'), 'title'=>Mage::helper('news')->__('Go to News & Innovations'), 'link'=>$this->getUrl('news/listado'))
|
12 |
+
);
|
13 |
+
|
14 |
+
|
15 |
+
}
|
16 |
+
return parent::_prepareLayout();
|
17 |
+
}
|
18 |
+
|
19 |
+
}
|
app/code/local/GreenPackages/News/Block/Detalle.php
ADDED
@@ -0,0 +1,50 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class GreenPackages_News_Block_Detalle extends Mage_Core_Block_Template{
|
4 |
+
|
5 |
+
protected $_newsCollection = null;
|
6 |
+
|
7 |
+
|
8 |
+
protected function _prepareLayout()
|
9 |
+
{
|
10 |
+
$this->getLayout()->createBlock('news/breadcrumbs');
|
11 |
+
return parent::_prepareLayout();
|
12 |
+
}
|
13 |
+
|
14 |
+
|
15 |
+
public function getLoadedNewsCollection()
|
16 |
+
{
|
17 |
+
return $this->_getNewsCollection();
|
18 |
+
}
|
19 |
+
|
20 |
+
public function _getNewsCollection()
|
21 |
+
{
|
22 |
+
$news_id = $this->getRequest()->getParam('id');
|
23 |
+
|
24 |
+
if($news_id != null && $news_id != '') {
|
25 |
+
$news = Mage::getModel('news/news')->load($news_id)->getData();
|
26 |
+
} else {
|
27 |
+
$news = null;
|
28 |
+
}
|
29 |
+
|
30 |
+
if($news == null) {
|
31 |
+
$resource = Mage::getSingleton('core/resource');
|
32 |
+
$read= $resource->getConnection('core_read');
|
33 |
+
$newsTable = $resource->getTableName('news');
|
34 |
+
|
35 |
+
$select = $read->select()
|
36 |
+
->from($newsTable,array('news_id','title','texto','status'))
|
37 |
+
->where('publicar',1);
|
38 |
+
|
39 |
+
|
40 |
+
$news = $read->fetchRow($select);
|
41 |
+
|
42 |
+
}
|
43 |
+
|
44 |
+
|
45 |
+
return $news;
|
46 |
+
}
|
47 |
+
|
48 |
+
|
49 |
+
|
50 |
+
}
|
app/code/local/GreenPackages/News/Block/Links.php
ADDED
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class GreenPackages_News_Block_Links extends Mage_Page_Block_Template_Links
|
4 |
+
{
|
5 |
+
|
6 |
+
public function addNewsLink()
|
7 |
+
{
|
8 |
+
|
9 |
+
$text = $this->__('Noticias');
|
10 |
+
|
11 |
+
$this->addLink($text, 'news/listado', $text, true, array(), 30, null, 'class="top-link-wishlist"');
|
12 |
+
|
13 |
+
return $this;
|
14 |
+
}
|
15 |
+
}
|
app/code/local/GreenPackages/News/Block/Listado.php
ADDED
@@ -0,0 +1,71 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class GreenPackages_News_Block_Listado extends Mage_Core_Block_Template{
|
4 |
+
|
5 |
+
|
6 |
+
public function _construct(){
|
7 |
+
|
8 |
+
}
|
9 |
+
|
10 |
+
protected $_newsCollection = null;
|
11 |
+
|
12 |
+
|
13 |
+
/**
|
14 |
+
* Recogemos la collection de news
|
15 |
+
*
|
16 |
+
*/
|
17 |
+
public function getLoadedNewsCollection()
|
18 |
+
{
|
19 |
+
return $this->_getNewsCollection();
|
20 |
+
}
|
21 |
+
|
22 |
+
|
23 |
+
/** Devuelve el listado de noticias de news
|
24 |
+
*
|
25 |
+
*/
|
26 |
+
public function _getNewsCollection()
|
27 |
+
{
|
28 |
+
if (is_null($this->_newsCollection)) {
|
29 |
+
//$now = date('Y-m-d');
|
30 |
+
$now = now();
|
31 |
+
|
32 |
+
//$this->_newsCollection = Mage::getModel('news/news')->getCollection()->prepareSummary();
|
33 |
+
$this->_newsCollection = Mage::getModel('news/news')->getCollection();
|
34 |
+
|
35 |
+
$this->_newsCollection->getSelect('*');
|
36 |
+
$this->_newsCollection->addFieldToFilter('status', '1')->addFieldToFilter('dateto',array('gteq'=>$now))
|
37 |
+
->setOrder('datefrom','desc');
|
38 |
+
|
39 |
+
}
|
40 |
+
|
41 |
+
return $this->_newsCollection;
|
42 |
+
}
|
43 |
+
|
44 |
+
/**
|
45 |
+
* Need use as _prepareLayout - but problem in declaring collection from
|
46 |
+
* another block (was problem with search result)
|
47 |
+
*/
|
48 |
+
public function _beforeToHtml()
|
49 |
+
{
|
50 |
+
$toolbar = $this->getLayout()->createBlock('news/toolbar', microtime());
|
51 |
+
|
52 |
+
$toolbar->setCollection($this->_getNewsCollection());
|
53 |
+
$this->setChild('toolbar', $toolbar);
|
54 |
+
Mage::dispatchEvent('news_block_listado_collection', array(
|
55 |
+
'collection'=>$this->_getNewsCollection(),
|
56 |
+
));
|
57 |
+
|
58 |
+
$this->_getNewsCollection()->load();
|
59 |
+
return parent::_prepareLayout();
|
60 |
+
}
|
61 |
+
|
62 |
+
/**
|
63 |
+
* Retrieve list toolbar HTML
|
64 |
+
*
|
65 |
+
* @return string
|
66 |
+
*/
|
67 |
+
public function getToolbarHtml()
|
68 |
+
{
|
69 |
+
return $this->getChildHtml('toolbar');
|
70 |
+
}
|
71 |
+
}
|
app/code/local/GreenPackages/News/Block/News.php
ADDED
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class GreenPackages_News_Block_News extends Mage_Core_Block_Template
|
3 |
+
{
|
4 |
+
|
5 |
+
public function _prepareLayout()
|
6 |
+
{
|
7 |
+
if (Mage::getSingleton('cms/wysiwyg_config')->isEnabled() && ($block = $this->getLayout()->getBlock('head')))
|
8 |
+
{
|
9 |
+
$block->setCanLoadTinyMce(true);
|
10 |
+
}
|
11 |
+
return parent::_prepareLayout();
|
12 |
+
}
|
13 |
+
|
14 |
+
public function getNews()
|
15 |
+
{
|
16 |
+
if (!$this->hasData('news')) {
|
17 |
+
$this->setData('news', Mage::registry('news'));
|
18 |
+
}
|
19 |
+
return $this->getData('news');
|
20 |
+
|
21 |
+
}
|
22 |
+
|
23 |
+
}
|
app/code/local/GreenPackages/News/Block/Toolbar.php
ADDED
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
class GreenPackages_News_Block_Toolbar extends Mage_Page_Block_Html_Pager
|
3 |
+
{
|
4 |
+
|
5 |
+
public function __construct()
|
6 |
+
{
|
7 |
+
parent::__construct();
|
8 |
+
$this->setTemplate('news/toolbar.phtml');
|
9 |
+
}
|
10 |
+
|
11 |
+
public function setCollection($collection)
|
12 |
+
{
|
13 |
+
parent::setCollection($collection);
|
14 |
+
return $this;
|
15 |
+
}
|
16 |
+
|
17 |
+
|
18 |
+
public function getAvailableLimit()
|
19 |
+
{
|
20 |
+
$perPageValues = Mage::getConfig()->getNode('frontend/news/per_page_values');
|
21 |
+
$perPageValues = explode(',', $perPageValues);
|
22 |
+
$perPageValues = array_combine($perPageValues, $perPageValues);
|
23 |
+
return ($perPageValues);
|
24 |
+
return parent::getAvailableLimit();
|
25 |
+
}
|
26 |
+
|
27 |
+
public function getLimit()
|
28 |
+
{
|
29 |
+
$limits = $this->getAvailableLimit();
|
30 |
+
if ($limit = $this->getRequest()->getParam($this->getLimitVarName())) {
|
31 |
+
if (isset($limits[$limit])) {
|
32 |
+
return $limit;
|
33 |
+
}
|
34 |
+
}
|
35 |
+
$defaultLimit = Mage::getStoreConfig('news/frontend/product_per_page');
|
36 |
+
if ($defaultLimit != '') {
|
37 |
+
return $defaultLimit;
|
38 |
+
}
|
39 |
+
$limits = array_keys($limits);
|
40 |
+
return $limits[0];
|
41 |
+
}
|
42 |
+
}
|
app/code/local/GreenPackages/News/Helper/Data.php
ADDED
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class GreenPackages_News_Helper_Data extends Mage_Core_Helper_Abstract
|
4 |
+
{
|
5 |
+
|
6 |
+
}
|
app/code/local/GreenPackages/News/Model/Mysql4/News.php
ADDED
@@ -0,0 +1,73 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class GreenPackages_News_Model_Mysql4_News extends Mage_Core_Model_Mysql4_Abstract
|
4 |
+
{
|
5 |
+
public function _construct()
|
6 |
+
{
|
7 |
+
// Note that the news_id refers to the key field in your database table.
|
8 |
+
$this->_init('news/news', 'news_id');
|
9 |
+
}
|
10 |
+
|
11 |
+
/**
|
12 |
+
*
|
13 |
+
*
|
14 |
+
* @param Mage_Core_Model_Abstract $object
|
15 |
+
*/
|
16 |
+
|
17 |
+
public function urls_amigables($url) {
|
18 |
+
|
19 |
+
// Tranformamos todo a minusculas
|
20 |
+
$url = strtolower($url);
|
21 |
+
|
22 |
+
//Rememplazamos caracteres especiales latinos
|
23 |
+
$find = array('�', '�', '�', '�', '�', '�');
|
24 |
+
$repl = array('a', 'e', 'i', 'o', 'u', 'n');
|
25 |
+
$url = str_replace ($find, $repl, $url);
|
26 |
+
|
27 |
+
// A�adimos los guiones
|
28 |
+
$find = array(' ', '&', '\r\n', '\n', '+');
|
29 |
+
$url = str_replace ($find, '-', $url);
|
30 |
+
|
31 |
+
// Eliminamos y Reemplazamos dem�s caracteres especiales
|
32 |
+
$find = array('/[^a-z0-9\-<>]/', '/[\-]+/', '/<[^>]*>/');
|
33 |
+
$repl = array('', '-', '');
|
34 |
+
$url = preg_replace ($find, $repl, $url);
|
35 |
+
|
36 |
+
return $url;
|
37 |
+
|
38 |
+
}
|
39 |
+
|
40 |
+
|
41 |
+
public function _beforeSave(Mage_Core_Model_Abstract $object)
|
42 |
+
{
|
43 |
+
$amigable = $this->urls_amigables($object->getTitular());
|
44 |
+
$object->setAmigable($amigable);
|
45 |
+
|
46 |
+
if(!$object->getIsMassupdate()){
|
47 |
+
if (!$object->getFechaini()) {
|
48 |
+
//$object->setFechaini(new Zend_Db_Expr('NULL'));
|
49 |
+
}else{
|
50 |
+
$fechaini = explode('/',$object->getFechaini());
|
51 |
+
$object->setFechaini($this->formatDate($fechaini[1].'/'.$fechaini[0].'/'.$fechaini[2]));
|
52 |
+
}
|
53 |
+
|
54 |
+
if (!$object->getFechafin()) {
|
55 |
+
//$object->setFechafin(new Zend_Db_Expr('NULL'));
|
56 |
+
}else{
|
57 |
+
$fechafin = explode('/',$object->getFechafin());
|
58 |
+
$object->setFechafin($this->formatDate($fechafin[1].'/'.$fechafin[0].'/'.$fechafin[2]));
|
59 |
+
}
|
60 |
+
}
|
61 |
+
return $this;
|
62 |
+
}
|
63 |
+
|
64 |
+
public function load(Mage_Core_Model_Abstract $object, $value, $field=null)
|
65 |
+
{
|
66 |
+
if (strcmp($value, (int)$value) !== 0) {
|
67 |
+
$field = 'identifier';
|
68 |
+
}
|
69 |
+
return parent::load($object, $value, $field);
|
70 |
+
}
|
71 |
+
|
72 |
+
|
73 |
+
}
|
app/code/local/GreenPackages/News/Model/Mysql4/News/Collection.php
ADDED
@@ -0,0 +1,38 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class GreenPackages_News_Model_Mysql4_News_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
|
4 |
+
{
|
5 |
+
public function _construct()
|
6 |
+
{
|
7 |
+
parent::_construct();
|
8 |
+
$this->_init('news/news');
|
9 |
+
}
|
10 |
+
|
11 |
+
public function prepareSummary()
|
12 |
+
{
|
13 |
+
$this->setConnection($this->getResource()->getReadConnection());
|
14 |
+
|
15 |
+
$this->getSelect()
|
16 |
+
->from(array('main_table'=>'news'),'*')
|
17 |
+
->where('publicar = ?', 1)
|
18 |
+
->order('fechaini','asc');;
|
19 |
+
|
20 |
+
return $this;
|
21 |
+
}
|
22 |
+
|
23 |
+
public function getDetalle($news_id)
|
24 |
+
{
|
25 |
+
|
26 |
+
$this->setConnection($this->getResource()->getReadConnection());
|
27 |
+
$this->getSelect()
|
28 |
+
->from(array('main_table'=>'news'),'*')
|
29 |
+
->where('news_id = ?', $news_id);
|
30 |
+
|
31 |
+
|
32 |
+
return $this;
|
33 |
+
|
34 |
+
|
35 |
+
}
|
36 |
+
|
37 |
+
|
38 |
+
}
|
app/code/local/GreenPackages/News/Model/News.php
ADDED
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class GreenPackages_News_Model_News extends Mage_Core_Model_Abstract
|
4 |
+
{
|
5 |
+
|
6 |
+
public function _construct()
|
7 |
+
{
|
8 |
+
parent::_construct();
|
9 |
+
$this->_init('news/news');
|
10 |
+
}
|
11 |
+
|
12 |
+
|
13 |
+
}
|
app/code/local/GreenPackages/News/Model/Status.php
ADDED
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class GreenPackages_News_Model_Status extends Varien_Object
|
4 |
+
{
|
5 |
+
const STATUS_ENABLED = 1;
|
6 |
+
const STATUS_DISABLED = 2;
|
7 |
+
|
8 |
+
static public function getOptionArray()
|
9 |
+
{
|
10 |
+
return array(
|
11 |
+
self::STATUS_ENABLED => Mage::helper('news')->__('Enabled'),
|
12 |
+
self::STATUS_DISABLED => Mage::helper('news')->__('Disabled')
|
13 |
+
);
|
14 |
+
}
|
15 |
+
}
|
app/code/local/GreenPackages/News/controllers/Adminhtml/NewsController.php
ADDED
@@ -0,0 +1,237 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class GreenPackages_News_Adminhtml_NewsController extends Mage_Adminhtml_Controller_action
|
4 |
+
{
|
5 |
+
|
6 |
+
protected function _initAction() {
|
7 |
+
$this->loadLayout()
|
8 |
+
->_setActiveMenu('news/newss')
|
9 |
+
->_addBreadcrumb(Mage::helper('adminhtml')->__('Newss Manager'), Mage::helper('adminhtml')->__('News Manager'));
|
10 |
+
|
11 |
+
return $this;
|
12 |
+
}
|
13 |
+
|
14 |
+
public function indexAction() {
|
15 |
+
$this->_initAction()
|
16 |
+
->renderLayout();
|
17 |
+
}
|
18 |
+
/*---------------edit existing news content----------*/
|
19 |
+
public function editAction() {
|
20 |
+
$id = $this->getRequest()->getParam('id');
|
21 |
+
$model = Mage::getModel('news/news')->load($id);
|
22 |
+
|
23 |
+
if ($model->getId() || $id == 0) {
|
24 |
+
$data = Mage::getSingleton('adminhtml/session')->getFormData(true);
|
25 |
+
if (!empty($data)) {
|
26 |
+
$model->setData($data);
|
27 |
+
}
|
28 |
+
|
29 |
+
Mage::register('news_data', $model);
|
30 |
+
|
31 |
+
$this->loadLayout();
|
32 |
+
$this->_setActiveMenu('news/newss');
|
33 |
+
|
34 |
+
$this->_addBreadcrumb(Mage::helper('adminhtml')->__('News Manager'), Mage::helper('adminhtml')->__('News Manager'));
|
35 |
+
$this->_addBreadcrumb(Mage::helper('adminhtml')->__('News News'), Mage::helper('adminhtml')->__('News News'));
|
36 |
+
|
37 |
+
$this->getLayout()->getBlock('head')->setCanLoadExtJs(true);
|
38 |
+
|
39 |
+
$this->_addContent($this->getLayout()->createBlock('news/adminhtml_news_edit'))
|
40 |
+
->_addLeft($this->getLayout()->createBlock('news/adminhtml_news_edit_tabs'));
|
41 |
+
|
42 |
+
$this->renderLayout();
|
43 |
+
} else {
|
44 |
+
Mage::getSingleton('adminhtml/session')->addError(Mage::helper('news')->__('News does not exist'));
|
45 |
+
$this->_redirect('*/*/');
|
46 |
+
}
|
47 |
+
}
|
48 |
+
/*---------------add new news content----------*/
|
49 |
+
public function newAction() {
|
50 |
+
$this->_forward('edit');
|
51 |
+
}
|
52 |
+
/*------------save new / old news content----------*/
|
53 |
+
public function saveAction() {
|
54 |
+
|
55 |
+
if ($data = $this->getRequest()->getPost()) {
|
56 |
+
|
57 |
+
$model = Mage::getModel('news/news');
|
58 |
+
if(isset($_FILES['filename']['name']) && $_FILES['filename']['name'] != '') {
|
59 |
+
try {
|
60 |
+
/* Starting upload */
|
61 |
+
$uploader = new Varien_File_Uploader('filename');
|
62 |
+
|
63 |
+
// Any extention would work
|
64 |
+
$uploader->setAllowedExtensions(array('jpg','jpeg','gif','png'));
|
65 |
+
$uploader->setAllowRenameFiles(false);
|
66 |
+
|
67 |
+
// Set the file upload mode
|
68 |
+
// false -> get the file directly in the specified folder
|
69 |
+
// true -> get the file in the product like folders
|
70 |
+
// (file.jpg will go in something like /media/f/i/file.jpg)
|
71 |
+
$uploader->setFilesDispersion(false);
|
72 |
+
|
73 |
+
// We set media as the upload dir
|
74 |
+
$path = Mage::getBaseDir('media') . '/' .'news' . '/' . 'images' .'/' ;
|
75 |
+
|
76 |
+
$uploader->save($path, $_FILES['filename']['name'] );
|
77 |
+
$pathUrl = Mage::getBaseUrl('media') . '/' .'news' . '/' . 'images' .'/' ;
|
78 |
+
$uploadFileName = $uploader->getUploadedFileName();
|
79 |
+
$data['filename'] = $pathUrl.$uploadFileName;
|
80 |
+
$model->setFilename($data['filename']);
|
81 |
+
|
82 |
+
} catch (Exception $e) {
|
83 |
+
|
84 |
+
}
|
85 |
+
|
86 |
+
//this way the name is saved in DB
|
87 |
+
|
88 |
+
}
|
89 |
+
if(is_array($data['filename']))
|
90 |
+
{
|
91 |
+
if($data['filename']['delete'])
|
92 |
+
{
|
93 |
+
$data['filename'] = "";
|
94 |
+
}
|
95 |
+
else{
|
96 |
+
$data['filename'] = $data['filename']['value'];
|
97 |
+
}
|
98 |
+
$model->setFilename($data['filename']);
|
99 |
+
}
|
100 |
+
|
101 |
+
|
102 |
+
|
103 |
+
$model->setData($data)
|
104 |
+
->setId($this->getRequest()->getParam('id'));
|
105 |
+
|
106 |
+
try {
|
107 |
+
|
108 |
+
$model->save();
|
109 |
+
Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('news')->__('News was successfully saved'));
|
110 |
+
Mage::getSingleton('adminhtml/session')->setFormData(false);
|
111 |
+
|
112 |
+
if ($this->getRequest()->getParam('back')) {
|
113 |
+
$this->_redirect('*/*/edit', array('id' => $model->getId()));
|
114 |
+
return;
|
115 |
+
}
|
116 |
+
$this->_redirect('*/*/');
|
117 |
+
return;
|
118 |
+
} catch (Exception $e) {
|
119 |
+
Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
|
120 |
+
Mage::getSingleton('adminhtml/session')->setFormData($data);
|
121 |
+
$this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
|
122 |
+
return;
|
123 |
+
}
|
124 |
+
}
|
125 |
+
Mage::getSingleton('adminhtml/session')->addError(Mage::helper('news')->__('Unable to find news to save'));
|
126 |
+
$this->_redirect('*/*/');
|
127 |
+
}
|
128 |
+
/*-------------------delete specific news---------*/
|
129 |
+
public function deleteAction() {
|
130 |
+
if( $this->getRequest()->getParam('id') > 0 ) {
|
131 |
+
try {
|
132 |
+
$model = Mage::getModel('news/news');
|
133 |
+
|
134 |
+
$model->setId($this->getRequest()->getParam('id'))
|
135 |
+
->delete();
|
136 |
+
|
137 |
+
Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('adminhtml')->__('News was successfully deleted'));
|
138 |
+
$this->_redirect('*/*/');
|
139 |
+
} catch (Exception $e) {
|
140 |
+
Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
|
141 |
+
$this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
|
142 |
+
}
|
143 |
+
}
|
144 |
+
$this->_redirect('*/*/');
|
145 |
+
}
|
146 |
+
/*-------------------delete all selected news---------*/
|
147 |
+
public function massDeleteAction() {
|
148 |
+
|
149 |
+
$newsIds = $this->getRequest()->getParam('news');
|
150 |
+
if(!is_array($newsIds)) {
|
151 |
+
Mage::getSingleton('adminhtml/session')->addError(Mage::helper('adminhtml')->__('Please select news(s)'));
|
152 |
+
} else {
|
153 |
+
try {
|
154 |
+
foreach ($newsIds as $newsId) {
|
155 |
+
$news = Mage::getModel('news/news')->load($newsId);
|
156 |
+
$news->delete();
|
157 |
+
}
|
158 |
+
Mage::getSingleton('adminhtml/session')->addSuccess(
|
159 |
+
Mage::helper('adminhtml')->__(
|
160 |
+
'Total of %d record(s) were successfully deleted', count($newsIds)
|
161 |
+
)
|
162 |
+
);
|
163 |
+
} catch (Exception $e) {
|
164 |
+
Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
|
165 |
+
}
|
166 |
+
}
|
167 |
+
|
168 |
+
|
169 |
+
$this->_redirect('*/*/index');
|
170 |
+
}
|
171 |
+
/*-------------------change status of all selected news---------*/
|
172 |
+
public function massStatusAction()
|
173 |
+
{
|
174 |
+
$newsIds = $this->getRequest()->getParam('news');
|
175 |
+
|
176 |
+
Mage::log('status change');
|
177 |
+
Mage::log($newsIds);
|
178 |
+
|
179 |
+
|
180 |
+
if(!is_array($newsIds)) {
|
181 |
+
Mage::getModel('adminhtml/session')->addError($this->__('Please select news(s)'));
|
182 |
+
} else {
|
183 |
+
try {
|
184 |
+
|
185 |
+
foreach ($newsIds as $newsId) {
|
186 |
+
$news = Mage::getSingleton('news/news')
|
187 |
+
->load($newsId)
|
188 |
+
->setPublicar($this->getRequest()->getParam('status'))
|
189 |
+
->setIsMassupdate(true)
|
190 |
+
->save();
|
191 |
+
}
|
192 |
+
|
193 |
+
|
194 |
+
$this->_getSession()->addSuccess(
|
195 |
+
$this->__('Total of %d record(s) were successfully updated', count($newsIds))
|
196 |
+
);
|
197 |
+
} catch (Exception $e) {
|
198 |
+
$this->_getSession()->addError($e->getMessage());
|
199 |
+
}
|
200 |
+
}
|
201 |
+
$this->_redirect('*/*/index');
|
202 |
+
}
|
203 |
+
|
204 |
+
public function exportCsvAction()
|
205 |
+
{
|
206 |
+
$fileName = 'news.csv';
|
207 |
+
$content = $this->getLayout()->createBlock('news/adminhtml_news_grid')
|
208 |
+
->getCsv();
|
209 |
+
|
210 |
+
$this->_sendUploadResponse($fileName, $content);
|
211 |
+
}
|
212 |
+
|
213 |
+
public function exportXmlAction()
|
214 |
+
{
|
215 |
+
$fileName = 'news.xml';
|
216 |
+
$content = $this->getLayout()->createBlock('news/adminhtml_news_grid')
|
217 |
+
->getXml();
|
218 |
+
|
219 |
+
$this->_sendUploadResponse($fileName, $content);
|
220 |
+
}
|
221 |
+
|
222 |
+
protected function _sendUploadResponse($fileName, $content, $contentType='application/octet-stream')
|
223 |
+
{
|
224 |
+
$response = $this->getResponse();
|
225 |
+
$response->setHeader('HTTP/1.1 200 OK','');
|
226 |
+
$response->setHeader('Pragma', 'public', true);
|
227 |
+
$response->setHeader('Cache-Control', 'must-revalidate, post-check=0, pre-check=0', true);
|
228 |
+
$response->setHeader('Content-Disposition', 'attachment; filename='.$fileName);
|
229 |
+
$response->setHeader('Last-Modified', date('r'));
|
230 |
+
$response->setHeader('Accept-Ranges', 'bytes');
|
231 |
+
$response->setHeader('Content-Length', strlen($content));
|
232 |
+
$response->setHeader('Content-type', $contentType);
|
233 |
+
$response->setBody($content);
|
234 |
+
$response->sendResponse();
|
235 |
+
die;
|
236 |
+
}
|
237 |
+
}
|
app/code/local/GreenPackages/News/controllers/DetalleController.php
ADDED
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class GreenPackages_News_DetalleController extends Mage_Core_Controller_Front_Action
|
4 |
+
{
|
5 |
+
/* function for showing news deatials of specific news-------------*/
|
6 |
+
|
7 |
+
public function indexAction()
|
8 |
+
{
|
9 |
+
$this->loadLayout()->renderLayout();
|
10 |
+
}
|
11 |
+
}
|
app/code/local/GreenPackages/News/controllers/ListadoController.php
ADDED
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class GreenPackages_News_ListadoController extends Mage_Core_Controller_Front_Action
|
4 |
+
{
|
5 |
+
/*showing list of those news which are active---------*/
|
6 |
+
public function indexAction()
|
7 |
+
{
|
8 |
+
|
9 |
+
$this->loadLayout();
|
10 |
+
$breadcrumbs = $this->getLayout()->getBlock('breadcrumbs');
|
11 |
+
$breadcrumbs->addCrumb('home',array('label'=>Mage::helper('cms')->__('Home'), 'title'=>Mage::helper('cms')->__('Home Page'),
|
12 |
+
'link'=>Mage::getBaseUrl()));
|
13 |
+
$breadcrumbs->addCrumb('News & Innovation', array('label'=>$this->__('News & Innovation'),
|
14 |
+
'title'=>'News & Innovation'
|
15 |
+
));
|
16 |
+
|
17 |
+
|
18 |
+
|
19 |
+
//echo $this->getLayout()->getBlock('breadcrumbs')->toHtml();
|
20 |
+
$this->renderLayout();
|
21 |
+
}
|
22 |
+
}
|
app/code/local/GreenPackages/News/etc/config.xml
ADDED
@@ -0,0 +1,134 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<modules>
|
4 |
+
<GreenPackages_News>
|
5 |
+
<version>0.1.0</version>
|
6 |
+
</GreenPackages_News>
|
7 |
+
</modules>
|
8 |
+
<frontend>
|
9 |
+
<routers>
|
10 |
+
<news>
|
11 |
+
<use>standard</use>
|
12 |
+
<args>
|
13 |
+
<module>GreenPackages_News</module>
|
14 |
+
<frontName>news</frontName>
|
15 |
+
</args>
|
16 |
+
</news>
|
17 |
+
</routers>
|
18 |
+
<layout>
|
19 |
+
<updates>
|
20 |
+
<news>
|
21 |
+
<file>news.xml</file>
|
22 |
+
</news>
|
23 |
+
</updates>
|
24 |
+
</layout>
|
25 |
+
<news>
|
26 |
+
<per_page_values>5,10,20,50</per_page_values>
|
27 |
+
</news>
|
28 |
+
<translate>
|
29 |
+
<modules>
|
30 |
+
<GreenPackages_News>
|
31 |
+
<files>
|
32 |
+
<default>GreenPackages_News.csv</default>
|
33 |
+
</files>
|
34 |
+
</GreenPackages_News>
|
35 |
+
</modules>
|
36 |
+
</translate>
|
37 |
+
|
38 |
+
</frontend>
|
39 |
+
<admin>
|
40 |
+
<routers>
|
41 |
+
<news>
|
42 |
+
<use>admin</use>
|
43 |
+
<args>
|
44 |
+
<module>GreenPackages_News</module>
|
45 |
+
<frontName>news</frontName>
|
46 |
+
</args>
|
47 |
+
</news>
|
48 |
+
</routers>
|
49 |
+
</admin>
|
50 |
+
<adminhtml>
|
51 |
+
<menu>
|
52 |
+
|
53 |
+
<news module="news">
|
54 |
+
<title>Green Packages</title>
|
55 |
+
<sort_order>71</sort_order>
|
56 |
+
<children>
|
57 |
+
<items module="news">
|
58 |
+
<title>Manage News</title>
|
59 |
+
<sort_order>0</sort_order>
|
60 |
+
<action>news/adminhtml_news</action>
|
61 |
+
</items>
|
62 |
+
</children>
|
63 |
+
</news>
|
64 |
+
</menu>
|
65 |
+
<acl>
|
66 |
+
<resources>
|
67 |
+
<all>
|
68 |
+
<title>Allow Everything</title>
|
69 |
+
</all>
|
70 |
+
<admin>
|
71 |
+
<children>
|
72 |
+
<GreenPackages_News>
|
73 |
+
<title>News Module</title>
|
74 |
+
<sort_order>10</sort_order>
|
75 |
+
</GreenPackages_News>
|
76 |
+
</children>
|
77 |
+
</admin>
|
78 |
+
</resources>
|
79 |
+
</acl>
|
80 |
+
<layout>
|
81 |
+
<updates>
|
82 |
+
<news>
|
83 |
+
<file>news.xml</file>
|
84 |
+
</news>
|
85 |
+
</updates>
|
86 |
+
</layout>
|
87 |
+
</adminhtml>
|
88 |
+
<global>
|
89 |
+
<models>
|
90 |
+
<news>
|
91 |
+
<class>GreenPackages_News_Model</class>
|
92 |
+
<resourceModel>news_mysql4</resourceModel>
|
93 |
+
</news>
|
94 |
+
<news_mysql4>
|
95 |
+
<class>GreenPackages_News_Model_Mysql4</class>
|
96 |
+
<entities>
|
97 |
+
<news>
|
98 |
+
<table>news</table>
|
99 |
+
</news>
|
100 |
+
</entities>
|
101 |
+
</news_mysql4>
|
102 |
+
</models>
|
103 |
+
<resources>
|
104 |
+
<news_setup>
|
105 |
+
<setup>
|
106 |
+
<module>GreenPackages_News</module>
|
107 |
+
</setup>
|
108 |
+
<connection>
|
109 |
+
<use>core_setup</use>
|
110 |
+
</connection>
|
111 |
+
</news_setup>
|
112 |
+
<news_write>
|
113 |
+
<connection>
|
114 |
+
<use>core_write</use>
|
115 |
+
</connection>
|
116 |
+
</news_write>
|
117 |
+
<news_read>
|
118 |
+
<connection>
|
119 |
+
<use>core_read</use>
|
120 |
+
</connection>
|
121 |
+
</news_read>
|
122 |
+
</resources>
|
123 |
+
<blocks>
|
124 |
+
<news>
|
125 |
+
<class>GreenPackages_News_Block</class>
|
126 |
+
</news>
|
127 |
+
</blocks>
|
128 |
+
<helpers>
|
129 |
+
<news>
|
130 |
+
<class>GreenPackages_News_Helper</class>
|
131 |
+
</news>
|
132 |
+
</helpers>
|
133 |
+
</global>
|
134 |
+
</config>
|
app/code/local/GreenPackages/News/sql/news_setup/mysql4-install-0.1.0.php
ADDED
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
$installer = $this;
|
4 |
+
|
5 |
+
$installer->startSetup();
|
6 |
+
|
7 |
+
$installer->run("
|
8 |
+
|
9 |
+
-- DROP TABLE IF EXISTS {$this->getTable('news')};
|
10 |
+
CREATE TABLE {$this->getTable('news')} (
|
11 |
+
`news_id` int(11) unsigned NOT NULL auto_increment,
|
12 |
+
`title` varchar(255) NOT NULL default '',
|
13 |
+
`texto` text NOT NULL default '',
|
14 |
+
`filename` varchar(255) NOT NULL default '',
|
15 |
+
`datefrom` date default NULL,
|
16 |
+
`dateto` date default NULL,
|
17 |
+
`status` tinyint(1) NOT NULL default '0',
|
18 |
+
`amigable` varchar(255) NOT NULL default '',
|
19 |
+
PRIMARY KEY USING BTREE (`news_id`)
|
20 |
+
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
21 |
+
|
22 |
+
");
|
23 |
+
|
24 |
+
$installer->endSetup();
|
app/design/adminhtml/default/default/layout/news.xml
ADDED
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<layout version="0.1.0">
|
3 |
+
<news_adminhtml_news_index>
|
4 |
+
<reference name="content">
|
5 |
+
<block type="news/adminhtml_news" name="news" />
|
6 |
+
</reference>
|
7 |
+
</news_adminhtml_news_index>
|
8 |
+
<news_adminhtml_news_edit>
|
9 |
+
<update handle="editor"/>
|
10 |
+
</news_adminhtml_news_edit>
|
11 |
+
</layout>
|
app/design/frontend/default/default/layout/news.xml
ADDED
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<layout version="0.1.0">
|
3 |
+
<default>
|
4 |
+
|
5 |
+
<reference name="root">
|
6 |
+
<action method="setTemplate"><template>page/2columns-left.phtml</template></action>
|
7 |
+
</reference>
|
8 |
+
<reference name="head">
|
9 |
+
<action method="addCss"><stylesheet>greenpackages/news/news.css</stylesheet></action>
|
10 |
+
</reference>
|
11 |
+
<reference name="top.links">
|
12 |
+
<action method="addLink" translate="label" module="news"><name>News Blog</name><path>news/listado</path><label>News Blog</label><prepare>true</prepare></action>
|
13 |
+
</reference>
|
14 |
+
<reference name="left">
|
15 |
+
<block type="news/listado" name="news.left" template="news/left.phtml"/>
|
16 |
+
</reference>
|
17 |
+
</default>
|
18 |
+
<news_listado_index>
|
19 |
+
<reference name="head">
|
20 |
+
<action method="setTitle" translate="title" module="news"><title>News Blog</title></action>
|
21 |
+
</reference>
|
22 |
+
<reference name="content">
|
23 |
+
<block type="news/listado" name="news.listado" template="news/listado.phtml"/>
|
24 |
+
</reference>
|
25 |
+
</news_listado_index>
|
26 |
+
<news_detalle_index>
|
27 |
+
<reference name="head">
|
28 |
+
<action method="setTitle" translate="title" module="news"><title>News Blog</title></action>
|
29 |
+
</reference>
|
30 |
+
<reference name="content">
|
31 |
+
<block type="news/detalle" name="news.detalle" template="news/detalle.phtml"/>
|
32 |
+
</reference>
|
33 |
+
</news_detalle_index>
|
34 |
+
</layout>
|
app/design/frontend/default/default/template/news/detalle.phtml
ADDED
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
// Detalle de una noticia
|
3 |
+
?>
|
4 |
+
<div class="box cNoticias">
|
5 |
+
<div class="boxFndPie">
|
6 |
+
<div class="head">
|
7 |
+
<h1><?php echo $this->__('News Blog')?></h1>
|
8 |
+
</div>
|
9 |
+
<div class="cNoticia">
|
10 |
+
<?php $news = $this->getLoadedNewsCollection(); ?>
|
11 |
+
<?php if($news){ ?>
|
12 |
+
|
13 |
+
<h4><?php echo $news['title'] ?></h4>
|
14 |
+
|
15 |
+
<div style="float:right;width:200px;margin:10px;margin-right:0px;border:1px solid #e4e4e4;">
|
16 |
+
<ins style="display:inline-table;border:none;height:100px;margin:0;padding:0;position:relative;visibility:visible;width:100%;">
|
17 |
+
<ins style="display:block;border:none;height:100px;margin:0;padding:0;position:relative;visibility:visible;"><?php
|
18 |
+
|
19 |
+
if($news['filename']){
|
20 |
+
|
21 |
+
$dire = $news['filename'];
|
22 |
+
?>
|
23 |
+
<img src="<?php echo $dire; ?>" width="100%" height="100" alt="<?php echo $news['filename']; ?>" title="<?php echo $news['title']; ?>" />
|
24 |
+
<?php
|
25 |
+
}
|
26 |
+
?>
|
27 |
+
</ins>
|
28 |
+
</ins>
|
29 |
+
</div>
|
30 |
+
<p><?php echo nl2br($news['texto']) ?></p>
|
31 |
+
<?php }else{ ?>
|
32 |
+
<p class="msgNoResultados"><?php echo $this->__("At this moment there is no available information in this section. Please, try again in the next days.") ?></p>
|
33 |
+
<?php } ?>
|
34 |
+
</div>
|
35 |
+
</div>
|
36 |
+
</div>
|
37 |
+
|
38 |
+
<div class="buttons-set">
|
39 |
+
<span class="f-left"> <a href="<?php echo $this->getUrl('news/listado') ?>"><?php echo $this->__('Back') ?></a></span>
|
40 |
+
</div>
|
41 |
+
|
42 |
+
|
app/design/frontend/default/default/template/news/left.phtml
ADDED
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<div class="block block-news">
|
2 |
+
<div class="block-title">
|
3 |
+
<strong><?php echo $this->__('News Blog')?></strong>
|
4 |
+
</div>
|
5 |
+
<div class="block-content">
|
6 |
+
<?php $now = now();?>
|
7 |
+
<?php $news = Mage::getModel('news/news')->getCollection()->addFieldToFilter('status', '1')->addFieldToFilter('dateto',array('gteq'=>$now))
|
8 |
+
->setOrder('datefrom','desc');
|
9 |
+
?>
|
10 |
+
<?php if(count($news)>0) :?>
|
11 |
+
<?php $news->getSelect()->limit(5);?>
|
12 |
+
|
13 |
+
<ul>
|
14 |
+
<?php foreach($news as $news) :?>
|
15 |
+
|
16 |
+
|
17 |
+
<li>
|
18 |
+
<a href="<?php echo $this->getUrl('news/detalle', array('id' => $news->getId().'/'.$news->getAmigable().'.html')) ?>"><span ><?php echo $news->getTitle();?></span></a>
|
19 |
+
</li>
|
20 |
+
|
21 |
+
|
22 |
+
<?php endforeach ?>
|
23 |
+
</ul>
|
24 |
+
<?php $allurl = $this->getUrl('news/listado')?>
|
25 |
+
<p class="empty"><a href="<?php echo $allurl?>"><?php echo $this->__('View all')?></a></p>
|
26 |
+
<?php else : ?>
|
27 |
+
<p class="empty"><?php echo $this->__('You have no items in your quote.')?></p>
|
28 |
+
<?php endif;?>
|
29 |
+
</div>
|
30 |
+
|
31 |
+
</div>
|
app/design/frontend/default/default/template/news/listado.phtml
ADDED
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<div class="box cNoticias">
|
2 |
+
<div class="boxFndPie">
|
3 |
+
<div class="head">
|
4 |
+
<h1><?php echo $this->__('News Blog') ?></h1>
|
5 |
+
</div>
|
6 |
+
<div class="cuerpo">
|
7 |
+
<?php $news = $this->getLoadedNewsCollection();?>
|
8 |
+
<?php if($news->getSize() > 0) : ?>
|
9 |
+
<?php echo $this->getToolbarHtml(); ?>
|
10 |
+
<?php foreach ($news as $noticia): ?>
|
11 |
+
<div class="noticia">
|
12 |
+
<div class="content">
|
13 |
+
<h4><a href="<?php echo $this->getUrl('news/detalle', array('id' => $noticia->getId().'/'.$noticia->getAmigable().'.html')) ?>"><?php echo $noticia->getTitle() ?></a></h4>
|
14 |
+
<p class="cBreve"><?php echo nl2br(Mage::helper('core/string')->truncate($noticia->getTexto(),160)); ?></p>
|
15 |
+
<p class="news_more"><span ><a href="<?php echo $this->getUrl('news/detalle', array('id' => $noticia->getId().'/'.$noticia->getAmigable().'.html')) ?>"><?php echo $this->__('Read more')?></a></span></p>
|
16 |
+
</div>
|
17 |
+
<div class="image">
|
18 |
+
<?php if($noticia->getFilename()) : ?>
|
19 |
+
<?php
|
20 |
+
$dire = $noticia->getFilename();?>
|
21 |
+
<img src="<?php echo $dire; ?>" width="100%" alt="<?php echo $noticia->getFilename(); ?>" title="<?php echo $noticia->getTitle(); ?>" />
|
22 |
+
<?php endif;?>
|
23 |
+
</div>
|
24 |
+
</div>
|
25 |
+
<?php endforeach; ?>
|
26 |
+
|
27 |
+
<?php else : ?>
|
28 |
+
<p class="msgNoResultados"><?php echo $this->__("At this moment there is no available information in this section. Please, try again in the next days.") ?></p>
|
29 |
+
<?php endif;?>
|
30 |
+
</div>
|
31 |
+
</div>
|
32 |
+
</div>
|
33 |
+
|
app/design/frontend/default/default/template/news/toolbar.phtml
ADDED
@@ -0,0 +1,48 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
|
2 |
+
<?php if($this->getCollection()->getSize()): ?>
|
3 |
+
<table class="pager" cellspacing="0" style="float:left;width:100%;margin-bottom:20px;">
|
4 |
+
<tr>
|
5 |
+
<td>
|
6 |
+
<?php if($this->getLastPageNum()>1): ?>
|
7 |
+
<?php echo $this->__('%s to %s of %s total', $this->getFirstNum(), $this->getLastNum(), $this->getTotalNum()) ?>
|
8 |
+
<?php else: ?>
|
9 |
+
<?php echo $this->__('Show %s Item(s)', $this->getTotalNum()) ?>
|
10 |
+
<?php endif; ?>
|
11 |
+
</td>
|
12 |
+
<?php if($this->getLastPageNum()>1): ?>
|
13 |
+
<td>
|
14 |
+
<strong><?php echo $this->__('Page:') ?></strong>
|
15 |
+
<ol>
|
16 |
+
<?php if (!$this->isFirstPage()): ?>
|
17 |
+
<li>
|
18 |
+
<a href="<?php echo $this->getPreviousPageUrl() ?>"><img src="<?php echo $this->getSkinUrl('images/pager_arrow_left.gif') ?>" alt="<?php echo $this->__('Previous') ?>"/></a>
|
19 |
+
</li>
|
20 |
+
<?php endif ?>
|
21 |
+
<?php foreach ($this->getPages() as $_page): ?>
|
22 |
+
<?php if ($this->isPageCurrent($_page)): ?>
|
23 |
+
<li><span class="on"><?php echo $_page ?></span></li>
|
24 |
+
<?php else: ?>
|
25 |
+
<li><a href="<?php echo $this->getPageUrl($_page) ?>"><?php echo $_page ?></a></li>
|
26 |
+
<?php endif ?>
|
27 |
+
<?php endforeach;; ?>
|
28 |
+
<?php if (!$this->isLastPage()): ?>
|
29 |
+
<li>
|
30 |
+
<a href="<?php echo $this->getNextPageUrl() ?>"><img src="<?php echo $this->getSkinUrl('images/pager_arrow_right.gif') ?>" alt="<?php echo $this->__('Next') ?>"/></a>
|
31 |
+
</li>
|
32 |
+
<?php endif ?>
|
33 |
+
</ol>
|
34 |
+
</td>
|
35 |
+
<?php endif; ?>
|
36 |
+
<td class="a-right">
|
37 |
+
<?php echo $this->__('Show') ?> <select onchange="setLocation(this.value)">
|
38 |
+
<?php foreach ($this->getAvailableLimit() as $_key=>$_limit): ?>
|
39 |
+
<option value="<?php echo $this->getLimitUrl($_key) ?>"<?php if($this->isLimitCurrent($_key)): ?> selected="selected"<?php endif ?>>
|
40 |
+
<?php echo $_limit ?>
|
41 |
+
</option>
|
42 |
+
<?php endforeach; ?>
|
43 |
+
</select> <?php echo $this->__('per page') ?>
|
44 |
+
</td>
|
45 |
+
</tr>
|
46 |
+
</table>
|
47 |
+
<?php endif ?>
|
48 |
+
|
app/etc/modules/GreenPackages_News.xml
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<modules>
|
4 |
+
<GreenPackages_News>
|
5 |
+
<active>true</active>
|
6 |
+
<codePool>local</codePool>
|
7 |
+
</GreenPackages_News>
|
8 |
+
</modules>
|
9 |
+
</config>
|
package.xml
ADDED
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<package>
|
3 |
+
<name>Greenpackages_News_Blog</name>
|
4 |
+
<version>0.1.0</version>
|
5 |
+
<stability>stable</stability>
|
6 |
+
<license uri="http://opensource.org/licenses/osl-3.0.php">Open Software License (OSL)</license>
|
7 |
+
<channel>community</channel>
|
8 |
+
<extends/>
|
9 |
+
<summary>This extension adds a news &amp; innovations section on the store.</summary>
|
10 |
+
<description>Using this extension you can easily add news with start and end date and upload a image on each news. For news content you can easily enter or modify your text uisng wysiwyg editor.
|
11 |
+
Features:
|
12 |
+
1. No core file changed.
|
13 |
+
2. Small useful extension for merchants.
|
14 |
+
3. Works on Magento 1.6 and above.
|
15 |
+
</description>
|
16 |
+
<notes>Using this extension you can easily add news with start and end date and upload a image on each news. For news content you can easily enter or modify your text uisng wysiwyg editor.
|
17 |
+
Features:
|
18 |
+
1. No core file changed.
|
19 |
+
2. Small useful extension for merchants.
|
20 |
+
3. Works on Magento 1.6 and above.
|
21 |
+
</notes>
|
22 |
+
<authors><author><name>Greenpackages</name><user>Greenpackages</user><email>support@magentogreenpackages.com</email></author></authors>
|
23 |
+
<date>2013-05-15</date>
|
24 |
+
<time>18:47:37</time>
|
25 |
+
<contents><target name="magelocal"><dir name="GreenPackages"><dir name="News"><dir name="Block"><dir name="Adminhtml"><dir name="News"><dir name="Edit"><file name="Form.php" hash="d02a858e968838d39ca5d3c93550a90e"/><dir name="Tab"><file name="Form.php" hash="b2daf4b2faeb59bdaa75eb2b11ad9e65"/></dir><file name="Tabs.php" hash="a3070c166fde08cd7c8a7e17a17fba65"/></dir><file name="Edit.php" hash="e2d93a33b583e94f4decdc05e744c2b4"/><file name="Grid.php" hash="e64ea03302404bc2f1bea45ba24f0f6b"/><dir name="Renderer"><file name="Image.php" hash="895665e01ae1ebe61e98574b1d5c0563"/></dir></dir><file name="News.php" hash="e4ef39ee8595110a1e98756d395ad3ae"/></dir><file name="Breadcrumbs.php" hash="4f0e85e5d6fd4371d4096b04c1c2c075"/><file name="Detalle.php" hash="8d4614543d61d34cd8c7c7298453b558"/><file name="Links.php" hash="7169d394fa4393e1d9f2a7242ad85eb2"/><file name="Listado.php" hash="c9741b475a22ca2d4203222e37cd166e"/><file name="News.php" hash="79c5546d975e3e7ceda22212566cc19a"/><file name="Toolbar.php" hash="b4b3274abd3457cbe721efa08ea93266"/></dir><dir name="Helper"><file name="Data.php" hash="5dd6eac5bb029501ca2ca47aa6b46f3e"/></dir><dir name="Model"><dir name="Mysql4"><dir name="News"><file name="Collection.php" hash="b7cf7322f417411388f30adad8d01a64"/></dir><file name="News.php" hash="1cef8dee339ee8e2ec9821a3e0f02697"/></dir><file name="News.php" hash="7e498f5067576f330c0cbce48e71c78e"/><file name="Status.php" hash="b1fd41246e165ff51b249d57a46f6708"/></dir><dir name="controllers"><dir name="Adminhtml"><file name="NewsController.php" hash="0155b126bb570c1876984cbc88928917"/></dir><file name="DetalleController.php" hash="97f1ba1366df5030be59ad7fa5a836da"/><file name="ListadoController.php" hash="2e89ee76f9d33ba67f6bc59cf9dae9d5"/></dir><dir name="etc"><file name="config.xml" hash="5fc31403a3f3595dc5a2a68bad526616"/></dir><dir name="sql"><dir name="news_setup"><file name="mysql4-install-0.1.0.php" hash="608c85d42b4aea794e1bab4446a92b7b"/></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="GreenPackages_News.xml" hash="1a7af92d1616c6206f93d6cd96f0dbf9"/></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="news.xml" hash="67660e74ee5938d7329704ca837b1a03"/></dir></dir></dir></dir><dir name="frontend"><dir name="default"><dir name="default"><dir name="layout"><file name="news.xml" hash="bc931ef8049097d00f3d39728552412d"/></dir><dir name="template"><dir name="news"><file name="detalle.phtml" hash="0d3f0cf68eb9b7b4286dbf19ce1ef580"/><file name="left.phtml" hash="70c181cfb983f1660e6030a6312e2681"/><file name="listado.phtml" hash="d75c5e3e25c35c853374f56c854e730b"/><file name="toolbar.phtml" hash="a169bbdf61685f5afcc327945909c766"/></dir></dir></dir></dir></dir></target><target name="mageskin"><dir name="frontend"><dir name="default"><dir name="default"><dir name="greenpackages"><dir name="news"><file name="news.css" hash="221c9fe5a389bd694df3f5da4aed32fc"/></dir></dir></dir></dir></dir></target></contents>
|
26 |
+
<compatible/>
|
27 |
+
<dependencies><required><php><min>5.1.0</min><max>5.3.0</max></php></required></dependencies>
|
28 |
+
</package>
|
skin/frontend/default/default/greenpackages/news/news.css
ADDED
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
.block-news .block-content{}
|
2 |
+
.block-news li {list-style:none;padding:8px;}
|
3 |
+
.block-news li a {text-decoration:none;color:#444;}
|
4 |
+
.block-news li a:hover{color:#000;}
|
5 |
+
.block-news .empty a{color:#444;}
|
6 |
+
.noticia .content{width:75%;float:left;}
|
7 |
+
.noticia .image{width:18%;float:right;margin-left:15px;border:1px solid #e4e4e4;}
|
8 |
+
.cuerpo .msgNoResultados{}
|