false, 'ttl' => 60, ); # CCDB Suche protected static $ccdbsearch = null; public static $ccdb_config = array( 'convert_to_utf8' => false, # Kludge: Daten aus der CP1252-CCDB auf der UTF-8-Seite ausgeben ); # Debug Konfiguration protected static $debug_config = array( 'enabled' => false, 'logfile' => '/tmp/ir_debug.log', ); protected static $debug_logfile_postfix = ''; public static function error() { if (IRGlobal::$debug_config['enabled']) { $debug_logfile = null; if (is_scalar(IRGlobal::$debug_config['logfile']) && IRGlobal::$debug_config['logfile'] && !is_null(static::$debug_logfile_postfix)) { $debug_logfile = IRGlobal::$debug_config['logfile'] . (static::$debug_logfile_postfix ? '.' . static::$debug_logfile_postfix : ''); } if (!is_null($debug_logfile)) { ob_start(); } print '###FEHLER###' . "\n"; foreach (func_get_args() as $_errorinfo) { print (is_scalar($_errorinfo) ? $_errorinfo : print_r($_errorinfo, true)) . "\n"; } debug_print_backtrace(); print "\n" . '###/FEHLER###' . "\n"; if (!is_null($debug_logfile)) { file_put_contents($debug_logfile, ob_get_contents(), FILE_APPEND); ob_end_clean(); } } } #### # Cache-Funktionen #### protected static function cache_get_object(array $options = array()) /* * Gibt das IR_Cache Objekt zurück * Parameter: * $options: Parameter für das IRCache Modul * Rückgabewert: * IR_Cache Objekt / null */ { $return = null; $cacheparams = array( 'ttl' => static::$cache_config['ttl'], 'keyonly' => true, ); if (!static::$cache_config['disabled']) { foreach ($options as $_key => $_value) { $cacheparams[$_key] = $_value; } $return = new IR_Cache($cacheparams); if (!is_object($return)) { $return = null; static::error('cache init error'); } } return $return; } public static function cache_get($cachekey, &$target, array $options = array()) /** * liest Daten aus dem Cache * Parameter: * - Cachekey * - Name des Ziel-Keys in $cache_data * - Optionen für Cache-Objekt (ttl) * Rückgabewert: * - Erfolg (true/false) */ { $success = false; $cachedata = false; $cache = static::cache_get_object($options); if (is_object($cache)) { try { $cachedata = unserialize($cache->get($cachekey)); if ($cachedata !== false && is_array($cachedata) && array_key_exists('data', $cachedata)) { $target = $cachedata['data']; $success = true; } } catch (Exception $exception) { static::error($exception); } } return $success; } public static function cache_put($cachekey, $source, array $options = array()) /** * schreibt Daten in den Cache * Parameter: * - Cachekey * - Name des Quell-Keys in $cache * Rückgabewert: * - Erfolg (true/false) */ { $success = false; $cache = static::cache_get_object($options); if (is_object($cache)) { try { $cache->put(serialize(array( 'data' => $source )), $cachekey); $success = true; } catch (Exception $exception) { static::error($exception); } } return $success; } #### # CCDB-Funktionen #### public static function ccdb_init() # Initialisiert das IR_CCDB_Search Objekt für die CCDB-Suche # Rückgabewert: # true (initialisert) / false (Fehler) { $success = false; if (!(self::$ccdbsearch instanceof IR_CCDB_Search)) { try { self::$ccdbsearch = new IR_CCDB_search(); $success = true; } catch (Exception $exception) { static::error($exception); } } return $success; } public static function ccdb_get_count($ccdbsearchconfig, &$target) /** * Liest die Anzahl der Datensätze zu einer CCDB Konfiguration aus. * Parameter: * $ccdbsearchconfig: Konfiguration der CCDB * &$target: Referenzvariable für das Ergebnis der CCDB Suche * Rückgabewert: * true (erfolgreich) / false (Fehler) */ { $success = false; static::ccdb_init(); if (self::$ccdbsearch instanceof IR_CCDB_Search) { try { self::$ccdbsearch->config($ccdbsearchconfig); $target = self::$ccdbsearch->fetch_count(); $success = true; } catch (Exception $exception) { $target = 0; static::error($exception); } } return $success; } public static function ccdb_get_data($ccdbsearchconfig, &$target) /** * Liest die Datensätze zu einer CCDB Konfiguration aus. * Parameter: * $ccdbsearchconfig: Konfiguration der CCDB * &$target: Referenzvariable für das Ergebnis der CCDB Suche * Rückgabewert: * true (erfolgreich) / false (Fehler) */ { $success = false; static::ccdb_init(); if (self::$ccdbsearch instanceof IR_CCDB_Search) { try { self::$ccdbsearch->config($ccdbsearchconfig); $target = self::$ccdbsearch->fetch_data(); for ($_counter = 0; $_counter < count($target); $_counter++) { if (self::$ccdb_config['convert_to_utf8']) { foreach (array_keys($target[$_counter]) as $_key) { $target[$_counter][$_key] = iconv('Windows-1252', 'UTF-8', $target[$_counter][$_key]); } } // # Prüft ob die URL mit einem Slash beginnt und der Bereich existiert // if (array_key_exists('url', $target[$_counter]) && preg_match('/\A\//', $target[$_counter]['url']) && array_key_exists('bereich', $target[$_counter]) && array_key_exists((string) $target[$_counter]['bereich'], static::$bereich_info)) // { // $target[$_counter]['url'] = static::$bereich_info[$target[$_counter]['bereich']]['baseurl'] . $target[$_counter]['url']; // } } $success = true; } catch (Exception $exception) { $target = array(); static::error($exception); } } return $success; } public static function ccdb_get_last_query() /** * Gibt das letzte SQL-Statement der CCDB Suche zurück (für Debugzwecke) * Rückgabewert: * SQL-Statement */ { return self::$ccdbsearch->get_last_query(); } public static function ccdbcache_get_count($ccdbsearchconfig, &$target) /** * Liest die Anzahl der Datensätze zu einer CCDB Konfiguration aus. (mit Caching der Daten) * Parameter: * $ccdbsearchconfig: Konfiguration der CCDB * &$target: Referenzvariable für das Ergebnis der CCDB Suche * Rückgabewert: * true (erfolgreich) / false (Fehler) */ { $success = false; unset($ccdbsearchconfig['order'], $ccdbsearchconfig['maxshow'], $ccdbsearchconfig['offset']); $cachekey = 'count_' . md5(serialize($ccdbsearchconfig)); if (static::cache_get($cachekey, $target)) { $success = true; } else { $success = static::ccdb_get_count($ccdbsearchconfig, $target); if ($success) { static::cache_put($cachekey, $target); } } return $success; } public static function ccdbcache_get_data($ccdbsearchconfig, &$target) /** * Liest die Datensätze zu einer CCDB Konfiguration aus. (mit Caching der Daten) * Parameter: * $ccdbsearchconfig: Konfiguration der CCDB * &$target: Referenzvariable für das Ergebnis der CCDB Suche * Rückgabewert: * true (erfolgreich) / false (Fehler) */ { $success = false; $cachekey = 'data_' . md5(serialize($ccdbsearchconfig)); if (static::cache_get($cachekey, $target)) { $success = true; } else { $success = static::ccdb_get_data($ccdbsearchconfig, $target); if ($success) { static::cache_put($cachekey, $target); } } return $success; } } /** * Funktion die NUR das Layout "2018_GFA_Consulting_Group_News" berücksichtigt. * @param string $direction [previouse|next] * @return array */ function get_browse_link($direction) { $return = array(); if (in_array($direction, array('previous', 'next'))) { $ccdb_data = array(); # Zuerst prüfen, ob es einen Container mit gleichem Datum gibt, jedoch mit größerer oder kleinerer Container ID $search_config = array( // 'distinct' => 1, 'result_columns' => array( 'Content.URL', ), 'layout' => array(2559), 'search_values' => array( 'datum' => array( 'column' => 'Content.Datum', 'type' => 'EQ', 'value' => '2020-03-10', ), 'container' => array( 'column' => 'Content.Container', 'type' => ($direction == 'previous') ? 'LT' : 'GT', 'value' => '3934184', ), ), 'connector' => '##datum## AND ##container##', // 'connector' => '##datum##', 'order' => 'Content.Container ' . (($direction == 'previous') ? 'DESC' : 'ASC'), 'maxshow' => 1, 'offset' => 0, ); IRGlobal::ccdbcache_get_data($search_config, $ccdb_data); # nach größerem oder kleinerem Datum suchen, falls die erste Abfrage kein Ergebnis liefert if (!count($ccdb_data )) { $search_config = array( // 'distinct' => 1, 'result_columns' => array( 'Content.URL', 'Content.Layout', ), 'layout' => array(2559), 'search_values' => array( 'datum' => array( 'column' => 'Content.Datum', 'type' => ($direction == 'previous') ? 'LT' : 'GT', 'value' => '2020-03-10', ), ), 'connector' => '##datum##', 'order' => 'Content.Datum ' . (($direction == 'previous') ? 'DESC' : 'ASC') . ', Content.Container ' . (($direction == 'previous') ? 'DESC' : 'ASC'), 'maxshow' => 1, 'offset' => 0, ); IRGlobal::ccdbcache_get_data($search_config, $ccdb_data); } if (count($ccdb_data)) { $return = $ccdb_data[0]; } } return $return; } ?> GFA - CLIMATE CHANGE ADAPTATION WITH SMART VALLEYS

CLIMATE CHANGE ADAPTATION WITH SMART VALLEYS

Posted on 10 Mar, 2020 by Justus Pape

On 18 February 2020, GFA presented the climate change adaptation measure "Smart-Valleys" at GIZ headquarters in Eschborn. This specific adaptation measure was introduced successfully in the “Project on Adaptation of Agriculture to Climate Change” (PACC), implemented by GFA in Benin. GIZ planners of the working group Water & Agriculture as well as employees from different agricultural GIZ projects, connected via video, were among the participants of the presentation.

Due to climate change, the rainy season in Benin is increasingly delayed and ends earlier than in the past. Additionally, periods of drought and heavy rainfall during the rainy season are becoming more frequent. The Smart Valleys approach makes it possible to better adapt wet rice cultivation to the effects of climate change. This technically very simple and cost-efficient innovation enables better water management in the rice-growing areas through the construction of canals and dams, thereby increasing the resilience of rice cultivation to the steadily decreasing availability of rainwater. In comparison to the traditional rice cultivation, the harvests in the Smart Valleys more than tripled on average.

The PACC was conducted by the GFA in Benin from June 2014 to November 2019. The aim of the project was to adapt Benin’s agriculture to the consequences of climate change, such as more frequent and severe droughts, precipitation that is more irregular, and higher temperatures. To this end, the impact of climate change on agricultural production and possible adaptation measures were identified together with the population in nine water catchment areas.

> More information about the project