Пример #1
0
     }
 } else {
     $res = PostController::update($_POST);
     //Tags
     $tags = array();
     if (count($_POST["tags"]) > 0) {
         $tags = explode(",", $_POST["tags"]);
     }
     $newTags = array();
     if (count($_POST["newTags"]) > 0 && !empty($_POST["newTags"])) {
         $newTags = explode(",", $_POST["newTags"]);
     }
     if (!empty($newTags) && count($newTags) > 0) {
         foreach ($newTags as $newTag) {
             $arr = array("nome" => $newTag, "seo" => "");
             $tags[] = TagController::insert($arr);
         }
     }
     $tagsPost = PostController::getAllPostTag($_POST['id'], "", "");
     if (count($tagsPost) > 0) {
         foreach ($tagsPost as $tag) {
             $tagsPostList[] = $tag->IdTag;
         }
         $array = array();
         foreach ($tags as $tag) {
             error_log($tag);
             if (!in_array($tag, $tagsPostList)) {
                 $arr = array("idTag" => $tag, "idPost" => $_POST['id']);
                 PostController::insertPostTag($arr);
             }
         }
Пример #2
0
        $selected = "selected";
    } else {
        $selected = "";
    }
    echo "<option value=" . $categoria->Id . " " . $selected . ">" . $categoria->Nome . "</option>";
}
?>
								</select>
							</div>
						</div>
						<div class="form-group">
                        	<label for="tagsList" class="col-sm-2 control-label">Tags</label>
                            <div class="col-sm-10" id="tagsList">
                            	<select id="tagsSelect" multiple="multiple" class="tokenize-sample">
                                	<?php 
foreach (TagController::getAll("", "Id") as $tag) {
    if (in_array($tag->Id, $arrayTags)) {
        $selected = "selected";
    } else {
        $selected = "";
    }
    echo "<option value=" . $tag->Id . " " . $selected . ">" . $tag->Nome . "</option>";
}
?>
 
								</select>
							</div>
						</div>
						<div class="form-group hidden">
                        	<label for="criador" class="col-sm-2 control-label">Criador</label>
                        	<div class="col-sm-8">
 /**
  * Adds a tag to a problem
  *
  * @param Request $r
  * @return array
  * @throws InvalidDatabaseOperationException
  * @throws ForbiddenAccessException
  */
 public static function apiAddTag(Request $r)
 {
     // Check problem_alias
     Validators::isStringNonEmpty($r['problem_alias'], 'problem_alias');
     // Authenticate logged user
     self::authenticateRequest($r);
     $problem = ProblemsDAO::getByAlias($r['problem_alias']);
     if (!Authorization::IsProblemAdmin($r['current_user_id'], $problem)) {
         throw new ForbiddenAccessException();
     }
     // Normalize name.
     $tag_name = $r['name'];
     Validators::isStringNonEmpty($tag_name, 'name');
     $tag_name = TagController::normalize($tag_name);
     try {
         $tag = TagsDAO::getByName($tag_name);
     } catch (Exception $e) {
         $this->log->info($e);
         // Operation failed in the data layer
         throw new InvalidDatabaseOperationException($e);
     }
     if ($tag == null) {
         try {
             $tag = new Tags();
             $tag->name = $tag_name;
             TagsDAO::save($tag);
         } catch (Exception $inner) {
             $this->log->info($e);
             // Operation failed in the data layer
             throw new InvalidDatabaseOperationException($inner);
         }
     }
     if (is_null($tag->tag_id)) {
         throw new InvalidDatabaseOperationException(new Exception('tag'));
     }
     $problem_tag = new ProblemsTags();
     $problem_tag->problem_id = $problem->problem_id;
     $problem_tag->tag_id = $tag->tag_id;
     $problem_tag->public = $r['public'] ? 1 : 0;
     // Save the tag to the DB
     try {
         ProblemsTagsDAO::save($problem_tag);
     } catch (Exception $e) {
         // Operation failed in the data layer
         self::$log->error('Failed to save tag', $e);
         throw new InvalidDatabaseOperationException($e);
     }
     return array('status' => 'ok', 'name' => $tag_name);
 }
Пример #4
0
<?php

if ($_POST['action'] == "save") {
    if (empty($_POST['id'])) {
        $res = TagController::insert($_POST);
        if ($res) {
            header("Location: blog-tags");
            exit;
        } else {
            die("ERRO");
        }
    } else {
        $res = TagController::update($_POST);
        if ($res) {
            header("Location: blog-tags");
            exit;
        } else {
            die("ERRO");
        }
    }
} elseif ($_POST['action'] == "del") {
    if (TagController::delete($_POST)) {
        die("OK");
    } else {
        die("ERRO");
    }
}
Пример #5
0
							<button type="submit" name="action" value="save" class="btn btn-success">Salvar</button>
						</div>
					</div>
					<fieldset>
						<div class="form-group">
							<label for="nome" class="col-sm-2 control-label">Nome</label>
							<div class="col-sm-4">                        		
								<input class="form-control" name="nome" id="nome" type="text" autofocus>
							</div>
						</div>
						<div class="form-group">
							<label for="seo" class="col-sm-2 control-label">URL</label>
							<div class="col-sm-4">
								<input class="form-control" name="seo" id="seo" type="text">
							</div>
						</div>
					</fieldset>
                </form>
                
			</div>
			
		</div>
		
	</div>

<?php 
if (isset($_GET['id'])) {
    $tag = TagController::getTag($_GET['id']);
    echo "\t<script>\n\t\t\t\t\t\$('#id').val('" . $tag->Id . "');\n\t\t\t\t\t\$('#nome').val('" . addslashes($tag->Nome) . "');\n\t\t\t\t\t\$('#seo').val('" . $tag->Seo . "');\n\t\t\t\t\t\$('#subtitle').text('/ Editar tag');\n\t\t\t\t</script>";
}
include "helper/rodape.php";
Пример #6
0
<?php

require "helper/cabecalho.php";
$url = explode("/tag/", $_SERVER['REQUEST_URI']);
$tag = new TagController();
$tagModel = $tag->getTagBySeo($url[1]);
$posts = new PostController();
$totalPosts = $posts->getPostsCountByTag($tagModel->Id);
?>
	
	<div class="container">
		<div class="row">
			
			<div class="col-sm-9" id="conteudo-pagina">
				
				<div id="topo-home">
					
					<h2 class="titulo-bloco">
						<span>Tag:</span> 
						<?php 
echo $tagModel->Nome;
?>
					</h2>
					
					<div class="row lista-posts">
						
						<?php 
foreach ($posts->getPostsByTag($tagModel->Id, 0, 5) as $post) {
    echo "\t<div class='col-sm-12'>\n\t\t\t\t\t\t\t\t\t\t\t<div class='post-thumb horizontal lista' url='" . $post->Seo . "'>\n\t\t\t\t\t\t\t\t\t\t\t\t<div class='imagem'>\n\t\t\t\t\t\t\t\t\t\t\t\t\t" . (!empty($post->Capa) ? "<img src='" . $post->Capa . "'>" : "") . "\n\t\t\t\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t\t\t\t\t<div class='dados'>\n\t\t\t\t\t\t\t\t\t\t\t\t\t<h1 class='titulo'>" . $post->Titulo . "</h1>\n\t\t\t\t\t\t\t\t\t\t\t\t\t<span class='categoria'>" . $post->CategoriaPrincipal_Nome . "</span>\n\t\t\t\t\t\t\t\t\t\t\t\t\t<span class='data'>Publicado em " . DefaultHelper::converterData($post->DataCriacao, true) . "</span>\n\t\t\t\t\t\t\t\t\t\t\t\t\t<div class='nota rateit' data-rateit-min='0' data-rateit-max='5' data-rateit-readonly='true' data-rateit-value='" . $post->NotaGeral . "'></div>\n\t\t\t\t\t\t\t\t\t\t\t\t\t<div class='resumo'>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t" . $post->Corpo . "\n\t\t\t\t\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t\t\t\t\t\t<div class='acoes'>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t<a href='post/" . $post->Seo . "' class='btn btn-link link'>Continuar lendo</a>\n\t\t\t\t\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t\t\t</div>";
}
?>