2 blueyed Dec 05, 2005 19:22

Here's the zip: http://www.brendoman.com/dev/blogs/plugins/pollport.zip
It's pretty messy at this point. Here are some things you might want to know.
1. Most of what was the main plugin file (democracy/democracy.php) has been moved to _poll.plugin.php. democracy.php is now a small file that attempts to respond to the AJAX code when someone votes. old-democracy.php is the file from the Wordpress version.
2. I've commented out all of the user permission checks, since they're the WP way they don't work. They can be added back in later.
3. Installing: Drop the _poll.plugin.php file and the democracy directory into the plugins directory. Then add this to the skin in the head section:
<?php
// -------- POLL INCLUDED HERE ---------------
// Call the Poll plugin head section:
$Plugins->call_by_code( 'evo_poll', array(
'display'=>'head' ) );
// -------- END OF POLL -----------------
?>
And this in the sidebar:
<?php
// -------------- POLL INCLUDED HERE -----------------
// Call the Poll plugin sidebar section:
$Plugins->call_by_code( 'evo_poll', array( // Add parameters below:
) );
// --------------- END OF POLL -------------------------
?>
4. Once this is working we'll want to add in multiblog support. Basically we can just add a column to the question table called blog_id. And then fix up the functions so they respect that an allow each blog to have one active poll. The backoffice can display the blogs that the use has permission to edit along the top of the page, just like in the 'Write' tab.
5. I'm getting more comfortable with PHP, but OOP and AJAX are still over my head (as you'll probably be able to tell from the code).
Thanks for your help,
Danny
Your main problem (from looking at the code) seems to be that the democracy.php file (which answers the JS calls!?) will give fatal error: call to undefined function, because there you call functions, but have transformed the WP plugin functions into methods of your plugin.
functions: global/static.
methods: functions of an object.
You'll have to change your plugins source to make the democracy functions functions again (currently they are methods [of your Plugin]).
That should work.
To debug it, you could call democracy.php like the JS does it directly in your browser probably.
I like the idea/port and hope you'll get it to work.. :)
That's what I'll have to do. Move those functions out of the object. The only problem is that I need to be able to access the database to record votes and fetch results. I can include the _config.php file and use the built in php mysql functions rather than $DB->query(). I'll give that a try.
You could also require/include /evocore/_main.inc.php - that should init anything, but it's probably overkill.
Perhaps it would be a good idea, to have a /evocore/_connect.inc.php that could be required/included to have just a DB connection.
Anyway, take a look where $DB gets instantiated in _main.inc.php, you could do it the same. It's a lot more fun to work with the DB class than with mysql_* functions.
Great advice, blueyed. I got past that problem. It's able to send a vote and fetch results with Ajax now.
I am so excited to see this... I was hoping someone would put one of these together... please post when it is ready for prime time! And thanks in advance!! :D
personman, you're probably happy to here, that I've created a call_plugin.php file in /htsrv/ (just locally for now), which allows to easily link to plugin methods that get executed through http (htsrv).
I'd be interested in issues you have with implementing your plugin and suggestions how to address those..
That sounds great. That should make my plugin a lot easier to make.
Will call_plugin.php make it into version 1.7?
I'd like to, of course. I'll try. A problem is of course to provide also a call_plugin_light.php file that does not get the whole _main.inc.php file down etc.
I see that call_plugin.php has made it into CVS. I read your comments and I think I see how this will work when it's done. Let me know if I can do anything to help (like writing a howto).
It should be done, like it is. Actually we have a code freeze, so there won't happen much until the beta..
The procedure is quite simple:
- define a get_htsrv_methods() method in your plugin that returns the method names you want to make accessible through call_plugin.php (as array)
- define those methods in your plugin (prefixed with "htsrv_").
- use $this->get_htsrv_url() in your Plugin to create an URL that links/calls your method.
E.g.:
class my_plugin extends Plugin
{
function get_htsrv_methods()
{
return array( 'js_callback' );
}
function htsrv_js_callback( & $params )
{
// $params will be what you've given in $this->get_call_url()
}
function DisplayOnSomeEvent( & $params )
{
echo '...'.$this->get_htsrv_url( 'js_callback', array( 'some' => 'params', 'which' => 'get passed to your htsrv_* method' ).'...';
}
}
Documentation would be good, of course.
A problem of this is, that it's quite slow, because it does an whole init of the system.. therefor I want to add (after the beta) call_plugin_static.php which just loads the config and the Plugin class and instantiates the Plugin, while providing static methods to connect to the DB for example, if you want to use that.
I guess I didn't understand it as well as I thought I did. Thanks for the example. I tried it out successfully. Now back to that poll plugin . . .
Keep up the good work. I'm looking forward to the beta.
wow I just randomly came across your site with the wp poll on it which made me search the b2evolution forums and voila here you are working on a b2evolution version, thanks alot! :>
let me just make sure you're the same guy, is the original plugin this one? http://blog.jalenack.com/archives/democracy/
Yep, that's the plugin I ported. It's all done now. I'm just waiting for 1.7-beta to come out, then I'll release the plugin.
You're a star
out of curiousity why did you port it to b2evolution, do you use b2evolution as well as wordpress?
personman wrote:
Yep, that's the plugin I ported. It's all done now. I'm just waiting for 1.7-beta to come out, then I'll release the plugin.
I don't use Wordpress at all. I have an install that I use to test out plugins and stuff, but my main site is powered by b2evolution. Note that I didn't write the original plugin. That was Andrew Jalenack. I just ported it to b2evolution.
ahh, that makes sense, sorry for the mixup...
you should do the shoutbox too ;)
http://blog.jalenack.com/ajax/
personman wrote:
I don't use Wordpress at all. I have an install that I use to test out plugins and stuff, but my main site is powered by b2evolution. Note that I didn't write the original plugin. That was Andrew Jalenack. I just ported it to b2evolution.
Couldn't you release it even now, please? The current 1.6 Alpha is from Nov 05, at it may take a while before 1.7 comes out. Or, will it be tight to new features not present in 1.6?
personman wrote:
Yep, that's the plugin I ported. It's all done now. I'm just waiting for 1.7-beta to come out, then I'll release the plugin.
The plugin does use hooks that aren't in version 1.6. And even if you installed from CVS, the code has changed a lot since I wrote this, so it probably wouldn't work. When the beta is released I'll make sure it's working and then release it. Sorry to tease you with it. :)
Is this plugin 1.8 compatable? If not could you please make it so if you have some sparetime. Would be much appriciated from my side :)
Yes, I'm using it on my site now and I run 1.8-beta. I'll try to release it soon.
you couldn't send the version you use for beta testing ;)
yeah, a release would be nice :P even if its beta
:oops:
Shanti
I'm looking for that plugin too. I saw wp-polls.php running on a WP blog and it looked like just the thing to help people get started to partcipate.
I'm posting this so I'll get auto mail replies when it becomes available.
Hello guys,
i´ve searched for a poll plugin. I need it till a blog have to go online tomorrow. The Link http://www.brendoman.com/dev/b...llport.zip is down, or has moved?
@Bredoman: Can you sent me the latest version? I´m using b2e version 1.8.1-RC
Thanks a lot.
Mikih
I gave this a shot, and while it works, it's not what I was looking for. Any way to integrate this poll into a specific post rather than into the skin?
Hi guys,
First off, thanks to the developer for this plugin, an awesome addition to my site.
I have but one issue/questions.
Can this be configured to create poll posts also?
I have a blog category that is assigned to polls only and I would love to use this to create the poll posts.
Please advise.
That's not possible in the current version, but it would be a nice feature.
Personman,
It would be an awesome feature and I can see it adding much value and functionality to many blogs.
The simple fact of having this poll organized in a category on your site with the charts, priceless.
Would this be hard to code/design?
Personman,
Here's the error i'm getting on my Blog when viewing the main page,
";s:7:"after_q";s:9:"";s:4:"sort
After you vote this appears,
";s:7:"after_q";s:9:"";s:4:"sort";b:1;s:4:"blog";s:1:"1";s:12:"archive_link";b:0;s:3:"gft";b:1;s:3:"gct";s:4:"#06c";s:3:"gcb";s:4:"#05a";s:7:"poll_id";i:0;}' />
Notice: unserialize() [function.unserialize]: Error at offset 1017 of 1027 bytes in /titssn/blogs/plugins/democracy_plugin/_democracy.plugin.php on line 697
Any ideas as to how to fix this?
I've never seen that error. Can you paste in the question and choices of your poll? You may have some characters that need to be escaped.
Personman,
Thanks for the assistance with this issue.
Here's the info you requested.
Question: Are you concerned about your online identity?
Choices:
1. Yes
2. No
3. I don't have one.
4. Never thought about it.
It would be nice if a bar chart option was available :-).
Thanks for making this awesome plugin available.
add a \ before the ' ;)
¥
Yabba,
Thanks for the feedback and sugegstion.
That didn't help. It's still doing the same thing. Take a look at the site. Unless I added the \ at the wrong place.
Hey guys,
Any help with this?
Please advise as I am now having the problem on multiple pages.
TITSSN,
I'm using the plugin on b2evolution 2.4 and not having the problem. There must be something different in the way you're set up. Can you make sure you have the most current version of the plugin? Are you adding the poll to the page using a widget, or did you add code to your skin?
The last params are without html codes like ".
s="" polls="" ;s:16:="" widget_css_class="" ;s:9:="" widget_id="" ;s:0:="" ;s:5:="" title="" ;s:4:="" poll="" ;s:8:="" before_q="" ;s:27:="" type="hidden">
<strong id="poll-question">";s:7:"after_q";s:9:"</strong>";s:4:"sort";b:1;s:4:"blog";s:1:"1";s:12:"archive_link";b:0;s:3:"gft";b:1;s:3:"gct";s:4:"#06c";s:3:"gcb";
s:4:"#05a";s:7:"poll_id";i:0;}
It missed to htmlspecialchars() the params. May be a bug, but I have only seen it in the TITSSN blog.
TITSSN, I don't have the error on my testblog. Do try a fresh copy of the plugin as personman suggested.
Good luck
Personman/Afwas,
Thank you for the feedback and response. I uninstalled and reinstalled it and now it works :-).
I think I figured out what the problem was. When I installed it I wanted it to say TITSSN Polls in the sidebar and so I changed the name in the plugins section.
So, it's working fine now :-). I still think this is an awesome compliment to by site and would love to see the posts version. I have all faith in you that this will happen and I have a category just waiting for it :-)
TITSSN, great to hear that it's working. Sorry it took so long.
Afwas, thanks for your help.
Zip it up, I'd like to take a look and help.