OJS OCS OMP OHS

You are viewing the PKP Support Forum | PKP Home Wiki



Manager and File handlers

OJS development discussion, enhancement requests, third-party patches and plug-ins.

Moderators: jmacgreg, btbell, michael, bdgregg, barbarah, asmecher

Forum rules
Developer Resources:

Documentation: The OJS Technical Reference and the OJS API Reference are both available from the OJS Documentation page.

Git: You can access our public Git Repository here. Comprehensive Git usage instructions are available on the wiki.

Bugzilla: You can access our Bugzilla report tracker here.

Search: You can use our Google Custom Search to search across our main website, the support forum, and Bugzilla.

Questions and discussion are welcome, but if you have a workflow or usability question you should probably post to the OJS Editorial Support and Discussion subforum; if you have a technical support question, try the OJS Technical Support subforum.

Manager and File handlers

Postby jjgitties » Tue Nov 26, 2013 4:50 am

Hi, I am trying to re-use the functions of the journal file upload area as used in the "manager/files". I can see that the 2 main handlers are Manager and FileHandler. All I really need to do is customize the folder location (it's different from the default location) where the page uploads and lists files from. My location is going to be "external/files". Is there a way to pass a customized "currentPath" and "currentDIR" to the tpl files or do I just create a new handler and extend these or can I pass a variable argument to the pages?

FilesHandler.inc.php

ManagerHandler.inc.php

from the index.tpl of "manager/files"

Code: Select all
{assign var="pageTitle" value="manager.filesBrowser"}
{include file="common/header.tpl"}
{assign var=displayDir value="/$currentDir"}
<h3>{translate key="manager.files.indexOfDir" dir=$displayDir|escape}</h3>

{if $currentDir}
<p><a href="{url op="files" path=$parentDir|explode:"/"}" class="action">&lt; {translate key="manager.files.parentDir"}</a></p>
{/if}
jjgitties
 
Posts: 20
Joined: Tue Nov 12, 2013 11:11 am

Re: Manager and File handlers

Postby asmecher » Tue Nov 26, 2013 8:44 am

Hi jjgitties,

If you want a quick and easy way to do this, why not make a symbolic link from your files directory into the directory you also want to permit browsing within? The file manager should follow the symbolic link as though it were any directory when you click on it.

Regards,
Alec Smecher
Public Knowledge Project Team
asmecher
 
Posts: 8851
Joined: Wed Aug 10, 2005 12:56 pm

Re: Manager and File handlers

Postby jjgitties » Tue Nov 26, 2013 8:59 am

Mainly because we want to try to keep the files separate in content. They are not journal files.

I am assigning variables in the handlers as such: All the files are in /var/www/files/myfiles folder.

$currentDir = "/";
$parentDir = "/var/www/files/";
$displayDir = "/myfiles/";
$templateMgr->assign('currentDir', $currentDir);
$templateMgr->assign('parentDir', $parentDir);
$templateMgr->assign('displayDir', $displayDir);

In the tpl i am using the default code.

Code: Select all
{assign var="pageTitle" value="manager.filesBrowser"}
{include file="common/header.tpl"}
<h3>{translate key="manager.files.indexOfDir" dir=$displayDir|escape}</h3>

{if $currentDir}
<p><a href="{url op="files" path=$parentDir|explode:"/"}" class="action">&lt; {translate key="manager.files.parentDir"}</a></p>
{/if}

<table width="100%" class="listing">


I guess my question is, should the handler extend Handler or FilesHandler?

This

Code: Select all
class NewFilesManagerHandler extends Handler {


or

Code: Select all
class NewFilesManagerHandler extends FilesHandler {
jjgitties
 
Posts: 20
Joined: Tue Nov 12, 2013 11:11 am

Re: Manager and File handlers

Postby asmecher » Tue Nov 26, 2013 10:18 am

Hi jjgitties,

If all you want to do is permit web-based administration, through the Manager's "Files Browser", of a directory outside the journal files directory -- then the symbolic link approach would work. I'd suggest giving it a quick try to see if it'll suit your needs, since it's so easy and will save you hacking the code every time you need to upgrade.

However, if you'd like to code up the same thing by extending the existing classes, then here are a few suggestions:
  • The FilesHandler already extends the ManagerHandler. I suggest extending the FilesHandler -- otherwise you'd have to duplicate all the relevant code in FilesHandler, much of which can probably be reused.
  • Note that you'll have to map functions from the URL to the right handler class; that's done in pagse/manager/index.php. Note that you'll have to figure out how to permit both FilesHandler and your new files handler classes to be used when many of the functions will have the same names. You might consider having differently-named functions in the new handler class that simply call functions of the old names, e.g. (untested):
    Code: Select all
    function newFiles($args, &$request) {
        return $this->files($args, $request);
    }
    This will permit you to use your extension of the existing files() function, even though requests to that directly in the URL will go to the FilesHandler rather than your new handler. You'll have to differentiate between the two in your templates, of course.
Regards,
Alec Smecher
Public Knowledge Project Team
asmecher
 
Posts: 8851
Joined: Wed Aug 10, 2005 12:56 pm

Re: Manager and File handlers

Postby jjgitties » Thu Nov 28, 2013 7:02 pm

Now I see why you suggested doing the sym links. Its a real pain to go it manually the other way.
jjgitties
 
Posts: 20
Joined: Tue Nov 12, 2013 11:11 am


Return to OJS Development

Who is online

Users browsing this forum: No registered users and 2 guests