Example #1
0
 /**
  * Get the node for a given path.
  *
  * @param string $path
  */
 public function getNodeByPath($path, $node = null)
 {
     if (!$this->getConnection()) {
         return null;
     }
     $bits = split('/', $path);
     if ($node == null) {
         $node = $this->spacesStore->getCompanyHome();
     }
     /* @var $node Node */
     foreach ($bits as $bit) {
         // Skip up until we have the parts after the company home
         if (empty($bit) || $bit == 'Company Home') {
             continue;
         }
         // Get the node for the current bit. If the current
         // "bit" doesn't exist, then
         $children = $node->getChildren();
         foreach ($children as $child) {
             $childNode = $child->getChild();
             if ($childNode->cm_name == $bit) {
                 $node = $childNode;
                 // Cheat and skip to the next 'bit' to scan
                 continue 2;
             }
         }
         $node = null;
         break;
     }
     return $node;
 }
Example #2
0
 function indexAction()
 {
     $session = Session::create("admin", "admin", "http://localhost:8080/alfresco/api");
     $spacesStore = new SpacesStore($session);
     $selected = $this->_getParam('id');
     $root = null;
     if (!$selected) {
         $root = $spacesStore->getCompanyHome();
     } else {
         $root = $this->getNode($session, $spacesStore, $selected);
     }
     /* @var $root Node */
     $children = $root->getChildren();
     if ($root->getPrimaryParent() != null) {
         echo '<a href="?id=' . $root->getPrimaryParent()->getId() . '">..</a><br/>';
     }
     foreach ($children as $childAssociation) {
         /* @var $childAssociation ChildAssociation */
         $child = $childAssociation->getChild();
         /* @var $child Node */
         echo '<a href="?id=' . $child->getId() . '">' . $childAssociation->getChild()->cm_name . "</a><br/>";
     }
 }
Example #3
0
 public function testContentCreationAndPopulation()
 {
     $session = $this->getSession();
     $store = new SpacesStore($session);
     $fileName = "2myDoc_" . time() . ".txt";
     $node = $store->getCompanyHome()->createChild("cm_content", "cm_contains", "cm_" . $fileName);
     $node->cm_name = $fileName;
     $node->updateContent("cm_content", "text/plain", "UTF-8", "testTESTtest");
     $session->save();
     $nodeId = $node->id;
     // Create a new session and get the same node back
     $ticket = $this->getRepository()->authenticate("admin", "admin");
     $session2 = $this->getRepository()->createSession($ticket);
     $store2 = new SpacesStore($session2);
     $node2 = $session2->getNode($store2, $nodeId);
     //echo "node: ".$node2->__toString()."<BR>";
     $contentData = $node2->cm_content;
     $this->assertNotNull($contentData);
     $this->assertEquals("text/plain", $contentData->mimetype);
     $this->assertEquals("UTF-8", $contentData->encoding);
     $this->assertEquals(12, $contentData->size);
     $this->assertEquals("testTESTtest", $contentData->content);
 }