View source
<?php
function exif_install() {
switch ($GLOBALS['db_type']) {
case 'mysql':
case 'mysqli':
db_query("CREATE TABLE {exif_tags} (\n ifd int(10) unsigned NOT NULL default '0',\n tag int(10) unsigned NOT NULL default '0',\n status int(10) unsigned NOT NULL default '0',\n weight int(11) NOT NULL default '0',\n PRIMARY KEY (ifd, tag)\n ) /*!40100 DEFAULT CHARACTER SET utf8 */;");
db_query("CREATE TABLE {exif} (\n fid int(10) unsigned NOT NULL default '0',\n ifd int(10) unsigned NOT NULL default '0',\n tag int(10) unsigned NOT NULL default '0',\n value varchar(255) NOT NULL default '',\n PRIMARY KEY (fid, ifd, tag)\n ) /*!40100 DEFAULT CHARACTER SET utf8 */;");
break;
case 'pgsql':
db_query("CREATE TABLE {exif_tags} (\n ifd integer NOT NULL default '0',\n tag integer NOT NULL default '0',\n status integer NOT NULL default '0',\n weight integer NOT NULL default '0',\n PRIMARY KEY (ifd, tag)\n );");
db_query("CREATE TABLE {exif} (\n fid int(10) unsigned NOT NULL default '0',\n ifd int(10) unsigned NOT NULL default '0',\n tag int(10) unsigned NOT NULL default '0',\n value varchar(255) NOT NULL default '',\n PRIMARY KEY (fid, ifd, tag)\n );");
break;
}
}
function exif_update_1() {
$ret[] = update_sql('ALTER TABLE {exif} RENAME TO {exif_tags}');
switch ($GLOBALS['db_type']) {
case 'mysql':
case 'mysqli':
$ret[] = update_sql("CREATE TABLE {exif} (\n fid int(10) unsigned NOT NULL default '0',\n ifd int(10) unsigned NOT NULL default '0',\n tag int(10) unsigned NOT NULL default '0',\n value varchar(255) NOT NULL default '',\n PRIMARY KEY (fid, ifd, tag)\n ) /*!40100 DEFAULT CHARACTER SET utf8 */;");
break;
case 'pgsql':
$ret[] = update_sql("CREATE TABLE {exif} (\n fid int(10) unsigned NOT NULL default '0',\n ifd int(10) unsigned NOT NULL default '0',\n tag int(10) unsigned NOT NULL default '0',\n value varchar(255) NOT NULL default '',\n PRIMARY KEY (fid, ifd, tag)\n );");
break;
}
return $ret;
}
function exif_update_2() {
if (!isset($_SESSION['exif_update_2'])) {
$_SESSION['exif_update_2']['nid'] = 0;
$_SESSION['exif_update_2']['max'] = db_result(db_query("SELECT MAX(nid) FROM {node} WHERE type = 'image'"));
}
$context =& $_SESSION['exif_update_2'];
$result = db_query_range("SELECT f.* FROM {files} f JOIN {node} n ON n.nid = f.nid\n WHERE n.type = 'image' AND n.nid > %d AND f.filename = '_original'\n ORDER BY n.nid DESC", $context['nid'], 0, 20);
while ($file = db_fetch_object($result)) {
_update_exif_data($file);
$context['nid'] = $file->nid;
}
if ($context['nid'] < $context['max']) {
return array(
'#finished' => $context['nid'] / $context['max'],
);
}
else {
unset($_SESSION['exif_update_2']);
return array(
'#finished' => 1,
);
}
}
function exif_uninstall() {
db_query('DROP TABLE {exif_tags}');
db_query('DROP TABLE {exif}');
}