each time the edit form is displayed.
try {
$notify = true;
$result = false;
-
+
switch ($action) {
case 'ListEvents':
$start = new Horde_Date(Util::getFormData('start'));
$result->events = $events;
}
break;
-
+
case 'GetEvent':
if (!($kronolith_driver = getDriver($cal = Util::getFormData('cal')))) {
$result = true;
$result = new stdClass;
$result->event = $event->toJSON(true, $prefs->getValue('twentyFour') ? 'H:i' : 'h:i A');
break;
-
+
case 'SaveEvent':
$cal = Util::getFormData('cal');
if (!($kronolith_driver = getDriver($cal))) {
$result->events = $events;
}
break;
-
+
case 'UpdateEvent':
if (!($kronolith_driver = getDriver($cal = Util::getFormData('cal')))) {
break;
$notification->push($result, 'horde.error');
}
break;
-
+
case 'DeleteEvent':
if (!($kronolith_driver = getDriver($cal = Util::getFormData('cal')))) {
$result = true;
$result = new stdClass;
$result->deleted = true;
break;
-
+
case 'SaveCalPref':
$result = true;
break;
-
+
case 'ChunkContent':
$chunk = basename(Util::getPost('chunk'));
if (!empty($chunk)) {
$result->chunk = Util::bufferOutput('include', KRONOLITH_TEMPLATES . '/chunks/' . $chunk . '.php');
}
break;
+
+ case 'ListTopTags':
+ $tagger = new Kronolith_Tagger();
+ $result = new stdClass;
+ $result->tags = array();
+ $tags = $tagger->getCloud(Auth::getAuth(), 10);
+ foreach ($tags as $tag) {
+ $result->tags[] = $tag['tag_name'];
+ }
+ break;
}
} catch (Exception $e) {
$notification->push($e->getMessage(), 'horde.error');
if (id) {
RedBox.loading();
+ this.doAction('ListTopTags', {}, this._topTags.bind(this));
this.doAction('GetEvent', { 'cal': calendar, 'id': id }, this._editEvent.bind(this));
} else {
+ this.doAction('ListTopTags', {}, this._topTags.bind(this));
var d = new Date();
$('kronolithEventForm').enable();
$('kronolithEventForm').reset();
this.eventForm = RedBox.getWindowContents();
}
},
-
+
+ _topTags: function(r)
+ {
+ if (!r.response.tags) {
+ return;
+ }
+ $('eventTopTags').update();
+ r.response.tags.each(function(tag) {
+ $('eventTopTags').insert(new Element('span').update(tag));
+ });
+ return;
+ },
+
/**
* Callback method for showing event forms.
*
$this->tag($localId, $add, $content_type);
}
-
/**
* @TODO
* @param array $tags An array of tag ids.
//TODO
}
+ /**
+ * List tags beginning with $token. Used for autocomplete code.
+ *
+ * @param $token
+ * @return unknown_type
+ */
public function listTags($token)
{
return self::$_tagger->getTags(array('q' => $token));
}
+ public function getCloud($user, $limit = 5)
+ {
+ return self::$_tagger->getTagCloud(array('userId' => $user,
+ 'limit' => $limit));
+ }
}
<textarea name="tags" id="kronolithEventTags" rows="2" class="kronolithLongField"></textarea>
</div>
-<div class="kronolithTags">
- <span>portugal</span>
- <span>política</span>
- <span>religião</span>
- <span>outra</span>
- <span>informática</span>
- <span>lálá</span>
-</div>
+<div id="eventTopTags" class="kronolithTags"></div>
<div id="kronolithEventActions">
<input id="kronolithEventSave" type="button" value="<?php echo _("Save") ?>" class="button ok" />