$featured = isset($_POST['featured']) ? $_POST['featured'] : ''; $body = isset($_POST['body']) ? $_POST['body'] : ''; $url = isset($_POST['url']) ? $_POST['url'] : ''; $type = isset($_POST['type']) ? $_POST['type'] : ''; $published_date = isset($_POST['published_date']) ? $_POST['published_date'] : ''; $author = isset($_POST['author']) ? $_POST['author'] : ''; $tag = isset($_POST['tag']) ? $_POST['tag'] : ''; if (checkPermissions('createPage', $published)) { if (count($segments) > 4 && $segments[2] === 'revisions' && $segments[4] === 'extras') { $response = $Cosmo->revisionsExtrasCreate($segments[3], $segments[1], $name, $extra); } if (count($segments) > 2 && $segments[2] === 'revisions') { $response['id'] = $Cosmo->revisionsCreate($segments[1], $title, $description, $header, $subheader, $featured, $body, $url, $type, $published, $published_date, $author); } else { if (count($segments) > 2 && $segments[2] === 'extras') { $response = $Cosmo->contentExtrasCreate($segments[1], $name, $extra); } else { if (count($segments) > 2 && $segments[2] === 'tags') { $response = $Cosmo->contentTagsCreate($segments[1], $tag); } else { // Create a new page $response['id'] = $Cosmo->contentCreate($title, $description, $header, $subheader, $featured, $body, $url, $author, $type, $published, $published_date); } } } } break; case 'PUT': $published = isset($_PUT['published']) ? $_PUT['published'] : ''; $name = isset($_PUT['name']) ? $_PUT['name'] : ''; $extra = isset($_PUT['extra']) ? $_PUT['extra'] : '';
$stmt->execute($data); // Create new page $stmt = $pdo->prepare('INSERT INTO ' . $prefix . 'content (url, author, published) VALUES (?,?,?) ON DUPLICATE KEY UPDATE url=VALUES(url)'); $data = array('/new', 1, 'Y'); $stmt->execute($data); // Create error page $stmt = $pdo->prepare('INSERT INTO ' . $prefix . 'content (url, type, author, published) VALUES (?,?,?,?) ON DUPLICATE KEY UPDATE url=VALUES(url)'); $data = array('/error', 'home.html', 1, 'Y'); $stmt->execute($data); // Insert records try { // Create admin username/password $Cosmo->usersCreate($adminUsername, $email, $adminPassword, 'admin'); // Create first post $Cosmo->contentCreate('Welcome to Cosmo', 'Welcome to Pendant, a blog theme developed for Cosmo.', 'Welcome to Cosmo', 'Your new website awaits', 'uploads/MIbCzcvxQdahamZSNQ26_12082014-IMG_3526-54571eebdae22.jpg', '<p class="ng-scope">Your site is now running on Cosmo, an open source content management system that\'s designed to help make editing your website quick and easy, it\'s created by James and<a href="http://twitter.com/jordandunn"> Jordan Dunn</a>. If this is your first time using Cosmo we recommend <a href="http://cosmocms.org/cosmo-basics">checking out our how-to\'s</a> for creating pages, editing content, uploading media and more. Once you\'re ready to make your first page, click the umbrella to your left, go to content > new page and you\'ll be on your way.</p><p class="ng-scope"><span class="ng-scope">If you\'re looking to create a new theme for Cosmo you can view all documentation for <a href="http://cosmocms.org/how-to-create-a-theme-for-cosmo">theme creation</a> along with how to use or <a href="http://cosmocms.org/how-to-create-a-module-for-cosmo">create new modules</a> to run within Cosmo.</span></p><p class="ng-scope">If you\'re looking for some free photos to work well with your new site, we recommend checking out <a href="http://deathtothestockphoto.com">Death to Stock Photo</a> or <a href="https://unsplash.com">Unsplash</a>.</p><p class="ng-scope">Once your website is up and running, <a href="http://twitter.com/cosmocms">send us a link</a> so we can check it out and maybe even highlight it on our website or social media.</p>', '/welcome-to-cosmo', 1, 'post.html', 'Y', NULL); $Cosmo->contentExtrasCreate(4, 'featured', '{"id":"featured","alt":"Welcome","src":"uploads/MIbCzcvxQdahamZSNQ26_12082014-IMG_3526-54571eebdae22.jpg","size":"responsive","responsive":"yes"}'); $Cosmo->contentTagsCreate(4, 'blog'); // Insert first file $stmt = $pdo->prepare('INSERT INTO ' . $prefix . 'files (filename, responsive, type, timestamp) VALUES (?,?,?,?)'); $data = array('uploads/MIbCzcvxQdahamZSNQ26_12082014-IMG_3526-54571eebdae22.jpg', 'yes', 'image', time()); $stmt->execute($data); // Insert first block $Cosmo->blocksCreate('Home Page'); $Cosmo->blocksUpdate('Home Page', '<div one-post="blog"></div>', 0, 'block1', 1); $Cosmo->blocksRequirementsCreate(1, 'visible', '/'); // Insert footer block $Cosmo->blocksCreate('Copyright'); $Cosmo->blocksUpdate('Copyright', '<p>Copyright © {{page.current_year}} | Built with <a href="http://www.cosmocms.org/"><img class="cosmo-logo" alt="Single Page Application CMS" src="core/img/cosmo-logo.svg"></a></p>', 0, 'footer', 2); // Insert example primary menu $Cosmo->menusCreate('Primary'); $Cosmo->menusUpdate(1, 'Primary', '[{"id":1,"title":"About","url":"about","items":[]},{"id":100,"title":"Contact","url":"contact","items":[]}]', 'primary');