project report of integrating google docs with open journal system · 2011. 9. 22. · abstract...

29
PROJECT REPORT OF INTEGRATING GOOGLE DOCS WITH OPEN JOURNAL SYSTEM by Zoro Wu a Report submitted in partial fulfillment of the requirements for the SFU-ZU dual degree of Bachelor of Science in the School of Computing Science Simon Fraser University and the College of Computer Science and Technology Zhejiang University c Zoro Wu 2010 SIMON FRASER UNIVERSITY AND ZHEJIANG UNIVERSITY Spring 2010 All rights reserved. This work may not be reproduced in whole or in part, by photocopy or other means, without the permission of the author.

Upload: others

Post on 12-Sep-2020

2 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: PROJECT REPORT OF INTEGRATING GOOGLE DOCS WITH OPEN JOURNAL SYSTEM · 2011. 9. 22. · Abstract Open Journal Systems (OJS) is an open source journal management and publishing system

PROJECT REPORT OF INTEGRATING GOOGLE DOCS

WITH OPEN JOURNAL SYSTEM

by

Zoro Wu

a Report submitted in partial fulfillment

of the requirements for the SFU-ZU dual degree of

Bachelor of Science

in the School of Computing Science

Simon Fraser University

and

the College of Computer Science and Technology

Zhejiang University

c© Zoro Wu 2010

SIMON FRASER UNIVERSITY AND ZHEJIANG UNIVERSITY

Spring 2010

All rights reserved. This work may not be

reproduced in whole or in part, by photocopy

or other means, without the permission of the author.

Page 2: PROJECT REPORT OF INTEGRATING GOOGLE DOCS WITH OPEN JOURNAL SYSTEM · 2011. 9. 22. · Abstract Open Journal Systems (OJS) is an open source journal management and publishing system

APPROVAL

Name: Zoro Wu

Degree: Bachelor of Science

Title of Report: PROJECT REPORT OF INTEGRATING GOOGLE DOCS

WITH OPEN JOURNAL SYSTEM

Examining Committee:

Dr. Qianping Gu, Professor, Computing Science

Simon Fraser University

Supervisor

Dr. Krishnamurti, Professor, Computing Science

Simon Fraser University

SFU Examiner

Date Approved:

ii

Page 3: PROJECT REPORT OF INTEGRATING GOOGLE DOCS WITH OPEN JOURNAL SYSTEM · 2011. 9. 22. · Abstract Open Journal Systems (OJS) is an open source journal management and publishing system

Abstract

Open Journal Systems (OJS) is an open source journal management and publishing system.

To include a more seamless online environment in which documents can be edited and that

Google Docs has given the potential for smart interaction with documents, the OJS team

would like to implement features where document editing and version control is handled by

Google Docs. Google Docs is a free, Web-based word processor and data storage service

offered by Google. After doing a short survey on the project, I realized several features to

integrate Google Docs with OJS in a 13-week semester. The key functions supported are

authenticating an account into Google Docs, uploading a document into the Google Docs

account and modifying the document’s accessibility for specific users. The major benefits of

these features include a more seamless online environment in which documents can be edited

and greater potential for smart interaction with documents. As my own project manager,

I managed to define a reasonable scope and finished my project on time. Although the

solution is partial, it fulfills the requirements and provides a set of usable features to users

of OJS for its self-Integrity and extendability.

iii

Page 4: PROJECT REPORT OF INTEGRATING GOOGLE DOCS WITH OPEN JOURNAL SYSTEM · 2011. 9. 22. · Abstract Open Journal Systems (OJS) is an open source journal management and publishing system

Contents

Approval ii

Abstract iii

Contents iv

List of Figures vi

1 Introduction 1

1.1 PKP and OJS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1

1.2 User roles and responsibilities . . . . . . . . . . . . . . . . . . . . . . . . . . . 3

1.3 Article submission work flow . . . . . . . . . . . . . . . . . . . . . . . . . . . 4

1.4 Google Docs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4

1.5 Project intention . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6

1.6 Overview of the following chapters . . . . . . . . . . . . . . . . . . . . . . . . 6

2 Project scope 7

2.1 Where to store the document . . . . . . . . . . . . . . . . . . . . . . . . . . . 8

2.2 Google Docs account . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8

2.3 Narrow the scope . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9

3 Google Docs API and low layer functions 10

3.1 Authentication . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11

3.2 Uploading a document . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12

3.3 Document accessibility (ACL manipulation) . . . . . . . . . . . . . . . . . . . 14

iv

Page 5: PROJECT REPORT OF INTEGRATING GOOGLE DOCS WITH OPEN JOURNAL SYSTEM · 2011. 9. 22. · Abstract Open Journal Systems (OJS) is an open source journal management and publishing system

4 OJS technical layers 16

4.1 Add a hyper link . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18

5 Conclusion 21

5.1 LAMP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21

5.2 Google Services . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22

5.3 Future improvement . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22

Bibliography 23

v

Page 6: PROJECT REPORT OF INTEGRATING GOOGLE DOCS WITH OPEN JOURNAL SYSTEM · 2011. 9. 22. · Abstract Open Journal Systems (OJS) is an open source journal management and publishing system

List of Figures

1.1 OJS website overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2

1.2 OJS article submission work flow (Page 12, OJS in an hour)[3] . . . . . . . . 5

2.1 My initial idea, a basic process . . . . . . . . . . . . . . . . . . . . . . . . . . 7

4.1 OJS technical layout . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17

4.2 The Google Docs link shown in file information . . . . . . . . . . . . . . . . . 20

vi

Page 7: PROJECT REPORT OF INTEGRATING GOOGLE DOCS WITH OPEN JOURNAL SYSTEM · 2011. 9. 22. · Abstract Open Journal Systems (OJS) is an open source journal management and publishing system

Chapter 1

Introduction

1.1 PKP and OJS

The Public Knowledge Project (PkP) is a research initiative on on-line publishing and

knowledge-sharing, trying to improve the scholarly and public quality of academic research.

It is begun by Professor John Willinsky and now cooperated by the Faculty of Education

at the University of British Columbia, the Simon Fraser University Library, the School of

Education at Stanford University, and the Canadian Center for Studies in Publishing at

Simon Fraser University. PKP has developed free software for management, publishing and

indexing of journals and conferences that are Open Journal System and Open Conference

System.[5]

Open Journal Systems (OJS) is open source software which is freely available for jour-

nal hosting and publishing worldwide. It provides all features that online journal system

need that are article submission, editing, reviewing and publishing. Being installed on web

servers, the OJS system is a fully functional web site. It hosts online journal entries within

the site. The site administrator maintains a list of journals as well as users. Users are

assigned roles, typically bound with journals. For each journal, multiple registered users act

differently to play their roles. The roles are divided into seven categories that are author,

editor, section editor, reviewer, copyeditor, layout editor, proofreader and reader. Figure

1.1 shows the overview of an OJS web site.

1

Page 8: PROJECT REPORT OF INTEGRATING GOOGLE DOCS WITH OPEN JOURNAL SYSTEM · 2011. 9. 22. · Abstract Open Journal Systems (OJS) is an open source journal management and publishing system

CHAPTER 1. INTRODUCTION 2

Figure 1.1: OJS website overview

Page 9: PROJECT REPORT OF INTEGRATING GOOGLE DOCS WITH OPEN JOURNAL SYSTEM · 2011. 9. 22. · Abstract Open Journal Systems (OJS) is an open source journal management and publishing system

CHAPTER 1. INTRODUCTION 3

1.2 User roles and responsibilities

In OJS, different user roles own different responsibilities. The following responsibilities for

user roles are specified in the introductory guide of OJS. (Page 10, OJS in an Hour.[3])

• Journal Manager: Sets up journal and staff editorial roles (can also serve

as an Editor and other roles as well);

• Author: Authors are able to register and submit items to the journal directly

through the journal’s web site. The Author is asked to upload the item, as

well as provide metadata or indexing information associated with the item,

to improve the search capability for research online and for this journal.

• Editor: Oversees the editorial process; can assign submissions to Section

Editors to see through Submission Review and Submission Editing; under-

takes scheduling of the content and publishing of the journal.

• Section Editor: Oversees Submission Review and possibly Submission Edit-

ing for assigned submissions.

• Copyeditor: Works with submissions to improve grammar and clarity, poses

questions to the author on possible errors, and ensure strict adherence to

the journal’s bibliographic and textual style.

• Layout Editor: Transforms the copyedited submission into galleys in HTML,

PDF, and/or PS files in the proper format for electronic publishing.

• Proofreader: Reads galleys for typographic and formatting errors.

• Reader: Readers include subscribers for journals for which access is subscription-

based and readers who chose to register for open access journals (whether

immediately open access or open after a period of time after initial publica-

tion of journal content).

• Reviewer: The Reviewer is selected by the Section Editor to review a sub-

mission. Reviewers are asked to submit reviews to the journal’s web site

and are able to upload attachments for the use of the Editor and Author.

Page 10: PROJECT REPORT OF INTEGRATING GOOGLE DOCS WITH OPEN JOURNAL SYSTEM · 2011. 9. 22. · Abstract Open Journal Systems (OJS) is an open source journal management and publishing system

CHAPTER 1. INTRODUCTION 4

1.3 Article submission work flow

Each journal is composed of issues divided by time. As shown in Figure 1.2, an article is

submitted by an author into a journal. Then the process of editing and reviewing starts.

After an article goes through the flow chart shown below, it is ready for being assigned into

an issue of that journal.

OJS currently saves article files on web servers. Each article is composed of two parts,

meta data and an article file. At the very beginning of the submission work flow, an author

submits an article file which can be in any format (like doc, txt, pdf)1. Users enrolled in the

editing process have to download the file from the server, edit it locally and upload the edited

file back into server. This process implicitly requires users’ computers to have document

editing software like Microsoft Office, Adobe Reader, and so on installed. However, the idea

of open source software is to provide free software for better accessibility and usability. The

approach of users handling the editing tools violates the idea of creating OJS, which is to

make all tools freely available.

1.4 Google Docs

As described in the wikipedia web site[6]:

Google Docs is a free, Web-based word processor, spreadsheet, presentation

form, and data storage service offered by Google. It allows users to create and

edit documents online and collaborate in real-time with other users. Google Docs

combines the features of three services, Writely and Spreadsheets and Presenta-

tion.

Google Docs is Google’s software as a service version of an office suite similar to Microsoft

Office. Documents can be created within the web application itself, imported through the

web interface, or sent via email. They can also be saved to the user’s computer in a variety

of formats (ODF, HTML, PDF, RTF, Text, and Word). By default, they are saved to the

Google servers.

Documents in Google Docs are very convenient to use. To use Google Docs, all a user

needs is a Google account and a computer with internet access. Document editing can be

1doc, txt and pdf are common document file formats.

Page 11: PROJECT REPORT OF INTEGRATING GOOGLE DOCS WITH OPEN JOURNAL SYSTEM · 2011. 9. 22. · Abstract Open Journal Systems (OJS) is an open source journal management and publishing system

CHAPTER 1. INTRODUCTION 5

Figure 1.2: OJS article submission work flow (Page 12, OJS in an hour)[3]

Page 12: PROJECT REPORT OF INTEGRATING GOOGLE DOCS WITH OPEN JOURNAL SYSTEM · 2011. 9. 22. · Abstract Open Journal Systems (OJS) is an open source journal management and publishing system

CHAPTER 1. INTRODUCTION 6

accomplished within Google’s online editor interface and saved immediately. Also, another

important feature of Google Docs is that it supports document sharing very neatly. By

simply putting another Google user’s account or someone’s email into the Access Control

List (ACL)2 of a document, the document is successfully shared between users.

Google also provides an API3 for programmers to use in their applications communicating

with Google Docs. This will be discussed more in Chapter 4.

1.5 Project intention

Rather than having OJS users maintain Microsoft Word documents for editing in an off-line

environment, the OJS team would like to investigate and implement features where OJS

delegates document editing and version control to Google Docs. The major benefits of this

integration include a more seamless online environment in which documents can be edited

with greater potential for smart interaction with documents. However, the project is to

some extent under exploration. Since no one in the team has taken a look at the Google

Docs API, the scope and complexity of this project is not defined.

1.6 Overview of the following chapters

The second chapter will give an outline of the project scope. The third chapter will have a

glance of Google Docs API and the Google Docs technical layer functions. Furthermore, the

fourth chapter will take the readers to the OJS classes and details about how to implement

OJS layers. The last chapter, chapter five, will give a brief conclusion on the project and

discuss further improvements and things I learned by doing this capstone project.

2An access control list (ACL), with respect to a computer file system, is a list of permissions attached toan object.

3An Application Programming Interface (API) is an interface implemented by a software program toenable its interaction with other software.

Page 13: PROJECT REPORT OF INTEGRATING GOOGLE DOCS WITH OPEN JOURNAL SYSTEM · 2011. 9. 22. · Abstract Open Journal Systems (OJS) is an open source journal management and publishing system

Chapter 2

Project scope

As stated in the previous chapter, I wanted to allow users to read and edit article files using

Google Docs’ online editor. After taking a look at the Google Docs API, which will be

discussed more in Chapter 4, I planned a basic file manipulation process through Google

Docs. The process is shown in Figure 2.1.

Figure 2.1: My initial idea, a basic process

7

Page 14: PROJECT REPORT OF INTEGRATING GOOGLE DOCS WITH OPEN JOURNAL SYSTEM · 2011. 9. 22. · Abstract Open Journal Systems (OJS) is an open source journal management and publishing system

CHAPTER 2. PROJECT SCOPE 8

2.1 Where to store the document

However, documents in Google Docs are stored in users’ accounts rather than in a simple

web space like an ftp server. Thus, when author uploads a file to OJS and wants it to

be uploaded into Google Docs, it has to be uploaded into someone’s account. If I use the

author’s account, then the file belongs to the author rather than OJS. Once the author

deletes that document, or simply unregisters his/her Google account, then the document is

lost. Thus it is required to set up a Google Docs account for the OJS site at the administrator

level.

2.2 Google Docs account

Since Google Docs is based on user accounts, each user will have to have their own account

to be granted proper accessibility to the document kept in the OJS server’s Google Docs

account. In other words, each user should have a valid Google Docs account name within

his/her profile. OJS can then notify Google Docs to give proper accessing permission to a

user via his/her Google Docs account.

Google Docs allows sharing based on users’ account, and there are three different roles a

user can play in a document’s ACL. The different roles are those of owner, editor and reader.

The OJS site with the administratior Google Docs account is the owner. All users on the

OJS site that need to edit the article file should be granted write permission. These include

editor, section editor and author. Similarly, all users on the OJS site who only need to read

the file should be granted read accessibility, including reviewer, reader and proofreader.

The document is kept in the OJS site’s Google Docs account. And through the Google

Docs API, OJS site users are granted access to that document. By opening that document’s

URL1 , and logging into Google Docs via their own accounts, users can then access that

document and read or edit the document online. Furthermore, users with write permissions

can save their changes for a document. The document’s revision list is kept in Google Docs

automatically and is accessible.

1Uniform Resource Locator (URL) is a subset of the Uniform Resource Identifier (URI) that specifieswhere an identified resource is available and the mechanism for retrieving it.

Page 15: PROJECT REPORT OF INTEGRATING GOOGLE DOCS WITH OPEN JOURNAL SYSTEM · 2011. 9. 22. · Abstract Open Journal Systems (OJS) is an open source journal management and publishing system

CHAPTER 2. PROJECT SCOPE 9

2.3 Narrow the scope

As I was just a beginner of PHP programs2, I found it too much work to finish the whole

integration within 13 weeks. But the good thing was I am my own manager of the entire

project. At the sixth week, I decided to cut off a part of project that deals with file revision

tracking and saving.

The tasks I set out for my project were:

1. Allow the journal manager to set up a Google Docs account/password as the server’s

account to store files when installing the website.

2. Automatically upload the file into the server’s account when the author uploads a file,

showing the link to that document feed.

3. Allow each user to have a field that is his/her Google Docs account.

4. Display the link to an article file in an article’s profile so users can follow that link to

visit the document online.

5. Handle the ACL of the document, when a user is enrolled in an article. Automatically

modify the ACL of the corresponding Google Docs document in the OJS site’s Google

Docs account so the file is accessible by that user (so that any user who can see the

link with a single click, open the Google document online and start reading or editing

in his/her web browser)

2PHP: Hypertext Preprocessor is a widely used, general-purpose scripting language that was originallydesigned for web development to produce dynamic web pages. For more information, visit http://php.net/.

Page 16: PROJECT REPORT OF INTEGRATING GOOGLE DOCS WITH OPEN JOURNAL SYSTEM · 2011. 9. 22. · Abstract Open Journal Systems (OJS) is an open source journal management and publishing system

Chapter 3

Google Docs API and low layer

functions

My project should allow basic operations such as uploading a file into a Google Docs Account

and adding a user’s account into a document’s ACL. In the future, for fully functional

integration of OJS and Google Docs, operations such as removing a user from a document’s

ACL, downloading a file from Google Docs server and retrieving a specific revision of a

document are to be developed. Google Docs provides basic data API interactions using raw

XML/HTTP1. Thus, a wide range of programming languages can be used to communicate

with Google Docs. For communicating with Google Docs API using PHP, an existing open

source library named Zend Google Data Client Library2 is available. The Zend Google

Data Client Library is available as part of the Zend Framework and also as a separate

download. To gather the operations, I created a class named GoogleDocsSettings in file

GoogleDocsSettings.inc.php. In it there are three main functions that are authentication,

uploading files and adding users into ACL.

1Extensible Markup Language (XML) is a set of rules for encoding documents electronically. Hyper-text Transfer Protocol (HTTP) is an Application Layer protocol for distributed, collaborative, hypermediainformation systems.

2Zend Framework is focused on building more secure, reliable, and modern Web 2.0 applications and webservices, and consuming widely available APIs from leading vendors like Google, Amazon, Yahoo!, Flickr, aswell as API providers and cataloguers like StrikeIron and ProgrammableWeb.

10

Page 17: PROJECT REPORT OF INTEGRATING GOOGLE DOCS WITH OPEN JOURNAL SYSTEM · 2011. 9. 22. · Abstract Open Journal Systems (OJS) is an open source journal management and publishing system

CHAPTER 3. GOOGLE DOCS API AND LOW LAYER FUNCTIONS 11

3.1 Authentication

Google Docs uses Google Accounts for authentication. As in other systems, the purpose is

to identify a user for his/her services.

There are three different authentication mechanisms that can be used, namely AuthSub,

OAuth and ClientLogin[1]. AuthSub and OAuth are similar. They need to authenticate

their users to Google accounts. A web page is redirected to Google’s authentication page,

allowing a user to type in their user name and password. After authentication, the user

comes back to the original page. ClientLogin is used without going to Google’s authentica-

tion page. Instead, the user provides their user name and password to the application and

it is the application that deals with the authentication process with Google. In my project,

ClientLogin is chosen because it is easy to implement and the server needs to be able to

connect to Google docs with a server’s Google account.

The code to set up the authentication is shown in Listing 3.1.

f unc t i on getDocs ( ) {$docs =& Reg i s t ry : : get ( ’ docs ’ ) ;

i f ( $docs == n u l l ) {$ s i t eSe t t i ng sDao =& DAORegistry : : getDAO( ’

SiteSettingsDAO ’ ) ;

$gdocs account = $s i t eSe t t ingsDao−>g e t S e t t i n g ( ’

gdocsEmail ’ , ’ en US ’ ) ;

$gdocs password = $s i t eSe t t ingsDao−>g e t S e t t i n g ( ’

gdocsPassword ’ , ’ en US ’ ) ;

$ c l i e n t = getCl i entLog inHttpCl i ent ( $gdocs account ,

$gdocs password ) ;

$docs = new Zend Gdata Docs ( $ c l i e n t ) ;

Reg i s t ry : : s e t ( ’ docs ’ , $docs ) ;

}

re turn $docs ;

}

Listing 3.1: Authenticating the OJS administrative Google Docs account

Page 18: PROJECT REPORT OF INTEGRATING GOOGLE DOCS WITH OPEN JOURNAL SYSTEM · 2011. 9. 22. · Abstract Open Journal Systems (OJS) is an open source journal management and publishing system

CHAPTER 3. GOOGLE DOCS API AND LOW LAYER FUNCTIONS 12

3.2 Uploading a document

Documents are uploaded to the server via an HTTP POST3 optionally using MIME4 mul-

tipart encoding to combine the document contents. Zend Framework provides existing

functions for uploading a document.

Files may be uploaded to the Google Docs server using the uploadFile method in the

Zend Gdata Docs client object. The new title for the Google document and MIME type of

the file are sent to the server to facilitate conversion. In the example, the script accepts the

file (either uploaded to your own web server as a temporary file, or a local file if the sample

is run on the command line), uses the file’s original name to determine the MIME type of

the file data, and sets the Google document title to the file name. This file is then sent from

your machine to the Google Docs server. In uploadFile, the Docs object will look up the

MIME type of the file based on the file name if the MIME type is null.

However, during my testing of the library, the uploading function does not work. After

doing some research on the library, I found there was a tiny error in the code for Docs.php

that lead to the problem. After making the change as shown in Listing 3.25 , the function

uploadfile came back to work again.

−−− C:\ Users \ zoro \Desktop\ code compare\ZendGdata−1.10.3\ l i b r a r y \Zend/Gdata/Docs . php 2010−01−06 17 :39 :32 .000000000 −0800

+++ C:\ Users \ zoro \Desktop\ code compare\Zend/Gdata/Docs . php

2010−04−10 13 :55 :00 .914400000 −0700

@@ −242 ,7 +247 ,7 @@

// Set the mime type o f the data .

i f ($mimeType === n u l l ) {− $ f i l enamePart s = explode ( ’ . ’ , $ f i l e L o c a t i o n ) ;

3An HTTP POST is a type of HTTP request message. A POST is used when the requested action maychange data on the server, such as updating data in a database or storing an uploaded file.

4Multipurpose Internet Mail Extensions (MIME) is an Internet standard that extends the format ofe-mail to support: Text in character sets other than ASCII, Non-text attachments, Message bodies withmultiple parts and Header information in non-ASCII character sets. For more information, see http://en.

wikipedia.org/wiki/MIME.5The code difference is auto-generated by diffutil. diff is a file comparison utility that outputs the

differences between two files. It is typically used to show the changes between one version of a file and aformer version of the same file. For more information, see http://en.wikipedia.org/wiki/Diff.

Page 19: PROJECT REPORT OF INTEGRATING GOOGLE DOCS WITH OPEN JOURNAL SYSTEM · 2011. 9. 22. · Abstract Open Journal Systems (OJS) is an open source journal management and publishing system

CHAPTER 3. GOOGLE DOCS API AND LOW LAYER FUNCTIONS 13

+ $f i l enamePart s = explode ( ’ . ’ , $ t i t l e ) ;

$ f i l e E x t e n s i o n = end ( $ f i l enamePart s ) ;

$mimeType = s e l f : : lookupMimeType ( $ f i l e E x t e n s i o n ) ;

}

Listing 3.2: Correction to the Zend library

The function to upload a file is shown in Listing 3.3.

f unc t i on uploadFileToGdocs ( $fi leName , $ f i l e I d , $ a r t i c l e ) {$ a r t i c l e F i l e D a o =& DAORegistry : : getDAO( ’

ArticleFileDAO ’ ) ;

$a r t i c l eDao = & DAORegistry : : getDAO( ’ ArticleDAO ’ ) ;

$gdocs = new Gdocs ( ) ;

$docs = $gdocs−>getDocs ( ) ;

$ f i l eToUpload = $ FILES [ $f i leName ] [ ’name ’ ] ;

$ a r t i c l e F i l e = $a r t i c l eF i l eD a o−>g e t A r t i c l e F i l e (

$ f i l e I d ) ;

$ f i l e p a t h = $ a r t i c l e F i l e −>getF i l ePath ( ) ;

$newDocumentEntry = $docs−>up loadFi l e ( $ f i l e p a t h ,

$f i leToUpload ,

nu l l , Zend Gdata Docs : : DOCUMENTS LIST FEED URI) ;

$ r e s o u r s e I d = $newDocumentEntry−>getResourceId ( )−>getText ( ) ;

foreach ( $newDocumentEntry−>l ink as $ l i n k ) {i f ( $ l ink−>getRel ( ) === ’ a l t e r n a t e ’ ) {

$a l t e rna t eL ink = $l ink−>getHre f ( ) ;

}}

$ a r t i c l e F i l e −>setGdocsLink ( $a l t e rna t eL ink ) ;

$ a r t i c l e F i l e −>setGdocsId ( $ r e s o u r s e I d ) ;

Page 20: PROJECT REPORT OF INTEGRATING GOOGLE DOCS WITH OPEN JOURNAL SYSTEM · 2011. 9. 22. · Abstract Open Journal Systems (OJS) is an open source journal management and publishing system

CHAPTER 3. GOOGLE DOCS API AND LOW LAYER FUNCTIONS 14

$ a r t i c l e−>setGdocsLink ( $a l t e rna t eL ink ) ;

$ a r t i c l e−>setGdocsId ( $ r e s o u r s e I d ) ;

$ar t i c l eDao−>updateArt i c l e ( $ a r t i c l e ) ;

$ a r t i c l e F i l e Da o−>u p d a t e A r t i c l e F i l e ( $ a r t i c l e F i l e ) ;

r e turn $newDocumentEntry ;

}

Listing 3.3: Code to upload a file into a Google Docs account

3.3 Document accessibility (ACL manipulation)

The Zend Framework for Google Docs is based on Google Data API Protocol 1.0 . It is an

early version of the Google Data API and does not support features like document sharing

and revision tracking. The newest protocol is version 3.0. In this version, document and

folder sharing is controlled via the access control list feed. Access control lists (ACL) are

just basic lists that show who has access to a given resource. In the ACL feed, there are

three roles for a given document or folder: owner, writer and reader.

• owner - the owner of the document. As an owner you have the ability to modify the

ACL feed, delete the document, etc.

• writer - a collaborator, who can edit as well as read a document.

• reader - a viewer (equivalent to read-only access).

As per Google Docs’ Protocol guide 3.0, to add a user as writer into a document’s ACL,

one can simply issue a POST request. In the Zend framework, there are functions to put

the headers together and send requests to Google servers. To include this feature, I added

the functions in Listing 3.4.

pub l i c func t i on shareDocument ( $resource Id , $userEmail )

{

Page 21: PROJECT REPORT OF INTEGRATING GOOGLE DOCS WITH OPEN JOURNAL SYSTEM · 2011. 9. 22. · Abstract Open Journal Systems (OJS) is an open source journal management and publishing system

CHAPTER 3. GOOGLE DOCS API AND LOW LAYER FUNCTIONS 15

$data = ’<entry xmlns=”http ://www. w3 . org /2005/Atom” xmlns :

gAcl=\ ’ http :// schemas . goog l e . com/ a c l /2007\ ’>< category

scheme=\ ’ http :// schemas . goog l e . com/g/2005#kind \ ’ term=\ ’

http :// schemas . goog l e . com/ a c l /2007# acces sRule\’/><gAcl :

r o l e va lue =\ ’ w r i t e r \’/><gAcl : scope type =\ ’ u se r \ ’ va lue

=\ ’ ’ . $userEmail . ’\’/></entry> ’ ;

$u r i = s t r r e p l a c e ( ’ r e s o u r c e i d ’ , $ re source Id , s e l f : :

DOCUMENTS ACL FEED URI) ;

//TODO er ror hand l ing : in case o f an e rror occurred , do

er ror hand l ing

//one common case would be the user has a l r e a d y g o t t e n

ac ces s to t h a t document

t ry {$th i s−>post ( $data , $u r i ) ;

} catch ( Zend Gdata App HttpException $e ) {}}

f unc t i on grantAccess ( $ a r t i c l e , $user = n u l l ) {$docs = $th i s−>getDocs ( ) ;

i f ( $user == n u l l ) {$user = & Request : : getUser ( ) ;

}

$gdocsemai l = $user−>getGdocsemail ( ) ;

$ r e sour c e Id = $ a r t i c l e−>getGdocsId ( ) ;

$docs−>shareDocument ( $resource Id , $gdocsemai l ) ;

}

Listing 3.4: Code to share a document

Page 22: PROJECT REPORT OF INTEGRATING GOOGLE DOCS WITH OPEN JOURNAL SYSTEM · 2011. 9. 22. · Abstract Open Journal Systems (OJS) is an open source journal management and publishing system

Chapter 4

OJS technical layers

The programming language used for OJS is PHP, while MySQL1 database is employed to

store data. PHP combined with MySQL is a very popular solution to web programming

nowadays.

OJS is heavily structured for maintainability, flexibility and robustness. It is similar in

design to the Model-View-Controller (MVC)2 pattern. In a MVC structure, data storage

and representation, user interface presentation, and control are separated into different

layers. The major categories, roughly ordered from frontend to backend, specifically in the

OJS Technical Reference[4], are given below:

• Smarty3 templates, which are responsible for assembling HTML pages to

display to users;

• Page classes, which receive requests from users’ web browsers, delegate any

required processing to various other classes, and call up the appropriate

Smarty template to generate a response;

• Action classes, which are used by the Page classes to perform nontrivial

processing of user requests;

1MySQL is the world’s most popular open source database software, for more information, visit http:

//www.mysql.com/.2Model-View-Controller (MVC) is software architecture, currently considered as an architectural pattern

used in software engineering. The pattern isolates domain logic (the application logic for the user) frominput and presentation (GUI), permitting independent development, testing and maintenance of each.

3Smarty is a web template system written in PHP. Smarty is primarily promoted as a tool for separationof concerns, which is a common design strategy for certain kinds of applications. For more information, seehttp://en.wikipedia.org/wiki/Smarty.

16

Page 23: PROJECT REPORT OF INTEGRATING GOOGLE DOCS WITH OPEN JOURNAL SYSTEM · 2011. 9. 22. · Abstract Open Journal Systems (OJS) is an open source journal management and publishing system

CHAPTER 4. OJS TECHNICAL LAYERS 17

• Model classes, which implement PHP objects representing the system’s var-

ious entities, such as Users, Articles, and Journals;

• Data Access Objects (DAOs), which generally provide (amongst others) up-

date, create, and delete functions for their associated Model classes, are

responsible for all database interaction;

• Support classes, which provide core functionalities, miscellaneous common

classes and functions, etc.

The layout of the OJS model is shown in Figure 4.1 (Page 8, OJS technical reference[4]).

To integrate Google Docs support into OJS, I made changes throughout the layers in differ-

Figure 4.1: OJS technical layout

ent classes as well as user interfaces. The major changes are based on the tasks. Examples

Page 24: PROJECT REPORT OF INTEGRATING GOOGLE DOCS WITH OPEN JOURNAL SYSTEM · 2011. 9. 22. · Abstract Open Journal Systems (OJS) is an open source journal management and publishing system

CHAPTER 4. OJS TECHNICAL LAYERS 18

are adding properties to classes of articles, site settings and user profiles, methods of upload-

ing files, displaying the Google Docs link, and granting users access to an article document

they are enrolled in.

To illustrate the work I did, I will take adding a hyper link of an article file as an example.

4.1 Add a hyper link

Since the URL link to the document in Google Docs corresponding to an article is a property

of the article, I added a property named gdocsLink into the Article class, as shown in Listing

4.1. Also, to handle the database storage of an article, I added a column named gdocLink

in the database table articles which is used to store article data, as shown in Listing 4.2.

−−− C:\ o j s 2 .3.1−2/ c l a s s e s / a r t i c l e / A r t i c l e . i nc . php 2009−12−01

22 :38 :30 .000000000 −0800

+++ C:\ o j s m o d i f i e d / c l a s s e s / a r t i c l e / A r t i c l e . i nc . php 2010−04−02

14 :19 :45 .407200000 −0700

@@ −560 ,6 +560 ,30 @@

+

+ func t i on getGdocsLink ( ) {+ return $th i s−>getData ( ’ gdocsLink ’ ) ;

+ }+

+ /∗∗+ ∗ Set gdocs l i n k o f the f i l e .

+ ∗ @param $ f i leName s t r i n g

+ ∗/+ func t i on setGdocsLink ( $ l i n k ) {+ return $th i s−>setData ( ’ gdocsLink ’ , $ l i n k ) ;

+ }+

Listing 4.1: Add a property of Google Docs link

−−− C:\ o j s 2 .3.1−2/ c l a s s e s / a r t i c l e /ArticleDAO . inc . php 2009−07−22

20 :11 :42 .000000000 −0700

Page 25: PROJECT REPORT OF INTEGRATING GOOGLE DOCS WITH OPEN JOURNAL SYSTEM · 2011. 9. 22. · Abstract Open Journal Systems (OJS) is an open source journal management and publishing system

CHAPTER 4. OJS TECHNICAL LAYERS 19

+++ C:\ o j s m o d i f i e d / c l a s s e s / a r t i c l e /ArticleDAO . inc . php 2010−04−02

14 :23 :01 .182200000 −0700

@@ −138 ,6 +138 ,8 @@

+ $ a r t i c l e−>setGdocsLink ( $row [ ’ gdoc s l i nk ’ ] ) ;

Listing 4.2: Change in Database Access Object

Immediately after a file is uploaded into the Site administrator Google Docs account,

the gdocslink property of an article is set to be the hyper link to that document in Google

Docs. This is done by the code in List 4.3 in function uploadFileToGdocs.

−−− C:\ o j s 2 .3.1−2/ c l a s s e s / gdocs / GoogleDocsSett ings . i nc . php

1969−12−31 16 :00 :00 .000000000 −0800

+++ C:\ o j s m o d i f i e d / c l a s s e s / gdocs / GoogleDocsSett ings . inc . php

2010−04−03 21 :54 :10 .594600000 −0700

@@ −0,0 +1 ,69 @@

+ func t i on uploadFileToGdocs ( $fi leName , $ f i l e I d , $ a r t i c l e ) {.

.

+ $ a r t i c l e−>setGdocsLink ( $a l t e rna t eL ink ) ;

.

.

+ return $newDocumentEntry ;

+ }

Listing 4.3: Set the Google Docs link property

To display the link in the user interface, I added code into the smarty template file which

displays the file information. The code is shown in Listing 4.4.

<t r va l i gn=” top”>

<td width=”20%” c l a s s=” l a b e l ”>{ t r a n s l a t e key=” gdocs . l i n k ”

}</td>

<td width=”60%” c l a s s=” value ”><a h r e f=”{ $submiss ionFi l e−>getGdocsLink ( ) }” t a r g e t=” blank ”>{$submiss ionFi l e−>getGdocsLink ( ) | escape}</a></td>

Page 26: PROJECT REPORT OF INTEGRATING GOOGLE DOCS WITH OPEN JOURNAL SYSTEM · 2011. 9. 22. · Abstract Open Journal Systems (OJS) is an open source journal management and publishing system

CHAPTER 4. OJS TECHNICAL LAYERS 20

</tr>

Listing 4.4: Change in smarty template

Finally when the user uploads a file, the hyper link to the uploaded document in Google

Docs is shown as in Figure 4.2.

Figure 4.2: The Google Docs link shown in file information

Page 27: PROJECT REPORT OF INTEGRATING GOOGLE DOCS WITH OPEN JOURNAL SYSTEM · 2011. 9. 22. · Abstract Open Journal Systems (OJS) is an open source journal management and publishing system

Chapter 5

Conclusion

After finishing this project, I learned the whole structure of OJS. In this process, I learned

the popular web programming technique which is usually called LAMP (Linux1, Apache2,

MySQL, and PHP). Through research and coding with Google’s document service, I learned

the wide range of Google’s services such as calendar, photos and document. Not only can I

use them normally through Google’s website, but I also have a deep understanding of the

Google Data API to access these services programmatically. The last section of this chapter

explains the improvement and completion of the integration of OJS and Google Docs, which

can be achieved in the future.

5.1 LAMP

At the very beginning, I had a very frustrating time setting up my laptop. Unlike most

windows software, which has just a simple installation file like emphinstall.exe, PHP needs

a lot of manual configuration. I needed to install PHP, MySQL and Apache separately and

configure them one by one to get everything to work. All too often I went through Google’s

search pages for a solution to some problem that prevented me from getting OJS installed

on my local machine. Since the system I use is Windows and LAMP is usually used on

Linux, some problems were just hard to resolve. But finally I got all things working on my

1Linux is a generic term referring to Unix-like computer operating systems based on the Linux kernel.For more information, see http://en.wikipedia.org/wiki/Linux.

2The Apache HTTP Server, commonly referred to as Apache, is web server software notable for playinga key role in the initial growth of the World Wide Web. For more information, see http://en.wikipedia.

org/wiki/Apache_HTTP_Server.

21

Page 28: PROJECT REPORT OF INTEGRATING GOOGLE DOCS WITH OPEN JOURNAL SYSTEM · 2011. 9. 22. · Abstract Open Journal Systems (OJS) is an open source journal management and publishing system

CHAPTER 5. CONCLUSION 22

computer. I learned how to configure PHP using php.ini, how to get Apache settings to

include my PHP executable and getting the Eclipse compiler for PHP set up for debugging.

At the code level, I learned how to write a PHP program, especially the Object Oriented

principles behind PHP, and its basic grammar, design pattern and class structure. These

are similar to C++ but somewhat different. For instance it is loosely typed, which means a

variable does not need to be declared with a type. Another feature is that PHP generates

web contents dynamically and sends them to users’ browsers, and browsers translate the

HTTP-based contents into user-readable output.

5.2 Google Services

Other than the basic web searching feature, Google provides dozens of services that users

can use to enjoy internet surfing. All services for single users are free. Google’s online ap-

plications include Blogger, Calendar, Docs, Gmail, and Groups3. Among these applications

I dealt with Google Docs in this project and found it was convenient to use. Furthermore,

as a programmer, I can also use the entire range of Google services in my application. By

doing some research on the API, I believe that I can integrate Google’s services into my

future applications neatly.

5.3 Future improvement

To complete the integration of OJS and Google Docs, we need to include functions at a

low level in the Zend Framework, as well as in OJS. The required low layer functions are

removing a user from a document’s ACL, retrieving a specified document revision, and

downloading a document into the web site folder. At the OJS layer, we need to track an

article file. For example, when an editor modifies a document within Google Docs, it should

be possible to record the link to that revision of the document and download that revision

into local server.

3For the use of these services and more information, visit http://www.google.ca/options/.

Page 29: PROJECT REPORT OF INTEGRATING GOOGLE DOCS WITH OPEN JOURNAL SYSTEM · 2011. 9. 22. · Abstract Open Journal Systems (OJS) is an open source journal management and publishing system

Bibliography

[1] Google Docs API- Developer’s Guide.http://code.google.com/apis/documents/docs/3.0/developers guide protocol.html.

[2] OJS demonstration site. http://pkp.sfu.ca/ojs/demo/present/index.php.

[3] OJS in an Hour. http://pkp.sfu.ca/files/OJSinanHour.pdf.

[4] OJS technical reference. http://pkp.sfu.ca/ojs/OJSTechnicalReference.pdf.

[5] PKP main site. http://pkp.sfu.ca/.

[6] Wikipedia - Google Docs. http://en.wikipedia.org/wiki/Google Docs.

[7] Zend Framework documentation. http://framework.zend.com/docs/overview.

23