本文整理汇总了PHP中tag类的典型用法代码示例。如果您正苦于以下问题:PHP tag类的具体用法?PHP tag怎么用?PHP tag使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了tag类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: askAction
public function askAction()
{
//include_once("connect.php");
if ($_POST) {
$content = $_POST['content'];
$id = $_POST['UID'];
$title = $_POST['title'];
$abstract = substr($content, 0, 100);
$nowtime = date('Y-m-d H:i:s');
$tab = $_POST['tag'];
//$tab = 'hahaha';
$ask = new ask();
$question = new question();
$tag = new tag();
$question_arr = array('QTitle' => $title, 'Qcontent' => $content, 'Qabstract' => $abstract, 'looknum' => 0);
$qid = $question->insertQuestion($question_arr);
$ask_arr = array('UID' => $id, 'QID' => $qid, 'time' => $nowtime);
$ask->insertAsk($ask_arr);
$tag_arr = array('QID' => $qid, 'tag' => $tab);
$tag->insertTag($tag_arr);
//$this->view->QID = $qid;
echo $qid;
//$this->render('questioned');
}
}
示例2: build_add_article_html_form
function build_add_article_html_form()
{
global $base_path;
$helper_obj = new Helper();
$category_obj = new Category();
$pgrate_obj = new Pgrate();
$tag_obj = new tag();
//$BUCKET = 'cosmic-descent-775.appspot.com/article/';
//$options = [ 'gs_bucket_name' => $BUCKET ];
// $upload_url = CloudStorageTools::createUploadUrl('/add_article_html', $options);
$output = '<script src="js/plugins/ckeditor/ckeditor.js"></script>';
$output .= '<div class="box box-bordered">';
$output .= '<div class="box-title">
<h3><i class="icon-th-list"></i> Add Article</h3>
</div>';
$output .= "<form class='form-horizontal form-validate form-vertical form-bordered' method='post' id='add_article_html' name='add_article_html' action='add_article_html'>";
$output .= "<div class='control-group'> \n <label class='control-label' for='client_name'>Title</label>\n <div class='controls'> \n <input style='width:500px' class='input-xlarge' data-rule-required='true' type='text' name='title' id='title' placeholder='" . $helper_obj->t('Title') . "'> \n </div>\n </div>";
$output .= "<div class='control-group'> \n <label class='control-label' for='client_name'>Image1</label>\n <div class='controls'>\n <input class='input-xlarge' data-rule-required='true' accept='image/*' type='file' name='image1' id='image1'> \n </div> \n </div>";
/*$output .= "<div class='control-group'>
<label class='control-label' for='client_name'>Video Url</label>
<div class='controls'>
<input style='width:600px' class='input-xlarge' data-rule-required='true' type='text' name='video' id='video' placeholder='" . $helper_obj->t('Video Url') . "'>
</div>
</div>"; */
$output .= $category_obj->build_categories_list("add", "", "", "style='width:152px'");
$output .= $pgrate_obj->build_pgrate_list("add", "", "", "style='width:152px'");
$output .= $tag_obj->build_tags_list("add", "", "", "style='height:152px'");
$output .= '<div class="control-group">
<label class="control-label">Main Category in home page</label>
<div class="controls">
<label class="radio">
<input checked="checked" type="radio" name="section" value="1"> Top Section
</label>
<label class="radio">
<input type="radio" name="section" value="2"> Middle Section
</label>
<!--<label class="radio">
<input type="radio" name="section" value="3"> Bottom Section
</label>-->
</div>
</div>';
$output .= '<div class="row-fluid">
<div class="span12">
<div class="box">
<div class="box-title">
<h3><i class="icon-th"></i> Article Body</h3>
</div>
<div class="box-content nopadding">
<textarea data-rule-required=\'true\' name="ck" id="ck" class=\'ckeditor span12\' rows="5"></textarea>
</div>
</div>
</div>
';
$output .= "<input onclick='setEditorValue();' class='btn btn-primary' type='submit' value='" . $helper_obj->t('Save') . "'>";
$output .= "<input type='reset' style='display: none' id='add_article_html_reset'></div>";
$output .= "</form><br /><br />";
return $output;
}
示例3: ajax
function ajax()
{
global $user, $tenjin, $config_q;
if ($_GET["vote_for"] == 1) {
echo quote::vote_for(array("quote_id" => $_GET["q_id"], "user_id" => $user->data["user_id"], "ip" => $_SERVER['REMOTE_ADDR']));
} else {
if ($_GET["vote_against"] == 1) {
echo quote::vote_against(array("quote_id" => $_GET["q_id"], "user_id" => $user->data["user_id"], "ip" => $_SERVER['REMOTE_ADDR']));
/*
$cv = new vote(array(
"quote_id" => $_GET["q_id"],
"user_id" => $user->data["user_id"],
"ip" => $_SERVER['REMOTE_ADDR'],
));
$cv->vote_for();
*/
}
}
if ($_GET["get_quote_for_facebook"] == 1) {
echo ajax::get_quote_for_facebook($_GET["q_id"]);
}
if ($_GET["get_quotes_for_facebook"] == 1) {
quote::get_random_quotes_for_facebook();
die;
}
/* a strange kind of acl but ok
from here on you have to have permissions
*/
if (!can_access()) {
return true;
}
if ($_GET["dialog__add_quote"] == 1) {
$tenjin_template = $config_q["template_dir"] . '/dialog__add_quote.phtml';
$output = $tenjin->render($tenjin_template, $context);
echo $output;
} elseif ($_GET["get_tags"] == 1) {
/*$this->format_tags_as_links(array(
"tags" => $_POST["tags"],
));*/
} elseif ($_GET["format_tags_as_links"] == 1) {
$tag = new tag();
echo $tag->format_tags_as_links($_POST["tags"]);
} elseif ($_GET["set_tags"] == 1) {
$this->set_tags(array("tags" => $_POST["tags"], "q_id" => $_POST["q_id"]));
} elseif ($_GET["get_quote"] == 1) {
echo "get_quote";
} elseif ($_GET["set_quote"] == 1) {
echo "set_quote";
} elseif ($_GET["get_category"] == 1) {
$this->get_category(array("category_id" => $_POST["category_id"], "q_id" => $_POST["q_id"]));
} elseif ($_GET["set_category"] == 1) {
$this->set_category(array("category_id" => $_POST["category_id"], "q_id" => $_POST["q_id"]));
}
}
示例4: delete
static function delete($request)
{
$item = rest::resolve($request->url);
access::required("edit", $item);
// Deleting this collection means removing all tags associated with the item.
tag::clear_all($item);
}
示例5: item_created
/**
* Handle the creation of a new photo.
* @todo Get tags from the XMP and/or IPTC data in the image
*
* @param Item_Model $photo
*/
static function item_created($photo)
{
$tags = array();
if ($photo->is_photo()) {
$path = $photo->file_path();
$size = getimagesize($photo->file_path(), $info);
if (is_array($info) && !empty($info["APP13"])) {
$iptc = iptcparse($info["APP13"]);
if (!empty($iptc["2#025"])) {
foreach ($iptc["2#025"] as $tag) {
$tag = str_replace("", "", $tag);
if (function_exists("mb_detect_encoding") && mb_detect_encoding($tag) != "UTF-8") {
$tag = utf8_encode($tag);
}
$tags[$tag] = 1;
}
}
}
}
// @todo figure out how to read the keywords from xmp
foreach (array_keys($tags) as $tag) {
tag::add($photo, $tag);
}
return;
}
示例6: item_created
/**
* Handle the creation of a new photo.
* @todo Get tags from the XMP and/or IPTC data in the image
*
* @param Item_Model $photo
*/
static function item_created($photo) {
$tags = array();
if ($photo->is_photo()) {
$path = $photo->file_path();
$size = getimagesize($photo->file_path(), $info);
if (is_array($info) && !empty($info["APP13"])) {
$iptc = iptcparse($info["APP13"]);
if (!empty($iptc["2#025"])) {
foreach($iptc["2#025"] as $tag) {
$tag = str_replace("\0", "", $tag);
if (function_exists("mb_detect_encoding") && mb_detect_encoding($tag) != "UTF-8") {
$tag = utf8_encode($tag);
}
$tags[$tag] = 1;
}
}
}
}
// @todo figure out how to read the keywords from xmp
foreach(array_keys($tags) as $tag) {
try {
tag::add($photo, $tag);
} catch (Exception $e) {
Kohana::log("error", "Error adding tag: $tag\n" .
$e->getMessage() . "\n" . $e->getTraceAsString());
}
}
return;
}
示例7: build
protected function build()
{
$this->add(new HiddenBox($this->id));
$build_tag_from_datasource = false;
if ($this->get_par('database-save-parameters')) {
$this->att('class', 'osy-taglist-onextab', true);
$build_tag_from_datasource = true;
}
$ul = $this->add(tag::create('ul'));
if ($sql = $this->get_par('datasource-sql')) {
$sql = HelperOsy::replacevariable($sql);
$res = $this->db->exec_query($sql, null, 'NUM');
$datalist = $this->add(tag::create('datalist'));
$datalist->att('id', $this->id . '_data');
foreach ($res as $k => $rec) {
if ($rec[2] == 1) {
$ul->add('<li class="osy-taglist-entry" tid="' . $rec[0] . '"><span class="osy-taglist-entry-text">' . $rec[1] . '</span><a href="#" class="osy-taglist-entry-remove">remove</a></li>');
}
$datalist->add(tag::create('option'))->add($rec[1]);
}
}
if (!$build_tag_from_datasource && !empty($_REQUEST[$this->id])) {
$item_list = explode(',', $_REQUEST[$this->id]);
foreach ($item_list as $k => $v) {
$ul->add('<li class="osy-taglist-entry" pos="' . $k . '"><span class="osy-taglist-entry-text">' . $v . '</span><a href="#" class="osy-taglist-entry-remove">remove</a></li>');
}
}
$txt = $ul->add(tag::create('li'))->att('class', 'listbuilder-entry-text')->add(tag::create('input'))->att('name', $this->id . '_add')->att('type', 'text')->att('class', 'add osy-taglist-input');
if (isset($datalist)) {
$txt->att('list', $this->id . '_data');
}
$ul->add('<br style="clear: both">');
}
示例8: _form_add
public function _form_add($item_id)
{
$item = ORM::factory("item", $item_id);
access::required("view", $item);
access::required("edit", $item);
return tag::get_add_form($item);
}
示例9: form_rename
public function form_rename($id)
{
$tag = ORM::factory("tag", $id);
if ($tag->loaded) {
print tag::get_rename_form($tag);
}
}
示例10: tag
public function tag($id)
{
$categories = Category::all();
$tag = tag::find($id);
$products = $tag->products;
return view('store.tag', compact('categories', 'products', 'tag'));
}
示例11: get_test
public function get_test()
{
$t1 = tag::add(item::root(), "t1");
$t2 = tag::add(item::root(), "t2");
$request = new stdClass();
$this->assert_equal_array(array("url" => rest::url("tags"), "members" => array(rest::url("tag", $t1), rest::url("tag", $t2))), tags_rest::get($request));
}
示例12: save
function save($album_id)
{
access::verify_csrf();
$album = ORM::factory("item", $album_id);
access::required("edit", $album);
if (Input::instance()->post("save")) {
$titles = Input::instance()->post("title");
$descriptions = Input::instance()->post("description");
$filenames = Input::instance()->post("filename");
$internetaddresses = Input::instance()->post("internetaddress");
$tags = Input::instance()->post("tags");
$enable_tags = module::is_active("tag");
foreach (array_keys($titles) as $id) {
$item = ORM::factory("item", $id);
if ($item->loaded() && access::can("edit", $item)) {
$item->title = $titles[$id];
$item->description = $descriptions[$id];
$item->name = $filenames[$id];
$item->slug = $internetaddresses[$id];
$item->save();
if ($enable_tags) {
tag::clear_all($item);
foreach (explode(",", $tags[$id]) as $tag_name) {
if ($tag_name) {
tag::add($item, trim($tag_name));
}
}
tag::compact();
}
}
}
message::success(t("Captions saved"));
}
url::redirect($album->abs_url());
}
示例13: get_test
public function get_test()
{
$tag = tag::add(item::root(), "tag1")->reload();
$request = new stdClass();
$request->url = rest::url("tag", $tag);
$this->assert_equal_array(array("url" => rest::url("tag", $tag), "entity" => $tag->as_array(), "relationships" => array("items" => array("url" => rest::url("tag_items", $tag), "members" => array(rest::url("tag_item", $tag, item::root()))))), tag_rest::get($request));
}
示例14: tagitems
public function tagitems()
{
// Tag all non-album items in the current album with the specified tags.
// Prevent Cross Site Request Forgery
access::verify_csrf();
// Generate an array of all non-album items in the current album.
$children = ORM::factory("item")->where("parent_id", $this->input->post("item_id"))->where("type !=", "album")->find_all();
// Loop through each item in the album and make sure the user has
// access to view and edit it.
foreach ($children as $child) {
if (access::can("view", $child) && access::can("edit", $child)) {
// Assuming the user can view/edit the current item, loop
// through each tag that was submitted and apply it to
// the current item.
foreach (split(",", $this->input->post("name")) as $tag_name) {
$tag_name = trim($tag_name);
if ($tag_name) {
tag::add($child, $tag_name);
}
}
}
}
// Redirect back to the album.
$item = ORM::factory("item", $this->input->post("item_id"));
url::redirect(url::abs_site("{$item->type}s/{$item->id}"));
}
示例15: rename
public function rename($id)
{
access::verify_csrf();
$tag = ORM::factory("tag", $id);
if (!$tag->loaded) {
kohana::show_404();
}
$form = tag::get_rename_form($tag);
$valid = $form->validate();
if ($valid) {
$new_name = $form->rename_tag->inputs["name"]->value;
$new_tag = ORM::factory("tag")->where("name", $new_name)->find();
if ($new_tag->loaded) {
$form->rename_tag->inputs["name"]->add_error("in_use", 1);
$valid = false;
}
}
if ($valid) {
$old_name = $tag->name;
$tag->name = $new_name;
$tag->save();
$message = t("Renamed tag %old_name to %new_name", array("old_name" => $old_name, "new_name" => $tag->name));
message::success($message);
log::success("tags", $message);
print json_encode(array("result" => "success", "location" => url::site("admin/tags"), "tag_id" => $tag->id, "new_tagname" => html::clean($tag->name)));
} else {
print json_encode(array("result" => "error", "form" => $form->__toString()));
}
}