/
List.php
141 lines (124 loc) · 3.73 KB
/
List.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
<?php
/*------------------------------------------------------------------------
# VenusTheme Brand Module
# ------------------------------------------------------------------------
# author: VenusTheme.Com
# copyright: Copyright (C) 2012 http://www.venustheme.com. All Rights Reserved.
# @license: http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
# Websites: http://www.venustheme.com
# Technical Support: http://www.venustheme.com/
-------------------------------------------------------------------------*/
class Ves_Brand_Block_List extends Mage_Core_Block_Template
{
/**
* @var string $_config
*
* @access protected
*/
protected $_config = array();
/**
* @var string $_config
*
* @access protected
*/
protected $_listDesc = array();
/**
* @var string $_config
*
* @access protected
*/
protected $_show = 0;
protected $_theme = "";
/**
* Contructor
*/
public function __construct($attributes = array())
{
$this->convertAttributesToConfig($attributes);
parent::__construct();
$cms_block_id = $this->getConfig('cmsblock');
$cms = "";
if($cms_block_id){
$cms = Mage::getSingleton('core/layout')->createBlock('cms/block')->setBlockId($cms_block_id)->toHtml();
}
$this->assign( "cms", $cms );
/*Cache Block*/
$enable_cache = $this->getConfig("enable_cache", 1 );
if(!$enable_cache) {
$cache_lifetime = null;
} else {
$cache_lifetime = $this->getConfig("cache_lifetime", 86400 );
$cache_lifetime = (int)$cache_lifetime>0?$cache_lifetime: 86400;
}
$this->addData(array('cache_lifetime' => $cache_lifetime));
$this->addCacheTag(array(
Mage_Core_Model_Store::CACHE_TAG,
Mage_Cms_Model_Block::CACHE_TAG,
Ves_Brand_Model_Brand::CACHE_BLOCK_LIST_TAG
));
}
/**
* Get Key pieces for caching block content
*
* @return array
*/
public function getCacheKeyInfo()
{
return array(
'VES_BRAND_BLOCK_LIST',
$this->getNameInLayout(),
Mage::app()->getStore()->getId(),
Mage::getDesign()->getPackageName(),
Mage::getDesign()->getTheme('template'),
Mage::getSingleton('customer/session')->getCustomerGroupId(),
'template' => $this->getTemplate(),
);
}
public function convertAttributesToConfig($attributes = array()) {
if($attributes) {
foreach($attributes as $key=>$val) {
$this->setConfig($key, $val);
}
}
}
/**
* overrde the value of the extension's configuration
*
* @return string
*/
function setConfig($key, $value) {
$this->_config[$key] = $value;
return $this;
}
public function getConfig( $val, $default = "" ){
$return = "";
$value = $this->getData($val);
//Check if has widget config data
if($this->hasData($val) && $value !== null) {
if($value == "true") {
return 1;
} elseif($value == "false") {
return 0;
}
return $value;
} else {
if(isset($this->_config[$val])){
$return = $this->_config[$val];
if($return == "true") {
$return = 1;
} elseif($return == "false") {
$return = 0;
}
}else{
$return = Mage::getStoreConfig("ves_brand/module_setting/".$val );
}
if($return == "" && $default) {
$return = $default;
}
}
return $return;
}
public function getGeneralConfig( $val, $default = "" ){
return Mage::getStoreConfig( "ves_brand/general_setting/".$val );
}
}