[Phpbbproject-svn] SF.net SVN: phpbbproject: [265] trunk
phpBB download manager, mainly aimed at MOD authors
Status: Planning
Brought to you by:
lord_le_brand
From: <lor...@us...> - 2008-04-23 19:51:20
|
Revision: 265 http://phpbbproject.svn.sourceforge.net/phpbbproject/?rev=265&view=rev Author: lord_le_brand Date: 2008-04-23 12:51:18 -0700 (Wed, 23 Apr 2008) Log Message: ----------- Merged project_actions and project_action_contents Wrote project_import_modx class Modified Paths: -------------- trunk/develop/create_schema_files_phpbb3.php trunk/phpbb3/root/includes/sources_project/download_project.php trunk/phpbb3/root/includes/sources_project/import_project.php trunk/phpbb3/root/project_install/schemas/mysql_41_schema.sql Added Paths: ----------- trunk/phpbb3/root/store/phpbbproject/import/ Modified: trunk/develop/create_schema_files_phpbb3.php =================================================================== --- trunk/develop/create_schema_files_phpbb3.php 2008-04-23 00:26:14 UTC (rev 264) +++ trunk/develop/create_schema_files_phpbb3.php 2008-04-23 19:51:18 UTC (rev 265) @@ -875,6 +875,7 @@ 'project_target_version' => array('VCHAR:10', ''), 'project_version' => array('VCHAR:15', ''), 'project_stage' => array('TINT:2', '0'), + 'project_target' => array('XSTEXT_UNI', ''), 'project_logo' => array('VCHAR', ''), 'project_logo_type' => array('TINT:2', '0'), 'project_logo_width' => array('USINT', '0'), @@ -882,7 +883,7 @@ 'project_start_time' => array('UINT:11', '0'), 'project_owner' => array('UINT', '0'), 'project_last_update' => array('UINT:11', '0'), - 'is_active' => array('BOOL', '1'), + 'project_status' => array('BOOL', '0'), 'file_only' => array('BOOL', '0'), 'project_downloads' => array('UINT:11', '0'), ), Modified: trunk/phpbb3/root/includes/sources_project/download_project.php =================================================================== --- trunk/phpbb3/root/includes/sources_project/download_project.php 2008-04-23 00:26:14 UTC (rev 264) +++ trunk/phpbb3/root/includes/sources_project/download_project.php 2008-04-23 19:51:18 UTC (rev 265) @@ -14,6 +14,7 @@ * Handles packaging * * @package phpbbproject + * @todo Make downlaod class work woth /templates and /languages */ class download_project { @@ -44,7 +45,13 @@ public $actions_sql = array(); public $actions_diy = array(); - + /** + * Constructor + * + * @param integer $project_id + * @param string $archive_type + * @param integer $download_type + */ function __construct($project_id, $archive_type = 'zip', $download_type = PROJECT_DOWNLOAD_NORMAL) { global $db; @@ -257,32 +264,19 @@ PROJECT_ACTION_REPLACE_WITH => 'replace with', ); - /** - * @todo Change these queries to work on new SQL schema - */ - $sql = 'SELECT action_id - FROM ' . PROJECT_ACTIONS_TABLE . " - WHERE project_id = $this->project_id - AND action_type <> " . PROJECT_ACTION_DELETED; - $db->sql_query($sql, 604800); - $action_ids = array(); - while ($row = $db->sql_fetchrow()) - { - $action_ids[] = $row['action_id']; - } - $db->sql_freeresult(); - - $sql = 'SELECT ac.* - FROM ' . PROJECT_ACTION_CONTENTS_TABLE . ' ac - WHERE ' . $db->sql_in_set('ac.action_id', $action_ids) . ' - AND ac.version_time = + // Get the newest versions of the actions up to $this->version_time + $sql = 'SELECT a.* + FROM ' . PROJECT_ACTIONS_TABLE . " a + WHERE a.project_id = $this->project_id + AND a.action_type <> " . PROJECT_ACTION_DELETED . ' + AND a.version_time = ( - SELECT MAX(ac2.version_time) - FROM ' . PROJECT_ACTION_CONTENTS_TABLE . " ac2 - WHERE ac2.version_time <= $this->version_time - AND ac2.action_id = ac.action_id + SELECT MAX(a2.version_time) + FROM ' . PROJECT_ACTIONS_TABLE . " a2 + WHERE a2.version_time <= $this->version_time + AND a2.action_id = a.action_id ) - ORDER BY action_order ASC"; + ORDER BY action_order"; $db->sql_query($sql, 604800); $open_file = ''; Modified: trunk/phpbb3/root/includes/sources_project/import_project.php =================================================================== --- trunk/phpbb3/root/includes/sources_project/import_project.php 2008-04-23 00:26:14 UTC (rev 264) +++ trunk/phpbb3/root/includes/sources_project/import_project.php 2008-04-23 19:51:18 UTC (rev 265) @@ -9,6 +9,340 @@ */ /** + * Base import class + * + * @package create_project + */ +abstract class project_import_base +{ + protected $install_file, $install_filetype; + public $data = array(); + public $authors = array(); + public $history = array(); + public $actions = array(); + public $files; + protected $parser; + + public function process() + { + global $phpbb_root_path, $phpEx; + + if (!class_exists('parser_base')) + { + include("{$phpbb_root_path}includes/sources_project/mod/parser.$phpEx"); + } + + switch ($this->install_filetype) + { + case 'mod': + $this->parser = new parser_mod($this->install_file); + break; + + case 'modx': + $this->parser = new parser_modx($this->install_file); + break; + } + + $this->parser->parse(); + + $this->data = array_merge($this->data, array( + 'project_title' => $this->parser->mod_title, + 'project_description' => $this->parser->mod_description, + 'project_notes' => $this->parser->author_notes, + 'project_target_version' => serialize($this->parser->target_version_p), + 'project_version' => $this->parser->mod_version, + 'file_only' => 0, + )); + + $this->process_actions(); + $this->process_authors(); + $this->process_history(); + } + + /** + * Get the actions into place + */ + protected function process_actions() + { + $order = 0; + + for ($i = 0, $size = sizeof($this->parser->actions_copy); $i < $size; $i++) + { + $this->actions[] = array( + 'action_order' => $order, + 'action_file' => '', + 'action_type' => PROJECT_ACTION_COPY, + 'action_content' => 'copy ' . $this->parser->actions_copy[$i][0] . ' to ' . $this->parser->actions_copy[$i][1], + 'action_comment' => '' + ); + + $order++; + } + + for ($i = 0, $size = sizeof($this->parser->actions_sql); $i < $size; $i++) + { + $this->actions[] = array( + 'action_order' => $order, + 'action_file' => '', + 'action_type' => PROJECT_ACTION_SQL, + 'action_content' => $this->parser->actions_sql[$i], + 'action_comment' => '' + ); + + $order++; + } + + for ($i = 0, $size = sizeof($this->parser->actions); $i < $size; $i++) + { + switch ($this->parser->actions[$i]['type']) + { + case 'open': + $file_open = $this->parser->actions[$i]['data']; + break; + + case 'find': + $this->actions[] = array( + 'action_order' => $order, + 'action_file' => $file_open, + 'action_type' => PROJECT_ACTION_FIND, + 'action_content' => $this->parser->actions[$i]['data'], + 'action_comment' => $this->parser->actions[$i]['comment'] + ); + + $order++; + break; + + case 'after, add': + $this->actions[] = array( + 'action_order' => $order, + 'action_file' => $file_open, + 'action_type' => PROJECT_ACTION_AFTER_ADD, + 'action_content' => $this->parser->actions[$i]['data'], + 'action_comment' => '' + ); + + $order++; + break; + + case 'before, add': + $this->actions[] = array( + 'action_order' => $order, + 'action_file' => $file_open, + 'action_type' => PROJECT_ACTION_BEFORE_ADD, + 'action_content' => $this->parser->actions[$i]['data'], + 'action_comment' => '' + ); + + $order++; + break; + + case 'replace with': + $this->actions[] = array( + 'action_order' => $order, + 'action_file' => $file_open, + 'action_type' => PROJECT_ACTION_REPLACE_WITH, + 'action_content' => $this->parser->actions[$i]['data'], + 'action_comment' => '' + ); + + $order++; + break; + + case 'increment': + $this->actions[] = array( + 'action_order' => $order, + 'action_file' => $file_open, + 'action_type' => PROJECT_ACTION_INCREMENT, + 'action_content' => $this->parser->actions[$i]['data'], + 'action_comment' => '' + ); + + $order++; + break; + + case 'in-line find': + $this->actions[] = array( + 'action_order' => $order, + 'action_file' => $file_open, + 'action_type' => PROJECT_ACTION_INLINE_FIND, + 'action_content' => $this->parser->actions[$i]['data'], + 'action_comment' => $this->parser->actions[$i]['comment'] + ); + + $order++; + break; + + case 'in-line after, add': + $this->actions[] = array( + 'action_order' => $order, + 'action_file' => $file_open, + 'action_type' => PROJECT_ACTION_INLINE_AFTER_ADD, + 'action_content' => $this->parser->actions[$i]['data'], + 'action_comment' => '' + ); + + $order++; + break; + + case 'in-line before, add': + $this->actions[] = array( + 'action_order' => $order, + 'action_file' => $file_open, + 'action_type' => PROJECT_ACTION_INLINE_BEFORE_ADD, + 'action_content' => $this->parser->actions[$i]['data'], + 'action_comment' => '' + ); + + $order++; + break; + + case 'in-line replace with': + $this->actions[] = array( + 'action_order' => $order, + 'action_file' => $file_open, + 'action_type' => PROJECT_ACTION_INLINE_REPLACE_WITH, + 'action_content' => $this->parser->actions[$i]['data'], + 'action_comment' => '' + ); + + $order++; + break; + + case 'in-line increment': + $this->actions[] = array( + 'action_order' => $order, + 'action_file' => $file_open, + 'action_type' => PROJECT_ACTION_INLINE_INCREMENT, + 'action_content' => $this->parser->actions[$i]['data'], + 'action_comment' => '' + ); + + $order++; + break; + } + } + + for ($i = 0, $size = sizeof($this->parser->actions_diy); $i < $size; $i++) + { + $this->actions[] = array( + 'action_order' => $order, + 'action_file' => '', + 'action_type' => PROJECT_ACTION_DIY, + 'action_content' => $this->parser->actions_diy[$i], + 'action_comment' => '' + ); + + $order++; + } + } + + /** + * Get the version history + */ + protected function process_history() + { + $stages = array( + 'alpha' => PROJECT_STAGE_ALPHA, + 'beta' => PROJECT_STAGE_BETA, + 'release-candidate' => PROJECT_STAGE_RC, + 'gamma' => PROJECT_STAGE_RC, + 'delta' => PROJECT_STAGE_RC, + 'stable' => PROJECT_STAGE_STABLE, + '' => PROJECT_STAGE_DEV, + ); + + for ($i = 0, $size = sizeof($this->parser->mod_history); $i < $size; $i++) + { + $this->history[] = array( + 'version_time' => $this->parser->mod_history[$i]['time'], + 'version_major' => $this->parser->mod_history[$i]['version_p'][0], + 'version_minor' => $this->parser->mod_history[$i]['version_p'][1], + 'version_revision' => $this->parser->mod_history[$i]['version_p'][2], + 'version_release' => $this->parser->mod_history[$i]['version_p'][3], + 'version_stage' => $stages[$this->parser->mod_history[$i]['stage']], + 'version_changelog' => implode("\n", $this->parser->mod_history[$i]['changelog']), + ); + } + } + + /** + * Get author information + */ + protected function process_authors() + { + for ($i = 0, $size = sizeof($this->parser->mod_authors); $i < $size; $i++) + { + $this->authors[] = array( + 'author_username' => $this->parser->mod_authors[$i]['username'], + 'author_realname' => $this->parser->mod_authors[$i]['realname'], + 'author_email' => $this->parser->mod_authors[$i]['email'], + 'author_website' => $this->parser->mod_authors[$i]['website'], + ); + } + } +} + +/** + * Import Project from MODX package. + * + * This class will import a project from a MODX package. + * It will assume that it is packaged according to the packaging standards. + * + * @package create_project + */ +class project_import_modx extends project_import_base +{ + /** + * Constructor + * + * @param string $input + * @todo make it work with /languages and /templates folders + */ + public function __construct($input) + { + global $phpbb_root_path, $phpEx; + + $this->install_filetype = 'modx'; + $filename = substr(basename($input), 0, strpos(basename($input), '.')); + + if (!class_exists('compress_zip')) + { + include("{$phpbb_root_path}includes/functions_compress.$phpEx"); + } + + $compress = new compress_zip('r', $input); + $compress->extract("{$phpbb_root_path}store/phpbbproject/import/$filename/"); + + $directory = "{$phpbb_root_path}store/phpbbproject/import/$filename"; + + if (is_dir("$directory/$filename")) + { + $directory .= "/$filename"; + } + + $file_content = ''; + + $dir = dir($directory); + while (false !== ($file = $dir->read())) + { + if (preg_match('#(.+)\.xml$#i', $file, $matches)) + { + $file_content = file_get_contents("$directory/{$matches[0]}"); + } + } + + if (empty($file_content)) + { + $this->error = 'PROJECT_IMPORT_FAILED'; + return; + } + + $this->install_file = $file_content; + + } +} + +/** * Import Project from SVN Repository * * This class will import a project from a Subversion repository. @@ -17,9 +351,21 @@ * * @package create_project */ -class project_import_svn +class project_import_svn extends project_import_base { + protected $repository, $path, $revision; + /** + * Constructor + * + * @param string $repository + * @param string|boolean $path + * @param integer|boolean $revision + */ + public function __construct($repository, $path = false, $revision = false) + { + // UNIX/Windows? + } } ?> \ No newline at end of file Modified: trunk/phpbb3/root/project_install/schemas/mysql_41_schema.sql =================================================================== --- trunk/phpbb3/root/project_install/schemas/mysql_41_schema.sql 2008-04-23 00:26:14 UTC (rev 264) +++ trunk/phpbb3/root/project_install/schemas/mysql_41_schema.sql 2008-04-23 19:51:18 UTC (rev 265) @@ -63,10 +63,9 @@ project_logo_width smallint(4) UNSIGNED DEFAULT '0' NOT NULL, project_logo_height smallint(4) UNSIGNED DEFAULT '0' NOT NULL, project_start_time int(11) UNSIGNED DEFAULT '0' NOT NULL, - project_start_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - project_start_author varchar(255) DEFAULT '' NOT NULL, + project_owner mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, project_last_update int(11) UNSIGNED DEFAULT '0' NOT NULL, - is_active tinyint(1) UNSIGNED DEFAULT '1' NOT NULL, + project_status tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, file_only tinyint(1) UNSIGNED DEFAULT '0' NOT NULL, project_downloads int(11) UNSIGNED DEFAULT '0' NOT NULL, PRIMARY KEY (project_id), @@ -75,14 +74,6 @@ ) CHARACTER SET `utf8` COLLATE `utf8_bin`; -# Table: 'phpbb_project_actions' -CREATE TABLE phpbb_project_actions ( - action_id int(11) UNSIGNED NOT NULL auto_increment, - project_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, - PRIMARY KEY (action_id) -) CHARACTER SET `utf8` COLLATE `utf8_bin`; - - # Table: 'phpbb_project_versions' CREATE TABLE phpbb_project_versions ( version_id int(11) UNSIGNED NOT NULL auto_increment, @@ -92,17 +83,18 @@ version_major tinyint(3) DEFAULT '0' NOT NULL, version_minor tinyint(3) DEFAULT '0' NOT NULL, version_revision tinyint(3) DEFAULT '0' NOT NULL, - version_release varchar(1) DEFAULT '' NOT NULL, version_stage tinyint(2) DEFAULT '0' NOT NULL, + version_release varchar(1) DEFAULT '' NOT NULL, version_changelog mediumtext NOT NULL, PRIMARY KEY (version_id), KEY project_id (project_id) ) CHARACTER SET `utf8` COLLATE `utf8_bin`; -# Table: 'phpbb_project_action_contents' -CREATE TABLE phpbb_project_action_contents ( +# Table: 'phpbb_project_actions' +CREATE TABLE phpbb_project_actions ( action_id int(11) UNSIGNED DEFAULT '0' NOT NULL, + project_id mediumint(8) UNSIGNED DEFAULT '0' NOT NULL, version_id int(11) UNSIGNED DEFAULT '0' NOT NULL, version_time int(11) UNSIGNED DEFAULT '0' NOT NULL, action_order smallint(4) UNSIGNED DEFAULT '0' NOT NULL, @@ -111,6 +103,7 @@ action_content mediumtext NOT NULL, action_comment text NOT NULL, PRIMARY KEY (action_id, version_id), + KEY project_id (project_id), KEY action_order (action_order), KEY version_time (version_time) ) CHARACTER SET `utf8` COLLATE `utf8_bin`; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |