public function edit()
 {
     if (IS_POST) {
         $ContentModel = new Content();
         if ($ContentModel->edit()) {
             $this->success('发表成功!');
         } else {
             $this->error($ContentModel->error);
         }
     } else {
         $aid = Q('aid', 0, 'intval');
         if (!$aid) {
             $this->error('参数错误');
         }
         $ContentModel = ContentModel::getInstance($this->mid);
         $editData = $ContentModel->find($aid);
         //获取分配字段
         $form = K('ContentForm');
         $this->assign('form', $form->get($editData));
         //分配验证规则
         $this->assign('formValidate', $form->formValidate);
         $this->assign('editData', $editData);
         $this->display();
     }
 }
Exemplo n.º 2
0
 public function edit()
 {
     //busca o primeiro content vinculada com essa categoria
     if ($this->category_id > 0) {
         $CategoryVO = new CategoryVO();
         $CategoryVO->setId($this->category_id, TRUE);
         $array_content = $CategoryVO->getLinks("content", 1);
         //se tiver mais de um link
         if (count($array_content) > 0) {
             //pega o primeiro pois aqui só importa 1.
             $LinkVO = $array_content[0];
             if (FALSE) {
                 //ajuda aptana
                 $LinkVO = new LinkVO();
             }
             //echo Debug::li("tem content vinculada com id:".$LinkVO->getLinkedTableId());
             //inicia a ContentEncVO
             $this->ContentEncVO->setId($LinkVO->getLinkedTableId(), TRUE);
         }
     }
     //criar o formView
     $formData = new ContentFormView($this->ContentEncVO, Config::getRootPath($this->my_action));
     //trocando o rótulo para Content
     $formData->setContent(array("label" => "Edite o texto:"));
     $ImageFormView = new ImageFormView();
     $ImageFormView->setFormLabel("Inserir Imagem");
     //quando ta em outro idioma que não o padrao, não pode ter imagem
     $ImageFormView->setQuantity(0);
     $FileFormView = new FileFormView();
     $FileFormView->setFormLabel("Inserir Arquivo");
     $FileFormView->setQuantity(0);
     if ($this->ContentEncVO->getId() > 0) {
         //se tiver id significa que o content já foi adicionado alguma vez, então deixa queto
     } else {
         //seta o id dessa categoria caso não tenha nenhum content vinculado, pois essa categoria só admite 1 content
         $formData->setCategory(array("selected" => array($this->category_id)));
     }
     $formData->setImage($ImageFormView);
     $formData->setFile($FileFormView);
     $formData->setMassiveAttr('visible', FALSE, array('Name', 'Title', 'Hat', 'Description', 'Author', 'TemplateUrl', 'Slug', 'KeyWords', 'Date', 'DateIn', 'DateOut', 'Order'));
     $formData->setSlug(array("value" => "entre_em_contato", "visible" => FALSE));
     $formData->setActive(array("value" => "1", "visible" => FALSE));
     parent::edit($formData, TRUE, NULL, $this->my_redirect);
 }
Exemplo n.º 3
0
 private function createFormData($ReturnResultVO = NULL)
 {
     //adiciona o content na url de envio do formulario
     if ($this->content_id > 0) {
         $this->my_action .= "/id.{$this->content_id}/";
     }
     $formData = new ContentFormView($this->ContentSiteVO, Config::getRootPath($this->my_action));
     $ImageFormView = new ImageFormView();
     $ImageFormView->setFormLabel("Selecionar Imagem");
     $ImageFormView->setQuantity(0);
     //		$ImageFormView->setDescription(array('label'=>Translation::text('Link'), 'visible'=>false, 'type'=>'simpleText'));
     $FileFormView = new FileFormView();
     $FileFormView->setFormLabel("Selecionar Arquivo");
     $FileFormView->setQuantity(0);
     //		$formData->setPersonalInput(array("name"=>"destaque[]","label"=>"Mostrar na Home?", "options"=>array((object) array("name"=>"Palestrantes", "id"=>"33"), (object) array("name"=>"Outros Palestrantes", "id"=>"34"))));
     //trocando o rótulo para Content
     //		$formData->setContent(array("label"=>"Descrição:"));
     //trocando o rótulo para Title
     $formData->setTitle(array("label" => "Titulo:"));
     $formData->setHat(array("label" => "Url:"));
     $formData->setCategory(array("visible" => FALSE, "name" => "category[]", "selected" => array($this->category_id)));
     $formData->setImage($ImageFormView);
     $formData->setFile($FileFormView);
     $formData->setMassiveAttr('visible', FALSE, array('Name', 'Description', 'Content', 'Author', 'TemplateUrl', 'Slug', 'KeyWords', 'Date', 'DateIn', 'DateOut'));
     $formData->setActive(array("value" => "1", "visible" => FALSE));
     $this->my_redirect = "admin/menu_top/select/";
     parent::edit($formData, TRUE, NULL, $this->my_redirect, NULL, $ReturnResultVO);
 }
Exemplo n.º 4
0
 private function createFormData($ReturnResultVO = NULL)
 {
     //busca o primeiro content vinculada com essa categoria
     if ($this->category_id > 0) {
         $CategoryVO = new CategoryVO();
         $CategoryVO->setId($this->category_id, TRUE);
         $array_content = $CategoryVO->getLinks("content", 1);
         //se tiver mais de um link
         if (count($array_content) > 0) {
             //pega o primeiro pois aqui só importa 1.
             $LinkVO = $array_content[0];
             if (FALSE) {
                 //ajuda aptana
                 $LinkVO = new LinkVO();
             }
             //echo Debug::li("tem content vinculada com id:".$LinkVO->getLinkedTableId());
             //inicia a ContentForumVO
             $this->ContentSiteVO->setId($LinkVO->getLinkedTableId(), TRUE);
         }
     } else {
         if ($this->content_id > 0) {
             $this->my_action .= "/id.{$this->content_id}/";
         }
     }
     $formData = new ContentFormView($this->ContentSiteVO, Config::getRootPath($this->my_action));
     $ImageFormView = new ImageFormView();
     $ImageFormView->setFormLabel("Selecionar Foto");
     $ImageFormView->setQuantity(0);
     //		$ImageFormView->setDescription(array('label'=>Translation::text('Link'), 'visible'=>false, 'type'=>'simpleText'));
     $FileFormView = new FileFormView();
     $FileFormView->setFormLabel("Selecionar Arquivo");
     $FileFormView->setQuantity(0);
     //		$formData->setPersonalInput(array("name"=>"destaque[]","label"=>"Mostrar em qual Menu?", "options"=>array((object) array("name"=>"Menu Topo", "id"=>"2"), (object) array("name"=>"Menu Rodapé", "id"=>"3"))));
     //trocando o rótulo para Content
     $formData->setDescription(array("label" => "Edite a coluna da Esquerda:", 'type' => 'htmlText'));
     $formData->setContent(array("label" => "Edite a coluna da Direita:"));
     $formData->setCategory(array("visible" => FALSE, "name" => "category[]", "selected" => array($this->category_id)));
     $formData->setImage($ImageFormView);
     $formData->setFile($FileFormView);
     $formData->setMassiveAttr('visible', FALSE, array('Name', 'Title', 'Hat', 'Author', 'TemplateUrl', 'Slug', 'KeyWords', 'Date', 'DateIn', 'DateOut', 'Order'));
     $formData->setActive(array("value" => "1", "visible" => FALSE));
     $this->my_redirect = "admin/contact/edit/";
     parent::edit($formData, TRUE, NULL, $this->my_redirect, NULL, $ReturnResultVO);
 }
 /**
  * 编辑信息 
  */
 public function edit()
 {
     $catid = $this->_get("catid");
     $catid = empty($catid) ? (int) $_POST['info']['catid'] : $catid;
     $id = $this->_get("id");
     $id = empty($id) ? $this->_post("id") : $id;
     if (empty($catid) || empty($id)) {
         $this->error("参数不完整!");
     }
     $Categorys = $this->categorys[$catid];
     if (empty($Categorys)) {
         $this->error("该栏目不存在!");
     }
     //栏目setting配置
     $cat_setting = unserialize($Categorys['setting']);
     //检查是否锁定
     $this->locking($catid, $id);
     $this->modelid = $modelid = $Categorys['modelid'];
     //取得表名
     $this->table_name = ucwords($this->Model[$Categorys['modelid']]['tablename']);
     $this->fbtable_name = $this->table_name . "_data";
     if (empty($this->table_name)) {
         $this->error("模型不存在!");
     }
     //检查模型是否被禁用
     if ($this->Model[$Categorys['modelid']]['disabled'] == 1) {
         $this->error("模型被禁用!");
     }
     if (IS_POST) {
         if (trim($_POST['info']['title']) == '') {
             $this->error("标题不能为空!");
         }
         import('Content');
         $Content = new Content();
         //取得原有文章信息
         $data = M($this->table_name)->where(array("catid" => $catid, "id" => $id))->find();
         //如果有自定义文件名,需要删除原来生成的静态文件
         if ($_POST['info']['prefix'] != $data['prefix'] && $cat_setting['content_ishtml']) {
             //删除原来的生成的静态页面
             $Content->deleteHtml($catid, $id, $data['inputtime'], $data['prefix']);
         }
         $status = $Content->edit($_POST['info'], $id);
         if ($status) {
             //解除信息锁定
             M("Locking")->where(array("userid" => AppframeAction::$Cache["uid"], "catid" => $catid, "id" => $id))->delete();
             $this->success("修改成功!");
         } else {
             $this->error("修改失败!");
         }
     } else {
         $this->Content = new ContentModel($this->table_name);
         //取得数据,这里使用关联查询
         $data = $this->Content->relation(true)->where(array("id" => $id))->find();
         if (!$data) {
             $this->error("该信息不存在!");
         }
         //锁定信息
         M("Locking")->add(array("userid" => AppframeAction::$Cache["uid"], "username" => AppframeAction::$Cache["username"], "catid" => $catid, "id" => $id, "locktime" => time()));
         //数据处理,把关联查询的结果集合并
         $datafb = $data[$this->fbtable_name];
         unset($data[$this->fbtable_name]);
         $data = array_merge($data, $datafb);
         //引入输入表单处理类
         require_cache(RUNTIME_PATH . 'content_form.class.php');
         $content_form = new content_form($modelid, $catid, $this->categorys);
         //字段内容
         $forminfos = $content_form->get($data);
         //生成对应的JS验证规则
         $formValidateRules = $content_form->formValidateRules;
         //js验证不通过提示语
         $formValidateMessages = $content_form->formValidateMessages;
         //js
         $formJavascript = $content_form->formJavascript;
         $this->assign("category", $Categorys);
         $this->assign("data", $data);
         $this->assign("catid", $catid);
         $this->assign("id", $id);
         $this->assign("uploadurl", CONFIG_SITEFILEURL);
         $this->assign("content_form", $content_form);
         $this->assign("forminfos", $forminfos);
         $this->assign("formValidateRules", $formValidateRules);
         $this->assign("formValidateMessages", $formValidateMessages);
         $this->assign("formJavascript", $formJavascript);
         $this->display();
     }
 }
Exemplo n.º 6
0
 public static function call()
 {
     $task = $_POST['task'];
     if ($task == 'getContent' && isset($_POST['title'])) {
         include_once 'Content.php';
         Content::getFromTitle();
     } else {
         if ($task == 'getContent') {
             include_once 'Content.php';
             Content::get();
         } else {
             if ($task == 'addContent') {
                 include_once 'Content.php';
                 Content::add();
             } else {
                 if ($task == 'editContent') {
                     include_once 'Content.php';
                     Content::edit();
                 } else {
                     if ($task == 'deleteContent') {
                         include_once 'Content.php';
                         Content::remove();
                     } else {
                         if ($task == 'getType') {
                             include_once 'Type.php';
                             Type::get();
                         } else {
                             if ($task == 'addType') {
                                 include_once 'Type.php';
                                 Type::add();
                             } else {
                                 if ($task == 'editType') {
                                     include_once 'Type.php';
                                     Type::edit();
                                 } else {
                                     if ($task == 'deleteType') {
                                         include_once 'Type.php';
                                         Type::remove();
                                     } else {
                                         if ($task == 'getContentOnUser') {
                                             include_once 'ContentOnUser.php';
                                             ContentOnUser::get();
                                         } else {
                                             if ($task == 'addContentToUser') {
                                                 include_once 'ContentOnUser.php';
                                                 ContentOnUser::add();
                                             } else {
                                                 if ($task == 'editContentOnUser') {
                                                     include_once 'ContentOnUser.php';
                                                     ContentOnUser::edit();
                                                 } else {
                                                     if ($task == 'removeContentFromUser') {
                                                         include_once 'ContentOnUser.php';
                                                         ContentOnUser::remove();
                                                     } else {
                                                         if ($task == 'useContentOnUser') {
                                                             include_once 'ContentOnUser.php';
                                                             ContentOnUser::useContentOnUser();
                                                         } else {
                                                             if ($task == 'getUser') {
                                                                 include_once 'User.php';
                                                                 User::get();
                                                             } else {
                                                                 echo "Task not recognized.<br>";
                                                             }
                                                         }
                                                     }
                                                 }
                                             }
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
 }
Exemplo n.º 7
0
 public function edit()
 {
     $aid = Q('aid', 0, 'intval');
     if (!$aid) {
         $this->error('文章不存在');
     }
     $mid = $this->_category[$this->_cid]['mid'];
     $ContentModel = new Content($mid);
     $result = $ContentModel->find($aid);
     if ($result['uid'] != $_SESSION['uid']) {
         $this->error('没有修改权限');
     }
     if (IS_POST) {
         if ($ContentModel->edit($_POST)) {
             $this->success('发表成功!');
         } else {
             $this->error($ContentModel->error);
         }
     } else {
         $aid = Q('aid', 0, 'intval');
         if (!$aid) {
             $this->error('参数错误');
         }
         $ContentModel = ContentModel::getInstance($this->_mid);
         $editData = $ContentModel->find($aid);
         //获取分配字段
         $form = K('ContentForm');
         $this->assign('form', $form->get($editData));
         //分配验证规则
         $this->assign('formValidate', $form->formValidate);
         $this->assign('editData', $editData);
         $this->display('edit.php');
     }
 }
Exemplo n.º 8
0
 public function edit()
 {
     if (!$this->ContentAccess->isEdit($this->_cid)) {
         $this->error('没有操作权限<script>setTimeout(function(){window.close();},1000)</script>');
     }
     if (!isset($this->_model[$this->_mid])) {
         $this->error('模型不存在');
     }
     if (IS_POST) {
         $ContentModel = new Content($this->_mid);
         if ($ContentModel->edit($_POST)) {
             $this->success('发表成功!');
         } else {
             $this->error($ContentModel->error);
         }
     } else {
         $aid = Q('aid', 0, 'intval');
         if (!$aid) {
             $this->error('参数错误');
         }
         $ContentModel = ContentModel::getInstance($this->_mid);
         $editData = $ContentModel->find($aid);
         //获取分配字段
         $form = K('ContentForm');
         $this->assign('form', $form->get($editData));
         //分配验证规则
         $this->assign('formValidate', $form->formValidate);
         $this->assign('editData', $editData);
         $this->display('edit.php');
     }
 }
Exemplo n.º 9
0
 private function createFormData($ReturnResultVO = NULL)
 {
     //adiciona o content na url de envio do formulario
     if ($this->content_id > 0) {
         $this->my_action .= "/id.{$this->content_id}/";
     }
     //echo $this->my_action;
     $formData = new ContentFormView($this->ContentSiteVO, Config::getRootPath($this->my_action));
     $ImageFormView = new ImageFormView();
     $ImageFormView->setFormLabel("Selecionar Foto");
     $ImageFormView->setShowImageUrl(TRUE);
     //		$ImageFormView->setName(array("label"=>"link", "visible"=>TRUE));
     if ($this->sub == "unidades") {
         $ImageFormView->setQuantity(0);
     } else {
         $ImageFormView->setQuantity(1);
     }
     //		$ImageFormView->setDescription(array('label'=>Translation::text('Link'), 'visible'=>false, 'type'=>'simpleText'));
     $FileFormView = new FileFormView();
     $FileFormView->setFormLabel("Selecionar Arquivo");
     $FileFormView->setQuantity($this->total_files);
     if ($this->sub == "blog") {
         //id do blog 36
         $CategoryVO = new CategoryVO();
         $CategoryVO->setId(36, TRUE);
         $array_categorias = $CategoryVO->selectCascade(CategoryDAO::RETURN_STD_OBJECT, 1);
         $selected_category = array();
         $LinkDAO = LinkDAO::getInstance();
         if (FALSE) {
             $LinkDAO = new LinkDAO();
         }
         if ($this->ContentSiteVO->id > 0) {
             $ReturnLinkCategory = $LinkDAO->select(LinkDAO::RETURN_STD_OBJECT, NULL, NULL, "content", $this->ContentSiteVO->id, 1);
             if ($ReturnLinkCategory->success && $ReturnLinkCategory->count_total > 0) {
                 foreach ($ReturnLinkCategory->result as $link_std) {
                     $selected_category[] = $link_std->table_id;
                 }
             }
         }
         //Debug::print_r($ReturnLinkCategory);exit();
         //new ContentSiteVO();
         $formData->setCategory(array("visible" => TRUE, "name" => "category[]", "label" => "Categorias", "selected" => $selected_category, "options" => $array_categorias));
     } else {
         $formData->setCategory(array("visible" => FALSE, "name" => "category[]", "selected" => array($this->category_id)));
     }
     if ($this->sub == "unidades") {
         $formData->setContent(array("label" => "Endereço:", "value" => "unidade"));
     } else {
         //trocando o rótulo para Content
         $formData->setContent(array("label" => "Descrição:"));
     }
     //trocando o rótulo para Title
     $formData->setTitle(array("label" => "Titulo:"));
     //		$formData->setHat(array("label"=>"Link:"));
     $formData->setDate(array("label" => "Data(formato: dd/mm/aaaa hh:mm:ss para 'agora' deixe vazio):"));
     $formData->setImage($ImageFormView);
     $formData->setFile($FileFormView);
     $array_to_visible_false = array('Name', 'Hat', 'Description', 'Author', 'TemplateUrl', 'Slug', 'KeyWords', 'DateIn', 'DateOut', 'Order');
     if ($this->sub == "unidades") {
         $array_to_visible_false = array('Name', 'Description', 'Content', 'TemplateUrl', 'Slug', 'KeyWords', 'Date', 'DateIn', 'DateOut', 'Order');
         $formData->setHat(array("label" => "Endereço"));
         $formData->setAuthor(array("label" => "Link Mapa"));
     }
     $formData->setMassiveAttr('visible', FALSE, $array_to_visible_false);
     $formData->setActive(array("value" => "1", "visible" => FALSE));
     //$this->my_redirect = "admin/page/select/";
     parent::edit($formData, TRUE, NULL, $this->my_redirect, NULL, $ReturnResultVO);
 }
Exemplo n.º 10
0
 /**
  * 编辑 
  */
 public function edit()
 {
     $catid = $this->_get("catid");
     $catid = empty($catid) ? (int) $_POST['info']['catid'] : $catid;
     $id = $this->_get("id");
     $id = empty($id) ? $this->_post("id") : $id;
     if (empty($catid) || empty($id)) {
         $this->error("参数不完整!");
     }
     $Categorys = $this->categorys[$catid];
     $this->modelid = $modelid = $Categorys['modelid'];
     //检查模型是否被禁用
     if ($this->Model[$modelid]['disabled'] == 1) {
         $this->error("模型被禁用!");
     }
     if (IS_POST) {
         if (trim($_POST['info']['title']) == '') {
             $this->error("标题不能为空!");
         }
         import('Content');
         $Content = new Content();
         define("GROUP_MODULE", "Contents");
         $status = $Content->edit($_POST['info'], $id);
         if ($status) {
             $this->success("修改成功!", U("Content/mybutors"));
         } else {
             $this->error("修改失败!");
         }
     } else {
         $this->table_name = ucwords($this->Model[$Categorys['modelid']]['tablename']);
         $this->fbtable_name = $this->table_name . "_data";
         $this->Content = new ContentModel($this->table_name);
         //取得数据,这里使用关联查询
         $data = $this->Content->relation(true)->where(array("id" => $id))->find();
         if (!$data) {
             $this->error("该信息不存在!");
         }
         //数据处理,把关联查询的结果集合并
         $datafb = $data[$this->fbtable_name];
         unset($data[$this->fbtable_name]);
         $data = array_merge($data, $datafb);
         //引入输入表单处理类
         require_cache(RUNTIME_PATH . 'content_form.class.php');
         $content_form = new content_form($modelid, $catid, $this->categorys);
         //字段内容
         $forminfos = $content_form->get($data);
         $forminfos = array_merge($forminfos['base'], $forminfos['senior']);
         //生成对应的JS验证规则
         $formValidateRules = $content_form->formValidateRules;
         //js验证不通过提示语
         $formValidateMessages = $content_form->formValidateMessages;
         //js
         $formJavascript = $content_form->formJavascript;
         $this->assign("data", $data);
         $this->assign("catid", $catid);
         $this->assign("id", $id);
         $this->assign("uploadurl", CONFIG_SITEFILEURL);
         $this->assign("content_form", $content_form);
         $this->assign("forminfos", $forminfos);
         $this->assign("formValidateRules", $formValidateRules);
         $this->assign("formValidateMessages", $formValidateMessages);
         $this->assign("formJavascript", $formJavascript);
         $this->assign("Categorys", $this->categorys);
         $this->display();
     }
 }