Krishinc_Videogallery - Version 0.1.0

Version Notes

Fixed minor bug

Download this release

Release Info

Developer Mayank Zalavadia
Extension Krishinc_Videogallery
Version 0.1.0
Comparing to
See all releases


Version 0.1.0

Files changed (23) hide show
  1. app/code/community/Krishinc/Videogallery/Block/Adminhtml/Videogallery.php +14 -0
  2. app/code/community/Krishinc/Videogallery/Block/Adminhtml/Videogallery/Edit.php +26 -0
  3. app/code/community/Krishinc/Videogallery/Block/Adminhtml/Videogallery/Edit/Form.php +19 -0
  4. app/code/community/Krishinc/Videogallery/Block/Adminhtml/Videogallery/Edit/Tab/Form.php +47 -0
  5. app/code/community/Krishinc/Videogallery/Block/Adminhtml/Videogallery/Edit/Tabs.php +23 -0
  6. app/code/community/Krishinc/Videogallery/Block/Adminhtml/Videogallery/Grid.php +136 -0
  7. app/code/community/Krishinc/Videogallery/Block/Product/Videogallery.php +34 -0
  8. app/code/community/Krishinc/Videogallery/Block/Renderer/Image.php +27 -0
  9. app/code/community/Krishinc/Videogallery/Block/Videogallery.php +49 -0
  10. app/code/community/Krishinc/Videogallery/Helper/Data.php +6 -0
  11. app/code/community/Krishinc/Videogallery/Model/Mysql4/Videogallery.php +9 -0
  12. app/code/community/Krishinc/Videogallery/Model/Mysql4/Videogallery/Collection.php +8 -0
  13. app/code/community/Krishinc/Videogallery/Model/Videogallery.php +49 -0
  14. app/code/community/Krishinc/Videogallery/controllers/Adminhtml/VideogalleryController.php +255 -0
  15. app/code/community/Krishinc/Videogallery/controllers/IndexController.php +16 -0
  16. app/code/community/Krishinc/Videogallery/etc/config.xml +144 -0
  17. app/code/community/Krishinc/Videogallery/etc/system.xml +68 -0
  18. app/code/community/Krishinc/Videogallery/sql/videogallery_setup/mysql4-install-0.1.0.php +17 -0
  19. app/design/frontend/default/default/layout/videogallery.xml +41 -0
  20. app/design/frontend/default/default/template/videogallery/videogallery.phtml +87 -0
  21. app/design/frontend/default/default/template/videogallery/videogallerylist.phtml +85 -0
  22. app/etc/modules/Krishinc_Videogallery.xml +9 -0
  23. package.xml +29 -0
app/code/community/Krishinc/Videogallery/Block/Adminhtml/Videogallery.php ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Krishinc_Videogallery_Block_Adminhtml_Videogallery extends Mage_Adminhtml_Block_Widget_Grid_Container
3
+ {
4
+ public function __construct()
5
+ {
6
+ $this->_controller = 'adminhtml_videogallery';
7
+ $this->_blockGroup = 'videogallery';
8
+
9
+ $this->_headerText = Mage::helper('videogallery')->__('Videogallery Manager');
10
+ $this->_addButtonLabel = Mage::helper('videogallery')->__('Add New Videogallery');
11
+
12
+ parent::__construct();
13
+ }
14
+ }
app/code/community/Krishinc/Videogallery/Block/Adminhtml/Videogallery/Edit.php ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Krishinc_Videogallery_Block_Adminhtml_Videogallery_Edit extends Mage_Adminhtml_Block_Widget_Form_Container
3
+ {
4
+ public function __construct()
5
+ {
6
+ parent::__construct();
7
+
8
+ $this->_objectId = 'id';
9
+ $this->_blockGroup = 'videogallery';
10
+ $this->_controller = 'adminhtml_videogallery';
11
+
12
+ $this->_updateButton('save', 'label', Mage::helper('videogallery')->__('Save Video'));
13
+ $this->_updateButton('delete', 'label', Mage::helper('videogallery')->__('Delete Video'));
14
+ $this->_updateButton('delete', 'onclick', 'deleteConfirm(\'Are you sure you want to do this?\', \'' .$this->getUrl('videogallery/adminhtml_videogallery/delete/videogallery_id/', array('videogallery_id' => $this->getRequest()->getParam('id'))).'\')');
15
+ }
16
+
17
+ public function getHeaderText()
18
+ {
19
+ if( Mage::registry('videogallery_data') && Mage::registry('videogallery_data')->getId() ) {
20
+
21
+ return Mage::helper('videogallery')->__("Edit Videogallery '%s'", $this->htmlEscape(Mage::registry('videogallery_data')->getName()));
22
+ } else {
23
+ return Mage::helper('videogallery')->__('Add New Video Information');
24
+ }
25
+ }
26
+ }
app/code/community/Krishinc/Videogallery/Block/Adminhtml/Videogallery/Edit/Form.php ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Krishinc_Videogallery_Block_Adminhtml_Videogallery_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/community/Krishinc/Videogallery/Block/Adminhtml/Videogallery/Edit/Tab/Form.php ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Krishinc_Videogallery_Block_Adminhtml_Videogallery_Edit_Tab_Form extends Mage_Adminhtml_Block_Widget_Form
3
+ {
4
+ protected function _prepareForm()
5
+ {
6
+ $form = new Varien_Data_Form();
7
+ $this->setForm($form);
8
+ $fieldset = $form->addFieldset('Videogallery_form', array('legend'=>Mage::helper('videogallery')->__('Video information')));
9
+
10
+ $fieldset->addField('videogallery_url', 'text', array(
11
+ 'label' => Mage::helper('videogallery')->__('Youtube Video Url'),
12
+ 'class' => 'required-entry',
13
+ 'required' => true,
14
+ 'style' => 'width:100%;',
15
+ 'name' => 'videogallery_url',
16
+ 'after_element_html' => '<p class="note"><span>I.e. : http://www.youtube.com/watch?v=mFBIsCyI0PA</span></p>',
17
+ ));
18
+
19
+ $fieldset->addField('videogallery_category', 'text', array(
20
+ 'label' => Mage::helper('videogallery')->__('Video Category'),
21
+ 'required' => false,
22
+ 'style' => 'width:100%;',
23
+ 'name' => 'videogallery_category',
24
+ 'after_element_html' => '<p class="note"><span>I.e. : Yoga</span></p>',
25
+ ));
26
+ if ( Mage::getSingleton('adminhtml/session')->getVideogalleryData() )
27
+ {
28
+ $form->setValues(Mage::getSingleton('adminhtml/session')->getVideogalleryData());
29
+ Mage::getSingleton('adminhtml/session')->setVideogalleryData(null);
30
+ } elseif ( Mage::registry('videogallery_data') ) {
31
+ $form->setValues(Mage::registry('videogallery_data')->getData());
32
+ }
33
+ return parent::_prepareForm();
34
+ }
35
+ protected function getAllManu()
36
+ {
37
+ $product = Mage::getModel('catalog/product');
38
+ $attributes = Mage::getResourceModel('eav/entity_attribute_collection')
39
+ ->setEntityTypeFilter($product->getResource()->getTypeId())
40
+ ->addFieldToFilter('attribute_code', 'videogallery'); //can be changed to any attribute
41
+ $attribute = $attributes->getFirstItem()->setEntity($product->getResource());
42
+ $videogallerys = $attribute->getSource()->getAllOptions(false);
43
+
44
+ return $videogallerys;
45
+ }
46
+
47
+ }
app/code/community/Krishinc/Videogallery/Block/Adminhtml/Videogallery/Edit/Tabs.php ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Krishinc_Videogallery_Block_Adminhtml_Videogallery_Edit_Tabs extends Mage_Adminhtml_Block_Widget_Tabs
4
+ {
5
+
6
+ public function __construct()
7
+ {
8
+ parent::__construct();
9
+ $this->setId('videogallery_tabs');
10
+ $this->setDestElementId('edit_form');
11
+ $this->setTitle(Mage::helper('videogallery')->__('Video Information'));
12
+ }
13
+
14
+ protected function _beforeToHtml()
15
+ {
16
+ $this->addTab('form_section', array(
17
+ 'label' => Mage::helper('videogallery')->__('Video Information'),
18
+ 'title' => Mage::helper('videogallery')->__('Video Information'),
19
+ 'content' => $this->getLayout()->createBlock('videogallery/adminhtml_videogallery_edit_tab_form')->toHtml(),
20
+ ));
21
+ return parent::_beforeToHtml();
22
+ }
23
+ }
app/code/community/Krishinc/Videogallery/Block/Adminhtml/Videogallery/Grid.php ADDED
@@ -0,0 +1,136 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Krishinc_Videogallery_Block_Adminhtml_Videogallery_Grid extends Mage_Adminhtml_Block_Widget_Grid
3
+ {
4
+ public function __construct()
5
+ {
6
+ parent::__construct();
7
+ $this->setId('videogalleryGrid');
8
+ // This is the primary key of the database
9
+ $this->setDefaultSort('videogallery_id');
10
+ $this->setDefaultDir('DESC');
11
+ $this->setSaveParametersInSession(true);
12
+ //$this->setUseAjax(true);
13
+ }
14
+ protected function _prepareCollection() {
15
+
16
+ $collection = Mage::getModel('videogallery/videogallery')->getCollection();
17
+ $session = Mage::getSingleton('adminhtml/session');
18
+ if($this->getRequest()->getParam('dir'))
19
+ $dir=$this->getRequest()->getParam('dir');
20
+ else
21
+ $dir=(($videogalleryGrid=$session->getData('videogalleryGrid')) ? $videogalleryGrid : 'DESC');
22
+
23
+ if($session->getData('videogalleryGridsort'))
24
+ $videogalleryGridsort = $session->getData('videogalleryGridsort');
25
+ else
26
+ $videogalleryGridsort = 'videogallery_id';
27
+
28
+ if($sort=$this->getRequest()->getParam('sort'))
29
+ $collection->getSelect()->order("$sort $dir");
30
+ else
31
+ $collection->getSelect()->order("$videogalleryGridsort $dir");
32
+
33
+ $this->setCollection($collection);
34
+ return parent::_prepareCollection();
35
+ }
36
+
37
+
38
+ protected function _prepareColumns() {
39
+ $this->addColumn('videogallery_id', array(
40
+ 'header' => Mage::helper('videogallery')->__('ID'),
41
+ 'align' => 'right',
42
+ 'width' => '50px',
43
+ 'index' => 'videogallery_id',
44
+ 'filter_index' => 'videogallery_id',
45
+ 'type' => 'number',
46
+ 'sortable' => true
47
+ ));
48
+ $this->addColumn('name', array(
49
+ 'header' => Mage::helper('videogallery')->__('Name'),
50
+ 'align' => 'left',
51
+ 'index' => 'name',
52
+ 'filter_index' => 'name',
53
+ 'sortable' => true
54
+ ));
55
+ $this->addColumn('videogallery_category', array(
56
+ 'header' => Mage::helper('videogallery')->__('Category'),
57
+ 'align' => 'left',
58
+ 'index' => 'videogallery_category',
59
+ 'filter_index' => 'videogallery_category',
60
+ 'sortable' => true
61
+ ));
62
+ $this->addColumn('image', array(
63
+ 'header' => Mage::helper('videogallery')->__('Image'),
64
+ 'align' => 'left',
65
+ 'index' => 'image',
66
+ 'type' => 'image',
67
+ 'filter_index' => 'image',
68
+ 'width' => '75px',
69
+ 'height' => '75px',
70
+ 'filter' => false,
71
+ 'sortable' => false,
72
+ 'renderer' => 'videogallery/renderer_image',
73
+ ));
74
+
75
+
76
+ $this->addColumn('action',
77
+ array(
78
+ 'header' => Mage::helper('videogallery')->__('Action'),
79
+ 'width' => '100',
80
+ 'type' => 'action',
81
+ 'getter' => 'getId',
82
+ 'actions' => array(
83
+ array(
84
+ 'caption' => Mage::helper('videogallery')->__('Delete'),
85
+ 'url' => array('base'=> '*/*/delete'),
86
+ 'field' => 'videogallery_id',
87
+ 'confirm' => Mage::helper('videogallery')->__('Are you sure?')
88
+ )
89
+ ),
90
+ 'filter' => false,
91
+ 'sortable' => false,
92
+ 'index' => 'stores',
93
+ 'is_system' => true,
94
+ ));
95
+ $this->addExportType('*/*/exportCsv', Mage::helper('videogallery')->__('CSV'));
96
+ $this->addExportType('*/*/exportXml', Mage::helper('videogallery')->__('XML'));
97
+
98
+ return parent::_prepareColumns();
99
+ }
100
+ protected function _prepareMassaction()
101
+ {
102
+ $this->setMassactionIdField('videogallery_id');
103
+ $this->getMassactionBlock()->setFormFieldName('videogallery');
104
+
105
+ $this->getMassactionBlock()->addItem('delete', array(
106
+ 'label' => Mage::helper('videogallery')->__('Delete'),
107
+ 'url' => $this->getUrl('*/*/massDelete'),
108
+ 'confirm' => Mage::helper('videogallery')->__('Are you sure?')
109
+ ));
110
+
111
+ // $statuses = Mage::getSingleton('videogallery/status')->getOptionArray();
112
+
113
+
114
+ return $this;
115
+ }
116
+
117
+ public function getRowUrl($row)
118
+ {
119
+ return $this->getUrl('*/*/edit', array('id' => $row->getId()));
120
+ }
121
+ public function getAllManu() {
122
+ $product = Mage::getModel('catalog/product');
123
+ $attributes = Mage::getResourceModel('eav/entity_attribute_collection')
124
+ ->setEntityTypeFilter($product->getResource()->getTypeId())
125
+ ->addFieldToFilter('attribute_code', 'videogallery');
126
+ $attribute = $attributes->getFirstItem()->setEntity($product->getResource());
127
+ $videogallery = $attribute->getSource()->getAllOptions(false);
128
+ return $videogallery;
129
+ }
130
+ //public function getGridUrl()
131
+ // {
132
+ // return $this->getUrl('*/*/grid', array('_current'=>true));
133
+ // }
134
+
135
+
136
+ }
app/code/community/Krishinc/Videogallery/Block/Product/Videogallery.php ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Krishinc_Videogallery_Block_Product_Videogallery extends Mage_Catalog_Block_Product_View
4
+ {
5
+
6
+ protected $_videogalleryCollection;
7
+
8
+ public function getVideogallerysCollection($product)
9
+ {
10
+ if($product)
11
+ {
12
+ $productVideogallerys = $product->getVideogallery();
13
+ $pos = strpos($productVideogallerys,',');
14
+ if ($pos === false)
15
+ {
16
+
17
+ $this->_videogalleryCollection[] = Mage::getModel('videogallery/videogallery')->getCollection()
18
+ ->addFieldToFilter('videogallery_id', $productVideogallerys);
19
+ } else {
20
+
21
+ $arrProductVideogallerys = explode(',',$productVideogallerys);
22
+ foreach ($arrProductVideogallerys as $awId)
23
+ {
24
+ $this->_videogalleryCollection[] = Mage::getModel('videogallery/videogallery')->getCollection()
25
+ ->addFieldToFilter('videogallery_id', $awId);
26
+ }
27
+ }
28
+
29
+
30
+ }
31
+
32
+ return $this->_videogalleryCollection;
33
+ }
34
+ }
app/code/community/Krishinc/Videogallery/Block/Renderer/Image.php ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Krishinc_Videogallery_Block_Renderer_Image extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract {
3
+
4
+ public function render(Varien_Object $row) {
5
+ if (empty($row['image'])) return '';
6
+ $image = Mage::getBaseDir('media').DS."videogallery".$row['image'];
7
+ if (!file_exists($image)){
8
+ $url = $row['videogallery_url'];
9
+ parse_str( parse_url( $url, PHP_URL_QUERY ) );
10
+ $videourl = 'http://img.youtube.com/vi/'.$v.'/0.jpg';
11
+ $videoimage = $v;
12
+ $img_file = $videourl;
13
+ $img_file=file_get_contents($img_file);
14
+ $file_loc=Mage::getBaseDir('media').DS."videogallery".DS.'videogallery_'.$videoimage.'.jpg';
15
+
16
+ $file_handler=fopen($file_loc,'w');
17
+
18
+ if(fwrite($file_handler,$img_file)==false){
19
+ echo 'error';
20
+ }
21
+ fclose($file_handler);
22
+ }
23
+ $block = new Krishinc_videogallery_Block_Videogallery();
24
+ return '<img width="75px" height="55px" src="'.$block->getImageresize($row['image'],'small',75,55). '" />';
25
+ }
26
+
27
+ }
app/code/community/Krishinc/Videogallery/Block/Videogallery.php ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Krishinc_videogallery_Block_Videogallery extends Mage_Catalog_Block_Product_List
3
+ {
4
+
5
+ public function getImageresize($image,$type,$width,$height)
6
+ {
7
+ //IMAGE RESIZE CODE START
8
+ if(!file_exists(Mage::getBaseDir('media').'/videogallery/resized/'.$type.'/'))mkdir(Mage::getBaseDir('media').'/videogallery/resized/'.$type.'/',0777);
9
+ $imageUrl = Mage::getBaseDir('media').'/videogallery/'.$image;
10
+ if($imageUrl):
11
+ $imageName = substr(strrchr($imageUrl,"/"),1);
12
+ $imageResized = Mage::getBaseDir('media').DS."videogallery".DS."resized".DS."".$type."".DS.$imageName;
13
+ $dirImg = Mage::getBaseDir().str_replace("/",DS,strstr($imageUrl,'/media'));
14
+ if (!file_exists($imageResized)&&file_exists($dirImg)) :
15
+ $imageObj = new Varien_Image($imageUrl);
16
+ $imageObj->constrainOnly(FALSE);
17
+ $imageObj->keepAspectRatio(FALSE);
18
+ $imageObj->keepFrame(FALSE);
19
+ $imageObj->resize($width, $height);
20
+ $imageObj->save($imageResized);
21
+ endif;
22
+ return Mage::getBaseUrl('media')."videogallery/resized/".$type."/".$imageName;
23
+ endif;
24
+ //IMAGE RESIZE CODE END
25
+ }
26
+ public function _prepareLayout()
27
+ {
28
+ $breadcrumbs = $this->getLayout()->getBlock('breadcrumbs');
29
+ $breadcrumbs->addCrumb('home', array('label'=>Mage::helper('cms')->__('Home'), 'title'=>Mage::helper('cms')->__('Home Page'), 'link'=>Mage::getBaseUrl()));
30
+
31
+
32
+ if($this->getRequest()->getParam('id')!='')
33
+ {
34
+ $breadcrumbs->addCrumb('videogallery', array('label'=>'video gallery', 'title'=>'video gallery', 'link'=>Mage::getUrl("videogallery")));
35
+ $galleryid=$this->getRequest()->getParam('id');
36
+ $name=strtolower($galleryid);
37
+
38
+ $breadcrumbs->addCrumb(''.$name.'', array('label'=>''.$name.'', 'title'=>''.$name.''));
39
+
40
+ }else
41
+ {
42
+ $breadcrumbs->addCrumb('videogallery', array('label'=>'video gallery', 'title'=>'video gallery'));
43
+ }
44
+
45
+
46
+ return parent::_prepareLayout();
47
+ }
48
+
49
+ }
app/code/community/Krishinc/Videogallery/Helper/Data.php ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
1
+ <?php
2
+ class Krishinc_Videogallery_Helper_Data extends Mage_Core_Helper_Abstract
3
+ {
4
+
5
+
6
+ }
app/code/community/Krishinc/Videogallery/Model/Mysql4/Videogallery.php ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Krishinc_Videogallery_Model_Mysql4_Videogallery extends Mage_Core_Model_Mysql4_Abstract
3
+ {
4
+ public function _construct()
5
+ {
6
+ $this->_init('videogallery/videogallery', 'videogallery_id');
7
+ $this->_isPkAutoIncrement = false;
8
+ }
9
+ }
app/code/community/Krishinc/Videogallery/Model/Mysql4/Videogallery/Collection.php ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Krishinc_Videogallery_Model_Mysql4_Videogallery_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
3
+ {
4
+ public function _construct()
5
+ {
6
+ $this->_init('videogallery/videogallery');
7
+ }
8
+ }
app/code/community/Krishinc/Videogallery/Model/Videogallery.php ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Krishinc_Videogallery_Model_Videogallery extends Mage_Core_Model_Abstract
3
+ {
4
+ public function _construct()
5
+ {
6
+ parent::_construct();
7
+ $this->_init('videogallery/videogallery');
8
+ }
9
+ public function updateOptionsToVideogallerys($options)
10
+ {
11
+
12
+ if($options)
13
+ {
14
+
15
+ foreach ($options['value'] as $optionId => $value)
16
+ {
17
+ $model = Mage::getModel('videogallery/videogallery');
18
+ $data = $model->load($optionId);
19
+ if(!$data->getVideogalleryId())
20
+ {
21
+
22
+ $model->setVideogalleryId($optionId)
23
+ ->setVideogalleryOptionId($optionId)
24
+ ->setName($value[0])
25
+ ->save();
26
+
27
+
28
+ } else {
29
+
30
+ $data->setName($value[0])
31
+ ->save();
32
+ }
33
+ }
34
+
35
+ foreach ($options['delete'] as $optionId => $value)
36
+ {
37
+ if(!empty($value))
38
+ {
39
+ $model->load($optionId);
40
+ $image = $this->getImage();
41
+ $filepath = Mage::getBaseDir('media')."\videogallery\\".$image;
42
+ unlink($filepath);
43
+ $model->delete();
44
+ }
45
+ }
46
+
47
+ }
48
+ }
49
+ }
app/code/community/Krishinc/Videogallery/controllers/Adminhtml/VideogalleryController.php ADDED
@@ -0,0 +1,255 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Krishinc_Videogallery_Adminhtml_VideogalleryController extends Mage_Adminhtml_Controller_Action
3
+ {
4
+ protected function _initAction()
5
+ {
6
+ $this->loadLayout()
7
+ ->_setActiveMenu('videogallery/items')
8
+ ->_addBreadcrumb(Mage::helper('adminhtml')->__('Videogallery Manager'), Mage::helper('adminhtml')->__('Videogallery Manager'));
9
+ return $this;
10
+ }
11
+ public function indexAction() {
12
+ $this->_initAction();
13
+ $this->_addContent($this->getLayout()->createBlock('videogallery/adminhtml_videogallery'));
14
+ $this->renderLayout();
15
+ }
16
+ public function newAction() {
17
+ $this->_forward('edit');
18
+ }
19
+ public function editAction()
20
+ {
21
+
22
+ $id = $this->getRequest()->getParam('id');
23
+ $model = Mage::getModel('videogallery/videogallery')->load($id);
24
+
25
+ if ($model->getVideogalleryId()) {
26
+ $data = Mage::getSingleton('adminhtml/session')->getFormData(true);
27
+ if (!empty($data)) {
28
+ $model->setData($data);
29
+ }
30
+
31
+ Mage::register('videogallery_data', $model);
32
+
33
+ $this->loadLayout();
34
+ $this->_setActiveMenu('videogallery/items');
35
+
36
+ $this->_addBreadcrumb(Mage::helper('adminhtml')->__('Videogallery Names Manager'), Mage::helper('adminhtml')->__('Videogallery Names Manager'));
37
+ $this->_addBreadcrumb(Mage::helper('adminhtml')->__('Videogallery Name'), Mage::helper('adminhtml')->__('Videogallery Name'));
38
+
39
+ $this->getLayout()->getBlock('head')->setCanLoadExtJs(true);
40
+
41
+ $this->_addContent($this->getLayout()->createBlock('videogallery/adminhtml_videogallery_edit'))
42
+ ->_addLeft($this->getLayout()->createBlock('videogallery/adminhtml_videogallery_edit_tabs'));
43
+
44
+ $this->renderLayout();
45
+ } else {
46
+ $data = Mage::getSingleton('adminhtml/session')->getFormData(true);
47
+ if ($data) {
48
+ print_r($data);exit;
49
+ //$data->getData();
50
+ // $model->setTitle($data['value']);
51
+ $model->setName($data['value']);
52
+ //$model->setName($data['value']);
53
+ //$model->setVideogalleryAttributeId($data['option_id']);
54
+ //$model->getVideogalleryAttributeId($data['option_id']);
55
+ }
56
+
57
+ Mage::register('videogallery_data', $model);
58
+
59
+ $this->loadLayout();
60
+ $this->_setActiveMenu('videogallery/items');
61
+
62
+ $this->_addBreadcrumb(Mage::helper('adminhtml')->__('Videogallery Name Manager'), Mage::helper('adminhtml')->__('Videogallery Names Manager'));
63
+ $this->_addBreadcrumb(Mage::helper('adminhtml')->__('Videogallery Name'), Mage::helper('adminhtml')->__('Videogallery Name'));
64
+
65
+ $this->getLayout()->getBlock('head')->setCanLoadExtJs(true);
66
+
67
+ $this->_addContent($this->getLayout()->createBlock('videogallery/adminhtml_videogallery_edit'))
68
+ ->_addLeft($this->getLayout()->createBlock('videogallery/adminhtml_videogallery_edit_tabs'));
69
+
70
+ $this->renderLayout();
71
+ }
72
+ }
73
+
74
+
75
+
76
+
77
+
78
+ public function saveAction() {
79
+
80
+ if ($data = $this->getRequest()->getPost()) {
81
+ //echo "<pre>";
82
+ //print_r($data);
83
+ $url = $data['videogallery_url'];
84
+ $checkurl = explode('?v=',$url);
85
+ if($checkurl[0] != 'https://www.youtube.com/watch' && $checkurl[0] != 'http://www.youtube.com/watch')
86
+ {
87
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('videogallery')->__('Please Enter Valid Youtube Url For Example : https://www.youtube.com/watch?v=lTEjfMjv654'));
88
+ if ($this->getRequest()->getParam('id')) {
89
+ Mage::getSingleton('adminhtml/session')->setFormData($data);
90
+ $this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
91
+ return;
92
+ }
93
+ $this->_redirect('*/*/');
94
+ return;
95
+
96
+ }else{
97
+ parse_str( parse_url( $url, PHP_URL_QUERY ) );
98
+ $videourl = 'http://img.youtube.com/vi/'.$v.'/0.jpg';
99
+ $videoimage = $v;
100
+ $content = file_get_contents("http://youtube.com/get_video_info?video_id=".$videoimage);
101
+ parse_str($content, $videoname);
102
+ $videoname = $videoname['title'];
103
+ $videoname;
104
+ if(isset($data['videogallery_url']) && $data['videogallery_url'] != '') {
105
+ if(!file_exists(Mage::getBaseDir('media').'/videogallery/'))mkdir(Mage::getBaseDir('media').'/videogallery/',0777);
106
+ $img_file = $videourl;
107
+ $img_file=file_get_contents($img_file);
108
+ $file_loc=Mage::getBaseDir('media').DS."videogallery".DS.'videogallery_'.$videoimage.'.jpg';
109
+
110
+ $file_handler=fopen($file_loc,'w');
111
+
112
+ if(fwrite($file_handler,$img_file)==false){
113
+ echo 'error';
114
+ }
115
+ fclose($file_handler);
116
+
117
+ $newfilename ='videogallery_'.$videoimage.'.jpg';
118
+ // Upload the image
119
+ $videoimage = $newfilename;
120
+
121
+ }
122
+
123
+
124
+ if($this->getRequest()->getParam('id'))
125
+ {
126
+ $modeldata = Mage::getModel('videogallery/videogallery')->getCollection()->addFieldToFilter('videogallery_id',array('eq'=>$this->getRequest()->getParam('id')));
127
+ $model = Mage::getModel('videogallery/videogallery')->load($modeldata->getFirstItem()->getVideogalleryId());
128
+ $model->setImage($videoimage)->setName($videoname)->setVideogalleryUrl($data['videogallery_url'])->setVideogalleryCategory($data['videogallery_category']);
129
+ }else {
130
+ $model = Mage::getModel('videogallery/videogallery');
131
+ $model->setData($data)->setImage($videoimage)->setName($videoname)->setVideogalleryUrl($data['videogallery_url'])->setVideogalleryCategory($data['videogallery_category']);
132
+ }
133
+
134
+ try {
135
+ $model->save();
136
+
137
+ Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('videogallery')->__('Item was successfully saved'));
138
+ Mage::getSingleton('adminhtml/session')->setFormData(false);
139
+
140
+ if ($this->getRequest()->getParam('back')) {
141
+ $this->_redirect('*/*/edit', array('videogallery_id' => $model->getVideogalleryId()));
142
+ return;
143
+ }
144
+ $this->_redirect('*/*/');
145
+ return;
146
+ } catch (Exception $e) {
147
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
148
+ Mage::getSingleton('adminhtml/session')->setFormData($data);
149
+ $this->_redirect('*/*/edit', array('videogallery_id' => $this->getRequest()->getParam('videogallery_id')));
150
+ return;
151
+ }
152
+ }
153
+ }
154
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('videogallery')->__('Unable to find item to save'));
155
+ $this->_redirect('*/*/');
156
+
157
+ }
158
+
159
+ public function deleteAction()
160
+ {
161
+
162
+ if ($this->getRequest()->getParam('videogallery_id') > 0) {
163
+ try {
164
+ $model = Mage::getModel('videogallery/videogallery')->load($this->getRequest()->getParam('videogallery_id'), 'videogallery_id');
165
+ $image = $model->getImage();
166
+ $filepath = Mage::getBaseDir('media').DS."videogallery\\".$image;
167
+ $filepath2 = Mage::getBaseDir('media').DS."videogallery".DS."resized".DS."small\\".$image;
168
+ $filepath3 = Mage::getBaseDir('media').DS."videogallery".DS."resized".DS."thumb\\".$image;
169
+ unlink($filepath);
170
+ unlink($filepath2);
171
+ unlink($filepath3);
172
+ if ($model->getVideogalleryId()) {
173
+ $model->delete();
174
+ }
175
+ } catch (Exception $e) {
176
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('adminhtml')->__('Item could not be deleted'));
177
+ $this->_redirect('*/*/');
178
+ }
179
+ }
180
+ $this->_redirect('*/*/');
181
+ }
182
+ public function massDeleteAction() {
183
+ $videogalleryIds = $this->getRequest()->getParam('videogallery');
184
+
185
+ if (!is_array($videogalleryIds)) {
186
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('adminhtml')->__('Please select item(s)'));
187
+ } else {
188
+ try {
189
+ foreach ($videogalleryIds as $videogalleryId) {
190
+ $model = Mage::getModel('videogallery/videogallery')->load($videogalleryId, 'videogallery_id');
191
+ $image = $model->getImage();
192
+ $filepath = Mage::getBaseDir('media').DS."videogallery\\".$image;
193
+ $filepath2 = Mage::getBaseDir('media').DS."videogallery".DS."resized".DS."small\\".$image;
194
+ $filepath3 = Mage::getBaseDir('media').DS."videogallery".DS."resized".DS."thumb\\".$image;
195
+ unlink($filepath);
196
+ unlink($filepath2);
197
+ unlink($filepath3);
198
+ if ($model->getVideogalleryId()) {
199
+ $model->delete();
200
+ }
201
+ }
202
+ Mage::getSingleton('adminhtml/session')->addSuccess(
203
+ Mage::helper('adminhtml')->__(
204
+ 'Total of %d record(s) were successfully deleted', count($videogalleryIds)
205
+ )
206
+ );
207
+ } catch (Exception $e) {
208
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
209
+ }
210
+ }
211
+ $this->_redirect('*/*/index');
212
+ }
213
+ public function exportCsvAction() {
214
+ $fileName = 'videogallery.csv';
215
+ $content = $this->getLayout()->createBlock('videogallery/adminhtml_videogallery_grid')
216
+ ->getCsv();
217
+
218
+ $this->_sendUploadResponse($fileName, $content);
219
+ }
220
+
221
+ public function exportXmlAction() {
222
+ $fileName = 'videogallery.xml';
223
+ $content = $this->getLayout()->createBlock('videogallery/adminhtml_videogallery_grid')
224
+ ->getXml();
225
+
226
+ $this->_sendUploadResponse($fileName, $content);
227
+ }
228
+
229
+ protected function _sendUploadResponse($fileName, $content, $contentType='application/octet-stream') {
230
+ $response = $this->getResponse();
231
+ $response->setHeader('HTTP/1.1 200 OK', '');
232
+ $response->setHeader('Pragma', 'public', true);
233
+ $response->setHeader('Cache-Control', 'must-revalidate, post-check=0, pre-check=0', true);
234
+ $response->setHeader('Content-Disposition', 'attachment; filename=' . $fileName);
235
+ $response->setHeader('Last-Modified', date('r'));
236
+ $response->setHeader('Accept-Ranges', 'bytes');
237
+ $response->setHeader('Content-Length', strlen($content));
238
+ $response->setHeader('Content-type', $contentType);
239
+ $response->setBody($content);
240
+ $response->sendResponse();
241
+ die;
242
+ }
243
+ /**
244
+ * Product grid for AJAX request.
245
+ * Sort and filter result for example.
246
+ */
247
+ public function gridAction()
248
+ {
249
+ $this->loadLayout();
250
+ $this->getResponse()->setBody(
251
+ $this->getLayout()->createBlock('krishinc/adminhtml_videogallery_grid')->toHtml()
252
+ );
253
+ }
254
+
255
+ }
app/code/community/Krishinc/Videogallery/controllers/IndexController.php ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Krishinc_Videogallery_IndexController extends Mage_Core_Controller_Front_Action
3
+ {
4
+ public function indexAction()
5
+ {
6
+ $this->loadLayout();
7
+ $this->renderLayout();
8
+ }
9
+ public function categoryAction()
10
+ {
11
+
12
+ $this->loadLayout();
13
+ $this->renderLayout();
14
+ }
15
+
16
+ }
app/code/community/Krishinc/Videogallery/etc/config.xml ADDED
@@ -0,0 +1,144 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Krishinc_Videogallery>
5
+ <version>0.1.0</version>
6
+ </Krishinc_Videogallery>
7
+ </modules>
8
+
9
+ <admin>
10
+ <routers>
11
+ <videogallery>
12
+ <use>admin</use>
13
+ <args>
14
+ <module>Krishinc_Videogallery</module>
15
+ <frontName>videogallery</frontName>
16
+ </args>
17
+ </videogallery>
18
+ </routers>
19
+ </admin>
20
+ <adminhtml>
21
+ <menu>
22
+ <multimedia translate="title" module="videogallery">
23
+ <title>Multimedia</title>
24
+ <sort_order>72</sort_order>
25
+ <children>
26
+ <videogalleryitems module="videogallery">
27
+ <title>Manage Video Gallery</title>
28
+ <sort_order>0</sort_order>
29
+ <action>videogallery/adminhtml_videogallery</action>
30
+ </videogalleryitems>
31
+
32
+
33
+ </children>
34
+ </multimedia>
35
+ </menu>
36
+ <acl>
37
+ <resources>
38
+ <all>
39
+ <title>Allow Everything</title>
40
+ </all>
41
+ <admin>
42
+ <children>
43
+ <videogallery>
44
+ <title>Videogallery Module</title>
45
+ <sort_order>200</sort_order>
46
+ </videogallery>
47
+ <system>
48
+ <children>
49
+ <config>
50
+ <children>
51
+ <videogallery>
52
+ <title>Videogallery</title>
53
+ </videogallery>
54
+ </children>
55
+ </config>
56
+ </children>
57
+ </system>
58
+ </children>
59
+ </admin>
60
+ </resources>
61
+ </acl>
62
+ <layout>
63
+ <updates>
64
+ <videogallery>
65
+ <file>videogallery.xml</file>
66
+ </videogallery>
67
+ </updates>
68
+ </layout>
69
+ </adminhtml>
70
+ <frontend>
71
+ <routers>
72
+ <videogallery>
73
+ <use>standard</use>
74
+ <args>
75
+ <module>Krishinc_videogallery</module>
76
+ <frontName>videogallery</frontName>
77
+ </args>
78
+ </videogallery>
79
+ </routers>
80
+ <layout>
81
+ <updates>
82
+ <videogallery>
83
+ <file>videogallery.xml</file>
84
+ </videogallery>
85
+ </updates>
86
+ </layout>
87
+ </frontend>
88
+ <global>
89
+ <helpers>
90
+ <videogallery>
91
+ <class>Krishinc_Videogallery_Helper</class>
92
+ </videogallery>
93
+ </helpers>
94
+
95
+ <models>
96
+ <videogallery>
97
+ <class>Krishinc_Videogallery_Model</class>
98
+ <resourceModel>videogallery_mysql4</resourceModel>
99
+ </videogallery>
100
+ <videogallery_mysql4>
101
+ <class>Krishinc_Videogallery_Model_Mysql4</class>
102
+ <entities>
103
+ <videogallery>
104
+ <table>videogallery</table>
105
+ </videogallery>
106
+ </entities>
107
+ </videogallery_mysql4>
108
+ </models>
109
+ <resources>
110
+ <videogallery_setup>
111
+ <setup>
112
+ <module>Krishinc_Videogallery</module>
113
+ </setup>
114
+ <connection>
115
+ <use>core_setup</use>
116
+ </connection>
117
+ </videogallery_setup>
118
+ <videogallery_write>
119
+ <connection>
120
+ <use>core_write</use>
121
+ </connection>
122
+
123
+
124
+ </videogallery_write>
125
+ <videogallery_read>
126
+ <connection>
127
+ <use>core_read</use>
128
+ </connection>
129
+ </videogallery_read>
130
+ </resources>
131
+ <blocks>
132
+ <videogallery>
133
+ <class>Krishinc_Videogallery_Block</class>
134
+ </videogallery>
135
+ </blocks>
136
+ </global>
137
+ <default>
138
+ <videogallery>
139
+ <videogallery_gallery>
140
+ <videogallery>12</videogallery>
141
+ </videogallery_gallery>
142
+ </videogallery>
143
+ </default>
144
+ </config>
app/code/community/Krishinc/Videogallery/etc/system.xml ADDED
@@ -0,0 +1,68 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * Kontilint_News extension
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ *
13
+ * @category Kontilint
14
+ * @package Kontilint_News
15
+ * @copyright Copyright (c) 2009 Kontilint Agency SA
16
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
17
+ */
18
+
19
+ /**
20
+ * @category Kontilint
21
+ * @package Kontilint_News
22
+ * @author Mattias Bomelin <mattias@kontilint.se>
23
+ */
24
+ -->
25
+ <config>
26
+ <identifier translate="label">
27
+ <label>SELF URL Identifier</label>
28
+ <frontend_type>text</frontend_type>
29
+ <backend_model>videogallery/config_identifier</backend_model>
30
+
31
+ </identifier>
32
+ <tabs>
33
+ <multimedia translate="label" module="videogallery">
34
+ <label>Multimedia</label>
35
+ <sort_order>110</sort_order>
36
+ </multimedia>
37
+ </tabs>
38
+ <sections>
39
+ <videogallery translate="label" module="videogallery">
40
+ <label>Video Gallery</label>
41
+ <tab>multimedia</tab>
42
+ <frontend_type>text</frontend_type>
43
+ <sort_order>0</sort_order>
44
+ <show_in_default>1</show_in_default>
45
+ <show_in_website>1</show_in_website>
46
+ <show_in_store>1</show_in_store>
47
+ <groups>
48
+ <videogallery_gallery translate="label">
49
+ <label>Manage Video Gallery</label>
50
+ <sort_order>100</sort_order>
51
+ <show_in_default>1</show_in_default>
52
+ <show_in_website>1</show_in_website>
53
+ <show_in_store>1</show_in_store>
54
+ <fields>
55
+ <videogallery translate="label">
56
+ <label>Number of Videos Per Page</label>
57
+ <frontend_type>text</frontend_type>
58
+ <sort_order>13</sort_order>
59
+ <show_in_default>1</show_in_default>
60
+ <show_in_website>1</show_in_website>
61
+ <show_in_store>1</show_in_store>
62
+ </videogallery>
63
+ </fields>
64
+ </videogallery_gallery>
65
+ </groups>
66
+ </videogallery>
67
+ </sections>
68
+ </config>
app/code/community/Krishinc/Videogallery/sql/videogallery_setup/mysql4-install-0.1.0.php ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ $installer = $this;
4
+ $installer->startSetup();
5
+ $installer->run("
6
+ -- DROP TABLE IF EXISTS {$this->getTable('videogallery')};
7
+ CREATE TABLE {$this->getTable('videogallery')} (
8
+ `videogallery_id` int(11) unsigned NOT NULL auto_increment,
9
+ `videogallery_category` varchar(200) NOT NULL default '',
10
+ `videogallery_url` varchar(500) NOT NULL default '',
11
+ `name` varchar(255) NOT NULL default '',
12
+ `image` varchar(255) NOT NULL default '',
13
+ `gallery_image` varchar(255) NOT NULL default '',
14
+ PRIMARY KEY (`videogallery_id`)
15
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
16
+ ");
17
+ $installer->endSetup();
app/design/frontend/default/default/layout/videogallery.xml ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <layout version="0.1.0">
3
+ <default>
4
+ <reference name="root">
5
+ <reference name="top.links">
6
+ <action method="addLink" translate="label title">
7
+ <label>Video Gallery</label>
8
+ <url>videogallery</url> <!-- can use full url also -->
9
+ <title>Video Gallery</title>
10
+ <prepare>true</prepare> <!-- set true if adding base url param -->
11
+ <urlParams helper="core/url/getHomeUrl"/> <!-- base url - thanks @Russ! -->
12
+ <position>1</position>
13
+ <liParams/>
14
+ <aParams>class="top-link-about-us"</aParams>
15
+ <beforeText></beforeText>
16
+ <afterText></afterText>
17
+ </action>
18
+ </reference>
19
+ </reference>
20
+ </default>
21
+ <videogallery_index_index>
22
+ <reference name="root">
23
+ <action method="setTemplate">
24
+ <template>page/1column.phtml</template>
25
+ </action>
26
+ </reference>
27
+ <reference name="content">
28
+ <block type="videogallery/videogallery" name="videogallery_list" template="videogallery/videogallerylist.phtml"/>
29
+ </reference>
30
+ </videogallery_index_index>
31
+ <videogallery_index_category>
32
+ <reference name="root">
33
+ <action method="setTemplate">
34
+ <template>page/1column.phtml</template>
35
+ </action>
36
+ </reference>
37
+ <reference name="content">
38
+ <block type="videogallery/videogallery" name="videogallery" template="videogallery/videogallery.phtml" />
39
+ </reference>
40
+ </videogallery_index_category>
41
+ </layout>
app/design/frontend/default/default/template/videogallery/videogallery.phtml ADDED
@@ -0,0 +1,87 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ $baseurl=$this->getUrl('');
3
+ $model_data = Mage::getModel('videogallery/videogallery')->getCollection();
4
+ $categoryid=$this->getRequest()->getParam('id');
5
+ $model_data->addFieldToFilter('videogallery_category', $categoryid);
6
+ $results = $model_data->getData();
7
+ $collection=Mage::getModel('videogallery/videogallery')->getCollection()->addFieldToSelect('videogallery_category');
8
+ $collection->getSelect()->distinct(true);
9
+ $categorys = $collection->getData();
10
+ ?>
11
+
12
+ <div class="col-left sidebar">
13
+ <div class="block">
14
+ <div class="block-title">Video Category</div>
15
+ <div class="block-content">
16
+ <ul style="padding:10px">
17
+ <li><a href="<?php echo $baseurl."videogallery/"; ?>" class="active">All Videos</a></li>
18
+ <?php foreach($categorys as $category): ?>
19
+ <li><a href="<?php echo $baseurl."videogallery/index/category/id/".$category['videogallery_category']; ?>"><?php echo $category['videogallery_category']; ?></a></li>
20
+ <?php endforeach; ?>
21
+ </ul>
22
+ </div>
23
+ </div>
24
+ </div>
25
+ <div style="width:75%; float:right;">
26
+ <div class="page-title category-title">
27
+ <h1><?php echo $categoryid; ?></h1>
28
+ </div>
29
+ <?php
30
+ $count = count($results);
31
+ if($count==0){
32
+ ?>
33
+ <p class="note-msg">There are no videos matching the selection.</p>
34
+ <?php
35
+ }
36
+ $i = 0;
37
+ $j = 0;
38
+ foreach($results as $result):
39
+ $i++;
40
+ $j++;
41
+ $id=$result['videogallery_id'];
42
+ $videogallery=Mage::getModel("videogallery/videogallery")->load($id);
43
+ if($videogallery!=$videogallery['videogallery_id']):
44
+
45
+ parse_str( parse_url( $videogallery['videogallery_url'], PHP_URL_QUERY ) );
46
+ $videoid = $v;
47
+ $videoname = $videogallery['name'];
48
+ ?>
49
+ <?php if($i == 1): ?>
50
+ <div id="thumbs" class="navigation video_gallery">
51
+ <div id="video_frame_cont">
52
+ <iframe id="mainvideo" width="655" height="311" src="http://www.youtube-nocookie.com/embed/<?php echo $videoid; ?>?wmode=opaque&rel=0&autohide=1&showinfo=0&autoplay=0" frameborder="0" allowfullscreen></iframe>
53
+ </div>
54
+ <ul class="clearfix thumbs noscript">
55
+ <?php endif;?>
56
+ <li class="<?php if($j == 1): ?>first<?php elseif($j == 2): $j = 0; ?>last<?php endif;?>" style="display:inline;float:left;margin:0px 5px 5px;width:315px;" onclick="selectvideo('<?php echo $videoid; ?>')"> <img style="cursor:pointer;" src="<?php echo $this->getImageresize($videogallery['image'],'big',315,141);?>" width="315" height="141" title="<?php echo $videogallery['name']; ?>" />
57
+ <div class="play_btn">
58
+ <?php /*?><img src="<?php echo $this->getSkinUrl('images/video_play_btn.png') ?>" alt="" /><?php */?>
59
+ </div>
60
+ <h2 class="product-name" style="height: 35px; overflow: hidden;"><a title="<?php echo $videoname; ?>"><?php echo $videoname; ?></a></h2>
61
+ </li>
62
+ <?php endif;?>
63
+ <?php if($i == $count): ?>
64
+ </ul>
65
+ </div>
66
+ <?php endif;?>
67
+ <?php endforeach; ?>
68
+ </div>
69
+ <script type="text/javascript" charset="utf-8">
70
+ function scrollToElement(pageElement) {
71
+ var positionX = 0,
72
+ positionY = 0;
73
+
74
+ while(pageElement != null){
75
+ positionX += pageElement.offsetLeft;
76
+ positionY += pageElement.offsetTop;
77
+ pageElement = pageElement.offsetParent;
78
+ window.scrollTo(positionX, positionY);
79
+ }
80
+ }
81
+ function selectvideo(id) {
82
+ var main_image = document.getElementById("mainvideo");
83
+ main_image.src = 'http://www.youtube-nocookie.com/embed/'+id+'?wmode=opaque&rel=0&autohide=1&showinfo=0&autoplay=1';
84
+ var video_frame_cont = document.getElementById("video_frame_cont");
85
+ scrollToElement(video_frame_cont);
86
+ };
87
+ </script>
app/design/frontend/default/default/template/videogallery/videogallerylist.phtml ADDED
@@ -0,0 +1,85 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ $baseurl=$this->getUrl('');
3
+ $model_data = Mage::getModel('videogallery/videogallery')->getCollection();
4
+ $results = $model_data->getData();
5
+ $collection=Mage::getModel('videogallery/videogallery')->getCollection()->addFieldToSelect('videogallery_category');
6
+ $collection->getSelect()->distinct(true);
7
+ $categorys = $collection->getData();
8
+ ?>
9
+
10
+ <div class="col-left sidebar">
11
+ <div class="block">
12
+ <div class="block-title">Video Category</div>
13
+ <div class="block-content">
14
+ <ul style="padding:10px">
15
+ <li><a href="<?php echo $baseurl."videogallery/"; ?>" class="active">All Videos</a></li>
16
+ <?php foreach($categorys as $category): ?>
17
+ <li><a href="<?php echo $baseurl."videogallery/index/category/id/".$category['videogallery_category']; ?>"><?php echo $category['videogallery_category']; ?></a></li>
18
+ <?php endforeach; ?>
19
+ </ul>
20
+ </div>
21
+ </div>
22
+ </div>
23
+ <div style="width:75%; float:right;">
24
+ <div class="page-title category-title">
25
+ <h1>Videos Gallery</h1>
26
+ </div>
27
+ <?php
28
+ $count = count($results);
29
+ if($count==0){
30
+ ?>
31
+ <p class="note-msg">There are no videos matching the selection.</p>
32
+ <?php
33
+ }
34
+ $i = 0;
35
+ $j = 0;
36
+ foreach($results as $result):
37
+ $i++;
38
+ $j++;
39
+ $id=$result['videogallery_id'];
40
+ $videogallery=Mage::getModel("videogallery/videogallery")->load($id);
41
+ if($videogallery!=$videogallery['videogallery_id']):
42
+
43
+ parse_str( parse_url( $videogallery['videogallery_url'], PHP_URL_QUERY ) );
44
+ $videoid = $v;
45
+ $videoname = $videogallery['name'];
46
+ ?>
47
+ <?php if($i == 1): ?>
48
+ <div id="thumbs" class="navigation video_gallery">
49
+ <div id="video_frame_cont">
50
+ <iframe id="mainvideo" width="655" height="311" src="http://www.youtube-nocookie.com/embed/<?php echo $videoid; ?>?wmode=opaque&rel=0&autohide=1&showinfo=0&autoplay=0" frameborder="0" allowfullscreen></iframe>
51
+ </div>
52
+ <ul class="clearfix thumbs noscript">
53
+ <?php endif;?>
54
+ <li class="<?php if($j == 1): ?>first<?php elseif($j == 2): $j = 0; ?>last<?php endif;?>" style="display:inline;float:left;margin:0px 5px 5px;width:315px;" onclick="selectvideo('<?php echo $videoid; ?>')"> <img style="cursor:pointer;" src="<?php echo $this->getImageresize($videogallery['image'],'big',315,141);?>" width="315" height="141" title="<?php echo $videogallery['name']; ?>" />
55
+ <div class="play_btn">
56
+ <?php /*?><img src="<?php echo $this->getSkinUrl('images/video_play_btn.png') ?>" alt="" /><?php */?>
57
+ </div>
58
+ <h2 class="product-name" style="height: 35px; overflow: hidden;"><a title="<?php echo $videoname; ?>"><?php echo $videoname; ?></a></h2>
59
+ </li>
60
+ <?php endif;?>
61
+ <?php if($i == $count): ?>
62
+ </ul>
63
+ </div>
64
+ <?php endif;?>
65
+ <?php endforeach; ?>
66
+ </div>
67
+ <script type="text/javascript" charset="utf-8">
68
+ function scrollToElement(pageElement) {
69
+ var positionX = 0,
70
+ positionY = 0;
71
+
72
+ while(pageElement != null){
73
+ positionX += pageElement.offsetLeft;
74
+ positionY += pageElement.offsetTop;
75
+ pageElement = pageElement.offsetParent;
76
+ window.scrollTo(positionX, positionY);
77
+ }
78
+ }
79
+ function selectvideo(id) {
80
+ var main_image = document.getElementById("mainvideo");
81
+ main_image.src = 'http://www.youtube-nocookie.com/embed/'+id+'?wmode=opaque&rel=0&autohide=1&showinfo=0&autoplay=1';
82
+ var video_frame_cont = document.getElementById("video_frame_cont");
83
+ scrollToElement(video_frame_cont);
84
+ };
85
+ </script>
app/etc/modules/Krishinc_Videogallery.xml ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Krishinc_Videogallery>
5
+ <active>true</active>
6
+ <codePool>community</codePool>
7
+ </Krishinc_Videogallery>
8
+ </modules>
9
+ </config>
package.xml ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>Krishinc_Videogallery</name>
4
+ <version>0.1.0</version>
5
+ <stability>stable</stability>
6
+ <license uri="http://opensource.org/licenses/osl-3.0.php">OSL v3.0</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>A Video Gallery Extension Is Allow Admin To Upload YouTube Video By Video URL. And also admin can enter the video category name on the admin section for perticular Video.A Video Gallery Extension Is Allow Admin To Upload YouTube Video By Video URL.</summary>
10
+ <description>Note:- Please Disable the Cache and Compilation before Install this module.&#xD;
11
+ &#xD;
12
+ A Video Gallery Extension Which automatically upload YouTube video By Video URL. And also admin can enter the video category name on the admin section for perticular video. &#xD;
13
+ &#xD;
14
+ A Video Gallery Extension Give You a Configration Section. In this section admin can set the Number of Video Display Per Page.&#xD;
15
+ &#xD;
16
+ A Video Gallery Extension automatically manage all the video by category and it can be display on Frontend with all the video and also display by category.&#xD;
17
+ &#xD;
18
+ A Video Gallery Extension automatically set the video gallery link on the top navigation.&#xD;
19
+ &#xD;
20
+ Note:- Please Refresh the Cache and Enable the Cache and Compilation after Installed this module.&#xD;
21
+ </description>
22
+ <notes>Fixed minor bug</notes>
23
+ <authors><author><name>Mayank Zalavadia</name><user>zalavadia</user><email>mayankzalavadia@gmail.com</email></author></authors>
24
+ <date>2012-12-27</date>
25
+ <time>10:22:32</time>
26
+ <contents><target name="mageetc"><dir name="modules"><file name="Krishinc_Videogallery.xml" hash="c72873019478662f79fc4c21906eb6e9"/></dir></target><target name="magecommunity"><dir name="Krishinc"><dir name="Videogallery"><dir name="Block"><dir name="Adminhtml"><dir name="Videogallery"><dir name="Edit"><file name="Form.php" hash="265beb2e84dd33088ccc934b2d3526d3"/><dir name="Tab"><file name="Form.php" hash="15767eb442cf739abde9bd25bcd06f38"/></dir><file name="Tabs.php" hash="8bc23ec1af91e7a58757270b3bea842c"/></dir><file name="Edit.php" hash="0b48b01569d3dd5e2ad88088b077ab26"/><file name="Grid.php" hash="eb3aec442ef6322f5ebda473bb8cc4c9"/></dir><file name="Videogallery.php" hash="65e643bb950faf7bb0d665acb8216843"/></dir><dir name="Product"><file name="Videogallery.php" hash="bc3c1d0def14adcfb187d82fc2cf42c5"/></dir><dir name="Renderer"><file name="Image.php" hash="ec6ff859d2de5928a6225569dc5985e7"/></dir><file name="Videogallery.php" hash="9bdd8d7b8d4d491db311844b3fd8ee40"/></dir><dir name="Helper"><file name="Data.php" hash="c455ceb7e8df6f7b1120b45126e339b8"/></dir><dir name="Model"><dir name="Mysql4"><dir name="Videogallery"><file name="Collection.php" hash="ad56aea5dbdb1ed03653d244491a4cc7"/></dir><file name="Videogallery.php" hash="23a402e533038cfc29d5c18d64aba4ce"/></dir><file name="Videogallery.php" hash="cc6d6634e80bfb52072c2522ed0763ee"/></dir><dir name="controllers"><dir name="Adminhtml"><file name="VideogalleryController.php" hash="cce7ec03a845ef2fe153acfcb98e740e"/></dir><file name="IndexController.php" hash="621900d01c77677b549856935c9aad7e"/></dir><dir name="etc"><file name="config.xml" hash="f13dacde0e15d0116aa0a0a21326c263"/><file name="system.xml" hash="1a1d46f6188134113b2eaa2e51f65533"/></dir><dir name="sql"><dir name="videogallery_setup"><file name="mysql4-install-0.1.0.php" hash="50ca60ddbf0ab5fef2f206dd0622801d"/></dir></dir></dir></dir></target><target name="magedesign"><dir><dir name="frontend"><dir name="default"><dir name="default"><dir name="layout"><file name="videogallery.xml" hash="b2c28d542c5666b07012d2ec1b38e557"/></dir><dir name="template"><dir name="videogallery"><file name="videogallery.phtml" hash="1fdab99f82caac7c65178f0591c67f0c"/><file name="videogallerylist.phtml" hash="465667f00e61c7d001ba6db206d912b2"/></dir></dir></dir></dir></dir></dir></target></contents>
27
+ <compatible/>
28
+ <dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
29
+ </package>