Ejemplo n.º 1
0
 /**
  * Creates the database connection for the installation process.
  *
  * @access private
  * @return xPDO The xPDO instance to be used by the installation.
  */
 public function _connect($dsn, $user = '', $password = '', $prefix = '', array $options = array())
 {
     if (include_once MODX_CORE_PATH . 'xpdo/xpdo.class.php') {
         $this->xpdo = new xPDO($dsn, $user, $password, array_merge(array(xPDO::OPT_CACHE_PATH => MODX_CORE_PATH . 'cache/', xPDO::OPT_TABLE_PREFIX => $prefix, xPDO::OPT_SETUP => true), $options), array(PDO::ATTR_ERRMODE => PDO::ERRMODE_SILENT));
         $this->xpdo->setLogTarget(array('target' => 'FILE', 'options' => array('filename' => 'install.' . MODX_CONFIG_KEY . '.' . strftime('%Y%m%dT%H%M%S') . '.log')));
         $this->xpdo->setLogLevel(xPDO::LOG_LEVEL_ERROR);
         return $this->xpdo;
     } else {
         return $this->lexicon('xpdo_err_nf', array('path' => MODX_CORE_PATH . 'xpdo/xpdo.class.php'));
     }
 }
Ejemplo n.º 2
0
}
/* get properties */
$properties = array();
$f = dirname(__FILE__) . '/build.properties.php';
$included = false;
if (file_exists($f)) {
    $included = @(include $f);
}
if (!$included) {
    die('build.properties.php was not found. Please make sure you have created one using the template of build.properties.sample.php.');
}
unset($f, $included);
/* instantiate xpdo instance */
$xpdo = new xPDO(XPDO_DSN, XPDO_DB_USER, XPDO_DB_PASS, array(xPDO::OPT_TABLE_PREFIX => XPDO_TABLE_PREFIX, xPDO::OPT_CACHE_PATH => MODX_CORE_PATH . 'cache/'), array(PDO::ATTR_ERRMODE => PDO::ERRMODE_WARNING));
$cacheManager = $xpdo->getCacheManager();
$xpdo->setLogLevel(xPDO::LOG_LEVEL_INFO);
$xpdo->setLogTarget(XPDO_CLI_MODE ? 'ECHO' : 'HTML');
$xpdo->loadClass('transport.xPDOTransport', XPDO_CORE_PATH, true, true);
$packageDirectory = MODX_CORE_PATH . 'packages/';
$xpdo->log(xPDO::LOG_LEVEL_INFO, 'Beginning build script processes...');
flush();
/* remove pre-existing package files and directory */
if (file_exists($packageDirectory . 'core.transport.zip')) {
    @unlink($packageDirectory . 'core.transport.zip');
}
if (file_exists($packageDirectory . 'core') && is_dir($packageDirectory . 'core')) {
    $cacheManager->deleteTree($packageDirectory . 'core', array('deleteTop' => true, 'skipDirs' => false, 'extensions' => '*'));
}
if (!file_exists($packageDirectory . 'core') && !file_exists($packageDirectory . 'core.transport.zip')) {
    $xpdo->log(xPDO::LOG_LEVEL_INFO, 'Removed pre-existing core/ and core.transport.zip.');
    flush();
Ejemplo n.º 3
0
 /**
  * Create or grab a reference to a static xPDO/modX instance.
  *
  * The instances can be reused by multiple tests and test suites.
  *
  * @param string $class A fixture class to get an instance of.
  * @param string $name A unique identifier for the fixture.
  * @param boolean $new
  * @param array $options An array of configuration options for the fixture.
  * @return object|null An instance of the specified fixture class or null on failure.
  */
 public static function &getFixture($class, $name, $new = false, array $options = array())
 {
     if (!$new && array_key_exists($name, self::$fixtures) && self::$fixtures[$name] instanceof $class) {
         $fixture =& self::$fixtures[$name];
     } else {
         $properties = array();
         include_once dirname(dirname(dirname(__FILE__))) . '/core/model/modx/modx.class.php';
         include dirname(__FILE__) . '/properties.inc.php';
         self::$properties = $properties;
         if (array_key_exists('debug', self::$properties)) {
             self::$debug = (bool) self::$properties['debug'];
         }
         $fixture = null;
         $driver = self::$properties['xpdo_driver'];
         switch ($class) {
             case 'modX':
                 if (!defined('MODX_REQP')) {
                     define('MODX_REQP', false);
                 }
                 if (!defined('MODX_CONFIG_KEY')) {
                     define('MODX_CONFIG_KEY', array_key_exists('config_key', self::$properties) ? self::$properties['config_key'] : 'test');
                 }
                 $fixture = new modX(null, self::$properties["{$driver}_array_options"]);
                 if ($fixture instanceof modX) {
                     $logLevel = array_key_exists('logLevel', self::$properties) ? self::$properties['logLevel'] : modX::LOG_LEVEL_WARN;
                     $logTarget = array_key_exists('logTarget', self::$properties) ? self::$properties['logTarget'] : (XPDO_CLI_MODE ? 'ECHO' : 'HTML');
                     $fixture->setLogLevel($logLevel);
                     $fixture->setLogTarget($logTarget);
                     if (!empty(self::$debug)) {
                         $fixture->setDebug(self::$properties['debug']);
                     }
                     $fixture->initialize(self::$properties['context']);
                     $fixture->user = $fixture->newObject('modUser');
                     $fixture->user->set('id', $fixture->getOption('modx.test.user.id', null, 1));
                     $fixture->user->set('username', $fixture->getOption('modx.test.user.username', null, 'test'));
                     $fixture->getRequest();
                     $fixture->getParser();
                     $fixture->request->loadErrorHandler();
                 }
                 break;
             case 'xPDO':
                 $fixture = new xPDO(self::$properties["{$driver}_string_dsn_test"], self::$properties["{$driver}_string_username"], self::$properties["{$driver}_string_password"], self::$properties["{$driver}_array_options"], self::$properties["{$driver}_array_driverOptions"]);
                 if ($fixture instanceof xPDO) {
                     $logLevel = array_key_exists('logLevel', self::$properties) ? self::$properties['logLevel'] : xPDO::LOG_LEVEL_WARN;
                     $logTarget = array_key_exists('logTarget', self::$properties) ? self::$properties['logTarget'] : (XPDO_CLI_MODE ? 'ECHO' : 'HTML');
                     $fixture->setLogLevel($logLevel);
                     $fixture->setLogTarget($logTarget);
                     if (!empty(self::$debug)) {
                         $fixture->setDebug(self::$properties['debug']);
                     }
                 }
                 break;
             default:
                 $fixture = new $class($options);
                 break;
         }
         if ($fixture !== null && $fixture instanceof $class) {
             self::$fixtures[$name] = $fixture;
         } else {
             die("Error setting fixture {$name} of expected class {$class}.");
         }
     }
     return $fixture;
 }
Ejemplo n.º 4
0
 /**
  * Creates the database connection for the installation process.
  *
  * @access private
  * @return xPDO The xPDO instance to be used by the installation.
  */
 public function _connect($dsn, $user = '', $password = '', $prefix = '', array $options = array())
 {
     if (include_once MODX_CORE_PATH . 'xpdo/xpdo.class.php') {
         $xpdo = new xPDO($dsn, $user, $password, array_merge(array(xPDO::OPT_CACHE_PATH => MODX_CORE_PATH . 'cache/', xPDO::OPT_TABLE_PREFIX => $prefix, xPDO::OPT_LOADER_CLASSES => array('modAccessibleObject'), xPDO::OPT_SETUP => true), $options), array(PDO::ATTR_ERRMODE => PDO::ERRMODE_WARNING, PDO::ATTR_PERSISTENT => false, PDO::MYSQL_ATTR_USE_BUFFERED_QUERY => true));
         $xpdo->setLogTarget(array('target' => 'FILE', 'options' => array('filename' => 'install.' . MODX_CONFIG_KEY . '.' . strftime('%Y%m%dT%H%M%S') . '.log')));
         $xpdo->setLogLevel(xPDO::LOG_LEVEL_ERROR);
         return $xpdo;
     } else {
         return $this->lexicon('xpdo_err_nf', array('path' => MODX_CORE_PATH . 'xpdo/xpdo.class.php'));
     }
 }
Ejemplo n.º 5
0
    }
}
//Removing Terms
$terms = $modx->getCollection('Term',array('class_key'=>'Term'));
if($terms) {
    foreach ($terms as $page) {
        if ($page->remove() == false) {
           echo 'An error occurred while trying to remove Term ' . $page->get('pagetitle') . '<br>';
        } else {
             echo $page->get('pagetitle') . ' Term Deleted. <br>' ;
        }
    }
}
*/
// Re-create them
$xpdo->setLogLevel(xPDO::LOG_LEVEL_WARN);
print '<h3>Creating Tables...</h3>';
$manager->createObjectContainer('Survey');
$manager->createObjectContainer('Question');
$manager->createObjectContainer('Response');
$manager->createObjectContainer('Data');
print '<code>Done.</code>';
//$product_taxonomies = include $data_src_dir . 'transport.product_taxonomies.php';
$mtime = microtime();
$mtime = explode(" ", $mtime);
$mtime = $mtime[1] + $mtime[0];
$tend = $mtime;
$totalTime = $tend - $tstart;
$totalTime = sprintf("%2.4f s", $totalTime);
print_msg("<br/><br/><strong>Finished!</strong> Execution time: {$totalTime}<br/>");
print_msg("<br/>Check <code>{$class_dir}</code> for your newly generated class files!");