| CODENOTIFIER | HelpYou are not signed inSign in |
Project: Movable Type
Revision: 3082
Author: bchoate
Date: 02 Oct 2008 21:07:01
Changes:Merging fireball branch changes to-date to trunk: svn merge -r2974:3081 http://code.sixapart.com/svn/movabletype/branches/fireball .
Files:| ... | ...@@ -9,7 +9,7 @@ | |
| 9 | 9 | define('VERSION_ID', '4.21'); |
| 10 | 10 | define('PRODUCT_VERSION', '4.21'); |
| 11 | 11 | |
| 12 | $PRODUCT_NAME = '__PRODUCT_NAME__'; | |
| 12 | $PRODUCT_NAME = 'Movable Type Pro'; | |
| 13 | 13 | if($PRODUCT_NAME == '__PRODUCT' . '_NAME__') |
| 14 | 14 | $PRODUCT_NAME = 'Movable Type'; |
| 15 | 15 |
| ... | ...@@ -1415,8 +1415,11 @@ | |
| 1415 | 1415 | require MT::Template; |
| 1416 | 1416 | require MT::Template::Context; |
| 1417 | 1417 | require MT::Entry; |
| 1418 | ||
| 1418 | 1419 | my $blog; |
| 1419 | unless ( $blog = $param{Blog} ) { | |
| 1420 | $blog = $param{Blog} | |
| 1421 | if defined $param{Blog}; | |
| 1422 | if (!$blog && defined $param{BlogID}) { | |
| 1420 | 1423 | my $blog_id = $param{BlogID}; |
| 1421 | 1424 | $blog = MT::Blog->load($blog_id) |
| 1422 | 1425 | or return $mt->error( |
| ... | ...@@ -1427,9 +1430,15 @@ | |
| 1427 | 1430 | ); |
| 1428 | 1431 | } |
| 1429 | 1432 | my $tmpl = $param{Template}; |
| 1430 | unless ($blog) { | |
| 1433 | if ($tmpl && (!$blog || $blog->id != $tmpl->blog_id)) { | |
| 1431 | 1434 | $blog = MT::Blog->load( $tmpl->blog_id ); |
| 1432 | 1435 | } |
| 1436 | ||
| 1437 | return $mt->error( | |
| 1438 | MT->translate( | |
| 1439 | "Blog, BlogID or Template param must be specified.") | |
| 1440 | ) unless $blog; | |
| 1441 | ||
| 1433 | 1442 | return 1 if $blog->is_dynamic; |
| 1434 | 1443 | my $iter; |
| 1435 | 1444 | if ($tmpl) { |
| ... | ...@@ -37,7 +37,7 @@ | |
| 37 | 37 | $closure = 2; |
| 38 | 38 | $inside = preg_replace('!/?>$!', '', $inside); |
| 39 | 39 | $attrs = ''; |
| 40 | if (preg_match_all('/\s*(\w+)\s*=(?:([\'"])(.*?)\2|([^\s]+))\s*/', $inside, $matches, PREG_SET_ORDER)) { | |
| 40 | if (preg_match_all('/\s*(\w+)\s*=(?:([\'"])(.*?)\2|([^\s]+))\s*/s', $inside, $matches, PREG_SET_ORDER)) { | |
| 41 | 41 | foreach ($matches as $match) { |
| 42 | 42 | $attr = strtolower($match[1]); |
| 43 | 43 | if (isset($match[4])) { |
| ... | ...@@ -54,7 +54,7 @@ | |
| 54 | 54 | if (preg_match('/^(src|href|dynsrc)$/', $attr)) { |
| 55 | 55 | $dec_val = preg_replace('/�*58(?:=;|[^0-9])/', ':', $dec_val); |
| 56 | 56 | $dec_val = preg_replace('/�*3[Aa](?:=;|[^a-fA-F0-9])/', ':', $dec_val); |
| 57 | if (preg_match('/^(.+?):/', $dec_val, $proto_match)) { | |
| 57 | if (preg_match('/^([\s\S]+?):/', $dec_val, $proto_match)) { | |
| 58 | 58 | $proto = $proto_match[1]; |
| 59 | 59 | if (preg_match('/[\r\n\t]/', $proto)) { |
| 60 | 60 | $safe = 0; |
| ... | ...@@ -320,7 +320,7 @@ | |
| 320 | 320 | |
| 321 | 321 | # If no blog IDs specified, use the current blog |
| 322 | 322 | if ( ! $blog_ids ) { |
| 323 | $terms->{$col} = $blog_id if $col eq 'blog_id'; | |
| 323 | $terms->{$col} = $blog_id if $blog_id && $col eq 'blog_id'; | |
| 324 | 324 | } |
| 325 | 325 | # If exclude blogs, set the terms and the NOT arg for load |
| 326 | 326 | # 'All' is not a valid value for exclude_blogs |
| ... | ...@@ -1300,7 +1300,7 @@ | |
| 1300 | 1300 | $thumb_h = $max_dim; |
| 1301 | 1301 | $dest; |
| 1302 | 1302 | $thumb_name = $static_file_path.DIRECTORY_SEPARATOR.$image_path.DIRECTORY_SEPARATOR.$format; |
| 1303 | if (!$thumb->get_thumbnail($dest, $thumb_w, $thumb_h, $scale, $thumb_name, 'png')) { | |
| 1303 | if (!$thumb->get_thumbnail($dest, $thumb_w, $thumb_h, $asset['asset_id'], $scale, $thumb_name, 'png')) { | |
| 1304 | 1304 | return ''; |
| 1305 | 1305 | } |
| 1306 | 1306 | $basename = basename($dest); |
| ... | ...@@ -1313,18 +1313,18 @@ | |
| 1313 | 1313 | } |
| 1314 | 1314 | |
| 1315 | 1315 | # for compatibility... |
| 1316 | function make_thumbnail_file($src, $dest, $width, $height, $scale = 0, $dest_type = 'auto') { | |
| 1316 | function make_thumbnail_file($src, $dest, $width, $height, $scale = 0, $dest_type = 'auto', $id = 0) { | |
| 1317 | 1317 | require_once('thumbnail_lib.php'); |
| 1318 | 1318 | $thumb = new Thumbnail($src); |
| 1319 | 1319 | |
| 1320 | 1320 | $thumb_w = $width; |
| 1321 | 1321 | $thumb_h = $height; |
| 1322 | $thumb->get_thumbnail($dest, $thumb_w, $thumb_h, $scale, null, $dest_type); | |
| 1322 | $thumb->get_thumbnail($dest, $thumb_w, $thumb_h, $id, $scale, null, $dest_type); | |
| 1323 | 1323 | |
| 1324 | 1324 | return array($thumb_w, $thumb_h); |
| 1325 | 1325 | } |
| 1326 | 1326 | |
| 1327 | function get_thumbnail_file($asset, $blog, $width = 0, $height = 0, $scale = 0, $format = '%f-thumb-%wx%h%x') { | |
| 1327 | function get_thumbnail_file($asset, $blog, $width = 0, $height = 0, $scale = 0, $format = '%f-thumb-%wx%h-%i%x') { | |
| 1328 | 1328 | # Get parameter |
| 1329 | 1329 | $site_path = $blog['blog_site_path']; |
| 1330 | 1330 | $site_path = preg_replace('/\/$/', '', $site_path); |
| ... | ...@@ -1337,26 +1337,34 @@ | |
| 1337 | 1337 | |
| 1338 | 1338 | $ts = preg_replace('![^0-9]!', '', $asset['asset_created_on']); |
| 1339 | 1339 | $date_stamp = format_ts('%Y/%m', $ts, $blog); |
| 1340 | $cache_dir = $site_path . DIRECTORY_SEPARATOR . $cache_path . DIRECTORY_SEPARATOR . $date_stamp . DIRECTORY_SEPARATOR; | |
| 1340 | $base_path = $site_path; | |
| 1341 | if (preg_match('/^%a/', $asset['asset_file_path']) && !empty($blog['blog_archive_path'])) { | |
| 1342 | $base_path = $blog['blog_archive_path']; | |
| 1343 | $base_path = preg_replace('/\/$/', '', $base_path); | |
| 1344 | } | |
| 1345 | ||
| 1346 | $cache_dir = $base_path . DIRECTORY_SEPARATOR . $cache_path . DIRECTORY_SEPARATOR . $date_stamp . DIRECTORY_SEPARATOR; | |
| 1341 | 1347 | $thumb_name = $cache_dir . $format; |
| 1342 | ||
| 1348 | ||
| 1343 | 1349 | # generate thumbnail |
| 1344 | 1350 | require_once('thumbnail_lib.php'); |
| 1345 | 1351 | $thumb = new Thumbnail($filename); |
| 1346 | 1352 | $thumb_w = $width; |
| 1347 | 1353 | $thumb_h = $height; |
| 1348 | 1354 | $dest; |
| 1349 | if (!$thumb->get_thumbnail($dest, $thumb_w, $thumb_h, $scale, $thumb_name)) { | |
| 1355 | if (!$thumb->get_thumbnail($dest, $thumb_w, $thumb_h, $asset['asset_id'], $scale, $thumb_name)) { | |
| 1350 | 1356 | return ''; |
| 1351 | 1357 | } |
| 1352 | 1358 | |
| 1353 | 1359 | # make url |
| 1354 | 1360 | $basename = basename($dest); |
| 1355 | $site_url = $blog['blog_site_url']; | |
| 1356 | if (!preg_match('!/$!', $site_url)) | |
| 1357 | $site_url .= '/'; | |
| 1361 | $base_url = $blog['blog_site_url']; | |
| 1362 | if (preg_match('/^%a/', $asset['asset_file_path']) && !empty($blog['blog_archive_url'])) | |
| 1363 | $base_url = $blog['blog_archive_url']; | |
| 1364 | if (!preg_match('!/$!', $base_url)) | |
| 1365 | $base_url .= '/'; | |
| 1358 | 1366 | |
| 1359 | $thumb_url = $site_url . $cache_path . '/' . $date_stamp . '/' . $basename; | |
| 1367 | $thumb_url = $base_url . $cache_path . '/' . $date_stamp . '/' . $basename; | |
| 1360 | 1368 | |
| 1361 | 1369 | return array($thumb_url, $thumb_w, $thumb_h, $thumb_name); |
| 1362 | 1370 | } |
| ... | ...@@ -23,6 +23,8 @@ | |
| 23 | 23 | type="submit" |
| 24 | 24 | <mt:if name="dialog"> |
| 25 | 25 | onclick="if ( window.opener ) { window.close(); } else { window.parent.closeDialog('<mt:var name="link" escape="js">'); }; return false;" |
| 26 | <mt:elseif name="fs"> | |
| 27 | onclick="window.location='<mt:var name="link" escape="js">'; return false;" | |
| 26 | 28 | <mt:else> |
| 27 | 29 | onclick="if ( window.opener ) { window.opener.location.href='<mt:var name="link" escape="js">'; window.close(); } else { window.open('<mt:var name="link" escape="js">') }; return false;" |
| 28 | 30 | </mt:if> |
| ... | ...@@ -230,7 +230,7 @@ | |
| 230 | 230 | my $file = $asset->file_name or return; |
| 231 | 231 | |
| 232 | 232 | require MT::Util; |
| 233 | my $format = $param{Format} || MT->translate('%f-thumb-%wx%h%x'); | |
| 233 | my $format = $param{Format} || MT->translate('%f-thumb-%wx%h-%i%x'); | |
| 234 | 234 | my $width = $param{Width} || 'auto'; |
| 235 | 235 | my $height = $param{Height} || 'auto'; |
| 236 | 236 | $file =~ s/\.\w+$//; |
| ... | ...@@ -549,6 +549,7 @@ | |
| 549 | 549 | return $app->error( |
| 550 | 550 | $app->translate( "Invalid basename '[_1]'", $rel_path ) ); |
| 551 | 551 | } |
| 552 | $rel_path .= '-' . $asset->id; | |
| 552 | 553 | my $ext = $blog->file_extension || ''; |
| 553 | 554 | $ext = '.' . $ext if $ext ne ''; |
| 554 | 555 | require MT::Template::Context; |
| ... | ...@@ -566,15 +567,7 @@ | |
| 566 | 567 | my $abs_file_path = |
| 567 | 568 | File::Spec->catfile( $root_path, $rel_path . $ext ); |
| 568 | 569 | |
| 569 | ## If the popup filename already exists, we don't want to overwrite | |
| 570 | ## it, because it could contain valuable data; so we'll just make | |
| 571 | ## sure to generate the name uniquely. | |
| 572 | 570 | my ( $i, $rel_path_ext ) = ( 0, $rel_path . $ext ); |
| 573 | while ( $fmgr->exists($abs_file_path) ) { | |
| 574 | $rel_path_ext = $rel_path . ++$i . $ext; | |
| 575 | $abs_file_path = | |
| 576 | File::Spec->catfile( $root_path, $rel_path_ext ); | |
| 577 | } | |
| 578 | 571 | $pseudo_path = File::Spec->catfile( $pseudo_path, $rel_path_ext ); |
| 579 | 572 | my ( $vol, $dirs, $basename ) = |
| 580 | 573 | File::Spec->splitpath($rel_path_ext); |
| ... | ...@@ -599,7 +592,9 @@ | |
| 599 | 592 | $asset_html = new $html_pkg; |
| 600 | 593 | $original = $asset_html->clone; |
| 601 | 594 | $asset_html->blog_id($blog_id); |
| 602 | $asset_html->url($pseudo_path); | |
| 595 | my $pseudo_url = $pseudo_path; | |
| 596 | $pseudo_url =~ s!\\!/!g; | |
| 597 | $asset_html->url($pseudo_url); | |
| 603 | 598 | $asset_html->label($app->translate("Popup Page for [_1]", $asset->label || $asset->file_name)); |
| 604 | 599 | $asset_html->file_path($pseudo_path); |
| 605 | 600 | $asset_html->file_name($basename); |
| ... | ...@@ -609,7 +604,7 @@ | |
| 609 | 604 | $asset_html->save; |
| 610 | 605 | } else { |
| 611 | 606 | $original = $asset_html->clone; |
| 612 | } | |
| 607 | } | |
| 613 | 608 | |
| 614 | 609 | # Select back the real URL for callbacks |
| 615 | 610 | $url = $asset_html->url; |
| ... | ...@@ -633,7 +633,7 @@ | |
| 633 | 633 | 'Error scaling image: [_1]' => '画像のサイズを変更できませんでした: [_1]', |
| 634 | 634 | 'Error converting image: [_1]' => '画像を変換できませんでした: [_1]', |
| 635 | 635 | 'Error creating thumbnail file: [_1]' => 'サムネールを作成できませんでした: [_1]', |
| 636 | '%f-thumb-%wx%h%x' => '%f-thumb-%wx%h%x', | |
| 636 | '%f-thumb-%wx%h-%i%x' => '%f-thumb-%wx%h-%i%x', | |
| 637 | 637 | 'Can\'t load image #[_1]' => 'ID:[_1]の画像をロードできませんでした。', |
| 638 | 638 | 'View image' => '表示', |
| 639 | 639 | 'Permission denied setting image defaults for blog #[_1]' => 'ブログ(ID:[_1])に画像に関する既定値を保存する権限がありません。', |
| ... | ...@@ -741,6 +741,7 @@ | |
| 741 | 741 | 'Error making path \'[_1]\': [_2]' => 'パス(\'[_1]\')を作成できません: [_2]', |
| 742 | 742 | 'Writing to \'[_1]\' failed: [_2]' => '\'[_1]\'に書き込めませんでした: [_2]', |
| 743 | 743 | 'Renaming tempfile \'[_1]\' failed: [_2]' => 'テンポラリファイル\'[_1]\'の名前を変更できませんでした: [_2]', |
| 744 | 'Blog, BlogID or Template param must be specified.' => 'Blog, BlogID, またはTemplateのいずれかを指定してください。', | |
| 744 | 745 | 'Template \'[_1]\' does not have an Output File.' => 'テンプレート\'[_1]\'には出力ファイルの設定がありません。', |
| 745 | 746 | 'An error occurred while publishing scheduled entries: [_1]' => '日時指定されたブログ記事の再構築中にエラーが発生しました: [_1]', |
| 746 | 747 | |
| ... | ...@@ -985,7 +986,6 @@ | |
| 985 | 986 | 'Notification List' => '通知リスト', |
| 986 | 987 | 'IP Banning' => 'IP禁止リスト', |
| 987 | 988 | 'Removing tag failed: [_1]' => 'タグを削除できませんでした: [_1]', |
| 988 | 'You can\'t delete that category because it has sub-categories. Move or delete the sub-categories first if you want to delete this one.' => 'サブカテゴリのあるカテゴリは削除できません。サブカテゴリを先に削除するか、移動してください。', | |
| 989 | 989 | 'Loading MT::LDAP failed: [_1].' => 'MT::LDAPの読み込みに失敗しました: [_1]', |
| 990 | 990 | 'System templates can not be deleted.' => 'システムテンプレートは削除できません。', |
| 991 | 991 | |
| ... | ...@@ -1635,7 +1635,8 @@ | |
| 1635 | 1635 | 'Mapping template ID [_1] to [_2] ([_3]).' => 'テンプレート(ID:[_1])を[_2]([_3])にマッピングしています...', |
| 1636 | 1636 | 'Mapping template ID [_1] to [_2].' => 'テンプレート(ID:[_1])を[_2]にマッピングしています...', |
| 1637 | 1637 | 'Error loading class: [_1].' => 'クラスをロードできませんでした: [_1]', |
| 1638 | 'Error saving [_1] record # [_3]: [_2]... [_4].' => '[_1](ID: [_3])の保存中にエラーが発生しました: [_2]... [_4]', | |
| 1638 | 'Assigning entry comment and TrackBack counts...' => 'コメントとトラックバックの件数を設定しています....', | |
| 1639 | 'Error saving [_1] record # [_3]: [_2]...' => '[_1]のレコード(ID:[_3])を保存できませんでした: [_2]', | |
| 1639 | 1640 | 'Creating entry category placements...' => 'ブログ記事とカテゴリの関連付けを作成しています...', |
| 1640 | 1641 | 'Updating category placements...' => 'カテゴリの関連付けを更新しています...', |
| 1641 | 1642 | 'Assigning comment/moderation settings...' => 'コメントとコメントの保留設定を適用しています...', |
| ... | ...@@ -1677,7 +1678,6 @@ | |
| 1677 | 1678 | 'Assigning blog template set...' => 'ブログにテンプレートセットを設定しています...', |
| 1678 | 1679 | 'Assigning blog page layout...' => 'ブログにページレイアウトを設定しています...', |
| 1679 | 1680 | 'Assigning author basename...' => 'ユーザーにベースネームを設定しています...', |
| 1680 | 'Assigning entry comment and TrackBack counts...' => 'コメントとトラックバックの件数を設定しています....', | |
| 1681 | 1681 | 'Assigning embedded flag to asset placements...' => 'アイテムの関連付けの有無を設定しています...', |
| 1682 | 1682 | 'Updating template build types...' => 'テンプレートのビルドオプションを設定しています...', |
| 1683 | 1683 | 'Replacing file formats to use CategoryLabel tag...' => 'ファイルフォーマットをMTCategoryLabelに変換しています...', |
| ... | ...@@ -1836,7 +1836,6 @@ | |
| 1836 | 1836 | 'Remove Tags...' => 'タグの削除', |
| 1837 | 1837 | 'Tags to remove from selected entries' => '削除するタグを入力', |
| 1838 | 1838 | 'Batch Edit Entries' => 'ブログ記事の一括編集', |
| 1839 | 'Publish Pages' => 'ウェブページを公開', | |
| 1840 | 1839 | 'Unpublish Pages' => 'ウェブページの公開を取り消し', |
| 1841 | 1840 | 'Tags to add to selected pages' => '追加するタグを入力', |
| 1842 | 1841 | 'Tags to remove from selected pages' => '削除するタグを入力', |
| ... | ...@@ -1866,7 +1865,6 @@ | |
| 1866 | 1865 | 'Spam Comments' => 'スパムコメント', |
| 1867 | 1866 | 'Published comments' => '公開されているコメント', |
| 1868 | 1867 | 'Comments in the last 7 days' => '最近7日間以内のコメント', |
| 1869 | 'E-mail Templates' => 'メールテンプレート', | |
| 1870 | 1868 | 'Tags with entries' => 'ブログ記事のタグ', |
| 1871 | 1869 | 'Tags with pages' => 'ウェブページのタグ', |
| 1872 | 1870 | 'Tags with assets' => 'アイテムのタグ', |
| ... | ...@@ -3256,6 +3254,9 @@ | |
| 3256 | 3254 | 'You must set your Local Site Path.' => 'サイトパスを指定する必要があります。', |
| 3257 | 3255 | 'You must set a valid Site URL.' => '有効なサイトURLを指定してください。', |
| 3258 | 3256 | 'You must set a valid Local Site Path.' => '有効なサイトパスを指定してください。', |
| 3257 | 'You must set Local Archive Path.' => 'アーカイブパスを指定する必要があります。', | |
| 3258 | 'You must set a valid Archive URL.' => '有効なアーカイブURLを指定してください。', | |
| 3259 | 'You must set a valid Local Archive Path.' => '有効なアーカイブパスを指定してください。', | |
| 3259 | 3260 | 'Publishing Paths' => '公開パス', |
| 3260 | 3261 | 'The URL of your website. Do not include a filename (i.e. exclude index.html). Example: http://www.example.com/blog/' => '公開するURLを入力してください。ファイル名(index.html など)は含めないでください。例: http://www.example.com/blog/', |
| 3261 | 3262 | 'Unlock this blog’s site URL for editing' => 'ロックを解除すればブログのサイトURLを編集できます。', |
| ... | ...@@ -531,7 +531,7 @@ | |
| 531 | 531 | my $app = shift; |
| 532 | 532 | my $type = $app->param('_type') || 'entry'; |
| 533 | 533 | my @ids = $app->param('id'); |
| 534 | $app->{goback} = "window.location='" . $app->return_uri . "'"; | |
| 534 | $app->{goback} = $app->return_uri; | |
| 535 | 535 | $app->{value} ||= $app->translate('Go Back'); |
| 536 | 536 | if ( $type eq 'entry' ) { |
| 537 | 537 | my %ids = map { $_ => 1 } @ids; |
| ... | ...@@ -610,9 +610,7 @@ | |
| 610 | 610 | my $entry = MT::Entry->load($obj_id); |
| 611 | 611 | $edit_type = $entry ? $entry->class : 'entry'; |
| 612 | 612 | } |
| 613 | $app->{goback} = | |
| 614 | "window.location='" | |
| 615 | . $app->object_edit_uri( $edit_type, $obj_id ) . "'"; | |
| 613 | $app->{goback} = $app->object_edit_uri( $edit_type, $obj_id ); | |
| 616 | 614 | $app->{value} ||= $app->translate('Go Back'); |
| 617 | 615 | } |
| 618 | 616 | } |
| ... | ...@@ -690,10 +688,22 @@ | |
| 690 | 688 | } |
| 691 | 689 | elsif ($type) { |
| 692 | 690 | my $special = 0; |
| 693 | my @options = $app->{rebuild_options} ||= {}; | |
| 691 | my @options; | |
| 692 | my $opts = $app->registry("rebuild_options") || {}; | |
| 693 | if ($opts) { | |
| 694 | foreach my $opt ( keys %$opts ) { | |
| 695 | $opts->{$opt}{key} ||= $opt; | |
| 696 | push @options, $opts->{$opt}; | |
| 697 | } | |
| 698 | } | |
| 694 | 699 | $app->run_callbacks( 'rebuild_options', $app, \@options ); |
| 695 | 700 | for my $optn (@options) { |
| 696 | 701 | if ( ( $optn->{key} || '' ) eq $type ) { |
| 702 | my $code = $optn->{code}; | |
| 703 | unless ( ref($code) eq 'CODE' ) { | |
| 704 | $code = MT->handler_to_coderef($code); | |
| 705 | $optn->{code} = $code; | |
| 706 | } | |
| 697 | 707 | $optn->{code}->(); |
| 698 | 708 | $special = 1; |
| 699 | 709 | } |
| ... | ...@@ -151,7 +151,7 @@ | |
| 151 | 151 | # Strip the dialect portion of the language code (ab_CD into ab). |
| 152 | 152 | ($self->{'short-lang=s'} = $self->{'lang=s'}) =~ s/([a-z]{2})_[A-Z]{2}$/$1/o; |
| 153 | 153 | |
| 154 | $self->{'pack=s'} ||= 'MT'; | |
| 154 | $self->{'pack=s'} ||= 'MTOS'; | |
| 155 | 155 | $ENV{BUILD_PACKAGE} = $self->{'pack=s'}; |
| 156 | 156 | $ENV{BUILD_LANGUAGE} = $self->{'lang=s'}; |
| 157 | 157 |
| ... | ...@@ -960,10 +960,6 @@ | |
| 960 | 960 | } |
| 961 | 961 | } |
| 962 | 962 | elsif ( $type eq 'category' ) { |
| 963 | my @kids = MT::Category->load( { parent => $id } ); | |
| 964 | return $app->errtrans( | |
| 965 | "You can't delete that category because it has sub-categories. Move or delete the sub-categories first if you want to delete this one." | |
| 966 | ) if @kids; | |
| 967 | 963 | if ( $app->config('DeleteFilesAtRebuild') ) { |
| 968 | 964 | require MT::Blog; |
| 969 | 965 | require MT::Entry; |
| ... | ...@@ -175,7 +175,11 @@ | |
| 175 | 175 | $blog_id ? (blog_id => $blog_id) : (), |
| 176 | 176 | object_datasource => $datasource |
| 177 | 177 | }, { unique => 1, %jargs }); |
| 178 | my @tags = MT::Tag->load($terms, $args); | |
| 178 | my @tags; | |
| 179 | my $iter = MT::Tag->load_iter($terms, $args); | |
| 180 | while ( my $tag = $iter->() ) { | |
| 181 | push @tags, $tag; | |
| 182 | } | |
| 179 | 183 | @tags; |
| 180 | 184 | } |
| 181 | 185 | |
| ... | ...@@ -334,11 +338,14 @@ | |
| 334 | 338 | @tags = grep { defined } @{ MT::Tag->lookup_multi($tag_ids) }; |
| 335 | 339 | } else { |
| 336 | 340 | require MT::ObjectTag; |
| 337 | @tags = MT::Tag->search(undef, { | |
| 341 | my $iter = MT::Tag->load_iter(undef, { | |
| 338 | 342 | sort => 'name', |
| 339 | 343 | join => [ 'MT::ObjectTag', 'tag_id', { object_id => $obj->id, |
| 340 | 344 | object_datasource => $obj->datasource }, { unique => 1 } ], |
| 341 | 345 | }); |
| 346 | while ( my $tag = $iter->() ) { | |
| 347 | push @tags, $tag; | |
| 348 | } | |
| 342 | 349 | $cache->set($memkey, [ map { $_->id } @tags ], TAG_CACHE_TIME); |
| 343 | 350 | } |
| 344 | 351 | $obj->{__tags} = [ map { $_->name } @tags ]; |
| ... | ...@@ -20,6 +20,7 @@ | |
| 20 | 20 | <li id="system-tab"><a href="<mt:var name="script_url">?__mode=list&_type=template#system" onclick="showTable('system-listing');"><__trans phrase="System Templates"></a></li> |
| 21 | 21 | </mt:if> |
| 22 | 22 | </ul> |
| 23 | <$mtapp:ListFilters$> | |
| 23 | 24 | </mtapp:widget> |
| 24 | 25 | <mtapp:widget |
| 25 | 26 | id="useful-links" |
| ... | ...@@ -349,37 +349,7 @@ | |
| 349 | 349 | 'core_set_count_columns' => { |
| 350 | 350 | version_limit => 4.0047, |
| 351 | 351 | priority => 3.2, |
| 352 | updater => { | |
| 353 | type => 'entry', | |
| 354 | label => 'Assigning entry comment and TrackBack counts...', | |
| 355 | condition => sub { | |
| 356 | require MT::Comment; | |
| 357 | my $comment_count = MT::Comment->count( | |
| 358 | { | |
| 359 | entry_id => $_[0]->id, | |
| 360 | visible => 1, | |
| 361 | } | |
| 362 | ); | |
| 363 | $_[0]->comment_count($comment_count); | |
| 364 | require MT::Trackback; | |
| 365 | require MT::TBPing; | |
| 366 | my $tb = MT::Trackback->load( { entry_id => $_[0]->id } ); | |
| 367 | my $ping_count; | |
| 368 | if ($tb) { | |
| 369 | my $ping_count = MT::TBPing->count( | |
| 370 | { | |
| 371 | tb_id => $tb->id, | |
| 372 | visible => 1, | |
| 373 | } | |
| 374 | ); | |
| 375 | $_[0]->ping_count($ping_count); | |
| 376 | } | |
| 377 | ( $comment_count || $ping_count ); | |
| 378 | }, | |
| 379 | # only count once and set it, so code do nothing. | |
| 380 | # it doesn't have the unnecessary save. | |
| 381 | code => sub { 1; }, | |
| 382 | }, | |
| 352 | code => \&core_update_entry_counts, | |
| 383 | 353 | }, |
| 384 | 354 | 'core_assign_object_embedded' => { |
| 385 | 355 | version_limit => 4.0052, |
| ... | ...@@ -492,36 +462,6 @@ | |
| 492 | 462 | }, |
| 493 | 463 | }, |
| 494 | 464 | }, |
| 495 | 'core_assign_all_permisssions_blog_admin' => { | |
| 496 | version_limit => 4.0063, | |
| 497 | priority => 3.4, | |
| 498 | updater => { | |
| 499 | type => 'permission', | |
| 500 | label => 'Assigning all permissions to blog administrator...', | |
| 501 | condition => sub { | |
| 502 | $_[0]->can_administer_blog && $_[0]->blog_id; | |
| 503 | }, | |
| 504 | code => sub { | |
| 505 | my ($perm) = shift; | |
| 506 | $perm->set_full_permissions; | |
| 507 | }, | |
| 508 | }, | |
| 509 | }, | |
| 510 | 'core_recover_sysadmin_permissions' => { | |
| 511 | version_limit => 4.0066, | |
| 512 | priority => 3.5, | |
| 513 | updater => { | |
| 514 | type => 'permission', | |
| 515 | label => 'Recover permissions of system administrators...', | |
| 516 | condition => sub { | |
| 517 | !$_[0]->blog_id && !$_[0]->has('administer') && $_[0]->can_administer_blog; | |
| 518 | }, | |
| 519 | code => sub { | |
| 520 | my ($perm) = shift; | |
| 521 | $perm->set_permissions('system'); | |
| 522 | }, | |
| 523 | }, | |
| 524 | }, | |
| 525 | 465 | }; |
| 526 | 466 | } |
| 527 | 467 | |
| ... | ...@@ -1061,6 +1001,8 @@ | |
| 1061 | 1001 | my $args = { |
| 1062 | 1002 | 'limit' => 101, |
| 1063 | 1003 | 'fetchonly' => [ 'id' ], # meta is added to the select list separately |
| 1004 | 'sort' => 'id', | |
| 1005 | 'direction' => 'ascend', | |
| 1064 | 1006 | $offset ? ( 'offset' => $offset ) : () |
| 1065 | 1007 | }; |
| 1066 | 1008 | my $stmt = $driver->prepare_statement( $class, $terms, $args ); |
| ... | ...@@ -1187,4 +1129,91 @@ | |
| 1187 | 1129 | return 0; |
| 1188 | 1130 | } |
| 1189 | 1131 | |
| 1132 | sub core_update_entry_counts { | |
| 1133 | my $self = shift; | |
| 1134 | my (%param) = @_; | |
| 1135 | ||
| 1136 | my $class = MT->model('entry'); | |
| 1137 | return $self->error($self->translate_escape("Error loading class: [_1].", $param{type})) | |
| 1138 | unless $class; | |
| 1139 | ||
| 1140 | my $msg = $self->translate_escape("Assigning entry comment and TrackBack counts..."); | |
| 1141 | my $offset = $param{offset} || 0; | |
| 1142 | my $count = $param{count}; | |
| 1143 | if (!$count) { | |
| 1144 | $count = $class->count({ class => '*' }); | |
| 1145 | } | |
| 1146 | return unless $count; | |
| 1147 | if ($offset) { | |
| 1148 | $self->progress(sprintf("$msg (%d%%)", ($offset/$count*100)), $param{step}); | |
| 1149 | } else { | |
| 1150 | $self->progress($msg, $param{step}); | |
| 1151 | } | |
| 1152 | ||
| 1153 | my $continue = 0; | |
| 1154 | my $driver = $class->driver; | |
| 1155 | ||
| 1156 | my $iter = $class->load_iter({ class => '*' }, { offset => $offset, limit => $MAX_ROWS+1 }); | |
| 1157 | my $start = time; | |
| 1158 | my ( %touched, %c, %tb ); | |
| 1159 | my $rows = 0; | |
| 1160 | while (my $e = $iter->()) { | |
| 1161 | $rows++; | |
| 1162 | $c{$e->id} = $e; | |
| 1163 | if (my $tb = $e->trackback) { | |
| 1164 | $tb{$tb->id} = $e; | |
| 1165 | } | |
| 1166 | $continue = 1, last if scalar $rows == $MAX_ROWS; | |
| 1167 | } | |
| 1168 | if ( $continue ) { | |
| 1169 | $iter->end; | |
| 1170 | $offset += $rows; | |
| 1171 | } | |
| 1172 | ||
| 1173 | # now gather counts -- comments | |
| 1174 | if (my $grp_iter = MT::Comment->count_group_by({ | |
| 1175 | visible => 1, | |
| 1176 | entry_id => [ keys %c ], | |
| 1177 | }, { | |
| 1178 | group => ['entry_id'], | |
| 1179 | })) { | |
| 1180 | while (my ($count, $id) = $grp_iter->()) { | |
| 1181 | my $e = $c{$id} or next; | |
| 1182 | if ((!defined $e->comment_count) || (($e->comment_count || 0) != $count)) { | |
| 1183 | $e->comment_count($count); | |
| 1184 | $touched{$e->id} = $e; | |
| 1185 | } | |
| 1186 | } | |
| 1187 | } | |
| 1188 | ||
| 1189 | # pings | |
| 1190 | if ( %tb ) { | |
| 1191 | if (my $grp_iter = MT::TBPing->count_group_by({ | |
| 1192 | visible => 1, | |
| 1193 | tb_id => [ keys %tb ], | |
| 1194 | }, { | |
| 1195 | group => ['tb_id'], | |
| 1196 | })) { | |
| 1197 | while (my ($count, $id) = $grp_iter->()) { | |
| 1198 | my $e = $tb{$id} or next; | |
| 1199 | if ((!defined $e->ping_count) || (($e->ping_count || 0) != $count)) { | |
| 1200 | $e->ping_count($count); | |
| 1201 | $touched{$e->id} = $e; | |
| 1202 | } | |
| 1203 | } | |
| 1204 | } | |
| 1205 | } | |
| 1206 | ||
| 1207 | foreach my $e (values %touched) { | |
| 1208 | $e->save; | |
| 1209 | } | |
| 1210 | ||
| 1211 | if ($continue) { | |
| 1212 | return { offset => $offset, count => $count }; | |
| 1213 | } else { | |
| 1214 | $self->progress("$msg (100%)", $param{step}); | |
| 1215 | } | |
| 1216 | 1; | |
| 1217 | } | |
| 1218 | ||
| 1190 | 1219 | 1; |
| ... | ...@@ -720,7 +720,12 @@ | |
| 720 | 720 | |
| 721 | 721 | sub _fltr_setvar { |
| 722 | 722 | my ($str, $arg, $ctx) = @_; |
| 723 | $ctx->var($arg, $str); | |
| 723 | if ( my $hash = $ctx->{__inside_set_hashvar} ) { | |
| 724 | $hash->{$arg} = $str; | |
| 725 | } | |
| 726 | else { | |
| 727 | $ctx->var($arg, $str); | |
| 728 | } | |
| 724 | 729 | return ''; |
| 725 | 730 | } |
| 726 | 731 | |
| ... | ...@@ -10143,7 +10148,7 @@ | |
| 10143 | 10148 | my $blog = $ctx->stash('blog'); |
| 10144 | 10149 | unless (ref $blog) { |
| 10145 | 10150 | my $blog_id = $blog || $args->{offset_blog_id}; |
| 10146 | if ($blog) { | |
| 10151 | if ($blog_id) { | |
| 10147 | 10152 | $blog = MT->model('blog')->load($blog_id); |
| 10148 | 10153 | return $ctx->error( MT->translate( 'Can\'t load blog #[_1].', $blog_id ) ) |
| 10149 | 10154 | unless $blog; |
| ... | ...@@ -10154,7 +10159,7 @@ | |
| 10154 | 10159 | if ($args->{utc}) { |
| 10155 | 10160 | my($y, $mo, $d, $h, $m, $s) = $ts =~ /(\d\d\d\d)[^\d]?(\d\d)[^\d]?(\d\d)[^\d]?(\d\d)[^\d]?(\d\d)[^\d]?(\d\d)/; |
| 10156 | 10161 | $mo--; |
| 10157 | my $server_offset = $blog->server_offset; | |
| 10162 | my $server_offset = ($blog && $blog->server_offset) || MT->config->TimeOffset; | |
| 10158 | 10163 | if ((localtime (timelocal ($s, $m, $h, $d, $mo, $y )))[8]) { |
| 10159 | 10164 | $server_offset += 1; |
| 10160 | 10165 | } |
| ... | ...@@ -10172,7 +10177,7 @@ | |
| 10172 | 10177 | if (my $format = lc ($args->{format_name} || '')) { |
| 10173 | 10178 | my $tz = 'Z'; |
| 10174 | 10179 | unless ($args->{utc}) { |
| 10175 | my $so = $blog->server_offset; | |
| 10180 | my $so = ($blog && $blog->server_offset) || MT->config->TimeOffset; | |
| 10176 | 10181 | my $partial_hour_offset = 60 * abs($so - int($so)); |
| 10177 | 10182 | if ($format eq 'rfc822') { |
| 10178 | 10183 | $tz = sprintf("%s%02d%02d", $so < 0 ? '-' : '+', |
| ... | ...@@ -15947,7 +15952,7 @@ | |
| 15947 | 15952 | # Added a file_ext filter to the filters list. |
| 15948 | 15953 | if (my $ext = $args->{file_ext}) { |
| 15949 | 15954 | my @exts = split(',', $args->{file_ext}); |
| 15950 | if (!$assets) { | |
| 15955 | if ($assets) { | |
| 15951 | 15956 | push @filters, sub { my $a = $_[0]->file_ext; grep(m/$a/, @exts) }; |
| 15952 | 15957 | } else { |
| 15953 | 15958 | $terms{file_ext} = \@exts; |
| ... | ...@@ -2419,12 +2419,12 @@ | |
| 2419 | 2419 | my $type = $app->param('__type') || ''; |
| 2420 | 2420 | if ( $type eq 'dialog' ) { |
| 2421 | 2421 | $param->{name} ||= $app->{name} || 'dialog'; |
| 2422 | $param->{goback} ||= $app->{goback} || 'closeDialog()'; | |
| 2422 | $param->{goback} ||= "window.location='" . $app->{goback} . "'" || 'closeDialog()'; | |
| 2423 | 2423 | $param->{value} ||= $app->{value} || $app->translate("Close"); |
| 2424 | 2424 | $param->{dialog} = 1; |
| 2425 | 2425 | } |
| 2426 | 2426 | else { |
| 2427 | $param->{goback} ||= $app->{goback} || 'history.back()'; | |
| 2427 | $param->{goback} ||= "window.location='" . $app->{goback} . "'" || 'history.back()'; | |
| 2428 | 2428 | $param->{value} ||= $app->{value} || $app->translate("Go Back"); |
| 2429 | 2429 | } |
| 2430 | 2430 | $tmpl->param($param); |
| ... | ...@@ -165,7 +165,12 @@ | |
| 165 | 165 | my $code = $fn->{code} || $fn->{handler}; |
| 166 | 166 | $code = MT->handler_to_coderef($code); |
| 167 | 167 | my $result = $code->($self, %param, %update_params, step => $name); |
| 168 | if ((defined $result) && ($result > 1)) { | |
| 168 | if (ref $result eq 'HASH') { | |
| 169 | $param{$_} = $result->{$_} for keys %$result; | |
| 170 | $result = 1; | |
| 171 | $self->add_step($name, %param); | |
| 172 | } | |
| 173 | elsif ((defined $result) && ($result > 1)) { | |
| 169 | 174 | $param{offset} = $result; $result = 1; |
| 170 | 175 | $self->add_step($name, %param); |
| 171 | 176 | } |
| ... | ...@@ -215,6 +220,7 @@ | |
| 215 | 220 | $MAX_ROWS = 300; |
| 216 | 221 | my $fn = \%MT::Upgrade::functions; |
| 217 | 222 | my @these_steps = @steps; |
| 223 | ||
| 218 | 224 | while (@these_steps) { |
| 219 | 225 | my $step = shift @these_steps; |
| 220 | 226 | @steps = (); |
| ... | ...@@ -224,6 +230,11 @@ | |
| 224 | 230 | @these_steps = sort { $fn->{$a->[0]}->{priority} <=> |
| 225 | 231 | $fn->{$b->[0]}->{priority} } @these_steps; |
| 226 | 232 | } |
| 233 | ||
| 234 | # Reset the request to eliminate any caching that may be | |
| 235 | # happening there (objects tend to cache into the request | |
| 236 | # with the 'cache_property' method) | |
| 237 | MT->request->reset; | |
| 227 | 238 | } |
| 228 | 239 | return 1; |
| 229 | 240 | } else { |
| ... | ...@@ -837,6 +848,93 @@ | |
| 837 | 848 | 1; |
| 838 | 849 | } |
| 839 | 850 | |
| 851 | sub core_update_entry_counts { | |
| 852 | my $self = shift; | |
| 853 | my (%param) = @_; | |
| 854 | ||
| 855 | my $class = MT->model('entry'); | |
| 856 | return $self->error($self->translate_escape("Error loading class: [_1].", $param{type})) | |
| 857 | unless $class; | |
| 858 | ||
| 859 | my $msg = $self->translate_escape("Assigning entry comment and TrackBack counts..."); | |
| 860 | my $offset = $param{offset} || 0; | |
| 861 | my $count = $param{count}; | |
| 862 | if (!$count) { | |
| 863 | $count = $class->count({ class => '*' }); | |
| 864 | } | |
| 865 | return unless $count; | |
| 866 | if ($offset) { | |
| 867 | $self->progress(sprintf("$msg (%d%%)", ($offset/$count*100)), $param{step}); | |
| 868 | } else { | |
| 869 | $self->progress($msg, $param{step}); | |
| 870 | } | |
| 871 | ||
| 872 | my $continue = 0; | |
| 873 | my $driver = $class->driver; | |
| 874 | ||
| 875 | my $iter = $class->load_iter({ class => '*' }, { offset => $offset, limit => $MAX_ROWS+1 }); | |
| 876 | my $start = time; | |
| 877 | my ( %touched, %c, %tb ); | |
| 878 | my $rows = 0; | |
| 879 | while (my $e = $iter->()) { | |
| 880 | $rows++; | |
| 881 | $c{$e->id} = $e; | |
| 882 | if (my $tb = $e->trackback) { | |
| 883 | $tb{$tb->id} = $e; | |
| 884 | } | |
| 885 | $continue = 1, last if scalar $rows == $MAX_ROWS; | |
| 886 | } | |
| 887 | if ( $continue ) { | |
| 888 | $iter->end; | |
| 889 | $offset += $rows; | |
| 890 | } | |
| 891 | ||
| 892 | # now gather counts -- comments | |
| 893 | if (my $grp_iter = MT::Comment->count_group_by({ | |
| 894 | visible => 1, | |
| 895 | entry_id => [ keys %c ], | |
| 896 | }, { | |
| 897 | group => ['entry_id'], | |
| 898 | })) { | |
| 899 | while (my ($count, $id) = $grp_iter->()) { | |
| 900 | my $e = $c{$id} or next; | |
| 901 | if ((!defined $e->comment_count) || (($e->comment_count || 0) != $count)) { | |
| 902 | $e->comment_count($count); | |
| 903 | $touched{$e->id} = $e; | |
| 904 | } | |
| 905 | } | |
| 906 | } | |
| 907 | ||
| 908 | # pings | |
| 909 | if ( %tb ) { | |
| 910 | if (my $grp_iter = MT::TBPing->count_group_by({ | |
| 911 | visible => 1, | |
| 912 | tb_id => [ keys %tb ], | |
| 913 | }, { | |
| 914 | group => ['tb_id'], | |
| 915 | })) { | |
| 916 |