Esempio n. 1
0
 /**
  * Generate a new migration
  *
  * @param string path where the new migration will live
  * @param string name of the new migration
  */
 public static function generate($path, $name)
 {
     $version = strftime('%Y%m%d%H%M%S');
     $fileName = _path($path, "{$version}_{$name}.php");
     if (!file_put_contents($fileName, self::templatize($name))) {
         die("Unable to create migration\n\n");
     }
     exit;
 }
 public function up()
 {
     // reset db metadata cache
     QFrame_Db_Table::scanDb();
     QFrame_Db_Table::resetAll();
     $this->auth();
     $xml = file_get_contents(_path(PROJECT_PATH, 'xml', 'sig-4-0-questionnaire-definition.xml'));
     QuestionnaireModel::importXML($xml);
     InstanceModel::importXML($xml, 'Sample SIG Instance');
 }
Esempio n. 3
0
$core_path = _path(dirname(__FILE__), '..', 'core');
/*
 * Set up a bunch of path constants that the application will use to refer
 * to various application directories
 */
include _path(dirname(__FILE__), '..', 'core', 'paths.php');
/*
 * Deal with environment stuff including determining the current environment
 * and loading the configuration stuff for that environment
 */
include _path(CORE_PATH, 'env.php');
/*
 * Include file that contains pure configuration (used for testing)
 * as well as routing.  Also include the file that sets up database
 * "stuff".
 */
include _path(CORE_PATH, 'database.php');
/*
 * Set up any dynamic properties (properties that rely on current environment configuration)
 */
include _path($core_path, 'dynamic.php');
/*
 * Change the password
 */
$user = DbUserModel::findByUsername($username);
if ($user === NULL) {
    die("Username {$username} not found.\n\n");
}
$user->dbUserPW = $password;
$user->save();
print "Password changed.\n\n";
Esempio n. 4
0
function runTests($tree, $branches)
{
    $pid = pcntl_fork();
    if ($pid != 0) {
        pcntl_waitpid($pid, $status);
        $failures = file_get_contents(PROJECT_PATH . '/tmp/.autotest');
        return intval($failures);
    }
    /*
     * Prepare the database...
     */
    require _path(CORE_PATH, 'database.php');
    $db = Zend_Db_Table_Abstract::getDefaultAdapter();
    foreach (QFrame_Db_Table::getTables() as $table) {
        $db->getConnection()->exec("TRUNCATE TABLE {$table}");
    }
    if (is_array($branches)) {
        $tests = array();
        $suite_name = implode(' && ', $branches);
        foreach ($branches as $branch) {
            $tests = array_merge($tests, collectBranchTests($tree, $branch));
        }
        $tests = array_unique($tests);
        if (count($tests) <= 0) {
            return;
        }
    } elseif ($branches == 'all') {
        $suite_name = 'all';
        $tests = collectAllTests($tree);
    }
    $suite = new PHPUnit_Framework_TestSuite($suite_name);
    foreach ($tests as $test) {
        require_once TEST_PATH . '/unit/' . $test;
        $class_name = preg_replace('/\\.php$/', '', $test);
        $suite_name = preg_replace('/^' . preg_quote(PROJECT_PATH . '/', '/') . '|\\.php$/', '', 'IGNORE');
        $suite->addTestSuite(new PHPUnit_Framework_TestSuite('Test_Unit_' . $class_name, $suite_name));
    }
    $result = new PHPUnit_Framework_TestResult();
    $result->addListener(new QFrame_Test_Listener());
    $suite->run($result);
    file_put_contents(PROJECT_PATH . '/tmp/.autotest', count($result->failures()));
    exit;
}
Esempio n. 5
0
 *
 * @copyright  Copyright (c) 2007 Collaborative Software Initiative (CSI)
 * @license    http://www.gnu.org/licenses/   GNU General Public License v3
 */
// Uncomment this to see phpinfo() for the running server
//phpinfo(); exit;
/*
 * Load the core of the QFrame application
 */
include dirname(__FILE__) . DIRECTORY_SEPARATOR . 'load.php';
/*
 * Require file that contains pure configuration (used for testing)
 * as well as routing.  Also include the file that sets up database
 * "stuff".
 */
require _path($core_path, 'database.php');
/*
 * If in maintenance mode, tell the user and exit.
 */
$maintenanceConfig = QFrame_Maintenance::instance();
if ($maintenanceConfig->isMaintenanceModeOn() === true) {
    die("{$maintenanceConfig->comment}");
}
/*
 * Get the front controller instance for the rest of the script to use and give it a controller
 * directory
 */
$front = Zend_Controller_Front::getInstance();
$front->setControllerDirectory(CONTROLLER_PATH);
/*
 * Register the logging and sanity checking plugins with the front controller
function asset($path)
{
    $source = DOCUMENT_ROOT . '/public/' . $path;
    return _path($path) . '?' . filemtime($source);
}
Esempio n. 7
0
 private function questionnaireDefinition2completedResponseSchema($dom)
 {
     $xsl = new DOMDocument();
     if (!$xsl->load(_path(PROJECT_PATH, 'xml', 'csi-qframe-questionnaire-definition-to-completed-response-schema-v1_0.xsl'))) {
         $errors = libxml_get_errors();
         try {
             $logger = Zend_Registry::get('logger');
         } catch (Zend_Exception $e) {
         }
         foreach ($errors as $error) {
             $message = rtrim("XSL XML error on line {$error->line} of {$error->file}: {$error->message}");
             if (isset($logger) && $logger) {
                 $logger->log($message, Zend_Log::ERR);
             }
             error_log($message);
         }
         if (count($errors) > 0) {
             throw new Exception('XSL XML Validation Exception');
         }
     }
     $proc = new XSLTProcessor();
     $proc->importStyleSheet($xsl);
     $result = $proc->transformToXML($dom);
     $files = new FileModel($this);
     $files->store($result, array('filename' => 'completed-response-schema.xsd'));
 }
Esempio n. 8
0
 /**
  * Apply an XSLT to the XML which returns XHTML
  */
 public function xml2html($pageHeaders = array())
 {
     $dom = new DOMDocument();
     $dom->loadXML($this->toXML(1, $pageHeaders));
     $errors = libxml_get_errors();
     try {
         $logger = Zend_Registry::get('logger');
     } catch (Zend_Exception $e) {
     }
     foreach ($errors as $error) {
         $message = rtrim("XML error on line {$error->line} of {$error->file}: {$error->message}");
         if (isset($logger) && $logger) {
             $logger->log($message, Zend_Log::ERR);
         }
         error_log($message);
     }
     if (count($errors) > 0) {
         throw new Exception('XML Exception');
     }
     $xsl = new DOMDocument();
     if (!$xsl->load(_path(PROJECT_PATH, 'xml', 'csi-qframe-instance-to-html-v1_0.xsl'))) {
         $errors = libxml_get_errors();
         try {
             $logger = Zend_Registry::get('logger');
         } catch (Zend_Exception $e) {
         }
         foreach ($errors as $error) {
             $message = rtrim("XSL XML error on line {$error->line} of {$error->file}: {$error->message}");
             if (isset($logger) && $logger) {
                 $logger->log($message, Zend_Log::ERR);
             }
             error_log($message);
         }
         if (count($errors) > 0) {
             throw new Exception('XSL XML Validation Exception');
         }
     }
     $proc = new XSLTProcessor();
     $proc->importStyleSheet($xsl);
     $result = $proc->transformToXML($dom);
     return $result;
 }
Esempio n. 9
0
 /**
  * Saves the properties as a yaml file
  */
 public function save()
 {
     $yaml = Spyc::YAMLDump($GLOBALS['qframe_maintenance'], 2, 0);
     $fullPath = _path(PROJECT_PATH, 'config', 'environments', QFRAME_ENV) . '_maintenance.yml';
     file_put_contents($fullPath, $yaml);
     if (!is_writable($fullPath)) {
         throw new Exception('Unable to write maintenance configuration file [' . $fullPath . ']');
     }
 }
Esempio n. 10
0
/*
 * Set up a bunch of path constants that the application will use to refer
 * to various application directories
 */
include _path(dirname(__FILE__), '..', 'core', 'paths.php');
/*
 * Deal with environment stuff including determining the current environment
 * and loading the configuration stuff for that environment
 */
include _path(CORE_PATH, 'env.php');
/*
 * Get database connection information for the current environment
 */
$profiles = Spyc::YAMLLoad(_path(CONFIG_PATH, 'database.yml'));
$options = array_merge(array('password' => null), $profiles[QFRAME_ENV]);
$backupFullPath = _path($backupDir, "{$options['dbname']}." . date("Ymd") . "." . date("His") . ".sql");
/*
 * Set up the base MySQL client command
 */
$command = "mysqldump --complete-insert --single-transaction " . "--result-file='{$backupFullPath}' " . "--host={$options['host']} ";
$user = isset($_SERVER['argv'][3]) ? $_SERVER['argv'][3] : $options['username'];
$password = isset($_SERVER['argv'][4]) ? $_SERVER['argv'][4] : $options['password'];
$base = isset($_SERVER['argv'][5]) ? $_SERVER['argv'][5] : '';
$command .= "--user={$user} ";
$command .= "--password={$password} ";
if (isset($options['port'])) {
    $command .= "--port={$options['port']} ";
}
if (isset($options['unix_socket'])) {
    $command .= "--socket=" . $base . "/{$options['unix_socket']} ";
}
Esempio n. 11
0
<?php

/**
 * This file is part of the CSI QFrame.
 *
 * The CSI QFrame is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 3 of the License, or
 * (at your option) any later version.
 *
 * The CSI QFrame is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * @copyright  Copyright (c) 2007 Collaborative Software Initiative (CSI)
 * @license    http://www.gnu.org/licenses/   GNU General Public License v3
 */
/*
 * Get a reference to the configuration object
 */
$config = QFrame_Config::instance();
/*
 * Set any paths that depend on configuration options
 */
$data_path = preg_replace('/\\/|\\\\/', DIRECTORY_SEPARATOR, $config->data_path);
define('DATA_PATH', _path(PROJECT_PATH, $data_path));
Esempio n. 12
0
<div class="container">

	<h1><?php 
echo 'Welcome';
?>
</h1>

	<?php 
echo _url();
?>
<br>
	<?php 
echo url('home');
?>
<br>

	<?php 
echo _path();
?>
<br>
	<?php 
echo path('home');
?>
<br>


</div>

<?php 
require 'views/base.php';
Esempio n. 13
0
 * The CSI QFrame is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 3 of the License, or
 * (at your option) any later version.
 *
 * The CSI QFrame is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * @copyright  Copyright (c) 2007 Collaborative Software Initiative (CSI)
 * @license    http://www.gnu.org/licenses/   GNU General Public License v3
 */
/* 
 * Set up core paths and change directory to PROJECT_PATH
 */
define('PROJECT_PATH', realpath(_path(dirname(__FILE__), '..')));
define('CORE_PATH', _path(PROJECT_PATH, 'core'));
define('LOG_PATH', _path(PROJECT_PATH, 'log'));
define('TEST_PATH', _path(PROJECT_PATH, 'test'));
define('APPLICATION_PATH', _path(PROJECT_PATH, 'application'));
define('LIBRARY_PATH', _path(PROJECT_PATH, 'library'));
define('CONFIG_PATH', _path(PROJECT_PATH, 'config'));
define('CONTROLLER_PATH', _path(APPLICATION_PATH, 'controllers'));
/*
 * Set up an include path that includes important app-specific paths
 */
set_include_path('.' . PATH_SEPARATOR . LIBRARY_PATH . PATH_SEPARATOR . get_include_path());
Esempio n. 14
0
include implode(DIRECTORY_SEPARATOR, array(dirname(__FILE__), '..', 'core', 'utility.php'));
$core_path = _path(dirname(__FILE__), '..', 'core');
/*
 * Set up a bunch of path constants that the application will use to refer
 * to various application directories
 */
include _path(dirname(__FILE__), '..', 'core', 'paths.php');
/*
 * Deal with environment stuff including determining the current environment
 * and loading the configuration stuff for that environment
 */
include _path(CORE_PATH, 'env.php');
/*
 * Include file that contains pure configuration (used for testing)
 * as well as routing.  Also include the file that sets up database
 * "stuff".
 */
include _path(CORE_PATH, 'database.php');
/*
 * Set up any dynamic properties (properties that rely on current environment configuration)
 */
include _path($core_path, 'dynamic.php');
// perform mock authentication
$auth_adapter = new QFrame_Auth_Adapter('', '', true);
$auth = Zend_Auth::getInstance();
$auth->authenticate($auth_adapter);
$content = file_get_contents(_path(PROJECT_PATH, 'xml', 'sig-4-0-questionnaire-definition.xml'));
QuestionnaireModel::importXML($content);
$options['pageResponses']['all'] = 1;
// import all responses
InstanceModel::importXML($content, 'Acme Vendor', $options);
Esempio n. 15
0
} elseif (!preg_match('/^\\d+$/', $_SERVER['argv'][1])) {
    die("First argument to this script must be either 'new' or numeric.\n\n");
} else {
    $target = $_SERVER['argv'][1];
}
// print a message indicating that we are starting migration
echo "(starting migration)\n";
/*
 * Get all of the files in the db/migrations directory and run the ones
 * that need to be run
 */
$migrations = array();
$migrateUp = !isset($target) || Migration_Adapter::getAdapter()->getSchemaVersion() <= $target;
foreach (scandir($migrationPath) as $file) {
    if (preg_match('/\\.php$/', $file)) {
        include _path($migrationPath, $file);
        $className = preg_replace('/^\\d+_|\\.php$/', '', $file);
        if (!class_exists($className)) {
            die("Filename '{$file}' must contain the class '{$className}'\n\n");
        }
        if (preg_match('/^(\\d+)_/', $file, $matches)) {
            $migrations[$matches[1]] = $className;
        } else {
            die("Migration filenames must start with an integer [{$file}]\n\n");
        }
    }
}
// Set target to the maximum version if it is not already set
if (!isset($target)) {
    $target = max(array_keys($migrations));
}