/** * WPML_TM_ICL_Translations constructor. * * @throws InvalidArgumentException if given data does not correspond to a * record in icl_translations * * @param WPML_TM_Records $tm_records * @param int|array $id * @param string $type translation id, trid_lang or id_prefix for now */ public function __construct(&$tm_records, $id, $type = 'translation_id') { $this->wpdb = $tm_records->wpdb(); parent::__construct($tm_records); if ($id > 0 && $type === 'translation_id') { $this->{$type} = $id; } elseif ($type === 'id_type_prefix' && isset($id['element_id']) && isset($id['type_prefix'])) { $this->select_translation_id(" element_id = %d AND element_type LIKE %s ", array($id['element_id'], $id['type_prefix'] . '%')); } elseif ($type === 'trid_lang' && isset($id['trid']) && isset($id['language_code'])) { $this->select_translation_id(" trid = %d AND language_code = %s ", array($id['trid'], $id['language_code'])); } else { throw new InvalidArgumentException('Unknown column: ' . $type . ' or invalid id: ' . serialize($id)); } }
/** * WPML_TM_ICL_Translations constructor. * * @throws InvalidArgumentException if given data does not correspond to a * record in icl_translations * * @param WPML_TM_Records $tm_records * @param int|array $id * @param string $type translation id, trid_lang or id_prefix for now */ public function __construct(&$tm_records, $id, $type = 'translation_id') { $this->wpdb = $tm_records->wpdb(); $this->post_translations = $tm_records->get_post_translations(); $this->term_translations = $tm_records->get_term_translations(); parent::__construct($tm_records); if ($id > 0 && $type === 'translation_id') { $this->{$type} = $id; } elseif ($type === 'id_type_prefix' && isset($id['element_id']) && isset($id['type_prefix'])) { $this->build_from_element_id($id); } elseif ($type === 'trid_lang' && isset($id['trid']) && isset($id['language_code'])) { $this->build_from_trid($id); } else { throw new InvalidArgumentException('Unknown column: ' . $type . ' or invalid id: ' . serialize($id)); } }
/** * @param WPML_TM_Records $tm_records */ public function __construct(&$tm_records) { $wpdb = $tm_records->wpdb(); parent::__construct($wpdb); $this->tm_records =& $tm_records; }