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())); }
public function setConfig() { if (!$this->buildConfigValidator()->isValid()) { return new ActionRedirectResponse('install', 'config'); } Language::deleteCache(); // site name $this->config->setValueByLang('STORE_NAME', $this->request->get('language'), $this->request->get('name')); $this->config->save(); ClassLoader::import('application.model.Currency'); // create currency if (ActiveRecord::objectExists('Currency', $this->request->get('curr'))) { $currency = Currency::getInstanceByID($this->request->get('curr'), Currency::LOAD_DATA); } else { $currency = ActiveRecord::getNewInstance('Currency'); $currency->setID($this->request->get('curr')); $currency->isEnabled->set(true); $currency->isDefault->set(true); $currency->save(ActiveRecord::PERFORM_INSERT); } ClassLoader::import('application.model.system.Language'); // create language if (ActiveRecord::objectExists('Language', $this->request->get('language'))) { $language = Language::getInstanceByID($this->request->get('language'), Language::LOAD_DATA); } else { $language = ActiveRecord::getNewInstance('Language'); $language->setID($this->request->get('language')); $language->save(ActiveRecord::PERFORM_INSERT); $language->isEnabled->set(true); $language->isDefault->set(true); $language->save(); } // set root category name to "LiveCart" ClassLoader::import('application.model.category.Category'); $root = Category::getInstanceById(Category::ROOT_ID, Category::LOAD_DATA); $root->setValueByLang('name', $language->getID(), 'LiveCart'); $root->save(); // create a default shipping service ClassLoader::import('application.model.delivery.DeliveryZone'); ClassLoader::import('application.model.delivery.ShippingService'); ClassLoader::import('application.model.delivery.ShippingRate'); $service = ShippingService::getNewInstance(DeliveryZone::getDefaultZoneInstance(), 'Default Service', ShippingService::SUBTOTAL_BASED); $service->save(); $rate = ShippingRate::getNewInstance($service, 0, 100000); $rate->flatCharge->set(10); $rate->save(); // create a couple of blank static pages ClassLoader::import('application.model.staticpage.StaticPage'); $page = StaticPage::getNewInstance(); $page->setValueByLang('title', $language->getID(), 'Contact Info'); $page->setValueByLang('text', $language->getID(), 'Enter your contact information here'); $page->menu->set(array('INFORMATION' => true)); $page->save(); $page = StaticPage::getNewInstance(); $page->setValueByLang('title', $language->getID(), 'Shipping Policy'); $page->setValueByLang('text', $language->getID(), 'Enter your shipping rate & policy information here'); $page->menu->set(array('INFORMATION' => true)); $page->save(); // create an example site news post ClassLoader::import('application.model.sitenews.NewsPost'); $news = ActiveRecordModel::getNewInstance('NewsPost'); $news->setValueByLang('title', $language->getID(), 'Our store is open'); $news->setValueByLang('text', $language->getID(), 'Powered by LiveCart software, we have gone live! Of course, we will have to go to <a href="../backend">the backend area</a> and add some categories and products first...'); $news->setValueByLang('moreText', $language->getID(), 'Do not forget to delete this post when you actually go live :)'); $news->isEnabled->set(true); $news->save(); return new ActionRedirectResponse('install', 'finish'); }
/** * @role create */ public function create() { $page = StaticPage::getNewInstance(); return $this->save($page); }
public function getNextStaticPage() { if (!($data = $this->loadRecord('SELECT * FROM ' . $this->getTablePrefix() . 'aux_pages'))) { return null; } $page = StaticPage::getNewInstance(); $page->setValueByLang('title', $this->defLang, $data['aux_page_name']); $page->setValueByLang('text', $this->defLang, $data['aux_page_text']); $page->menu->set(array('INFORMATION' => true)); return $page; }