Version Notes
This is stable version.
Download this release
Release Info
| Developer | pureimagination |
| Extension | PI_News |
| Version | 0.1.0 |
| Comparing to | |
| See all releases | |
Version 0.1.0
- app/code/local/PI/News/Block/Adminhtml/News.php +12 -0
- app/code/local/PI/News/Block/Adminhtml/News/Edit.php +45 -0
- app/code/local/PI/News/Block/Adminhtml/News/Edit/Form.php +19 -0
- app/code/local/PI/News/Block/Adminhtml/News/Edit/Tab/Form.php +79 -0
- app/code/local/PI/News/Block/Adminhtml/News/Edit/Tabs.php +25 -0
- app/code/local/PI/News/Block/Adminhtml/News/Grid.php +135 -0
- app/code/local/PI/News/Block/Breadcrumbs.php +19 -0
- app/code/local/PI/News/Block/Detalle.php +50 -0
- app/code/local/PI/News/Block/Links.php +15 -0
- app/code/local/PI/News/Block/Listado.php +71 -0
- app/code/local/PI/News/Block/News.php +19 -0
- app/code/local/PI/News/Block/Toolbar.php +42 -0
- app/code/local/PI/News/Helper/Data.php +6 -0
- app/code/local/PI/News/Model/Mysql4/News.php +73 -0
- app/code/local/PI/News/Model/Mysql4/News/Collection.php +38 -0
- app/code/local/PI/News/Model/News.php +13 -0
- app/code/local/PI/News/Model/Status.php +15 -0
- app/code/local/PI/News/controllers/Adminhtml/NewsController.php +221 -0
- app/code/local/PI/News/controllers/DetalleController.php +11 -0
- app/code/local/PI/News/controllers/ListadoController.php +22 -0
- app/code/local/PI/News/etc/config.xml +144 -0
- app/code/local/PI/News/sql/news_setup/mysql4-install-0.1.0.php +24 -0
- app/design/adminhtml/default/default/layout/news.xml +8 -0
- app/design/frontend/base/default/layout/news.xml +30 -0
- app/design/frontend/base/default/template/news/detalle.phtml +55 -0
- app/design/frontend/base/default/template/news/left.phtml +32 -0
- app/design/frontend/base/default/template/news/listado.phtml +36 -0
- app/design/frontend/base/default/template/news/toolbar.phtml +48 -0
- app/etc/modules/PI_News.xml +9 -0
- package.xml +18 -0
app/code/local/PI/News/Block/Adminhtml/News.php
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
class PI_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/PI/News/Block/Adminhtml/News/Edit.php
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
class PI_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 |
+
}
|
app/code/local/PI/News/Block/Adminhtml/News/Edit/Form.php
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
class PI_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/PI/News/Block/Adminhtml/News/Edit/Tab/Form.php
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
class PI_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 |
+
$fieldset->addField('title', 'text', array(
|
| 11 |
+
'label' => Mage::helper('news')->__('Title'),
|
| 12 |
+
'class' => 'required-entry',
|
| 13 |
+
'required' => true,
|
| 14 |
+
'name' => 'title',
|
| 15 |
+
));
|
| 16 |
+
|
| 17 |
+
$fieldset->addField('filename', 'file', array(
|
| 18 |
+
'label' => Mage::helper('news')->__('File'),
|
| 19 |
+
'required' => false,
|
| 20 |
+
'name' => 'filename',
|
| 21 |
+
));
|
| 22 |
+
|
| 23 |
+
$dateFormatIso = Mage::app()->getLocale()->getDateFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT);
|
| 24 |
+
|
| 25 |
+
$fieldset->addField('datefrom', 'date', array(
|
| 26 |
+
'name' => 'datefrom',
|
| 27 |
+
'label' => Mage::helper('news')->__('Date From'),
|
| 28 |
+
'title' => Mage::helper('news')->__('Date From'),
|
| 29 |
+
'image' => $this->getSkinUrl('images/grid-cal.gif'),
|
| 30 |
+
'input_format' => Varien_Date::DATE_INTERNAL_FORMAT,
|
| 31 |
+
'format' => $dateFormatIso,
|
| 32 |
+
'required' => true
|
| 33 |
+
));
|
| 34 |
+
$fieldset->addField('dateto', 'date', array(
|
| 35 |
+
'name' => 'dateto',
|
| 36 |
+
'label' => Mage::helper('news')->__('Date To'),
|
| 37 |
+
'title' => Mage::helper('news')->__('Date To'),
|
| 38 |
+
'image' => $this->getSkinUrl('images/grid-cal.gif'),
|
| 39 |
+
'input_format' => Varien_Date::DATE_INTERNAL_FORMAT,
|
| 40 |
+
'format' => $dateFormatIso,
|
| 41 |
+
'required' => true
|
| 42 |
+
));
|
| 43 |
+
|
| 44 |
+
$fieldset->addField('status', 'select', array(
|
| 45 |
+
'label' => Mage::helper('news')->__('Status'),
|
| 46 |
+
'name' => 'status',
|
| 47 |
+
'values' => array(
|
| 48 |
+
array(
|
| 49 |
+
'value' => 1,
|
| 50 |
+
'label' => Mage::helper('news')->__('Enabled'),
|
| 51 |
+
),
|
| 52 |
+
|
| 53 |
+
array(
|
| 54 |
+
'value' => 2,
|
| 55 |
+
'label' => Mage::helper('news')->__('Disabled'),
|
| 56 |
+
),
|
| 57 |
+
),
|
| 58 |
+
));
|
| 59 |
+
|
| 60 |
+
$fieldset->addField('texto', 'editor', array(
|
| 61 |
+
'name' => 'texto',
|
| 62 |
+
'label' => Mage::helper('news')->__('Content'),
|
| 63 |
+
'title' => Mage::helper('news')->__('Content'),
|
| 64 |
+
'style' => 'width:700px; height:500px;',
|
| 65 |
+
'wysiwyg' => false,
|
| 66 |
+
'required' => true,
|
| 67 |
+
));
|
| 68 |
+
|
| 69 |
+
if ( Mage::getSingleton('adminhtml/session')->getNewsData() )
|
| 70 |
+
{
|
| 71 |
+
$form->setValues(Mage::getSingleton('adminhtml/session')->getNewsData());
|
| 72 |
+
Mage::getSingleton('adminhtml/session')->setNewsData(null);
|
| 73 |
+
} elseif ( Mage::registry('news_data') ) {
|
| 74 |
+
$form->setValues(Mage::registry('news_data')->getData());
|
| 75 |
+
}
|
| 76 |
+
|
| 77 |
+
return parent::_prepareForm();
|
| 78 |
+
}
|
| 79 |
+
}
|
app/code/local/PI/News/Block/Adminhtml/News/Edit/Tabs.php
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
class PI_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/PI/News/Block/Adminhtml/News/Grid.php
ADDED
|
@@ -0,0 +1,135 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
class PI_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')->__('Texto'),
|
| 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')->__('Imagen'),
|
| 47 |
+
'align' =>'left',
|
| 48 |
+
'index' => 'filename',
|
| 49 |
+
));
|
| 50 |
+
|
| 51 |
+
$this->addColumn('datefrom',
|
| 52 |
+
array(
|
| 53 |
+
'header'=>Mage::helper('news')->__('Date From'),
|
| 54 |
+
'index'=>'datefrom',
|
| 55 |
+
'gmtoffset' => false,
|
| 56 |
+
'type'=>'date'
|
| 57 |
+
));
|
| 58 |
+
|
| 59 |
+
$this->addColumn('dateto',
|
| 60 |
+
array(
|
| 61 |
+
'header'=>Mage::helper('news')->__('Date To'),
|
| 62 |
+
'index'=>'dateto',
|
| 63 |
+
'gmtoffset' => false,
|
| 64 |
+
'type'=>'date'
|
| 65 |
+
));
|
| 66 |
+
|
| 67 |
+
$this->addColumn('status', array(
|
| 68 |
+
'header' => Mage::helper('news')->__('Status'),
|
| 69 |
+
'align' => 'left',
|
| 70 |
+
'width' => '80px',
|
| 71 |
+
'index' => 'status',
|
| 72 |
+
'type' => 'options',
|
| 73 |
+
'options' => array(
|
| 74 |
+
1 => 'Enabled',
|
| 75 |
+
2 => 'Disabled',
|
| 76 |
+
),
|
| 77 |
+
));
|
| 78 |
+
$this->addColumn('action',
|
| 79 |
+
array(
|
| 80 |
+
'header' => Mage::helper('news')->__('Action'),
|
| 81 |
+
'width' => '100',
|
| 82 |
+
'type' => 'action',
|
| 83 |
+
'getter' => 'getId',
|
| 84 |
+
'actions' => array(
|
| 85 |
+
array(
|
| 86 |
+
'caption' => Mage::helper('news')->__('Edit'),
|
| 87 |
+
'url' => array('base'=> '*/*/edit'),
|
| 88 |
+
'field' => 'id'
|
| 89 |
+
)
|
| 90 |
+
),
|
| 91 |
+
'filter' => false,
|
| 92 |
+
'sortable' => false,
|
| 93 |
+
'index' => 'stores',
|
| 94 |
+
'is_system' => true,
|
| 95 |
+
));
|
| 96 |
+
|
| 97 |
+
$this->addExportType('*/*/exportCsv', Mage::helper('news')->__('CSV'));
|
| 98 |
+
$this->addExportType('*/*/exportXml', Mage::helper('news')->__('XML'));
|
| 99 |
+
|
| 100 |
+
return parent::_prepareColumns();
|
| 101 |
+
}
|
| 102 |
+
|
| 103 |
+
protected function _prepareMassaction()
|
| 104 |
+
{
|
| 105 |
+
$this->setMassactionIdField('news_id');
|
| 106 |
+
$this->getMassactionBlock()->setFormFieldName('news');
|
| 107 |
+
|
| 108 |
+
$this->getMassactionBlock()->addItem('delete', array(
|
| 109 |
+
'label' => Mage::helper('news')->__('Delete'),
|
| 110 |
+
'url' => $this->getUrl('*/*/massDelete'),
|
| 111 |
+
'confirm' => Mage::helper('news')->__('Are you sure?')
|
| 112 |
+
));
|
| 113 |
+
|
| 114 |
+
$statuses = Mage::getSingleton('news/status')->getOptionArray();
|
| 115 |
+
|
| 116 |
+
array_unshift($statuses, array('label'=>'', 'value'=>''));
|
| 117 |
+
$this->getMassactionBlock()->addItem('status', array(
|
| 118 |
+
'label'=> Mage::helper('news')->__('Change status'),
|
| 119 |
+
'url' => $this->getUrl('*/*/massStatus', array('_current'=>true)),
|
| 120 |
+
'additional' => array(
|
| 121 |
+
'visibility' => array(
|
| 122 |
+
'name' => 'status',
|
| 123 |
+
'type' => 'select',
|
| 124 |
+
'class' => 'required-entry',
|
| 125 |
+
'label' => Mage::helper('news')->__('Status'),
|
| 126 |
+
'values' => $statuses
|
| 127 |
+
)
|
| 128 |
+
)
|
| 129 |
+
));
|
| 130 |
+
return $this;
|
| 131 |
+
}
|
| 132 |
+
|
| 133 |
+
|
| 134 |
+
|
| 135 |
+
}
|
app/code/local/PI/News/Block/Breadcrumbs.php
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
class PI_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/PI/News/Block/Detalle.php
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
class PI_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/PI/News/Block/Links.php
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
class PI_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/PI/News/Block/Listado.php
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
class PI_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/PI/News/Block/News.php
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
class PI_News_Block_News extends Mage_Core_Block_Template
|
| 3 |
+
{
|
| 4 |
+
|
| 5 |
+
public function _prepareLayout()
|
| 6 |
+
{
|
| 7 |
+
return parent::_prepareLayout();
|
| 8 |
+
}
|
| 9 |
+
|
| 10 |
+
public function getNews()
|
| 11 |
+
{
|
| 12 |
+
if (!$this->hasData('news')) {
|
| 13 |
+
$this->setData('news', Mage::registry('news'));
|
| 14 |
+
}
|
| 15 |
+
return $this->getData('news');
|
| 16 |
+
|
| 17 |
+
}
|
| 18 |
+
|
| 19 |
+
}
|
app/code/local/PI/News/Block/Toolbar.php
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
class PI_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/PI/News/Helper/Data.php
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
class PI_News_Helper_Data extends Mage_Core_Helper_Abstract
|
| 4 |
+
{
|
| 5 |
+
|
| 6 |
+
}
|
app/code/local/PI/News/Model/Mysql4/News.php
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
class PI_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/PI/News/Model/Mysql4/News/Collection.php
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
class PI_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/PI/News/Model/News.php
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
class PI_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/PI/News/Model/Status.php
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
class PI_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/PI/News/controllers/Adminhtml/NewsController.php
ADDED
|
@@ -0,0 +1,221 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
class PI_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 |
+
//print_r($data);die();
|
| 57 |
+
|
| 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') . DS . 'news' . DS;
|
| 75 |
+
$uploader->save($path, $_FILES['filename']['name'] );
|
| 76 |
+
|
| 77 |
+
} catch (Exception $e) {
|
| 78 |
+
|
| 79 |
+
}
|
| 80 |
+
|
| 81 |
+
//this way the name is saved in DB
|
| 82 |
+
$data['filename'] = $_FILES['filename']['name'];
|
| 83 |
+
}
|
| 84 |
+
|
| 85 |
+
|
| 86 |
+
$model = Mage::getModel('news/news');
|
| 87 |
+
$model->setData($data)
|
| 88 |
+
->setId($this->getRequest()->getParam('id'));
|
| 89 |
+
|
| 90 |
+
try {
|
| 91 |
+
|
| 92 |
+
$model->save();
|
| 93 |
+
Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('news')->__('News was successfully saved'));
|
| 94 |
+
Mage::getSingleton('adminhtml/session')->setFormData(false);
|
| 95 |
+
|
| 96 |
+
if ($this->getRequest()->getParam('back')) {
|
| 97 |
+
$this->_redirect('*/*/edit', array('id' => $model->getId()));
|
| 98 |
+
return;
|
| 99 |
+
}
|
| 100 |
+
$this->_redirect('*/*/');
|
| 101 |
+
return;
|
| 102 |
+
} catch (Exception $e) {
|
| 103 |
+
Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
|
| 104 |
+
Mage::getSingleton('adminhtml/session')->setFormData($data);
|
| 105 |
+
$this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
|
| 106 |
+
return;
|
| 107 |
+
}
|
| 108 |
+
}
|
| 109 |
+
Mage::getSingleton('adminhtml/session')->addError(Mage::helper('news')->__('Unable to find news to save'));
|
| 110 |
+
$this->_redirect('*/*/');
|
| 111 |
+
}
|
| 112 |
+
/*-------------------delete specific news---------*/
|
| 113 |
+
public function deleteAction() {
|
| 114 |
+
if( $this->getRequest()->getParam('id') > 0 ) {
|
| 115 |
+
try {
|
| 116 |
+
$model = Mage::getModel('news/news');
|
| 117 |
+
|
| 118 |
+
$model->setId($this->getRequest()->getParam('id'))
|
| 119 |
+
->delete();
|
| 120 |
+
|
| 121 |
+
Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('adminhtml')->__('News was successfully deleted'));
|
| 122 |
+
$this->_redirect('*/*/');
|
| 123 |
+
} catch (Exception $e) {
|
| 124 |
+
Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
|
| 125 |
+
$this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
|
| 126 |
+
}
|
| 127 |
+
}
|
| 128 |
+
$this->_redirect('*/*/');
|
| 129 |
+
}
|
| 130 |
+
/*-------------------delete all selected news---------*/
|
| 131 |
+
public function massDeleteAction() {
|
| 132 |
+
|
| 133 |
+
$newsIds = $this->getRequest()->getParam('news');
|
| 134 |
+
if(!is_array($newsIds)) {
|
| 135 |
+
Mage::getSingleton('adminhtml/session')->addError(Mage::helper('adminhtml')->__('Please select news(s)'));
|
| 136 |
+
} else {
|
| 137 |
+
try {
|
| 138 |
+
foreach ($newsIds as $newsId) {
|
| 139 |
+
$news = Mage::getModel('news/news')->load($newsId);
|
| 140 |
+
$news->delete();
|
| 141 |
+
}
|
| 142 |
+
Mage::getSingleton('adminhtml/session')->addSuccess(
|
| 143 |
+
Mage::helper('adminhtml')->__(
|
| 144 |
+
'Total of %d record(s) were successfully deleted', count($newsIds)
|
| 145 |
+
)
|
| 146 |
+
);
|
| 147 |
+
} catch (Exception $e) {
|
| 148 |
+
Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
|
| 149 |
+
}
|
| 150 |
+
}
|
| 151 |
+
|
| 152 |
+
|
| 153 |
+
$this->_redirect('*/*/index');
|
| 154 |
+
}
|
| 155 |
+
/*-------------------change status of all selected news---------*/
|
| 156 |
+
public function massStatusAction()
|
| 157 |
+
{
|
| 158 |
+
$newsIds = $this->getRequest()->getParam('news');
|
| 159 |
+
|
| 160 |
+
Mage::log('status change');
|
| 161 |
+
Mage::log($newsIds);
|
| 162 |
+
|
| 163 |
+
|
| 164 |
+
if(!is_array($newsIds)) {
|
| 165 |
+
Mage::getModel('adminhtml/session')->addError($this->__('Please select news(s)'));
|
| 166 |
+
} else {
|
| 167 |
+
try {
|
| 168 |
+
|
| 169 |
+
foreach ($newsIds as $newsId) {
|
| 170 |
+
$news = Mage::getSingleton('news/news')
|
| 171 |
+
->load($newsId)
|
| 172 |
+
->setPublicar($this->getRequest()->getParam('status'))
|
| 173 |
+
->setIsMassupdate(true)
|
| 174 |
+
->save();
|
| 175 |
+
}
|
| 176 |
+
|
| 177 |
+
|
| 178 |
+
$this->_getSession()->addSuccess(
|
| 179 |
+
$this->__('Total of %d record(s) were successfully updated', count($newsIds))
|
| 180 |
+
);
|
| 181 |
+
} catch (Exception $e) {
|
| 182 |
+
$this->_getSession()->addError($e->getMessage());
|
| 183 |
+
}
|
| 184 |
+
}
|
| 185 |
+
$this->_redirect('*/*/index');
|
| 186 |
+
}
|
| 187 |
+
|
| 188 |
+
public function exportCsvAction()
|
| 189 |
+
{
|
| 190 |
+
$fileName = 'news.csv';
|
| 191 |
+
$content = $this->getLayout()->createBlock('news/adminhtml_news_grid')
|
| 192 |
+
->getCsv();
|
| 193 |
+
|
| 194 |
+
$this->_sendUploadResponse($fileName, $content);
|
| 195 |
+
}
|
| 196 |
+
|
| 197 |
+
public function exportXmlAction()
|
| 198 |
+
{
|
| 199 |
+
$fileName = 'news.xml';
|
| 200 |
+
$content = $this->getLayout()->createBlock('news/adminhtml_news_grid')
|
| 201 |
+
->getXml();
|
| 202 |
+
|
| 203 |
+
$this->_sendUploadResponse($fileName, $content);
|
| 204 |
+
}
|
| 205 |
+
|
| 206 |
+
protected function _sendUploadResponse($fileName, $content, $contentType='application/octet-stream')
|
| 207 |
+
{
|
| 208 |
+
$response = $this->getResponse();
|
| 209 |
+
$response->setHeader('HTTP/1.1 200 OK','');
|
| 210 |
+
$response->setHeader('Pragma', 'public', true);
|
| 211 |
+
$response->setHeader('Cache-Control', 'must-revalidate, post-check=0, pre-check=0', true);
|
| 212 |
+
$response->setHeader('Content-Disposition', 'attachment; filename='.$fileName);
|
| 213 |
+
$response->setHeader('Last-Modified', date('r'));
|
| 214 |
+
$response->setHeader('Accept-Ranges', 'bytes');
|
| 215 |
+
$response->setHeader('Content-Length', strlen($content));
|
| 216 |
+
$response->setHeader('Content-type', $contentType);
|
| 217 |
+
$response->setBody($content);
|
| 218 |
+
$response->sendResponse();
|
| 219 |
+
die;
|
| 220 |
+
}
|
| 221 |
+
}
|
app/code/local/PI/News/controllers/DetalleController.php
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
class PI_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/PI/News/controllers/ListadoController.php
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
|
| 3 |
+
class PI_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/PI/News/etc/config.xml
ADDED
|
@@ -0,0 +1,144 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0"?>
|
| 2 |
+
<config>
|
| 3 |
+
<modules>
|
| 4 |
+
<PI_News>
|
| 5 |
+
<version>0.1.0</version>
|
| 6 |
+
</PI_News>
|
| 7 |
+
</modules>
|
| 8 |
+
<frontend>
|
| 9 |
+
<routers>
|
| 10 |
+
<news>
|
| 11 |
+
<use>standard</use>
|
| 12 |
+
<args>
|
| 13 |
+
<module>PI_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 |
+
<PI_News>
|
| 31 |
+
<files>
|
| 32 |
+
<default>PI_News.csv</default>
|
| 33 |
+
</files>
|
| 34 |
+
</PI_News>
|
| 35 |
+
</modules>
|
| 36 |
+
</translate>
|
| 37 |
+
|
| 38 |
+
</frontend>
|
| 39 |
+
<admin>
|
| 40 |
+
<routers>
|
| 41 |
+
<news>
|
| 42 |
+
<use>admin</use>
|
| 43 |
+
<args>
|
| 44 |
+
<module>PI_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>News</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 |
+
<PI_News>
|
| 73 |
+
<title>News Module</title>
|
| 74 |
+
<sort_order>10</sort_order>
|
| 75 |
+
</PI_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 |
+
<translate>
|
| 88 |
+
<modules>
|
| 89 |
+
<pi_adminhtml>
|
| 90 |
+
<files>
|
| 91 |
+
<news>PI_News.csv</news>
|
| 92 |
+
</files>
|
| 93 |
+
</pi_adminhtml>
|
| 94 |
+
</modules>
|
| 95 |
+
</translate>
|
| 96 |
+
|
| 97 |
+
</adminhtml>
|
| 98 |
+
<global>
|
| 99 |
+
<models>
|
| 100 |
+
<news>
|
| 101 |
+
<class>PI_News_Model</class>
|
| 102 |
+
<resourceModel>news_mysql4</resourceModel>
|
| 103 |
+
</news>
|
| 104 |
+
<news_mysql4>
|
| 105 |
+
<class>PI_News_Model_Mysql4</class>
|
| 106 |
+
<entities>
|
| 107 |
+
<news>
|
| 108 |
+
<table>news</table>
|
| 109 |
+
</news>
|
| 110 |
+
</entities>
|
| 111 |
+
</news_mysql4>
|
| 112 |
+
</models>
|
| 113 |
+
<resources>
|
| 114 |
+
<news_setup>
|
| 115 |
+
<setup>
|
| 116 |
+
<module>PI_News</module>
|
| 117 |
+
</setup>
|
| 118 |
+
<connection>
|
| 119 |
+
<use>core_setup</use>
|
| 120 |
+
</connection>
|
| 121 |
+
</news_setup>
|
| 122 |
+
<news_write>
|
| 123 |
+
<connection>
|
| 124 |
+
<use>core_write</use>
|
| 125 |
+
</connection>
|
| 126 |
+
</news_write>
|
| 127 |
+
<news_read>
|
| 128 |
+
<connection>
|
| 129 |
+
<use>core_read</use>
|
| 130 |
+
</connection>
|
| 131 |
+
</news_read>
|
| 132 |
+
</resources>
|
| 133 |
+
<blocks>
|
| 134 |
+
<news>
|
| 135 |
+
<class>PI_News_Block</class>
|
| 136 |
+
</news>
|
| 137 |
+
</blocks>
|
| 138 |
+
<helpers>
|
| 139 |
+
<news>
|
| 140 |
+
<class>PI_News_Helper</class>
|
| 141 |
+
</news>
|
| 142 |
+
</helpers>
|
| 143 |
+
</global>
|
| 144 |
+
</config>
|
app/code/local/PI/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,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
+
</layout>
|
app/design/frontend/base/default/layout/news.xml
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0"?>
|
| 2 |
+
<layout version="0.1.0">
|
| 3 |
+
<default>
|
| 4 |
+
<reference name="root">
|
| 5 |
+
<action method="setTemplate"><template>page/2columns-left.phtml</template></action>
|
| 6 |
+
</reference>
|
| 7 |
+
<reference name="top.links">
|
| 8 |
+
<action method="addLink" translate="label" module="news"><name>News And Innovation</name><path>news/listado</path><label>News And Innovation</label><prepare>true</prepare></action>
|
| 9 |
+
</reference>
|
| 10 |
+
<reference name="left">
|
| 11 |
+
<block type="news/listado" name="news.left" template="news/left.phtml"/>
|
| 12 |
+
</reference>
|
| 13 |
+
</default>
|
| 14 |
+
<news_listado_index>
|
| 15 |
+
<reference name="head">
|
| 16 |
+
<action method="setTitle" translate="title" module="news"><title>News and Innovations</title></action>
|
| 17 |
+
</reference>
|
| 18 |
+
<reference name="content">
|
| 19 |
+
<block type="news/listado" name="news.listado" template="news/listado.phtml"/>
|
| 20 |
+
</reference>
|
| 21 |
+
</news_listado_index>
|
| 22 |
+
<news_detalle_index>
|
| 23 |
+
<reference name="head">
|
| 24 |
+
<action method="setTitle" translate="title" module="news"><title>News and Innovations</title></action>
|
| 25 |
+
</reference>
|
| 26 |
+
<reference name="content">
|
| 27 |
+
<block type="news/detalle" name="news.detalle" template="news/detalle.phtml"/>
|
| 28 |
+
</reference>
|
| 29 |
+
</news_detalle_index>
|
| 30 |
+
</layout>
|
app/design/frontend/base/default/template/news/detalle.phtml
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<style>
|
| 2 |
+
.news_more
|
| 3 |
+
{
|
| 4 |
+
margin-left:5px;
|
| 5 |
+
text-decoration:underline;
|
| 6 |
+
}
|
| 7 |
+
.news_more a:hover
|
| 8 |
+
{
|
| 9 |
+
color:#3a579f;
|
| 10 |
+
}
|
| 11 |
+
</style>
|
| 12 |
+
<?php
|
| 13 |
+
// Detalle de una noticia
|
| 14 |
+
?>
|
| 15 |
+
<div class="box cNoticias">
|
| 16 |
+
<div class="boxFndPie">
|
| 17 |
+
<div class="head">
|
| 18 |
+
<h1><?php echo $this->__('News & Innovations')?></h1>
|
| 19 |
+
</div>
|
| 20 |
+
<div class="cNoticia">
|
| 21 |
+
<?php $news = $this->getLoadedNewsCollection(); ?>
|
| 22 |
+
<?php if($news){ ?>
|
| 23 |
+
|
| 24 |
+
<h4><?php echo $news['title'] ?></h4>
|
| 25 |
+
|
| 26 |
+
<div style="float:right;width:200px;margin:10px;margin-right:0px;border:1px solid #e4e4e4;">
|
| 27 |
+
<ins style="display:inline-table;border:none;height:100px;margin:0;padding:0;position:relative;visibility:visible;width:100%;">
|
| 28 |
+
<ins style="display:block;border:none;height:100px;margin:0;padding:0;position:relative;visibility:visible;"><?php
|
| 29 |
+
|
| 30 |
+
if($news['filename']){
|
| 31 |
+
$location = Mage::getStoreConfig('web/secure/base_url');
|
| 32 |
+
$dire = $location . 'media/news/' . $news['filename'];
|
| 33 |
+
?>
|
| 34 |
+
<img src="<?php echo $dire; ?>" width="100%" height="100" alt="<?php echo $news['filename']; ?>" title="<?php echo $news['title']; ?>" />
|
| 35 |
+
<?php
|
| 36 |
+
}
|
| 37 |
+
?>
|
| 38 |
+
</ins>
|
| 39 |
+
</ins>
|
| 40 |
+
</div>
|
| 41 |
+
<p><?php echo nl2br($news['texto']) ?></p>
|
| 42 |
+
<?php }else{ ?>
|
| 43 |
+
<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>
|
| 44 |
+
<?php } ?>
|
| 45 |
+
</div>
|
| 46 |
+
</div>
|
| 47 |
+
</div>
|
| 48 |
+
<div style="width:100%;height:auto;float:left;margin-top:0px;">
|
| 49 |
+
<div style="width:94%;margin:0 auto;">
|
| 50 |
+
<div class="buttons-set">
|
| 51 |
+
<span class="f-right news_more"> <a href="<?php echo $this->getUrl('news/listado') ?>"><?php echo $this->__('Back') ?></a></span>
|
| 52 |
+
</div>
|
| 53 |
+
</div>
|
| 54 |
+
</div>
|
| 55 |
+
|
app/design/frontend/base/default/template/news/left.phtml
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
<div class="block block-news">
|
| 3 |
+
<div class="block-title">
|
| 4 |
+
<strong><?php echo $this->__('News & Innovations')?></strong>
|
| 5 |
+
</div>
|
| 6 |
+
<div class="block-content">
|
| 7 |
+
<?php $now = now();?>
|
| 8 |
+
<?php $news = Mage::getModel('news/news')->getCollection()->addFieldToFilter('status', '1')->addFieldToFilter('dateto',array('gteq'=>$now))
|
| 9 |
+
->setOrder('datefrom','desc');
|
| 10 |
+
?>
|
| 11 |
+
<?php if(count($news)>0) :?>
|
| 12 |
+
<?php $news->getSelect()->limit(5);?>
|
| 13 |
+
|
| 14 |
+
<ol>
|
| 15 |
+
<?php foreach($news as $news) :?>
|
| 16 |
+
|
| 17 |
+
|
| 18 |
+
<li style="padding:8px;">
|
| 19 |
+
<a href="<?php echo $this->getUrl('news/detalle', array('id' => $news->getId().'/'.$news->getAmigable().'.html')) ?>"><span ><?php echo $news->getTitle();?></span></a>
|
| 20 |
+
</li>
|
| 21 |
+
|
| 22 |
+
|
| 23 |
+
<?php endforeach ?>
|
| 24 |
+
</ol>
|
| 25 |
+
<?php $allurl = $this->getUrl('news/listado')?>
|
| 26 |
+
<p class="empty"><a href="<?php echo $allurl?>"><?php echo $this->__('View all')?></a></p>
|
| 27 |
+
<?php else : ?>
|
| 28 |
+
<p class="empty"><?php echo $this->__('You have no items in your quote.')?></p>
|
| 29 |
+
<?php endif;?>
|
| 30 |
+
</div>
|
| 31 |
+
|
| 32 |
+
</div>
|
app/design/frontend/base/default/template/news/listado.phtml
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<div class="box cNoticias">
|
| 2 |
+
<div class="boxFndPie">
|
| 3 |
+
<div class="head">
|
| 4 |
+
<h1><span><?php echo $this->__('News')?></span><?php echo $this->__(' & Innovations') ?></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 style="width:75%;float:left;">
|
| 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" style="margin-left:0px;"><?php echo nl2br(Mage::helper('core/string')->truncate($noticia->getTexto(),160)); ?></p>
|
| 15 |
+
<p style="text-align:right;"><span class="news_more"><a href="<?php echo $this->getUrl('news/detalle', array('id' => $noticia->getId().'/'.$noticia->getAmigable().'.html')) ?>"><?php echo $this->__('more')?></a></span></p>
|
| 16 |
+
</div>
|
| 17 |
+
<div style="width:18%;float:right;margin-left:15px;border:1px solid #e4e4e4;">
|
| 18 |
+
<?php if($noticia->getFilename()) : ?>
|
| 19 |
+
<?php $location = Mage::getStoreConfig('web/secure/base_url');
|
| 20 |
+
$dire = $location . 'media/news/' . $noticia->getFilename();?>
|
| 21 |
+
|
| 22 |
+
|
| 23 |
+
|
| 24 |
+
<img src="<?php echo $dire; ?>" width="100%" alt="<?php echo $noticia->getFilename(); ?>" title="<?php echo $noticia->getTitle(); ?>" />
|
| 25 |
+
<?php endif;?>
|
| 26 |
+
</div>
|
| 27 |
+
</div>
|
| 28 |
+
<?php endforeach; ?>
|
| 29 |
+
|
| 30 |
+
<?php else : ?>
|
| 31 |
+
<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>
|
| 32 |
+
<?php endif;?>
|
| 33 |
+
</div>
|
| 34 |
+
</div>
|
| 35 |
+
</div>
|
| 36 |
+
|
app/design/frontend/base/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/PI_News.xml
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0"?>
|
| 2 |
+
<config>
|
| 3 |
+
<modules>
|
| 4 |
+
<PI_News>
|
| 5 |
+
<active>true</active>
|
| 6 |
+
<codePool>local</codePool>
|
| 7 |
+
</PI_News>
|
| 8 |
+
</modules>
|
| 9 |
+
</config>
|
package.xml
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?xml version="1.0"?>
|
| 2 |
+
<package>
|
| 3 |
+
<name>PI_News</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 is use to add news section.</summary>
|
| 10 |
+
<description>You can use this extension in order to add news on your site, it will provide you a section in admin so that you can add your news from their.</description>
|
| 11 |
+
<notes>This is stable version.</notes>
|
| 12 |
+
<authors><author><name>pureimagination</name><user>pureimagination</user><email>johncarter15oct@gmail.com</email></author></authors>
|
| 13 |
+
<date>2015-06-18</date>
|
| 14 |
+
<time>16:25:47</time>
|
| 15 |
+
<contents><target name="magelocal"><dir name="PI"><dir name="News"><dir name="Block"><dir name="Adminhtml"><dir name="News"><dir name="Edit"><file name="Form.php" hash="1ac1491599ff1c0870d88030e667efbd"/><dir name="Tab"><file name="Form.php" hash="74d188cddbdcf01c2ef1f618ab268e7d"/></dir><file name="Tabs.php" hash="996795acd3335e02f75acd210c501f5c"/></dir><file name="Edit.php" hash="b996b64fb428e5b8e1872c71094e394c"/><file name="Grid.php" hash="f3b8fe2a42b13da94cbfcee05a81fda7"/></dir><file name="News.php" hash="e958a1fcd4145779aff9ab3a52cba8d9"/></dir><file name="Breadcrumbs.php" hash="62c36306a8ac7d5cf6f26e1c2461e70d"/><file name="Detalle.php" hash="bdd265cc4e8a5977e64a78158b960c22"/><file name="Links.php" hash="b290bd4745402ddecc042316a1510c34"/><file name="Listado.php" hash="31da5237bc74746ffa07556b99f81aba"/><file name="News.php" hash="f9fe56d9a678c8b5518251970e5f48cf"/><file name="Toolbar.php" hash="ba25b11f8696931ae6da7c49e8821115"/></dir><dir name="Helper"><file name="Data.php" hash="40bfbd01ec85d2126c81b64821490fc2"/></dir><dir name="Model"><dir name="Mysql4"><dir name="News"><file name="Collection.php" hash="4d12f5d2f1a553bdcdf4546ada2c55fa"/></dir><file name="News.php" hash="b1c1e1a62756fa75b60abf89b9f5c4ce"/></dir><file name="News.php" hash="b066a6dabffaa54a1da4d03bf0ef50ee"/><file name="Status.php" hash="5390cd50d8a382503499d55379163b0c"/></dir><dir name="controllers"><dir name="Adminhtml"><file name="NewsController.php" hash="32823183f7d19ce1187c2441fbb7dcc2"/></dir><file name="DetalleController.php" hash="c060fdd047f2978cc5aa31332c02cfeb"/><file name="ListadoController.php" hash="e916d68ff789d1136b5fdd20c46294ec"/></dir><dir name="etc"><file name="config.xml" hash="5940cb0cc6fa9227273b6a56dfc4bdac"/></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="PI_News.xml" hash="e3b1a6f16ca01f9be7c256cc975fd190"/></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="news.xml" hash="b9e289df44e9d80094e7266270230d68"/></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="template"><dir name="news"><file name="detalle.phtml" hash="4406f7557d76818f3d72e4e041bf7f5b"/><file name="left.phtml" hash="ef9cee1f226bfa432a5132b02118b68b"/><file name="listado.phtml" hash="1f520bc2f2c9d9ce07922bad4946002d"/><file name="toolbar.phtml" hash="a169bbdf61685f5afcc327945909c766"/></dir></dir><dir name="layout"><file name="news.xml" hash="cda1def5de651cf48d3b472e29f503b0"/></dir></dir></dir></dir></target></contents>
|
| 16 |
+
<compatible/>
|
| 17 |
+
<dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
|
| 18 |
+
</package>
|
