Changeset 80 for Dev/trunk


Ignore:
Timestamp:
08/09/11 14:48:35 (14 years ago)
Author:
basvannuland
Message:

Application save load from db should work. styles not part of save yet.
More work on session save load

Location:
Dev/trunk
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • Dev/trunk/applicationcreation.php

    r78 r80  
    11<?php
    22require 'classes/master.php';
     3
     4var_dump($_POST);
    35
    46if (is_null($_SESSION['username']))
     
    1618       
    1719    $applicationDBI = new ApplicationDatabaseInterface($id);
    18     $applicationDBI->setApplicationInfo($application);
     20    $applicationDBI->setApplicationInfo($_POST);
     21}
     22else if(isset($_POST['applicationTitle']))
     23{
     24    $title = $_POST['applicationTitle'];
     25    $description = $_POST['applicationDescription'];
     26    $application = new Application($title, $description);
     27       
     28    $applicationDBI = new ApplicationDatabaseInterface(null);
     29    $applicationDBI->setApplicationInfo($_POST);
    1930}
    2031
  • Dev/trunk/classes/ApplicationDatabaseInterface.php

    r78 r80  
    2828    public function setApplicationInfo($applicationInfo)
    2929    {
    30         $appTitle = $application['applicationTitle'];
    31         $appDescription = $application['applicationDescription'];
    32         $appStyle = $application['applicationStyle'];
     30        $appTitle = $applicationInfo['applicationTitle'];
     31        $appDescription = $applicationInfo['applicationDescription'];
     32        $appStyle = null;
    3333
    3434        $this->applicationRDFWriter->setApplicationInfo($appTitle, $appDescription, $appStyle);
     
    5656
    5757        $resultApplication = $this->applicationRDFReader->readAllApplications();
    58 
    59         for($aNumber = 0;$aNumber<=sizeof($resultApplication[0]);$aNumber++)
     58       
     59        for($aNumber = 0;$aNumber<sizeof($resultApplication[0]);$aNumber++)
    6060        {
    6161            $aID = substr($resultApplication[0][$aNumber]['?uid'],9,strlen($resultApplication[0][$aNumber]['?uid'])-11);
    62             $aTitle = substr($resultApplication[1][$aNumber]['?title'],9,strlen($resultApplication[0][$aNumber]['?title'])-11);
     62            $aTitle = substr($resultApplication[1][$aNumber]['?title'],9,strlen($resultApplication[1][$aNumber]['?title'])-11);
    6363            $applicationInfo[$aID] = $aTitle;
    6464        }               
  • Dev/trunk/classes/ApplicationRDFWriter.php

    r62 r80  
    1515
    1616        if(file_exists($this->fileName))
    17         $this->model->load($this->fileName);
     17            $this->model->load($this->fileName);
    1818    }   
    1919
    2020    public function saveApplications()
    2121    {   
    22         $this->model->saveAs($fileName,'rdf');
     22        $this->model->saveAs($this->fileName,'rdf');
    2323    }
    2424
  • Dev/trunk/classes/SessionDatabaseInterface.php

    r78 r80  
    6262       
    6363        foreach ($resultSession[1][1] as $surveyInfo)
    64          {
    65            
     64        {
     65             $surveyUID = substr($surveyInfo['?uid'],9,strlen($surveyInfo['?uid'])-11);
     66             $surveyIndex = substr($surveyInfo['?index'],9,strlen($surveyInfo['?index'])-11);
     67             $sessionInfo[$surveyIndex . 's'] = $surveyUID;
     68        }
     69        foreach ($resultSession[1][2] as $applicationInfo)
     70        {
     71             $applicationUID = substr($applicationInfo['?uid'],9,strlen($applicationInfo['?uid'])-11);
     72             $applicationIndex = substr($applicationInfo['?index'],9,strlen($applicationInfo['?index'])-11);
     73             $sessionInfo[$applicationIndex . 'a'] = $applicationUID;
     74        }
     75        foreach ($resultSession[1][3] as $dashboardInfo)
     76        {
     77             $dashboardUID = substr($dashboardInfo['?uid'],9,strlen($dashboardInfo['?uid'])-11);
     78             $dashboardIndex = substr($dashboardInfo['?index'],9,strlen($dashboardInfo['?index'])-11);
     79             $sessionInfo[$dashboardIndex . 's'] = $dashboardUID;
    6680        }
    6781    }
     
    6983    public function getExistingSessions()
    7084    {
    71        
     85        $sessionIDs = array();
     86        $sessions = array();
     87
     88        if($handle = opendir('data/sessions/'))
     89        {
     90            while (false !== ($file = readdir($handle))) {
     91                if(strstr($file, 'session_'))
     92                    $sessionIDs[] = substr($file,7,strlen($file)-11);
     93            }
     94        }
     95
     96        foreach($sessionIDs as $sessionID)
     97        {
     98            $sessionTitle = $this->sessionRDFReader->getSessionTitleByID($sessionID);
     99            $$sessions[$sessionID] = substr($sessionTitle[0]['?title'],9,strlen($sessionTitle[0]['?title'])-11);
     100        }
     101
     102        return $surveys;
    72103    }
    73104}
  • Dev/trunk/classes/SessionRDFReader.php

    r78 r80  
    112112        return $result;
    113113    }
     114   
     115    public function getSessionTitleByID($sessionID)
     116    {
     117        // Create empty MemModel
     118        $factory = new ModelFactory();
     119        $tempmodel= $factory->getDefaultModel();
     120        $tempmodel->load('data/sessions/session_'.$sessionID.'/session_'.$sessionID.'.rdf');
     121
     122        $querystring = '
     123            PREFIX  predicates: <' . SURVEYTOOL_PREDICATES_NAMESPACE . '>
     124            PREFIX  resources: <' . SURVEYTOOL_RESOURCES_NAMESPACE . '>
     125            SELECT  ?title
     126            WHERE       
     127            {
     128                    _session    predicates:resource_type        resources:session ;
     129                                predicates:title                ?title 
     130            }';
     131
     132        $result = $tempmodel->sparqlQuery($querystring);
     133
     134        return $result;
     135    }
    114136}
    115137
  • Dev/trunk/classes/SurveyDatabaseInterface.php

    r62 r80  
    120120        return $surveys;
    121121    }
     122   
     123    public function getSurveyTitleByID($surveyID)
     124    {
     125        $surveyTitleLiteral = $this->surveyRDFReader->getSurveyTitleByID($surveyID);
     126        $surveyTitle = substr($surveyTitle[0]['?title'],9,strlen($surveyTitle[0]['?title'])-11);
     127       
     128        return $surveyTitle;
     129    }
    122130
    123131}
  • Dev/trunk/survey.php

    r78 r80  
    22require 'classes/master.php';
    33
    4     var_dump($_POST);
     4    //var_dump($_POST);
    55   
    66if (is_null($_SESSION['username']))
     
    1616    $savedSurvey = Survey::getSurvey($info);
    1717   
    18     //var_dump($_POST);
     18    var_dump($_POST);
    1919}
    2020else
  • Dev/trunk/surveycreation.php

    r59 r80  
    1818}
    1919
    20 /* AUTOSAVE */ else if (isset($_POST['timeStamp'])) {
     20/* AUTOSAVE */
     21else if (isset($_POST['timeStamp'])) {
    2122    $timeStamp = $_POST['timeStamp'];
    2223
Note: See TracChangeset for help on using the changeset viewer.