function cmis_download() { $cmis_object_id = $_GET['cmis_obj_id']; if ($cmis_object_id != '') { $client = new CMISService(get_option('cmis_repository_url'), get_option('cmis_username'), get_option('cmis_password')); $props = $client->getProperties($cmis_object_id); $file_name = $props->properties['cmis:name']; $file_size = $props->properties['cmis:contentStreamLength']; $mime_type = $props->properties['cmis:contentStreamMimeType']; header('Content-type: $mime_type'); header('Content-Disposition: attachment; filename="' . $file_name . '"'); header("Content-length: {$file_size}"); $content = $client->getContentStream($cmis_object_id); echo $content; } }
function do_cmis($folder, $tree, $keywords, $name) { // Initialize CMIS Client $repo_url = get_option('cmis_repository_url'); $repo_username = get_option('cmis_username'); $repo_password = get_option('cmis_password'); $client = new CMISService($repo_url, $repo_username, $repo_password); $query_conditions = array(); $error_message = 'Error. Unable to show documents.'; try { if ($folder) { $f = $client->getObjectByPath($folder); array_push($query_conditions, "IN_FOLDER('{$f->id}')"); } elseif ($tree) { $f = $client->getObjectByPath($tree); array_push($query_conditions, "IN_TREE(d,'{$f->id}')"); } if ($keywords) { array_push($query_conditions, "CONTAINS('{$keywords}')"); } if ($name) { array_push($query_conditions, "d.cmis:name LIKE '{$name}'"); } // Perform query if (sizeof($query_conditions)) { $query = "SELECT d.*, o.* FROM cmis:document AS d JOIN cm:titled AS o ON d.cmis:objectId = o.cmis:objectId WHERE " . join(" AND ", $query_conditions) . "ORDER BY d.cmis:name"; //$query = "SELECT * FROM cmis:document WHERE " . join(" AND ", $query_conditions); $objs = $client->query($query); return display_cmis_objects($objs); } } catch (CmisObjectNotFoundException $e) { $error_message = "No documents found."; } catch (CmisRuntimeException $e) { $error_message = "Error. Unexpected problem when retrieving documents."; } return "<div class=\"alert\">{$error_message}</div>"; }
function updateProperties($objectId, $properties = array(), $options = array()) { // Yes $varmap = $options; $varmap["id"] = $objectId; $objectName = $this->getTitle($objectId); $objectType = $this->getObjectType($objectId); $obj_url = $this->getLink($objectId, "edit"); $obj_url = CMISRepositoryWrapper::getOpUrl($obj_url, $options); static $entry_template; if (!isset($entry_template)) { $entry_template = CMISService::getEntryTemplate(); } if (is_array($properties)) { $hash_values = $properties; } else { $hash_values = array(); } $properties_xml = $this->processPropertyTemplates($objectType, $hash_values); if (is_array($options)) { $hash_values = $options; } else { $hash_values = array(); } $fixed_hash_values = array("PROPERTIES" => $properties_xml, "SUMMARY" => CMISService::getSummaryTemplate()); // merge the fixes hash values first so that the processing order is correct $hash_values = array_merge($fixed_hash_values, $hash_values); if (!isset($hash_values['title'])) { $hash_values['title'] = $objectName; } if (!isset($hash_values['summary'])) { $hash_values['summary'] = $objectName; } $put_value = CMISRepositoryWrapper::processTemplate($entry_template, $hash_values); $ret = $this->doPut($obj_url, $put_value, MIME_ATOM_XML_ENTRY); $obj = $this->extractObject($ret->body); $this->cacheEntryInfo($obj); return $obj; }
# See the License for the specific language governing permissions and # limitations under the License. # # Authors: # Richard McKnight # require_once ('cmis_repository_wrapper.php'); $repo_url = $_SERVER["argv"][1]; $repo_username = $_SERVER["argv"][2]; $repo_password = $_SERVER["argv"][3]; $repo_folder = $_SERVER["argv"][4]; $repo_new_folder = $_SERVER["argv"][5]; $repo_debug = $_SERVER["argv"][6]; $client = new CMISService($repo_url, $repo_username, $repo_password); if ($repo_debug) { print "Repository Information:\n===========================================\n"; print_r($client->workspace); print "\n===========================================\n\n"; } $myfolder = $client->getObjectByPath($repo_folder); if ($repo_debug) { print "Folder Object:\n===========================================\n"; print_r($myfolder); print "\n===========================================\n\n"; }
# distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # # Authors: # Richard McKnight # require_once ('cmis_repository_wrapper.php'); $repo_url = $_SERVER["argv"][1]; $repo_username = $_SERVER["argv"][2]; $repo_password = $_SERVER["argv"][3]; $repo_debug = $_SERVER["argv"][4]; $client = new CMISService($repo_url, $repo_username, $repo_password); if ($repo_debug) { print "Repository Information:\n===========================================\n"; print_r($client->workspace); print "\n===========================================\n\n"; } $objs = $client->query("select * from cmis:folder"); if ($repo_debug) { print "Returned Objects\n:\n===========================================\n"; print_r($objs); print "\n===========================================\n\n"; }
function updateProperties($objectId, $properties = array(), $options = array()) { // Yes $varmap = $options; $varmap["id"] = $objectId; $objectName = $this->getTitle($objectId); $objectType = $this->getObjectType($objectId); $obj_url = $this->getLink($objectId, "edit"); $obj_url = CMISRepositoryWrapper::getOpUrl($obj_url, $options); static $entry_template; if (!isset($entry_template)) { $entry_template = CMISService::getEntryTemplate(); } if (is_array($properties)) { $hash_values = $properties; } else { $hash_values = array(); } $properties_xml = $this->processPropertyTemplates($objectType, $hash_values); if (is_array($options)) { $hash_values = $options; } else { $hash_values = array(); } $hash_values["PROPERTIES"] = $properties_xml; $hash_values["SUMMARY"] = CMISService::getSummaryTemplate(); if (!isset($hash_values['title'])) { $hash_values['title'] = $objectName; } if (!isset($hash_values['summary'])) { $hash_values['summary'] = $objectName; } $put_value = CMISRepositoryWrapper::processTemplate($entry_template, $hash_values); // print $put_value; // RRM DEBUG $ret = $this->doPut($obj_url, $put_value, MIME_ATOM_XML_ENTRY); $obj = $this->extractObject($ret->body); $this->cacheObjectInfo($obj); return $obj; }
require_once ('cmis_repository_wrapper.php'); $repo_url = $_SERVER["argv"][1]; $repo_username = $_SERVER["argv"][2]; $repo_password = $_SERVER["argv"][3]; $repo_folder = $_SERVER["argv"][4]; $repo_new_folder = $_SERVER["argv"][5]; $repo_debug = $_SERVER["argv"][6]; if ($repo_username == "alf_ticket") { $client = new CMISService($repo_url, null, null, array ( $repo_username => $repo_password )); } else { $client = new CMISService($repo_url, $repo_username, $repo_password); } if ($repo_debug) { print "Repository Information:\n===========================================\n"; print_r($client->workspace); print "\n===========================================\n\n"; } $myfolder = $client->getObjectByPath($repo_folder); print_r($client->getLastRequest()); if ($repo_debug) { print "Folder Object:\n===========================================\n"; print_r($myfolder);
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # # Authors: # Richard McKnight # require_once ('cmis_repository_wrapper.php'); $repo_url = $_SERVER["argv"][1]; $repo_username = $_SERVER["argv"][2]; $repo_password = $_SERVER["argv"][3]; $repo_search_text = $_SERVER["argv"][4]; $repo_debug = $_SERVER["argv"][5]; $client = new CMISService($repo_url, $repo_username, $repo_password); if ($repo_debug) { print "Repository Information:\n===========================================\n"; print_r($client->workspace); print "\n===========================================\n\n"; } $query = sprintf("SELECT cmis:name,score() as rel from cmis:document WHERE CONTAINS('%s')", $repo_search_text); $objs = $client->query($query); if ($repo_debug) { print "Returned Objects\n:\n===========================================\n"; print_r($objs); print "\n===========================================\n\n";
/** * Checkin * @param String $objectId Object ID * @param mixed[] $options Options * @return Object The checked in object * @api CMIS-VersionServices * @since CMIS-1.0 */ function checkIn($objectId, $properties = array()) { /* * Tal vez la forma mas prolija de hacer esto es guardar en el checkout * la propiedad $obj->links['self'], y usarla despues aca. * El problema es que se necesita mantener un contexto * entre los 2 usos del api, y ademas se rompe la logica de construccion * de URLs que en ningun caso parte de una URL provista desde afuera... */ $myURL = $this->url . "/default/entry"; $qs = array("id" => $objectId, "major" => "true", "checkin" => "true"); $myURL = CMISRepositoryWrapper::getOpUrl($myURL, $qs); $objectName = $this->getTitle($objectId); $objectType = $this->getObjectType($objectId); static $entry_template; if (!isset($entry_template)) { $entry_template = CMISService::getEntryTemplate(); } if (is_array($properties)) { $hash_values = $properties; } else { $hash_values = array(); } $properties_xml = $this->processPropertyTemplates($objectType, $hash_values); $fixed_hash_values = array("PROPERTIES" => $properties_xml, "SUMMARY" => CMISService::getSummaryTemplate()); // merge the fixes hash values first so that the processing order is correct $hash_values = array_merge($fixed_hash_values, $hash_values); if (!isset($hash_values['title'])) { $hash_values['title'] = $objectName; } if (!isset($hash_values['summary'])) { $hash_values['summary'] = $objectName; } $put_value = CMISRepositoryWrapper::processTemplate($entry_template, $hash_values); $ret = $this->doPut($myURL, $put_value, MIME_ATOM_XML_ENTRY); }
function check_response($client) { if ($client->getLastRequest()->code > 299) { print "There was a problem with this request!\n"; exit (255); } } $repo_url = $_SERVER["argv"][1]; $repo_username = $_SERVER["argv"][2]; $repo_password = $_SERVER["argv"][3]; $repo_folder = $_SERVER["argv"][4]; $repo_new_folder = $_SERVER["argv"][5]; $client = new CMISService($repo_url, $repo_username, $repo_password); print "Connected\n"; $myfolder = $client->getObjectByPath($repo_folder); print "Got Folder\n"; check_response($client); if ($myfolder->properties['cmis:baseTypeId'] != "cmis:folder") { print "NOT A FOLDER!\n"; exit (255); } $my_new_folder = $client->createFolder($myfolder->id, $repo_new_folder); check_response($client); $obj_doc = $client->createDocument($my_new_folder->id, "TextFile.txt", array (), "THIS IS A NEW DOCUMENT", "text/plain"); check_response($client);
# See the License for the specific language governing permissions and # limitations under the License. # # Authors: # Richard McKnight # require_once ('cmis_repository_wrapper.php'); $repo_url = $_SERVER["argv"][1]; $repo_username = $_SERVER["argv"][2]; $repo_password = $_SERVER["argv"][3]; $repo_folder = $_SERVER["argv"][4]; $repo_new_file = $_SERVER["argv"][5]; $repo_debug = $_SERVER["argv"][6]; $client = new CMISService($repo_url, $repo_username, $repo_password); if ($repo_debug) { print "Repository Information:\n===========================================\n"; print_r($client->workspace); print "\n===========================================\n\n"; } $myfolder = $client->getObjectByPath($repo_folder); if ($repo_debug) { print "Folder Object:\n===========================================\n"; print_r($myfolder); print "\n===========================================\n\n"; }
/** * Front-end display of widget. * * @see WP_Widget::widget() * * @param array $args Widget arguments. * @param array $instance Saved values from database. */ public function widget($args, $instance) { extract($args); $title = apply_filters('widget_title', $instance['title']); echo $before_widget; if (!empty($title)) { echo $before_title . $title . $after_title; } //echo __( 'Hello, World!', 'text_domain' ); $showfolder = urlencode($instance['folderpath']); if (!empty($showfolder)) { $ret = ""; try { $client = new CMISService(get_option('cmis_repo_url'), get_option('cmis_user'), get_option('cmis_pass')); $folder = $client->getObjectByPath($showfolder); if ($folder) { if (empty($title)) { $title = $folder->properties["cmis:name"]; echo $before_title . $title . $after_title; } $objs = $client->getChildren($folder->id); $ret .= build_list($objs, $folder, FALSE); } else { $ret = "Folder not found: " . $showfolder; } } catch (Exception $e) { $ret = "Error retrieving documents: {$e}"; } echo $ret; } echo $after_widget; }
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # # Authors: # Richard McKnight # require_once ('cmis_repository_wrapper.php'); $repo_url = $_SERVER["argv"][1]; $repo_username = $_SERVER["argv"][2]; $repo_password = $_SERVER["argv"][3]; $repo_folder = $_SERVER["argv"][4]; $repo_debug = $_SERVER["argv"][5]; $client = new CMISService($repo_url, $repo_username, $repo_password); if ($repo_debug) { print "Repository Information:\n===========================================\n"; print_r($client->workspace); print "\n===========================================\n\n"; } $myfolder = $client->getObjectByPath($repo_folder); if ($repo_debug) { print "Folder Object:\n===========================================\n"; print_r($myfolder); print "\n===========================================\n\n"; }