Pixelpost

Authentic Photoblog Flavour


Go Back   Pixelpost Forum > DEVELOPMENT > Addons

Post Reply
 
Thread Tools
  #1  
Old 05-11-2007, 02:47 PM
tommaso Offline
forum loafer
 
Join Date: Feb 2007
Location: Italy
Posts: 19
ADDON: About Text AddOn

Hi all,

I did a little addon that allows to use two new tags:

<ABOUT_TEXT>
<ABOUT_TEXT_ALT>

I use it on my site to write down a couple of words about me.
Without it I had to open html template files to change text.

I hope you enjoy it (and test it btw).

I had an issue about the text lengh which is now restricted to mysql varchar type maximum (255). I tried to use text/longtext types but my server seems to not accept it.
Any suggestion?

download it here: http://www.tomsights.net/templates/t...about_text.zip
live here: http://www.tomsights.net/index.php?x=about

bye
Tommaso
TomSights.net
Reply With Quote
  #2  
Old 05-11-2007, 03:11 PM
dakwegmo's Avatar
dakwegmo+ Offline
Team Pixelpost
 
Join Date: Jul 2005
Location: West of Between
Posts: 689
Hey cool. I was going to suggest this is a feature for 1.7, then decided it might be better as an addon. I'll have to test it when I get home.
__________________
My Photoblog
If you find my help useful please consider feeding the PixelPost Kitty
If you're short on cash just feed my ego
Reply With Quote
  #3  
Old 05-13-2007, 05:52 PM
Dennis's Avatar
Dennis+ Offline
Team Pixelpost
 
Join Date: Jul 2006
Posts: 2,394
Send a message via MSN to Dennis
Nice addon, I'll surely have a look at it.
__________________
My photoblog, powered by PixelPost 1.9 dev SVN | My Pixelpost Addons | My Cool Photoblog profile
Reply With Quote
  #4  
Old 05-14-2007, 10:16 PM
sentinel's Avatar
sentinel Offline
pixelpost guru
 
Join Date: Sep 2005
Posts: 130
Quote:
Originally Posted by tommaso View Post
I had an issue about the text lengh which is now restricted to mysql varchar type maximum (255). I tried to use text/longtext types but my server seems to not accept it.
what error did arise when u tried to use text as data type.. afaik tinytext, text, mediumtext and longtext should be supported since 4.0 (which for sure matches the needs for pp)

[edit] did you use DEFAULT values with text data type too? because text and blob can not have default values. without the default values in the ALTER statements it should work
__________________
my pp
good day good light
\martin_d
Reply With Quote
  #5  
Old 05-15-2007, 08:36 AM
tommaso Offline
forum loafer
 
Join Date: Feb 2007
Location: Italy
Posts: 19
Thanks Sentinel!

I cut the default value and now it works with text type.
Updated here: http://www.tomsights.net/templates/t...about_text.zip

At this time the two fileds "about_text" and "about_text_alt" must be removed before reinstalling the addon.

I'll work on a tool to delete them from the the db via pixelpost addon page.

bye
Tommaso
TomSights.net
Reply With Quote
  #6  
Old 05-15-2007, 11:23 AM
dhdesign's Avatar
dhdesign Offline
pixelpost guru
 
Join Date: Mar 2007
Location: Ohio
Posts: 431
Nice addon! Am going to give it a try later this AM.

A couple of comments I have after looking at the code:

1. Most of the other addons that I have installed (advanced comment stats and image stats) create a new database table to store their info in. Your addon is altering the pixelpost config table. Would it be easier to code the install/uninstall portions if you created a new table called 'about', rather than altering the configuration table?

2. In the code, you are using <font> tags to show the message that the texts have been updated. The <font> tag is deprecated and should probably be changed to <span> tags (<span style=\"color: blue;\">Updated about texts.</span>).
Reply With Quote
  #7  
Old 05-16-2007, 05:04 AM
Dkozikowski's Avatar
Dkozikowski+ Offline
Team Pixelpost
 
Join Date: Oct 2005
Posts: 1,855
Send a message via AIM to Dkozikowski
Nice start but this must be refined some more.

As dhdesign has stated, creating its own table is a much better practice than adding onto pixelposts default tables.

Also, you insert the about text into the database "as is" without taking the proper steps to encode and decode the text.

For example, when someone enters the following about text:

Hello there. This is dwilkinsjr's photoblog.

it will insert into the database as:

Hello there. This is dwilkinsjr\'s photoblog.

Sometimes, the database will not add the \ by itself and then some issues may arise.

Anyway, when this same person uses the tag to display their about text on their website, the \ will remain depending on the servers magic_quote settings.

Hopefully you understand what I am saying. I tried to explain it as best as possible. I will clean your addon up for you and reconfigure it to use its own database table. If you wish to see this copy, please send me a private message.
Reply With Quote
  #8  
Old 05-16-2007, 07:40 AM
tommaso Offline
forum loafer
 
Join Date: Feb 2007
Location: Italy
Posts: 19
Thanks dwilkinsjr, I will continue on your version with the part of uninstall.

Quote:
Originally Posted by dhdesign View Post
2. In the code, you are using <font> tags to show the message that the texts have been updated. The <font> tag is deprecated and should probably be changed to <span> tags (<span style=\"color: blue;\">Updated about texts.</span>).
I will fix this too. Thanks

bye
__________________
Porfolio
Reply With Quote
  #9  
Old 05-16-2007, 08:00 AM
Dkozikowski's Avatar
Dkozikowski+ Offline
Team Pixelpost
 
Join Date: Oct 2005
Posts: 1,855
Send a message via AIM to Dkozikowski
Quote:
Originally Posted by tommaso View Post
Thanks dwilkinsjr, I will continue on your version with the part of uninstall.
I'm not sure what you mean about the uninstall part but here is a much cleaner and properly encoded script.

The code is bellow but it may be easier to grab it from http://public.dwilkinsjr.com/pixelpo...bout_text.phps

PHP Code:
<?php

/*
About Text AddOn - Version 1.01
Last update: 05/16/2007
First version: 05/11/2007
Written by: Tommaso Carullo - tom|at|tomsights|dot|net - www.tomsights.net
Refined by: Dwilkinsjr - dwilkinsjr|at|dwilkinsjr|dot|com - www.dwilkinsjr.com
Requires Pixelpost version 1.5 or newer

CHANGE LOG:
05/15/2007: Fixed the problem about data types (thanks to Sentinel, www.digitalview.at)
05/11/2007: First test emission, it works but have an open issue on data type of about fields

License: http://www.gnu.org/copyleft/gpl.html

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

*/


$addon_name "<a name=\"ATA\"></a>About Text Addon";
$addon_version "1.01";
$addon_description "Type the text to be displayed with &lt;ABOUT_TEXT&gt; or &lt;ABOUT_TEXT_ALT&gt; tags.<br />\n";
$addon_description .= "<p>Created by <a href='http://www.tomsights.net'>Tommaso Carullo</a> Refined by <a href='http://www.dwilkinsjr.com'>Dwilkinsjr</a></p>\n";

global 
$pixelpost_db_prefix;

### create the about text table to store the about text information
@mysql_query("CREATE TABLE IF NOT EXISTS `".$pixelpost_db_prefix."abouttxt` (`id` INT NOT NULL AUTO_INCREMENT,PRIMARY KEY(id),`about_txt` TEXT NOT NULL,`about_txt_alt` TEXT NOT NULL)");


if(
$_POST['action'] == "update_abouttxt") {
    
    
### query the about text database and pullout all the rows
    
$cquery   = @mysql_query("SELECT * FROM `".$pixelpost_db_prefix."abouttxt`");
    
$abouttxt = @mysql_fetch_array($cquery);

    
### add slashes to special chars like ' and "
    
$about_txt addslashes($_POST['about_txt']);
    
    
### add slashes to special chars like ' and "
    
$about_txt_alt addslashes($_POST['about_txt_alt']);
    
    
### check if an id is currently present within the about text database
    
if($abouttxt['id'] != '') {
    
        
### we have an id so we can simply update the current row
        
@mysql_query("UPDATE `".$pixelpost_db_prefix."abouttxt` SET `about_txt` = '".$about_txt."', `about_txt_alt` = '".$about_txt_alt."'");
    } else { 
### if we made it down here, there is no id present in the database, we need to use the insert statement

        
@mysql_query("INSERT INTO `".$pixelpost_db_prefix."abouttxt` (`about_txt`, `about_txt_alt`) VALUES('".$about_txt."','".$about_txt_alt."')");
    }
}

### query the about text database again and pullout all the rows
$cquery   = @mysql_query("SELECT * FROM `".$pixelpost_db_prefix."abouttxt`");
$abouttxt = @mysql_fetch_array($cquery);

### remove those slashes we previously added for viewing
$about $abouttxt['about_txt'];
$about stripslashes($about);

### remove those slashes we previously added for viewing
$about_alt $abouttxt['about_txt_alt'];
$about_alt stripslashes($about_alt);


### lets output our form
$addon_description .= "\n<form name=\"abouttxtaddon\" id=\"formATA\" method=\"post\" action=\"#ATA\">\n";
$addon_description .= "<input name=\"action\" type=\"hidden\" value=\"update_abouttxt\" />\n\n";

$addon_description .= "<table border=\"0\" cellspacing=\"2\" cellpadding=\"3\">\n";
$addon_description .= "  <tr>\n";
$addon_description .= "    <td align=\"left\" valign=\"middle\">&nbsp;About Main Lang:</td>\n";
$addon_description .= "  </tr>\n";
$addon_description .= "  <tr>\n";
$addon_description .= "    <td align=\"center\" valign=\"middle\"><textarea name=\"about_txt\" id=\"about_txt\" rows=\"3\" cols=\"30\">".$about."</textarea></td>\n";
$addon_description .= "  </tr>\n";
$addon_description .= "  <tr>\n";
$addon_description .= "    <td></td>\n";
$addon_description .= "  </tr>\n";
$addon_description .= "  <tr>\n";
$addon_description .= "    <td align=\"left\" valign=\"middle\">&nbsp;About Alternative Lang:</td>\n";
$addon_description .= "  </tr>\n";
$addon_description .= "  <tr>\n";
$addon_description .= "    <td align=\"center\" valign=\"middle\"><textarea name=\"about_txt_alt\" id=\"about_txt_alt\" rows=\"3\" cols=\"30\">".$about_alt."</textarea></td>\n";
$addon_description .= "  </tr>\n";
$addon_description .= "  <tr>\n";
$addon_description .= "    <td align=\"right\" valign=\"middle\"><input type=\"submit\" name=\"Submit\" value=\"Submit\" /></td>\n";
$addon_description .= "  </tr>\n";
$addon_description .= "</table>\n\n";

$addon_description .= "</form>\n\n";


### finally, our template tags
$tpl str_replace("<ABOUT_TEXT>",$about,$tpl);
$tpl str_replace("<ABOUT_TEXT_ALT>",$about_alt,$tpl);
?>

Last edited by Dkozikowski; 05-16-2007 at 08:38 AM.
Reply With Quote
  #10  
Old 06-11-2007, 01:58 PM
dhdesign's Avatar
dhdesign Offline
pixelpost guru
 
Join Date: Mar 2007
Location: Ohio
Posts: 431
dwilkinsjr -

I refined the code you wrote to remove the table layout for the admin form. Feel free to use this version if you want.

PHP Code:
<?php
/*
About Text AddOn - Version 1.01
Last update: 05/16/2007
First version: 05/11/2007
Written by: Tommaso Carullo - tom|at|tomsights|dot|net - www.tomsights.net
Refined by: Dwilkinsjr - dwilkinsjr|at|dwilkinsjr|dot|com - www.dwilkinsjr.com
Requires Pixelpost version 1.5 or newer

CHANGE LOG:
05/15/2007: Fixed the problem about data types (thanks to Sentinel, www.digitalview.at)
05/11/2007: First test emission, it works but have an open issue on data type of about fields

License: http://www.gnu.org/copyleft/gpl.html

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

*/


$addon_name "<a name=\"ATA\"></a>About Text Addon";
$addon_version "1.01";
$addon_description "Type the text to be displayed with &lt;ABOUT_TEXT&gt; or &lt;ABOUT_TEXT_ALT&gt; tags.<br />\n";
$addon_description .= "<p>Created by <a href='http://www.tomsights.net'>Tommaso Carullo</a>. Refined by <a href='http://www.dwilkinsjr.com'>Dwilkinsjr</a>.</p>\n";

global 
$pixelpost_db_prefix;

### create the about text table to store the about text information
@mysql_query("CREATE TABLE IF NOT EXISTS `".$pixelpost_db_prefix."abouttxt` (`id` INT NOT NULL AUTO_INCREMENT,PRIMARY KEY(id),`about_txt` TEXT NOT NULL,`about_txt_alt` TEXT NOT NULL)");


if(
$_POST['action'] == "update_abouttxt") {
    
    
### query the about text database and pullout all the rows
    
$cquery   = @mysql_query("SELECT * FROM `".$pixelpost_db_prefix."abouttxt`");
    
$abouttxt = @mysql_fetch_array($cquery);

    
### add slashes to special chars like ' and "
    
$about_txt addslashes($_POST['about_txt']);
    
    
### add slashes to special chars like ' and "
    
$about_txt_alt addslashes($_POST['about_txt_alt']);
    
    
### if there is no id present in the database, we need to use the insert statement
    
if($abouttxt['id'] == '') {
    
        @
mysql_query("INSERT INTO `".$pixelpost_db_prefix."abouttxt` (`about_txt`, `about_txt_alt`) VALUES('".$about_txt."','".$about_txt_alt."')");
    } 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."abouttxt` SET `about_txt` = '".$about_txt."', `about_txt_alt` = '".$about_txt_alt."'");
    }
}

### query the about text database again and pullout all the rows
$cquery   = @mysql_query("SELECT * FROM `".$pixelpost_db_prefix."abouttxt`");
$abouttxt = @mysql_fetch_array($cquery);

### remove those slashes we previously added for viewing
$about $abouttxt['about_txt'];
$about stripslashes($about);

### remove those slashes we previously added for viewing
$about_alt $abouttxt['about_txt_alt'];
$about_alt stripslashes($about_alt);

### lets output our form
$addon_description .= "\n<form name=\"abouttxtaddon\" id=\"formATA\" method=\"post\" action=\"#ATA\">\n";
$addon_description .= "<input name=\"action\" type=\"hidden\" value=\"update_abouttxt\" />\n\n";
$addon_description .= "About Main Language:<br />\n";
$addon_description .= "<textarea name=\"about_txt\" id=\"about_txt\" rows=\"10\" cols=\"90\">".$about."</textarea><br /><br />\n";
$addon_description .= "About Alternative Language:<br />\n";
$addon_description .= "<textarea name=\"about_txt_alt\" id=\"about_txt_alt\" rows=\"10\" cols=\"90\">".$about_alt."</textarea><br /><br />\n";
$addon_description .= "<input type=\"submit\" name=\"Submit\" value=\"Submit\" />\n";
$addon_description .= "</form>\n\n";


### finally, our template tags
$tpl str_replace("<ABOUT_TEXT>",$about,$tpl);
$tpl str_replace("<ABOUT_TEXT_ALT>",$about_alt,$tpl);
?>
__________________
My photoblog: KP Images
Reply With Quote
Post Reply


Thread Tools




All times are GMT. The time now is 11:18 AM.

Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd. | Style Design: d3 designs