Ejemplo n.º 1
0
 /**
  * Standard modular run function for symbol hooks. Searches for tasks to perform.
  *
  * @param  array		Symbol parameters
  * @return string		Result
  */
 function run($param)
 {
     $value = '';
     if (array_key_exists(1, $param) && addon_installed('catalogues')) {
         static $cache = array();
         if (isset($cache[$param[0]][$param[1]])) {
             return $cache[$param[0]][$param[1]];
         }
         require_code('fields');
         $entry_id = get_bound_content_entry($param[0], $param[1]);
         $value = is_null($entry_id) ? '' : strval($entry_id);
         $cache[$param[0]][$param[1]] = $value;
     }
     return $value;
 }
Ejemplo n.º 2
0
function recalculate_bounding_long_lat($category)
{
    static $fields = NULL;
    if (is_null($fields)) {
        $fields = $GLOBALS['SITE_DB']->query_select('catalogue_fields', array('*'), array('c_name' => '_catalogue_category'), 'ORDER BY cf_order');
    }
    $min_latitude = mixed();
    $max_latitude = mixed();
    $min_longitude = mixed();
    $max_longitude = mixed();
    $subcategories = $GLOBALS['SITE_DB']->query_select('catalogue_categories', array('id'), array('cc_parent_id' => $category));
    require_code('fields');
    foreach ($subcategories as $subcat) {
        $assocated_catalogue_entry_id = get_bound_content_entry('catalogue_category', strval($subcat['id']));
        $_min_latitude = $GLOBALS['SITE_DB']->query_value('catalogue_efv_float', 'cv_value', array('ce_id' => $assocated_catalogue_entry_id, 'cf_id' => $fields[2]['id']));
        $_max_latitude = $GLOBALS['SITE_DB']->query_value('catalogue_efv_float', 'cv_value', array('ce_id' => $assocated_catalogue_entry_id, 'cf_id' => $fields[3]['id']));
        $_min_longitude = $GLOBALS['SITE_DB']->query_value('catalogue_efv_float', 'cv_value', array('ce_id' => $assocated_catalogue_entry_id, 'cf_id' => $fields[4]['id']));
        $_max_longitude = $GLOBALS['SITE_DB']->query_value('catalogue_efv_float', 'cv_value', array('ce_id' => $assocated_catalogue_entry_id, 'cf_id' => $fields[5]['id']));
        if (is_null($min_latitude) || $_min_latitude < $min_latitude) {
            $min_latitude = $_min_latitude;
        }
        if (is_null($max_latitude) || $_max_latitude > $max_latitude) {
            $max_latitude = $_max_latitude;
        }
        if (is_null($min_longitude) || $_min_longitude < $min_longitude) {
            $min_longitude = $_min_longitude;
        }
        if (is_null($max_longitude) || $_max_longitude > $max_longitude) {
            $max_longitude = $_max_longitude;
        }
    }
    $assocated_catalogue_entry_id = get_bound_content_entry('catalogue_category', strval($category));
    $GLOBALS['SITE_DB']->query_update('catalogue_efv_float', array('cv_value' => $min_latitude), array('ce_id' => $assocated_catalogue_entry_id, 'cf_id' => $fields[5]['id']), '', 1);
    $GLOBALS['SITE_DB']->query_update('catalogue_efv_float', array('cv_value' => $max_latitude), array('ce_id' => $assocated_catalogue_entry_id, 'cf_id' => $fields[5]['id']), '', 1);
    $GLOBALS['SITE_DB']->query_update('catalogue_efv_float', array('cv_value' => $min_longitude), array('ce_id' => $assocated_catalogue_entry_id, 'cf_id' => $fields[5]['id']), '', 1);
    $GLOBALS['SITE_DB']->query_update('catalogue_efv_float', array('cv_value' => $max_longitude), array('ce_id' => $assocated_catalogue_entry_id, 'cf_id' => $fields[5]['id']), '', 1);
}
Ejemplo n.º 3
0
/**
 * Delete custom fields for content item.
 *
 * @param  ID_TEXT		Award hook codename
 * @param  ID_TEXT		Content entry ID
 */
function delete_form_custom_fields($content_type, $id)
{
    require_code('catalogues2');
    $existing = get_bound_content_entry($content_type, $id);
    if (!is_null($existing)) {
        actual_delete_catalogue_entry($existing);
        $GLOBALS['SITE_DB']->query_delete('catalogue_entry_linkage', array('catalogue_entry_id' => $existing));
    }
}