Esempio n. 1
0
 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());
 }
Esempio n. 2
0
 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));
 }
Esempio n. 3
0
 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 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));
 }
Esempio n. 5
0
  /**
   * 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;
  }
Esempio n. 6
0
 /**
  * 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;
 }
Esempio n. 7
0
 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)));
 }
 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());
 }
Esempio n. 9
0
 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();
 }
Esempio n. 10
0
 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();
 }
Esempio n. 11
0
 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());
             }
         }
     }
 }
Esempio n. 12
0
 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)));
 }
Esempio n. 13
0
 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));
 }
Esempio n. 14
0
 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()));
     }
 }
Esempio n. 15
0
 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);
 }
Esempio n. 16
0
 static function tag_item($item)
 {
     if (!$item->is_album() && $item->captured) {
         $date_format = module::get_var("date_tag", "template");
         foreach (explode(",", date($date_format, $item->captured)) as $tag_name) {
             $tag_name = trim($tag_name);
             if ($tag_name) {
                 tag::add($item, $tag_name);
             }
         }
     }
     return;
 }
Esempio n. 17
0
 public function rename_merge_tag_with_same_items_test()
 {
     $album = test::random_album();
     tag::add($album, "tag1");
     tag::add($album, "tag2");
     $tag1 = ORM::factory("tag")->where("name", "=", "tag1")->find();
     $tag1->name = "tag2";
     $tag1->save();
     // Tags should be merged
     $tag1->reload();
     $this->assert_equal(1, $tag1->count);
     $this->assert_true($tag1->has($album));
     $this->assert_equal(1, ORM::factory("tag")->count_all());
 }
Esempio n. 18
0
 public function create($item_id)
 {
     $item = ORM::factory("item", $item_id);
     access::required("view", $item);
     access::required("edit", $item);
     $form = tag::get_add_form($item);
     if ($form->validate()) {
         foreach (explode(",", $form->add_tag->inputs["name"]->value) as $tag_name) {
             $tag_name = trim($tag_name);
             if ($tag_name) {
                 $tag = tag::add($item, $tag_name);
             }
         }
         print json_encode(array("result" => "success", "cloud" => (string) tag::cloud(30)));
     } else {
         print json_encode(array("result" => "error", "form" => (string) $form));
     }
 }
Esempio n. 19
0
 public function create_tag_test()
 {
     $rand = rand();
     $root = ORM::factory("item", 1);
     $album = album::create($root, $rand, $rand, $rand);
     $tag1 = "tag1";
     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);
     $tag = ORM::factory("tag")->where("name", $tag1)->find();
     $this->assert_true(1, $tag->count);
     $rand = rand();
     $album = album::create($root, $rand, $rand, $rand);
     tag::add($album, $tag1);
     $tag = ORM::factory("tag")->where("name", $tag1)->find();
     $this->assert_true(2, $tag->count);
 }
Esempio n. 20
0
 /**
  * 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)
 {
     if ($photo->is_photo()) {
         $path = $photo->file_path();
         $tags = array();
         $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) {
                     $tags[$tag] = 1;
                 }
             }
         }
     }
     // @todo figure out how to read the keywords from xmp
     foreach (array_keys($tags) as $tag) {
         tag::add($photo, $tag);
     }
     return;
 }
Esempio n. 21
0
 public function tagitems()
 {
     // Tag all non-album items in the current album with the specified tags.
     // Prevent Cross Site Request Forgery
     access::verify_csrf();
     $input = Input::instance();
     // Figure out if the contents of sub-albums should also be tagged
     $str_tag_subitems = $input->post("tag_subitems");
     $children = "";
     if ($str_tag_subitems == false) {
         // Generate an array of all non-album items in the current album.
         $children = ORM::factory("item")->where("parent_id", "=", $input->post("item_id"))->where("type", "!=", "album")->find_all();
     } else {
         // Generate an array of all non-album items in the current album
         //   and any sub albums.
         $item = ORM::factory("item", $input->post("item_id"));
         $children = $item->descendants();
     }
     // 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) && !$child->is_album()) {
             // Assuming the user can view/edit the current item, loop
             //   through each tag that was submitted and apply it to
             //   the current item.
             foreach (explode(",", $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", $input->post("item_id"));
     url::redirect(url::abs_site("{$item->type}s/{$item->id}"));
 }
Esempio n. 22
0
 public function tagitems2()
 {
     // Tag all non-album items in the current album with the specified tags.
     // Prevent Cross Site Request Forgery
     access::verify_csrf();
     $input = Input::instance();
     // Variables
     if ($input->get("batchtag_max") == false || $input->get("batchtag_max") == "0") {
         $batchtag_max = "50";
     } else {
         $batchtag_max = $input->get("batchtag_max");
     }
     if ($input->get("batchtag_items_processed") == false) {
         $batchtag_items_processed = "0";
     } else {
         $batchtag_items_processed = $input->get("batchtag_items_processed");
     }
     // Figure out if the contents of sub-albums should also be tagged
     $str_tag_subitems = $input->get("tag_subitems");
     $children = "";
     if ($str_tag_subitems == false) {
         // Generate an array of all non-album items in the current album.
         $children = ORM::factory("item")->where("parent_id", "=", $input->get("item_id"))->where("type", "!=", "album")->find_all();
     } else {
         // Generate an array of all non-album items in the current album
         //   and any sub albums.
         $item = ORM::factory("item", $input->get("item_id"));
         $children = $item->descendants();
     }
     // Loop through each item in the album and make sure the user has
     //   access to view and edit it.
     $children_count = "0";
     $tag_count = "0";
     //echo Kohana::debug($children);
     echo '<style>.continue { margin: 5em auto; text-align: center; }</style>';
     foreach ($children as $child) {
         if ($tag_count < $batchtag_max) {
             if ($children_count >= $batchtag_items_processed) {
                 if (access::can("view", $child) && access::can("edit", $child) && !$child->is_album()) {
                     // Assuming the user can view/edit the current item, loop
                     //   through each tag that was submitted and apply it to
                     //   the current item.
                     foreach (explode(",", $input->get("name")) as $tag_name) {
                         $tag_name = trim($tag_name);
                         if ($tag_name) {
                             tag::add($child, $tag_name);
                         }
                         // $tag_count should be inside the foreach loop as it is depending on the number of time tag:add is run
                         $tag_count++;
                     }
                 }
                 echo '<style>.c' . $children_count . ' { display:none; }</style>' . "\n";
                 $children_count++;
                 $batchtag_max_new = $tag_count;
                 echo '<div class="continue c' . $children_count . '"><a href="' . url::abs_site("batchtag/tagitems2?name={$input->get('name')}&item_id={$input->get('item_id')}&tag_subitems={$input->get('tag_subitems')}&batchtag_items_processed={$children_count}&batchtag_max={$batchtag_max_new}&csrf={$input->get('csrf')}") . '">Continue</a></div>';
             } else {
                 $children_count++;
             }
         } else {
             break;
         }
     }
     if ($tag_count < $batchtag_max) {
         // Redirect back to the album.
         $item = ORM::factory("item", $input->get("item_id"));
         url::redirect(url::abs_site("{$item->type}s/{$item->id}"));
         //echo url::abs_site("{$item->type}s/{$item->id}");
     } else {
         url::redirect(url::abs_site("batchtag/tagitems2?name={$input->get('name')}&item_id={$input->get('item_id')}&tag_subitems={$input->get('tag_subitems')}&batchtag_items_processed={$children_count}&batchtag_max={$batchtag_max}&csrf={$input->get('csrf')}"));
         //echo url::abs_site("batchtag/tagitems2?name={$input->get('name')}&item_id={$input->get('item_id')}&tag_subitems={$input->get('tag_subitems')}&batchtag_items_processed=$children_count&batchtag_max=$batchtag_max&csrf={$input->get('csrf')}");
     }
 }
Esempio n. 23
0
 static function import_keywords_as_tags($keywords, $item)
 {
     // Keywords in G2 are free form.  So we don't know what our user used as a separator.  Try to
     // be smart about it.  If we see a comma or a semicolon, expect the keywords to be separated
     // by that delimeter.  Otherwise, use space as the delimiter.
     if (strpos($keywords, ";")) {
         $delim = ";";
     } else {
         if (strpos($keywords, ",")) {
             $delim = ",";
         } else {
             $delim = " ";
         }
     }
     $tags = "";
     foreach (preg_split("/{$delim}/", $keywords) as $keyword) {
         $keyword = trim($keyword);
         if ($keyword) {
             $tags .= (strlen($tags) ? ", " : "") . tag::add($item, $keyword);
         }
     }
 }
Esempio n. 24
0
 static function import_keywords_as_tags($keywords, $item)
 {
     if (!module::is_active("tag")) {
         return;
     }
     foreach (preg_split("/[,;]/", $keywords) as $keyword) {
         $keyword = trim($keyword);
         if ($keyword) {
             tag::add($item, $keyword);
         }
     }
 }
Esempio n. 25
0
 private static function _add_tag()
 {
     $items = ORM::factory("item")->find_all()->as_array();
     if (!empty($items)) {
         $tags = self::_generateTags();
         $tag_name = $tags[array_rand($tags)];
         $item = $items[array_rand($items)];
         tag::add($item, $tag_name);
     }
 }
Esempio n. 26
0
 static function add_photos_form_completed($album, $form)
 {
     foreach (explode(",", $form->add_photos->tags->value) as $tag_name) {
         $tag_name = trim($tag_name);
         if ($tag_name) {
             $tag = tag::add($album, $tag_name);
         }
     }
 }
Esempio n. 27
0
 function do_save($callback = false)
 {
     $aid = (int) $_POST['aid'];
     $cid = (int) $_POST['cid'];
     $userid = (int) $_POST['userid'];
     $scid = implode(',', (array) $_POST['scid']);
     $pid = implode(',', (array) $_POST['pid']);
     $status = (int) $_POST['status'];
     $chapter = (int) $_POST['chapter'];
     $ordernum = _int($_POST['ordernum']);
     $_cid = iS::escapeStr($_POST['_cid']);
     $_pid = iS::escapeStr($_POST['_pid']);
     $_scid = iS::escapeStr($_POST['_scid']);
     $_tags = iS::escapeStr($_POST['_tags']);
     $title = iS::escapeStr($_POST['title']);
     $stitle = iS::escapeStr($_POST['stitle']);
     $pic = iS::escapeStr($_POST['pic']);
     $mpic = iS::escapeStr($_POST['mpic']);
     $spic = iS::escapeStr($_POST['spic']);
     $source = iS::escapeStr($_POST['source']);
     $author = iS::escapeStr($_POST['author']);
     $editor = iS::escapeStr($_POST['editor']);
     $description = iS::escapeStr($_POST['description']);
     $keywords = iS::escapeStr($_POST['keywords']);
     $tags = str_replace(',', ',', iS::escapeStr($_POST['tags']));
     $clink = iS::escapeStr($_POST['clink']);
     $url = iS::escapeStr($_POST['url']);
     $tpl = iS::escapeStr($_POST['tpl']);
     $metadata = iS::escapeStr($_POST['metadata']);
     $metadata = $metadata ? addslashes(serialize($metadata)) : '';
     $body = (array) $_POST['body'];
     $creative = (int) $_POST['creative'];
     iACP::CP($cid, $aid ? 'ce' : 'ca', 'alert');
     empty($_POST['pubdate']) && ($_POST['pubdate'] = get_date(0, 'Y-m-d H:i:s'));
     $pubdate = iPHP::str2time($_POST['pubdate']);
     $weight = _int($_POST['weight']);
     $postype = $_POST['postype'] ? $_POST['postype'] : 0;
     $ischapter = isset($_POST['ischapter']) ? 1 : 0;
     isset($_POST['inbox']) && ($status = "0");
     $tags && ($tags = preg_replace('/<[\\/\\!]*?[^<>]*?>/is', '', $tags));
     empty($title) && iPHP::alert('标题不能为空!');
     empty($cid) && iPHP::alert('请选择所属栏目');
     empty($body) && empty($url) && iPHP::alert('文章内容不能为空!');
     $userid or $userid = iMember::$userid;
     iFS::$userid = $userid;
     if (empty($aid) && iCMS::$config['publish']['repeatitle']) {
         articleTable::check_title($title) && iPHP::alert('该标题的文章已经存在!请检查是否重复');
     }
     if (strstr($this->category[$cid]['contentRule'], '{LINK}') !== false) {
         empty($clink) && ($clink = strtolower(pinyin($title)));
         if (empty($aid) && $clink) {
             articleTable::check_clink($clink) && iPHP::alert('该文章自定义链接已经存在!请检查是否重复');
         }
     }
     if (empty($description) && empty($url)) {
         $description = $this->autodesc($body);
     }
     stripos($pic, 'http://') === false or $pic = iFS::http($pic);
     stripos($mpic, 'http://') === false or $mpic = iFS::http($mpic);
     stripos($spic, 'http://') === false or $spic = iFS::http($spic);
     $haspic = empty($pic) ? 0 : 1;
     $SELFURL = __SELF__ . $_POST['REFERER'];
     if (empty($_POST['REFERER']) || strstr($_POST['REFERER'], '=save')) {
         $SELFURL = __SELF__ . '?app=article&do=manage';
     }
     $editor or $editor = empty(iMember::$data->nickname) ? iMember::$data->username : iMember::$data->nickname;
     // if($aid && $ischapter){
     //     $this->article_data($body,$aid);
     //     iDB::query("UPDATE `#iCMS@__article` SET `chapter`=chapter+1  WHERE `id` = '$aid'");
     //     iPHP::success('章节添加完成!','url:'.$SELFURL);
     // }
     iPHP::import(iPHP_APP_CORE . '/iMAP.class.php');
     $picdata = '';
     $ucid = 0;
     $fields = articleTable::fields($aid);
     if (empty($aid)) {
         $postime = $pubdate;
         $hits = 0;
         $good = $bad = $comments = 0;
         $ischapter && ($chapter = 1);
         $mobile = 0;
         $aid = articleTable::insert(compact($fields));
         if ($this->callback['primary']) {
             $PCB = $this->callback['primary'];
             $handler = $PCB[0];
             $params = (array) $PCB[1] + array('indexid' => $aid);
             if (is_callable($handler)) {
                 call_user_func_array($handler, $params);
             }
         }
         if ($tags) {
             iPHP::app('tag.class', 'static');
             tag::add($tags, $userid, $aid, $cid);
             //articleTable::update(compact('tags'),array('id'=>$aid));
         }
         map::init('prop', $this->appid);
         $pid && map::add($pid, $aid);
         map::init('category', $this->appid);
         map::add($cid, $aid);
         $scid && map::add($scid, $aid);
         $tagArray && tag::map_iid($tagArray, $aid);
         $url or $this->article_data($body, $aid, $haspic);
         $this->categoryApp->update_count_one($cid);
         $article_url = iURL::get('article', array(array('id' => $aid, 'url' => $url, 'cid' => $cid, 'pubdate' => $pubdate), $this->category[$cid]))->href;
         if ($status && iCMS::$config['api']['baidu']['sitemap']['sync']) {
             baidu_ping($article_url);
         }
         if ($callback) {
             return array("code" => $callback, 'indexid' => $aid);
         }
         $moreBtn = array(array("text" => "查看该文章", "target" => '_blank', "url" => $article_url, "o" => 'target="_blank"'), array("text" => "编辑该文章", "url" => APP_URI . "&do=add&id=" . $aid), array("text" => "继续添加文章", "url" => APP_URI . "&do=add&cid=" . $cid), array("text" => "返回文章列表", "url" => $SELFURL), array("text" => "查看网站首页", "url" => iCMS_URL, "target" => '_blank'));
         iPHP::$dialog['lock'] = true;
         iPHP::dialog('success:#:check:#:文章添加完成!<br />10秒后返回文章列表', 'url:' . $SELFURL, 10, $moreBtn);
     } else {
         if ($tags) {
             iPHP::app('tag.class', 'static');
             tag::diff($tags, $_tags, iMember::$userid, $aid, $cid);
         }
         $picdata = $this->picdata($pic, $mpic, $spic);
         articleTable::update(compact($fields), array('id' => $aid));
         if ($this->callback['primary']) {
             $PCB = $this->callback['primary'];
             $handler = $PCB[0];
             $params = (array) $PCB[1] + array('indexid' => $aid);
             if (is_callable($handler)) {
                 call_user_func_array($handler, $params);
             }
         }
         map::init('prop', $this->appid);
         map::diff($pid, $_pid, $aid);
         map::init('category', $this->appid);
         map::diff($cid, $_cid, $aid);
         map::diff($scid, $_scid, $aid);
         $url or $this->article_data($body, $aid, $haspic);
         //$ischapter && $this->chapter_count($aid);
         if ($_cid != $cid) {
             $this->categoryApp->update_count_one($_cid, '-');
             $this->categoryApp->update_count_one($cid);
         }
         if ($callback) {
             return array("code" => $callback, 'indexid' => $aid);
         }
         //       if(!strstr($this->category[$cid]['contentRule'],'{PHP}')&&!$this->category[$cid]['url']&&$this->category[$cid]['mode']=="1" && $status) {
         // 	$htmlApp = iACP::app('html');
         // 	$htmlApp->Article($aid);
         // }
         iPHP::success('文章编辑完成!<br />3秒后返回文章列表', 'url:' . $SELFURL);
     }
 }
Esempio n. 28
0
 static function add_photos_form_completed($album, $form)
 {
     $group = $form->add_photos;
     if (!is_object($group->uploadify)) {
         return;
     }
     foreach (explode(",", $form->add_photos->tags->value) as $tag_name) {
         $tag_name = trim($tag_name);
         if ($tag_name) {
             $tag = tag::add($album, $tag_name);
         }
     }
 }
Esempio n. 29
0
 function add_tags($count)
 {
     $items = ORM::factory("item")->find_all()->as_array();
     if (!empty($items)) {
         $tags = $this->_generateTags($count);
         while ($count-- > 0) {
             $tag_name = $tags[array_rand($tags)];
             $item = $items[array_rand($items)];
             tag::add($item, $tag_name);
         }
     }
     url::redirect("scaffold");
 }
Esempio n. 30
0
 private function _copy_items_for_tags($tag, $tag_list)
 {
     foreach ($tag->items() as $item) {
         foreach ($tag_list as $new_tag_name) {
             tag::add($item, trim($new_tag_name));
         }
     }
 }