Skip to content

Commit

Permalink
added new text field (name) for gallery item, updated database
Browse files Browse the repository at this point in the history
  • Loading branch information
Goszu committed Jan 30, 2012
1 parent f60fe34 commit 886abab
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 11 deletions.
7 changes: 4 additions & 3 deletions database.sql
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,14 @@ DROP TABLE IF EXISTS `items`;
CREATE TABLE `items` (
`id` int(10) NOT NULL AUTO_INCREMENT,
`position` int(10) NOT NULL,
`name` varchar(50) DEFAULT NULL,
`link_txt` varchar(512) NOT NULL,
`link_url` varchar(512) NOT NULL,
`item_text` text NOT NULL,
`filename` varchar(50) NOT NULL,
`size` int(12) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM AUTO_INCREMENT=17 DEFAULT CHARSET=utf8;
) ENGINE=MyISAM AUTO_INCREMENT=19 DEFAULT CHARSET=utf8;
/*!40101 SET character_set_client = @saved_cs_client */;

--
Expand All @@ -40,7 +41,7 @@ CREATE TABLE `items` (

LOCK TABLES `items` WRITE;
/*!40000 ALTER TABLE `items` DISABLE KEYS */;
INSERT INTO `items` VALUES (9,1,'fly to venus !!!','www.google.co.uk','The planet venus...','venus.jpg',127937),(10,2,'Get the trip around the world','http://www.google.co.uk','Planet earth - our homeworld...','earth.jpg',50211),(11,4,'Mars flights discount','http://www.dochub.io','Mars - the red planet. Is there life on mars?','mars.jpg',139010),(12,3,'Buy properties on moon','http://nssdc.gsfc.nasa.gov','Moon the closest world from earth...','moon.jpg',59091),(16,5,'Get the Jupiter photos','http://www.guardian.co.uk','Jupiter - the gas gigant...','jupiter.jpg',109383);
INSERT INTO `items` VALUES (9,1,'Venus','fly to venus !!!','http://www.google.co.uk','The planet venus...','venus.jpg',127937),(10,2,'Earth','Get the trip around the world','www.google.co.uk','Planet earth - our homeworld...','earth.jpg',50211),(11,4,'Mars','Mars flights discount','http://www.dochub.io','Mars - the red planet. Is there life on mars?','mars.jpg',139010),(12,3,'Moon','Buy properties on moon','http://nssdc.gsfc.nasa.gov','Moon the closest world from earth...','moon.jpg',59091),(16,5,'Jupiter','Get the Jupiter photos','www.guardian.co.uk','Jupiter - the gas gigant...','jupiter.jpg',109383);
/*!40000 ALTER TABLE `items` ENABLE KEYS */;
UNLOCK TABLES;

Expand Down Expand Up @@ -78,4 +79,4 @@ UNLOCK TABLES;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;

-- Dump completed on 2012-01-30 0:20:02
-- Dump completed on 2012-01-30 23:32:43
3 changes: 2 additions & 1 deletion includes/item.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@
class Item {

protected static $table_name="items";
protected static $db_fields = array('id', 'position', 'link_txt', 'link_url', 'item_text', 'filename', 'size');
protected static $db_fields = array('id', 'position', 'name', 'link_txt', 'link_url', 'item_text', 'filename', 'size');

public $id;
public $position;
public $name;
public $link_txt;
public $link_url;
public $item_text;
Expand Down
7 changes: 4 additions & 3 deletions public/admin/additem.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

$item = new Item();
$item->position = $itemCount + 1;
$item->name = trim($_POST['name']);
$item->link_txt = trim($_POST['link_txt']);
$item->link_url = trim($_POST['link_url']);
$item->item_text = trim($_POST['item_text']);
Expand All @@ -33,14 +34,14 @@
<h2>Add Item</h2>
<?php echo output_message($message); ?>
<form action="additem.php" enctype="multipart/form-data" method="post">
<!--<label for="position">Position:</label>
<input type="text" name="position" maxlength="5" />-->
<label for="name">Item name:</label>
<input id="name" type="text" name="name" />
<label for="link_txt">Text for link:</label>
<input type="text" id="link_txt" name="link_txt" />
<label for="link_url">Link URL:</label>
<input type="text" id="link_url" name="link_url" />
<label for="item_text">Item Text:</label>
<textarea id="item_text" name="item_text" rows="10" cols="30"> </textarea>
<textarea id="item_text" name="item_text" rows="10" cols="30"></textarea>
<label for="file_upload">Photo file:</label>
<input id="file_upload" type="file" name="file_upload" />

Expand Down
5 changes: 4 additions & 1 deletion public/admin/edititem.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
if (isset($_POST['submit'])) {

$item = Item::find_by_id(trim($_POST['item_id']));
$item->name = trim($_POST['name']);
$item->link_txt = trim($_POST['link_txt']);
$item->link_url = trim($_POST['link_url']);
$item->item_text = trim($_POST['item_text']);
Expand All @@ -30,12 +31,14 @@
<h2>Edit item</h2>
<?php echo output_message($message); ?>
<form action="edititem.php?itemid=<?php echo trim($_GET['itemid']) ?>" method="post">
<label for="name">Item name:</label>
<input id="name" type="text" name="name" value="<?php echo $item->name ?>" />
<label for="link_txt">Text for link:</label>
<input id="link_txt" type="text" name="link_txt" value="<?php echo $item->link_txt ?>" />
<label for="link_url">Link URL:</label>
<input id="link_url" type="text" name="link_url" value="<?php echo $item->link_url ?>" />
<label for="item_text">Item Text:</label>
<textarea id="item_text" name="item_text" rows="10" cols="30"> <?php echo $item->item_text ?> </textarea>
<textarea id="item_text" name="item_text" rows="10" cols="30"><?php echo $item->item_text ?></textarea>
<input type="hidden" value="<?php echo trim($_GET['itemid']) ?>" name="item_id" />
<input type="submit" name="submit" value="Update Item" />
</form>
Expand Down
6 changes: 3 additions & 3 deletions public/admin/listitems.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@
<li class="ui-state-default" id="itemid-<?php echo $item->id ?>">
<input type="checkbox" value="<?php echo $item->id ?>" name="iid[]" />
<span><?php echo $item->id ?> </span>
<span><?php echo $item->item_text ?> </span>
<span><?php echo $item->filename ?> </span>
<span><?php echo $item->size_as_text() ?></span>
<span><strong>Name: </strong><?php echo $item->name ?> </span>
<span><strong>Filename: </strong><?php echo $item->filename ?> </span>
<span><strong>Size: </strong><?php echo $item->size_as_text() ?></span>
<span><a href="edititem.php?itemid=<?php echo $item->id ?>">Edit</a></span>
</li>
<?php } ?>
Expand Down
9 changes: 9 additions & 0 deletions public/css/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,19 @@ input, textarea {
margin-bottom: 10px;
}

#item_text {
width: 880px;
weight: 200px;
}

.sortable input {
display: inline;
}

.sortable li span {
margin-left: 10px;
}

#response {
padding: 10px;
}
Expand Down

0 comments on commit 886abab

Please sign in to comment.