1: <?php
2: /**
3: * Magento
4: *
5: * NOTICE OF LICENSE
6: *
7: * This source file is subject to the Open Software License (OSL 3.0)
8: * that is bundled with this package in the file LICENSE.txt.
9: * It is also available through the world-wide-web at this URL:
10: * http://opensource.org/licenses/osl-3.0.php
11: * If you did not receive a copy of the license and are unable to
12: * obtain it through the world-wide-web, please send an email
13: * to license@magentocommerce.com so we can send you a copy immediately.
14: *
15: * DISCLAIMER
16: *
17: * Do not edit or add to this file if you wish to upgrade Magento to newer
18: * versions in the future. If you wish to customize Magento for your
19: * needs please refer to http://www.magentocommerce.com for more information.
20: *
21: * @category Mage
22: * @package Mage_XmlConnect
23: * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
24: * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25: */
26:
27: /**
28: * XmlConnect Template model
29: *
30: * @category Mage
31: * @package Mage_Xmlconnect
32: * @author Magento Core Team <core@magentocommerce.com>
33: */
34: class Mage_XmlConnect_Model_Template extends Mage_Core_Model_Template
35: {
36: /**
37: * Model constructor
38: *
39: * @return null
40: */
41: protected function _construct()
42: {
43: $this->_init('xmlconnect/template');
44: }
45:
46: /**
47: * Processing object before save data
48: * Add created_at and modified_at params
49: *
50: * @return Mage_XmlConnect_Model_Template
51: */
52: protected function _beforeSave()
53: {
54: parent::_beforeSave();
55:
56: $currentDate = Mage::getSingleton('core/date')->gmtDate();
57: if (!$this->getId()) {
58: $this->setCreatedAt($currentDate);
59: }
60: $this->setModifiedAt($currentDate);
61:
62: return $this;
63: }
64:
65: /**
66: * Get template type
67: *
68: * @return int
69: */
70: public function getType()
71: {
72: return self::TYPE_HTML;
73: }
74:
75: /**
76: * Retrieve processed template
77: *
78: * @param array $variables
79: * @return string
80: */
81: public function getProcessedTemplate(array $variables = array())
82: {
83: /* @var $processor Mage_Widget_Model_Template_Filter */
84: $processor = Mage::getModel('widget/template_filter');
85:
86: $variables['this'] = $this;
87:
88: if (Mage::app()->isSingleStoreMode()) {
89: $processor->setStoreId(Mage::app()->getStore());
90: } else {
91: $processor->setStoreId(1);
92: }
93:
94: $htmlDescription = <<<EOT
95: <div style="font-size: 0.8em; text-decoration: underline; margin-top: 1.5em; line-height: 2em;">%s:</div>
96: EOT;
97: $html = sprintf($htmlDescription, Mage::helper('xmlconnect')->__('Push title'))
98: . $this->getPushTitle();
99: $html .= sprintf($htmlDescription, Mage::helper('xmlconnect')->__('Message title'))
100: . $this->getMessageTitle();
101: $html .= sprintf($htmlDescription, Mage::helper('xmlconnect')->__('Message content'))
102: . $processor->filter($this->getContent());
103:
104: return $html;
105: }
106: }
107: