Response::fail("Applying the template failed. Reason: " . $e->getMessage()); } Response::done(array('cgs' => Appearances::getColorsHTML($Appearance, NOWRAP, !$AppearancePage, $AppearancePage))); break; default: CoreUtils::notFound(); } } else { if (preg_match(new RegExp('^([gs]et|make|del|merge|recount|(?:un)?synon)tag(?:/(\\d+))?$'), $data, $_match)) { $action = $_match[1]; if ($action === 'recount') { $tagIDs = (new Input('tagids', 'int[]', array(Input::CUSTOM_ERROR_MESSAGES => array(Input::ERROR_MISSING => 'Missing list of tags to update', Input::ERROR_INVALID => 'List of tags is invalid'))))->out(); $counts = array(); $updates = 0; foreach ($tagIDs as $tid) { if (Tags::getActual($tid, 'tid', RETURN_AS_BOOL)) { $result = Tags::updateUses($tid, true); if ($result['status']) { $updates++; } $counts[$tid] = $result['count']; } } Response::success(!$updates ? 'There was no change in the tag usage counts' : "{$updates} tag" . ($updates !== 1 ? "s'" : "'s") . ' use count' . ($updates !== 1 ? 's were' : ' was') . ' updated', array('counts' => $counts)); } $adding = $action === 'make'; if (!$adding) { if (!isset($_match[2])) { Response::fail('Missing tag ID'); } $TagID = intval($_match[2], 10);