/** * Generate and updates mails. * @param String $template HTML template to serve as a base. * @param Array $data New datas for emails and footer to use * to generate and update emails in oc_t_pages. * @return int Number of locales updated. */ public function update($template, $id, $newDatas, $nEmail) { $m = new Mustache_Engine(); $activeLocales = Madhouse_Utils_Collections::getFieldsFromList(osc_get_locales(), "pk_c_code"); if ($nEmail["s_internal_name"] == "exemple_page") { mdh_error_log(array($nEmail)); } $i = 0; foreach ($nEmail["locales"] as $l) { // Find the correct footer content. $footer = Madhouse_Utils_Collections::findByField($newDatas["footer"]["locales"], "fk_c_locale_code", $l["fk_c_locale_code"]); if (in_array($l["fk_c_locale_code"], $activeLocales) && !Madhouse_EmailMagick_Utils::isLocaleEmpty($l)) { // Updates the description using DAO method. Page::newInstance()->updateDescription($id, $l["fk_c_locale_code"], $l["s_title"], $m->render($template, array("CONTENT" => $l["s_text"], "TITLE" => $l["s_title"], "EXCERPT" => $l["s_excerpt"], "FOOTER" => $footer["s_text"]))); $i++; } } return $i; }