/** * Update a Page of the module * @param page $page */ public function updatePage(page $page) { $id = $page->getId(); $this->pages[$id] = $page->getRegex(); $page->save(); }
$fail = TRUE; $redmsg .= "<p>You must have a title between 3 and 50 characters.</p>"; } if (isset($_POST['content'])) { $page->text = $_POST['content']; } else { $fail = TRUE; $redmsg .= "<p>You must have some content.</p>"; } if (isset($_POST['ispublic'])) { $page->ispublic = TRUE; } else { $page->ispublic = FALSE; } if ($fail == FALSE) { if ($page->save()) { $greenmsg .= "<p>The page has been published.</p>"; } else { $redmsg .= "<p>Failed to save page.</p>"; $title = $_POST['title']; $content = $_POST['content']; } } else { $title = $_POST['title']; $content = $_POST['content']; } if ($redmsg != "") { $redmsg = '<div class="notification red">' . $redmsg . '</div>'; } if ($greenmsg != "") { $greenmsg = '<div class="notification green">' . $greenmsg . '</div>';
function createNewObject($object_type, $post_vars, $system_data_classes, $object_save = 0) { if (!$object_type) { return false; } if (!in_array($object_type, $system_data_classes)) { return false; } switch ($object_type) { case "page": $object = new page("new page"); $object->update_document_props($post_vars); if ($object_save == 1) { $object->createContent(); $object->save(); } break; case "process": $object = new process("new process"); $object->update_document_props($post_vars); $object->update_design_props($post_vars); if ($object_save == 1) { $object->save(); } break; case "section": $object = new section("new section"); $object->update_document_props($post_vars); if ($object_save == 1) { $object->createContent(); $object->save(); } break; case "image": $object = new image("new image"); $object->update_document_props($post_vars); if ($object_save == 1) { $object->save(); } break; case "file": $object = new file("new file"); $object->update_document_props($post_vars); if ($object_save == 1) { $object->save(); } break; default: break; } return $object; }
public function testCreateSameIDDifferentLanguage() { $page = new page; $page->language = 'en'; $page->title = 'Test Blog'; $page->content = 'A'; $page->authorID = 'nathan'; $page->save(); $id1 = $page->ID; $page = new page; $page->language = 'nl'; $page->title = 'Test Blog'; $page->content = 'B'; $page->authorID = 'nathan'; $page->save(); $id2 = $page->ID; $this->assertEquals($id1, $id2); $page1 = Page::get($id1, 'en'); $page2 = Page::get($id2, 'nl'); $this->assertEquals('Test Blog', $page1->title); $this->assertEquals('Test Blog', $page2->title); $this->assertEquals('A', $page1->content); $this->assertEquals('B', $page2->content); }
public static function addToNavigation() { $page = new page(); $pluginsManager = pluginsManager::getInstance(); // Création d'items de navigation absents (plugins) foreach ($pluginsManager->getPlugins() as $k => $plugin) { if ($plugin->getConfigVal('activate') && $plugin->getPublicFile() && $plugin->getName() != 'page') { $find = false; foreach ($page->getItems() as $k2 => $pageItem) { if ($pageItem->getTarget() == $plugin->getName()) { $find = true; } } if (!$find) { $pageItem = new pageItem(); $pageItem->setName($plugin->getInfoVal('name')); $pageItem->setPosition($page->makePosition()); $pageItem->setIsHomepage(0); $pageItem->setContent(''); $pageItem->setIsHidden(0); $pageItem->setFile(''); $pageItem->setTarget($plugin->getName()); $page->save($pageItem); } } } // génération de la navigation foreach ($page->getItems() as $k => $pageItem) { if (!$pageItem->getIsHidden()) { $core = core::getInstance(); $pluginsManager->getPlugin('page')->addToNavigation($pageItem->getName(), $page->makeUrl($pageItem), $pageItem->getTargetAttr()); } } }
$pageItem = $page->create($_POST['id']); } else { $pageItem = new pageItem(); } $pageItem->setName($_POST['name']); $pageItem->setPosition($_POST['position']); $pageItem->setIsHomepage(isset($_POST['isHomepage']) ? 1 : 0); $pageItem->setContent($_POST['content']); $pageItem->setFile($_POST['file']); $pageItem->setIsHidden(isset($_POST['isHidden']) ? 1 : 0); $pageItem->setMainTitle($_POST['mainTitle']); $pageItem->setMetaDescriptionTag($_POST['metaDescriptionTag']); $pageItem->setMetaTitleTag($_POST['metaTitleTag']); $pageItem->setTarget($_POST['target']); $pageItem->setTargetAttr($_POST['targetAttr']); if ($page->save($pageItem)) { $msg = $core->lang("The changes have been saved."); $msgType = 'success'; } else { $msg = $core->lang("An error occurred while saving the changes."); $msgType = 'error'; } header('location:index.php?p=page&msg=' . urlencode($msg) . '&msgType=' . $msgType); die; } break; case 'edit': if (isset($_GET['id'])) { $pageItem = $page->create($_GET['id']); } else { $pageItem = new pageItem();