Author: dgoette Date: Thu Feb 12 12:54:30 2009 New Revision: 39572
URL: http://svn.reactos.org/svn/reactos?rev=39572&view=rev Log: * fix adding of new entries * hackfix login dialog * allow manual adding of depencies * fix generator
Modified: branches/danny-web/reactos.org/htdocs/roscms/config.php branches/danny-web/reactos.org/htdocs/roscms/connect.db.php branches/danny-web/reactos.org/htdocs/roscms/convert3to4.sql branches/danny-web/reactos.org/htdocs/roscms/css/cms_website.css branches/danny-web/reactos.org/htdocs/roscms/js/cms_website.js branches/danny-web/reactos.org/htdocs/roscms/lib/DBConnection.class.php branches/danny-web/reactos.org/htdocs/roscms/lib/RosCMS.class.php branches/danny-web/reactos.org/htdocs/roscms/lib/backend/Backend_ViewAddEntry.class.php branches/danny-web/reactos.org/htdocs/roscms/lib/backend/Backend_ViewEditor.class.php branches/danny-web/reactos.org/htdocs/roscms/lib/om/Depencies.class.php 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/view/HTML_User_Login.class.php
Modified: branches/danny-web/reactos.org/htdocs/roscms/config.php URL: http://svn.reactos.org/svn/reactos/branches/danny-web/reactos.org/htdocs/ros... ============================================================================== --- branches/danny-web/reactos.org/htdocs/roscms/config.php [iso-8859-1] (original) +++ branches/danny-web/reactos.org/htdocs/roscms/config.php [iso-8859-1] Thu Feb 12 12:54:30 2009 @@ -43,8 +43,9 @@ $config->setSiteLanguage('en'); // standard language $config->setSiteTimezone(-2); // time difference to utc time from server time
-$config->setPathGenerated('/reactos/'); // path to generated files $config->setPathRoscms('/reactos/roscms/'); // path to roscms files +$config->setPathGenerationCache('../roscms_cache/'); // path to generated files (relative to roscms folder) +$config->setPathGenerated('../'); // path to generated files (relative to roscms folder)
Modified: branches/danny-web/reactos.org/htdocs/roscms/connect.db.php URL: http://svn.reactos.org/svn/reactos/branches/danny-web/reactos.org/htdocs/ros... ============================================================================== --- branches/danny-web/reactos.org/htdocs/roscms/connect.db.php [iso-8859-1] (original) +++ branches/danny-web/reactos.org/htdocs/roscms/connect.db.php [iso-8859-1] Thu Feb 12 12:54:30 2009 @@ -21,10 +21,10 @@
// Database: $db_host = 'localhost'; -$db_user = 'lev-db'; -$db_pass = 'DangerGround'; -$db_name = 'realroscms'; -$db_port = 3306; +$db_user = 'username'; +$db_pass = 'password'; +$db_name = 'roscms'; +$db_port = 3301;
// vars are unset in DBConnection class // !!! so be sure to use DBConnection or unset(..) yourself
Modified: branches/danny-web/reactos.org/htdocs/roscms/convert3to4.sql URL: http://svn.reactos.org/svn/reactos/branches/danny-web/reactos.org/htdocs/ros... ============================================================================== --- branches/danny-web/reactos.org/htdocs/roscms/convert3to4.sql [iso-8859-1] (original) +++ branches/danny-web/reactos.org/htdocs/roscms/convert3to4.sql [iso-8859-1] Thu Feb 12 12:54:30 2009 @@ -113,6 +113,7 @@ child_id bigint(20) unsigned default NULL COMMENT '->entries(id)', child_name varchar(80) collate utf8_unicode_ci default NULL, include tinyint(1) NOT NULL default '0', + user_defined tinyint(1) NOT NULL default '0', PRIMARY KEY (id), KEY rev_id (rev_id), KEY child_id (child_id), @@ -129,6 +130,7 @@ name varchar(100) collate utf8_unicode_ci NOT NULL, name_short varchar(50) collate utf8_unicode_ci NOT NULL, description varchar(255) collate utf8_unicode_ci NOT NULL, + standard tinyint(1) NOT NULL default '0', PRIMARY KEY (id), UNIQUE KEY name (name), UNIQUE KEY name_short (name_short) @@ -139,10 +141,12 @@ NULL, sec_fullname, sec_name, - sec_description + sec_description, + FALSE FROM data_security ORDER BY sec_name;
+UPDATE roscms_entries_access SET standard=TRUE WHERE name_short='default';
-- -------------------------------------------------------- @@ -271,7 +275,8 @@ (34, 'show admin filter', 'admin_filter', 'special admin filters'), (35, 'Show all filter', 'dont_hide_filter', 'don''t hide filter from users'), (36, 'Make Entries Stable', 'make_stable', 'Make Entries Stable'), -(37, 'show system entries', 'show_sys_entry', 'show entries of type ''system'''); +(37, 'show system entries', 'show_sys_entry', 'show entries of type ''system'''), +(38, 'Add manuel depencies', 'add_depencies', 'add new manuell depencies to entries');
@@ -290,7 +295,7 @@ WHERE ((a.name_short = 'system_tags' OR a.name_short = 'entry_details' OR a.name_short = 'new_entry' OR a.name_short = 'deltag' OR a.name_short = 'del_entry' OR a.name_short = 'mix_priv_pub' OR a.name_short = 'show_sys_entry' OR a.name_short = 'addlvl1group' OR a.name_short = 'more_filter' OR a.name_short = 'make_stable' OR a.name_short = 'dont_hide_filter') AND g.security_level > 1)
-OR ((a.name_short = 'delete_file' OR a.name_short = 'delmembership' OR a.name_short = 'disableaccount' OR a.name_short = 'user_details' OR a.name_short = 'other_drafts' OR a.name_short = 'stats' OR a.name_short = 'dynamic_pages' OR a.name_short = 'updatetag' OR a.name_short = 'del_wo_archiv' OR a.name_short = 'addlvl2group' OR a.name_short = 'user' OR a.name_short = 'addmembership' OR a.name_short = 'maintain' OR a.name_short = 'admin_filter') +OR ((a.name_short = 'delete_file' OR a.name_short = 'delmembership' OR a.name_short = 'disableaccount' OR a.name_short = 'user_details' OR a.name_short = 'other_drafts' OR a.name_short = 'stats' OR a.name_short = 'dynamic_pages' OR a.name_short = 'updatetag' OR a.name_short = 'del_wo_archiv' OR a.name_short = 'addlvl2group' OR a.name_short = 'user' OR a.name_short = 'addmembership' OR a.name_short = 'maintain' OR a.name_short = 'admin_filter' OR a.name_short = 'add_depencies') AND g.security_level = 3)
OR ((a.name_short = 'admin' OR a.name_short = 'logs' OR a.name_short = 'addlvl3group') @@ -721,6 +726,7 @@ DROP old_archive, ADD UNIQUE KEY type_name ( type , name ); ALTER TABLE roscms_entries_revisions DROP old_id; +ALTER TABLE roscms_entries_access DROP name_short;
Modified: branches/danny-web/reactos.org/htdocs/roscms/css/cms_website.css URL: http://svn.reactos.org/svn/reactos/branches/danny-web/reactos.org/htdocs/ros... ============================================================================== --- branches/danny-web/reactos.org/htdocs/roscms/css/cms_website.css [iso-8859-1] (original) +++ branches/danny-web/reactos.org/htdocs/roscms/css/cms_website.css [iso-8859-1] Thu Feb 12 12:54:30 2009 @@ -120,3 +120,6 @@
#legend .lbox { border: solid 1px black; width: 17px;}
+ +.deletebutton { cursor:pointer; color:#006090; font-weight: bold; } +
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/ros... ============================================================================== --- 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] Thu Feb 12 12:54:30 2009 @@ -1951,6 +1951,11 @@ alertbox('Entry updated'); break;
+ case 'updatedepencies': + alertbox(http_request.responseText); + makeRequest('?page=backend&type=text&subtype=mef&d_fl=showdepencies&d_r_id='+document.getElementById('mefrrevid').innerHTML, 'mef', 'frmedittagsc2', 'html', 'GET', ''); + break; + case 'updatetag': selectUserTags(); objid = tsplits[1]; @@ -2322,7 +2327,7 @@
// new dynamic entry case 1: - makeRequest('?page=backend&type=text&subtype=ned&action=newdynamic&name='+encodeURIComponent(document.getElementById('txtadddynsource').value), 'ned', 'newentryarea', 'html', 'GET', ''); + makeRequest('?page=backend&type=text&subtype=ned&action=newdynamic&data_id='+encodeURIComponent(document.getElementById('txtadddynsource').value), 'ned', 'newentryarea', 'html', 'GET', ''); break;
// new page & content (with template) @@ -2374,6 +2379,35 @@ document.getElementById('previewzone').innerHTML = http_request.responseText; document.getElementById('previewhead').innerHTML = '<span class="button" onclick="loadEntryTableWithOffset(roscms_current_tbl_position)"><strong>« Back</strong></span> <strong>Preview</strong>'; } // end of function showPreview + + + +/** + * add a new manual depency + * + * @param int rev_id + */ +function addDepency( rev_id ) +{ + var name = document.getElementById('dep_name').value; + + // check if name is given + if (name != '') { + makeRequest('?page=backend&type=text&subtype=mef&d_fl=adddepency&rev_id='+rev_id+'&dep_name='+encodeURIComponent(name)+'&dep_type='+encodeURIComponent(document.getElementById('dep_type').value), 'mef', 'updatedepencies', 'html', 'GET', ''); + } +} // addDepency + + + +/** + * delete a new manual depency + * + * @param int dep_id depency id + */ +function deleteDepency( dep_id ) +{ + makeRequest('?page=backend&type=text&subtype=mef&d_fl=deletedepency&dep_id='+dep_id, 'mef', 'updatedepencies', 'html', 'GET', ''); +} // deleteDepency
Modified: branches/danny-web/reactos.org/htdocs/roscms/lib/DBConnection.class.php URL: http://svn.reactos.org/svn/reactos/branches/danny-web/reactos.org/htdocs/ros... ============================================================================== --- branches/danny-web/reactos.org/htdocs/roscms/lib/DBConnection.class.php [iso-8859-1] (original) +++ branches/danny-web/reactos.org/htdocs/roscms/lib/DBConnection.class.php [iso-8859-1] Thu Feb 12 12:54:30 2009 @@ -37,7 +37,7 @@ */ public function __construct() { - global $db_host, $db_host, $db_user, $db_pass; + global $db_host, $db_host, $db_user, $db_pass, $db_port; include_once(ROSCMS_PATH.'connect.db.php');
try {
Modified: branches/danny-web/reactos.org/htdocs/roscms/lib/RosCMS.class.php URL: http://svn.reactos.org/svn/reactos/branches/danny-web/reactos.org/htdocs/ros... ============================================================================== --- branches/danny-web/reactos.org/htdocs/roscms/lib/RosCMS.class.php [iso-8859-1] (original) +++ branches/danny-web/reactos.org/htdocs/roscms/lib/RosCMS.class.php [iso-8859-1] Thu Feb 12 12:54:30 2009 @@ -44,7 +44,8 @@ private $site_language = 'en'; // standard language private $site_timezone = -2; // time difference to utc time from server time
- private $path_generated = '/reactos/'; // path to generated files + private $path_generated = '../reactos/'; // path to generated files + private $path_generation_cache = '../reactos/roscms_cache'; // path to cache files while generation process private $path_roscms = '/reactos/roscms/'; // path to roscms files
// system vars @@ -97,6 +98,7 @@ public function siteTimezone(){ return $this->site_timezone; }
public function pathGenerated() { return $this->path_generated; } + public function pathGenerationCache() { return $this->path_generation_cache; } public function pathRosCMS() { return $this->path_roscms; }
@@ -152,6 +154,11 @@ public function setPathGenerated( $new_value ) { $this->path_generated = $new_value; } + + public function setPathGenerationCache( $new_value ) { + $this->path_generation_cache = $new_value; + } + public function setPathRosCMS( $new_value ) { $this->path_roscms = $new_value; }
Modified: branches/danny-web/reactos.org/htdocs/roscms/lib/backend/Backend_ViewAddEntry.class.php URL: http://svn.reactos.org/svn/reactos/branches/danny-web/reactos.org/htdocs/ros... ============================================================================== --- branches/danny-web/reactos.org/htdocs/roscms/lib/backend/Backend_ViewAddEntry.class.php [iso-8859-1] (original) +++ branches/danny-web/reactos.org/htdocs/roscms/lib/backend/Backend_ViewAddEntry.class.php [iso-8859-1] Thu Feb 12 12:54:30 2009 @@ -65,7 +65,7 @@ * * @access private */ - private function evalAction( ) + private function evalAction( ) { switch ($_GET['action']) {
@@ -77,7 +77,22 @@
// dynamic entry - save entry case 'newdynamic': - $rev_id = Entry::add($_GET['name'], 'content', null, true); + + // 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->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); + + // show editor new Backend_ViewEditor($rev_id); break;
@@ -106,7 +121,7 @@ break; } // end switch type break; - + } // end switch action } // end of member function evalAction
Modified: branches/danny-web/reactos.org/htdocs/roscms/lib/backend/Backend_ViewEditor.class.php URL: http://svn.reactos.org/svn/reactos/branches/danny-web/reactos.org/htdocs/ros... ============================================================================== --- branches/danny-web/reactos.org/htdocs/roscms/lib/backend/Backend_ViewEditor.class.php [iso-8859-1] (original) +++ branches/danny-web/reactos.org/htdocs/roscms/lib/backend/Backend_ViewEditor.class.php [iso-8859-1] Thu Feb 12 12:54:30 2009 @@ -112,6 +112,26 @@ // show Depencies case 'showdepencies': $this->showEntryDetails(self::DEPENCIES); + break; + + // add Depencies + case 'adddepency': + if (Depencies::addManual($_GET['rev_id'],$_GET['dep_name'],$_GET['dep_type'])) { + echo 'Adding user defined depency was successful.'; + } + else { + echo 'Error while adding user defined depency.'; + } + break; + + // delete Depencies + case 'deletedepency': + if (Depencies::deleteManual($_GET['dep_id'])) { + echo 'Deleting user defined depency was successful.'; + } + else { + echo 'Error while deleting user defined depency.'; + } break;
// show Field details @@ -376,6 +396,7 @@ </span> '.$revision['name'].'</span> + <span style="display: none;" id="mefrrevid">'.$revision['id'].'</span> <span style="white-space: nowrap;">type: <span class="revDetail">'.$revision['type'].'</span></span> <span style="white-space: nowrap;">version: <span id="mefrverid" class="revDetail">'.$revision['version'].'</span></span> <span style="white-space: nowrap;">language: <span class="revDetail">'.$revision['language'].'</span><span id="mefrlang" style="display:none;">'.$revision['lang_id'].'</span></span> @@ -635,18 +656,38 @@ */ private function showEntryDepencies() { + + // add manual depency + if (ThisUser::getInstance()->hasAccess('add_depencies')) { + echo_strip(' + <h3>Add Depency</h3> + <fieldset> + <label for="dep_name">Name:</label> + <input type="text" name="dep_name" id="dep_name" /><br /> + + <label for="dep_type">Type:</label> + <select name="dep_type" id ="dep_type"> + <option value="content">Content</option> + <option value="script">Script</option> + <option value="template">Template</option> + '.(ThisUser::getInstance()->hasAccess('dynamic_pages') ? '<option value="dynamic">Dynamic Page</option>' : '').' + </select><br /> + <button type="submit" onclick="'."addDepency(".$this->rev_id.")".'">add manual depency</button> + </fieldset>'); + } + // print depency tree echo '<h3>Dependent Entries</h3>'; $this->buildDepencyTree($this->data_id);
// required articles that don't exist - $stmt=&DBConnection::getInstance()->prepare("SELECT DISTINCT child_name, include FROM ".ROSCMST_DEPENCIES." WHERE rev_id=:rev_id AND child_id IS NULL ORDER BY include DESC, child_name ASC"); + $stmt=&DBConnection::getInstance()->prepare("SELECT DISTINCT child_name, include, id, user_defined FROM ".ROSCMST_DEPENCIES." WHERE rev_id=:rev_id AND child_id IS NULL ORDER BY include DESC, child_name ASC"); $stmt->bindParam('rev_id',$this->rev_id, PDO::PARAM_INT); $stmt->execute(); $required_fail = $stmt->fetchAll(PDO::FETCH_ASSOC);
// articles that exist - $stmt=&DBConnection::getInstance()->prepare("SELECT DISTINCT d.name, d.type, w.include FROM ".ROSCMST_DEPENCIES." w JOIN ".ROSCMST_ENTRIES." d ON d.id=w.child_id WHERE rev_id=:rev_id AND w.child_name IS NULL ORDER BY w.include DESC, d.name ASC, d.type ASC"); + $stmt=&DBConnection::getInstance()->prepare("SELECT DISTINCT d.name, d.type, w.include, w.id, w.user_defined FROM ".ROSCMST_DEPENCIES." w JOIN ".ROSCMST_ENTRIES." d ON d.id=w.child_id WHERE rev_id=:rev_id AND w.child_name IS NULL ORDER BY w.include DESC, d.name ASC, d.type ASC"); $stmt->bindParam('rev_id',$this->rev_id, PDO::PARAM_INT); $stmt->execute(); $required_exist = $stmt->fetchAll(PDO::FETCH_ASSOC); @@ -658,17 +699,31 @@ if (count($required_exist) > 0) { echo '<ul>'; foreach($required_exist as $required) { - echo '<li>'.$required['name'].' ['.$required['type'].'] ('.($required['include']==true ? 'include' : 'link').')</li>'; + echo '<li>['.$required['type'].'] '.$required['name'].' ('.($required['include']==true ? 'include' : 'link').')'; + + // delete manual depency + if (ThisUser::getInstance()->hasAccess('add_depencies') && $required['user_defined']) { + echo ' <span class="deletebutton" onclick="'."deleteDepency(".$required['id'].")".'"><img src="images/remove.gif" alt="" /> Delete</span>'; + } + + echo '</li>'; } echo '</ul>'; }
if (count($required_fail) > 0) { echo_strip(' - <h4>Entries that don't exist</h4> + <h4>Required Entries that don't exist</h4> <ul>'); foreach($required_fail as $required) { - echo '<li>'.$required['child_name'].' ('.($required['include']==true ? 'include' : 'link').')</li>'; + echo '<li>'.$required['child_name'].' ('.($required['include']==true ? 'include' : 'link').')'; + + // delete manual depency + if (ThisUser::getInstance()->hasAccess('add_depencies') && $required['user_defined']) { + echo ' <span class="deletebutton" onclick="'."deleteDepency(".$required['id'].")".'"><img src="images/remove.gif" alt="" /> Delete</span>'; + } + + echo '</li>'; } echo '</ul>'; } @@ -685,7 +740,7 @@ private function buildDepencyTree( $data_id ) { // get current childs - $stmt=&DBConnection::getInstance()->prepare("SELECT d.name, l.name AS language, d.type, r.data_id FROM ".ROSCMST_DEPENCIES." w JOIN ".ROSCMST_REVISIONS." r ON w.rev_id = r.id JOIN ".ROSCMST_ENTRIES." d ON d.id=r.data_id JOIN ".ROSCMST_LANGUAGES." l ON l.id=r.lang_id WHERE w.child_id=:data_id AND w.include IS TRUE ORDER BY l.name ASC, d.name ASC"); + $stmt=&DBConnection::getInstance()->prepare("SELECT d.name, l.name AS language, d.type, r.data_id, w.user_defined, w.id FROM ".ROSCMST_DEPENCIES." w JOIN ".ROSCMST_REVISIONS." r ON w.rev_id = r.id JOIN ".ROSCMST_ENTRIES." d ON d.id=r.data_id JOIN ".ROSCMST_LANGUAGES." l ON l.id=r.lang_id WHERE w.child_id=:data_id AND w.include IS TRUE ORDER BY l.name ASC, d.name ASC"); $stmt->bindParam('data_id',$data_id, PDO::PARAM_INT); $stmt->execute(); $depencies = $stmt->fetchAll(PDO::FETCH_ASSOC); @@ -695,15 +750,19 @@ if (count($depencies) > 0) { echo '<ul>';
- $last_language = null; // show Depencies + $x=0; foreach ($depencies as $depency) { - echo '<li>'.$depency['name'].' ('.$depency['type'].') ['.$depency['language'].']'; + $x++; + echo '<li style="color: #'.($x%2 ? '000' : '777').';">['.$depency['type'].'] '.$depency['name'].' <span style="color: #'.($x%2 ? 'AAA' : 'CCC').';">('.$depency['language'].')</span>'; + + // get childs if ($data_id != $depency['data_id']) { $this->buildDepencyTree( $depency['data_id']); } echo '</li>'; - } + } // end foreach + echo '</ul>'; } elseif ($this->data_id === $data_id) { @@ -1008,7 +1067,14 @@ { // select all related entries if ($lang_id === null) { - $stmt=&DBConnection::getInstance()->prepare("SELECT r.data_id, d.name, r.id, r.lang_id, l.name AS language, r.version, DATE(r.datetime) as date, r.datetime, u.name AS user_name, r.archive FROM ".ROSCMST_ENTRIES." d JOIN ".ROSCMST_REVISIONS." r ON r.data_id = d.id JOIN ".ROSCMST_LANGUAGES." l ON r.lang_id = l.id JOIN ".ROSCMST_USERS." u ON u.id = r.user_id WHERE d.id = :data_id AND r.version > 0 ORDER BY l.name ASC, r.datetime DESC"); + if (ThisUser::getInstance()->hasAccess('more_lang')) { + $stmt=&DBConnection::getInstance()->prepare("SELECT r.data_id, d.name, r.id, r.lang_id, l.name AS language, r.version, DATE(r.datetime) as date, r.datetime, u.name AS user_name, r.archive FROM ".ROSCMST_ENTRIES." d JOIN ".ROSCMST_REVISIONS." r ON r.data_id = d.id JOIN ".ROSCMST_LANGUAGES." l ON r.lang_id = l.id JOIN ".ROSCMST_USERS." u ON u.id = r.user_id WHERE d.id = :data_id AND r.version > 0 ORDER BY l.name ASC, r.datetime DESC"); + } + else { + $stmt=&DBConnection::getInstance()->prepare("SELECT r.data_id, d.name, r.id, r.lang_id, l.name AS language, r.version, DATE(r.datetime) as date, r.datetime, u.name AS user_name, r.archive FROM ".ROSCMST_ENTRIES." d JOIN ".ROSCMST_REVISIONS." r ON r.data_id = d.id JOIN ".ROSCMST_LANGUAGES." l ON r.lang_id = l.id JOIN ".ROSCMST_USERS." u ON u.id = r.user_id WHERE d.id = :data_id AND r.version > 0 AND l.id IN(:standard_lang,:lang_id) ORDER BY l.name ASC, r.datetime DESC"); + $stmt->bindParam('standard_lang',Language::getStandardId(),PDO::PARAM_INT); + $stmt->bindParam('lang_id',ThisUser::getInstance()->language(),PDO::PARAM_INT); + } }
// select only one language
Modified: branches/danny-web/reactos.org/htdocs/roscms/lib/om/Depencies.class.php URL: http://svn.reactos.org/svn/reactos/branches/danny-web/reactos.org/htdocs/ros... ============================================================================== --- branches/danny-web/reactos.org/htdocs/roscms/lib/om/Depencies.class.php [iso-8859-1] (original) +++ branches/danny-web/reactos.org/htdocs/roscms/lib/om/Depencies.class.php [iso-8859-1] Thu Feb 12 12:54:30 2009 @@ -46,7 +46,7 @@ @set_time_limit(0);
// remove old depencies - DBConnection::getInstance()->exec("DELETE FROM ".ROSCMST_DEPENCIES); + DBConnection::getInstance()->exec("DELETE FROM ".ROSCMST_DEPENCIES." WHERE user_defined IS FALSE");
// walk trough all stable $stmt=&DBConnection::getInstance()->prepare("SELECT id FROM ".ROSCMST_REVISIONS." WHERE archive IS FALSE AND status='stable'"); @@ -146,6 +146,48 @@
/** + * add a new user defined depency + * + * @param int rev_id + * @param string name entry name + * @param string type entry type + * @return bool + * @access public + */ + public static function addManual( $rev_id, $name, $type ) + { + // check access rights + if (ThisUser::getInstance()->hasAccess('add_depencies')) { + return self::insert($rev_id, $name, $type, true); + } + return false; + } // end of member function addManual + + + + /** + * deletes a user defined Depency + * + * @param int dep_id depency id + * @return bool + * @access public + */ + public static function deleteManual( $dep_id ) + { + // check access rights + if (ThisUser::getInstance()->hasAccess('add_depencies')) { + + // delete depencies + $stmt=&DBConnection::getInstance()->prepare("DELETE FROM ".ROSCMST_DEPENCIES." WHERE id = :dep_id AND user_defined IS TRUE"); + $stmt->bindParam('dep_id',$dep_id,PDO::PARAM_INT); + return $stmt->execute(); + } + return false; + } // end of member function deleteManual + + + + /** * inserts/updates new depency into database * * @param string[] matches @@ -158,36 +200,73 @@ switch ($matches[2]) { case 'templ': $type = 'template'; - $include = true; break; case 'cont': $type = 'content'; - $include = true; break; case 'inc': $type = 'script'; - $include = true; break; case 'link': $type = 'page'; + break; + } + + return self::insert($this->rev_id, $matches[3], $type, false); + } // end of member function newDepency + + + + /** + * shared function to insert/update entries + * + * @param int rev_id parent + * @param string name child + * @param string type child + * @param bool user_defined + * @return bool + * @access public + */ + private static function insert( $rev_id, $name, $type, $user_defined ) + { + // is include depency ? + switch ($type) { + case 'template': + $depency_name = 'templ_'.$name; + $include = true; + break; + case 'content': + $depency_name = 'cont_'.$name; + $include = true; + break; + case 'script': + $depency_name = 'inc_'.$name; + $include = true; + break; + case 'dynamic': + $depency_name = 'link_'.$name; + $include = true && $user_defined; + break; + case 'page': + $depency_name = 'link_'.$name; $include = false; break; }
- // try to get depency id + // check for existing entry $stmt=&DBConnection::getInstance()->prepare("SELECT id FROM ".ROSCMST_ENTRIES." WHERE name = :name AND type = :type LIMIT 1"); - $stmt->bindParam('name',$matches[3],PDO::PARAM_STR); + $stmt->bindParam('name',$name,PDO::PARAM_STR); $stmt->bindParam('type',$type,PDO::PARAM_STR); if ($stmt->execute()) { $data_id = $stmt->fetchColumn();
// check if we already have an depency to this entry $stmt=&DBConnection::getInstance()->prepare("SELECT id FROM ".ROSCMST_DEPENCIES." WHERE child_name=:depency_name"); - $stmt->bindParam('depency_name',$matches[1],PDO::PARAM_STR); + $stmt->bindParam('depency_name',$depency_name,PDO::PARAM_STR); $stmt->execute(); $depency_id = $stmt->fetchColumn();
- // update depency with name -> depency with id + // update entry with data id instead of name&type if ($depency_id !== false) { $stmt=&DBConnection::getInstance()->prepare("UPDATE ".ROSCMST_DEPENCIES." SET child_name=NULL, child_id=:depency_id WHERE id=:depency_id"); $stmt->bindParam('child_id',$data_id,PDO::PARAM_INT); @@ -195,27 +274,28 @@ return $stmt->execute(); }
- // inseert new depency + // insert new depency else {
// insert depency with name if ($data_id === false) { - $stmt=&DBConnection::getInstance()->prepare("INSERT INTO ".ROSCMST_DEPENCIES." (rev_id, child_name, include) VALUES (:rev_id, :depency_name, :is_include)"); - $stmt->bindParam('depency_name',$matches[1],PDO::PARAM_STR); + $stmt=&DBConnection::getInstance()->prepare("INSERT INTO ".ROSCMST_DEPENCIES." (rev_id, child_name, include, user_defined) VALUES (:rev_id, :depency_name, :is_include, :user_defined)"); + $stmt->bindParam('depency_name',$depency_name,PDO::PARAM_STR); }
// insert depency with id else { - $stmt=&DBConnection::getInstance()->prepare("INSERT INTO ".ROSCMST_DEPENCIES." (rev_id, child_id, include) VALUES (:rev_id, :depency_id, :is_include)"); + $stmt=&DBConnection::getInstance()->prepare("INSERT INTO ".ROSCMST_DEPENCIES." (rev_id, child_id, include, user_defined) VALUES (:rev_id, :depency_id, :is_include, :user_defined)"); $stmt->bindParam('depency_id',$data_id,PDO::PARAM_INT); } - $stmt->bindParam('rev_id',$this->rev_id,PDO::PARAM_INT); + $stmt->bindParam('rev_id',$rev_id,PDO::PARAM_INT); $stmt->bindParam('is_include',$include,PDO::PARAM_BOOL); + $stmt->bindParam('user_defined',$user_defined,PDO::PARAM_BOOL); return $stmt->execute(); } } return false; - } // end of member function newDepency + } // end of member function deleteManual
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/ros... ============================================================================== --- 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] Thu Feb 12 12:54:30 2009 @@ -167,7 +167,7 @@ * @return bool * @access public */ - public static function add($data_name, $data_type = null, $template = '', $dynamic = false) + public static function add($data_name, $data_type = null, $template = '') { $data_name = trim($data_name);
@@ -180,11 +180,16 @@
// if entry does not exist -> create a new one if ($data_id === false) { + + $stmt_ask=&DBConnection::getInstance()->prepare("SELECT id FROM ".ROSCMST_ACCESS." WHERE standard IS TRUE"); + $stmt_ask->execute(); + $access_id = $stmt_ask->fetchColumn();
// insert new data - $stmt_ins=&DBConnection::getInstance()->prepare("INSERT INTO ".ROSCMST_ENTRIES." ( id , name , type ) VALUES ( NULL , :name, :type )"); + $stmt_ins=&DBConnection::getInstance()->prepare("INSERT INTO ".ROSCMST_ENTRIES." ( id , name , type , access_id ) VALUES ( NULL , :name, :type, :access_id )"); $stmt_ins->bindParam('name',$data_name,PDO::PARAM_STR); $stmt_ins->bindParam('type',$data_type,PDO::PARAM_STR); + $stmt_ins->bindParam('access_id',$access_id,PDO::PARAM_INT); $stmt_ins->execute();
// and get new data_id (use old used statement again) @@ -199,6 +204,7 @@
// only go on, if we got a new revision if ($rev_id === false) { + echo 'Could not create new revision, maybe the entry already exists.'; return false; }
@@ -225,16 +231,6 @@ Tag::add($rev_id, 'next_number', 1, -1); } } - elseif ($data_type == 'content' && $dynamic === true) { - - // get highest saved dynamic number for this data - $next_number = intval(Tag::getValue($rev_id,'number_next',-1)); - - // add a title - $stmt->bindValue('description','title',PDO::PARAM_STR); - $stmt->bindValue('content',$data_name.'_'.$next_number,PDO::PARAM_STR); - $stmt->execute(); - }
// set page content to template, if selected if ($template != '' && $template != 'none') { @@ -256,7 +252,7 @@ // 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->id(), -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);
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/ros... ============================================================================== --- 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] Thu Feb 12 12:54:30 2009 @@ -27,9 +27,8 @@ class Generate {
- private $destination_folder = '../'; // distance between roscms folder to pages folder - private $cache_dir = '../roscms_cache/'; // cached files - private $base_dir = ''; + private $cache_dir; // cached files + private $base_dir; // where current things are generated into (may switch between normal generation and caching generation)
// page related vars private $page_name; @@ -51,11 +50,15 @@ */ public function __construct( ) { + // setup paths for generating content and caching + $this->base_dir = ROSCMS_PATH.RosCMS::getInstance()->pathGenerated(); + $this->cache_dir = ROSCMS_PATH.RosCMS::getInstance()->pathGenerationCache(); + // set generation start time $this->begin = date('Y-m-d H:i:s');
// try to force a bigger script runtime (needed by some functions) - @set_time_limit(300); + @set_time_limit(0); } // end of constructor
@@ -130,7 +133,7 @@
// build all entries if ($id === null) { - $stmt=&DBConnection::getInstance()->prepare("SELECT d.name, type, l.id AS lang_id, l.name AS language, l.name_short AS lang_short FROM ".ROSCMST_ENTRIES." d CROSS JOIN ".ROSCMST_LANGUAGES." l WHERE (d.type = 'page' OR d.type = 'dynamic') ORDER BY l.level DESC, l.id ASC, d.name ASC"); + $stmt=&DBConnection::getInstance()->prepare("SELECT d.name, type, l.id AS lang_id, l.name AS language, l.name_short AS lang_short FROM ".ROSCMST_ENTRIES." d CROSS JOIN ".ROSCMST_LANGUAGES." l WHERE (d.type = 'page' OR d.type = 'dynamic') ORDER BY l.level DESC, l.name ASC, d.name ASC"); }
// build only the selected language @@ -141,14 +144,14 @@
// build only the selected page, in all languages elseif ($id_type === 'data') { - $stmt=&DBConnection::getInstance()->prepare("SELECT d.name, type, l.id AS lang_id, l.name AS language, l.name_short AS lang_short FROM ".ROSCMST_ENTRIES." d CROSS JOIN ".ROSCMST_LANGUAGES." l WHERE (d.type = 'page' OR d.type = 'dynamic') AND d.name = :data_name ORDER BY l.level DESC"); + $stmt=&DBConnection::getInstance()->prepare("SELECT d.name, type, l.id AS lang_id, l.name AS language, l.name_short AS lang_short FROM ".ROSCMST_ENTRIES." d CROSS JOIN ".ROSCMST_LANGUAGES." l WHERE (d.type = 'page' OR d.type = 'dynamic') AND d.name = :data_name ORDER BY l.level DESC, l.name ASC"); $stmt->bindParam('data_name',$ld,PDO::PARAM_STR); }
// build only the revision elseif ($id_type === 'revision') { - $stmt=&DBConnection::getInstance()->prepare("SELECT d.name, type, l.id AS lang_id, l.name AS language, l.name_short AS lang_short FROM ".ROSCMST_ENTRIES." d JOIN ".ROSCMST_REVISIONS." r ON r.data_id=d.id JOIN ".ROSCMST_LANGUAGES." l ON l.id=r.lang_id WHERE (d.type = 'page' OR d.type = 'dynamic') AND d.name = :data_name ORDER BY l.level DESC"); - $stmt->bindParam('data_name',$ld,PDO::PARAM_STR); + $stmt=&DBConnection::getInstance()->prepare("SELECT d.name, type, l.id AS lang_id, l.name AS language, l.name_short AS lang_short FROM ".ROSCMST_ENTRIES." d JOIN ".ROSCMST_REVISIONS." r ON r.data_id=d.id JOIN ".ROSCMST_LANGUAGES." l ON l.id=r.lang_id WHERE (d.type = 'page' OR d.type = 'dynamic') AND r.id = :rev_id"); + $stmt->bindParam('rev_id',$ld,PDO::PARAM_STR); } $stmt->execute();
@@ -157,7 +160,7 @@
// display language if ($old_lang != $data['lang_id']) { - echo '<span style="text-decoration:underline;">'.$data['language'].'</span>'; + echo '<span style="text-decoration:underline;font-size:1.3em;">'.$data['language'].'</span><br />'; $old_lang = $data['lang_id'];
$this->lang_id = $data['lang_id']; @@ -205,44 +208,38 @@ $file_name = $data_name.'.'.$file_extension;
// information, what was generated - echo $this->lang_id.'--'.$file_name.'<br />'; - - // can I copy from standard lang? Otherwise we will write a new file - if (!$this->cloneFile(RosCMS::getInstance()->siteLanguage(),$this->lang, $file_name)) { - - // needed by replacing functions - $this->page_name = $data_name; - $this->rev_id = $revision['id']; - - // file content - $content = $revision['content']; - - // used by templates - $content = str_replace('[#%NAME%]', $data_name, $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',$revision['id'],PDO::PARAM_INT); - $stmt_more->execute(); - $depencies = $stmt_more->fetchAll(PDO::FETCH_ASSOC); - foreach ($depencies as $depency) { - - // 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); - } - } - - // execute scripts - $content = preg_replace_callback('/[#inc_([^][#[:space:]]+)]/', array($this,'evalTemplate'),$content); - - // replace roscms vars - $content = $this->replaceRoscmsPlaceholder($content); - - // write content to filename, if possible - return $this->writeFile($this->lang,$file_name, $content.'<!-- Generated with '.RosCMS::getInstance()->systemBrand().' ('.RosCMS::getInstance()->systemVersion().') - '.date('Y-m-d H:i:s').' -->'); - } - return false; + echo $file_name.'<br />'; + + // needed by replacing functions + $this->page_name = $data_name; + $this->rev_id = $revision['id']; + + // file content + $content = $revision['content']; + + // used by templates + $content = str_replace('[#%NAME%]', $data_name, $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',$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); + } + } // end foreach + + // execute scripts + $content = preg_replace_callback('/[#inc_([^][#[:space:]]+)]/', array($this,'evalTemplate'),$content); + + // replace roscms vars + $content = $this->replaceRoscmsPlaceholder($content); + + // write content to filename, if possible + return $this->writeFile($this->lang,$file_name, $content.'<!-- Generated with '.RosCMS::getInstance()->systemBrand().' ('.RosCMS::getInstance()->systemVersion().') - '.date('Y-m-d H:i:s').' -->'); } // end of member function oneEntry
@@ -290,29 +287,43 @@
// information, what was generated echo $this->lang_id.'--'.$file_name.'<br />'; - - // can I copy from standard lang ? - if (!$this->cloneFile(RosCMS::getInstance()->siteLanguage(), $this->lang, $file_name)) { - - // needed by replacing functions - $this->page_name = $data_name; - $this->rev_id = $revision['id']; - $this->dynamic_num = $i; - - // used by templates - $content = str_replace('[#%NAME%]', $data_name, $revision['content']); - - // replace depencies - $content = preg_replace_callback('/[#((cont|templ)_[^][#[:space:]]+)]/', array($this,'getCached'),$content); - $content = preg_replace_callback('/[#inc_([^][#[:space:]]+)]/', array($this,'evalTemplate'),$content); - - // replace roscms vars - $content = $this->replaceRoscmsPlaceholder($content); - - // write content to filename, if possible - $this->writeFile($this->lang,$file_name, $content.'<!-- Generated with '.RosCMS::getInstance()->systemBrand().' ('.RosCMS::getInstance()->systemVersion().') - '.date('Y-m-d H:i:s').' -->'); - } - } + + // 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; + + // used by templates + $content = str_replace('[#%NAME%]', $data_name, $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->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); + } + } // end foreach + + // replace scripts + $content = preg_replace_callback('/[#inc_([^][#[:space:]]+)]/', array($this,'evalTemplate'),$content); + + // replace roscms vars + $content = $this->replaceRoscmsPlaceholder($content); + + // write content to filename, if possible + $this->writeFile($this->lang,$file_name, $content.'<!-- Generated with '.RosCMS::getInstance()->systemBrand().' ('.RosCMS::getInstance()->systemVersion().') - '.date('Y-m-d H:i:s').' -->'); + } // end for } // end of member function makeDynamic
@@ -339,7 +350,7 @@ $stmt->execute(); $revision=$stmt->fetchOnce(PDO::FETCH_ASSOC);
- // cache revision (set language, cache, restore base_dir) + // cache revision (set language, cache) $this->lang_id = $revision['lang_id']; $this->cacheFiles($revision['data_id']);
@@ -403,6 +414,7 @@ break; } // end switch } // end while depency + return true; } // end of member function update
@@ -427,16 +439,17 @@ }
if ($data_id === null) { - $stmt=&DBConnection::getInstance()->prepare("SELECT d.id AS data_id, d.type, d.name, l.id AS lang_id FROM ".ROSCMST_ENTRIES." d CROSS JOIN ".ROSCMST_LANGUAGES." l WHERE d.type = 'content' OR d.type = 'script' OR d.type='template' ORDER BY l.level DESC"); + $stmt=&DBConnection::getInstance()->prepare("SELECT d.id AS data_id, d.type, d.name, l.id AS lang_id FROM ".ROSCMST_ENTRIES." d CROSS JOIN ".ROSCMST_LANGUAGES." l WHERE d.type = 'content' OR d.type = 'script' OR d.type='template' ORDER BY l.level DESC, l.name ASC"); } else { - $stmt=&DBConnection::getInstance()->prepare("SELECT d.id AS data_id, d.type, d.name, l.id AS lang_id FROM ".ROSCMST_ENTRIES." d CROSS JOIN ".ROSCMST_LANGUAGES." l WHERE d.id=:data_id ORDER BY l.level DESC"); + $stmt=&DBConnection::getInstance()->prepare("SELECT id AS data_id, type, name, :lang_id AS lang_id FROM ".ROSCMST_ENTRIES." WHERE id=:data_id"); $stmt->bindParam('data_id',$data_id,PDO::PARAM_INT); + $stmt->bindParam('lang_id',$this->lang_id,PDO::PARAM_INT); } $stmt->execute();
// prepare for usage in loop - $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=&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'");
while ($data = $stmt->fetch(PDO::FETCH_ASSOC)) {
@@ -446,12 +459,11 @@ }
$filename = $this->short[$data['type']].'_'.$data['name'].'.rcf'; - $file = $data['lang_id'].'/'.$filename;
$revision = $this->getFrom($data['type'],$data['name']); - + // can I copy from standard language ? - if (!$this->cloneFile(Language::getStandardId(),$data['lang_id'], $filename)) { + if (!$this->cloneFile(Language::getStandardId(),$data['lang_id'], $filename, $revision['lang_id'])) {
// generate file $this->rev_id = $revision['id']; @@ -478,14 +490,13 @@ // cache dependent entries first $depency_file = $data['lang_id'].'/'.$this->short[$depency['type']].'_'.$depency['name'].'.rcf'; if (!file_exists($this->cache_dir.$depency_file) || $this->begin > date('Y-m-d H:i:s',filemtime($this->cache_dir.$depency_file))) { - $this->cacheFiles($depency['id']); + $this->cacheFiles($depency['child_id']); }
// replace - $content = str_replace('[#'.$this->short[$depency['type']].'_'.$depency['name'].']', $this->getCached(array(null, $this->short[$depency['type']].'_'.$depency['name'])), $content); + $content = '~'.$this->lang_id.'~'.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); } } // end while @@ -493,6 +504,7 @@ // reset old build path if ($first == $data_id) { $this->base_dir = $backup; + $backup = null; } } // end of member function cacheFiles
@@ -578,7 +590,9 @@
/** - * + * returns an array with revision information & text + * - if an localized version is available that one is returned + * - otherwise the standard language version * * @param string type * @param string name @@ -588,7 +602,7 @@ private function getFrom( $type, $name ) { // get entry - $stmt=&DBConnection::getInstance()->prepare("SELECT t.content, r.id, r.lang_id, r.version, r.status 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.version > 0 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); @@ -651,14 +665,17 @@ * This function tries to copy a file from the standard language folder to another language folder * * @param string source_folder + * @param string dest_folder + * @param string filename + * @param int content_lang * @return bool * @access private */ - private function cloneFile( $source_folder, $dest_folder, $filename ) + private function cloneFile( $source_folder, $dest_folder, $filename, $content_lang ) { // check, if language is different than standard and if requested file exists - if ($this->lang_id != Language::getStandardId() && file_exists($this->base_dir.$source_folder.'/'.$filename)) { - return copy($this->base_dir.$source_folder.'/'.$filename, $this->base_dir.$dest_folder.'/'.$filename); + if ($this->lang_id != Language::getStandardId() && $content_lang == Language::getStandardId() && file_exists($this->base_dir.$source_folder.'/'.$filename)) { + return @copy($this->base_dir.$source_folder.'/'.$filename, $this->base_dir.$dest_folder.'/'.$filename); } return false; } // end of member function cloneFile @@ -717,6 +734,9 @@ eval('?>'.$revision['content']); $content = ob_get_contents(); ob_end_clean(); + + // replace roscms links + $content = preg_replace_callback('/[#link_([^][#[:space:]]+)]/', array($this, 'replaceWithHyperlink'), $content); }
// no other script types supported -> return nothing @@ -724,9 +744,6 @@ $content = $revision['content']; }
- // replace roscms links - $content = preg_replace_callback('/[#link_([^][#[:space:]]+)]/', array($this, 'replaceWithHyperlink'), $content); - return $content; } // end of member function evalTemplate
Modified: branches/danny-web/reactos.org/htdocs/roscms/lib/view/HTML_User_Login.class.php URL: http://svn.reactos.org/svn/reactos/branches/danny-web/reactos.org/htdocs/ros... ============================================================================== --- branches/danny-web/reactos.org/htdocs/roscms/lib/view/HTML_User_Login.class.php [iso-8859-1] (original) +++ branches/danny-web/reactos.org/htdocs/roscms/lib/view/HTML_User_Login.class.php [iso-8859-1] Thu Feb 12 12:54:30 2009 @@ -28,6 +28,13 @@ class HTML_User_Login extends HTML_User {
+ + + private $err_message=null; + private $random_string_security=null; + + + /** * * @@ -36,6 +43,17 @@ public function __construct( ) { session_start(); + $this->checkLogin(); + + $config = &RosCMS::getInstance(); + + if (isset($_GET['sec']) && $_GET['sec'] == 'security') { + $this->random_string_security = $this->makeKey(); + Cookie::write($config->cookieSecure(), $this->random_string_security, 0); + } + else { + Cookie::write($config->cookieSecure(), '', time() - 3600); + }
// register js files $this->register_js('md5.js'); @@ -44,21 +62,21 @@
- protected function body( ) + protected function checkLogin( ) { $config = &RosCMS::getInstance();
// show login dialog if (empty($_POST[$config->cookieUserName()]) && empty($_POST[$config->cookiePassword()])) { - self::loginPage(); + $this->loginPage(); }
// pw or user are not set elseif(empty($_POST[$config->cookieUserName()])) { - self::loginPage('Please enter your username!'); + $this->loginPage('Please enter your username!'); } elseif(empty($_POST[$config->cookiePassword()])) { - self::loginPage('Please enter your password'); + $this->loginPage('Please enter your password'); }
// try to login the user @@ -71,7 +89,7 @@ $session_found = true; } else { - $session_id = self::makeKey(); + $session_id = $this->makeKey(); $session_found = false; }
@@ -80,7 +98,7 @@ $user_name = $matches[1]; } else { - self::loginPage('You have specified an incorrect username.'); + $this->loginPage('You have specified an incorrect username.'); exit; }
@@ -89,7 +107,7 @@ $password = $matches[1]; } else { - self::loginPage('You have specified an invalid password.'); + $this->loginPage('You have specified an invalid password.'); exit; }
@@ -110,13 +128,13 @@ }
if ($a_password != $user['password']) { - self::loginPage("You have specified an incorrect or inactive username, or an invalid password."); + $this->loginPage("You have specified an incorrect or inactive username, or an invalid password."); exit; }
// if the account is NOT enabled; e.g. a reason could be that a member of the admin group has disabled this account because of spamming, etc. if ($user['disabled'] == true) { - self::loginPage('Account is not activated or disabled!<br /><br />Check your email inbox (and spam folder), maybe you have overseen the activation information.'); + $this->loginPage('Account is not activated or disabled!<br /><br />Check your email inbox (and spam folder), maybe you have overseen the activation information.'); exit; }
@@ -191,6 +209,7 @@ } // end of member function body
+ /** * shows page with login formular * @@ -198,18 +217,19 @@ */ private function loginPage( $err_message = '' ) { + $this->err_message = $err_message; + } + + + + /** + * shows page with login formular + * + * @access private + */ + protected function body( ) + { $config = &RosCMS::getInstance(); - - //@ADD comment -> why do we need this - $random_string_security = ''; - - if (isset($_GET['sec']) && $_GET['sec'] == 'security') { - $random_string_security = self::makeKey(); - Cookie::write($config->cookieSecure(), $random_string_security, 0); - } - else { - Cookie::write($config->cookieSecure(), '', time() - 3600); - }
$target_clean = ''; if (isset($_REQUEST['target']) && preg_match('/^(/[a-zA-Z0-9!$%&,'()*+-./:;=?@_~]+)$/', $_REQUEST['target'], $matches)) { @@ -262,20 +282,20 @@ } echo_strip(' <input name="logintype" type="hidden" id="logintype" value="'.((isset($_GET['sec']) && $_GET['sec'] == 'security') ? 'security' : 'standard').'" /> - <button type="submit" name="submit"'.((isset($_GET['sec']) && $_GET['sec'] == 'security') ? ' onclick="'.$config->cookiePassword().'.value = calcMD5(''.$random_string_security.'' + calcMD5('.$config->cookiePassword().'.value))"': '').'>Login</button> + <button type="submit" name="submit"'.((isset($_GET['sec']) && $_GET['sec'] == 'security') ? ' onclick="'.$config->cookiePassword().'.value = calcMD5(''.$this->random_string_security.'' + calcMD5('.$config->cookiePassword().'.value))"': '').'>Login</button> </div> <div class="corner_BL"> <div class="corner_BR"></div> </div> </div>');
- if ($err_message != "") { + if ($this->err_message != "") { echo_strip(' <div class="bubble message"> <div class="corner_TL"> <div class="corner_TR"></div> </div> - <strong>');echo $err_message;echo_strip('</strong> + <strong>');echo $this->err_message;echo_strip('</strong> <div class="corner_BL"> <div class="corner_BR"></div> </div>