function resortTagItems($dir = 'DESC') { $tag_item = new Dase_DBO_TagItem($this->db); $tag_item->tag_id = $this->id; $tag_item->orderBy('sort_order, updated ' . $dir); $i = 0; foreach ($tag_item->find() as $ti) { $i++; $ti->sort_order = $i; $ti->updated = date(DATE_ATOM); $ti->update(); } }
public function getTags() { $tags = array(); $tag_item = new Dase_DBO_TagItem($this->db); $tag_item->item_id = $this->id; foreach ($tag_item->find() as $ti) { $tags[] = $ti->getTag(); } if (count($tags)) { return $tags; } else { return false; } }
<?php include 'config.php'; //this script replaces characters which are valid utf8 //but invalid in XML (there are just a few) $tis = new Dase_DBO_TagItem($db); foreach ($tis->find() as $ti) { if ($ti->annotation != strip_invalid_xml_chars2($ti->annotation)) { $tag = $ti->getTag(); print $tag->ascii_id . "\n"; //$ti->annotation = strip_invalid_xml_chars2($ti->annotation); //$ti->update(); file_put_contents('bad', $ti->annotation); print "found bad xml in tag_item {$ti->id}\n"; print $tag->dase_user_id . "\n"; //print $ti->annotation."\n"; } } function strip_invalid_xml_chars2($in) { $out = ""; $length = strlen($in); for ($i = 0; $i < $length; $i++) { $current = ord($in[$i]); if ($current == 0x9 || $current == 0xa || $current == 0xd || $current >= 0x20 && $current <= 0xd7ff || $current >= 0xe000 && $current <= 0xfffd || $current >= 0x10000 && $current <= 0x10ffff) { $out .= chr($current); } else { print $current . "\n"; $out .= " "; } }