本文整理汇总了PHP中steam_factory::create_document方法的典型用法代码示例。如果您正苦于以下问题:PHP steam_factory::create_document方法的具体用法?PHP steam_factory::create_document怎么用?PHP steam_factory::create_document使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类steam_factory
的用法示例。
在下文中一共展示了steam_factory::create_document方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: processData
public function processData(\IRequestObject $requestObject)
{
$params = $requestObject->getParams();
$parentObjectId = $params["portletObjectId"];
$name = "Neue Meldung";
//check diffrent types of parameter
if (is_string($parentObjectId)) {
$portletObject = \steam_factory::get_object($GLOBALS["STEAM"]->get_id(), $parentObjectId);
} else {
$portletObject = $parentObjectId;
}
$pName = "Neue Meldung";
$pContent = "Bitte geben Sie hier den Meldungstext ein.";
$pMimeType = "text/plain";
$pEnvironment = $portletObject;
//default is FALSE
$pDescription = "";
$messageObject = \steam_factory::create_document($GLOBALS["STEAM"]->get_id(), $pName, $pContent, $pMimeType, $pEnvironment, $pDescription);
$messageObject->set_attribute("bid:doctype", "portlet:msg");
$messageObject->set_attribute("bid:portlet:msg:link_open", "checked");
$messageObject->set_attribute("bid:portlet:msg:link_url", "");
$messageObject->set_attribute("bid:portlet:msg:link_url_label", "");
$messageObject->set_attribute("bid:portlet:msg:picture_alignment", "left");
$messageObject->set_attribute("bid:portlet:msg:picture_width", "");
$this->addMessageIdToPortlet($portletObject, $messageObject);
}
示例2: create
public static function create($name, $portfolio)
{
$newComment = steam_factory::create_document($GLOBALS["STEAM"]->get_id(), $name, "", $pMimeType = "");
$newComment->move($portfolio->getRoom());
$newComment->set_attribute(PORTFOLIO_PREFIX . "TYPE", "COMMENT");
$newComment->set_attribute("OBJ_TYPE", PORTFOLIO_PREFIX . "COMMENT");
$newComment = new Comment($newComment);
return $newPortfolio;
}
示例3: ajaxResponse
public function ajaxResponse(\AjaxResponseObject $ajaxResponseObject)
{
$ajaxResponseObject->setStatus("ok");
$current_room = \steam_factory::get_object($GLOBALS["STEAM"]->get_id(), $this->id);
$portal = \steam_factory::create_document($GLOBALS["STEAM"]->get_id(), strip_tags($this->params["name"]), "", "text/html", $current_room);
$jswrapper = new \Widgets\JSWrapper();
$jswrapper->setJs(<<<END
\t\tcloseDialog();
\t\tsendRequest("LoadContent", {"id":"{$this->id}"}, "explorerWrapper", "updater", null, null, "explorer");
END
);
$ajaxResponseObject->addWidget($jswrapper);
return $ajaxResponseObject;
}
示例4: frameResponse
public function frameResponse(\FrameResponseObject $frameResponseObject)
{
if (!defined("FILE_PERSISTENCE") || !FILE_PERSISTENCE) {
$html = "FILE_PERSISTENCE must be <b>true</b>";
} else {
$html = "FILE_PERSISTENCE is enabled.<br>";
$html .= "FILE_PERSISTENCE_PATH is " . FILE_PERSISTENCE_PATH . ".<br><br>Create a new document in your home \"filePersistenceTest.txt\".";
$doc = \steam_factory::create_document($GLOBALS["STEAM"]->get_id(), "filePersistenceTest.txt", "I am a file on file system.", "text/plain");
$home = $GLOBALS["STEAM"]->get_current_steam_user()->get_workroom();
$doc->move($home);
}
$rawHtml = new \Widgets\RawHtml();
$rawHtml->setHtml($html);
$frameResponseObject->addWidget($rawHtml);
return $frameResponseObject;
}
示例5: frameResponse
public function frameResponse(\FrameResponseObject $frameResponseObject)
{
$mplme = \steam_factory::get_object($GLOBALS["STEAM"]->get_id(), $this->id);
$frameResponseObject->setTitle("Mplme");
if (isset($_REQUEST["xmlData"])) {
$xmlDoc = \steam_factory::get_object_by_name($GLOBALS["STEAM"]->get_id(), $mplme->get_path() . "/data.xml");
if ($xmlDoc === 0 || !$xmlDoc instanceof \steam_document) {
$xml = simplexml_load_string("<datasets></datasets>");
$xmlDoc = \steam_factory::create_document($GLOBALS["STEAM"]->get_id(), "data.xml", $xml->asXML(), "text/xml");
$xmlDoc->move($mplme);
} else {
$xmlRaw = $xmlDoc->get_content();
$xml = simplexml_load_string($xmlRaw);
}
$xmlRequest = simplexml_load_string($_REQUEST["xmlData"]);
$xmlRequestDom = new \domDocument();
$xmlRequestDom->loadXML($xmlRequest->asXML());
$xmlDom = new \domDocument();
$xmlDom->loadXML($xml->asXML());
$xmlDom->documentElement->appendChild($xmlDom->importNode($xmlRequestDom->documentElement, true));
if ($_FILES && is_array($_FILES)) {
foreach ($_FILES as $file) {
$content = file_get_contents($file["tmp_name"]);
$doc = \steam_factory::create_document($GLOBALS["STEAM"]->get_id(), $file["name"], $content, $file["type"]);
$doc->move($mplme);
}
}
$xmlDoc->set_content($xmlDom->saveXML());
//echo "<pre>" . htmlentities($xmlDom->saveXML()) . "</pre>";
echo "ok";
} else {
echo "nix";
}
die;
//echo "done";
//$frameResponseObject->addWidget(new \Widgets\Blank());
//return $frameResponseObject;
}
示例6: ajaxResponse
public function ajaxResponse(\AjaxResponseObject $ajaxResponseObject)
{
$currentUser = $GLOBALS["STEAM"]->get_current_steam_user();
$currentUserName = $currentUser->get_name();
$dialog = new \Widgets\Dialog();
$dialog->setTitle("Eintrag diskutieren");
$dialog->setDescription("...");
$dialog->setPositionX($this->params["mouseX"]);
$dialog->setPositionY($this->params["mouseY"]);
// get discussion thread between portfolio owner and current user or create empty thread
$threads = $this->entry->get_annotations();
$discussion = null;
foreach ($threads as $thread) {
if ($thread->get_name() === $currentUserName) {
$discussion = $thread;
}
}
if (!isset($discussion)) {
$discussion = \steam_factory::create_document($GLOBALS["STEAM"]->get_id(), $currentUserName, "Discussing with " . $currentUserName . ".", "text/plain");
$this->entry->add_annotation($discussion);
}
$chat = new \Widgets\Chat();
$chat->setData($discussion);
$dialog->addWidget($chat);
$dialog->addWidget(new \Widgets\Clearer());
$rawHtml = new \Widgets\RawHtml();
$rawHtml->setHtml("<hr>");
$dialog->addWidget($rawHtml);
$textinput = new \Widgets\TextInput();
$textinput->setData($discussion);
$textinput->setContentProvider(\Widgets\DataProvider::annotationDataProvider());
$textinput->setLabel("Kommentar schreiben");
$dialog->addWidget($textinput);
$ajaxResponseObject->setStatus("ok");
$ajaxResponseObject->addWidget($dialog);
return $ajaxResponseObject;
}
示例7: file_get_contents
}
}
if (empty($problems)) {
$content = file_get_contents($_FILES["material"]["tmp_name"]);
/*
ob_start();
readfile( $_FILES["material"]["tmp_name"] );
$content = ob_get_contents();
ob_end_clean();
*/
if (defined("LOG_DEBUGLOG")) {
$time1 = microtime(TRUE);
logging::write_log(LOG_DEBUGLOG, "upload" . " \t" . $GLOBALS["STEAM"]->get_login_user_name() . " \t" . $_FILES["material"]["name"] . " \t" . filesize($_FILES["material"]["tmp_name"]) . " Bytes \t... ");
}
$filename = str_replace(array("\\", "'"), array("", ""), $_FILES["material"]["name"]);
$new_material = steam_factory::create_document($GLOBALS["STEAM"]->get_id(), $filename, $content, $_FILES["material"]["type"], FALSE);
if (defined("LOG_DEBUGLOG")) {
logging::append_log(LOG_DEBUGLOG, " \t" . round((microtime(TRUE) - $time1) * 1000) . " ms");
}
// Disabled for Testing issues
// upload($new_material->get_content_id(), $content);
if (isset($values["dsc"])) {
$new_material->set_attribute("OBJ_DESC", $values["dsc"]);
}
$new_material->move($env);
$_SESSION["confirmation"] = str_replace("%DOCUMENT", h($filename), gettext("'%DOCUMENT' has been uploaded."));
header("Location: " . $backlink);
exit;
} else {
$portal->set_problem_description($problems, $hints);
}
示例8: ajaxResponse
public function ajaxResponse(\AjaxResponseObject $ajaxResponseObject)
{
$ajaxResponseObject->setStatus("ok");
if (!isset($this->params["group"])) {
$rawWidget = new \Widgets\RawHtml();
$rawWidget->setHtml("Error: Kurs oder Gruppe auswählen");
$ajaxResponseObject->addWidget($rawWidget);
return $ajaxResponseObject;
}
if ($this->params["group"] == 1) {
// course
if (!isset($this->params["course"])) {
$rawWidget = new \Widgets\RawHtml();
$rawWidget->setHtml("Error: Kurs oder Gruppe auswählen");
$ajaxResponseObject->addWidget($rawWidget);
return $ajaxResponseObject;
}
$course = \steam_factory::get_object($GLOBALS["STEAM"]->get_id(), $this->params["course"]);
$subgroups = $course->get_subgroups();
foreach ($subgroups as $subgroup) {
if ($subgroup->get_name() == "staff") {
$admingroup = $subgroup;
} else {
if ($subgroup->get_name() == "learners") {
$basegroup = $subgroup;
}
}
}
} else {
// group
if (!isset($this->params["basegroup"]) || !isset($this->params["admingroup"])) {
$rawWidget = new \Widgets\RawHtml();
$rawWidget->setHtml("Error: Kurs oder Gruppe auswählen");
$ajaxResponseObject->addWidget($rawWidget);
return $ajaxResponseObject;
}
$basegroup = \steam_factory::get_object($GLOBALS["STEAM"]->get_id(), $this->params["basegroup"]);
$admingroup = \steam_factory::get_object($GLOBALS["STEAM"]->get_id(), $this->params["admingroup"]);
}
$start = $this->params["startElements"];
$maxcol = intval(log($start, 2) + 1);
$pyramidRoom = \steam_factory::create_room($GLOBALS["STEAM"]->get_id(), $this->params["title"], $basegroup->get_workroom(), $this->params["title"]);
$pyramidRoom->set_sanction_all($admingroup);
$pyramidRoom->set_sanction_all($basegroup);
$pyramidRoom->set_attribute("OBJ_TYPE", "container_pyramiddiscussion");
$pyramidRoom->set_attribute("PYRAMIDDISCUSSION_ACTCOL", 0);
$pyramidRoom->set_attribute("PYRAMIDDISCUSSION_ADMINGROUP", $admingroup);
$pyramidRoom->set_attribute("PYRAMIDDISCUSSION_BASEGROUP", $basegroup);
$pyramidRoom->set_attribute("PYRAMIDDISCUSSION_DEADLINES", array());
$pyramidRoom->set_attribute("PYRAMIDDISCUSSION_EDITOR", $this->params["editor"]);
$pyramidRoom->set_attribute("PYRAMIDDISCUSSION_INITIALIZED", 1);
$pyramidRoom->set_attribute("PYRAMIDDISCUSSION_MAX", $start);
$pyramidRoom->set_attribute("PYRAMIDDISCUSSION_MAXCOL", $maxcol);
$pyramidRoom->set_attribute("PYRAMIDDISCUSSION_OVERRIDE_DEADLINES", 0);
$pyramidRoom->set_attribute("PYRAMIDDISCUSSION_USEDEADLINES", "no");
$pyramidRoom->set_attribute("PYRAMIDDISCUSSION_VERSION", "koala_3.0");
$participants = array();
$members = $basegroup->get_members();
$admins = $admingroup->get_members();
foreach ($admins as $admin) {
if (!$basegroup->is_member($admin) && $admin instanceof \steam_user) {
array_push($members, $admin);
}
}
foreach ($members as $member) {
if ($member instanceof \steam_user) {
$participants[$member->get_id()] = 0;
}
}
$pyramidRoom->set_attribute("PYRAMIDDISCUSSION_PARTICIPANT_MANAGEMENT", $participants);
$adminconfig = array();
foreach ($admins as $admin) {
if ($admin instanceof \steam_user) {
$options = array();
$options["show_adminoptions"] = "true";
$adminconfig[$admin->get_id()] = $options;
}
}
$pyramidRoom->set_attribute("PYRAMIDDISCUSSION_ADMINCONFIG", $adminconfig);
$pyramidGroup = \steam_factory::create_group($GLOBALS["STEAM"]->get_id(), "pyramid_" . $pyramidRoom->get_id(), $basegroup);
// create position documents and corresponding groups
$groups = array();
for ($count = 1; $count <= $maxcol; $count++) {
for ($count2 = 1; $count2 <= $start / pow(2, $count - 1); $count2++) {
$newGroup = \steam_factory::create_group($GLOBALS["STEAM"]->get_id(), "group_" . $count . "_" . $count2, $pyramidGroup);
$newGroup->set_insert_access($basegroup);
$newGroup->set_insert_access($admingroup);
$groups[$count . $count2] = $newGroup;
$newPosition = \steam_factory::create_document($GLOBALS["STEAM"]->get_id(), "Position_" . $count . "_" . $count2, "", $this->params["editor"], $pyramidRoom, "Position " . $count . "-" . $count2);
$newPosition->set_attribute("PYRAMIDDISCUSSION_COLUMN", $count);
$newPosition->set_attribute("PYRAMIDDISCUSSION_ROW", $count2);
$newPosition->set_attribute("PYRAMIDDISCUSSION_POS_READ_STATES", array());
$newPosition->set_attribute("PYRAMIDDISCUSSION_POS_TITLE", "");
$newPosition->set_attribute("PYRAMIDDISCUSSION_RELGROUP", $newGroup);
}
}
// generate group structure
for ($count = 2; $count <= $maxcol; $count++) {
for ($count2 = 1; $count2 <= $start / pow(2, $count - 1); $count2++) {
$groups[$count . $count2]->add_member($groups[$count - 1 . ($count2 * 2 - 1)]);
//.........这里部分代码省略.........
示例9: return
// }
if (!isset($msg)) {
$msg = steam_factory::get_object($steam, $message);
}
$action = "save return(portlets/msg/edit.php)";
//on file upload, upload picture to steam
if (isset($_FILES["picture"]["size"]) && $_FILES["picture"]["size"] > 0) {
//get temporary filename
$filename = $_FILES["picture"]["tmp_name"];
//get picture content
ob_start();
readfile($filename);
$data = ob_get_contents();
ob_end_clean();
//upload picture
$picture_id = steam_factory::create_document($steam, time() . $_FILES["picture"]["name"], $data, "", $portlet);
# $msg->upload($portlet, $data);
// Die folgende Attribtierung funktioniert seit der Umstellung auf PHP5 aus ungekl�rten
// Gr�nden nicht mehr: $picture_id hat hier keinen (vern�nftigen) Wert. Bei der Umstellung
// auf das neue API sollten die Attribute aber wieder gesetzt werden.
// $picture = new steam_object($picture_id);
// $steam->set_attribute($picture, "bid:doctype", "portlet:picture");
// $steam->set_attribute($picture, "OBJ_DESC", $_FILES["picture"]["name"]);
}
if ($_POST["headline"] != "") {
$msg->set_attribute("OBJ_NAME", norm_post("headline"));
} else {
$msg->set_attribute("OBJ_NAME", $language == "ge" ? "KEINE Überschrift gesetzt" : "NO headline set");
}
$msg->set_attribute("OBJ_DESC", norm_post("subheadline"));
$msg->set_attribute("bid:portlet:msg:picture_alignment", isset($_POST["picture_alignment"]) ? $_POST["picture_alignment"] : "left");
示例10: createSurvey
public function createSurvey($old = null)
{
if ($old == null) {
$survey_container = \steam_factory::create_container($GLOBALS["STEAM"]->get_id(), $this->name, $this->rapidfeedback, $this->name);
$results_container = \steam_factory::create_container($GLOBALS["STEAM"]->get_id(), "results", $survey_container, "container for results");
} else {
$survey_container = \steam_factory::get_object($GLOBALS["STEAM"]->get_id(), $old);
$results_container = \steam_factory::get_object_by_name($GLOBALS["STEAM"]->get_id(), $survey_container->get_path() . "/results");
}
$survey_container->set_attribute("RAPIDFEEDBACK_STATE", 0);
$survey_container->set_attribute("RAPIDFEEDBACK_RESULTS", 0);
$survey_container->set_attribute("RAPIDFEEDBACK_PARTICIPANTS", array());
if ($this->starttype == 0) {
$survey_container->set_attribute("RAPIDFEEDBACK_STARTTYPE", 0);
} else {
$begin = $this->begin;
$end = $this->end;
$begin = mktime(0, 0, 0, substr($begin, 3, 2), substr($begin, 0, 2), substr($begin, 6, 4));
$end = mktime(0, 0, 0, substr($end, 3, 2), substr($end, 0, 2), substr($end, 6, 4));
$times = array();
array_push($times, $end);
array_push($times, $begin);
$survey_container->set_attribute("RAPIDFEEDBACK_STARTTYPE", $times);
}
$survey_container->set_attribute("RAPIDFEEDBACK_QUESTIONS", count($this->questions));
$xml = new \SimpleXMLElement("<survey></survey>");
$xml->addChild("name", $this->name);
$xml->addChild("begintext", $this->begintext);
$xml->addChild("endtext", $this->endtext);
foreach ($this->questions as $question) {
$xml_question = $xml->addChild("question");
$question->saveXML($xml_question);
}
if ($old == null) {
$xml_document = \steam_factory::create_document($GLOBALS["STEAM"]->get_id(), "survey.xml", $xml->saveXML(), "text/xml", $survey_container);
} else {
$xml_document = \steam_factory::get_object_by_name($GLOBALS["STEAM"]->get_id(), $survey_container->get_path() . "/survey.xml");
$xml_document->set_content($xml->saveXML());
}
return $survey_container;
}
示例11: execute
public function execute(\FrameResponseObject $frameResponseObject)
{
//CODE FOR ALL COMMANDS OF THIS PAKAGE END
$user = \lms_steam::get_current_user();
// Disable caching
// TODO: Work on cache handling. An enabled cache leads to bugs
// if used with the wiki.
\CacheSettings::disable_caching();
if (!($wiki_container = \steam_factory::get_object($GLOBALS["STEAM"]->get_id(), $this->id))) {
include "bad_link.php";
exit;
}
if (!$wiki_container instanceof \steam_container) {
$wiki_doc = $wiki_container;
$wiki_container = $wiki_doc->get_environment();
if ($wiki_doc->get_attribute(DOC_MIME_TYPE) != "text/wiki") {
include "bad_link.php";
exit;
}
}
//CODE FOR ALL COMMANDS OF THIS PAKAGE END
defined("OBJ_ID") or define("OBJ_ID", $wiki_container->get_id());
$content = \Wiki::getInstance()->loadTemplate("wiki_edit.template.html");
//$content = new HTML_TEMPLATE_IT();
//$content->loadTemplateFile( PATH_TEMPLATES . "wiki_edit.template.html" );
$wiki_entries = $wiki_container->get_inventory(CLASS_DOCUMENT);
foreach ($wiki_entries as $wiki_entry) {
if ($wiki_entry->get_attribute(DOC_MIME_TYPE) === "text/wiki") {
$name = $wiki_entry->get_name();
$content->setCurrentBlock("BLOCK_WIKI_ENTRY_OPTION");
$content->setVariable("WIKI_ENTRY_OPTION", "<option value=\"{$name}\">{$name}</option>");
$content->parse("BLOCK_WIKI_ENTRY_OPTION");
}
}
$problems = "";
if (!isset($create)) {
$create = FALSE;
}
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$values = $_POST["values"];
if (get_magic_quotes_gpc()) {
if (!empty($values['title'])) {
$values['title'] = stripslashes($values['title']);
}
if (!empty($values['body'])) {
$values['body'] = stripslashes($values['body']);
}
}
if (empty($values["title"])) {
$problems = gettext("Please enter a subject for your message.");
}
if (empty($values["body"])) {
$problems .= empty($problems) ? gettext("Please enter your message.") : "<br>" . gettext("Please enter your message.");
}
if (strpos($values["title"], "/")) {
if (!isset($problems)) {
$problems = "";
}
$problems .= gettext("Please don't use the \"/\"-char in the subject of your post.");
}
if (empty($problems)) {
$wiki_content = str_replace("@", "@", $values["body"]);
if (!empty($values['save'])) {
if ($create) {
$wiki_doc = \steam_factory::create_document($GLOBALS["STEAM"]->get_id(), $values["title"] . ".wiki", $wiki_content, "text/wiki", $wiki_container, "");
} else {
// PRUEFEN, OB ALLES OK, DANN NEUE WERTE SPEICHERN
$wiki_doc->set_name($values['title'] . ".wiki");
$wiki_doc->set_content($wiki_content);
}
// Clean cache for wiki_entries
$cache = get_cache_function($wiki_container->get_id(), 600);
$cache->clean($wiki_container->get_id());
// clean rsscache
$rcache = get_cache_function("rss", 600);
$feedlink = PATH_URL . "services/feeds/wiki_public.php?id=" . $wiki_container->get_id();
$rcache->drop("lms_rss::get_items", $feedlink);
header("Location: " . PATH_URL . "wiki/editentry/" . $wiki_doc->get_id() . "/");
exit;
} else {
// PREVIEW
$content->setCurrentBlock("BLOCK_PREVIEW");
$content->setVariable("LABEL_PREVIEW_EDIT", gettext("Preview the description"));
$content->setVariable("PREVIEW_EDIT", get_formatted_output($values["desc"]));
$content->parse("BLOCK_PREVIEW");
$headline = gettext("Change it?");
$content->setVariable("TEXT_DSC", h($values["desc"]));
$content->setVariable("TITLE_COMMENT", h($values["title"]));
}
} else {
$frameResponseObject->setProblemDescription($problems);
//$portal->set_problem_description( $problems );
}
}
if (empty($values)) {
$wikicontent = "";
$wikiname = "";
if (!$create) {
$wikicontent = $wiki_doc->get_content();
$wikicontent = str_replace("@", "@", $wikicontent);
//.........这里部分代码省略.........
示例12: output
$koala_support_installed_version = "0.0";
$ask_text = "Install koala_support version ";
} else {
output("Found koala_support {$koala_support_installed_version}");
$ask_text = "Update koala_support to version ";
}
output(" (newest available version is {$koala_support_server_version}).\n");
if (strcmp($koala_support_installed_version, $koala_support_server_version) < 0) {
$ask_update = new ConfigEntry("update.koala_support", "YesNo", $ask_text . $koala_support_server_version . " ?", NULL, "yes");
if ($ask_update->ask() === "yes") {
$package_container = steam_factory::get_object_by_name($STEAM->get_id(), "/packages");
if (!is_object($package_container)) {
output("Could not find /packages on your open-sTeam server.\n");
exit(1);
}
$package = steam_factory::create_document($STEAM->get_id(), $koala_support_spm->get_name(), $koala_support_spm->get_content(), $koala_support_spm->get_attribute(DOC_MIME_TYPE), $package_container);
if (!is_object($package)) {
output("Could not upload " . $koala_support_spm->get_name() . " to your open-sTeam server.\n");
exit(1);
}
try {
if (!$STEAM->install_package($package)) {
throw new Exception("Installation failed.");
}
output("Installed koala_support {$koala_support_server_version} on your open-sTeam server.\n");
} catch (Exception $ex) {
output("Could not install koala_support {$koala_support_server_version}: " . $ex->getMessage() . "\n");
output($ex->getTraceAsString() . "\n");
}
$package->delete();
}
示例13: create_textdoc
/**
*function create_textdoc:
*
* @param $pSteamConnector
* @param $pName
* @param $pContent
* @param $pEnviroment
* @param $pDescription
*
* @return
*/
public static function create_textdoc($pSteamConnectorID, $pName, $pContent, $pEnvironment = FALSE, $pDescription = "")
{
if (!is_string($pSteamConnectorID)) {
throw new ParameterException("pSteamConnectorID", "string");
}
return steam_factory::create_document($pSteamConnectorID, $pName, $pContent, "text/plain", $pEnvironment, $pDescription);
}
示例14: handleUpload
/**
* Returns array('success'=>true) or array('error'=>'error message')
*/
function handleUpload($uploadDirectory, $replaceOldFile = FALSE)
{
if (!is_writable($uploadDirectory)) {
return array('error' => "Server error. Upload directory isn't writable.");
}
if (!$this->file) {
return array('error' => 'No files were uploaded.');
}
$size = $this->file->getSize();
if ($size == 0) {
return array('error' => 'File is empty');
}
if ($size > $this->sizeLimit) {
return array('error' => 'File is too large');
}
$pathinfo = pathinfo($this->file->getName());
$filename = $pathinfo['filename'];
//$filename = md5(uniqid());
$ext = $pathinfo['extension'];
if ($this->allowedExtensions && !in_array(strtolower($ext), $this->allowedExtensions)) {
$these = implode(', ', $this->allowedExtensions);
return array('error' => 'File has an invalid extension, it should be one of ' . $these . '.');
}
//create empty steam_document and check write access
$steam_document = \steam_factory::create_document($GLOBALS["STEAM"]->get_id(), $this->file->getName(), "", "", \steam_factory::get_object($GLOBALS["STEAM"]->get_id(), $this->envid));
if (!$replaceOldFile) {
/// don't overwrite previous files that were uploaded
while (file_exists($uploadDirectory . $filename . '.' . $ext)) {
$filename .= rand(10, 99);
}
}
if ($this->file->save($uploadDirectory . $filename . '.' . $ext)) {
$steam_document->set_content(file_get_contents($uploadDirectory . $filename . '.' . $ext));
unlink($uploadDirectory . $filename . '.' . $ext);
return array('success' => true, 'oid' => $steam_document->get_id());
} else {
return array('error' => 'Could not save uploaded file.' . 'The upload was cancelled, or server error encountered');
}
}
示例15: execute
public function execute(\FrameResponseObject $frameResponseObject)
{
//$portal = \lms_portal::get_instance();
//$portal->initialize( GUEST_NOT_ALLOWED );
//$portal->set_page_title( gettext( "Buddy Icon" ) );
$user = \lms_steam::get_current_user();
$confirmText = "";
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$problem = "";
$hint = "";
if (isset($_POST["action"]) && $_POST["action"] == "deleteicon") {
// need to set OBJ_ICON to "0" and then to icons module to avoid weird
// effects in icon handling (server side fix done but not testedyet)
$old_icon = $user->get_attribute("OBJ_ICON");
$user->set_acquire_attribute("OBJ_ICON", 0);
$user->set_attribute("OBJ_ICON", 0);
// set the default user icon by acquiring OBJ_ICON from icons module
$user->set_acquire_attribute("OBJ_ICON", $GLOBALS["STEAM"]->get_module("icons"));
// delete previous user icon object
if ($old_icon instanceof steam_document) {
if ($old_icon->get_path() != "/images/doctypes/user_unknown.jpg" && $old_icon->check_access_write($user)) {
$this->clean_iconcache($old_icon);
$old_icon->delete();
}
}
$confirmText = gettext("Your profile icon has been deleted.");
$this->clean_usericoncache($user);
} else {
// upload new icon
if (count($_FILES) == 0) {
$problem = gettext("No image specified.") . " ";
$hint = gettext("Please choose an image on your local disk to upload.") . " ";
}
if (strpos($_FILES["icon"]["type"], "image") === FALSE) {
$problem .= gettext("File is not an image.") . " ";
$hint .= gettext("The icon has to be an image file (JPG, GIF or PNG).");
}
if ((int) $_FILES["icon"]["size"] > 256000) {
$problem .= gettext("File is larger than 250 KByte.");
$hint .= gettext("It is only allowed to upload profile icons with file size smaller than 250 KByte.");
}
if (empty($problem)) {
$user->set_acquire_attribute("OBJ_ICON", 0);
$user->delete_value("OBJ_ICON");
$old_icon = $user->get_attribute("OBJ_ICON");
ob_start();
readfile($_FILES["icon"]["tmp_name"]);
$content = ob_get_contents();
ob_end_clean();
$filename = str_replace(array("\\", "'"), array("", ""), $_FILES["icon"]["name"]);
if ($old_icon instanceof steam_document && $old_icon->check_access_write($user)) {
$new_icon = $old_icon;
$new_icon->set_attribute("OBJ_NAME", $filename);
$new_icon->set_content($content);
$new_icon->set_attribute("DOC_MIME_TYPE", $_FILES["icon"]["type"]);
} else {
$new_icon = \steam_factory::create_document($GLOBALS["STEAM"]->get_id(), $filename, $content, $_FILES["icon"]["type"], FALSE);
$new_icon->set_attribute("OBJ_TYPE", "document_icon_usericon");
}
$user->set_attribute("OBJ_ICON", $new_icon);
$all_user = \steam_factory::groupname_to_object($GLOBALS["STEAM"]->get_id(), "sTeam");
$new_icon->set_read_access($all_user);
$GLOBALS["STEAM"]->buffer_flush();
// clean cache-related data
$this->clean_usericoncache($user);
$confirmText = gettext("Your profile icon has been changed.");
} else {
$frameResponseObject->setProblemDescription($problem);
}
}
}
$content = \Profile::getInstance()->loadTemplate("profile_icon.template.html");
//$content = new \HTML_TEMPLATE_IT();
//$content->loadTemplateFile( PATH_TEMPLATES . "profile_icon.template.html" );
//$content->setVariable( "INFO_TEXT", gettext( "Your buddy icon is what we use to represent you when you're in koaLA." ) );
if (PLATFORM_ID == "bid") {
$content->setVariable("INFO_TEXT", "Hier können Sie ein Benutzerbild hinterlegen. Dieses wird beispielsweise an Ihren Dokumenten und Forenbeiträgen zusammen mit Ihrem Namen angezeigt.");
} else {
$content->setVariable("INFO_TEXT", "Das Benutzerbild wird Sie in " . PLATFORM_NAME . " repräsentieren");
}
$content->setVariable("WINDOW_CONFIRM_TEXT", gettext("Are you sure you want to delete your current buddy icon?"));
$content->setVariable("LABEL_DELETE", gettext("DELETE"));
$user->delete_value("OBJ_ICON");
$icon = $user->get_attribute("OBJ_ICON");
if ($icon instanceof \steam_object) {
$icon_id = $icon->get_id();
// if user icon is acquired (= default icon) hide the delete button
if (is_object($user->get_acquire_attribute("OBJ_ICON"))) {
$content->setVariable("HIDE_BUTTON", "style='display:none;'");
}
} else {
$icon_id = 0;
$content->setVariable("HIDE_BUTTON", "style='display:none;'");
}
// use it in 140x185 standard thumb size to optimize sharing of icon cache data
$icon_link = $icon_id == 0 ? PATH_URL . "styles/standard/images/anonymous.jpg" : PATH_URL . "download/image/" . $icon_id . "/140/185";
$content->setVariable("USER_IMAGE", $icon_link);
$content->setVariable("LABEL_YOUR_BUDDY_ICON", gettext("This is your buddy icon at the moment."));
$content->setVariable("LABEL_REPLACE", gettext("Replace with an image"));
$content->setVariable("LABEL_UPLOAD_INFO", gettext("The uploaded file has to be an image file (JPG, GIF or PNG), should have the dimensions of 140 x 185 pixels and <b>may not be larger than 250 KByte</b>. "));
//.........这里部分代码省略.........