OJS OCS OMP OHS

You are viewing the PKP Support Forum | PKP Home Wiki



Transportation settings - patch and new files

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

Moderators: jmacgreg, michael

Forum rules
Developer Resources:

Documentation: The OJS Technical Reference and the OJS API Reference are both available from the OJS Documentation page. While these are OJS-specific, the OCS codebase is similar enough to OJS they should be of help. There is also an [url=http://pkp.sfu.ca/ocs_documentation[/url]OCS Documentation[/url] page with some more general documentation that might also be of interest.

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 OCS Conference Support and Discussion subforum; if you have a technical support question, try the OCS Technical Support subforum.

Transportation settings - patch and new files

Postby spatialguru » Wed Feb 13, 2008 10:49 pm

As a learning exercise, I cloned the Accommodations settings from CVS version, and made an identical feature to store and present Transportation settings. For those who are interested I will paste the diff and the four new files I made (from copying accommodations ones).

I'd appreciate any feedback for doing this task better or easier and also to know if others might find it useful to be in the. It should be 99.9% pure copy of Accommodations code - with maybe 0.1 percent my own ideas :)
spatialguru
 
Posts: 112
Joined: Mon Jun 25, 2007 1:23 pm
Location: British Columbia, Canada

Transportation settings patch file

Postby spatialguru » Wed Feb 13, 2008 10:51 pm

Code: Select all
? classes/manager/form/TransportationSettingsForm.inc.php
? pages/manager/ManagerTransportationHandler.inc.php
? templates/manager/transportationSettings.tpl
? templates/schedConf/transportation.tpl
Index: locale/en_US/locale.xml
===================================================================
RCS file: /cvs/ocs2/locale/en_US/locale.xml,v
retrieving revision 1.185
diff -u -p -r1.185 locale.xml
--- locale/en_US/locale.xml   5 Feb 2008 00:41:08 -0000   1.185
+++ locale/en_US/locale.xml   14 Feb 2008 05:40:29 -0000
@@ -444,6 +444,7 @@
    <message key="schedConf.discussion">Discussion</message>
    <message key="schedConf.registration">Registration</message>
    <message key="schedConf.accommodation">Accommodation</message>
+        <message key="schedConf.transportation">Transportation</message>
    <message key="schedConf.supporters">Organizers and Partners</message>
    <message key="schedConf.timeline">Timeline</message>
    <message key="schedConf.schedule">Conference Schedule</message>
@@ -459,6 +460,7 @@
    <message key="schedConf.presentations.title">{$schedConfAbbrev} Presentations and Authors</message>
    <message key="schedConf.program.title">{$schedConfAbbrev} Program</message>
    <message key="schedConf.accommodation.title">{$schedConfAbbrev} Accommodation</message>
+        <message key="schedConf.transportation.title">{$schedConfAbbrev} Transportation</message>
    <message key="schedConf.trackPolicies.title">{$schedConfAbbrev} Track Policies</message>
 
    <!-- User self-registration form -->
@@ -926,6 +928,13 @@ Note that the OAI interface can be disab
    <message key="manager.accommodation.form.accommodationText">Accommodation Description</message>
    <message key="manager.accommodation.form.accommodationText.description">Enter text describing conference accommodations in the field below.</message>
 
+        <!-- Transportation settings -->
+        <message key="manager.transportation.form.description">Enter information about transportation logistics here. Several files including information like directions and forms may also be uploaded.</message>
+        <message key="manager.transportation.form.transportationFiles">Files</message>
+        <message key="manager.transportation.form.transportationFiles.description">Use this section to upload one or more files for registrants and potential registrants, such as maps, forms, etc.</message>
+        <message key="manager.transportation.form.transportationText">Transportation Description</message>
+        <message key="manager.transportation.form.transportationText.description">Enter text describing conference transportation issues in the field below.</message>
+
    <!-- Conference Management -->
    <message key="manager.conferenceSiteManagement">Conference Site Management</message>
    <message key="manager.websiteManagement">Website Management</message>
@@ -946,6 +955,7 @@ Note that the OAI interface can be disab
    <message key="manager.registration">Registrations</message>
    <message key="manager.registrationPolicies">Registration Policies</message>
    <message key="manager.accommodation">Accommodation</message>
+        <message key="manager.transportation">Transportation</message>
    <message key="manager.announcements">Announcements</message>
    <message key="manager.announcementTypes">Announcement Types</message>
 
Index: pages/manager/ManagerHandler.inc.php
===================================================================
RCS file: /cvs/ocs2/pages/manager/ManagerHandler.inc.php,v
retrieving revision 1.19
diff -u -p -r1.19 ManagerHandler.inc.php
--- pages/manager/ManagerHandler.inc.php   23 Jan 2008 19:34:21 -0000   1.19
+++ pages/manager/ManagerHandler.inc.php   14 Feb 2008 05:40:29 -0000
@@ -774,6 +774,21 @@ class ManagerHandler extends Handler {
    }
 
 
+        //
+        // Transportation
+        //
+       
+        function transportation() {
+                import('pages.manager.ManagerTransportationHandler');
+                ManagerTransportationHandler::transportation();
+        }       
+
+        function saveTransportationSettings() {
+                import('pages.manager.ManagerTransportationHandler');
+                ManagerTransportationHandler::saveTransportationSettings();
+        }
+
+
    //
    // Payment
    //
Index: pages/schedConf/SchedConfHandler.inc.php
===================================================================
RCS file: /cvs/ocs2/pages/schedConf/SchedConfHandler.inc.php,v
retrieving revision 1.31
diff -u -p -r1.31 SchedConfHandler.inc.php
--- pages/schedConf/SchedConfHandler.inc.php   31 Jan 2008 19:24:51 -0000   1.31
+++ pages/schedConf/SchedConfHandler.inc.php   14 Feb 2008 05:40:30 -0000
@@ -376,6 +376,26 @@ class SchedConfHandler extends Handler {
       $templateMgr->display('schedConf/accommodation.tpl');
    }
 
+        /**
+         * Display conference transportation page
+         */
+        function transportation() {
+                list($conference, $schedConf) = SchedConfHandler::validate(true, true);
+
+                $templateMgr = &TemplateManager::getManager();
+                $templateMgr->assign('pageHierarchy', array(
+                        array(Request::url(null, 'index', 'index'), $conference->getConferenceTitle(), true),
+                        array(Request::url(null, null, 'index'), $schedConf->getSchedConfTitle(), true)));
+                SchedConfHandler::setupSchedConfTemplate($conference,$schedConf);
+               
+                $templateMgr->assign('transportationDescription', $schedConf->getLocalizedSetting('transportationDescription'));
+                $templateMgr->assign('transportationFiles', $schedConf->getLocalizedSetting('transportationFiles'));
+
+                $templateMgr->assign('helpTopicId', 'schedConf.transportation');
+                $templateMgr->display('schedConf/transportation.tpl');
+        }
+       
+
    /**
     * Display the presentations
     */
Index: templates/manager/index.tpl
===================================================================
RCS file: /cvs/ocs2/templates/manager/index.tpl,v
retrieving revision 1.19
diff -u -p -r1.19 index.tpl
--- templates/manager/index.tpl   4 Feb 2008 23:19:53 -0000   1.19
+++ templates/manager/index.tpl   14 Feb 2008 05:40:30 -0000
@@ -45,7 +45,8 @@
       <li>&#187; <a href="{url schedConf=$schedConf->getPath() page="manager" op="registration" clearPageContext=1}">{translate key="manager.registration"}</a></li>
       <li>&#187; <a href="{url schedConf=$schedConf->getPath() page="manager" op="scheduler"}">{translate key="manager.scheduler"}</a></li>
       <li>&#187; <a href="{url schedConf=$schedConf->getPath() page="manager" op="paymentSettings"}">{translate key="manager.payment.paymentSettings"}</a></li>
-      <li>&#187; <a href="{url schedConf=$schedConf->getPath() page="manager" op="accommodation"}">{translate key="manager.accommodation"}</a></li>
+      <li>&#187; <a href="{url schedConf=$schedConf->getPath() page="manager" op="accommodation"}">{translate key="manager.accommodation"}</a> &ndash;
+                <a href="{url schedConf=$schedConf->getPath() page="manager" op="transportation"}">{translate key="manager.transportation"}</a></li>
       <li>&#187; <a href="{url schedConf=$schedConf->getPath() page="manager" op="people" clearPageContext=1}">{translate key="manager.roles"}</a></li>
       <li>
          <h4>{translate key="manager.roles"}</h4>
Index: templates/schedConf/index.tpl
===================================================================
RCS file: /cvs/ocs2/templates/schedConf/index.tpl,v
retrieving revision 1.21
diff -u -p -r1.21 index.tpl
--- templates/schedConf/index.tpl   30 Jan 2008 23:28:20 -0000   1.21
+++ templates/schedConf/index.tpl   14 Feb 2008 05:40:30 -0000
@@ -59,7 +59,8 @@
    {if $schedConfShowSchedule}<li>&#187; <a href="{url page="schedConf" op="schedule"}">{translate key="schedConf.schedule"}</a></li>{/if}
    <li>&#187; <a href="{url page="schedConf" op="presentations"}">{translate key="schedConf.presentations"}</a></li>
    {if $schedConfPaymentsEnabled}<li>&#187; <a href="{url page="schedConf" op="registration"}">{translate key="schedConf.registration"}</a></li>{/if}
-   <li>&#187; <a href="{url page="schedConf" op="accommodation"}">{translate key="schedConf.accommodation"}</a></li>
+   <li>&#187; <a href="{url page="schedConf" op="accommodation"}">{translate key="schedConf.accommodation"}</a> &ndash;
+   <a href="{url page="schedConf" op="transportation"}">{translate key="schedConf.transportation"}</a></li>
    <li>&#187; <a href="{url page="about" op="organizingTeam"}">{translate key="schedConf.supporters"}</a></li>
    {if $schedConfPostTimeline}<li>&#187; <a href="{url page="schedConf" op="timeline"}">{translate key="schedConf.timeline"}</a></li>{/if}
 </ul>
spatialguru
 
Posts: 112
Joined: Mon Jun 25, 2007 1:23 pm
Location: British Columbia, Canada

classes/manager/form/TransportationSettingsForm.inc.php

Postby spatialguru » Wed Feb 13, 2008 10:52 pm

Code: Select all
<?php

/**
 * @file TransportationSettingsForm.inc.php
 *
 * Copyright (c) 2000-2007 John Willinsky
 * Distributed under the GNU GPL v2. For full terms see the file docs/COPYING.
 *
 * @package manager.form
 * @class TransportationForm
 *
 * Form for modifying scheduled conference transportation settings.
 *
 * $Id: TransportationSettingsForm.inc.php,v 1.1 2007/11/17 01:56:15 asmecher Exp $
 */

import('form.Form');

class TransportationSettingsForm extends Form {

   /** @var array the setting names */
   var $settings;

   /**
    * Constructor.
    */
   function TransportationSettingsForm() {
      parent::Form('manager/transportationSettings.tpl');

      $this->addCheck(new FormValidatorPost($this));
   }

   /**
    * Display the form.
    */
   function display() {
      import('file.PublicFileManager');
      $schedConf =& Request::getSchedConf();

      $templateMgr = &TemplateManager::getManager();
      $site = &Request::getSite();
      $templateMgr->assign('helpTopicId','conference.managementPages.transportation');
      $templateMgr->assign('publicSchedConfFilesDir', Request::getBaseUrl() . '/' . PublicFileManager::getSchedConfFilesPath($schedConf->getSchedConfId()));
      $templateMgr->assign('transportationFiles', $schedConf->getSetting('transportationFiles', 'object', true));
      parent::display();
   }

   /**
    * Initialize form data from current settings.
    */
   function initData() {
      $schedConf = &Request::getSchedConf();
      $this->_data = array();
      $this->_data['transportationDescription'] = $schedConf->getSetting('transportationDescription', 'string', true);
   }

   /**
    * Assign form data to user-submitted data.
    */
   function readInputData() {
      $this->readUserVars(array('transportationDescription', 'transportationFileTitle'));
   }

   /**
    * Save modified settings.
    */
   function execute() {
      $schedConf = &Request::getSchedConf();
      $settingsDao = &DAORegistry::getDAO('SchedConfSettingsDAO');

      foreach ($this->_data as $name => $value) {
         $settingsDao->updateSetting(
            $schedConf->getSchedConfId(),
            $name,
            $value,
            $this->settings[$name],
            true // Localized
         );
      }
   }
}

?>
spatialguru
 
Posts: 112
Joined: Mon Jun 25, 2007 1:23 pm
Location: British Columbia, Canada

pages/manager/ManagerTransportationHandler.inc.php

Postby spatialguru » Wed Feb 13, 2008 10:53 pm

Code: Select all
<?php

/**
 * @file ManagerTransportationHandler.inc.php
 *
 * Copyright (c) 2000-2007 John Willinsky
 * Distributed under the GNU GPL v2. For full terms see the file docs/COPYING.
 *
 * @package pages.manager
 * @class ManagerTransportationHandler
 *
 * Handle requests for changing scheduled conference transportation settings.
 *
 * $Id: ManagerTransportationHandler.inc.php,v 1.1 2007/11/17 01:56:16 asmecher Exp $
 */

class ManagerTransportationHandler extends ManagerHandler {

   /**
    * Display form to edit transportation settings.
    */
   function transportation() {
      parent::validate();
      parent::setupTemplate(true);

      $schedConf =& Request::getSchedConf();
      if (!$schedConf) Request::redirect (null, null, 'index');

      import('manager.form.TransportationSettingsForm');

      $settingsForm = &new TransportationSettingsForm();
      if ($settingsForm->isLocaleResubmit()) {
         $settingsForm->readInputData();
      } else {
         $settingsForm->initData();
      }
      $settingsForm->display();
   }

   /**
    * Save changes to transportation settings.
    */
   function saveTransportationSettings() {
      parent::validate();
      parent::setupTemplate(true);

      $schedConf =& Request::getSchedConf();
      if (!$schedConf) Request::redirect (null, null, 'index');

      import('manager.form.TransportationSettingsForm');

      $settingsForm = &new TransportationSettingsForm();
      $settingsForm->readInputData();

      $editData = false;

      $transportationFiles =& $schedConf->getSetting('transportationFiles');
      if (Request::getUserVar('uploadTransportationFile')) {
         // Get a numeric key for this file.
         $thisFileKey = 0;
         if (isset($transportationFiles[$settingsForm->getFormLocale()])) foreach ($transportationFiles[$settingsForm->getFormLocale()] as $key => $junk) {
            $thisFileKey = $key + 1;
         }

         import('file.PublicFileManager');
         $fileManager =& new PublicFileManager();
         if ($fileManager->uploadedFileExists('transportationFile')) {
            $oldName = $fileManager->getUploadedFileName('transportationFile');
            $extension = $fileManager->getExtension($oldName);
            if (!$extension) break;
            $uploadName = 'transportation-' . $thisFileKey . '.' . $extension;
            if ($fileManager->uploadSchedConfFile($schedConf->getSchedConfId(), 'transportationFile', $uploadName)) {
               $value = array(
                  'name' => $oldName,
                  'uploadName' => $uploadName,
                  'dateUploaded' => Core::getCurrentDate(),
                  'title' => Request::getUserVar('transportationFileTitle')
               );
               $transportationFiles[$settingsForm->getFormLocale()][$thisFileKey] =& $value;
               $settingsForm->setData('transportationFiles', $transportationFiles);
               $settingsForm->setData('transportationFileTitle', '');
               $schedConf->updateSetting('transportationFiles', $transportationFiles, 'object', true);
            }
         }
         $editData = true;
      } else {
         $formLocale = $settingsForm->getFormLocale();
         $deleteKey = null;
         if (isset($transportationFiles[$formLocale])) {
            foreach ($transportationFiles[$formLocale] as $key => $junk) {
               if (Request::getUserVar("deleteTransportationFile-$formLocale-$key")) $deleteKey = $key;
            }
         }
         if ($deleteKey !== null) {
            import('file.PublicFileManager');
            $fileManager = &new PublicFileManager();
            if ($fileManager->removeSchedConfFile($schedConf->getSchedConfId(), $transportationFiles[$formLocale][$deleteKey]['uploadName'])) {
               unset($transportationFiles[$formLocale][$deleteKey]);
               $schedConf->updateSetting('transportationFiles', $transportationFiles, 'object', true);
            }
            $editData = true;
         }
      }

      if (!$editData && $settingsForm->validate()) {
         $settingsForm->execute();

         $templateMgr = &TemplateManager::getManager();
         $templateMgr->assign(array(
            'currentUrl' => Request::url(null, null, null, 'transportation'),
            'pageTitle' => 'schedConf.transportation',
            'message' => 'common.changesSaved',
            'backLink' => Request::url(null, null, Request::getRequestedPage()),
            'backLinkLabel' => 'manager.conferenceSiteManagement'
         ));
         $templateMgr->display('common/message.tpl');

      } else {
         $settingsForm->display();
      }
   }

}
?>
spatialguru
 
Posts: 112
Joined: Mon Jun 25, 2007 1:23 pm
Location: British Columbia, Canada

templates/manager/transportationSettings.tpl

Postby spatialguru » Wed Feb 13, 2008 11:53 pm

Code: Select all
{**
 * transportationSettings.tpl
 *
 * Copyright (c) 2000-2007 John Willinsky
 * Distributed under the GNU GPL v2. For full terms see the file docs/COPYING.
 *
 * Form to edit scheduled conference transportation settings.
 *
 * $Id: transportationSettings.tpl,v 1.2 2008/01/03 01:58:13 asmecher Exp $
 *}
{assign var="pageTitle" value="schedConf.transportation"}
{include file="common/header.tpl"}

{include file="common/formErrors.tpl"}

<form method="post" action="{url op="saveTransportationSettings"}" enctype="multipart/form-data">

<p>{translate key="manager.transportation.form.description"}</p>

<h4>{translate key="manager.transportation.form.transportationFiles"}</h4>
<p>{translate key="manager.transportation.form.transportationFiles.description"}</p>

<table class="data" width="100%">
{if count($formLocales) > 1}
   <tr valign="top">
      <td width="20%" class="label">{fieldLabel name="formLocale" key="form.formLanguage"}</td>
      <td width="80%" class="value">
         {url|assign:"setupFormUrl" op="schedConfSetup" path="1"}
         {form_language_chooser form="setupForm" url=$setupFormUrl}
         <span class="instruct">{translate key="form.formLanguage.description"}</span>
      </td>
   </tr>
{/if}

{foreach from=$transportationFiles[$formLocale] key=transportationFileKey item=transportationFile}
<tr valign="top">
   <td width="20%" class="label">{fieldLabel name="transportationFileTitle-$transportationFileKey" key="common.title" suppressId="true"}</td>
   <td width="80%" class="value">{$transportationFile.title|escape}</td>
</tr>
<tr valign="top">
   <td class="label">{fieldLabel name="transportationFile" key="common.file"}</td>
   <td class="value">
      {translate key="common.fileName"}: <a href="{$publicSchedConfFilesDir}/{$transportationFile.uploadName}" class="file">{$transportationFile.name|escape}</a> {$transportationFile.dateUploaded|date_format:$datetimeFormatShort} <input type="submit" name="deleteTransportationFile-{$formLocale|escape}-{$transportationFileKey|escape}" value="{translate key="common.delete"}" class="button" />
   </td>
</tr>
{/foreach}{* transportationFiles *}

<tr valign="top">
   <td width="20%" class="label">{fieldLabel name="transportationFileTitle" key="common.title"}</td>
   <td width="80%" class="value"><input type="text" id="transportationFileTitle" name="transportationFileTitle" value="{$transportationFileTitle|escape}" size="40" maxlength="120" class="textField" /></td>
</tr>
<tr valign="top">
   <td width="20%" class="label">{fieldLabel name="transportationFile" key="common.file"}</td>
   <td width="80%">
      <input type="file" name="transportationFile" class="uploadField" /> <input type="submit" name="uploadTransportationFile" value="{translate key="common.upload"}" class="button" />
   </td>
</tr>

</table>

<h4>{translate key="manager.transportation.form.transportationText"}</h4>
<p>{translate key="manager.transportation.form.transportationText.description"}</p>

<textarea name="transportationDescription[{$formLocale|escape}]" id="transportationDescription" rows="5" cols="60" class="textArea">{$transportationDescription[$formLocale]|escape}</textarea>

<div class="separator"></div>

<p><input type="submit" value="{translate key="common.save"}" class="button defaultButton" /> <input type="button" value="{translate key="common.cancel"}" class="button" onclick="document.location.href='{url page="manager"}'" /></p>

<p><span class="formRequired">{translate key="common.requiredField"}</span></p>

</form>

{include file="common/footer.tpl"}
spatialguru
 
Posts: 112
Joined: Mon Jun 25, 2007 1:23 pm
Location: British Columbia, Canada

templates/schedConf/transportation.tpl

Postby spatialguru » Wed Feb 13, 2008 11:55 pm

Code: Select all
{**
 * transportation.tpl
 *
 * Copyright (c) 2000-2007 John Willinsky
 * Distributed under the GNU GPL v2. For full terms see the file docs/COPYING.
 *
 * Scheduled conference transportation page.
 *
 * $Id: transportation.tpl,v 1.1 2007/11/17 01:56:16 asmecher Exp $
 *}
{translate|assign:"pageTitleTranslated" key="schedConf.transportation.title" schedConfAbbrev=$currentSchedConf->getSetting('abbrev')}{include file="common/header.tpl"}

<div>{$transportationDescription|nl2br}</div>

{if !empty($transportationFiles)}
   <div class="separator"></div>
{/if}

{foreach from=$transportationFiles item=transportationFile}
   <div>
      <a class="file" href="{$publicFilesDir}/{$transportationFile.uploadName}" target="_blank" alt="">{$transportationFile.title|escape}</a>
   </div>
{/foreach}

{include file="common/footer.tpl"}
spatialguru
 
Posts: 112
Joined: Mon Jun 25, 2007 1:23 pm
Location: British Columbia, Canada


Return to OCS Development

Who is online

Users browsing this forum: Bing [Bot] and 1 guest