function DeleteTemplateByID($id)
 {
     $result = false;
     $gCms = cmsms();
     $db = $gCms->GetDb();
     $query = "DELETE FROM " . cms_db_prefix() . "css_assoc WHERE assoc_type = 'template' AND assoc_to_id = ?";
     $dbresult = $db->Execute($query, array($id));
     $query = "DELETE FROM " . cms_db_prefix() . "templates where template_id = ?";
     $dbresult = $db->Execute($query, array($id));
     if ($dbresult !== false) {
         $result = true;
         remove_cross_references($id, 'template');
     }
     return $result;
 }
 function Delete()
 {
     $gCms = cmsms();
     global $sql_queries, $debug_errors;
     $config = $gCms->GetConfig();
     Events::SendEvent('Core', 'ContentDeletePre', array('content' => &$this));
     $db = $gCms->GetDb();
     $result = false;
     if (-1 > $this->mId) {
         if (true == $config["debug"]) {
             # :TODO: Translate the error message
             $debug_errors .= "<p>Could not delete content : invalid Id</p>\n";
         }
     } else {
         $query = "DELETE FROM " . cms_db_prefix() . "content WHERE content_id = ?";
         $dbresult = $db->Execute($query, array($this->mId));
         if (!$dbresult) {
             if (true == $config["debug"]) {
                 # :TODO: Translate the error message
                 $debug_errors .= "<p>Error deleting content</p>\n";
             }
         }
         // Fix the item_order if necessary
         $query = "UPDATE " . cms_db_prefix() . "content SET item_order = item_order - 1 WHERE parent_id = ? AND item_order > ?";
         $result = $db->Execute($query, array($this->ParentId(), $this->ItemOrder()));
         // Remove the cross references
         remove_cross_references($this->mId, 'content');
         $cachefilename = TMP_CACHE_LOCATION . '/contentcache.php';
         @unlink($cachefilename);
         if (NULL != $this->mProperties) {
             # :TODO: There might be some error checking there
             $this->mProperties->Delete($this->mId);
         } else {
             if (true == $config["debug"]) {
                 # :TODO: Translate the error message
                 $debug_errors .= "<p>Error deleting : the content has no properties</p>\n";
             }
         }
     }
     Events::SendEvent('Core', 'ContentDeletePost', array('content' => &$this));
 }