function getTranslationMemoryId($record, $source, $dest) { if ($source != $this->getSourceLanguage($record) or $dest != $this->getDefaultTargetLanguage($record)) { return null; } $wp = new SweteWebpage($record); $props = $wp->getProperties(); //print_r($props->vals()); return $props->val('translation_memory_id'); }
/** * @brief Calculates the effective property for a tree. Since * webpages in the database are meant to be hierarchical (i.e. properties * are propagated down to children unless overridden), we need a way * to calculate the effective properties for any page. * @param string $name The property name. Available properties are defined in the * columns of the webpage_properties table and include: * - active * - locked * - translation_memory_id * - enable_live_translation * - auto_approve * @param SweteWebpage $root The root webpage from which to calculate. * @param mixed $parentEffectiveProperty The effective property value of the $root's parent. * @param mixed $inheritVal * @returns void */ public static function calculateEffectivePropertyToTree($name, SweteWebpage $root, $parentEffectiveProperty, $inheritVal = -1) { $active = $root->getRecord()->val($name); if ($active <= $inheritVal) { $active = $parentEffectiveProperty; $root->getProperties()->setValue('effective_' . $name, $active); $res = $root->getProperties()->save(); if (PEAR::isError($res)) { throw new Exception($res->getMessage(), $res->getCode()); } } else { if ($active != $root->getProperties()->val('effective_' . $name)) { $root->getProperties()->setValue('effective_' . $name, $active); $root->getProperties()->save(); } } $active = $root->getInheritableProperty($name, true, $inheritVal); $skip = 0; while ($children = df_get_records_array('webpages', array('parent_id' => '=' . $root->getRecord()->val('webpage_id'), '-skip' => $skip, '-limit' => 30))) { $skip += 30; foreach ($children as $child) { $c = new SweteWebpage($child); self::calculateEffectivePropertyToTree($name, $c, $active, $inheritVal); } } }