Author: dgoette
Date: Fri Feb 27 02:41:36 2009
New Revision: 39780
URL:
http://svn.reactos.org/svn/reactos?rev=39780&view=rev
Log:
* fix problem, where entries got the wrong contents
* fix delete button
* fix filter option
* if dynamic content is updated, only generate this entry and not all related dynamic
pages
* simplify some code
* delete entries if all their revisions are deleted
* if we add a new dynamic content, add dependency to the related dynamic page
* reapply standard metadata for dynamic contents again (was broken)
* process correct content while genertion of dynamic pages
* fix handling of entry type correct while updating
* fix problem with broken caching
* implement comments into roscms [#*comment text*] where [#* is start sequence and *] the
end sequence
* get correct file extension from tag, instead of just using 'html', if using
[#roscms_filename]
Modified:
branches/danny-web/reactos.org/htdocs/roscms/js/cms_website.js
branches/danny-web/reactos.org/htdocs/roscms/js/cms_website.js.php
branches/danny-web/reactos.org/htdocs/roscms/lib/HTML_CMS.class.php
branches/danny-web/reactos.org/htdocs/roscms/lib/backend/Backend_EntryTable…
branches/danny-web/reactos.org/htdocs/roscms/lib/backend/Backend_SaveDraft.…
branches/danny-web/reactos.org/htdocs/roscms/lib/backend/Backend_ViewAddEnt…
branches/danny-web/reactos.org/htdocs/roscms/lib/backend/Backend_ViewEditor…
branches/danny-web/reactos.org/htdocs/roscms/lib/backend/Backend_ViewEntryT…
branches/danny-web/reactos.org/htdocs/roscms/lib/om/Entry.class.php
branches/danny-web/reactos.org/htdocs/roscms/lib/om/Generate.class.php
branches/danny-web/reactos.org/htdocs/roscms/lib/om/Revision.class.php
branches/danny-web/reactos.org/htdocs/roscms/lib/om/Tag.class.php
branches/danny-web/reactos.org/htdocs/roscms/lib/view/HTML_CMS_Help.class.p…
branches/danny-web/reactos.org/htdocs/roscms/lib/view/HTML_CMS_Website.clas…
Modified:
branches/danny-web/reactos.org/htdocs/roscms/js/cms_website.js
URL:
http://svn.reactos.org/svn/reactos/branches/danny-web/reactos.org/htdocs/ro…
==============================================================================
---
branches/danny-web/reactos.org/htdocs/roscms/js/cms_website.js [iso-8859-1]
(original)
+++
branches/danny-web/reactos.org/htdocs/roscms/js/cms_website.js [iso-8859-1] Fri Feb 27
02:41:36 2009
@@ -1215,7 +1215,7 @@
var poststr = getEditorTexts();
if (poststr !== false) {
-
makeRequest('?page=backend&type=text&subtype=asi&data_id='+encodeURIComponent(did)+'&rev_id='+encodeURIComponent(drid)+'&lang_id='+encodeURIComponent(document.getElementById("mefrlang").innerHTML),
'asi', 'mefasi', 'html', 'POST', poststr.substr(1));
+
makeRequest('?page=backend&type=text&subtype=asi&data_id='+encodeURIComponent(did)+'&rev_id='+encodeURIComponent(drid)+'&lang_id='+encodeURIComponent(document.getElementById("mefrlang").innerHTML),
'asi', 'mefasi', 'html', 'POST', poststr);
return true;
}
else {
@@ -1341,7 +1341,7 @@
*/
function changeSelectedTags( ctk )
{
- if (ctk === 'ms' || ctk === 'mn') {
+ if (ctk === 'ms' || ctk === 'mn' || ctk === 'xe' || ctk ===
'va') {
var tentrs = selectedEntries().split("|");
if (tentrs[0] < 1 || tentrs[0] === '') {
@@ -1580,6 +1580,9 @@
objid = tsplits[1];
default:
+ if (objid == 'editzone') {
+ document.getElementById('newentryzone').innerHTML = '';
+ }
document.getElementById(objid).innerHTML = http_request.responseText;
autosave_cache = getEditorTexts();
break;
@@ -1615,7 +1618,7 @@
}
document.getElementById('mefasi').innerHTML = 'Draft saved at '+
curr_hour +':'+ curr_min;
- if (http_request.responseText !== '') {
+ if (http_request.responseText != '') {
alertbox('Error: '+http_request.responseText);
}
else {
@@ -2068,6 +2071,7 @@
}
document.getElementById('newentryzone').innerHTML = http_request.responseText;
+ document.getElementById('editzone').innerHTML='';
document.getElementById('newentryhead').innerHTML = '<span
class="virtualLink"
onclick="loadEntryTableWithOffset(roscms_current_tbl_position)"><strong>«
Back</strong></span> <strong>New Entry</strong>';
} // end of function showNewEntryDialog
Modified:
branches/danny-web/reactos.org/htdocs/roscms/js/cms_website.js.php
URL:
http://svn.reactos.org/svn/reactos/branches/danny-web/reactos.org/htdocs/ro…
==============================================================================
---
branches/danny-web/reactos.org/htdocs/roscms/js/cms_website.js.php [iso-8859-1]
(original)
+++
branches/danny-web/reactos.org/htdocs/roscms/js/cms_website.js.php [iso-8859-1] Fri
Feb 27 02:41:36 2009
@@ -153,7 +153,7 @@
// order by
case 'o':
filtentryselstrs1 = '<select
id="sfb'+filterid+'"><option
value="asc">Ascending</option><option
value="desc">Descending</option></select>';
- filtentryselstrs2 = '<select
id="sfc'+filterid+'"><option value="date">Date
& Time</option><option
value="name">Name</option><option
value="lang">Language</option><option
value="user">User</option><option
value="type">Type</option><option
value="version">Version</option><option
value="number">Number ("dynamic" entry)</option>';
+ filtentryselstrs2 = '<select
id="sfc'+filterid+'"><option value="date">Date
& Time</option><option
value="name">Name</option><option
value="language">Language</option><option
value="user">User</option><option
value="type">Type</option><option
value="version">Version</option><option
value="number">Number ("dynamic" entry)</option>';
if (roscms_access['more_filter']) {
filtentryselstrs2 += '<option
value="security">Security</option><option
value="revid">RevID</option><option
value="ext">Extension</option><option
value="status">Status</option><option
value="kind">Kind</option>';
}
Modified:
branches/danny-web/reactos.org/htdocs/roscms/lib/HTML_CMS.class.php
URL:
http://svn.reactos.org/svn/reactos/branches/danny-web/reactos.org/htdocs/ro…
==============================================================================
---
branches/danny-web/reactos.org/htdocs/roscms/lib/HTML_CMS.class.php [iso-8859-1]
(original)
+++
branches/danny-web/reactos.org/htdocs/roscms/lib/HTML_CMS.class.php [iso-8859-1] Fri
Feb 27 02:41:36 2009
@@ -148,7 +148,7 @@
<td> </td>');
}
- echo_strip('
+ echo_strip('
<th'.(($this->branch == 'help') ? '
class="active"' : '').'>
<div class="corner_TL">
<div class="corner_TR">
Modified:
branches/danny-web/reactos.org/htdocs/roscms/lib/backend/Backend_EntryTable…
URL:
http://svn.reactos.org/svn/reactos/branches/danny-web/reactos.org/htdocs/ro…
==============================================================================
---
branches/danny-web/reactos.org/htdocs/roscms/lib/backend/Backend_EntryTable…
[iso-8859-1] (original)
+++
branches/danny-web/reactos.org/htdocs/roscms/lib/backend/Backend_EntryTable…
[iso-8859-1] Fri Feb 27 02:41:36 2009
@@ -256,13 +256,6 @@
}
}
- // get next rev version number (also search archive)
- $stmt=&DBConnection::getInstance()->prepare("SELECT version FROM
".ROSCMST_REVISIONS." WHERE data_id = :data_id AND version > 0 AND lang_id =
:lang ORDER BY version DESC, id DESC LIMIT 1");
- $stmt->bindParam('data_id',$revision['data_id'],PDO::PARAM_INT);
- $stmt->bindParam('lang',$revision['lang_id'],PDO::PARAM_INT);
- $stmt->execute();
- $version_num = $stmt->fetchColumn()+1;
-
// get latest stable head entry
$stmt=&DBConnection::getInstance()->prepare("SELECT id, data_id, lang_id
FROM ".ROSCMST_REVISIONS." WHERE data_id = :data_id AND version > 0 AND
lang_id = :lang AND archive IS FALSE AND status='stable' ORDER BY version DESC, id
DESC LIMIT 1");
$stmt->bindParam('data_id',$revision['data_id'],PDO::PARAM_INT);
@@ -274,7 +267,7 @@
if ($stable_revision !== false) {
// transfer
- Tag::copyFromRevision($stable_revision['id'], $revision['id']);
+ Tag::mergeFromRevision($stable_revision['id'], $revision['id']);
// move old revision to archive
if (!Revision::toArchive($stable_revision['id'])) {
@@ -284,30 +277,51 @@
}
}
+ // update depencies for new rev
+ $depency = new Depencies();
+ if (!$depency->addRevision($revision['id'])) {
+ echo 'Error while updating depencies';
+ return false;
+ }
+
+ // make entry stable
+ Revision::setStatus($revision['id'],'stable');
+
+ // if revision is dynamic content, get the number and give it to the generator
+ $stmt=&DBConnection::getInstance()->prepare("SELECT d.name FROM
".ROSCMST_ENTRIES." d JOIN ".ROSCMST_REVISIONS." r ON r.data_id=d.id
WHERE r.id = :rev_id");
+ $stmt->bindParam('rev_id',$revision['id'],PDO::PARAM_INT);
+ $stmt->execute();
+ $dynamic_num = preg_replace('/^.*_([1-9][0-9]*)$/i',
'$1',$stmt->fetchColumn());
+
+ // generate content
+ $generate = new Generate();
+ if ($dynamic_num > 0) {
+ $success = $generate->update($revision['id'], $dynamic_num);
+ }
+ else {
+ $success = $generate->update($revision['id']);
+ }
+
+ // was generation not successfull?
+ if (!$success) {
+ Revision::setStatus($revision['id'],$revision['status']);
+ echo 'Can\'t generate updated entry.';
+ return false;
+ }
+
+ // get next rev version number (also search archive)
+ $stmt=&DBConnection::getInstance()->prepare("SELECT version FROM
".ROSCMST_REVISIONS." WHERE data_id = :data_id AND version > 0 AND lang_id =
:lang ORDER BY version DESC, id DESC LIMIT 1");
+ $stmt->bindParam('data_id',$revision['data_id'],PDO::PARAM_INT);
+ $stmt->bindParam('lang',$revision['lang_id'],PDO::PARAM_INT);
+ $stmt->execute();
+ $version_num = $stmt->fetchColumn()+1;
+
// update the version number
$stmt=&DBConnection::getInstance()->prepare("UPDATE
".ROSCMST_REVISIONS." SET version = :version WHERE id = :rev_id");
$stmt->bindParam('version',$version_num,PDO::PARAM_INT);
$stmt->bindParam('rev_id',$revision['id'],PDO::PARAM_INT);
$stmt->execute();
- // update depencies for new rev
- $depency = new Depencies();
- if (!$depency->addRevision($revision['id'])) {
- echo 'Error while updating depencies';
- return false;
- }
-
- // make entry stable
- Revision::setStatus($revision['id'],'stable');
-
- // generate content
- $generate = new Generate();
- if (!$generate->update($revision['id'])) {
- Revision::setStatus($revision['id'],$revision['status']);
- echo 'Can\'t generate updated entry.';
- return false;
- }
-
Log::writeLow('mark entry as stable: data-id
'.$revision['data_id'].', rev-id '.$revision['id']);
return true;
Modified:
branches/danny-web/reactos.org/htdocs/roscms/lib/backend/Backend_SaveDraft.…
URL:
http://svn.reactos.org/svn/reactos/branches/danny-web/reactos.org/htdocs/ro…
==============================================================================
---
branches/danny-web/reactos.org/htdocs/roscms/lib/backend/Backend_SaveDraft.…
[iso-8859-1] (original)
+++
branches/danny-web/reactos.org/htdocs/roscms/lib/backend/Backend_SaveDraft.…
[iso-8859-1] Fri Feb 27 02:41:36 2009
@@ -56,7 +56,7 @@
private function save( )
{
$thisuser = &ThisUser::getInstance();
- $rev_id = 0; // helper var, contains current rev_id in force
+ $rev_id = false; // helper var, contains current rev_id in force
if (!$thisuser->hasAccess('more_lang') && $_GET['lang_id']
!= $thisuser->language()) {
die ('Can\'t save drafts of other than your language, due to access
restrictions');
@@ -68,15 +68,10 @@
$stmt->bindParam('user_id',$thisuser->id(),PDO::PARAM_INT);
$stmt->bindParam('lang',$_GET['lang_id'],PDO::PARAM_INT);
$stmt->execute();
- $draft_candidate = $stmt->fetchColumn();
-
- // if there is a valid value returned, use it as rev_id
- if ($draft_candidate !== false) {
- $rev_id = $draft_candidate;
- }
+ $rev_id = $stmt->fetchColumn();
// add new draft, if no autosave-draft exists or draft is submitted
- if ($rev_id === 0) {
+ if ($rev_id === false) {
// add a new revision
$rev_id = Revision::add($_GET['data_id'], $_GET['lang_id']);
@@ -84,13 +79,14 @@
// get stable entry
$stmt=&DBConnection::getInstance()->prepare("SELECT id FROM
".ROSCMST_REVISIONS." WHERE data_id = :data_id AND lang_id = :lang_id AND status
= 'stable' AND archive IS FALSE ORDER BY datetime DESC LIMIT 1");
$stmt->bindParam('data_id',$_GET['data_id'],PDO::PARAM_INT);
- $stmt->bindParam('lang_id',$_GET['lang_id'],PDO::PARAM_STR);
+ $stmt->bindParam('lang_id',$_GET['lang_id'],PDO::PARAM_INT);
$stmt->execute();
$stable = $stmt->fetchColumn();
+
if ($stable !== false) {
// transfer from stable entry
- Tag::copyFromRevision($stable, $rev_id);
+ Tag::mergeFromRevision($stable, $rev_id);
}
}
@@ -111,10 +107,11 @@
// insert/update short text
$stmt=&DBConnection::getInstance()->prepare("INSERT INTO
".ROSCMST_STEXT." ( id , rev_id , name , content ) VALUES ( NULL, :rev_id,
:name, :content)");
$stmt->bindParam('rev_id',$rev_id,PDO::PARAM_INT);
- for ($i=1; $i <= $_POST['stextsum']; ++$i) {
+ for ($i=1; $i <= $_POST['pstextsum']; ++$i) {
$stmt->bindParam('name',$_POST['pdstext'.$i],PDO::PARAM_STR);
$stmt->bindParam('content',$_POST['pstext'.$i],PDO::PARAM_STR);
$stmt->execute();
+
}
// insert/update long text
Modified:
branches/danny-web/reactos.org/htdocs/roscms/lib/backend/Backend_ViewAddEnt…
URL:
http://svn.reactos.org/svn/reactos/branches/danny-web/reactos.org/htdocs/ro…
==============================================================================
---
branches/danny-web/reactos.org/htdocs/roscms/lib/backend/Backend_ViewAddEnt…
[iso-8859-1] (original)
+++
branches/danny-web/reactos.org/htdocs/roscms/lib/backend/Backend_ViewAddEnt…
[iso-8859-1] Fri Feb 27 02:41:36 2009
@@ -79,18 +79,18 @@
case 'newdynamic':
// get some data about the dynamic page
- $stmt=&DBConnection::getInstance()->prepare("SELECT r.id AS rev_id,
d.name FROM ".ROSCMST_REVISIONS." r JOIN ".ROSCMST_ENTRIES." d ON
d.id=r.data_id WHERE d.id=:data_id AND lang_id=:standard_lang LIMIT 1");
+ $stmt=&DBConnection::getInstance()->prepare("SELECT r.id AS rev_id,
d.name FROM ".ROSCMST_REVISIONS." r JOIN ".ROSCMST_ENTRIES." d ON
d.id=r.data_id WHERE d.id=:data_id AND lang_id=:standard_lang AND
r.status='stable' AND r.archive IS FALSE LIMIT 1");
$stmt->bindParam('data_id',$_GET['data_id'],PDO::PARAM_INT);
$stmt->bindParam('standard_lang',Language::getStandardId(),PDO::PARAM_INT);
$stmt->execute();
$page = $stmt->fetchOnce(PDO::FETCH_ASSOC);
$next_index = Tag::getValue($page['rev_id'],'next_index',-1);
- // create new dynamic entry
- $rev_id = Entry::add($page['name'].'_'.$next_index,
'content');
-
// update next index for dynamic page
Tag::update(Tag::getId($page['rev_id'],'next_index',-1),$next_index+1);
+
+ // create new dynamic entry
+ $rev_id = Entry::add($page['name'].'_'.$next_index,
'content',null, true);
// show editor
new Backend_ViewEditor($rev_id);
Modified:
branches/danny-web/reactos.org/htdocs/roscms/lib/backend/Backend_ViewEditor…
URL:
http://svn.reactos.org/svn/reactos/branches/danny-web/reactos.org/htdocs/ro…
==============================================================================
---
branches/danny-web/reactos.org/htdocs/roscms/lib/backend/Backend_ViewEditor…
[iso-8859-1] (original)
+++
branches/danny-web/reactos.org/htdocs/roscms/lib/backend/Backend_ViewEditor…
[iso-8859-1] Fri Feb 27 02:41:36 2009
@@ -551,7 +551,7 @@
if ($thisuser->hasAccess('system_tags')) {
$stmt=&DBConnection::getInstance()->prepare("SELECT id, user_id, name,
value FROM ".ROSCMST_TAGS." WHERE rev_id = :rev_id AND user_id IN(-1, :user_id)
ORDER BY user_id ASC, name ASC");
}
-
+
// Display only privat labels
else {
$stmt=&DBConnection::getInstance()->prepare("SELECT id, user_id, name,
value FROM ".ROSCMST_TAGS." WHERE rev_id = :rev_id AND user_id =:user_id ORDER
BY user_id ASC, name ASC");
Modified:
branches/danny-web/reactos.org/htdocs/roscms/lib/backend/Backend_ViewEntryT…
URL:
http://svn.reactos.org/svn/reactos/branches/danny-web/reactos.org/htdocs/ro…
==============================================================================
---
branches/danny-web/reactos.org/htdocs/roscms/lib/backend/Backend_ViewEntryT…
[iso-8859-1] (original)
+++
branches/danny-web/reactos.org/htdocs/roscms/lib/backend/Backend_ViewEntryT…
[iso-8859-1] Fri Feb 27 02:41:36 2009
@@ -372,7 +372,7 @@
case 'name': // name
$this->sql_order .= "d.name ";
break;
- case 'lang': // language
+ case 'language': // language
$this->sql_order .= "r.lang_id ";
break;
case 'user': // user
Modified:
branches/danny-web/reactos.org/htdocs/roscms/lib/om/Entry.class.php
URL:
http://svn.reactos.org/svn/reactos/branches/danny-web/reactos.org/htdocs/ro…
==============================================================================
---
branches/danny-web/reactos.org/htdocs/roscms/lib/om/Entry.class.php [iso-8859-1]
(original)
+++
branches/danny-web/reactos.org/htdocs/roscms/lib/om/Entry.class.php [iso-8859-1] Fri
Feb 27 02:41:36 2009
@@ -166,9 +166,11 @@
* @return bool
* @access public
*/
- public static function add($data_name, $data_type = null, $template = '')
+ public static function add($data_name, $data_type = null, $template = '',
$dynamic = false)
{
$data_name = trim($data_name);
+
+ $rev_id = false;
// check if entry already exists
$stmt=&DBConnection::getInstance()->prepare("SELECT id FROM
".ROSCMST_ENTRIES." WHERE name = :name AND type = :type LIMIT 1");
@@ -207,13 +209,35 @@
return false;
}
+ // add dynamic content tags and dependencies from parent page
+ if ($dynamic) {
+ $parent_name =
preg_replace('/^(.*)_[1-9][0-9]*$/i','$1',$data_name);
+
+ $stmt=&DBConnection::getInstance()->prepare("SELECT r.id FROM
".ROSCMST_REVISIONS." r JOIN ".ROSCMST_ENTRIES." d ON d.id=r.data_id
WHERE d.name=:parent_name AND d.type = 'dynamic' AND r.status='stable' AND
r.archive IS FALSE");
+ $stmt->bindParam('parent_name',$parent_name,PDO::PARAM_STR);
+ $stmt->execute();
+ $parent_rev = $stmt->fetchColumn();
+
+ $next_index = Tag::getValue($parent_rev, 'next_index',-1);
+
+ // add Tags
+ Tag::add($rev_id, 'number', $next_index, -1);
+ Tag::add($rev_id, 'pub_date', date('Y-m-d'), -1);
+ Tag::add($rev_id, 'pub_user', ThisUser::getInstance()->id(), -1);
+
+ // update next number
+ Tag::update(Tag::getId($parent_rev,'next_index',-1),$next_index+1);
+
+ Depencies::addManual($parent_rev, $data_name, 'content');
+ }
+
// create new stext contents for (dynamic) pages
$stmt=&DBConnection::getInstance()->prepare("INSERT INTO
".ROSCMST_STEXT." ( id , rev_id , name , content ) VALUES ( NULL, :rev_id,
:description, :content )");
$stmt->bindParam('rev_id',$rev_id,PDO::PARAM_INT);
$stmt->bindValue('description','description',PDO::PARAM_STR);
$stmt->bindValue('content','',PDO::PARAM_STR);
$stmt->execute();
- if ($data_type == 'page' || $data_type == 'dynamic') {
+ if ($data_type == 'page' || $data_type == 'dynamic' || $dynamic) {
// add a comment as short text
$stmt->bindValue('description','comment',PDO::PARAM_STR);
@@ -225,7 +249,7 @@
$stmt->bindValue('content',$data_name,PDO::PARAM_STR);
$stmt->execute();
- // add next dynamic number for dynamic entries
+ // add initial next dynamic number for dynamic entries
if ($data_type == 'dynamic') {
Tag::add($rev_id, 'next_number', 1, -1);
}
@@ -245,23 +269,34 @@
$stmt->bindParam('content',$content,PDO::PARAM_STR);
$stmt->execute();
- // add dynamic content tags
- if (isset($next_number)) {
-
- // add Tags
- Tag::add($rev_id, 'number', $next_number, -1);
- Tag::add($rev_id, 'pub_date', date('Y-m-d'), -1);
- Tag::add($rev_id, 'pub_user', ThisUser::getInstance()->id(), -1);
-
- // update next number
- Tag::update(Tag::getId($rev_id,'number_next',-1),$next_number+1);
- }
-
+ // add standard page extension
if ($data_type == 'page' || $data_type == 'dynamic') {
Tag::add($rev_id, 'extension', 'html', -1);
}
return $rev_id;
} // end of member function add
+
+
+
+ /**
+ * delete a entry, if no revisions are derived from it
+ *
+ * @param int data_id
+ * @return bool
+ * @access public
+ */
+ public static function delete( $data_id )
+ {
+ $stmt=&DBConnection::getInstance()->prepare("SELECT TRUE FROM
".ROSCMST_REVISIONS." WHERE data_id=:data_id");
+ $stmt->bindParam('data_id',$data_id,PDO::PARAM_INT);
+ $stmt->execute();
+ if (!$stmt->fetchColumn()) {
+ $stmt=&DBconnection::getInstance()->prepare("DELETE FROM
".ROSCMST_ENTRIES." WHERE id=:data_id");
+ $stmt->bindParam('data_id',$data_id,PDO::PARAM_INT);
+ return $stmt->execute();
+ }
+ return false;
+ } // end of member function delete
Modified:
branches/danny-web/reactos.org/htdocs/roscms/lib/om/Generate.class.php
URL:
http://svn.reactos.org/svn/reactos/branches/danny-web/reactos.org/htdocs/ro…
==============================================================================
---
branches/danny-web/reactos.org/htdocs/roscms/lib/om/Generate.class.php [iso-8859-1]
(original)
+++
branches/danny-web/reactos.org/htdocs/roscms/lib/om/Generate.class.php [iso-8859-1]
Fri Feb 27 02:41:36 2009
@@ -39,7 +39,7 @@
private $lang_id = null;
private $lang = null;
- private $short = array('content'=>'cont',
'script'=>'inc');
+ private $short = array('content'=>'cont',
'dynamic'=>'page', 'page'=>'page',
'script'=>'inc');
@@ -208,7 +208,7 @@
$file_name = $data_name.'.'.$file_extension;
// information, what was generated
- echo $file_name.'<br />';
+ echo $this->lang_id.'--'.$file_name.'<br />';
// needed by replacing functions
$this->page_name = $data_name;
@@ -284,33 +284,27 @@
// information, what was generated
echo $this->lang_id.'--'.$file_name.'<br />';
-
- // get current instance (dynamic entry revision id)
- $stmt=&DBConnection::getInstance()->prepare("SELECT r.id, r.lang_id
FROM ".ROSCMST_REVISIONS." r JOIN ".ROSCMST_ENTRIES." d ON
d.id=r.data_id WHERE d.type='content' AND d.name =
CONCAT(:parent_name,'_',:dynamic_num) AND r.status='stable' AND r.archive
IS FALSE LIMIT 1");
-
$stmt->bindParam('parent_name',$revision['name'],PDO::PARAM_STR);
- $stmt->bindParam('dynamic_num',$i,PDO::PARAM_INT);
- $stmt->execute();
- $instance = $stmt->fetchOnce(PDO::FETCH_ASSOC);
// needed by replacing functions
$this->page_name = $data_name;
$this->rev_id = $revision['id'];
$this->dynamic_num = $i;
+ // copy content
+ $content = $revision['content'];
+
// replace depencies
- $stmt_more=&DBConnection::getInstance()->prepare("SELECT d.id, d.type,
d.name FROM ".ROSCMST_DEPENCIES." w JOIN ".ROSCMST_ENTRIES." d ON
w.child_id=d.id WHERE w.rev_id=:rev_id AND w.include IS TRUE");
- $stmt_more->bindParam('rev_id',$instance['id'],PDO::PARAM_INT);
+ $stmt_more=&DBConnection::getInstance()->prepare("SELECT d.id, d.type,
d.name FROM ".ROSCMST_DEPENCIES." w JOIN ".ROSCMST_ENTRIES." d ON
w.child_id=d.id WHERE w.rev_id=:rev_id AND w.include IS TRUE AND d.type !=
'script'");
+ $stmt_more->bindParam('rev_id',$revision['id'],PDO::PARAM_INT);
$stmt_more->execute();
while ($depency = $stmt_more->fetch(PDO::FETCH_ASSOC)) {
// replace
- if ($depency['type'] != 'script') {
- $content =
str_replace('[#'.$this->short[$depency['type']].'_'.$depency['name'].']',
$this->getCached(array(null,
$this->short[$depency['type']].'_'.$depency['name'])),
$content);
- }
+ $content =
str_replace('[#'.$this->short[$depency['type']].'_'.$depency['name'].']',
$this->getCached(array(null,
$this->short[$depency['type']].'_'.$depency['name'])),
$content);
} // end foreach
// replace scripts
- $content = preg_replace_callback('/\[#inc_([^][#[:space:]]+)\]/',
array($this,'evalScript'),$content);
+ $content = preg_replace_callback('/\[#inc_([a-zA-Z0-9_]+)\]/',
array($this,'evalScript'),$content);
// replace roscms vars
$content = $this->replaceRoscmsPlaceholder($content);
@@ -329,7 +323,7 @@
* @param bool
* @access private
*/
- public function update( $rev_id )
+ public function update( $rev_id, $dynamic_num = null )
{
static $base_rev;
@@ -339,28 +333,52 @@
}
// get revision information
- $stmt=&DBConnection::getInstance()->prepare("SELECT data_id, lang_id FROM
".ROSCMST_REVISIONS." WHERE id=:rev_id");
+ $stmt=&DBConnection::getInstance()->prepare("SELECT r.data_id, r.lang_id,
d.type, d.name FROM ".ROSCMST_REVISIONS." r JOIN ".ROSCMST_ENTRIES." d
ON d.id=r.data_id WHERE r.id=:rev_id");
$stmt->bindParam('rev_id',$rev_id,PDO::PARAM_INT);
$stmt->execute();
$revision=$stmt->fetchOnce(PDO::FETCH_ASSOC);
// cache revision (set language, cache)
$this->lang_id = $revision['lang_id'];
- $this->cacheFiles($revision['data_id']);
-
- // for usage in loop
+ $this->cacheFiles($revision['data_id'], false);
+
+ if ($revision['type'] == 'page' || $revision['type'] ==
'dynamic') {
+
// in standard language we may have depencies to other languages, so better
generate them all
if ($revision['lang_id'] == Language::getStandardId()){
- $stmt_lang=&DBConnection::getInstance()->prepare("SELECT id,
name_short FROM ".ROSCMST_LANGUAGES." ORDER BY level DESC, name ASC");
+ $stmt=&DBConnection::getInstance()->prepare("SELECT id, name_short
FROM ".ROSCMST_LANGUAGES." ORDER BY level DESC, name ASC");
}
else {
- $stmt_lang=&DBConnection::getInstance()->prepare("SELECT id,
name_short FROM ".ROSCMST_LANGUAGES." WHERE id=:lang_id");
-
$stmt_lang->bindParam('lang_id',$revision['lang_id'],PDO::PARAM_INT);
- }
+ $stmt=&DBConnection::getInstance()->prepare("SELECT id, name_short
FROM ".ROSCMST_LANGUAGES." WHERE id=:lang_id");
+
$stmt->bindParam('lang_id',$revision['lang_id'],PDO::PARAM_INT);
+ }
+ $stmt->execute();
+ while ($language = $stmt->fetch(PDO::FETCH_ASSOC)) {
+
+ // language settings for generating process
+ $this->lang_id=$language['id'];
+ $this->lang=$language['name_short'];
+ $this->lang=$language['name_short'];
+
+ // seperate functions for pages & dynamic pages (in that order)
+ if($revision['type'] == 'page') {
+ $this->oneEntry($revision['name']);
+ }
+ else {
+ if ($dynamic_num === null) {
+ $this->makeDynamic($revision['name']);
+ }
+ else {
+ $this->makeDynamic($revision['name'], $dynamic_num);
+ }
+ }
+ } // end while language
+ return true;
+ }
// get list of entries which depend on this one and handle their types
$stmt=&DBConnection::getInstance()->prepare("
- SELECT
+ SELECT DISTINCT
org.name, org.type, COALESCE( trans.id, org.id ) AS id, org.data_id
FROM (
SELECT d.name, d.type, r.id, r.data_id FROM ".ROSCMST_DEPENCIES." w
JOIN ".ROSCMST_REVISIONS." r ON r.id=w.rev_id JOIN ".ROSCMST_ENTRIES."
d ON d.id=r.data_id WHERE w.child_id=:depency_id AND r.lang_id = :standard_lang AND
w.rev_id NOT IN(:rev_id,:rev_id2) AND r.archive IS FALSE AND w.include IS TRUE
@@ -375,38 +393,12 @@
$stmt->execute();
while ($depency = $stmt->fetch(PDO::FETCH_ASSOC)) {
- // cache recursivly or generate page
- switch ($depency['type']) {
- case 'page':
- case 'dynamic':
-
- // generate pages for all languages, if standard lang, otherwise only once
- $stmt_lang->execute();
- while ($language = $stmt_lang->fetch(PDO::FETCH_ASSOC)) {
-
- // language settings for generating process
- $this->lang_id=$language['id'];
- $this->lang=$language['name_short'];
-
- // seperate functions for pages & dynamic pages (in that order)
- if($depency['type'] == 'page') {
- $this->oneEntry($depency['name'], $language['id']);
- }
- else {
- $this->makeDynamic($depency['name'], $language['id']);
- }
- } // end while language
- break;
-
- case 'script':
- // scripts are only executed in pages
- break;
- default:
-
- // only run update once per $rev_id
- $this->update($depency['id']);
- break;
- } // end switch
+ // only run update once per $rev_id
+ if ($depency['type'] != 'script') {
+
+ $this->update($depency['id'], $dynamic_num);
+ break;
+ }
} // end while depency
return true;
@@ -418,10 +410,10 @@
* cache files
*
* @param int data_id data to be cached, if nothing is set, everything will be cached
- * @param bool depencies if set to true, it'll be cached recursivly
- * @access private
- */
- private function cacheFiles( $data_id = null, $depencies = true )
+ * @param bool recursive if set to true, it'll be cached recursivly
+ * @access private
+ */
+ private function cacheFiles( $data_id = null, $recursive = true )
{
// set dir to generate contents
static $backup;
@@ -443,7 +435,7 @@
$stmt->execute();
// prepare for usage in loop
- $stmt_more=&DBConnection::getInstance()->prepare("SELECT w.child_id,
d.type, d.name FROM ".ROSCMST_DEPENCIES." w JOIN ".ROSCMST_ENTRIES." d
ON w.child_id=d.id WHERE w.rev_id=:rev_id AND w.include IS TRUE AND d.type !=
'script'");
+ $stmt_more=&DBConnection::getInstance()->prepare("SELECT w.child_id,
d.type, d.name FROM ".ROSCMST_DEPENCIES." w JOIN ".ROSCMST_ENTRIES." d
ON w.child_id=d.id WHERE w.rev_id=:rev_id AND w.include IS TRUE");
while ($data = $stmt->fetch(PDO::FETCH_ASSOC)) {
@@ -475,7 +467,7 @@
$content = preg_replace_callback('/\[#link_([^][#[:space:]]+)\]/',
array($this, 'replaceWithHyperlink'), $content);
// do we care about depencies ?
- if ($depencies) {
+ if ($recursive) {
// process depencies first
$stmt_more->bindParam('rev_id',$revision['id'],PDO::PARAM_INT);
@@ -490,7 +482,7 @@
}
// replace
- $content =
'~'.$this->lang_id.'~'.str_replace('[#'.$this->short[$depency['type']].'_'.$depency['name'].']',
$this->getCached(array(null,
$this->short[$depency['type']].'_'.$depency['name'])),
$content);
+ $content =
str_replace('[#'.$this->short[$depency['type']].'_'.$depency['name'].']',
$this->getCached(array(null,
$this->short[$depency['type']].'_'.$depency['name'])),
$content);
}
}
$this->writeFile($data['lang_id'],$filename, $content);
@@ -522,14 +514,14 @@
// take care of dynamic number independent entries
if ($this->dynamic_num === false) {
- $content = str_replace('[#roscms_filename]',
$this->page_name.'.html', $content);
+ $content = str_replace('[#roscms_filename]',
$this->page_name.'.'.Tag::getValue($this->rev_id,'extension',-1),
$content);
$content = str_replace('[#roscms_pagename]', $this->page_name,
$content);
$content = str_replace('[#roscms_pagetitle]',
Revision::getSText($this->rev_id, 'title'), $content);
}
// replace roscms constants dependent from dynamic number
else {
- $content = str_replace('[#roscms_filename]',
$this->page_name.'_'.$this->dynamic_num.'.html', $content);
+ $content = str_replace('[#roscms_filename]',
$this->page_name.'_'.$this->dynamic_num.'.'.Tag::getValue($this->rev_id,'extension',-1),
$content);
$content = str_replace('[#roscms_pagename]',
$this->page_name.'_'.$this->dynamic_num, $content);
$content = str_replace('[#roscms_pagetitle]',
Revision::getSText($this->rev_id, 'title').' #'.$this->dynamic_num,
$content);
}
@@ -545,6 +537,9 @@
$content = str_replace('[#roscms_language_short]',
$lang['name_short'], $content);
$content = str_replace('[#roscms_language_id]', $this->lang_id,
$content);
+ // eat comments
+ $content = preg_replace('/\[#\*.*\*\]/siU', '', $content);
+
return $content;
} // end of member function replaceRoscmsPlaceholder
@@ -598,7 +593,7 @@
private function getFrom( $type, $name )
{
// get entry
- $stmt=&DBConnection::getInstance()->prepare("SELECT t.content, r.id,
r.lang_id FROM ".ROSCMST_ENTRIES." d JOIN ".ROSCMST_REVISIONS." r ON
r.data_id = d.id JOIN ".ROSCMST_TEXT." t ON t.rev_id = r.id WHERE d.name = :name
AND d.type = :type AND r.version > 0 AND r.lang_id = :lang_id AND r.archive IS FALSE
AND t.name = 'content' AND status='stable' LIMIT 1");
+ $stmt=&DBConnection::getInstance()->prepare("SELECT t.content, r.id,
r.lang_id FROM ".ROSCMST_ENTRIES." d JOIN ".ROSCMST_REVISIONS." r ON
r.data_id = d.id JOIN ".ROSCMST_TEXT." t ON t.rev_id = r.id WHERE d.name = :name
AND d.type = :type AND r.lang_id = :lang_id AND r.archive IS FALSE AND t.name =
'content' AND status='stable' LIMIT 1");
$stmt->bindParam('name',$name,PDO::PARAM_STR);
$stmt->bindParam('type',$type,PDO::PARAM_STR);
$stmt->bindParam('lang_id',$this->lang_id,PDO::PARAM_INT);
@@ -610,10 +605,6 @@
$stmt->bindParam('lang_id',Language::getStandardId(),PDO::PARAM_INT);
$stmt->execute();
$revision=$stmt->fetch(PDO::FETCH_ASSOC);
-
- if ($revision === false) {
- return false;
- }
}
return $revision;
}
Modified:
branches/danny-web/reactos.org/htdocs/roscms/lib/om/Revision.class.php
URL:
http://svn.reactos.org/svn/reactos/branches/danny-web/reactos.org/htdocs/ro…
==============================================================================
---
branches/danny-web/reactos.org/htdocs/roscms/lib/om/Revision.class.php [iso-8859-1]
(original)
+++
branches/danny-web/reactos.org/htdocs/roscms/lib/om/Revision.class.php [iso-8859-1]
Fri Feb 27 02:41:36 2009
@@ -160,6 +160,12 @@
// delete Depencies
$success = Depencies::removeRevision($rev_id);
+ // get data id (check later if we can delete this)
+ $stmt=&DBConnection::getInstance()->prepare("SELECT data_id FROM
".ROSCMST_REVISIONS." WHERE id = :rev_id ");
+ $stmt->bindParam('rev_id',$rev_id,PDO::PARAM_INT);
+ $stmt->execute();
+ $data_id=$stmt->fetchColumn();
+
// delete revision and texts
$stmt=&DBConnection::getInstance()->prepare("DELETE FROM
".ROSCMST_REVISIONS." WHERE id = :rev_id LIMIT 1");
$stmt->bindParam('rev_id',$rev_id,PDO::PARAM_INT);
@@ -177,6 +183,9 @@
$stmt=&DBConnection::getInstance()->prepare("DELETE FROM
".ROSCMST_TAGS." WHERE rev_id = :rev_id LIMIT 1");
$stmt->bindParam('rev_id',$rev_id);
$success = $success && $stmt->execute();
+
+ // if the revision was the last one with this data id, delete the data also
+ Entry::delete($data_id);
// report if everything went right
return $success;
@@ -454,7 +463,7 @@
$stmt->execute();
// copy data tags and update status
- Tag::copyFromRevision($revision['id'], $new_rev_id);
+ Tag::mergeFromRevision($revision['id'], $new_rev_id);
// add original translator / translation date
if (Tag::getValue($revision['id'],'pub_user',-1) != '') {
Modified:
branches/danny-web/reactos.org/htdocs/roscms/lib/om/Tag.class.php
URL:
http://svn.reactos.org/svn/reactos/branches/danny-web/reactos.org/htdocs/ro…
==============================================================================
---
branches/danny-web/reactos.org/htdocs/roscms/lib/om/Tag.class.php [iso-8859-1]
(original)
+++
branches/danny-web/reactos.org/htdocs/roscms/lib/om/Tag.class.php [iso-8859-1] Fri Feb
27 02:41:36 2009
@@ -175,7 +175,7 @@
* @return bool
* @access public
*/
- public static function copyFromRevision( $old_rev_id, $new_rev_id )
+ public static function mergeFromRevision( $old_rev_id, $new_rev_id )
{
// prepare insert for usage in loop
$stmt_ins=&DBConnection::getInstance()->prepare("INSERT INTO
".ROSCMST_TAGS." ( id , rev_id , name , value , user_id ) VALUES (NULL, :rev_id,
:tag_name, :tag_value, :user_id)");
Modified:
branches/danny-web/reactos.org/htdocs/roscms/lib/view/HTML_CMS_Help.class.p…
URL:
http://svn.reactos.org/svn/reactos/branches/danny-web/reactos.org/htdocs/ro…
==============================================================================
---
branches/danny-web/reactos.org/htdocs/roscms/lib/view/HTML_CMS_Help.class.p…
[iso-8859-1] (original)
+++
branches/danny-web/reactos.org/htdocs/roscms/lib/view/HTML_CMS_Help.class.p…
[iso-8859-1] Fri Feb 27 02:41:36 2009
@@ -63,7 +63,7 @@
<div id="roscms_container">
<div class="leftMenu" style="position: absolute; top: 0px;
width: 150px; left: 0px; z-index:1;">
- <div id="lmInfo" class="lmItemTop"
onclick="loadInfo()" style="background-color: #C9DAF8; font-weight:
bold;">
+ <div id="lmInfo" class="lmItemTopSelected"
onclick="loadInfo()">
<div class="lmItemBottom">Info</div>
</div>
<div id="lmFirst" class="lmItemTop"
onclick="loadFirstSteps()">
Modified:
branches/danny-web/reactos.org/htdocs/roscms/lib/view/HTML_CMS_Website.clas…
URL:
http://svn.reactos.org/svn/reactos/branches/danny-web/reactos.org/htdocs/ro…
==============================================================================
---
branches/danny-web/reactos.org/htdocs/roscms/lib/view/HTML_CMS_Website.clas…
[iso-8859-1] (original)
+++
branches/danny-web/reactos.org/htdocs/roscms/lib/view/HTML_CMS_Website.clas…
[iso-8859-1] Fri Feb 27 02:41:36 2009
@@ -231,7 +231,7 @@
$stmt=&DBConnection::getInstance()->prepare("SELECT id, name FROM
".ROSCMST_LANGUAGES." WHERE level > 0 ORDER BY name ASC");
}
else {
- $stmt=&DBConnection::getInstance()->prepare("SELECT id, name FROM
".ROSCMST_LANGUAGES." WHERE id IN(:lang_id,:standard_lang)");
+ $stmt=&DBConnection::getInstance()->prepare("SELECT id, name FROM
".ROSCMST_LANGUAGES." WHERE id IN(:lang_id,:standard_lang) ORDER BY name
ASC");
$stmt->bindParam('lang_id',$thisuser->language(),PDO::PARAM_INT);
$stmt->bindParam('standard_lang',Language::getStandardId(),PDO::PARAM_INT);
}