View Issue Details
| ID | Project | Category | View Status | Date Submitted | Last Update |
|---|---|---|---|---|---|
| 877 | RackTables | default | public | 2013-06-03 13:18 | 2013-07-08 08:47 |
| Reporter | blaza-pl | Assigned To | infrastation | ||
| Priority | low | Severity | feature | Reproducibility | always |
| Status | closed | Resolution | no change required | ||
| Product Version | 0.20.4 | ||||
| Summary | 877: Add a new Atrribute type - hyperlink | ||||
| Description | I have created a patch that adds a new attribute type "hyperlink". When displayed it is shortened to domain name and presented as click-able hyperlink. Maybe this will be useful for someone :) | ||||
| Tags | No tags attached. | ||||
| Attached Files | hyperlink.attribute_database.php.patch (660 bytes)
--- ../racktables-test/inc/database.php 2013-04-16 11:41:11.453761272 +0200
+++ inc/database.php 2013-06-03 11:34:06.509136282 +0200
@@ -3405,6 +3405,9 @@
case 'date':
$record['value'] = $row['uint_value'];
break;
+ case 'hyperlink':
+ $record['value'] = $row['string_value'];
+ break;
default:
$record['value'] = NULL;
break;
@@ -3453,6 +3456,9 @@
case 'date':
$column = 'uint_value';
break;
+ case 'hyperlink':
+ $column = 'string_value';
+ break;
default:
throw new InvalidArgException ('$attr_type', $attr_type, 'Unknown attribute type found in object #'.$object_id.', attribute #'.$attr_id);
}
hyperlink.attribute_functions.php.patch (542 bytes)
--- inc/functions.php 2013-05-06 11:45:26.245151170 +0200
+++ inc/functions.php 2013-06-03 11:05:47.645145790 +0200
@@ -319,7 +319,7 @@
return $_REQUEST[$argname];
case 'enum/attr_type':
assertStringArg ($argname);
- if (!in_array ($sic[$argname], array ('uint', 'float', 'string', 'dict','date')))
+ if (!in_array ($sic[$argname], array ('uint', 'float', 'string', 'dict','date','hyperlink')))
throw new InvalidRequestArgException ($argname, $sic[$argname], 'Unknown value');
return $sic[$argname];
case 'enum/vlan_type':
hyperlink.attribute_interface.php.patch (2,817 bytes)
--- inc/interface.php 2013-06-03 12:55:11.889132843 +0200
+++ inc/interface.php 2013-06-03 11:47:35.569256778 +0200
@@ -75,7 +75,8 @@
'float' => '[F] floating point',
'string' => '[S] string',
'dict' => '[D] dictionary record',
- 'date' => '[T] date'
+ 'date' => '[T] date',
+ 'hyperlink' => '[H] hyperlink string'
);
$quick_links = NULL; // you can override this in your local.php, but first initialize it with getConfiguredQuickLinks()
@@ -905,6 +908,7 @@
case 'uint':
case 'float':
case 'string':
+ case 'hyperlink':
echo "<input type=text name=${i}_value value='${record['value']}'>";
break;
case 'dict':
@@ -998,6 +1002,7 @@
case 'uint':
case 'float':
case 'string':
+ case 'hyperlink':
echo "<input type=text name=${i}_value value='${record['value']}'>";
break;
case 'dict':
@@ -1178,12 +1183,21 @@
if ($info['has_problems'] == 'yes')
$summary[] = array ('<tr><td colspan=2 class=msg_error>Has problems</td></tr>');
foreach (getAttrValues ($object_id) as $record)
+ {
+ if($record['type'] == "hyperlink" )
+ {
+ preg_match('@^(?:http[s]*://)?([^/]+)@i',$record['value'], $matches);
+ $record['href'] = $record['value'];
+ $record['a_value'] = $matches[1];
+ }
+
if
(
strlen ($record['value']) and
permitted (NULL, NULL, NULL, array (array ('tag' => '$attr_' . $record['id'])))
)
$summary['{sticker}' . $record['name']] = formatAttributeValue ($record);
+ }
$summary[] = array (getOutputOf ('printTagTRs',
$info,
makeHref
@@ -3817,12 +3831,21 @@
if ($locationData['has_problems'] == 'yes')
$summary[] = array ('<tr><td colspan=2 class=msg_error>Has problems</td></tr>');
foreach (getAttrValues ($locationData['id']) as $record)
+ {
+ if($record['type'] == "hyperlink" )
+ {
+ preg_match('@^(?:http[s]*://)?([^/]+)@i',$record['value'], $matches);
+ $record['href'] = $record['value'];
+ $record['a_value'] = $matches[1];
+ }
+
if
(
$record['value'] != '' and
permitted (NULL, NULL, NULL, array (array ('tag' => '$attr_' . $record['id'])))
)
$summary['{sticker}' . $record['name']] = formatAttributeValue ($record);
+ }
$summary['tags'] = '';
if (strlen ($locationData['comment']))
$summary['Comment'] = $locationData['comment'];
@@ -3893,6 +3916,7 @@
case 'uint':
case 'float':
case 'string':
+ case 'hyperlink':
echo "<input type=text name=${i}_value value='${record['value']}'>";
break;
case 'dict':
@@ -4209,6 +4233,7 @@
$shortType['string'] = 'S';
$shortType['dict'] = 'D';
$shortType['date'] = 'T';
+ $shortType['hyperlink'] = 'H';
foreach ($attrMap as $attr)
echo "<option value=${attr['id']}>[" . $shortType[$attr['type']] . "] ${attr['name']}</option>";
echo "</select></td><td class=tdleft>";
| ||||
|
Could you explain how this is better than the existing wiki-style links in "string" attributes? For example: [[ example | http://example.com/ ]] would be rendered as clickable "example". |
|
| My bad. I must say I haven't found this feature earlier. So I think my feature can be dismissed :) | |
| No problem. Closing. | |
| Date Modified | Username | Field | Change |
|---|---|---|---|
| 2013-06-03 13:18 | blaza-pl | New Issue | |
| 2013-06-03 13:18 | blaza-pl | File Added: hyperlink.attribute_database.php.patch | |
| 2013-06-03 13:18 | blaza-pl | File Added: hyperlink.attribute_functions.php.patch | |
| 2013-06-03 13:18 | blaza-pl | File Added: hyperlink.attribute_interface.php.patch | |
| 2013-06-03 13:18 | blaza-pl | File Added: hyperlink.sql | |
| 2013-07-07 11:45 | infrastation | Note Added: 0001583 | |
| 2013-07-07 11:45 | infrastation | Assigned To | => infrastation |
| 2013-07-07 11:45 | infrastation | Status | new => feedback |
| 2013-07-08 07:10 | blaza-pl | Note Added: 0001585 | |
| 2013-07-08 07:10 | blaza-pl | Status | feedback => assigned |
| 2013-07-08 08:47 | infrastation | Note Added: 0001587 | |
| 2013-07-08 08:47 | infrastation | Status | assigned => closed |
| 2013-07-08 08:47 | infrastation | Resolution | open => no change required |