snytkine / LampCMS

Open source Question and Answer program similar to StackOverflow and Quora in PHP + MongoDB. Follow @snytkine on Twitter

Home Page:http://support.lampcms.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Use output buffer to substitute some variables

snytkine opened this issue · comments

Since many blocks in lampcms are pre-created and stored in DB as html string the only feasible way to use some types of variables is to store them in html like {WWW_DIR}, {URL_JS}, {URL_CSS}, {URL_AVATAR}, {URL_IMAGES}, {URL_UPLOADS}
Then do the replacement of these pseudo variables as a callback from output buffer.

This will allow histing images, css, js, avatars on different servers. Most useful will be for avatars, uploaded images and WWW_DIR since these are stored in parsed html. URL_JS and URL_CSS is probably not necessary to replace in output buffer

The advantage of doing this is that it will be automatically applied to non-ajax and to ajax based calls since output buffer callback is applied automatically when ob_end_flush is called or even when it's not called at all when php just flushes buffer at end of script.

Need to investigate wheather of not buffer is flushed when fastcgi_finish_request() is called or not. It's probably better to just
call ob_end_flush() manually in index.php and in in Responder::sendJSON()

Done. Translation and generation of links by replacing URI based placeholders are done in output buffer.