function Save($content_id)
 {
     if (count($this->mPropertyValues) > 0) {
         $gCms = cmsms();
         global $sql_queries, $debug_errors;
         $db = $gCms->GetDb();
         $config = $gCms->GetConfig();
         $concat = '';
         $timestamp = $db->DBTimeStamp(time());
         $insquery = "\n\t\t\t\tINSERT INTO " . cms_db_prefix() . "content_props \n\t\t\t\t(\n\t\t\t\t\tcontent_id, \n\t\t\t\t\ttype, \n\t\t\t\t\tprop_name, \n\t\t\t\t\tparam1, \n\t\t\t\t\tparam2, \n\t\t\t\t\tparam3, \n\t\t\t\t\tcontent,\n\t\t\t\t\tmodified_date\n\t\t\t\t) \n\t\t\t\t\tVALUES \n\t\t\t\t(\n\t\t\t\t\t?,?,?,'','','',?,{$timestamp}\n\t\t\t\t)\n\t\t\t";
         foreach ($this->mPropertyValues as $key => $value) {
             //				if ($this->GetAllowedPropertyNames() == NULL || in_array($key, $this->GetAllowedPropertyNames()))
             //				{
             $delquery = "DELETE FROM " . cms_db_prefix() . "content_props WHERE content_id = ? AND prop_name = ?";
             $dbresult = $db->Execute($delquery, array($content_id, $key));
             if (true == $config["debug"]) {
                 $sql_queries .= "<p>" . $db->sql . "</p>\n";
             }
             $sql_vars = array($content_id, $this->mPropertyTypes[$key], $key, $this->mPropertyValues[$key]);
             $dbresult = $db->Execute($insquery, $sql_vars);
             if (true == $config["debug"]) {
                 $sql_queries .= "<p>" . $db->sql . "</p>\n";
             }
             $concat .= $this->mPropertyValues[$key];
             if (!$dbresult) {
                 if (true == $config["debug"]) {
                     # :TODO: Translate the error message
                     $debug_errors .= "<p>Error updating content property</p>\n";
                 }
             }
             //				}
         }
         if ($concat != '') {
             do_cross_reference($content_id, 'content', $concat);
         }
     }
 }
 function UpdateTemplate($template)
 {
     $result = false;
     $gCms = cmsms();
     $db = $gCms->GetDb();
     $time = $db->DBTimeStamp(time());
     $query = "UPDATE " . cms_db_prefix() . "templates SET template_name = ?, template_content = ?, stylesheet = ?, encoding = ?, active = ?, default_template = ?, modified_date = " . $time . " WHERE template_id = ?";
     $dbresult = $db->Execute($query, array($template->name, $template->content, $template->stylesheet, $template->encoding, $template->active, $template->default, $template->id));
     if ($dbresult !== false) {
         $result = true;
         do_cross_reference($template->id, 'template', $template->content);
     }
     return $result;
 }
//Do the templates first
$query = 'SELECT template_id, template_content FROM ' . cms_db_prefix() . 'templates';
$result =& $db->Execute($query);
while ($result && !$result->EOF) {
    do_cross_reference($result->fields['template_id'], 'template', $result->fields['template_content']);
    $result->MoveNext();
}
//Gather up all content
$query = 'SELECT content_id, content FROM ' . cms_db_prefix() . 'content_props ORDER BY content_id';
$result =& $db->Execute($query);
$contentary = array();
while ($result && !$result->EOF) {
    if (isset($contentary[$result->fields['content_id']])) {
        $contentary[$result->fields['content_id']] .= $result->fields['content'];
    } else {
        $contentary[$result->fields['content_id']] = $result->fields['content'];
    }
    $result->MoveNext();
}
//Now run it all through the cross reference routine to populate
if (count($contentary) > 0) {
    foreach ($contentary as $key => $val) {
        do_cross_reference($key, 'content', $val);
    }
}
echo '[done]</p>';
echo '<p>Updating schema version... ';
$query = "UPDATE " . cms_db_prefix() . "version SET version = 21";
$db->Execute($query);
echo '[done]</p>';
# vim:ts=4 sw=4 noet