diff -c -r -x CVS -x '*~' phase3/LocalSettings.sample ../phase3/LocalSettings.sample *** phase3/LocalSettings.sample Wed Nov 19 07:37:07 2003 --- ../phase3/LocalSettings.sample Tue Jan 6 04:04:32 2004 *************** *** 38,43 **** --- 38,49 ---- $wgDBminWordLen = 3; # Match this to your MySQL fulltext $wgDBtransactions = false; # Set to true if using InnoDB tables + # This is the location of the convert and composite programs + # from the ImageMagick toolbox. You need it for the image + # resizing functionality + $wgImageMagickConvertCommand = "/home/jf/bin/convert"; + $wgImageMagickCompositeCommand = "/home/jf/bin/composite"; + # This code is still slightly experimental. Turn it off if "What links here" # and similar stuff does not work. $wgUseBetterLinksUpdate=true; diff -c -r -x CVS -x '*~' phase3/includes/GlobalFunctions.php ../phase3/includes/GlobalFunctions.php *** phase3/includes/GlobalFunctions.php Mon Dec 22 05:14:33 2003 --- ../phase3/includes/GlobalFunctions.php Sun Jan 4 23:59:30 2004 *************** *** 99,110 **** return wfUrlencode( $url ); } ! function wfImageArchiveUrl( $name ) { global $wgUploadPath; ! $hash = md5( substr( $name, 15) ); ! $url = "{$wgUploadPath}/archive/" . $hash{0} . "/" . substr( $hash, 0, 2 ) . "/{$name}"; return $url; } --- 99,141 ---- return wfUrlencode( $url ); } ! function wfImagePath( $img ) ! { ! global $wgUploadDirectory; ! ! $nt = Title::newFromText( $img ); ! if( !$nt ) return ""; ! ! $name = $nt->getDBkey(); ! $hash = md5( $name ); ! ! $url = "{$wgUploadDirectory}/" . $hash{0} . "/" . ! substr( $hash, 0, 2 ) . "/{$name}"; ! return wfUrlencode( $url ); ! } ! ! function wfThumbUrl( $img ) ! { ! global $wgUploadPath; ! ! $nt = Title::newFromText( $img ); ! if( !$nt ) return ""; ! ! $name = $nt->getDBkey(); ! $hash = md5( $name ); ! ! $url = "{$wgUploadPath}/thumb/" . $hash{0} . "/" . ! substr( $hash, 0, 2 ) . "/{$name}"; ! return wfUrlencode( $url ); ! } ! ! ! function wfImageArchiveUrl( $name, $subdir="archive" ) { global $wgUploadPath; ! $hash = md5( $name ); ! $url = "{$wgUploadPath}/{$subdir}/" . $hash{0} . "/" . substr( $hash, 0, 2 ) . "/{$name}"; return $url; } *************** *** 434,446 **** return $dest; } ! function wfImageArchiveDir( $fname ) { global $wgUploadDirectory; $hash = md5( $fname ); $oldumask = umask(0); ! $archive = "{$wgUploadDirectory}/archive"; if ( ! is_dir( $archive ) ) { mkdir( $archive, 0777 ); } $archive .= "/" . $hash{0}; if ( ! is_dir( $archive ) ) { mkdir( $archive, 0777 ); } --- 465,477 ---- return $dest; } ! function wfImageArchiveDir( $fname , $subdir="archive") { global $wgUploadDirectory; $hash = md5( $fname ); $oldumask = umask(0); ! $archive = "{$wgUploadDirectory}/{$subdir}"; if ( ! is_dir( $archive ) ) { mkdir( $archive, 0777 ); } $archive .= "/" . $hash{0}; if ( ! is_dir( $archive ) ) { mkdir( $archive, 0777 ); } diff -c -r -x CVS -x '*~' phase3/includes/ImagePage.php ../phase3/includes/ImagePage.php *** phase3/includes/ImagePage.php Mon Nov 24 11:48:39 2003 --- ../phase3/includes/ImagePage.php Mon Jan 5 16:46:07 2004 *************** *** 7,12 **** --- 7,16 ---- class ImagePage extends Article { function view() { + if ( Namespace::getImage() == $this->mTitle->getNamespace() ) { + $this->openShowImage(); + } + Article::view(); # If the article we've just shown is in the "Image" namespace, *************** *** 14,24 **** --- 18,61 ---- # it describes. if ( Namespace::getImage() == $this->mTitle->getNamespace() ) { + $this->closeShowImage(); $this->imageHistory(); $this->imageLinks(); } } + + function openShowImage() + { + global $wgOut, $wgUser; + $name = $this->mTitle->getText(); + $path = wfImagePath( $name ); + + list($width, $height, $type, $attr) = getimagesize( $path ); + + $sk = $wgUser->getSkin(); + $s = "
"; + if ( ($width > 250) && ($width < 800) ) { + $s .= "
"; + } else { + $s .= "
"; + } + if ( $type != "" ) { + # image + $s .= "
".$sk->makeImageLink($name,"")."
"; + } else { + $s .= "
".$sk->makeMediaLink($name,"")."
"; + } + $wgOut->AddHTML( $s ); + } + function closeShowImage() + { + global $wgOut, $wgUser; + $sk = $wgUser->getSkin(); + $s = "
"; + $wgOut->AddHTML( $s ); + } + # If the page we've just displayed is in the "Image" namespace, # we follow it with an upload history of the image and its usage. diff -c -r -x CVS -x '*~' phase3/includes/MagicWord.php ../phase3/includes/MagicWord.php *** phase3/includes/MagicWord.php Sun Dec 14 15:25:44 2003 --- ../phase3/includes/MagicWord.php Tue Jan 6 02:57:03 2004 *************** *** 25,30 **** --- 25,31 ---- $this->mRegex = ""; $this->mRegexStart = ""; $this->mVariableRegex = ""; + $this->mVariableStartToEndRegex = ""; } # Factory: creates an object representing an ID *************** *** 58,63 **** --- 59,65 ---- $this->mRegex = "/{$this->mBaseRegex}/{$case}"; $this->mRegexStart = "/^{$this->mBaseRegex}/{$case}"; $this->mVariableRegex = str_replace( "\\$1", "([A-Za-z0-9_\-]*)", $this->mRegex ); + $this->mVariableStartToEndRegex = str_replace( "\\$1", "([A-Za-z0-9_\-]*)", "/^{$this->mBaseRegex}$/{$case}" ); } # Gets a regex representing matching the word *************** *** 78,84 **** } return $this->mRegexStart; } ! # regex without the slashes and what not function getBaseRegex() { --- 80,86 ---- } return $this->mRegexStart; } ! # regex without the slashes and what not function getBaseRegex() { *************** *** 99,104 **** --- 101,122 ---- return preg_match( $this->getRegexStart(), $text ); } + # Returns NULL if there's no match, the value of $1 otherwise + # The return code is the matched string, if there's no variable + # part in the regex and the matched variable part ($1) if there + # is one. + function matchVariableStartToEnd( $text ) { + $matchcount = preg_match( $this->getVariableStartToEndRegex(), $text, $matches ); + if ( $matchcount == 0 ) { + return NULL; + } elseif ( count($matches) == 1 ) { + return $matches[0]; + } else { + return $matches[1]; + } + } + + # Returns true if the text matches the word, and alters the # input string, removing all instances of the word function matchAndRemove( &$text ) *************** *** 132,137 **** --- 150,164 ---- return $this->mVariableRegex; } + # Matches the entire string, where $1 is a wildcard + function getVariableStartToEndRegex() + { + if ( $this->mVariableStartToEndRegex == "" ) { + $this->initRegex(); + } + return $this->mVariableStartToEndRegex; + } + # Accesses the synonym list directly function getSynonym( $i ) { return $this->mSynonyms[$i]; diff -c -r -x CVS -x '*~' phase3/includes/Skin.php ../phase3/includes/Skin.php *** phase3/includes/Skin.php Thu Dec 25 04:25:17 2003 --- ../phase3/includes/Skin.php Tue Jan 6 04:08:28 2004 *************** *** 1410,1418 **** } function makeImageLinkObj( $nt, $alt = "" ) { ! $link = $nt->getPrefixedURL(); ! $name = $nt->getDBKey(); ! $url = wfImageUrl( $name ); if ( empty( $alt ) ) { $alt = preg_replace( '/\.(.+?)^/', '', $name ); } --- 1410,1457 ---- } function makeImageLinkObj( $nt, $alt = "" ) { ! $link = $nt->getPrefixedURL(); ! $name = $nt->getDBKey(); ! $url = wfImageUrl( $name ); ! $align = ""; ! ! # Check if the alt text is of the form "options|alt text" ! # Options are: ! # * thumbnail make a right aligned thumbnail with enlarge-icon and caption ! # * thumbnail-right alias of the above ! # * thumbnail-left same, but left aligned ! # * left no resizing, just left align. label is used for alt= only ! # * right same, but right aligned ! # * ___px scale to ___ pixels width, no aligning. e.g. use in taxobox ! ! $part = explode( "|", $alt); ! ! if ( count($part) > 1 ) { ! $mwThumbRight =& MagicWord::get( MAG_IMG_THUMBRIGHT ); ! $mwThumbLeft =& MagicWord::get( MAG_IMG_THUMBLEFT ); ! $mwLeft =& MagicWord::get( MAG_IMG_LEFT ); ! $mwRight =& MagicWord::get( MAG_IMG_RIGHT ); ! $mwWidth =& MagicWord::get( MAG_IMG_WIDTH ); ! $alt = $part[count($part)-1]; ! ! foreach( $part as $key => $val ) { ! if ( ! is_null( $mwThumbRight->matchVariableStartToEnd($val) ) ) { ! return $this->makeThumbLinkObj( $nt, $alt ); ! } elseif ( ! is_null( $mwThumbLeft->matchVariableStartToEnd($val) ) ) { ! return $this->makeThumbLinkObj( $nt, $alt, "left" ); ! } elseif ( ! is_null( $mwRight->matchVariableStartToEnd($val) ) ) { ! # remember to set an alignment, don't render immediately ! $align = "right"; ! } elseif ( ! is_null( $mwLeft->matchVariableStartToEnd($val) ) ) { ! # remember to set an alignment, don't render immediately ! $align = "left"; ! } elseif ( ! is_null( $match = $mwWidth->matchVariableStartToEnd($val) ) ) { ! # $matches[1] is the image width in pixels ! $url = $this->createThumb( $name, $match ); ! } ! } ! } ! if ( empty( $alt ) ) { $alt = preg_replace( '/\.(.+?)^/', '', $name ); } *************** *** 1421,1426 **** --- 1460,1532 ---- $u = wfLocalUrlE( $link ); $s = "" . "\"{$alt}\""; + if ( "" != $align ) { + $s = "
{$s}
"; + } + return $s; + } + + function createThumb( $name, $width, $icon = "" ) { + global $wgUploadDirectory; + global $wgImageMagickConvertCommand; + global $wgImageMagickCompositeCommand; + $imgPath = wfImagePath( $name ); + $thumbName = $width."px-".$icon.$name; + $thumbPath = wfImageArchiveDir( $thumbName, "thumb" )."/".$thumbName; + $thumbUrl = wfImageArchiveUrl( $thumbName, "thumb" ); + + if ( ! file_exists( $thumbPath ) ) { + # @@@ REFACTOR: Use variables for convert path + $cmd = $wgImageMagickConvertCommand . + " -quality 95 -geometry {$width}x ". + escapeshellarg($imgPath) . " " . + escapeshellarg($thumbPath); + $conv = shell_exec( $cmd ); + if ( $icon != "" ) { + # if an icon name is provided, stamp the icon into the lower right + # corner of the thumbnail + $cmd = $wgImageMagickCompositeCommand . + " -quality 95 -geometry +2+2 -gravity SouthEast {$wgUploadDirectory}/{$icon} ". + escapeshellarg($thumbPath) . " " . + escapeshellarg($thumbPath) ; + $conv = shell_exec( $cmd ); + } + } + return $thumbUrl; + } + + function makeThumbLinkObj( $nt, $label = "", $align = "right" ) { + global $wgUploadPath; + $name = $nt->getDBKey(); + $image = Title::makeTitle( Namespace::getImage(), $name ); + $link = $image->getPrefixedURL(); + $url = wfImageUrl( $name ); + $path = wfImagePath( $name ); + + list($width, $height, $type, $attr) = getimagesize( $path ); + $boxwidth = 180; + $cwidth = $boxwidth; + $cheight = intval( $height/($width/$cwidth) ); + if ($cheight > $boxwidth*1.5) { + $cheight = $boxwidth*1.3; + $cwidth = intval( $width/($height/$cheight) ); + } + if ( $cwidth > $width ) { + $cwidth = $width; + $cheight = $height; + } + + $thumbUrl = $this->createThumb( $name, $cwidth, "enlarge.png" ); + + $u = wfLocalUrlE( $link ); + + $more = wfMsg( "thumbnail-more" ); + + $s = "
" . + "" . + "\"{$label}\"" . + "

{$label}" . + "[{$more}]

"; return $s; } diff -c -r -x CVS -x '*~' phase3/stylesheets/cologneblue.css ../phase3/stylesheets/cologneblue.css *** phase3/stylesheets/cologneblue.css Sun Nov 16 01:22:35 2003 --- ../phase3/stylesheets/cologneblue.css Tue Jan 6 03:35:17 2004 *************** *** 94,96 **** --- 94,147 ---- small { font-size: 75%; } #toc { border:1px solid #8888aa; background-color:#f7f8ff;padding:5px;font-size:95%; } + + /* Images */ + div.floatright { float: right; margin: 0 0 1em 1em; } + div.floatright p { font-style: italic; } + div.floatleft { float: left; margin: 0.3em 0.5em 0.5em 0; } + div.floatleft p { font-style: italic; } + + /* Image Page */ + div.medium-imagepage { + float: center; + padding: 2px; + border:1px solid #8888aa; + background: #DDDDDD; + text-align: left; + } + div.imagepage { + border-width: 2px; + border-style: solid; + border-color: #CCCCCC; + padding: 1em; + text-align: left; + } + + /* thumbnails */ + div.thumbnail-right, div.thumbnail-left { + padding: 2px; + border:1px solid #8888aa; + background:#CCCCCC; + margin: 0.3em 0 0.5em; + font-size: 85%; + } + + div.thumbnail-right p, div.thumbnail-left p { + margin-top:3px; margin-bottom:3px; + } + + div.thumbnail-right { + float: right; + margin-left:0.5em; + } + + div.thumbnail-left { + float: left; + margin-right:0.5em; + } + + span.thumbnail-more { + float: right; + font-size: 85%; + } + diff -c -r -x CVS -x '*~' phase3/stylesheets/nostalgia.css ../phase3/stylesheets/nostalgia.css *** phase3/stylesheets/nostalgia.css Sun Nov 16 01:22:35 2003 --- ../phase3/stylesheets/nostalgia.css Tue Jan 6 03:35:17 2004 *************** *** 12,14 **** --- 12,61 ---- p.subtitle { padding-top: 0; margin-top: 0; } #toc { border:1px solid #8888aa; background-color:#f7f8ff;padding:5px;font-size:95%; } + + /* Images */ + div.floatright { float: right; margin: 0 0 1em 1em; } + div.floatright p { font-style: italic; } + div.floatleft { float: left; margin: 0.3em 0.5em 0.5em 0; } + div.floatleft p { font-style: italic; } + + /* Image Page */ + div.medium-imagepage { + float: center; + padding: 2px; + text-align: left; + } + div.imagepage { + padding: 1em; + text-align: left; + } + + + /* thumbnails */ + div.thumbnail-right, div.thumbnail-left { + padding: 2px; + border:1px solid #8888aa; + background:#CCCCCC; + margin: 0.3em 0 0.5em; + font-size: 85%; + } + + div.thumbnail-right p, div.thumbnail-left p { + margin-top:3px; margin-bottom:3px; + } + + div.thumbnail-right { + float: right; + margin-left:0.5em; + } + + div.thumbnail-left { + float: left; + margin-right:0.5em; + } + + span.thumbnail-more { + float: right; + font-size: 85%; + } + diff -c -r -x CVS -x '*~' phase3/stylesheets/wikistandard.css ../phase3/stylesheets/wikistandard.css *** phase3/stylesheets/wikistandard.css Sun Nov 9 12:45:12 2003 --- ../phase3/stylesheets/wikistandard.css Tue Jan 6 03:35:17 2004 *************** *** 37,44 **** td.bottom { border-top: 1px solid gray; } td.top { border-bottom: 1px solid gray; } /* images */ ! div.floatright { float:right;margin:0 0 1em 1em; } div.floatright p { font-style: italic; } /* table standards */ table.rimage { --- 37,93 ---- td.bottom { border-top: 1px solid gray; } td.top { border-bottom: 1px solid gray; } /* images */ ! div.floatright { float: right; margin: 0 0 1em 1em; } div.floatright p { font-style: italic; } + div.floatleft { float: left; margin: 0.3em 0.5em 0.5em 0; } + div.floatleft p { font-style: italic; } + + /* Image Page */ + div.medium-imagepage { + float: center; + padding: 2px; + border:1px solid #8888aa; + background: #DDDDDD; + text-align: left; + } + div.imagepage { + border-width: 2px; + border-style: solid; + border-color: #CCCCCC; + padding: 1em; + text-align: left; + } + + /* thumbnails */ + div.thumbnail-right, div.thumbnail-left { + padding: 2px; + border:1px solid #8888aa; + background:#CCCCCC; + margin: 0.3em 0 0.5em; + font-size: 85%; + text-align: center; + } + + div.thumbnail-right p, div.thumbnail-left p { + margin-top:3px; margin-bottom:3px; + text-align: left; + } + + div.thumbnail-right { + float: right; + margin-left:0.5em; + } + + div.thumbnail-left { + float: left; + margin-right:0.5em; + } + + span.thumbnail-more { + float: right; + font-size: 85%; + } + /* table standards */ table.rimage {