I’m new guy in PHP and want to add some more feature to OJS 3.1.1. Anyone can share which PHP framework that was used to implement OJS 3.1.1 (this would help me approach the code faster) and which IDE I should use to add more pages, features? I tried to integrate Apache in Eclipse to run the debug mode but it seem we couldn’t. Thanks in advance.
OJS uses own framework but it relies on several external libraries, e.g., it uses ADOdb as an abstract layer for interactions with the database, Smarty template engine for front-end, etc.
It’s build as a standard MVC application and has standard elements. like models, DAO classes, Controllers (Handlers)…
The best way to add a feature is making a plugin, I recommend to look at the plugins list and pick a one that adds similar functions and use it as a template for own code.
Do you have some specific function to add on your mind?
thanks for your suggestion,
regard my new feature, I want to count the number of page view (for example count the views in one article), I want to show it directly in that page so I think it should be update in the existing code.
Anyway just a small example I want to change so I want to dig deeper into the architecture, design of the code. Do you have any suggestion about the development environment (which IDE, server? how to debug?) for OJS?
I usually just deploy a current stable release or master branch on my local machine and run it with apache server. Any editor or IDE will work, I prefer PHPStorm as I’m finding searching needed methods with it faster.
As for the task, OJS counts the number of views for article landing page and each galley separately. You can start from looking at getViews() method from PublishedArticles class: https://github.com/pkp/ojs/blob/master/classes/article/PublishedArticle.inc.php#L77
For example, you can retrieve PublishedArticles from a plugin, call this method and assign result to Smarty templates. I’ve something similar in the Immersion theme recently - retrieved published articles and some additional data, iterated through all articles and assigned additional data to a result 3 dimensional array: https://github.com/pkp/immersion/blob/master/ImmersionThemePlugin.inc.php#L98 But that was for issue page. If you want to show on the article landing page, it should be much easier. E.g., to call articles from that page you only need something like:
$article = $smarty->get_template_vars("article"), and then
$article->getViews() (from OJS 3.1.2 ->getTemplateVars(…)). Or
$publishedArticleDao = DAORegistry::getDAO('PublishedArticleDAO'); $publishedArticle = $publishedArticleDao->getPublishedArticleByBestArticleId((int) $journal->getId(), $articleId, true);
But you need here to get journal id and article id before this. I think using
TemplateManager::display here should be enough. For the example, you can look at any plugin that is using it. If you are planning to override article page from a theme, you may use the Immersion theme as an example.
thank you, Vitaliy
Such a detail and awesome guide. I will follow up