コード例 #1
0
ファイル: Objects.php プロジェクト: rosko/workapp
 public function getTemplateFields($params)
 {
     $id = $params["id"];
     $tpl = new Model_Template();
     $fields = $tpl->getTypeTemplate($id);
     echo $this->view->render("objects_fields", array("fields" => $fields));
 }
コード例 #2
0
ファイル: Removed.php プロジェクト: rosko/workapp
 public function index()
 {
     if ($this->registry["ui"]["admin"]) {
         $this->view->setTitle("Просмотр удалённых объектов");
         $this->view->setLeftContent($this->view->render("left_objects", array()));
         if (isset($this->args[1])) {
             if (isset($_GET["page"])) {
                 if (is_numeric($_GET["page"])) {
                     if (!$this->object->setPage($_GET["page"])) {
                         $this->__call("objects", "list");
                     }
                 }
             }
             $ai = new Model_Ai();
             $forms = $ai->getForms();
             $this->object->links = "objects/" . $this->args[0] . "/" . $this->args[1] . "/";
             $data = $this->object->getTrashObjects($this->args[1]);
             $template = new Model_Template();
             $arr_objs = array();
             $i = 0;
             foreach ($data as $part) {
                 $arr_objs[$i] = $this->object->getShortObject($part["id"]);
                 $arr_objs[$i]["ai"] = $ai->getAdvancedInfo($part["id"]);
                 $i++;
             }
             $fields = $template->getTypeTemplate($this->args[1]);
             $this->view->objects_subgroupstrash(array("objs" => $arr_objs, "forms" => $forms, "gid" => $this->args[1], "fields" => $fields));
             //Отобразим пейджер
             if (count($this->object->pager) != 0) {
                 $this->view->pager(array("pages" => $this->object->pager));
             }
         }
     }
     $this->view->showPage();
 }
コード例 #3
0
ファイル: Sub.php プロジェクト: rosko/workapp
 public function index()
 {
     $this->view->setTitle("Просмотр объектов");
     $this->view->setLeftContent($this->view->render("left_objects", array()));
     if (isset($this->args[1])) {
         if (isset($_GET["page"])) {
             if (is_numeric($_GET["page"])) {
                 if (!$this->object->setPage($_GET["page"])) {
                     $this->__call("objects", "list");
                 }
             }
         }
         $ai = new Model_Ai();
         $forms = $ai->getForms();
         $this->object->links = "objects/" . $this->args[0] . "/" . $this->args[1] . "/";
         $sort =& $_SESSION["sort"];
         if (isset($_GET["clear"])) {
             unset($sort["sort"]);
         }
         if (isset($_POST) and count($_POST) > 0) {
             $sort_flag = true;
             $sort = $_POST;
             $data = $this->object->getObjectsSearch($this->args[1], $_POST);
         } else {
             if ($sort["sort"] != "") {
                 $sort_flag = true;
                 $data = $this->object->getObjectsSearch($this->args[1], $sort);
             } else {
                 $sort_flag = false;
                 $data = $this->object->getObjects($this->args[1]);
             }
         }
         $template = new Model_Template();
         $arr_objs = array();
         $i = 0;
         foreach ($data as $part) {
             $arr_objs[$i] = $this->object->getShortObject($part["id"]);
             $arr_objs[$i]["ai"] = $ai->getAdvancedInfo($part["id"]);
             $i++;
         }
         if (isset($this->registry["module_mail"])) {
             $mail = true;
         } else {
             $mail = false;
         }
         $fields = $template->getTypeTemplate($this->args[1]);
         $this->view->objects_subgroups(array("objs" => $arr_objs, "mail" => $mail, "forms" => $forms, "gid" => $this->args[1], "fields" => $fields, "sort_flag" => $sort_flag));
         //Отобразим пейджер
         if (count($this->object->pager) != 0) {
             $this->view->pager(array("pages" => $this->object->pager));
         }
     }
     $this->view->showPage();
 }
コード例 #4
0
ファイル: Object.php プロジェクト: rosko/workapp
 public function getObject($id)
 {
     $rows = FALSE;
     $sql = "SELECT o.id AS id, o.timestamp AS `timestamp`, o.template AS tid, o.fid AS fdirid, t.id AS tid, t.name AS tname, ov.fid AS fid, tf.field AS `field`, tf.main AS `main`, tf.type AS `type`, tf.datatype AS datatype, ov.val AS val, o.uid AS auid, author.name AS aname, author.soname AS asoname, o.timestamp AS adate, ov.uid AS euid, editor.name AS ename, editor.soname AS esoname, ov.timestamp AS edate\r\n\t\t\t\tFROM objects AS o\r\n                LEFT JOIN objects_vals AS ov ON (ov.oid = o.id)\r\n                LEFT JOIN templates_fields AS tf ON (tf.id = ov.fid)\r\n                LEFT JOIN templates AS t ON (t.id = tf.tid)\r\n                LEFT JOIN users AS author ON (author.id = o.uid)\r\n                LEFT JOIN users AS editor ON (editor.id = ov.uid)\r\n                WHERE o.id = :id\r\n                ORDER BY fid";
     $res = $this->registry['db']->prepare($sql);
     $param = array(":id" => $id);
     $res->execute($param);
     $rows = $res->fetchAll(PDO::FETCH_ASSOC);
     $template = new Model_Template();
     $fields = $template->getTypeTemplate($rows[0]["tid"]);
     for ($i = 0; $i < count($fields); $i++) {
         $flag = false;
         for ($j = 0; $j < count($rows); $j++) {
             if (isset($rows[$j]["val"])) {
                 $rows[$j]["formatval"] = nl2br($rows[$j]["val"]);
                 $search = array("\n", "\r");
                 $rows[$j]["formatval"] = str_replace($search, "", $rows[$j]["formatval"]);
             }
             if (isset($rows[$j]["field"])) {
                 if ($fields[$i]["field"] == $rows[$j]["field"]) {
                     $flag = true;
                     $rows[$i]["sel"] = $template->getDataVals($rows[$i]["datatype"]);
                 }
             }
         }
         if (!$flag) {
             $rows[] = $fields[$i];
         }
     }
     $sql = "SELECT `email`\r\n\t\tFROM mail_contacts\r\n\t\tWHERE oid = :id";
     $res = $this->registry['db']->prepare($sql);
     $param = array(":id" => $id);
     $res->execute($param);
     $email = $res->fetchAll(PDO::FETCH_ASSOC);
     if (count($email) and $email[0]["email"] != "") {
         $rows[0]["email"] = $email[0]["email"];
     }
     if ($rows) {
         $fields = $template->getTemplate($rows[0]["tid"]);
     } else {
         return FALSE;
     }
     foreach ($fields as $part) {
         $flag = FALSE;
         foreach ($rows as $row) {
             if ($part["fid"] == $row["fid"]) {
                 $flag = TRUE;
             }
         }
         if (!$flag) {
             $rows[] = $part;
         }
     }
     for ($i = 0; $i < count($rows); $i++) {
         $sql = "SELECT fid, x, y, w, h\r\n        \t\tFROM templates_view\r\n        \t\tWHERE tid = :tid";
         $res = $this->registry['db']->prepare($sql);
         $param = array(":tid" => $rows[0]["tid"]);
         $res->execute($param);
         $data = $res->fetchAll(PDO::FETCH_ASSOC);
     }
     // если поле есть в таблице  templates_view, присвоим массиву $fields значения
     for ($i = 0; $i < count($rows); $i++) {
         for ($j = 0; $j < count($data); $j++) {
             if ($rows[$i]["fid"] == $data[$j]["fid"]) {
                 $rows[$i]["view"] = $data[$j];
             }
         }
     }
     // sort array
     for ($i = 0; $i < count($rows); $i++) {
         for ($j = 0; $j < count($rows); $j++) {
             if (isset($rows[$i]["view"]["y"]) and isset($rows[$j]["view"]["y"])) {
                 if ($rows[$i]["view"]["y"] < $rows[$j]["view"]["y"]) {
                     $min = $rows[$i];
                     $rows[$i] = $rows[$j];
                     $rows[$j] = $min;
                 }
             }
         }
     }
     return $rows;
 }