Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Re: geo_vote
Thx Bloke for the Idea to look in my php-Version. My php-Version is “5.6.19” –
If I you correct understand, can this plugin only installing on php-version maximum “4.1.2”? Or should it install, because my php-Version is bigger than “4.1.2.”?
How (and where) can set the Plugin for newer php-Versions? Or have I you don’t understand…? (my english is not the best, sorry…)
Offline
Re: geo_vote
lythande wrote #310157:
My php-Version is “5.6.19”
Okay, then your installation woes are unlikely to be caused by the plugin’s use of mysql_* functions. Not sure why it wouldn’t install. When I treid, it did take a few enable/disable cycles before I saw the Vote tab on the menu. No idea why.
can this plugin only installing on php-version maximum “4.1.2”?
Nope, that value refers to the minimum supported MySQL version.
The patch I made just fixes the use of mysqli_* (with an ‘i’) calls so anyone running newer versions of PHP can play.
The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.
Hire Txp Builders – finely-crafted code, design and Txp
Offline
Re: geo_vote
Okay, I try out your patch in my one textpatter-plugin.
Edit:
Many many thanks, your Patch works great!!! :-)
I have set my new Lines for vote_subtitles inside the Plugin-PHP and your patch too. Then I go to “Expanses” – “Vote” and there is very quick to install the Tables and was finish in 2 seconds. With my “vote_subtitles”! :-)
Edit 2:
wowww, I have look in my php-database and there is now the right collation utf8_general_ci! Much thanks for that too!!!
Last edited by lythande (2018-03-20 13:24:21)
Offline
Re: geo_vote
Hi,
now I wish to using the vote-plugin. But each of the option-bars of a question has the same color (Option 1, Option 2 …).
How I can make the class for the option-bar do different for each bar?
Under "function geo_vote_show_results($rs, $message){ :
if (${‘option_title_’.$i} != ‘’) { … //hard coded css for alpha release $out[] = ‘<div class=”’.$option_title_class.’” style=“width:’.$total_votes_percent[$i].’%;height:16px;”></div>’;
doesn’t work it with:
$out[]= ‘<div class=”’.$option_title_class-$1.’”…>
its outputting in the source without '<div class="'.$option_title_class-$1.'"> and only -1"> and then the follow code doesnt work. Its erased <div class="'.$option_title_class.
Has someone an idea how I can make it for this final:
<span class=“option_title_class”>Ja (100%, 4 Teilnahme)</span><br /><div class=“option_title_class-1” style=“width:100%;height:16px;”>(bar is green)</div>
so e.g. for the bars:
<div class=“option_title_class-1” >(the bar is green with class)</div>
<div class=“option_title_class-2” >(the bar is red with class)</div>
<div class=“option_title_class-3” >(the bar is grey with class)</div>
Last edited by lythande (2019-01-19 18:09:56)
Offline
Re: geo_vote
A second question:
in the vote_title-field I wish to use the questionmarks "title". But it outputting with \"title\"
How I can use the "title" without the backslash \?
Offline
Re: geo_vote
Hmm, nobody has an idea to help me?
Offline
Re: geo_vote
lythande wrote #316181:
doesn’t work it with:
$out[]= '<div class="'.$option_title_class-$1.'" … >
I’m not familiar with the plugin or its code but you want to alter - slightly to be .'-'. between the two variables if you want the classes to be linked via a hyphen:
if (${'option_title_'.$i} != '') {
…
// hard coded css for alpha release
$out[] = '<div class="' . $option_title_class . '-' . $1 . '" style="width: ' . $total_votes_percent[$i] . '%; height: 16px;"></div>';
The second thing with the title sounds like the title is being escaped twice in the code somewhere. Without finding the code, I can’t say for sure.
A way of getting around the problem in the meantime is to use curly quotes in your text, e.g. “title” or „titel“. As escaping will only affect the straight quote and straight apostrophe (along with a few other key letters and punctuation symbols), those will be unaffected.
TXP Builders – finely-crafted code, design and txp
Offline
Re: geo_vote
Thanx you lot, Jacob!
I will try out it today evening.
After the last survey I have see another problem. The bars for “yes/no/maybe” are not really correct in the length.
e.g. a question has results:
yes: 62,5%
no: 25%
maybe: 12,5%
But the bars are not correct in the length. Normally the bar for 12,5 should be very short, but is same length how the bar for 62,5% (full wide length from page in the browser). The bar for 25% is the shortest.
Why? I think, the code cant work with the comma-separated %-length?
You can see the survey-results here
Offline
Re: geo_vote
lythande wrote #316772:
The bars for “yes/no/maybe” are not really correct in the length … I think, the code cant work with the comma-separated %-length?
It’s because you have a German , instead of a decimal point in the value for width. You need it to output width:22.22%; and then it works.
TXP Builders – finely-crafted code, design and txp
Offline
Re: geo_vote
Okay, I understand this now, thx. But the , its from the plugin-code.
How I can changing the , to . in the code?
function geo_vote_show_results($rs, $message){
$total_votes_percent = array_fill(1, 10, 0);
if ($total_votes > 0){
for ($i = 1; $i <= 10; $i++) {
$total_votes_percent[$i] = round((${'option_'.$i}/$total_votes)*100, 2);
}
}
...
for ($i = 1; $i <= 10; $i++){
if (${'option_title_'.$i} != '') {
$out[] = '<span class="'.$option_title_class.'">'.doSpecial(${"option_title_".$i}).' ('.$total_votes_percent[$i].'%, '.${"option_".$i}.' '.geo_vote_gTxt('votes').')</span><br />';
//hard coded css for alpha release
$out[] = '<div style="background:'.$vote_bar_colour.';width:'.$total_votes_percent[$i].'%;height:16px;"></div>';
}
Last edited by lythande (2019-03-02 00:45:37)
Offline
Re: geo_vote
Ah, so it’s the language setting that is changing that. Try this small addition to the penultimate line:
function geo_vote_show_results($rs, $message){
$total_votes_percent = array_fill(1, 10, 0);
if ($total_votes > 0){
for ($i = 1; $i <= 10; $i++) {
$total_votes_percent[$i] = round((${'option_'.$i}/$total_votes)*100, 2);
}
}
...
for ($i = 1; $i <= 10; $i++){
if (${'option_title_'.$i} != '') {
$out[] = '<span class="'.$option_title_class.'">'.doSpecial(${"option_title_".$i}).' ('.$total_votes_percent[$i].'%, '.${"option_".$i}.' '.geo_vote_gTxt('votes').')</span><br />';
//hard coded css for alpha release
$out[] = '<div style="background:' . $vote_bar_colour . ';width:' . number_format($total_votes_percent[$i], 2, '.', ',') . '%;height:16px;"></div>';
}
The change is replacing $total_votes_percent[$i] with this number_format($total_votes_percent[$i], 2, '.', ',') which should reformat the number in the required decimal form to 2 decimal place. If that doesn’t produce the desired effect, then you can also replace it with str_replace($total_votes_percent[$i], ',', '.') to simply replace commas with dots.
TXP Builders – finely-crafted code, design and txp
Offline
Re: geo_vote
jakob wrote #316728:
I’m not familiar with the plugin or its code but you want to alter
-slightly to be.'-'.between the two variables if you want the classes to be linked via a hyphen:
if (${'option_title_'.$i} != '') {...The second thing with the title sounds like the title is being escaped twice in the code somewhere. Without finding the code, I can’t say for sure.
Hi Jakob, much thanks! I have tried this ...'-'.$1.' . Unfortunately I getting an error:
Parse error: syntax error, unexpected '1.' (T_DNUMBER), expecting variable (T_VARIABLE) or '{' or '$' in /.../textpattern/lib/txplib_misc.php(1782) : eval()'d code on line 707
Last edited by lythande (2019-03-04 15:24:32)
Offline
Re: geo_vote
Hi Lythande, may I take a look on your site? I used to have a login for your site but I don’t know if it’s still active. You know my mail address ;-)
TXP Builders – finely-crafted code, design and txp
Offline
Re: geo_vote
I’ve not been able to get this plugin working on Textpattern 4.8.4.
I followed Bloke’s advice and replaced the mysql_ function calls, but when I access the installation page, the HTTP response never completes, and the tables don’t get created.
Does anybody know how I can get some more debug output from this plugin? Many thanks.
Last edited by sambooth74 (2021-02-28 11:15:19)
Offline
Re: geo_vote
sambooth74 wrote #329074:
I’ve not been able to get this plugin working on Textpattern 4.8.4.
I had a look for you and it ended up being a bit of a rabbit hole … there are quite a few reasons why it wasn’t installing the tables: it used a word for a table column that is now an official “reserved word” along with deprecated MySQL syntax and it uses a date system that has since been changed in Textpattern. Not so surprising given that the plugin is 10 years old.
Here’s an interim test version that will install the tables on installing the plugin (no need to visit the plugin’s panel first). It also removes them again on deleting the plugin which the original didn’t. I tested adding a new vote, editing an existing vote and deleting a vote on the admin side. I haven’t, however, tested the public-side tags. Unzip the linked file, then drag the .php file to your “Upload plugin” button. You can then install and activate the plugin. You set up the “vote polls” via the Extensions › Vote panel (note: that doesn’t show if you happen to be on the install plugins panel).
Can you test that out and report back whether the public tag works as desired?
If it does, then I could do some more neatening up on the admin end: the edit panel and list of votes could be brought in line with current Textpattern methods, for example. But if the public tags don’t work properly, that may not be worth pursuing further.
TXP Builders – finely-crafted code, design and txp
Offline