コード例 #1
0
ファイル: pwg.categories.php プロジェクト: squidjam/Piwigo
/**
 * API method
 *
 * Find a new album thumbnail.
 *
 * @param mixed[] $params
 *    @option int category_id
 */
function ws_categories_refreshRepresentative($params, &$service)
{
    global $conf;
    // does the category really exist?
    $query = '
SELECT id
  FROM ' . CATEGORIES_TABLE . '
  WHERE id = ' . $params['category_id'] . '
;';
    $result = pwg_query($query);
    if (pwg_db_num_rows($result) == 0) {
        return new PwgError(404, 'category_id not found');
    }
    $query = '
SELECT
    DISTINCT category_id
  FROM ' . IMAGE_CATEGORY_TABLE . '
  WHERE category_id = ' . $params['category_id'] . '
  LIMIT 1
;';
    $result = pwg_query($query);
    $has_images = pwg_db_num_rows($result) > 0 ? true : false;
    if (!$has_images) {
        return new PwgError(401, 'not permitted');
    }
    include_once PHPWG_ROOT_PATH . 'admin/include/functions.php';
    set_random_representant(array($params['category_id']));
    // return url of the new representative
    $query = '
SELECT *
  FROM ' . CATEGORIES_TABLE . '
  WHERE id = ' . $params['category_id'] . '
;';
    $category = pwg_db_fetch_assoc(pwg_query($query));
    return get_category_representant_properties($category['representative_picture_id']);
}
コード例 #2
0
ファイル: cat_modify.php プロジェクト: donseba/Piwigo
if ($category['is_virtual']) {
    $template->assign(array('U_DELETE' => $self_url . '&delete=' . $category['id'] . '&pwg_token=' . get_pwg_token()));
} else {
    $category['cat_full_dir'] = get_complete_dir($_GET['cat_id']);
    $template->assign(array('CAT_FULL_DIR' => preg_replace('/\\/$/', '', $category['cat_full_dir'])));
    if ($conf['enable_synchronization']) {
        $template->assign('U_SYNC', $base_url . 'site_update&site=1&cat_id=' . $category['id']);
    }
}
// representant management
if ($category['has_images'] or !empty($category['representative_picture_id'])) {
    $tpl_representant = array();
    // picture to display : the identified representant or the generic random
    // representant ?
    if (!empty($category['representative_picture_id'])) {
        $tpl_representant['picture'] = get_category_representant_properties($category['representative_picture_id']);
    }
    // can the admin choose to set a new random representant ?
    $tpl_representant['ALLOW_SET_RANDOM'] = $category['has_images'] ? true : false;
    // can the admin delete the current representant ?
    if ($category['has_images'] and $conf['allow_random_representative'] or !$category['has_images'] and !empty($category['representative_picture_id'])) {
        $tpl_representant['ALLOW_DELETE'] = true;
    }
    $template->assign('representant', $tpl_representant);
}
if ($category['is_virtual']) {
    $template->assign('parent_category', empty($category['id_uppercat']) ? array() : array($category['id_uppercat']));
}
trigger_notify('loc_end_cat_modify');
//----------------------------------------------------------- sending html code
$template->assign_var_from_handle('ADMIN_CONTENT', 'album_properties');