| 1 | <?php |
|---|
| 2 | |
|---|
| 3 | require_once(IA_ROOT_DIR."common/db/tags.php"); |
|---|
| 4 | |
|---|
| 5 | function blog_get_range($tag_name, $start, $range) { |
|---|
| 6 | if (is_tag_name($tag_name)) { |
|---|
| 7 | $tag_id = tag_get_id(array( |
|---|
| 8 | "name" => $tag_name, "type" => "tag", "parent" => 0)); |
|---|
| 9 | if (is_null($tag_id)) { |
|---|
| 10 | $tag_id = -1; |
|---|
| 11 | } |
|---|
| 12 | $where = tag_build_where("textblock", array($tag_id)); |
|---|
| 13 | } else { |
|---|
| 14 | $where = "TRUE"; |
|---|
| 15 | } |
|---|
| 16 | $query = sprintf("SELECT * FROM ia_textblock |
|---|
| 17 | WHERE %s AND name LIKE 'blog/%%' |
|---|
| 18 | AND security <> 'private' |
|---|
| 19 | ORDER BY ia_textblock.creation_timestamp DESC |
|---|
| 20 | LIMIT %s, %s", |
|---|
| 21 | $where, db_quote((int)$start), db_quote((int)$range)); |
|---|
| 22 | return db_fetch_all($query); |
|---|
| 23 | } |
|---|
| 24 | |
|---|
| 25 | function blog_get_forum_topic($name) { |
|---|
| 26 | $query = sprintf("SELECT `forum_topic` FROM ia_textblock |
|---|
| 27 | WHERE name = '%s'", db_escape($name)); |
|---|
| 28 | $result = db_fetch($query); |
|---|
| 29 | return $result['forum_topic']; |
|---|
| 30 | } |
|---|
| 31 | |
|---|
| 32 | function blog_get_comment_count($topic_id) { |
|---|
| 33 | $query = sprintf("SELECT `numReplies` FROM ia_smf_topics |
|---|
| 34 | WHERE ID_TOPIC = %d", db_escape($topic_id)); |
|---|
| 35 | $result = db_fetch($query); |
|---|
| 36 | return $result['numReplies']; |
|---|
| 37 | } |
|---|
| 38 | |
|---|
| 39 | function blog_count($tag_name) { |
|---|
| 40 | if (is_tag_name($tag_name)) { |
|---|
| 41 | $tag_id = tag_get_id(array( |
|---|
| 42 | "name" => $tag_name, "type" => "tag", "parent" => 0)); |
|---|
| 43 | if (is_null($tag_id)) { |
|---|
| 44 | $tag_id = -1; |
|---|
| 45 | } |
|---|
| 46 | $where = tag_build_where("textblock", array($tag_id)); |
|---|
| 47 | } else { |
|---|
| 48 | $where = "TRUE"; |
|---|
| 49 | } |
|---|
| 50 | $query = sprintf("SELECT COUNT(*) as `cnt` FROM ia_textblock WHERE %s |
|---|
| 51 | AND name LIKE 'blog/%%' |
|---|
| 52 | AND security <> 'private'", $where); |
|---|
| 53 | $result = db_fetch($query); |
|---|
| 54 | return $result['cnt']; |
|---|
| 55 | } |
|---|
| 56 | |
|---|
| 57 | function blog_get_tags() { |
|---|
| 58 | $query = "SELECT name, |
|---|
| 59 | (SELECT COUNT(*) FROM ia_textblock_tags WHERE tag_id = id AND textblock_id LIKE 'blog/%%') AS cnt |
|---|
| 60 | FROM ia_tags WHERE id IN |
|---|
| 61 | (SELECT DISTINCT tag_id FROM ia_textblock_tags WHERE textblock_id LIKE 'blog/%%') |
|---|
| 62 | ORDER BY name"; |
|---|
| 63 | return db_fetch_all($query); |
|---|
| 64 | } |
|---|
| 65 | ?> |
|---|