/** * @dataProvider getDefaultDesignTabsDataProvider */ public function testGetDefaultDesignTabs($appType) { $application = new Mage_XmlConnect_Model_Application(); $application->setType($appType); $tabs = $this->_helper->getDeviceHelper($application)->getDefaultDesignTabs(); $this->assertNotEmpty($tabs); foreach ($tabs as $tab) { $this->assertArrayHasKey('image', $tab); } }
/** * Retrieve initialized instance of XmlConnect application model * * @return Mage_XmlConnect_Model_Application */ protected function _getConnectApp() { if (!$this->_connectApp) { $this->_connectApp = Mage::helper('xmlconnect')->getApplication(); if (!$this->_connectApp) { $this->_connectApp = Mage::getModel('xmlconnect/application'); $this->_connectApp->loadDefaultConfiguration(); } } return $this->_connectApp; }
/** * Set application cookies * * Set application coolies: application code and device screen size. * * @param Mage_XmlConnect_Model_Application $app * @return void */ protected function _initCookies(Mage_XmlConnect_Model_Application $app) { $cookieToSetArray = array(array('cookieName' => Mage_XmlConnect_Model_Application::APP_CODE_COOKIE_NAME, 'paramName' => Mage_XmlConnect_Model_Application::APP_CODE_COOKIE_NAME, 'value' => $app->getCode()), array('cookieName' => Mage_XmlConnect_Model_Application::APP_SCREEN_SIZE_NAME, 'paramName' => Mage_XmlConnect_Model_Application::APP_SCREEN_SIZE_NAME, 'value' => $app->getScreenSize())); foreach ($cookieToSetArray as $item) { if (!isset($_COOKIE[$item['cookieName']]) || $_COOKIE[$item['cookieName']] != $this->getRequest()->getParam($item['paramName'])) { /** * @todo add management of cookie expire to application admin panel */ $cookieExpireOffset = 3600 * 24 * 30; Mage::getSingleton('core/cookie')->set($item['cookieName'], $item['value'], $cookieExpireOffset, '/', null, null, true); } } }
/** * Render block * * @return string */ protected function _toHtml() { /** @var $xml Mage_XmlConnect_Model_Simplexml_Element */ $xml = Mage::getModel('xmlconnect/simplexml_element', '<configuration></configuration>'); $this->_buildRecursive($xml, Mage::helper('xmlconnect')->excludeXmlConfigKeys($this->_app->getRenderConf()))->_addLocalization($xml); return $xml->asNiceXml(); }
/** * Get device tipe from application * * @param Mage_XmlConnect_Model_Application $application * @return string */ public function getDeviceType($application = null) { $deviceType = null; if (empty($application) && Mage::registry('current_app') !== null) { $deviceType = (string) $this->getApplication()->getType(); } elseif ($application instanceof Mage_XmlConnect_Model_Application) { $deviceType = (string) $application->getType(); } if (empty($deviceType)) { $deviceType = self::DEVICE_TYPE_DEFAULT; } return $deviceType; }
/** * Update all applications "updated at" parameter with current date * * @param Mage_XmlConnect_Model_Application $model * @return Mage_XmlConnect_Model_Resource_Application */ public function updateUpdatedAtParameter($model) { $this->_getWriteAdapter()->update($this->getMainTable(), array('updated_at' => $model->getUpdatedAt())); return $this; }
/** * Render block * * @return string */ protected function _toHtml() { $xml = new Mage_XmlConnect_Model_Simplexml_Element('<configuration></configuration>'); $this->_buildRecursive($xml, Mage::helper('xmlconnect')->excludeXmlConfigKeys($this->_app->getRenderConf())); return $xml->asNiceXml(); }
/** * Check if creating AirMail template for the application is allowed * * @param Mage_XmlConnect_Model_Application $application * @return boolean */ public static function isTemplateAllowedForApplication($application = null) { return $application instanceof Mage_XmlConnect_Model_Application ? in_array($application->getType(), array(self::DEVICE_TYPE_IPHONE)) : false; }