Esempio n. 1
0
/**
 * Initializes a bootstrapped PartKeepr environment.
 * 
 * This is done within a function because we don't want to pollute the globals, which would give the following message
 * during unit tests:
 * 
 * "PDOException: You cannot serialize or unserialize PDO instances"
 */
function initializeEnvironment()
{
    PartKeepr::initialize("test");
    $tool = new \Doctrine\ORM\Tools\SchemaTool(PartKeepr::getEM());
    $classes = PartKeepr::getClassMetaData();
    $tool->dropDatabase();
    $tool->createSchema($classes);
    /* Some very basic installation things */
    PartCategoryManager::getInstance()->ensureRootExists();
    /* Create a blank admin user */
    $user = new User();
    $user->setUsername("admin");
    $user->setPassword("admin");
    $user->setAdmin(true);
    PartKeepr::getEM()->persist($user);
    /* Create a blank regular user */
    $user2 = new User();
    $user2->setUsername("regular");
    $user2->setPassword("regular");
    $user2->setAdmin(false);
    PartKeepr::getEM()->persist($user2);
    PartKeepr::getEM()->flush();
}
<?php

/**
 * This is a script which updates all category path caches to the configured path separator.
 * 
 * This script needs to be called after changing the partkeepr.category.path_separator.
 */
namespace PartKeepr\Scripts;

use PartKeepr\PartKeepr, PartKeepr\PartCategory\PartCategoryManager, PartKeepr\Util\Configuration, PartKeepr\FootprintCategory\FootprintCategoryManager;
include "../src/backend/PartKeepr/PartKeepr.php";
PartKeepr::initialize();
PartCategoryManager::getInstance()->updateCategoryPaths(PartCategoryManager::getInstance()->getRootNode());
FootprintCategoryManager::getInstance()->updateCategoryPaths(FootprintCategoryManager::getInstance()->getRootNode());
PartKeepr::getEM()->flush();
echo "All categories are updated for the configured category seperator of ";
echo Configuration::getOption("partkeepr.category.path_separator") . "\n";
Esempio n. 3
0
<?php

namespace PartKeepr\Frontend;

use PartKeepr\PartKeepr, PartKeepr\Util\Configuration;
include "../src/backend/PartKeepr/PartKeepr.php";
header("Content-Type: text/xml; charset=UTF-8");
PartKeepr::initialize("");
echo file_get_contents(Configuration::getOption("partkeepr.files.path") . "/feed.rss");