Friday, December 30, 2011

My answer to "Little bug, with open editor"

This is my answer to a Question on Support site for LampCMS project


I don't really consider it a bug. It is actually a very valuable feature. The editor uses browser local storage feature to save text from your editor to local storage. So if you type something in the editor and don't post it right away and your session expires, the editor will still remember your text.

There is even a "save" icon in the editor so you can save whatever you typed in the editor, so you can continue writing your post later, can be even in a few days.

If you don't push the Save button, the text is auto-saved every few seconds so if your computer crashes your text will still not be lost.

The contents of cache are cleared after you post a question or the answer and the "success" message is returned from the server. This way if the sever is down for any reason at the time you trying to post, your text in the editor is still not lost, so you can try to post later.

As for second window "bug", it's just how browsers work - it shares local storage between windows for the same domain.

Finally if this bothers you, there is an icon next to "Save" icon in the editor "New". Clicking on it clears the cache of editor and your start with a blank page.

Enjoy.

Tuesday, December 27, 2011

New feature - categories

My Question on Support site for LampCMS project

Just want to let you all know that I've been working on adding support for categories, in addition to tags.

The first, most important part of this was to write an admin interface to add/edit categories and to sort categories by the order and by sub-categories.

I have just finished this feature. Basically we going to have support for categories with unlimited nested categories.

Next step will be to add drop-down menu to select the category when posting a question, then add a breadcrumb navigation links to question view pages to point to category.

Then add a new page that will show the list of all categories and sub-categories. That page will probably look similar to the look of most online forums like phpbb and vbulletin, where you see categories, subcategories and latest posts in each category.

More feature will be added, for example we will probably have a way to subscribe to category, similar to subscribing to a tag.

Should I upload the new category editor files now or wait until support for selecting a category when asking a question is done?

Click here to post your reply


Saturday, December 24, 2011

My answer to "Updates to Facebook API"

This is my answer to a Question on Support site for LampCMS project


I have just pushed the new files to github. It includes the new API for Facebook, both for login with Facebook and for posting to Facebook Wall.

This updates also includes a rewrite of how User (Viewer) object is stored in session. The User object is no longer stored in session, only the userid and classname of user is stored in session and the actual object is recreated on page load.

Is this less efficient? I don't thinks so. The select of user array on primary key from Mongo collection takes about 1 millisecond. Creating a new object is not any slower that unserializing it.

The benefit of this change is that session becomes alot more reliable now. No more sudden user logout, no more unpredictable session behaviour.

I also rewrite some parts of the script that used to have the exit() statement, we no longer using exit(), instead using a special type of exception which propagates all the way to the end of the script, so script always exists the natural way. The exit() method is not bad way to terminate the script, except that in some servers, in certain server environments it causes problems. Since this is an open source project, it must work on as many different platforms as possible. I think the latest change makes alot of progress in making it alot more reliable.

Please download, install, test it. Report any problems if you encounter any.

Thank you.

Monday, December 19, 2011

My answer to "Geo location"

This is my answer to a Question on Support site for LampCMS project


There is not special code to install. It's all automatic. If the user location can be determined from ip address, it is stored in USERS collection and then it's automatically shown on profile page.

Also when adding new question or answer the location, if it can be resolved from the ip address is stored in the collection with the QUESTION or ANSWER and than data base be shown or question/answer page. But that location (in Question or Answer) is not automatically displayed. I will update the templates to show the country flag of the locations in Question and Answer templates and will upload to github by end of the year.

Keep in mind that location is stored only if it is successfully resolved from the ip address, which means it will not work when you developing your site on localhost because your ip is local ip then.

Sunday, December 18, 2011

Updates to Facebook API

My Question on Support site for LampCMS project

As was noticed by one of the users, there is a problem with the "logout" action. I traced this problem to the Facebook Javascript API.

So I started investigating further and it turned out that Facebook has updated their APIs a couple of month ago and on December 13 the old APIs no longer working.

That's the reason for our problems with logout and with login using facebook button.

I will be rewriting our own Facebook API now. I will be using the official facebook php sdk this time.

This is not a difficult thing for me to do, normally stuff like that will take 2 days - one to write, another day to test and debug. The problem is that I'm not going to have 2 days untill Christmas, so the updates will be available after Christmas, but maybe even sooner. I have already started writing the new Client to Facebook API.

Click here to post your reply


Saturday, December 17, 2011

My answer to "Logout problem in original lampcms"

This is my answer to a Question on Support site for LampCMS project


I am having the same problem now. This is something new and it has to do with javascript from Facebook.

I searched for this error, looks like other people are having this problem with Facebook Javascript, but I just can't find any answer on how to fix this. There is a bug report filed on facebook API forum but apparantly that bug is closed.

Honestly I don't know how to fix this other than just not use Facebook login feature for now until these clowns at facebook fix their script.

Friday, December 16, 2011

My answer to "Problem with Geo_location"

This is my answer to a Question on Support site for LampCMS project


I have made a small change to Geo/Import class. It now creates indexes first and then imports, instead of creating data and then indexing it.

I tested on my local Windows 7 and on this site, both worked fine, but I never had the problem with the import in the first place. All I know that the script works after the update.

You can download the latest version from github and try it.
I also made some minor changes, so the never version is probably a little bit better anyway.

For example, the session_start is called earlier in the process, possibly fixing problem some people were having with sessions on local installations.

Also error handler will not email admin of non-critical errors.

My answer to "Problem with Geo_location"

This is my answer to a Question on Support site for LampCMS project


So it sounds like your script imported the 3.5 million records into GEO_BLOCKS which is good, then connection to MongoDB was lost. I know the GEO_BLOCKS import takes long, can take 3-5 minutes to complete as records are imported one by one.

I have not faced this problem before.

I'll investigate. Maybe there is some extra setting or param to MongoDB connection that can be used, I'll look into that. If I can't find the answer then maybe I can split the import into 2 scripts - one to import GEO_BLOCKS and then run another script to import LOCATIONS.

Thursday, December 15, 2011

My answer to "Is it possible for moderators to filter or control the posts before they are published?"

This is my answer to a Question on Support site for LampCMS project


RIght now there is no such feature. Moderator can only delete or edit post but there is no feature to "approve" a post.

This feature can be added pretty easily, probably with very little programming, just have to set the status of new posts to "deleted" - deleted posts dont show up on the site but moderator/admin can still see deleted posts and can 'undelete' them, so this will be exactly the feature you looking for.

Tuesday, December 13, 2011

My answer to "how GEO location is working flow of the geo location"

This is my answer to a Question on Support site for LampCMS project


First read and follow instructions in geo_import.php file in the www directory.

The location of user is resolved during the post of new question or answer and stored with the answer or question, in the same collection, in the same record.

Also location of user is stored during the registration process in the USERS collection, and during the normal operation of a site, if the "whos online" module is enabled in !config.ini, then it is also stored in the ONLINE collection.

You can then use this data in your custom module to display the locations of users. For example you can create a page with Google maps showing currently logged in users on the map or you can show a map on the View Question page showing locations of where the answers came from.

Or you can just edit template to display country name and city.

The extra fields added to collections to represent locations are:

'cc' = country code like US
'cn' = country name like "India"
'city' = city
'lat' = latitude
'lon' = longitude

Not all fields will have data, some locations may have only cc and cn and no city. Most of the time all the fields will be present.


Saturday, December 10, 2011

My answer to "EXPLAIN THE FLOW..."

This is my answer to a Question on Support site for LampCMS project


It means if question has any answers or if currently logged in user of the site is a moderator (admin also moderator, so it's true for admins too), then instantiate the Answers object and get the answers for this question.

The reason for isModerator check is that in theory the question may contain deleted answers, which would mean that count of answers is 0, but there still may be deleted answers. Since moderator may be allowed to "undelete" answers, the Answers object will still pull all the answers, even deleted ones.

My answer to "Language translation problem"

This is my answer to a Question on Support site for LampCMS project


The translation files are cached. You need to clear your cache. When logged in as admin, click on Settings, you will see an option to clear cache. Click on it and it should remove everything from cache collection.

After doing that try and see if your translations work on your site

Friday, December 9, 2011

My answer to "Follow Mecahnism"

This is my answer to a Question on Support site for LampCMS project


To explain it very simple - the user ID of your user account is added to array of followers. So a single question may has a property a_flwrs which is an array of user ids.

Very simple. When you unfollow question., your user id is removed from that array.

My answer to "How many collections are there in mongodb for lampcms"

This is my answer to a Question on Support site for LampCMS project


Looks about right. Once you start creating questions, answers and comments, the new collections will be added automatically as needed.

My answer to "Why social buttons are not displaying on local lampcms"

This is my answer to a Question on Support site for LampCMS project


You need to configure each one of the services, for example, to enable login with Twitter you need to register with Twitter developer account. Same for Facebook.

The buttons are only going to appear for services that you enabled - you must have special user accounts for each one. For example, to enable LinkedIn button, find the section [LINKEDIN] in your !config.ini and setup your own OAUTH_KEY and OAUTH_SECRET
Once set, the button will appear.

Also you will need to logout and log back in because I think the block with the buttons are cached in session for performance reasons.

Instructions are in the !config.ini file.

My answer to "How Geo Location is identifying in lampcms?"

This is my answer to a Question on Support site for LampCMS project


Geo IP database files are not included. You need to download the .csv files from Maxmind.com and run an import script.

Instructions are in the geo_import.php file in the www folder. Follow instructions and start this file from your browser. Once imported, the GeoIP will work on your site to map ip to location.

Thursday, December 8, 2011

My answer to "What actually contains question_title table?"

This is my answer to a Question on Support site for LampCMS project


It stores titles of questions.
Simple as that. The interesting thing about it as that this table has a full text index of titles.
Using full test search of mysql it is then easy to find "Similar" questions for a new question.
It is also used for the search feature of the site - the "Search" form uses it.
In the future the search feature may be powered by a more sophisticated search engine, but for now it's powered by mysql full text search. It's very easy to setup and it does the job.

Monday, December 5, 2011

My answer to "does lampcms support chinese well?is there some example website in china based on lampcms?"

This is my answer to a Question on Support site for LampCMS project


If you write your language translations string file, the ".xlf" file in the utf-8 charset that it can be in chinese or in any other language as long as it uses utf-8 encoding.

You just need to write your own translation file and same in 'translations' folder, name it "messages.cn.xml" ( I think "cn" is correct abbreviation for chinese locale, but I'm not sure)

You can see how it's done in translations/messages.ru.xlf for the Russian translation.

You then have to add a line in the !config.ini in the [LOCALES] section. For example, add this:
cn = "Chinese"

That will add the extra option to the drop-down language selection menu at the bottom of your site.

Saturday, December 3, 2011

My answer to "Few doubts in Lampcms ???"

This is my answer to a Question on Support site for LampCMS project


The factory in Urhere is not in User class. Urhere class extends LampcmsObject, so it uses factory in LampcmsObject. That class in the \Lampcms\Object.php file.

factory method even though is static, is inherited by sub-class - it's part of php 5.3 late static binding feature, where a new keyword "static" refers to the calling class. factory method then call constructor of the calling class.

Trust me, everything just works, and works pretty well.

My answer to "[want try lampcms]how to safely upgrade php 5.1.6 to php 5.3.3 , what should be backup before"

This is my answer to a Question on Support site for LampCMS project


I would say just install php 5.3.3 and try it.

Some existing php programs may have a few errors (most likely just warnings) pop up here and there after the upgrade, those can be easily fixed.

The 5.1.6 is really an outdated version, 5.3.3 (or newer) is much more effecient and just a faster version.

You will almost certainly will want to also use the APC extension instead of eAccelerator or if you really like eAccelerator then at least upgrade it to version compatable with php 5.3. I personally would just go with APC since it's not standard part of php and is maintained by php, unlike eAccelerator.

You don't have to do anything with nginx, just upgrade php, make sure you install php-fpm and use run php as fastcgi under php-fpm management.