示例#1
0
 public static function model()
 {
     if (empty(self::$_instance)) {
         self::$_instance = new self();
     }
     return self::$_instance;
 }
示例#2
0
 private function getData()
 {
     $id = EnvUtil::getRequest("id");
     $aidString = base64_decode(rawurldecode($id));
     if (empty($aidString)) {
         $this->error(Ibos::lang("Parameters error", "error"), "", array("autoJump" => 0));
     }
     $salt = Ibos::app()->user->salt;
     $decodeString = StringUtil::authCode($aidString, "DECODE", $salt);
     $decodeArr = explode("|", $decodeString);
     $count = count($decodeArr);
     if ($count < 3) {
         $this->error(Ibos::lang("Data type invalid", "error"), "", array("autoJump" => 0));
     } else {
         $aid = $decodeArr[0];
         $tableId = $decodeArr[1];
         if (0 <= $tableId && $tableId < 10) {
             $attach = AttachmentN::model()->fetch($tableId, $aid);
         }
         $return = array("decodeArr" => $decodeArr, "attach" => array());
         if (!empty($attach)) {
             $return["attach"] = $attach;
         }
         return $return;
     }
 }
示例#3
0
 public function imguploadProcessor($item, $readOnly)
 {
     $imgWidth = $item["data-width"];
     $imgHeight = $item["data-height"];
     $value = $this->getValue($item);
     if ($value !== "") {
         $attach = AttachmentN::model()->fetch(sprintf("rid:%d", $this->run->runid), $value);
         $imgSrc = FileUtil::fileName(FileUtil::getAttachUrl() . "/" . $attach["attachment"]);
         $imgID = $value;
     } else {
         $imgSrc = "";
         $imgID = "";
     }
     $bg = Ibos::app()->assetManager->getAssetsUrl("workflow") . "/image/pic_upload.png";
     if ($readOnly) {
         $read = 1;
     } else {
         $read = 0;
     }
     $eleout = "\t\t\t\t<div data-item=\"imgupload\" data-width=\"{$imgWidth}\" data-height=\"{$imgHeight}\" data-id=\"{$item["itemid"]}\" data-bg=\"{$bg}\" data-read=\"{$read}\" data-src=\"{$imgSrc}\">\r\n\t\t\t\t\t<input type=\"hidden\" name=\"imgid_{$item["itemid"]}\" value=\"{$imgID}\" />\r\n\t\t\t\t</div>";
     return $eleout;
 }
示例#4
0
 protected function handleImgComponent(&$formData)
 {
     foreach ($GLOBALS["_FILES"] as $key => $value) {
         if (strtolower(substr($key, 0, 5)) == "data_") {
             $formData["{$key}"] = "";
             $old = $_POST["imgid_" . substr($key, 5)];
             if ($value["name"] != "") {
                 if (!empty($old)) {
                     AttachUtil::delAttach($old);
                 }
                 $upload = FileUtil::getUpload($_FILES[$key], "workflow");
                 $upload->save();
                 $attach = $upload->getAttach();
                 $attachment = "workflow/" . $attach["attachment"];
                 $imgData = array("dateline" => TIMESTAMP, "filename" => $attach["name"], "filesize" => $attach["size"], "isimage" => $attach["isimage"], "attachment" => $attachment, "uid" => $this->uid);
                 $aid = Attachment::model()->add(array("uid" => $this->uid, "rid" => $this->runid, "tableid" => AttachUtil::getTableId($this->runid)), true);
                 $imgData["aid"] = $aid;
                 $newAttach = AttachmentN::model()->add(sprintf("rid:%d", $this->runid), $imgData, true);
                 $formData["{$key}"] = $newAttach;
             } else {
                 $formData["{$key}"] = $old;
             }
         }
     }
 }
示例#5
0
 public static function getAttachData($aid, $filterUnused = true)
 {
     $attach = array();
     $aid = is_array($aid) ? $aid : explode(",", trim($aid, ","));
     $records = Attachment::model()->fetchAllByPk($aid, $filterUnused ? "tableid != 127" : "");
     foreach ($records as $record) {
         if (!empty($record)) {
             $data = AttachmentN::model()->fetch($record["tableid"], $record["aid"]);
             $data["tableid"] = $record["tableid"];
             $attach[$record["aid"]] = $data;
         }
     }
     return $attach;
 }
示例#6
0
 protected function parseMarcroAttach($runID, $attachmentID, $showImg = true)
 {
     $attachDir = Ibos::app()->setting->get("setting/attachdir");
     $attach = AttachmentN::model()->fetch("rid:" . $runID, $attachmentID);
     if ($attach["isimage"] && $showImg) {
         $imgAttr = FileUtil::imageSize($attachDir . $attach["attachment"]);
         $attachLink = "<img src=\"{$attachDir}" . $attach["attachment"] . "\" {$imgAttr['3']} alt=\"{$attach["filename"]}\">";
         return $attachLink;
     }
     if ($this->flow->isFixed() && (StringUtil::findIn($this->process->attachpriv, "4") || !$this->process->attachpriv)) {
         $down = 1;
     } else {
         $down = 0;
     }
     if ($down) {
         $attachstr = AttachUtil::getAttachStr($attachmentID);
         $url = Ibos::app()->urlManager->createUrl("main/attach/download", array("id" => $attachstr));
         $link = "<a target=\"_blank\" class=\"xi2\" href=\"{$url}\">{$attach["filename"]}</a>";
     } else {
         $link = "<a class=\"xi2\" href=\"#\">{$attach["filename"]}</a>";
     }
     $type = StringUtil::getFileExt($attach["attach"]);
     $path = AttachUtil::attachType($type);
     $attachLink = "<span><img src=\"{$path}\">{$link}</span>";
     return $attachLink;
 }