コード例 #1
0
function getTools($dir = '.')
{
    $potentialTools = array();
    $contents = scandir($dir);
    foreach ($contents as $item) {
        if ($item === '.' or $item === '..') {
            continue;
        }
        if (is_dir($item)) {
            if ($item != 'Sample') {
                // don't show the 'Sample' tool
                $potentialTools[] = $item;
            }
        }
    }
    $tools = array();
    foreach ($potentialTools as $check) {
        if (FileExists($check . '/' . $check . '.php', false, false)) {
            // use name as the key and file location as value
            $tools[$check] = $check . '/' . $check . '.php';
        }
    }
    return $tools;
}
コード例 #2
0
ファイル: txs.php プロジェクト: x-clone/xsltforms
function Script($n)
{
    if ($n->hasChildNodes()) {
        $i = 0;
        while ($i < $n->childNodes->length) {
            $cur = $n->childNodes->item($i);
            if ($cur->nodeType == XML_DOCUMENT_NODE || $cur->nodeType == XML_ELEMENT_NODE) {
                $curname = $cur->nodeName;
                if (substr($curname, 0, 4) == "txs:") {
                    $xpath = new DOMXPath($n->ownerDocument);
                    $xpath->registerNameSpace("txs", "http://www.agencexml.com/txs");
                    $xpath->registerNameSpace("xsl", "http://www.w3.org/1999/XSL/Transform");
                    if ($cur->getAttribute("node") != '') {
                        if ($xpath->query($cur->getAttribute("node"), $cur)->length == 0) {
                            $curname = "dummy";
                        }
                    } else {
                        if ($xpath->query("ancestor::xsl:stylesheet", $cur)->length != 0 || $xpath->query("ancestor::txs:model", $cur)->length != 0) {
                            $curname = "dummy";
                        }
                    }
                }
                switch ($curname) {
                    case "txs:load":
                        Load($cur);
                        break;
                    case "txs:save":
                        Script($cur);
                        Save($cur);
                        break;
                    case "txs:transform":
                        Script($cur);
                        Transform($cur);
                        continue 2;
                    case "txs:httprequest":
                        Httprequest($cur);
                        break;
                    case "txs:call":
                        Call($cur);
                        continue 2;
                    case "txs:fileexists":
                        FileExists($cur);
                        break;
                    case "txs:folderexists":
                        FolderExists($cur);
                        break;
                    case "txs:from-model":
                        Script($cur);
                        FromModel($cur, $cur);
                        break;
                    case "txs:process":
                        Process($cur);
                        break;
                    default:
                        Script($cur);
                }
            }
            $i++;
        }
    }
}
コード例 #3
0
        }
    } else {
        $stimuliFiles[] = $_FILES->stim_files . '/' . $_SESSION['Condition']['Stimuli'];
    }
    foreach ($stimuliFiles as $fileName) {
        $temp = GetFromFile($fileName);
        foreach ($temp as $i => $row) {
            if ($i < 2) {
                continue;
            }
            // skip padding rows
            if (show($row['Cue']) !== $row['Cue']) {
                // show() detects a file extension like .png, and will use FileExists to check that it exists
                // but it will always return a string, for cases where you are showing regular text
                // using FileExists, we can see if a cue detected as an image by show() is a file that actually exists
                if (FileExists('../Experiment/' . $row['Cue']) === false) {
                    $errors['Count']++;
                    $errors['Details'][] = 'Image or audio file "../Experiment/' . $row['Cue'] . '" not found for row ' . $i . ' in Stimuli File "' . basename($fileName) . '".';
                }
            }
        }
    }
}
#### Check that we can find files for all trials in use (also finds custom scoring files)
$procedure = GetFromFile($_FILES->proc_files . '/' . $_SESSION['Condition']['Procedure']);
$trialTypes = array();
// we will make a list of all found trial types, and what level they will be used at
$notTrials = array('off' => true, 'no' => true, '' => true, 'n/a' => true);
foreach ($procedure as $i => $row) {
    // go through all rows of procedure
    if ($row === 0) {
コード例 #4
0
<?php

/*  Collector
    A program for running experiments on the web
    Copyright 2012-2015 Mikey Garcia & Nate Kornell
 */
####  good place to pull in values and/or compute things that'll be inserted into the HTML below
require 'initiateCollector.php';
$title = 'Experiment Instructions';
$_dataController = 'instructions';
require $_PATH->get('Header');
?>
<form name="Login" id="content" action="InstructionsRecord.php" method="post">
    <div class="alert alert-instructions">Please carefully read the instructions again.</div>
    <?php 
include FileExists($_PATH->get('Instructions'));
?>
    
	<input  name="RT"        id="RT"    type="hidden" value="0" />
	<input  name="Fails"     id="Fails" type="hidden" value="0" />
	<div class="precache">
    <?php 
### PRE-CACHES All cues and answers used in experiment ####
foreach ($_SESSION['Trials'] as $Trial) {
    echo show($Trial['Stimuli']['Cue']) . ' ';
    echo show($Trial['Stimuli']['Answer']) . ' ';
    echo '<br />';
}
?>
    </div>
</form>
コード例 #5
0
/**
 * Determine if the string refers to an audio or image file and generate tags.
 * @param string $string
 * @return string
 */
function show($string, $endOnly = true, $justSrc = false)
{
    global $_PATH;
    // navigate path to Experiment folder (unless linking to external file)
    if (!inString('www.', $string)) {
        $fileName = $_PATH->get('Common') . '/' . $string;
        if (FileExists($fileName)) {
            $fileName = FileExists($fileName);
        }
    } else {
        $fileName = $string;
    }
    if ($endOnly) {
        $searchString = substr($fileName, -5);
        // only check last 5 characters for file extensions
    } else {
        $searchString = $fileName;
    }
    // check extension to determine which tags to add
    if (strripos($searchString, '.jpg') !== false || strripos($searchString, '.jpeg') !== false || strripos($searchString, '.png') !== false || strripos($searchString, '.gif') !== false || strripos($searchString, '.bmp') !== false) {
        // add image tags
        if ($justSrc) {
            $string = $fileName;
        } else {
            $string = '<img src="' . $fileName . '">';
        }
    } elseif (strripos($searchString, '.mp3') || strripos($searchString, '.wav') || strripos($searchString, '.ogg')) {
        // audio tags
        if ($justSrc) {
            $string = $fileName;
        } else {
            $string = '<source src="' . $fileName . '"/>';
        }
    }
    return $string;
}
コード例 #6
0
ファイル: login.php プロジェクト: elenatheodora/Collector
        }
    } else {
        $stimuliFiles[] = $_PATH->get('Stimuli');
    }
    foreach ($stimuliFiles as $fileName) {
        $temp = GetFromFile($fileName);
        foreach ($temp as $i => $row) {
            if ($i < 2) {
                continue;
            }
            // skip padding rows
            if (show($row['Cue']) !== $row['Cue']) {
                // show() detects a file extension like .png, and will use FileExists to check that it exists
                // but it will always return a string, for cases where you are showing regular text
                // using FileExists, we can see if a cue detected as an image by show() is a file that actually exists
                if (FileExists($_PATH->get('Experiment') . '/' . $row['Cue']) === false) {
                    $errors['Count']++;
                    $errors['Details'][] = 'Image or audio file "' . $_PATH->get('Experiment') . '/' . $row['Cue'] . '" not found for row ' . $i . ' in Stimuli File "' . basename($fileName) . '".';
                }
            }
        }
    }
}
#### Check that we can find files for all trials in use (also finds custom scoring files)
$procedure = GetFromFile($_PATH->get('Procedure'));
$trialTypes = array();
// we will make a list of all found trial types, and what level they will be used at
$notTrials = array('off' => true, 'no' => true, '' => true, 'n/a' => true);
foreach ($procedure as $i => $row) {
    // go through all rows of procedure
    if ($row === 0) {