Wednesday, September 30, 2009

jct - most commented today filter!!!

OMG!!!!!!!!!!!!!!!!!!!!!!

I'm so excited! I just wrote code across three different files without any help from the forum and it works!

So, to create the most commented today filter for the news,
1) in libs/search.php
Added a info for a search function


}elseif ($setmek =='commented'){
$this->filterToTimeFrame = "today";
$this->orderBy = "link_comments DESC";

so now a search that looks for commented will filter the results to today only
and order it by number of comments descending

2) in sidebar2.tpl
Added in a radio button in the sort news column

{if $setmeka eq "commented"} ....

check the file for the rest of the code - I can't get blogger to keep it as a blcokquote and not turn it into links. v annoying.

3) in libs/smartyvariables.php
Needed to assign instructions re what to do with $index_url_commented (part of step 2 code)
in the commented section //set up the sorting links on the index page in smarty. This will tell it how to write the URL for that page
$main_smarty->assign('index_url_commented', getmyurl('index_sort', 'commented', $pligg_category));
So now, there's a radio button that sorts todays news by most commented!


So, today I decided to try to figure out how to turn ‘recently popular’ into ‘latest news’. After much searching on the Pligg forum, I worked out that the order of the default front page was set in index.php. When I had a look at the code, it actually appeared to be ordering it already by date based on the variable link_published_date DESC; and no other variable.
I went to the live site and started adding comments and voting for older stories and this seemed to hold true – the order didn’t change.

I also looked at the code for the ‘Live’ section (which we have deactivated). This lists everything in order from latest to oldest using the same code. In live2.php noticed it set the order of the list, but ordered it by the more general variable link_date desc;. couldn’t work out what some of the code meant, so I started tracking bits down, to see if they had impact on the display. I didn’t know what ‘index_url_today’ did, so I tracked it down with a grep search and found it also appeared in smartyvariables.php. Looking at the line of code it appeared in there, it was linked with ‘index_sort’ which led me to html1.php. I then realised that this all was just responsible for setting the URL for any page you were on based on the sort category the user had selected. A dead end re the article feed, but good to know, none the less.

Looking at the code behind sorting the news by ‘top today’ I could see it was calling on the links database again, but filtering by ‘today’ and ordering by link_votes. So I went to the database and looked at the table ‘Links’. I could see that both link_comments and link_votes were set to be integers, so I figure we should be able to construct a way to display most commented using similar code.

I went back to index.php and looked at the function that was calling all of this to happen. it was called $setmek. So I grep searched it and found the original function details in search.php.
In the function do_setmek(), "if ($setmek == ‘today’)", it filters the results by time frame ‘today’ and orders it by ‘link_votes DESC’, so it makes sense to me that be should be able to create a similar command to sort highest commented today y::
"if ($setmek =='commented') {
$this->filterToTimeFrame = 'today';
$this->orderBy = "link_comments";"

Which will display only the stories submitted today, ordered by the number of comments (which is taken from the database table 'links' field 'link_comments').

So that’s a side matter solved, but back to the main problem. There was a bunch of code at the top of the setmek function code that I didn’t understand, but looked like it was determining order shown based on a variable $ords. I couldn’t work it out, how to change it or if it affected what we were trying to do, so I flicked back to the live Strine site and paged through the news feed.

As I was doing this, I realised that each page had a consistent number of articles on it – but they weren’t necessarily divided equally between the two columns. In the ‘recently popular’ news sort, it picked the latest 8 stories, whether they appeared in news or opinion categories. In the ‘top today’ it picked the 8 highest rated stories from today – with no distinction between their categories. So THIS was why the columns were appearing unequally! The current code configuration was treating it all as one lot of news (just displayed in different columns depending on category) not two sets of news. I’ve bounced this one back to Matt, so he can check out his to column feed set up.

SO: Recently popular IS latest to oldest news and is the default.
Top today, yesterday etc is ordered by votes and limited to chosen time frame

Need to set up a similar top today etc ordered by comments

Researching fix for front page sort method

http://forums.pligg.com/questions-comments/2529-changing-how-posts-sorted-frontpage.html

I'm going to try editing the line in index.php as suggested and see if that works.

This site also seems to have a few mod suggestions (although not sur how currently it's kept up to date)

http://pliggmods.com/

Tuesday, September 29, 2009

jct progress @ Monday 290909

What I did
  • Ian had commented out the far right sidebar in pligg.tpl. It was still on the front page (although displaying a weird arrow) and it took off the navigation options on the profile page (which we didn’t want), so I removed the global change and looked for a more local solution. I looked at how the submit page was managed in the sidebar.tpl and sidebar2.tpl files. There was a whole bunch of stuff that was placed in a sidebar so long as “[if $pagename neq “submit”]” i.e. if the name of the page does not equal submit. I tried to add in a “ && if $pagename neq “index” “ to the end of the statement. Although it worked and took off the sidebar, it also made the footer disappear. I only realised this after making the next few changes and uploading the lot to the repository, so I had to work out how to revert the lot and start again.
  • I removed the trackback box from the second submit page by commenting out the code. I labelled the section to make it easy to find.
  • I removed the ‘upcoming news’ feature from the submission process and the site.
  1. In the admin panel I set ‘number of votes to publish’ = 0
  2. In header.tpl I commented out ‘
  3. To change the redirecting from the final submission page to the upcoming page (instead to the home page) I added this code to the start of the file upcoming_center.tpl “{php} header (‘location: ‘$this _vars [‘my_pligg_base’].”); {/php}"
  • After undoing it all and redoing the above two steps, I revisited why I was losing the footer when I tried to apply the same code from the submit page to the index page. I was stumped – it LOOKED the same to me. I looked at other examples of how these statements were grouped and I realised that they didn’t use a second ‘if’ in the statement. so I tried “[if $pagename neq “submit” && $pagename neq “index]” and it worked! So I sent it back up to the repository
  • Manuella had trouble applying an avatar to the site the other day so I double checked that the avatar folder and user_uploaded sub folder had been CHMODed to 777, so everyone had write permission. All good there
  • I made sure the entire team had ‘admin’ permission on the site, to be able to help moderate
  • I removed reference to Karma and ESP points from the profile page by commenting them out. I also commented out ‘settings’ and ‘upcoming’ from the nav bar options on this page, as they were redundant
  • On the front page, I commented out the ‘sort news’ options, except for ‘recently popular’, which would be our second sorting view for people to see the news (other than the main feed)
  • I backed up the live site files as I worked my way through the instruction sheet I wrote up for Matt, to make sure it was clear enough and accurately captured all steps. I posted this on the uts discussion board and ran through the process with Matt at the meeting. We will now start the Tues/Thurs and Sunday backup cycle.
Later…
  • After discussions at the meeting with Nathan, I went ahead and moved all of the relevant parts to the different areas, so he could just focus on the css. I moved the ‘What is Strine’ module code to the footer. I commented out the ‘top tags’ link/display (Matt had already copied this over to the section he was building the tag navigation bar, but I made sure to add a comment note so we could find it again if necessary ☺
  • I went to move the ‘recently popular’ link to the navigation bar (I thought it would make sense to have it up there next to ‘latest news’). I was looking at the code and realised that it was set to display recently popular when you selected ‘recently popular’ but also when nothing was selected i.e. “ “ i.e. recently popular was the default view! This means we will need to find some other way to sort the news, to give users more options. Shall we leave in ‘today’? or do we need to look for code or a module that creates a ‘most commented’ section? That looks like the research focus for this week
To do:
Let team know to disable private message module, configure voting to publish = 0 and configure spell check ‘off’
Work out method for removing dodgy users from database completely (or could get crowded)

jct progress @Saturday 270909

In meeting
  • Decided to remove ‘upcoming’ from the submission process, based on feedback from user testing
  • Find out if there is a module you can use to enable the users to sort the news by ‘most commented’ This will be a phase 2 endeavour
  • The two column feed seems to work fine on front page – Matt needs to test it still works with our other selected sort method ‘recently popular’ once it gets on the live site and there is enough data to test with
  • Team agreed that we try the tag cloud as a nav bar – Trending or Hot topics, like with Mixx. We will test this in the beta phase with users. Phase 2 we are considering setting categories (if we can work out how to do this) so we might look at trending topics and tags to define them and make them most relevant to our audience
  • Need to remove ‘settings’ option from profile page, as it just allows the user to decide which categories they want to view – as we have hijacked the categories for news and opinion, this is not an option we want them to use.
  • Need to remove ‘upcoming’ from the profile page navigation, as we won’t be having upcoming new, so it’s redundant
  • Switch off the inbox totally through the admin panel – we can add it in later easily if we decide to reintroduce that system
  • Team agreed to monitor and clean up titles of articles e.g. remove source categories like |News|Yahoo.com, as part of moderating activity
  • Matt and I agreed to start a back up schedule – Matt will run the back up of the site on Tues and Thurs at 11pm and I’ll run it on Sunday at 11pm. I’ll also continue to run the repository transfer to live site on an as need basis
  • The team all agreed that the Karma points seemed to be unclear and confusing, so we agreed to remove them for this first phase. We will look into the algorithm behind it to see if we could tweak it for phase 2. We couldn’t work out what ESP votes were so it was agreed to remove these at this point as well.

After meeting
  • Set across a repository transfer to get the two column up online. Documented the process for an instruction sheet
  • Removed dodgy users and their posts using ‘Kill Spam’ function. It seems to disable them but not take them out of the database. I suppose this will prevent them from signing up using the same log in details but it could clutter the database. Maybe research way to remove them?
  • Try to set up automatic publishing by changing ‘votes to publish’ to 1 (as each new submitted article gets a vote of 1). Didn’t seem to work – articles still went to upcoming page. Tried it with 0 and still no win. Maybe research further
  • Found out how to set the tag cloud text size in the admin panel configure/tags

Completed Tag to category code

Category improvements complete;

libs/html1.php


created code to create a list of the top five tags


function tag_list(){

global $db;

$tag_list = $db->get_results("SELECT `tag_words`, COUNT(tag_words) AS NumOccurrences FROM `pligg_tags` GROUP BY `tag_words` ORDER BY 'NumOccurrences' LIMIT 0, 6");


$tag_list = object_2_array($tag_list);

foreach($tag_list as $id => $rs){

$tag_list[$id]['tag_words'] = $rs['tag_words'];

}


return $tag_list; // returns list to function summon


}


then added


$taglist = tag_list();

$var_smarty->assign('taglist', $taglist);


to "function do_sidebar()" so this array would be passed on into the tpl files.


templates/oioioi/sidebar_modules/catagories.tpl


This means that using a submit loop;


{section name=thetag loop=$taglist}

{$taglist[thetag].tag_words}

{/section}


inserts all tag names onto the page


With this as a starting point, we can then create a second loop, using tags, which is inserted directly after the previous loop closes (i.e. right after {/section})


{section name=thetag loop=$taglist start=$start}

[li{if $cat_array[thecat].principlecat neq 0} class="dir"{/if}]

[a href="{$my_pligg_base}/search.php?search={$taglist[thetag].tag_words}&tag=true"]{$taglist[thetag].tag_words}[/a]

{if $cat_array[thecat].principlecat eq 0}[/li]{else}[ul]{/if}

{/section}


This uses the my_pligg_base url, to avoid problems with incorrect linking, and attaches the search.php?search as with the tag cloud. This links to the page.


While this seems to work fine, it has helped me spot a problem in the search.php file. Something to look into later.



Monday, September 28, 2009

MC Converting Tags into new catagories

Several steps have been undertaken so far;

libs/html1.php


created code to create a list of all tags


function tag_list(){ // this creates a list of all tags in the database

global $db; // connects to database details

$tag_list = $db->get_results("SELECT tag_words FROM pligg_tags ORDER BY 'tag_words'"); // selects all tags in the database

$tag_list = object_2_array($tag_list); // converts results to an array

foreach($tag_list as $id => $rs){

$tag_list[$id]['tag_words'] = $rs['tag_words']; // links the tag name to each tag

}


return $tag_list; // returns list to function summon


}


templates/oioioi/sidebar_modules/catagories2.tpl


Added


{include file=$the_template_sidebar_modules."/categories2.tpl"}


to add a second layer with the tags through file categories 2


templates/oioioi/sidebar_modules/catagories2.tpl


then added


$taglist = tag_list();

$var_smarty->assign('taglist', $taglist);


so this array would be passed on into the tpl files.


This means that using a submit loop;


{section name=thetag loop=$taglist}

{$taglist[thetag].tag_words}

{/section}


inserts all tag names onto the page


As a result, there is a second catagory column, with a list of all tags. The next step is to insert these into buttons, and attach the search code used in the tag cloud page.

MC Two column issue

There are two possible sources for this problem; due to issues with RapidSVN I haven't been able to upload the latest version of my code, which does not have the same organizational issues as the online site.

Alternatively, it is a cache issue. Either way, I will examine this closer later today.

MC Avatar image issue

This may or may not have been solved yet. Examining the code, I did find an issue with the database, caused by changing the overall folder name. Editing the database solved this, but this does not apply to the online issues.

Testing the avatar coding revealed no flaws, so it seems that the issue was caused by access permissions; i.e. the folder was not allowing the images to be stored in the online folder.

MC Splitting the two columns into seperate css values

This was a slightly involved edit; firstly templates/oioioi/pligg.tpl was edited to include

{if $cat_array[thecat].name eq 'Opinion'}
[div id="leftcoltwoopinion"]
{else}
[div id="leftcoltwo"]
{/if}

which gave separate css values for each column.

Then both link_summery_news.tpl and link_summery_opinion.tpl were altered to have sepperate text css values; storiesnews and storiesopinion

These new css values was then added to templates/oioioi/css/style.css

MC Extending two column feed to Upcoming Page

This was begun by going through templates/oioioi/pligg.tpl and upcoming.php and adding pagename eq Upcoming to various if-else statements.

This only partly worked; Two columns apeared on upcoming, but they held the same catagory. The desicion was made, however, to remove upcoming from the site completly, so there was no reason to complete this code.

MC Inbox on profile page only

I just realized that I haven't been updating this as I should have, so I am going to details the changes and fixes made over the past few days no, in order to fix that.

The functions controlling the Inbox were located in the templates/oioioi/sidebar.tpl; the code line
{checkActionsTpl location="tpl_pligg_sidebar_middle"}
summoned it.

Inserting an if-else statement around this allowed this function to be controlled and limited only to the page 'user'

Wednesday, September 23, 2009

MC Two category columns code complete

Ultimate goal; two columns on front page which show the two categories side by side.


Present changes; This was an involved process that was constructed with several separate coding processes.


Two css files were altered;

- style.css has been adjusted with a new leftcoltwo and stories_two value, allowing the pages to fit together.


templates/oioioi/pligg.tpl was altered with the following code, to create a loop that constructed as many columns as categories.


{if $pagename eq "submit"}

{elseif $pagename eq "index" } if index page


{section name=thecat loop=$cat_array start=$start} starts a loop; one loop for each catagory

[div id="leftcoltwo"] uses the leftcoltwo values for thinner columns


{if $pagename eq "group_story"}

[div id="group_navbar"][/div]

{/if}


{checkActionsTpl location="tpl_pligg_content_start"}

{checkActionsTpl location="tpl_pligg_above_center"}

{include file="wistie/index_center_index.tpl"}

{checkActionsTpl location="tpl_pligg_below_center"}

{checkActionsTpl location="tpl_pligg_content_end"}

[/div]

{/section}


A series of if-else loops were added to index_center.tpl to connect to different link summary output functions to link to different link_summery.tpl files


{if $cat_array[thecat].name eq 'News'}

{$news_link_summary_output}

{else}

{if $cat_array[thecat].name eq 'Opinion'}

{$opinion_link_summary_output}

{else}

{$link_summary_output}

{/if}

{/if}


From here, I had to modify libs/link_summary.php, libs/link.php and templates/oioioi/link_summery.tpl to individualize the index page columns without altering the rest of the site.


I added new functions to libs/link_summary.php to call separate functions from libs/link.php

$news_link_summary_output .= $link-> print_news_summary('summary', true);

$opinion_link_summary_output .= $link-> print_opinion_summary('summary', true);


and added control functions to allow feedback from the index.php file


if(isset($fetch_news_link_summary) && $fetch_news_link_summary == true){

$main_smarty->assign('news_link_summary_output', $news_link_summary_output);

} else {

echo $news_link_summary_output;

}

if(isset($fetch_opinion_link_summary) && $fetch_opinion_link_summary == true){

$main_smarty->assign('opinion_link_summary_output', $opinion_link_summary_output);

} else {

echo $opinion_link_summary_output;

}


In libs/link.php I copied the function print_summary which calls templates/oioioi/link_summery.tpl. These were;

print_news_summary altered to link to link_summary_news.tpl

print_opinion_summary altered to link to link_summary_opinion.tpl


To allow feedback from index.php, I had to adding new code

$fetch_news_link_summary = true;

$fetch_opinion_link_summary = true;


Finally, two copies of templates/oioioi/link_summery.tpl were created; link_summary_opinion.tpl and link_summary_news.tpl. These two new files had if-else loops added at the start of the file and the div class was changed to stories_two for the thinner columns;


{if $link_category eq "News"} Inserted code that activates if link_category is News


This resulted in three files;

link_summary.tpl -standard

link_summary_news.tpl -news only

link_summary_opinion.tpl -opinion only

jct progress

I tried uploading an avatar but it wouldn’t let me so I had to CHMOD 777 the file.

I tweaked the user_center.tpl file to remove the reference to ‘Group memberships’ from the profile page. While I was there I swapped the bookmarklet info with the ‘friends’ info – once someone has installed the bookmarklet, that’s just annoying text that gets in the way of your personal information.

I discovered all of the Admin Language panel text settings are actually saved in lang_english.conf, not in a database, so that should be easy to modify and rollout changes to the team. I am also tempted to make the changes directly in the lang_english.conf file as the admin panel keeps flipping out and chucking bugs up.

I moved the ‘About strine’ module in the sidebar2.tpl to sidebar.tpl i.e. from the far right sidebar column to the middle sidebar column. Now it doesn’t show up on the profile page (if you have a profile you already know about Strine, it was just adding clutter).

So, I decided we need to set up a safety backup system. Every 2 days I will save a back up of the database, the site public_html files and the svn repository to a local external harddrive, just in case something goes horribly wrong. I managed to run this last night, but it took a fair bit of time and did not run without issue…

I tried to back up the database and the site files through the Admin panel, but constantly got errors. After spending ages trying to fix it, I gave up and backed up via an export of the database from phpMyAdmin, which worked perfectly fine (and I will definitely use from now on!). I just downloaded a copy of the public_html files using my FTP client.

In order to get a whole working copy of the svn repository (with working links etc), without taking it offline, I had to run a hot copy. I did this through the Terminal line on the host server by:
$ svnadmin hotcopy ./svn/strinerepos ./svn/strinerepos_bkup

I just transferred a copy of ‘strinerepos_bkup’ via my FTP client to my external harddrive. I tried to gzip it first, but rather than zipping the whole lot together it zipped the individual files in the same folder as the original files, which was not what I was after!

After I managed to get everything backed up, I ran a repository export to the live server. The wrong referrer error code fix didn’t work, so I reverted the code and just commented it out, committed the changes to the repository and ran another repository export to the live server. The whole site just flipped out at that point – instead of using php comment signs /* */, I’d used the tpl comment signs {* *}. So I had to change the comment signs, commit the changes and run another repository export to the live server. Although that go the site working again, as soon as I tried to load the ‘submit a story’ page, it seized up on the ‘check referrer’ reference in submit.php. As it was around midnight at this point, I just reverted the file from a back up copy, just to get the site functioning again. It’s been put to the top of the bug list for tonight.

Although I don’t like taking out the ‘wrong referrer’ defence from the code, it’s either that or get rid of the bookmarklet….

I'm going to try to update the tech WIP sheet this afternoon - lost has happened in the last week!

Tuesday, September 22, 2009

jct progress - configure settings, spell check and wrong referrer error

Changed configure settings:
Group feature - set to false
Trackback - changed to strine.net.au
GMT time offset - changed to +10
URL validation - reset to test again

The reason the spell check is coming up blank/not working is because the host company either doesn't support or hasn't got aspell turned on. I'll email them to find out.

I used this wrong referrer code to try to fix the error with the bookmarklet. http://forums.pligg.com/wiki-articles/17531-wrong-referrer.html
It needs to be used on the live site as my bookmarklets point to strine.net.au, not my local server. If it doesn't work, I'll have to remove it, but it would be a shame to get rid of another line of defense... I'll run a test late tonight, so if it all goes pear shaped I can run a fix, hopefully without anyone being impacted!

I also heard back from the host company - they don't back up the files for us, so I will need to start not only backing up the site files and database, but also the SVN files. I'm reading up on how to run a hot copy (which takes a live copy of the svn files and I think won't flip out if someone happens to be using it at the same time?). There's also a bunch of automated code you can use (based on a quick Google search) but I think a bit of investigating needs to be doen today to determine best process

Monday, September 21, 2009

jct - modules and configuration changes

In order to remove some of the site functionality, to pare the pligg template back to basics for the first strine prototype, we disable or turn them off in the admin panel configuration or module tabs.

Any changes we make to the modules and the configuration of the site through the admin panel gets stored in the local database files. These files aren't downloaded in the SVN update, so changes must be made through this panel on the live site and replicated on each team member's local version.

What I have changed on the live site (all team members to execute on their local versions):
In the module tab
Disable 'sidebar stories', 'Sidebar top today'
Enable 'Send Welcome email'

In the configuration tab
'Enable live' set to false

I highly recommend everyone clear the template cache through the Admin home link regularly - it seems to often be behind errors when trying out new code

jct - how to comment out code in the tpl files

http://forums.pligg.com/questions-comments/17416-commenting-your-tpl-files.html

I used this to comment out the 'Group Share' link at the bottom of each story, seeing as we won't be using the group function at this point

MC Note to previous post

The $link_category in link_summary.tpl does not relate to the value of the link loop in pligg.tpl

Therefor, to get the two to conincide will likly require two ink_summary.tpl files, one for each catagory and each of which is summoned by the link loop in pligg.tpl (which will also allow simplification of these files, since they can not be summoned by other pages).




MC Single category Front page!

All changes here involve the templates/wistie/link_summary.tpl file.

The first step was changing the file to;

{if $pagename eq "index"}
{if $link_category eq "News"}

ALL original code in file except {checkActionsTpl location="tpl_pligg_story_end"}

{/if}
{else}

ALL original code in file except {checkActionsTpl location="tpl_pligg_story_end"}

{/if}
{checkActionsTpl location="tpl_pligg_story_end"}

This means that index now shows only stories from the News category, while the other pages remain unchanged.

I also rewrote the [div] code in the first orig_code_copy only to read;

[div class="stories_two" id="xnews-{$link_shakebox_index}" {if $link_shakebox_currentuser_reports gt 0} style="opacity:0.3;filter:alpha(opacity = 30)"{/if}]

while adding the following to templates/wistie/css/style.css;

.stories_two {
width: 275px;
margin-bottom: 30px;
}

Which ensured the stories now fitted within the shrunken column width.

jct progress - google analytics

OK - successfully inserted the google analytics locally in the footer.tpl file.

As the pligg files aren't straight forward html files, there were no body tags to put it in front of :-) I also had to encapsulate the code in {literal} tags. I wasn't sure if it was working, but it didn't seem to be freaking out the code, so I committed the changed to the repository files and practiced executing a repository export to the live server again. The live site still seems to be working, so I guess all good...

It did take a bit of time, just transferring the files and reinserting the settings and CHMODing correctly, so I'd be tempted to do this later at night from now on, as it leaves the site offline for a bit...

MC Story path update

I originally believed that the Pligg software followed a basic path of sequential files, each file calling the next in line, i.e.

index.php - templates/wistie/Pligg.tpl - templates/wistie/index_center.tpl - libs/link_summary.php - link_summary.tpl


This was wrong; it actually goes

index.php - templates/wistie/Pligg.tpl - templates/wistie/index_center.tpl - link_summary.tpl
- libs/link_summary.php -

With index.php calling both pligg.tpl and link_summary.php! The link_summary_output is created here, in index.php, which is why adding code further down in pligg.tpl and index_center.tpl didn't affect the link_summary_output; it was already defined!


Sunday, September 20, 2009

MC Pligg code summary

Open index page. This includes info from

Smarty.class.php leads to class.compiler.php

config.php provides the base configuration; warnings not to edit

in /libs folder

html1.php

link.php

tags.php

search.php

smartyvariables.php


Selects using isset and REQUEST to see if on category page, if not then loads up Can we use this for category inclusion?


else {

// breadcrumbs and page title

$navwhere['show'] = 'yes';

$navwhere['text1'] = $main_smarty->get_config_vars('PLIGG_Visual_Published_News');

$navwhere['link1'] = getmyurl('root', '');

$main_smarty->assign('navbar_where', $navwhere);

$main_smarty->assign('posttitle', $main_smarty->get_config_vars('PLIGG_Visual_Home_Title'));

$main_smarty->assign('page_header', $main_smarty->get_config_vars('PLIGG_Visual_Published_News'));

// pagename

define('pagename', 'index');

$main_smarty->assign('pagename', pagename);

}


if it does then it uses


if(isset($_REQUEST['category'])) {

$category_data = get_cached_category_data('category_safe_name', sanitize($_REQUEST['category'], 1));

$main_smarty->assign('meta_description', $category_data->category_desc);

$main_smarty->assign('meta_keywords', $category_data->category_keywords);


// breadcrumbs and page title for the category we're looking at

$main_smarty->assign('title', ''.$main_smarty->get_config_vars('PLIGG_Visual_Published_News').' - ' . $thecat . '');

$navwhere['text1'] = $main_smarty->get_config_vars('PLIGG_Visual_Published_News');

$navwhere['link1'] = getmyurl('root', '');

$navwhere['text2'] = $thecat;

$main_smarty->assign('navbar_where', $navwhere);

$main_smarty->assign('pretitle', $thecat );

$main_smarty->assign('posttitle', $main_smarty->get_config_vars('PLIGG_Visual_Published_News'));

$main_smarty->assign('page_header', $thecat . $main_smarty->get_config_vars('PLIGG_Visual_Published_News'));

// pagename

define('pagename', 'published');

$main_smarty->assign('pagename', pagename);


This summons the pligg.tpl file with


// show the template

$main_smarty->assign('tpl_center', $the_template . '/index_center');

$main_smarty->display($the_template . '/pligg.tpl');

?>


pligg.tpl then assembles the main body of the page.


This defines the page's structure, split between the different paragraphs


{checkActionsTpl location="tpl_pligg_content_start"}

{checkActionsTpl location="tpl_pligg_above_center"}

{include file="wistie/index_center_index_1.tpl"}

{checkActionsTpl location="tpl_pligg_below_center"}

{checkActionsTpl location="tpl_pligg_content_end"}


This connects to the file wistie/index_center.tpl


This then links to libs/link_summary.php


This connects to link_summary.tpl, which creates the individual stories.


------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------


Ultimate goal; two columns on front page which show the two categories side by side.


Present changes; style.css has been adjusted with a new leftcoltwo value, allowing the pages to fit together.

pligg.tpl has been altered with


{if $pagename eq "submit"}

{elseif $pagename eq "index" } if index page


{section name=thecat loop=$cat_array start=$start} starts a loop; one loop for each catagory

uses the leftcoltwo values


{if $pagename eq "group_story"}

{/if}


{checkActionsTpl location="tpl_pligg_content_start"}

{checkActionsTpl location="tpl_pligg_above_center"}

{include file="wistie/index_center_index_1.tpl"} connects to index.tpl

{checkActionsTpl location="tpl_pligg_below_center"}

{checkActionsTpl location="tpl_pligg_content_end"}

{/section}


Planned path;


index.php

- This page seems to be the initial place where categories are defined. Construct a if-else statement that if the pagename = index, creates two categories using the if(isset ($_REQUEST['category'])) { code to create a $thecat and $thecattwo which are inherited by the subsequent pages.

- this may require inserting the category loop in this page, summoning pligg.tpl twice, once for each catagory. Since pligg.tpl constructs the html page, this may cause problems here though, so will need careful testing and checking.


templates/libs/pligg.tpl

- (if the category loop is not used in index.php) Using the category loop, construct a pair of columns, one using $thecat and the other using $thecattwo.

- This will call subsequent pages using


wistie/index_center.tpl

- Unmodified


templates/libs/link_summary.php

- May need modifying; standard calls the category from the url. May need adjusting to use alternate data, possibly with redundant pages.


templates/libs/link_summary.tpl

- Unmodified

jct progress - pligg on wamp issue solved

Had problems at the install session at the meeting yesterday - on the windows machines, although pligg looked like it was working you couldn't log into the site you'd created.

I had a go at installing it on my Windows machine when I got home and had the same log in issues. I ran the Troubleshooter and it was telling me it wouldn't work as I was running SQL version 3.2.27, where WAMP was telling me it was running 5.1.36.

Anyway, I had a look at the phpMyAdmin homepage and it said the server was running MySQL client version: mysqlInd 5.0.5-dev - 081106 - $Revision: 1.3.2.27$. That $Revision bit looks like some sort of svn reference that got stuck in the code. Funnily enough, the last set of numbers 3.2.27 seems to be what Pligg is reading and it's stuffing up the whole install.

I posted on the wampserver and pligg forums, but didn't seem to have a response.
http://www.wampserver.com/phorum/read.php?2,54464
http://forums.pligg.com/questions-comments/19570-cant-log-pligg-wamp-2-0i.html#post85564

As far as I could tell, people were using Pligg fine on older versions of wamp, so I decided that would be the easiest solution to the problem. It worked, so I sent out these instructions to the team:

How to fix this:
1) Uninstall WAMP 2.0i
Use the Add/remove program function in the control panel, then go to your C drive and delete the wamp folder

2) Install WAMP5 version 1.7.4
from http://sourceforge.net/projects/wampserver/files/

3) Reinstall Pligg

I'll finish hooking everyone else up to the svn strine repository at the Monday night meeting

Saturday, September 19, 2009

jct progress report

Firstly, tested the built in Pligg file and database back up system. Seemed to work fairly easily. The file back up literally zipped the current version of all of your online files so you could download them and save them locally. That might be handy every now and then, and before big code changes. The avatar back up file also seemed to construct a zipped file which I was unable to open. I’m not sure what is in this or how to restore it if necessary. Should check that at some point – I’ve added it to the bug list.

Backed up the database files as well with the Pligg built in system. It downloads an sql file, which you apparently reinstate by executing the code through MyMSQLAdmin. I did read in one of the forum articles that it was actually just as easy/easier to periodically export the database contents through MySQLAdmin. Either way, backing up seems pretty easy!



Secondly, practiced exporting to the live server from the repository, to work out what the process will look like. I started by completely clearing out the existing public_html files (by renaming the folder via the Terminal) and bringing in the new ones (putting them in a new folder called public_html), then going back and reinserting settings.php and dbconnect.php in the appropriate places. The good news is, it worked, and the code change I made also worked online which is awesome! I think by starting fresh with a clean cache, it prevents the code issues I had in the past when uploading new files to the server and old cache files hanging around.

This is the process to use going forward:
1) Clear existing public_html through the Terminal. Do this by renaming the folder public_html to bkup_html. This will keep a copy on the server to make it easy to reinstate if necessary (plus makes the settings/dbconnect files easy to find):
mv public_html bkup_html

2) Export the site files from the svn repository:
svn export http://svn.strine.net.au/strinerepos/webdocs public_html --username jto

3) Check all of the files transferred by looking on the server with FTP client e.g. Cyberduck. Reinsert the settings and dbconnect docs here.

4) CHMOD 777 the /cache and /cache/template folders

5) That’s it!

Then I looked at how RapidSVN compares changes I’d made in the header.tpl doc in the log, to see what it would look like if I had to work out a code conflict. I had to install DiffMerge and followed the instructions http://www.rapidsvn.org/index.php/OnlineHelp:Contents#Mac_OS.2FX

to help to get it working with RapidSVN.



Lastly, I practiced the entire installation process on the bf to see what process I needed to follow to get the team up and running. This is what I worked it out to be:

1) Rename the Pligg file on the MAMP server to old pligg

2) Install RapidSVN and DiffMerge
- Download the dmg files and drag the two to the application folder
- Move the diffmerge shell script using the Terminal
o Make sure the diffmerge dmg file is open in a finder window
o Run this script
cd /Volumes/DiffMerge\3.3.0.1001/CommandLine

sudo cp diffmerge.sh /usr/bin/

- Change the preferences in RapidSVN to set DiffMerge as the Diff and Merge tool

3) Open RapidSVN and add the strine repository to the bookmarks
- Bookmarks/add existing repository
- http://svn.strine.net.au/strinerepos and authenticate

4) Download the repository to the local server
- Select webdocs, then Repository/check out
- Fill in the form – the location is MAMP/htdocs – create a new folder called ‘pligg’. Leave the rest of the fields

5) Once downloaded, go and manually replace the settings and dbconnect documents (back these up somewhere to avoid the reinstall later)
6) Start MAMP servers
7) Check the new files work by loading the local site localhost:8888/pligg
8) Remove the bookmark for svn.strine.net.au from RapidSVN


So the process for users after the installation of the repository files on their local server:
1) Check out the latest version of the files: /Modify/Update
2) Make your edits on your local machine
3) When you want to submit your changes to the online server, first check for latest version of the files: /Modify/Update. If no conflicts, Commit your files and changes. Add comments re what you changed and why in case someone needs to query or to help someone resolve a conflict
4) If there’s a conflict, resolve by using the Diff/Merge function (I haven’t tested yet)

Friday, September 18, 2009

Janet's progress last night with svn

I spent the first 20mins setting up the team’s username/pword and repository access through the command line. I’ll email everyone about that today so they can get on there (if they know how to use svn)

The next 2.5hours was taken up by setting up and testing the repository.

Firstly, I needed to copy over the public_html files/folders to strinerepos. I did this in the command line, in the main strine directory folder by typing:
svn import public_html http://svn.strine.net.au/strinerepos/webdocs --username jto –m “initial file import”

So what that means is:
svn = indicates it’s a subversion command

Import = what you want to do

public_html = the source of the data to action

http://svn.strine.net.au/strinerepos/webdocs = where to move it to. We have to dot he http as it goes out through the Apache server. Webdocs is the name of a folder to put all of the data in, so they aren’t just floating around in the root repos folder. I could have called it strine, but was getting lost amongst all of the strine references…this is where implementing some sort of folder/file naming convention would be awesome (but probably more important if we were creating the site files instead of using existing ones)

--username jto = this is to log me in as the user executing this action. It asked me for my password after I pressed enter to execute

- m “initial file import” = every action in subversion asks for a comment to be attached i.e. for you to explain the change you are committing. This is just a way to use the command line to do this, so in the svn register, this process will be logged and time stamped and you will be able to see what was done at this time.

So, everything copied over relatively painlessly – including the cache files, which were not needed! The cache files are just temporary versions of the site files including the template files. I’ve worked out they tend to be responsible for mucking up the code changes. I took a moment to clear them out of the repository.

Next, I used the bookmark I’d set up in RapidSVN to hook into the strine server and CHECK OUT all of the repository files to my local server. Don’t export the files at this point – that’s just like downloading them over ftp. By checking them out, the svn files remain linked and changes can be tracked.

So, I had to move all of my old pligg files away and start fresh with these linked files, to let svn track changes, which I downloaded to the same named folder as the old files had been in (hoping this would minimise the problems that came up in the code). By retaining the old files I’d worked on, I can go back and copy over the code changes I’d made easily into the svn tracked files. (If you’re confused, don’t worry. I feel like I’m bending my brain to track how this works, so I’m probably not explaining it clearly!). I noticed that the imported files were 18.3MB compared to 7.4MB in the original Pligg files – when I executed that shell script from a few weeks back, I could see that there was an invisible .svn file in all of the folders I’d downloaded – this is apparently where all of the changes were tracked and the old files kept for diff comparisons, so when you want to do that, you don’t need to check in with the server all the time!

After transferring the files across, I tried loading the local version in a browser window, but got an error re the strinemim_table not existing. I realised I had named my local database tables with the prefix pligg_ where as online I named them strinemim_, so after a bit of investigating I worked out a way to rename all of my tables in MySQLAdmin using the SQL command :
RENAME TABLE one TO two;
where ‘one’ and ‘two’ were the different table names.

This didn’t solve the problem so I googled the error and fixed it as per my post last night.
I have created a back up version of the settings.php and dbconnect.php files online in a separate folder on the segpub server

What this means in terms of using SVN and pligg for the Strine build:
I have removed the settings.php and dbconnect.php files from the repository, as these will always be local specific (as they deal with the database references, passwords and local URLs etc). You can have files in the same folder as your svn files that won’t be detected by svn unless they were downloaded that way.

When I help the team load the svn version of the files to their computer, I will need to back up their local versions of these files, install the checked out version of the files onto their server and then replace the backed up files in their rightful place. After that, it should be quiet simple for us all, as svn will track the rest of the files that we might need, and if someone does a full check in, they won’t accidentally erase anything.

When it comes to updating the live files, I will export the repository files, not check out, as there’s no need for the excess svn files, and all changes will be made in the repository, not the other way around.

I was hoping to find a way to automate the export update from the repository to the live site, but it looks like we will have to stick with a manual process, as we will have to also reinsert the settings.php and dbaccess.php files for he site to function, but it’s probably a good thing. While we’re still working out how to use this, it’s probably safer to supervise the updates in case a back track is necessary if it all falls apart. This should hopefully make for a smoother online experience for users.
This code creates a loop, repeating the link to the category pages for each category. It will probably be very useful.

{section name=thecat loop=$cat_array start=$start}

[a href="{if $pagename eq "upcoming" || $groupview eq "upcoming"}{$URL_queuedcategory, $cat_array[thecat].safename}{else}{$URL_maincategory, $cat_array[thecat].safename}{/if}"]{$cat_array[thecat].name}[/a]

{/section}

Thursday, September 17, 2009

Error bringing over the online version to the local server

OK, hassles trying to import the online version via svn to local MAMP server. Keep getting error X_table is empty or does not exist. As predicted in original Pligg install notes, when something goes wrong, it's likely to be either the settings.php or dbconnect.php files. I'm checking the following pages for help/advice/clues

http://moremoneygirls.net/programming/error-fix-the-table_prefixconfig-table-is-empty-or-does-not-exist/
http://forums.pligg.com/questions-comments/6401-pligg_config-table-empty-does-not-exist.html

Just checked out the contents of the settings.php and dbconnect.php file - they have references to passwords, base urls, database names etc. No other code that affects anything, so the easiest fix is to just overwrite the files with the old versions that worked with your local database! (so that's two pligg files i understand :-)

Now, for svn to work, we either don't bring checkout those two files or just never commit the changes to those files back online. Which is fine as the files won't ever be used for anything else (they're quite small).

How exciting! I feel like I'm unraveling a really large knot in fishing line.

I'll post my evening's progress tomorrow, got a bit more work I want to finish off before signing off

jct

SVN progress!

OK – big couple of days.

As I left it on Monday, I’d downloaded RapidSVN to my Mac. When I tried to add a repository (which is the folder where we house all of the files we will work on through svn) through the program it prompted me to do this through the Terminal with command line prompts. I wasn’t sure how to log in to Strine through the Terminal, so I decided to wait until that evening after uni to ask the bf (who has some experience with the UNIX interface). As I mentioned in the last post, I’d also sent off an email to the hosting company hoping they might send out something that might help.

After leaving the uni meeting early on Monday, I got home and tried to set up a repository after the bf showed me how to log in. It didn’t seem to be working – I couldn’t even log into strine using RapidSVN but I wasn’t sure if I was just flaking out and doing something wrong due to being unwell. There was still no response from the hosting company. I decided sleep would be a better option. The bf kindly tried to work it out for me for a couple of hours using the command line and TortoiseSVN (the Windows SVN client he is used to using for work), but he couldn’t get a connection either.

I sent this to the hosting company the next morning:

From: "janet_tot@yahoo.com" janet_tot@yahoo.com
To: ticket@segpub.com.au
Sent: Tuesday, 15 September, 2009 9:46:52 AM
Subject: Problem setting up svn on strine.net.au

IP: 66.216.73.128I tried to set up subversion on strine.net.au last night by running svnserve. By default svnserve on bsd systems listens on an IPv6 TCP port, but because we need to access it over the internet I overrode this behaviour by specifying an IPv4 hostname. The command was:

svnserve -d --foreground -r . --listen-host 0.0.0.0

Using netstat I was able to determine that svnserve was listening on the default svn port, 3690, and using the svn client on the same host I was able to connect to the server.

I was not able to connect to the server from a machine on another computer. The svn clients I tried (TortoiseSVN on Windows, svn from the command line and RapidSVN on Mac) were timing out when trying to connect, which gives me the impression they were not able to connect to that machine:port. Are certain ports blocked?

Could you let me know how you set up subversion on the host? Did you just install subversion, or get as far as setting it up to accept connections, and if so what IP address, hostname, port and protocol (svn, svn+ssh, http?) we should be using to connect?


Thanks
Janet




I didn’t receive a reply from them that night, so the bf kindly had another go at fixing the problem the next night, while I recuperated in my sick bed. He tried to create a repository directly on the server, but was still unable to connect with it. The good thing was, he clearly fiddled enough with the host’s server to cause them alarm, so they actually responded the next morning:

From: "ticket@segpub.com.au" ticket@segpub.com.au
To: janet_tot@yahoo.com
Sent: Wednesday, 16 September, 2009 7:00:52 AM
Subject: [segpub.net #5371] re strine.net.au

Hi Janet,

Apologies for the delay in getting back to you.

In regards to SVN, please don't run any background servers on your account, this is not allowed. SVN has been setup over HTTP at svn.strine.net.au.If you look in your "svn" directory within your home folder, you'll see two files here: .svnpass & .svnaccess.

The first file is an htpasswd file where you add your users to. To add a new user, you'll need to SSH into your account and run:
htpasswd ~/.svn/.svnpass username
Where username is the user you want to add (or edit if they exist).
Secondly the next file determines permissions for what repositories the user can access. The format of that is as follows:
[repositoryname:/]
user = rw

In this example we've allowed the user "user" read/write access to the repository named "repositoryname".To create a new repository, you'll need to use the svnadmin program:

svnadmin create ~/svn/repositoryname

Where repositoryname is the name of the repository you're wanting to create. Once you've created the repository you'll need to set the permissions on the directory to be 775 recursively, so ideally you should run:
chmod -R 775 ~/svn/repositoryname
Once you've created the repository initially so that read/writes can happen correctly over HTTP.

-- Best Regards,
Segment Publishing Customer Support



Once again, invisible files were the cause of my pain! By logging into the host’s server via the terminal, which you do by typing

ssh username@siteaddress
i.e.
ssh strine@strine.net.au

And then by filling in the password at the prompt, you are logged into the server!
Then, I got into the svn folder by entering
cd svn
(which means ‘change directory’ to svn)

I then asked it to list the contents of the directory (ls), but the bit at the end means show all of the invisible files as well
ls -la

I could see that they had created the files as described, and had shifted all of the bf’s repository files into a folder called ‘old’. They’d done all of this at 6.45am. With the delays in emails and the times I was getting replies from them, I’m starting to think the hosting co is just some dude with a day job, dealing with help issues before/after work.

So I tried to follow the instructions and to create a username/password for myself, but it wasn’t letting me save anything. I CHMODed the directory and it looked like I only had read access to the file. I had the bf check this when he got home from work and I was right! (I can’t believe I know all of this stuff now!). So I sent off another email (and was glad I had put in the deadline for getting this set up as Saturday, with all of the unforseen hiccups!).

From: "janet_tot@yahoo.com" janet_tot@yahoo.com
To: ticket@segpub.com.au
Sent: Wednesday, 16 September, 2009 7:51:07 PM
Subject: Re: [segpub.net #5371] re strine.net.au

Hi, thanks for getting back to me
I've tried to follow the instructions below to add a new user, but it looks like I don't have permission to write to either .svnpass or .svnaccess
Could you please let me know what it is that I might have missed?

Janet


Fortunately the hosting co got back to me this morning

From: "ticket@segpub.com.au" ticket@segpub.com.au
To: janet_tot@yahoo.com
Sent: Thursday, 17 September, 2009 6:48:53 AM
Subject: [segpub.net #5371] re strine.net.au

Hi Janet,

Try again now, sorry.

-- Best Regards,Segment Publishing Customer Support


Do I did try again and it worked! I’ve set myself up with a user name and password.
I created the repository by calling for the unix visual editor by typing in
vi .svnaccess

which created a visually unappealing version of the svnaccess file. I typed ‘I’ which allowed me to insert text into this file. I followed the hosting co’s instructions and gave myself read/write access to the repository by entering
[strinerespos:/]
jto = rw

After exiting there, I went to the client RapidSVN. It took a bit of mucking about but I managed to log into the repository! Very exciting :-)

Tonight after work I plan to transfer the site files to the repository and check that it’s all working (and how it will all work). I will also set up user name/passwords for the team. And try to work out how to use RapidSVN to call on different versions of code.

Tomorrow I’ll look into seeing how we’re going to make it work with Strine online – i.e. how we update the files. I’ll also test how Pligg responds to having the files updated in this way (although considering Pligg itself uses SVN, I’m pretty sure it should be OK). It will also be a good chance to test the database backup that’s built into Pligg, before we put too much information into it.

Considering I’m working the next couple of days, that should pretty much fill all of my spare hours!

jct