public function bind($context, $params)
 {
     $criteria = new Criteria();
     $criteria->add(QubitSlug::SLUG, $params['slug']);
     $criteria->addJoin(QubitSlug::OBJECT_ID, QubitObject::ID);
     $this->resource = QubitObject::get($criteria)->__get(0);
     if (@$params['throw404'] == false && !isset($this->resource)) {
         throw new sfError404Exception();
     }
     return parent::bind($context, $params);
 }
 public function delete($connection = null)
 {
     if ($this->deleted) {
         throw new PropelException('This object has already been deleted.');
     }
     $this->clear();
     $this->deleteFromNestedSet($connection);
     parent::delete($connection);
     return $this;
 }
 public function save($connection = null)
 {
     parent::save($connection);
     foreach ($this->accessionI18ns as $accessionI18n) {
         $accessionI18n->id = $this->id;
         $accessionI18n->save($connection);
     }
     return $this;
 }
 public function execute($request)
 {
     // Default items per page
     if (!isset($request->limit)) {
         $request->limit = sfConfig::get('app_hits_per_page');
     }
     $this->form = new sfForm();
     $this->resource = $this->getRoute()->resource;
     // Check that the object exists and that it is not the root
     if (!isset($this->resource) || !isset($this->resource->parent)) {
         $this->forward404();
     }
     // Check authorization
     if (!QubitAcl::check($this->resource, 'update')) {
         QubitAcl::forwardUnauthorized();
     }
     // "parent" form field
     $this->form->setValidator('parent', new sfValidatorString(array('required' => true)));
     $this->form->setWidget('parent', new sfWidgetFormInputHidden());
     // Root is default parent
     if ($this->resource instanceof QubitInformationObject) {
         $this->form->bind($request->getGetParameters() + array('parent' => $this->context->routing->generate(null, array(QubitInformationObject::getById(QubitInformationObject::ROOT_ID), 'module' => 'informationobject'))));
     } else {
         if ($this->resource instanceof QubitTerm) {
             $this->form->bind($request->getGetParameters() + array('parent' => $this->context->routing->generate(null, array(QubitTerm::getById(QubitTerm::ROOT_ID), 'module' => 'term'))));
         }
     }
     if ($request->isMethod('post')) {
         $this->form->bind($request->getPostParameters());
         if ($this->form->isValid()) {
             $params = $this->context->routing->parse(Qubit::pathInfo($this->form->parent->getValue()));
             // In term treeview, root node links (href) to taxonomy, but it represents the term root object
             if ($this->resource instanceof QubitTerm && QubitObject::getById($params['_sf_route']->resource->id) instanceof QubitTaxonomy) {
                 $this->resource->parentId = QubitTerm::ROOT_ID;
             } else {
                 $this->resource->parentId = $params['_sf_route']->resource->id;
             }
             $this->resource->save();
             if ($request->isXmlHttpRequest()) {
                 return $this->renderText('');
             } else {
                 if ($this->resource instanceof QubitInformationObject) {
                     $this->redirect(array($this->resource, 'module' => 'informationobject'));
                 } else {
                     if ($this->resource instanceof QubitTerm) {
                         $this->redirect(array($this->resource, 'module' => 'term'));
                     }
                 }
             }
         }
     }
     $params = $this->context->routing->parse(Qubit::pathInfo($this->form->parent->getValue()));
     $this->parent = QubitObject::getById($params['_sf_route']->resource->id);
     $query = QubitSearch::getInstance()->addTerm($this->parent->slug, 'parent');
     if (isset($request->query)) {
         $query = $request->query;
     }
     $this->pager = new QubitArrayPager();
     $this->pager->hits = QubitSearch::getInstance()->getEngine()->getIndex()->find($query);
     $this->pager->setMaxPerPage($request->limit);
     $this->pager->setPage($request->page);
     $ids = array();
     foreach ($this->pager->getResults() as $hit) {
         $ids[] = $hit->getDocument()->id;
     }
     $criteria = new Criteria();
     $criteria->add(QubitObject::ID, $ids, Criteria::IN);
     $this->results = QubitObject::get($criteria);
 }
 public function execute($request)
 {
     $this->baseObject = QubitObject::getById($request->id);
     // Check that object exists and that it is not the root
     if (!isset($this->baseObject) || !isset($this->baseObject->parent)) {
         $this->forward404();
     }
     $this->forward404Unless($this->request->format);
     // load the export config for this schema if it exists
     $exportConfig = sfConfig::get('sf_app_module_dir') . DIRECTORY_SEPARATOR . 'object' . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR . 'export' . DIRECTORY_SEPARATOR . $this->request->format . '.yml';
     if (file_exists($exportConfig)) {
         $this->schemaConfig = sfYaml::load($exportConfig);
     }
     // set the XML template to use for export
     if (!empty($this->schemaConfig['templateXML'])) {
         $this->setTemplate($this->schemaConfig['templateXML']);
     } else {
         $this->setTemplate($this->request->format);
     }
     $request->setRequestFormat('xml');
     if (!extension_loaded('xsl')) {
         return;
     }
     // Copied from sfExecutionFilter::executeView()
     $view = $this->getController()->getView($this->moduleName, $this->actionName, sfView::SUCCESS);
     $view->getAttributeHolder()->add($this->varHolder->getAll());
     // create a new DOM document to export
     $this->exportDOM = new DOMDocument('1,0', 'UTF-8');
     $this->exportDOM->encoding = 'UTF-8';
     $this->exportDOM->formatOutput = true;
     $this->exportDOM->preserveWhiteSpace = false;
     $this->exportDOM->loadXML($view->render());
     // if no XSLs are specified, use the default one
     if (empty($this->schemaConfig['processXSLT'])) {
         $this->schemaConfig = array('processXSLT' => array('export-postprocess.xsl'));
     } else {
         // little bit of fault-tolerance in case the filter has a string
         $this->schemaConfig['processXSLT'] = (array) $this->schemaConfig['processXSLT'];
         $this->schemaConfig['processXSLT'][] = 'export-postprocess.xsl';
     }
     // post-filter through XSLs in order
     foreach ($this->schemaConfig['processXSLT'] as $exportXSL) {
         $exportXSL = sfConfig::get('sf_data_dir') . DIRECTORY_SEPARATOR . 'xslt' . DIRECTORY_SEPARATOR . $exportXSL;
         if (file_exists($exportXSL)) {
             // instantiate an XSLT parser
             $xslDOM = new DOMDocument();
             $xslDOM->load($exportXSL);
             // Configure the transformer
             $xsltProc = new XSLTProcessor();
             $xsltProc->registerPHPFunctions();
             $xsltProc->importStyleSheet($xslDOM);
             // if we have a doctype declared, copy the values to preserve them in the XSL
             if (!empty($this->exportDOM->doctype)) {
                 $xsltProc->setParameter('', 'doctype', '!DOCTYPE ' . $this->exportDOM->doctype->name . ' PUBLIC "' . $this->exportDOM->doctype->publicId . '" "' . $this->exportDOM->doctype->systemId . '"');
             }
             $this->exportDOM->loadXML($xsltProc->transformToXML($this->exportDOM));
         }
     }
     // send final XML out to the browser
     return $this->renderText($this->exportDOM->saveXML());
 }
 public function save($connection = null)
 {
     parent::save($connection);
     foreach ($this->rightsI18ns as $rightsI18n) {
         $rightsI18n->id = $this->id;
         $rightsI18n->save($connection);
     }
     return $this;
 }
<?php

$app = 'qubit';
include dirname(__FILE__) . '/../../../bootstrap/functional.php';
class Browser extends sfBrowser
{
    public function files($files)
    {
        foreach ($files as $key => $path) {
            $error = UPLOAD_ERR_NO_FILE;
            $size = 0;
            if (is_readable($path)) {
                $error = UPLOAD_ERR_OK;
                $size = filesize($path);
            }
            $this->files[$key] = array('error' => $error, 'name' => basename($path), 'size' => $size, 'tmp_name' => $path, 'type' => '');
        }
        return $this;
    }
}
$browser = new QubitTestFunctional(new Browser());
$browser->disableSecurity();
$browser->files(array('file' => dirname(__FILE__) . '/../../../fixtures/ead.xml'))->post(';object/import')->with('request')->begin()->isParameter('module', 'object')->isParameter('action', 'import')->end()->click('View Information object')->with('request')->begin()->isParameter('module', 'sfIsadPlugin')->isParameter('action', 'index')->end();
$object = QubitObject::getById($browser->getRequest()->id);
$browser->test()->ok(isset($object->parent), 'Never create an information object without a parent');
$creators = $object->getCreators();
$browser->test()->ok(isset($creators[0]->parent), 'Never create an actor without a parent');
$object->delete();
$object->events[0]->delete();
$creators[0]->delete();
 public function __construct()
 {
     parent::__construct();
     $this->tables[] = Propel::getDatabaseMap(QubitObjectTermRelation::DATABASE_NAME)->getTable(QubitObjectTermRelation::TABLE_NAME);
 }
 public function save($connection = null)
 {
     parent::save($connection);
     foreach ($this->staticPageI18ns as $staticPageI18n) {
         $staticPageI18n->id = $this->id;
         $staticPageI18n->save($connection);
     }
     return $this;
 }