开发者

Documents repository (PHP)

This post is more to get advises and ideas rather than solving a problem. It's a bit difficult to explain, but I will try my best.

I have a document repository which consists o开发者_如何学Gof a unique directory with PDF, these documents have to be displayed to the end-user in "virtual" folders, as they must be visible in many of them. What I call virtual folders are a normal hierarchy of directories in the filesystem, but the final documents must be taken from the PDF repository mentioned previously.

Examples :

repo/{dozens of PDF}
rootfolder/sub-folder1/sub-folder11/contracts1.php
          /sub-folder2/contracts1.php
          /sub_folder3/sub-folder31/contracts2.php
          /sub_folder4/sub-folder41/sub-folder42/sub-folder43/contracts3.php
          /sub-folder5/contracts5.php

That was a project my boss wanted to be ready very quickly, so at this moment, I've been using php-file-tree that generates a nice tree-like way to navigate through the folders, the end file in each folder being a php file with the list of PDF. It works great, but for every changes, I need to edit those php files, and in the future this task should be done by someone else (an office user with no knowledge in HTML/PHP editing) in a easy way.

What would you guys recommend me?

The 2 important things are :

  1. the PDFs must be in one single location, single directory

  2. the end-user must see a tree-like page

Thank you.

fabien


Disclaimer: This is probably a bit much, but maybe it's useful anyway.

They way I would do it:

  • use ExtJs with Ext.tree.Panel (with one tree being your source of pdfs, and the second the virtual directories)

  • store the final tree in a database or xml-file

  • build a mini admin gui for the office user

  • build a view for the enduser only displaying the tree of virtual directories with their pdfs.


I would make a directory tree really virtual, i.e., instead of creating it in file system, I would create it in DB. List of files would also be in DB (i.e., filenames in DB, files - on filesystem). Another DB table would be used for linking files to directories.

create table file (
    id integer primary key,
    name varchar(64) not null
) engine = InnoDB;

create table directory (
    id integer primary key,
    parent_id integer,
    name varchar(64) not null
) engine = InnoDB;

create table file_in_directory (
    file_id integer not null,
    directory_id integer not null,
    primary key (file_id, directory_id)
) engine = InnoDB;

insert into directory (id, parent_id, name) values
    (1, null, 'rootfolder'),
    (2, 1, 'sub-folder1'),
    (3, 1, 'sub-folder2'),
    (4, 1, 'sub-folder3'),
    (5, 1, 'sub-folder4'),
    (6, 1, 'sub-folder5'),
    (7, 2, 'sub-folder11'),
    (8, 4, 'sub-folder31'),
    (9, 5, 'sub-folder41'),
    (10, 9, 'sub-folder42'),
    (11, 10, 'sub-folder43');

insert into file (id, name) values
    (1, 'contracts1.php'),
    (2, 'contracts2.php'),
    (3, 'contracts3.php'),
    (4, 'contracts5.php');

insert into file_in_directory (file_id, directory_id) values
    (1, 7), -- rootfolder/sub-folder1/sub-folder11/contracts1.php
    (1, 3), -- rootfolder/sub-folder2/contracts1.php
    (2, 8), -- rootfolder/sub_folder3/sub-folder31/contracts2.php
    (3, 11), -- rootfolder/sub_folder4/sub-folder41/sub-folder42/sub-folder43/contracts3.php
    (4, 6); -- rootfolder/sub-folder5/contracts5.php
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜