-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathblogpost.php
More file actions
89 lines (83 loc) · 3.8 KB
/
Copy pathblogpost.php
File metadata and controls
89 lines (83 loc) · 3.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
<?php
$action = (!empty($_POST['btn_submit']) &&
($_POST['btn_submit'] === 'Salvar')) ? 'save_article' : 'show_form';
switch($action) {
case 'save_article':
try{
$connection = new Mongo();
$database = $connection->selectDB('myblogsite');
$collection = $database->selectCollection('articles');
$article = array(
'title' => $_POST['title'],
'content' => $_POST['content'],
'tags' => $_POST['tags'],
'saved_at' => new MongoDate()
);
$collection->insert($article);
} catch(MongoConnectionException $e) {
die("Fallo al conectar con la base de datos" .
$e->getMessage());
} catch(MongoException $e) {
die("Fallo al insertar los datos " . $e->getMessage());
}
break;
case 'show_form':
default:
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xmlns" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<link rel="stylesheet" href="style.css"/>
<link rel="shortcut icon" type="image/x-icon" href="images/favicon.ico" />
<title>Blog Post</title>
<script type="text/javascript" src="tinymce/jscripts/tiny_mce/tiny_mce.js"></script>
<script language="javascript" type="text/javascript">
tinyMCE.init({
mode: "textareas",
theme: "advanced",
plugins : "autolink,lists,pagebreak,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,inlinepopups,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template,wordcount,advlist,autosave,visualblocks",
// Theme options
theme_advanced_buttons1 : "save,newdocument,|,bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,styleselect,formatselect,fontselect,fontsizeselect",
theme_advanced_buttons2 : "cut,copy,paste,pastetext,pasteword,|,search,replace,|,bullist,numlist,blockquote,|,undo,redo,|,link,unlink,anchor,image,code,|,insertdate,inserttime,preview,|,forecolor,backcolor",
theme_advanced_buttons3 : "hr,removeformat,visualaid,|,sub,sup,|,charmap,emotions,iespell,media,advhr,|,print,|,ltr,rtl,|,fullscreen",
theme_advanced_toolbar_location : "top",
theme_advanced_toolbar_align : "left",
theme_advanced_statusbar_location : "bottom",
theme_advanced_resizing : true,
template_external_list_url : "tinymce/jscripts/lists/template_list.js",
external_link_list_url : "tinymce/jscripts/lists/link_list.js",
external_image_list_url : "tinymce/jscripts/lists/image_list.js",
media_external_list_url : "tinymce/jscripts/lists/media_list.js",
skin_variant: "silver",
width: "450"});
</script>
</head>
<body>
<div id="contentarea">
<div id="innercontentarea">
<div id="logotype">
<h1>Blog Post<h1>
</div>
<?php if ($action === 'show_form'): ?>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
<!-- <h4>Titulo</h3> -->
<p><input type="text" name="title" id="title" /></p>
<h4>Contenido</h3>
<textarea name="content" rows="20"></textarea>
<h5>Tags</h4>
<p><input type="text" name="tags" id="tags" /></p>
<div id="botoiak">
<p><input type="submit" name="btn_submit" value="Salvar" />
<input type="reset" name="btn_reset" value="Borrar" /> </p>
</div>
</form>
<?php else: ?>
<p>Articulo guardado. _id:<?php echo $article['_id']; ?>. <br>
<a href="blogpost.php">Deseas escribir algo mas?</a></p>
<?php endif; ?>
</div>
</div>
</body>
</html>