当前位置: 首页>>代码示例>>PHP>>正文


PHP tag::add方法代码示例

本文整理汇总了PHP中tag::add方法的典型用法代码示例。如果您正苦于以下问题:PHP tag::add方法的具体用法?PHP tag::add怎么用?PHP tag::add使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在tag的用法示例。


在下文中一共展示了tag::add方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: 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());
 }
开发者ID:webmatter,项目名称:gallery3-contrib,代码行数:35,代码来源:captionator.php

示例2: 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));
 }
开发者ID:kandsten,项目名称:gallery3,代码行数:7,代码来源:Tag_Rest_Helper_Test.php

示例3: 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}"));
 }
开发者ID:kuranoglu,项目名称:gallery3-contrib,代码行数:26,代码来源:batchtag.php

示例4: 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));
 }
开发者ID:assad2012,项目名称:gallery3-appfog,代码行数:7,代码来源:Tags_Rest_Helper_Test.php

示例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("\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;
  }
开发者ID:HelixiR,项目名称:gallery3,代码行数:37,代码来源:tag_event.php

示例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("", "", $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;
 }
开发者ID:xafr,项目名称:gallery3,代码行数:31,代码来源:tag_event.php

示例7: post

 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)));
 }
开发者ID:kandsten,项目名称:gallery3,代码行数:8,代码来源:item_tags_rest.php

示例8: resolve_test

 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());
 }
开发者ID:andyst,项目名称:gallery3,代码行数:8,代码来源:Tag_Item_Rest_Helper_Test.php

示例9: item_edit_form_completed

 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, trim($tag_name));
         }
     }
     tag::compact();
 }
开发者ID:eo04837,项目名称:gallery3,代码行数:10,代码来源:tag_event.php

示例10: item_edit_form_completed

 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();
 }
开发者ID:jasonhight,项目名称:gallery3,代码行数:10,代码来源:tag_event.php

示例11: extract

 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());
             }
         }
     }
 }
开发者ID:webmatter,项目名称:gallery3-contrib,代码行数:54,代码来源:iptc.php

示例12: post

 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)));
 }
开发者ID:JasonWiki,项目名称:docs,代码行数:11,代码来源:tag_items_rest.php

示例13: post

 static function post($request)
 {
     if (empty($request->params->url)) {
         throw new Rest_Exception("Bad request", 400);
     }
     $tag = rest::resolve($request->url);
     $item = rest::resolve($request->params->url);
     access::required("edit", $item);
     tag::add($item, $tag->name);
     return array("url" => rest::url("tag_item", $tag, $item));
 }
开发者ID:andyst,项目名称:gallery3,代码行数:11,代码来源:tag_rest.php

示例14: _create

 public function _create($tag)
 {
     $item = ORM::factory("item", $this->input->post("item_id"));
     access::required("edit", $item);
     $form = tag::get_add_form($item);
     if ($form->validate()) {
         tag::add($item, $form->add_tag->inputs["name"]->value);
         print json_encode(array("result" => "success", "resource" => url::site("tags/{$tag->id}"), "form" => tag::get_add_form($item)->__toString()));
     } else {
         print json_encode(array("result" => "error", "form" => $form->__toString()));
     }
 }
开发者ID:Juuro,项目名称:Dreamapp-Website,代码行数:12,代码来源:tags.php

示例15: create_tag_test

 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);
 }
开发者ID:Joe7,项目名称:gallery3,代码行数:12,代码来源:Tag_Test.php


注:本文中的tag::add方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。