/**
 * Insert a new Permalink into the database for latter retrieval
 *
 * This function is basically only used if you have no '%id%' value in your permalink config.
 *
 * @access public
 * @param   array       The input data used for building the permalink
 * @param   string      The type of the permalink (entry|category|author)
 * @return  string      The permalink
 */
function serendipity_insertPermalink(&$data, $type = 'entry')
{
    global $serendipity;
    $link = serendipity_getPermalink($data, $type);
    switch ($type) {
        case 'entry':
            $idfield = 'id';
            break;
        case 'author':
            $idfield = 'authorid';
            break;
        case 'category':
            $idfield = 'categoryid';
            break;
    }
    return serendipity_db_query(sprintf("INSERT INTO {$serendipity['dbPrefix']}permalinks\n                                                    (permalink, entry_id, type)\n                                             VALUES ('%s', '%s', '%s')", serendipity_db_escape_string($link), (int) $data[$idfield], serendipity_db_escape_string($type)));
}
Esempio n. 2
0
/**
 * Smarty Function: Returns the s9y-URL for a given category-id
 *
 * @access public
 * @data   array       Smarty parameter input array:
 *                          cid: id of the category
 * @param   object  Smarty object
 * @return string       The URL of the category - must be added to {$serendipityBaseURL} for a full URL
 */
function smarty_getCategoryLinkByID($data, &$smarty)
{
    $cat = serendipity_fetchCategoryInfo($data['cid']);
    $result = serendipity_getPermalink($cat, 'category');
    return $result;
}