protected function _addTestPage($title = 'Test Page', $slug = 'testpage', $text = 'whatever', $isPublished = true) { $page = new SimplePagesPage(); $page->title = $title; $page->slug = $slug; $page->text = $text; $page->is_published = $isPublished ? '1' : '0'; $page->created_by_user_id = $this->user->id; $page->save(); return $page; }
/** * Install the plugin. */ public function hookInstall() { // Create the table. $db = $this->_db; $sql = "\n CREATE TABLE IF NOT EXISTS `{$db->SimplePagesPage}` (\n `id` int(10) unsigned NOT NULL AUTO_INCREMENT,\n `modified_by_user_id` int(10) unsigned NOT NULL,\n `created_by_user_id` int(10) unsigned NOT NULL,\n `is_published` tinyint(1) NOT NULL,\n `title` tinytext COLLATE utf8_unicode_ci NOT NULL,\n `slug` tinytext COLLATE utf8_unicode_ci NOT NULL,\n `text` mediumtext COLLATE utf8_unicode_ci,\n `updated` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,\n `inserted` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',\n `order` int(10) unsigned NOT NULL,\n `parent_id` int(10) unsigned NOT NULL,\n `template` tinytext COLLATE utf8_unicode_ci NOT NULL,\n `use_tiny_mce` tinyint(1) NOT NULL,\n PRIMARY KEY (`id`),\n KEY `is_published` (`is_published`),\n KEY `inserted` (`inserted`),\n KEY `updated` (`updated`),\n KEY `created_by_user_id` (`created_by_user_id`),\n KEY `modified_by_user_id` (`modified_by_user_id`),\n KEY `order` (`order`),\n KEY `parent_id` (`parent_id`)\n ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci"; $db->query($sql); // Save an example page. $page = new SimplePagesPage(); $page->modified_by_user_id = current_user()->id; $page->created_by_user_id = current_user()->id; $page->is_published = 1; $page->parent_id = 0; $page->title = 'About'; $page->slug = 'about'; $page->text = '<p>This is an example page. Feel free to replace this content, or delete the page and start from scratch.</p>'; $page->save(); $this->_installOptions(); }
/** * Create a Simple Pages page. * * @param boolean $public True if the page is public. * @param string $title The exhibit title. * @param string $slug The exhibit slug. * @return SimplePagesPage */ protected function _simplePage($public = true, $title = 'Test Title', $slug = 'test-slug') { $page = new SimplePagesPage(); // Set parent user and public/private. $page->created_by_user_id = current_user()->id; $page->is_published = $public; // Set text fields. $page->slug = $slug; $page->title = $title; $page->save(); return $page; }