
04-13-2009, 06:55 PM
|
|
forum loafer
|
|
Join Date: Dec 2008
Posts: 11
|
|
|
About Page Addon
Okay... I call it a "SpotLight" page, but it serves the same function. I see people post on here all the time asking how to update their About pages. Its usually people with very little HTML knowledge. So, I am trying to write my first addon to make this work in the admin screen. I have gotten far enough to create something with its own Tab in the admin screen and all. I just don't know how to make it work with markups. Does anyone want to clean this up a bit?
Quote:
<?PHP
if ($_GET['view']=='addons' && $_GET['spot']=='light') {
$_SESSION['spotlight'] = $_POST['spot'];
}
$addon_name = "<a name=\"APE\"></a>SpotLight";
$addon_version = "1.0";
$addon_description = "This Activates The SpotLight Section";
add_admin_functions('spot_light','info','','');
add_admin_functions('spot_light','options','option s','SpotLight');
add_admin_functions('','admin_main_menu','SpotLigh t','');
@mysql_query("CREATE TABLE IF NOT EXISTS `".$pixelpost_db_prefix."spotlighteditor` (`id` INT NOT NULL AUTO_INCREMENT,PRIMARY KEY(id),`spotlight_editor` TEXT NOT NULL)");
if($_POST['action'] == "update_spotlighteditor") {
### query the spotlight text database and pullout all the rows
$cquery = @mysql_query("SELECT * FROM `".$pixelpost_db_prefix."spotlighteditor`");
$spotlighteditor = @mysql_fetch_array($cquery);
### add slashes to special chars like ' and "
$spotlight_editor = addslashes($_POST['spotlight_editor']);
### if there is no id present in the database, we need to use the insert statement
if($spotlighteditor['id'] == '') {
@mysql_query("INSERT INTO `".$pixelpost_db_prefix."spotlighteditor` (`spotlight_editor`) VALUES('".$spotlight_editor."')");
} else { ### if we made it down here, we have an id and we can simply update the current row
@mysql_query("UPDATE `".$pixelpost_db_prefix."spotlighteditor` SET `spotlight_editor` = '".$spotlight_editor."'");
}
}
### query the about text database again and pullout all the rows
$query = @mysql_query("SELECT * FROM `".$pixelpost_db_prefix."spotlighteditor`");
$spotlighteditor = @mysql_fetch_array($query);
### remove those slashes we previously added for viewing
$spotlights = $spotlighteditor['spotlight_editor'];
$spotlights = stripslashes($spotlights);
add_admin_functions('spot_light','admin_main_menu_ contents','SpotLight','');
// hey, that is cool!
function spot_light()
{
$html =
<<<EOE
<form name="spotlighteditoraddon" id="formAPE" method="post" action="#APE">
<input name="action" type="hidden" value="update_spotlighteditor" />
<div class="jcaption" id="ara">Spotlight Instructions</div><BR>
<b>
<font color=#006600>(Use the box below to update your 'Info' page. Simply add info using the format in this example.)</font>
</b>
<BR><hr><BR>
<code><h2&g t;</code>
Put Your Title In This Space:
<code></h2></code>
<BR><BR>
<code><p> ;</code>
<BR>
Enter a paragraph about yourself here.
<BR>
<code></p></code>
<BR><BR>
<code><p> ;</code>
<BR>
Add another paragraph if you want to.
<BR>
<code></p></code>
<BR>
<BR><HR>
<b>
<font color=#006600>(Repeat This Format For Additional Sections.)</b></font><BR><BR><BR><BR>
<div class="jcaption" id="ara">Spotlight Page</div><BR>
Enter the details for your spotlight page here using the format above:<br />
<textarea name="spotlight_editor" id="spotlight_editor" rows="10" cols="90">
</textarea><br /><br />
<input type="submit" name="Submit" value="Submit" /><BR><BR>
<B><font color=#990000 ></font></b>
</form>
</div>
EOE;
echo $html;
}
### finally, our template tags
$tpl = str_replace("<SPOTLIGHT_PAGE>",$spotlights,$tpl);
?>
|
|