This repository has been archived by the owner on Nov 13, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Tag.php
executable file
·110 lines (99 loc) · 2.57 KB
/
Tag.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
<?php
/**
* @version $Id$
* @author Brian Smith <[email protected]>
* @package ABS
*/
/*
* Include the ABS Api, core classes.
*/
require_once 'Api.php';
/*
* Include the ABS Base object class, core classes.
*/
require_once 'Base.php';
class ABS_Tag extends ABS_Base {
/**
* The name of the XML element in the response that defines the object.
*
* @var string
*/
const XML_RESPONSE_ELEMENT = 'tag';
/**
* The id for a specific tag
*
* @var integer
*/
protected $_tag_id;
/**
* The name for a specific tag
*
* @var string
*/
protected $_tag_name;
function __construct(ABS_Api $api) {
parent::__construct($api, self::XML_RESPONSE_ELEMENT);
$this->__setXpath('tag/references/reference');
}
/*
* Method to return the appropriate URL ending based on the method being executed
*
* @param string $method
* @return string
* @throws ABS_Exception
*/
protected function getUrl($method) {
switch($method) {
case 'list':
return 'tags.xml';
break;
case 'usertags':
return 'user/tags.xml';
break;
case 'show':
return 'tags/' . $this->_tag_id . '.xml';
break;
case 'showbyname':
return 'tags/' . urlencode($this->_tag_name) . '.xml';
break;
default:
throw new ABS_Exception('Invalid method ' . $method);
}
}
/*
* Method to list all tags site-wide
*
* @return xml SimpleXML object
*/
public function listTags() {
return $this->requestXml('list');
}
/*
* Method to list all tags for this user
*
* @return xml SimpleXML object
*/
public function listUserTags() {
return $this->requestXml('usertags');
}
/*
* Show specific tag by id
*
* @param integer $tag_id
* @return xml SimpleXML object
*/
public function show($tag_id) {
$this->_tag_id = $tag_id;
return $this->requestXml('show');
}
/*
* Show specific tag by name
*
* @param string $tag_name
* @return xml SimpleXML object
*/
public function showByName($tag_name) {
$this->_tag_name = $tag_name;
return $this->requestXml('showbyname');
}
}