Anonymous avatar Anonymous committed c19376f

Initial commit.

Comments (0)

Files changed (6)

admin/admin.prof3tablog.html.php

+<?php
+
+/** ensure this file is being included by a parent file */
+defined( '_JEXEC' ) or die( 'Restricted access' );
+
+class prof3tablogScreens {
+   
+	function view() {
+
+		// Connect to the DB
+		$db =& JFactory::getDBO();
+
+		// Select all the Projects
+		$query = "SELECT * FROM #__prof3ta_blog_articles";
+		$db->setQuery( $query, 0);
+
+		// ... And print them!
+
+		// Table is not empty
+		if ($articles = $db->loadObjectList()) {
+			foreach ($articles as $article) {
+				echo $article->title."<br />";
+			}
+		} else {
+			echo "No articles in the database.<br />";
+		}
+
+	}
+
+	function addForm() {
+
+		echo "<form id=\"addForm\" name=\"addForm\" method=\"post\" action=\"index.php?option=com_prof3tablog&task=add\">";
+		echo "<table>";
+		echo "<tr><td>Title:<td/><td><input name=\"articleTitle\" type=\"text\" id=\"articleTitle\" /></td></tr>";
+		echo "<tr><td>Text:<td/><td>
+		<textarea name=\"articleText\" rows=20></textarea>
+		</td></tr>";
+		echo "<tr><td>Date (YYYY-MM-DD):<td/><td><input name=\"articleDate\" type=\"text\" id=\"articleDate\" /></td></tr>";
+		echo "</table>";
+		echo "<input type=\"submit\" name=\"Submit\" value=\"Add\" /><br />";
+		echo "</form>";
+
+	}
+
+	function add() {
+
+		// Connect to the DB
+		$db =& JFactory::getDBO();
+
+		$articleTitle = "'" . $db->getEscaped(JRequest::getVar('articleTitle')) . "'";
+		$articleText = "'" . addslashes(JRequest::getVar('articleText','','POST','STRING',JREQUEST_ALLOWRAW)) . "'";
+		$articleDate = "'" . $db->getEscaped(JRequest::getVar('articleDate')) . "'";
+
+		$query = "INSERT INTO `#__prof3ta_blog_articles` VALUES ('',".$articleTitle.", ".$articleText.", ". $articleDate .");";
+		$db->setQuery($query, 0);
+		$db->query();
+		echo "Article succesfully inserted!<br />";
+
+	}
+
+	function edit() {
+
+		// Connect to the DB
+		$db =& JFactory::getDBO();
+
+		$articleTitle = "'" . $db->getEscaped(JRequest::getVar('articleTitle')) . "'";
+		$articleId = "'" . $db->getEscaped(JRequest::getVar('articleId')) . "'";
+		$articleText = "'" . addslashes(JRequest::getVar('articleText','','POST','STRING',JREQUEST_ALLOWRAW)) . "'";
+		$articleDate = "'" . $db->getEscaped(JRequest::getVar('articleDate')) . "'";
+
+		$updateQuery = "UPDATE #__prof3ta_blog_articles SET title = ". $articleTitle .", text=".$articleText.", date=".$articleDate." WHERE id = ". $articleId .";";
+
+		$db->setQuery( $updateQuery );
+		$db->query();
+		echo JText::_('Article Details edited succesfully.');
+
+	}
+
+	function editChoose() {
+
+		// Connect to the DB
+		$db =& JFactory::getDBO();
+
+		// Select all the Projects
+		$query = "SELECT * FROM #__prof3ta_blog_articles";
+		$db->setQuery( $query, 0);
+
+		// ... And print them!
+
+		// Table is not empty
+		if ($articles = $db->loadObjectList()) {
+			JText::_('Select the article:<br/>');
+			echo "<form id=\"editChooseForm\" name=\"editChooseForm\" method=\"post\" action=\"index.php?option=com_prof3tablog&task=edit\">";
+			foreach ($articles as $article) {
+				echo "<INPUT TYPE='radio' NAME='articleId' VALUE='".$article->id."'> ";
+				echo $article->title."<br />";
+			}
+			echo "<br/>";
+			echo "<input type=\"submit\" name=\"Submit\" value=\"Go\" />";
+			echo "</form>";
+		} else {
+			echo "No articles in the database.<br />";
+		}
+
+	}
+
+	function editForm() {
+
+		// Connect to the DB
+		$db =& JFactory::getDBO();
+
+		$articleId = $db->getEscaped(JRequest::getVar('articleId'));
+
+		$query = "SELECT * FROM #__prof3ta_blog_articles WHERE id=".$articleId."";
+		$db->setQuery( $query, 0);
+
+		// ... And print them!
+
+		// Table is not empty
+		if ($article = $db->loadObject()) {
+			$articleTitle = $article->title;
+			$articleText = $article->text;
+			$articleDate = $article->date;
+
+		echo "<form id=\"editForm\" name=\"editForm\" method=\"post\" action=\"index.php?option=com_prof3tablog&task=edit\">";
+		echo "<table>";
+		echo "<tr><td>Title:<td/><td><input name=\"articleTitle\" type=\"text\" id=\"articleTitle\" value=\"".$articleTitle."\"/></td></tr>";
+		echo "<tr><td>Text:<td/><td>
+		<textarea name=\"articleText\" rows=20 \">".$articleText."</textarea>
+		</td></tr>";
+		echo "<tr><td>Date:<td/><td><input name=\"articleDate\" type=\"text\" id=\"articleDate\" value=\"".$articleDate."\"/></td></tr>";
+		echo "</table>";
+		echo "<input type='hidden' id='articleId' name='articleId' value='".$articleId."'> ";
+		echo "<input type=\"submit\" name=\"Submit\" value=\"Edit\" /><br />";
+		echo "</form>";
+
+		} else {
+			JText::_('Error');
+		}
+
+	}
+
+	function delete() {
+
+		// Connect to the DB
+		$db =& JFactory::getDBO();
+
+		$articleId = "'" . $db->getEscaped(JRequest::getVar('articleId')) . "'";
+
+		$query = "DELETE FROM `#__prof3ta_blog_articles` WHERE id=".$articleId.";";
+		$db->setQuery($query, 0);
+		$db->query();
+		echo "Article succesfully deleted!<br />";
+
+	}
+
+	function deleteChoose() {
+
+		// Connect to the DB
+		$db =& JFactory::getDBO();
+
+		// Select all the Articles
+		$query = "SELECT * FROM #__prof3ta_blog_articles";
+		$db->setQuery( $query, 0);
+
+		// ... And print them!
+
+		// Table is not empty
+		if ($articles = $db->loadObjectList()) {
+			JText::_('Select the article:<br/>');
+			echo "<form id=\"deleteChooseForm\" name=\"deleteChooseForm\" method=\"post\" action=\"index.php?option=com_prof3tablog&task=delete\">";
+			foreach ($articles as $article) {
+				echo "<INPUT TYPE='radio' NAME='articleId' VALUE='".$article->id."'> ";
+				echo $article->title."<br />";
+			}
+			echo "<input type=\"submit\" name=\"Submit\" value=\"Go\" />";
+			echo "</form>";
+		} else {
+			echo "No articles in the database.<br />";
+		}
+
+	}
+
+}
+?>

admin/admin.prof3tablog.php

+<?php
+
+// no direct access
+defined( '_JEXEC' ) or die( 'Restricted access' );
+
+require_once( JApplicationHelper::getPath( 'admin_html' ) );
+
+switch ($task) {
+	case 'add':
+		if(JRequest::getVar('articleTitle')) {
+			prof3tablogScreens::add();
+		} else {
+			prof3tablogScreens::addForm();
+		}
+		break;
+	case 'edit':
+		if(JRequest::getVar('articleTitle')) {
+			prof3tablogScreens::edit();
+		} else {
+			if(JRequest::getVar('articleId')) {
+				prof3tablogScreens::editForm();
+			} else {
+				prof3tablogScreens::editChoose();
+			}
+		}
+		break;
+	case 'view':
+		prof3tablogScreens::view();
+		break;
+	case 'delete':
+		if(JRequest::getVar('articleId')) {
+			prof3tablogScreens::delete();
+		} else {
+			prof3tablogScreens::deleteChoose();
+		}
+		break;
+
+	default:
+		break;
+}
+?>
+<html><body bgcolor="#FFFFFF"></body></html>

com_prof3tablog.xml

+<?xml version="1.0" encoding="utf-8"?>
+<!DOCTYPE install SYSTEM "http://dev.joomla.org/xml/1.5/component-install.dtd">
+<install type="component" version="1.5.0">
+	<name>Prof3ta Blog</name>
+	<creationDate>December 2007</creationDate>
+	<author>Roberto Aloi (a.k.a. Prof3ta)</author>
+	<authorEmail>prof3ta@gmail.com</authorEmail>
+	<authorUrl>http://prof3ta.netsons.org</authorUrl>
+	<copyright>(C) 2007 All rights reserved.</copyright>
+	<license>GNU/GPL</license>
+	<version>1.5.0 Beta</version>
+	<description>
+		Your Personal Joomla! Blog
+	</description> 
+
+	<install>
+		<queries>
+			<query>CREATE TABLE IF NOT EXISTS `#__prof3ta_blog_articles` (`id` INTEGER UNSIGNED NOT NULL AUTO_INCREMENT, `title` VARCHAR(400) NOT NULL, `text` TEXT, `date` VARCHAR(10), PRIMARY KEY(`id`));</query>
+		</queries>
+	</install>
+
+	<uninstall>
+		<queries>
+			<query>DROP TABLE IF EXISTS `#__prof3ta_blog_articles`;</query>
+		</queries>
+	</uninstall>
+
+	<!-- Site Main File Copy Section-->
+	<files>
+		<filename>index.html</filename>
+		<filename>prof3tablog.php</filename>
+	</files>
+	
+	<administration>
+	
+		<!-- Administration Menu Section -->
+		<menu>Prof3ta Blog</menu>
+		<submenu>
+			<menu link="option=com_prof3tablog&amp;task=add">Add an article</menu>
+			<menu link="option=com_prof3tablog&amp;task=edit">Edit an article</menu>
+			<menu link="option=com_prof3tablog&amp;task=delete">Delete an article</menu>
+			<menu link="option=com_prof3tablog&amp;task=view">View all articles</menu>
+		</submenu>
+		
+		<!-- Administration Main File Copy Section -->
+		<files folder="admin">
+			<filename>index.html</filename>
+			<filename>admin.prof3tablog.php</filename>
+			<filename>admin.prof3tablog.html.php</filename>
+		</files>
+
+	</administration>
+</install>
+<html><body bgcolor="#FFFFFF"></body></html>
+<?php
+
+// no direct access
+defined( '_JEXEC' ) or die( 'Restricted access' );
+
+// Connect to the DB
+$db =& JFactory::getDBO();
+
+// Select the last 10 Articles
+$query = "SELECT * FROM #__prof3ta_blog_articles ORDER BY date DESC;";
+$db->setQuery( $query, 0);
+
+// ... And print them!
+
+// Table is not empty
+if ($articles = $db->loadObjectList()) {
+	$i = 0;
+	foreach ($articles as $article) {
+		if ($i<10) {
+			echo "<h2>" . $article->title . "</h2>";
+			echo "<div align='justify'>";
+			echo $article->text . "<br /><br />";
+			echo "Posted: " . $article->date;
+			echo "<hr>";
+			echo "</div>";
+			$i++;
+		}
+	}
+} else {
+	echo "No articles in the database.<br />";
+}
+
+?>
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.