/** * Generates static page title * * @param array $params * @param Smarty $smarty * @return string * * @package application.helper.smarty * @author Integry Systems */ function smarty_function_pageName($params, Smarty_Internal_Template $smarty) { if (!class_exists('StaticPage', false)) { ClassLoader::import('application.model.staticpage.StaticPage'); } if (!isset($params['id'])) { return '<span style="color: red; font-weight: bold; font-size: larger;">No static page ID provided</span>'; } $page = StaticPage::getInstanceById($params['id'], StaticPage::LOAD_DATA)->toArray(); return $page[!empty($params['text']) ? 'text_lang' : 'title_lang']; }
/** * Generates static page URL * * @param array $params * @param Smarty $smarty * @return string * * @package application.helper.smarty * @author Integry Systems */ function smarty_function_pageUrl($params, LiveCartSmarty $smarty) { if (!class_exists('StaticPage', false)) { ClassLoader::import('application.model.staticpage.StaticPage'); } if (isset($params['id'])) { $params['data'] = StaticPage::getInstanceById($params['id'], StaticPage::LOAD_DATA)->toArray(); } $urlParams = array('controller' => 'staticPage', 'action' => 'view', 'handle' => $params['data']['handle']); return $smarty->getApplication()->getRouter()->createUrl($urlParams, true); }
function testUpdate() { $page = StaticPage::getNewInstance(); $page->setValueByLang('title', 'en', 'test title'); $page->save(); $page->setValueByLang('title', 'en', 'changed'); $page->save(); ActiveRecord::clearPool(); $instance = StaticPage::getInstanceById($page->getID()); $this->assertEqual($page->getValueByLang('title', 'en'), 'changed'); // test deleting a page $this->assertTrue(file_exists($page->getFileName())); $page->delete(); $this->assertFalse(file_exists($page->getFileName())); }
/** * @role remove */ public function delete() { try { $inst = StaticPage::getInstanceById($this->request->get('id'), StaticPage::LOAD_DATA); $inst->delete(); return new JSONResponse(array('id' => $inst->getID()), 'success'); } catch (Exception $e) { return new JSONResponse(false, 'failure'); } }