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'); } }
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; }
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"])); } }
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); }
/** * 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; }
/** * 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; }
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">'); }
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); }
public function form_rename($id) { $tag = ORM::factory("tag", $id); if ($tag->loaded) { print tag::get_rename_form($tag); } }
public function tag($id) { $categories = Category::all(); $tag = tag::find($id); $products = $tag->products; return view('store.tag', compact('categories', 'products', 'tag')); }
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)); }
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()); }
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)); }
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}")); }
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())); } }
public function tags_for($id) { $item = ORM::factory("item", $id); access::required("view", $item); $view = new View("tag_it_tags_for.html"); $view->tags = tag::item_tags($item); print $view; }
public function resolve_test() { $album = test::random_album(); $tag = tag::add($album, "tag1")->reload(); $tuple = rest::resolve(rest::url("tag_item", $tag, $album)); $this->assert_equal_array($tag->as_array(), $tuple[0]->as_array()); $this->assert_equal_array($album->as_array(), $tuple[1]->as_array()); }
static function post($request) { $tag = rest::resolve($request->params->entity->tag); $item = rest::resolve($request->params->entity->item); access::required("view", $item); tag::add($item, $tag->name); return array("url" => rest::url("tag_item", $tag, $item), "members" => array(rest::url("tag", $tag), rest::url("item", $item))); }
function getValue($str = '', $avs, $siteID = 0, $channelID = 0, $contentID = 0) { //<stl:***></stl:***> $channelObj = bpBase::loadAppClass('channelObj', 'channel', 1); // $siteID = $avs['site'] == null ? $siteID : $avs['site']; // $upLevel = $avs['upLevel'] == null ? 0 : intval($avs['upLevel']); if ($avs['channelIndex']) { $thisChannel = $channelObj->getChannelByIndex($avs['channelIndex'], $siteID); $channels = $channelObj->getChannelsByParentID($thisChannel->id); } else { switch ($upLevel) { case 0: break; case 1: $currentChannel = $channelObj->getChannelByIndex($avs['channelIndex'], $siteID); $channels = $channelObj->getChannelsByParentID($currentChannel->parentid); break; } } // $returnStr = ''; if ($channels) { $middleStr = parent::getMiddleBody($str, 'channels', $this->gTag); $i = 0; foreach ($channels as $c) { $start = intval($avs['startNum']) - 1; $count = intval($avs['totalNum']); if (!$count) { $count = count($channels); } if ($i == $start || $i > $start) { if ($i < $count) { $rs = str_replace(array('[stl.channel.id]', '[stl.channel.name]', '[stl.channel.link]', '[stl.channel.num]', '<stl:contents'), array($c->id, $c->name, $c->link, $i + intval($avs['numStart']), '<stl:contents channelIndex="' . $c->cindex . '"'), $middleStr); //current class if ($channelID == $c->id) { $rs = str_replace('[stl.channel.currentItemClass]', $avs['currentItemClass'], $rs); } else { $rs = str_replace('[stl.channel.currentItemClass]', '', $rs); } $returnStr .= $rs; } } $i++; } } //处理stl:contents if (strExists($returnStr, '<stl:contents')) { $template = bpBase::loadAppClass('template', 'template'); $now = SYS_TIME; $returnStr = $template->parseStr($returnStr, $now); @unlink(ABS_PATH . 'templatesCache' . DIRECTORY_SEPARATOR . $now . '.parsed.tpl.php'); @unlink(ABS_PATH . 'templatesCache' . DIRECTORY_SEPARATOR . $now . '.tags.tpl.php'); } // return $returnStr; }
public function __construct($name) { parent::__construct('div'); $this->class = 'osy-textsearch'; $this->id = $name; $this->add(new HiddenBox($name)); $this->textBox = $this->add(tag::create('input'))->att('type', 'text')->att('name', $name . '_lbl')->att('readonly', 'readonly'); $this->spanSrc = $this->add(tag::create('span'))->att('class', 'fa fa-search'); }
static function item_edit_form_completed($item, $form) { tag::clear_all($item); foreach (preg_split("/[,;]/", $form->edit_item->tags->value) as $tag_name) { if ($tag_name) { tag::add($item, str_replace(" ", ".", $tag_name)); } } tag::compact(); }
/** * Return a rendering of the cloud for the N most popular tags. * * @param integer $count the number of tags * @return View */ static function cloud($count) { $tags = tag::popular_tags($count)->as_array(); if ($tags) { $cloud = new View("tag_cloud.html"); $cloud->max_count = $tags[0]->count; usort($tags, array("tag_theme", "sort_by_name")); $cloud->tags = $tags; return $cloud; } }
protected function build() { if ($lp = $this->get_par('label-position')) { $this->panel->par('label-position', $lp); } if (!$this->get_par('disable-head')) { $this->title = $this->add(tag::create('div'))->att('class', 'osy-panel-mobile-title'); $this->title->add(tag::create('span'))->att('class', 'osy-win-ico-set fright')->add(' '); $this->title->add($this->get_par('label')); } }
static function extract($item) { $keys = array(); // Only try to extract IPTC from photos if ($item->is_photo() && $item->mime_type == "image/jpeg") { $info = getJpegHeader($item->file_path()); if ($info !== FALSE) { $iptcBlock = getIptcBlock($info); if ($iptcBlock !== FALSE) { $iptc = iptcparse($iptcBlock); } else { $iptc = array(); } $xmp = getXmpDom($info); foreach (self::keys() as $keyword => $iptcvar) { $iptc_key = $iptcvar[0]; $xpath = $iptcvar[2]; $value = null; if ($xpath != null) { $value = getXmpValue($xmp, $xpath); } if ($value == null) { if (!empty($iptc[$iptc_key])) { $value = implode(";", $iptc[$iptc_key]); if (function_exists("mb_detect_encoding") && mb_detect_encoding($value) != "UTF-8") { $value = utf8_encode($value); } } } if ($value != null) { $keys[$keyword] = Input::clean($value); } } } } $record = ORM::factory("iptc_record")->where("item_id", "=", $item->id)->find(); if (!$record->loaded()) { $record->item_id = $item->id; } $record->data = serialize($keys); $record->key_count = count($keys); $record->dirty = 0; $record->save(); if (array_key_exists('Keywords', $keys)) { $tags = explode(';', $keys['Keywords']); foreach ($tags as $tag) { try { tag::add($item, $tag); } catch (Exception $e) { Kohana_Log::add("error", "Error adding tag: {$tag}\n" . $e->getMessage() . "\n" . $e->getTraceAsString()); } } } }
static function relationships($resource_type, $resource) { switch ($resource_type) { case "item": $tags = array(); foreach (tag::item_tags($resource) as $tag) { $tags[] = rest::url("tag_item", $tag, $resource); } return array("tags" => array("url" => rest::url("item_tags", $resource), "members" => $tags)); } }
static function post($request) { $tag = rest::resolve($request->params->entity->tag); $item = rest::resolve($request->params->entity->item); access::required("view", $item); if (!$tag->loaded()) { throw new Kohana_404_Exception(); } tag::add($item, $tag->name); return array("url" => rest::url("tag_item", $tag, $item), "members" => array("tag" => rest::url("tag", $tag), "item" => rest::url("item", $item))); }
public function __construct($name) { parent::__construct('dummy',$name); env::$page->add_css(OSY_WEB_ROOT.'/css/leaflet.css'); env::$page->add_script(OSY_WEB_ROOT.'/js/component/omapgrid_openlayers.js'); $this->map = $this->add(tag::create('div'))->att('class','osy-mapgrid-openlayers'); $this->add(new HiddenBox($this->id.'_ne_lat')); $this->add(new HiddenBox($this->id.'_ne_lng')); $this->add(new HiddenBox($this->id.'_sw_lat')); $this->add(new HiddenBox($this->id.'_sw_lng')); $this->add(new HiddenBox($this->id.'_center')); }
public function create_tag_test() { $album = test::random_album(); tag::add($album, "tag1"); $tag = ORM::factory("tag")->where("name", "=", "tag1")->find(); $this->assert_true(1, $tag->count); // Make sure adding the tag again doesn't increase the count tag::add($album, "tag1"); $this->assert_true(1, $tag->reload()->count); tag::add(test::random_album(), "tag1"); $this->assert_true(2, $tag->reload()->count); }
protected function build() { $this->add(tag::create('ul')); //$this->iframe = $this->add(tag::create('iframe')); //$this->iframe->att('name',$this->id)->att("style",'width: 100%;'); $src = $this->get_par('src'); if (!array_key_exists($this->id, $_REQUEST) && !empty($src)) { $_REQUEST[$this->id] = $src; } if (array_key_exists($this->id, $_REQUEST) && !empty($_REQUEST[$this->id])) { $this->att('src', $_REQUEST[$this->id]); } }
/** * 动作:删除标签 * @return Response */ public function deletetag($id) { $tag = tag::findOrFail($id); $tagId = $tag->id; // 删除关联关系 ArticleTag::where('tag_id', '=', $tagId)->delete(); // 删除标签 if ($tag->delete()) { return Redirect::back()->with('success', '标签删除成功'); } else { return Redirect::back()->with('error', '标签删除失败'); } }