| 1 | package MT::Test; |
|---|
| 2 | |
|---|
| 3 | use strict; |
|---|
| 4 | # Handle cwd = MT_DIR, MT_DIR/t |
|---|
| 5 | use lib 't/lib', 'extlib', 'lib', '../lib', '../extlib'; |
|---|
| 6 | use File::Spec; |
|---|
| 7 | use MT; |
|---|
| 8 | |
|---|
| 9 | use Test::More; |
|---|
| 10 | |
|---|
| 11 | BEGIN { |
|---|
| 12 | # if MT_HOME is not set, set it |
|---|
| 13 | unless ($ENV{MT_HOME}) { |
|---|
| 14 | require Cwd; |
|---|
| 15 | my $cwd = Cwd::getcwd(); |
|---|
| 16 | my @pieces = File::Spec->splitdir($cwd); |
|---|
| 17 | pop @pieces unless -d 't'; |
|---|
| 18 | $ENV{MT_HOME} = File::Spec->catdir(@pieces); |
|---|
| 19 | } |
|---|
| 20 | # if MT_CONFIG is not set, set it |
|---|
| 21 | if ($ENV{MT_CONFIG}) { |
|---|
| 22 | if (!File::Spec->file_name_is_absolute($ENV{MT_CONFIG})) { |
|---|
| 23 | $ENV{MT_CONFIG} = File::Spec->catfile($ENV{MT_HOME}, "t", $ENV{MT_CONFIG}); |
|---|
| 24 | } |
|---|
| 25 | } else { |
|---|
| 26 | $ENV{MT_CONFIG} = File::Spec->catfile($ENV{MT_HOME}, "t", "mt.cfg"); |
|---|
| 27 | } |
|---|
| 28 | chdir $ENV{MT_HOME}; |
|---|
| 29 | my $ds_dir = File::Spec->catdir($ENV{MT_HOME}, "t", "db"); |
|---|
| 30 | if (!-d $ds_dir) { |
|---|
| 31 | mkdir $ds_dir; |
|---|
| 32 | } |
|---|
| 33 | } |
|---|
| 34 | |
|---|
| 35 | sub import { |
|---|
| 36 | my $pkg = shift; |
|---|
| 37 | foreach my $opt (@_) { |
|---|
| 38 | if ($opt eq ':db') { |
|---|
| 39 | diag "Initializing database"; |
|---|
| 40 | $pkg->init_db(); |
|---|
| 41 | } |
|---|
| 42 | elsif ($opt eq ':testdb') { |
|---|
| 43 | $pkg->init_test_db(); |
|---|
| 44 | } |
|---|
| 45 | elsif ($opt eq ':data') { |
|---|
| 46 | diag "Initializing sample data"; |
|---|
| 47 | $pkg->sample_data(); |
|---|
| 48 | } |
|---|
| 49 | } |
|---|
| 50 | } |
|---|
| 51 | |
|---|
| 52 | sub init_test_db { |
|---|
| 53 | my $pkg = shift; |
|---|
| 54 | # This is a bit of MT::Upgrade magic to prevent the full |
|---|
| 55 | # instantiation of the MT schema. We force the classes list |
|---|
| 56 | # to only contain the test 'Foo', 'Bar' classes and neuter |
|---|
| 57 | # the |
|---|
| 58 | require MT::Upgrade; |
|---|
| 59 | # Add our test 'Foo' and 'Bar' classes to the list of |
|---|
| 60 | # object classes to install. |
|---|
| 61 | %MT::Upgrade::classes = (foo=>'Foo',bar=>'Bar'); |
|---|
| 62 | #MT::Upgrade->register_class(['Foo', 'Bar']); |
|---|
| 63 | MT->instance; |
|---|
| 64 | MT->registry->{object_types}->{foo} = 'Foo'; |
|---|
| 65 | MT->registry->{object_types}->{bar} = 'Bar'; |
|---|
| 66 | |
|---|
| 67 | # Replace the standard seed_database/install_template functions |
|---|
| 68 | # with stubs since we're not creating a full schema. |
|---|
| 69 | MT::Upgrade->register_upgrade_function({ |
|---|
| 70 | core_seed_database => { code => sub { 1 } }, |
|---|
| 71 | core_upgrade_templates => { code => sub { 1 } }, |
|---|
| 72 | core_upgrade_templates => { code => sub { 1 } }, |
|---|
| 73 | core_finish => { code => sub { 1 } }, |
|---|
| 74 | }); |
|---|
| 75 | $pkg->init_db(); |
|---|
| 76 | } |
|---|
| 77 | |
|---|
| 78 | sub init_db { |
|---|
| 79 | my $pkg = shift; |
|---|
| 80 | my ($cfg) = @_; |
|---|
| 81 | |
|---|
| 82 | my $mt = MT->instance($cfg ? (Config => $cfg) : ()) |
|---|
| 83 | or die "No MT object " . MT->errstr; |
|---|
| 84 | |
|---|
| 85 | my $types = MT->registry('object_types'); |
|---|
| 86 | $types->{$_} = MT->model($_) for |
|---|
| 87 | grep { MT->model($_) } |
|---|
| 88 | map { $_ . ':meta' } |
|---|
| 89 | grep { MT->model($_)->meta_pkg } |
|---|
| 90 | sort keys %$types; |
|---|
| 91 | my @classes = map { $types->{$_} } grep { $_ !~ /\./ } sort keys %$types; |
|---|
| 92 | foreach my $class (@classes) { |
|---|
| 93 | if (ref($class) eq 'ARRAY') { |
|---|
| 94 | next; #TODO for now - it won't hurt when we do driver-tests. |
|---|
| 95 | } |
|---|
| 96 | elsif (!defined *{ $class . '::__properties' }) { |
|---|
| 97 | eval '# line ' . __LINE__ . ' ' . __FILE__ . "\n" . 'require '.$class or die $@; |
|---|
| 98 | } |
|---|
| 99 | } |
|---|
| 100 | |
|---|
| 101 | # Clear existing database tables |
|---|
| 102 | my $driver = MT::Object->driver(); |
|---|
| 103 | foreach my $class (@classes) { |
|---|
| 104 | if (ref($class) eq 'ARRAY') { |
|---|
| 105 | next; #TODO for now - it won't hurt when we do driver-tests. |
|---|
| 106 | } |
|---|
| 107 | else { |
|---|
| 108 | if ($driver->dbd->ddl_class->table_exists($class)) { |
|---|
| 109 | $driver->sql( |
|---|
| 110 | $driver->dbd->ddl_class->drop_table_sql($class), |
|---|
| 111 | ); |
|---|
| 112 | $driver->dbd->ddl_class->drop_sequence($class), |
|---|
| 113 | } |
|---|
| 114 | } |
|---|
| 115 | } |
|---|
| 116 | |
|---|
| 117 | require MT::Upgrade; |
|---|
| 118 | # Initialize the MT database |
|---|
| 119 | MT::Upgrade->do_upgrade( |
|---|
| 120 | Install => 1, |
|---|
| 121 | App => __PACKAGE__, |
|---|
| 122 | User => {}, |
|---|
| 123 | Blog => {} |
|---|
| 124 | ); |
|---|
| 125 | eval { |
|---|
| 126 | # line __LINE__ __FILE__ |
|---|
| 127 | MT::Entry->remove; |
|---|
| 128 | MT::Comment->remove; |
|---|
| 129 | }; |
|---|
| 130 | } |
|---|
| 131 | |
|---|
| 132 | sub progress {} |
|---|
| 133 | sub error { |
|---|
| 134 | my ($x, $msg) = @_; |
|---|
| 135 | print "ERROR: $msg\n"; |
|---|
| 136 | } |
|---|
| 137 | |
|---|
| 138 | sub sample_data { |
|---|
| 139 | my $pkg = shift; |
|---|
| 140 | my $blog = MT::Blog->new(); |
|---|
| 141 | $blog->set_values({ |
|---|
| 142 | name => 'none', |
|---|
| 143 | site_url => 'http://narnia.na/nana/', |
|---|
| 144 | archive_url => 'http://narnia.na/nana/archives/', |
|---|
| 145 | site_path => 't/site/', |
|---|
| 146 | archive_path => 't/site/archives/', |
|---|
| 147 | archive_type=>'Individual,Monthly,Weekly,Daily,Category,Page', |
|---|
| 148 | archive_type_preferred => 'Individual', |
|---|
| 149 | description => "Narnia None Test Blog", |
|---|
| 150 | custom_dynamic_templates => 'custom', |
|---|
| 151 | convert_paras => 1, |
|---|
| 152 | allow_reg_comments => 1, |
|---|
| 153 | allow_unreg_comments => 0, |
|---|
| 154 | allow_pings => 1, |
|---|
| 155 | sort_order_posts => 'descend', |
|---|
| 156 | sort_order_comments => 'ascend', |
|---|
| 157 | remote_auth_token => 'token', |
|---|
| 158 | convert_paras_comments => 1, |
|---|
| 159 | google_api_key => 'r9Vj5K8PsjEu+OMsNZ/EEKjWmbCeQAv1', |
|---|
| 160 | cc_license => 'by-nc-sa http://creativecommons.org/licenses/by-nc-sa/2.0/ http://creativecommons.org/images/public/somerights20.gif', |
|---|
| 161 | server_offset => '-3.5', |
|---|
| 162 | children_modified_on => '20000101000000', |
|---|
| 163 | language => 'en_us', |
|---|
| 164 | file_extension => 'html', |
|---|
| 165 | }); |
|---|
| 166 | $blog->id(1); |
|---|
| 167 | $blog->commenter_authenticators('enabled_TypeKey'); |
|---|
| 168 | $blog->save() or die "Couldn't save blog 1: ". $blog->errstr; |
|---|
| 169 | diag "Saved blog"; |
|---|
| 170 | |
|---|
| 171 | require MT::Entry; |
|---|
| 172 | require MT::Author; |
|---|
| 173 | my $chuckd = MT::Author->new(); |
|---|
| 174 | $chuckd->set_values({ |
|---|
| 175 | name => 'Chuck D', |
|---|
| 176 | nickname => 'Chucky Dee', |
|---|
| 177 | email => 'chuckd@example.com', |
|---|
| 178 | url => 'http://chuckd.com/', |
|---|
| 179 | api_password => 'seecret', |
|---|
| 180 | auth_type => 'MT', |
|---|
| 181 | }); |
|---|
| 182 | $chuckd->set_password("bass"); |
|---|
| 183 | $chuckd->type(MT::Author::AUTHOR()); |
|---|
| 184 | $chuckd->id(2); |
|---|
| 185 | $chuckd->is_superuser(1); |
|---|
| 186 | $chuckd->save() |
|---|
| 187 | or die "Couldn't save author record 2: " . $chuckd->errstr; |
|---|
| 188 | diag "Saved user Chuck D"; |
|---|
| 189 | |
|---|
| 190 | my $bobd = MT::Author->new(); |
|---|
| 191 | $bobd->set_values({ |
|---|
| 192 | name => 'Bob D', |
|---|
| 193 | nickname => 'Dylan', |
|---|
| 194 | email => 'bobd@example.com', |
|---|
| 195 | auth_type => 'MT', |
|---|
| 196 | }); |
|---|
| 197 | $bobd->set_password("flute"); |
|---|
| 198 | $bobd->type(MT::Author::AUTHOR()); |
|---|
| 199 | $bobd->id(3); |
|---|
| 200 | $bobd->save() or die "Couldn't save author record 3: " . $bobd->errstr; |
|---|
| 201 | diag "Saved user Bob D"; |
|---|
| 202 | |
|---|
| 203 | my $johnd = MT::Author->new(); |
|---|
| 204 | $johnd->set_values({ |
|---|
| 205 | name => 'John Doe', |
|---|
| 206 | nickname => 'John Doe', |
|---|
| 207 | email => 'jdoe@doe.com', |
|---|
| 208 | auth_type => 'TypeKey', |
|---|
| 209 | }); |
|---|
| 210 | $johnd->type(MT::Author::COMMENTER()); |
|---|
| 211 | $johnd->password('(none)'); |
|---|
| 212 | $johnd->id(4); |
|---|
| 213 | $johnd->save() or die "Couldn't save author record 4: " . $johnd->errstr; |
|---|
| 214 | diag "Saved user John Doe"; |
|---|
| 215 | |
|---|
| 216 | my $hiro = MT::Author->new(); |
|---|
| 217 | $hiro->set_values({ |
|---|
| 218 | name => 'Hiro Nakamura', |
|---|
| 219 | nickname => 'Hiro', |
|---|
| 220 | email => 'hiro@heroes.com', |
|---|
| 221 | auth_type => 'MT', |
|---|
| 222 | }); |
|---|
| 223 | $hiro->type(MT::Author::AUTHOR()); |
|---|
| 224 | $hiro->password('time'); |
|---|
| 225 | $hiro->id(5); |
|---|
| 226 | $hiro->status(2); |
|---|
| 227 | $hiro->save() or die "Couldn't save author record 5: " . $hiro->errstr; |
|---|
| 228 | diag "Saved user Hiro"; |
|---|
| 229 | |
|---|
| 230 | require MT::Role; |
|---|
| 231 | my ($admin_role, $author_role) = map { MT::Role->load({ name => $_ }) } |
|---|
| 232 | ('Blog Administrator', 'Author'); |
|---|
| 233 | |
|---|
| 234 | require MT::Association; |
|---|
| 235 | my $assoc = MT::Association->new(); |
|---|
| 236 | $assoc->author_id($chuckd->id); |
|---|
| 237 | $assoc->blog_id(1); |
|---|
| 238 | $assoc->role_id($admin_role->id); |
|---|
| 239 | $assoc->type(1); |
|---|
| 240 | $assoc->save(); |
|---|
| 241 | |
|---|
| 242 | $assoc = MT::Association->new(); |
|---|
| 243 | $assoc->author_id($bobd->id); |
|---|
| 244 | $assoc->blog_id(1); |
|---|
| 245 | $assoc->role_id($author_role->id); |
|---|
| 246 | $assoc->type(1); |
|---|
| 247 | $assoc->save(); |
|---|
| 248 | |
|---|
| 249 | $assoc = MT::Association->new(); |
|---|
| 250 | $assoc->author_id($hiro->id); |
|---|
| 251 | $assoc->blog_id(1); |
|---|
| 252 | $assoc->role_id($admin_role->id); |
|---|
| 253 | $assoc->type(1); |
|---|
| 254 | $assoc->save(); |
|---|
| 255 | |
|---|
| 256 | # set permission record for johnd commenter on blog 1 |
|---|
| 257 | $johnd->approve(1); |
|---|
| 258 | |
|---|
| 259 | my $entry = MT::Entry->load(1); |
|---|
| 260 | if (!$entry) { |
|---|
| 261 | $entry = MT::Entry->new(); |
|---|
| 262 | $entry->set_values({ |
|---|
| 263 | blog_id => 1, |
|---|
| 264 | title => 'A Rainy Day', |
|---|
| 265 | text => 'On a drizzly day last weekend,', |
|---|
| 266 | text_more => 'I took my grandpa for a walk.', |
|---|
| 267 | excerpt => 'A story of a stroll.', |
|---|
| 268 | keywords => 'keywords', |
|---|
| 269 | created_on => '19780131074500', |
|---|
| 270 | authored_on => '19780131074500', |
|---|
| 271 | modified_on => '19780131074600', |
|---|
| 272 | authored_on => '19780131074500', |
|---|
| 273 | author_id => $chuckd->id, |
|---|
| 274 | pinged_urls => 'http://technorati.com/', |
|---|
| 275 | allow_comments => 1, |
|---|
| 276 | allow_pings => 1, |
|---|
| 277 | status => MT::Entry::RELEASE(), |
|---|
| 278 | }); |
|---|
| 279 | $entry->id(1); |
|---|
| 280 | $entry->tags('rain', 'grandpa', 'strolling'); |
|---|
| 281 | $entry->save() or die "Couldn't save entry record 1: ".$entry->errstr; |
|---|
| 282 | diag "Saved entry #1"; |
|---|
| 283 | } |
|---|
| 284 | |
|---|
| 285 | $entry = MT::Entry->load(2); |
|---|
| 286 | if (!$entry) { |
|---|
| 287 | $entry = MT::Entry->new(); |
|---|
| 288 | $entry->set_values({ |
|---|
| 289 | blog_id => 1, |
|---|
| 290 | title => 'A preponderance of evidence', |
|---|
| 291 | text => 'It is sufficient to say...', |
|---|
| 292 | text_more => 'I suck at making up test data.', |
|---|
| 293 | created_on => '19790131074500', |
|---|
| 294 | authored_on => '19790131074500', |
|---|
| 295 | modified_on => '19790131074600', |
|---|
| 296 | authored_on => '19780131074500', |
|---|
| 297 | author_id => $bobd->id, |
|---|
| 298 | allow_comments => 1, |
|---|
| 299 | status => MT::Entry::FUTURE(), |
|---|
| 300 | }); |
|---|
| 301 | $entry->id(2); |
|---|
| 302 | $entry->save() or die "Couldn't save entry record 2: ".$entry->errstr; |
|---|
| 303 | diag "Saved entry #2"; |
|---|
| 304 | } |
|---|
| 305 | |
|---|
| 306 | $entry = MT::Entry->load(3); |
|---|
| 307 | if (!$entry) { |
|---|
| 308 | $entry = MT::Entry->new(); |
|---|
| 309 | $entry->set_values({ |
|---|
| 310 | blog_id => 1, |
|---|
| 311 | title => 'Spurious anemones', |
|---|
| 312 | text => '...are better than the non-spurious', |
|---|
| 313 | text_more => 'variety.', |
|---|
| 314 | created_on => '19770131074500', |
|---|
| 315 | authored_on => '19790131074500', |
|---|
| 316 | modified_on => '19770131074600', |
|---|
| 317 | authored_on => '19780131074500', |
|---|
| 318 | author_id => $chuckd->id, |
|---|
| 319 | allow_comments => 1, |
|---|
| 320 | allow_pings => 0, |
|---|
| 321 | status => MT::Entry::HOLD(), |
|---|
| 322 | }); |
|---|
| 323 | $entry->id(3); |
|---|
| 324 | $entry->tags('anemones'); |
|---|
| 325 | $entry->save() or die "Couldn't save entry record 3: ".$entry->errstr; |
|---|
| 326 | diag "Saved entry #3"; |
|---|
| 327 | } |
|---|
| 328 | |
|---|
| 329 | require MT::Trackback; |
|---|
| 330 | my $tb = MT::Trackback->load(1); |
|---|
| 331 | if (!$tb) { |
|---|
| 332 | $tb = new MT::Trackback; |
|---|
| 333 | $tb->entry_id(1); |
|---|
| 334 | $tb->blog_id(1); |
|---|
| 335 | $tb->title("Entry TrackBack Title"); |
|---|
| 336 | $tb->description("Entry TrackBack Description"); |
|---|
| 337 | $tb->category_id(0); |
|---|
| 338 | $tb->id(1); |
|---|
| 339 | $tb->save or die "Couldn't save Trackback record 1: " . $tb->errstr;; |
|---|
| 340 | } |
|---|
| 341 | |
|---|
| 342 | require MT::TBPing; |
|---|
| 343 | my $ping = MT::TBPing->load(1); |
|---|
| 344 | if (!$ping) { |
|---|
| 345 | $ping = new MT::TBPing; |
|---|
| 346 | $ping->tb_id(1); |
|---|
| 347 | $ping->blog_id(1); |
|---|
| 348 | $ping->ip('127.0.0.1'); |
|---|
| 349 | $ping->title('Foo'); |
|---|
| 350 | $ping->excerpt('Bar'); |
|---|
| 351 | $ping->source_url('http://example.com/'); |
|---|
| 352 | $ping->blog_name("Example Blog"); |
|---|
| 353 | $ping->created_on('20050405000000'); |
|---|
| 354 | $ping->id(1); |
|---|
| 355 | $ping->visible(1); |
|---|
| 356 | $ping->save or die "Couldn't save TBPing record 1: " . $ping->errstr; |
|---|
| 357 | diag "Saved a trackback ping"; |
|---|
| 358 | } |
|---|
| 359 | |
|---|
| 360 | my @verses = ( |
|---|
| 361 | 'Oh, where have you been, my blue-eyed son? |
|---|
| 362 | Oh, where have you been, my darling young one?', |
|---|
| 363 | 'I saw a newborn baby with wild wolves all around it |
|---|
| 364 | I saw a highway of diamonds with nobody on it', |
|---|
| 365 | 'Heard one hundred drummers whose hands were a-blazin\', |
|---|
| 366 | Heard ten thousand whisperin\' and nobody listenin\'', |
|---|
| 367 | 'I met one man who was wounded in love, |
|---|
| 368 | I met another man who was wounded with hatred', |
|---|
| 369 | 'Where hunger is ugly, where souls are forgotten, |
|---|
| 370 | Where black is the color, where none is the number, |
|---|
| 371 | And it\'s a hard, it\'s a hard, it\'s a hard, it\'s a hard, |
|---|
| 372 | It\'s a hard rain\'s a-gonna fall', |
|---|
| 373 | ); |
|---|
| 374 | |
|---|
| 375 | require MT::Category; |
|---|
| 376 | my $cat = MT::Category->load({ label => 'foo', blog_id => 1}); |
|---|
| 377 | if (!$cat) { |
|---|
| 378 | $cat = new MT::Category; |
|---|
| 379 | $cat->blog_id(1); |
|---|
| 380 | $cat->label('foo'); |
|---|
| 381 | $cat->description('bar'); |
|---|
| 382 | $cat->author_id($chuckd->id); |
|---|
| 383 | $cat->parent(0); |
|---|
| 384 | $cat->id(1); |
|---|
| 385 | $cat->save or die "Couldn't save category record 1: ". $cat->errstr; |
|---|
| 386 | diag "Saved category foo"; |
|---|
| 387 | } |
|---|
| 388 | |
|---|
| 389 | $cat = MT::Category->load({ label => 'bar', blog_id => 1}); |
|---|
| 390 | if (!$cat) { |
|---|
| 391 | $cat = new MT::Category; |
|---|
| 392 | $cat->blog_id(1); |
|---|
| 393 | $cat->label('bar'); |
|---|
| 394 | $cat->description('foo'); |
|---|
| 395 | $cat->author_id($chuckd->id); |
|---|
| 396 | $cat->parent(0); |
|---|
| 397 | $cat->id(2); |
|---|
| 398 | $cat->save or die "Couldn't save category record 2: ". $cat->errstr; |
|---|
| 399 | diag "Saved category bar"; |
|---|
| 400 | } |
|---|
| 401 | |
|---|
| 402 | $tb = MT::Trackback->load(2); |
|---|
| 403 | if (!$tb) { |
|---|
| 404 | $tb = new MT::Trackback; |
|---|
| 405 | $tb->title("Category TrackBack Title"); |
|---|
| 406 | $tb->description("Category TrackBack Description"); |
|---|
| 407 | $tb->entry_id(0); |
|---|
| 408 | $tb->blog_id(1); |
|---|
| 409 | $tb->category_id(2); |
|---|
| 410 | $tb->id(2); |
|---|
| 411 | $tb->save or die "Couldn't save Trackback record 2: " . $tb->errstr;; |
|---|
| 412 | diag "Saved category bar's trackback target"; |
|---|
| 413 | } |
|---|
| 414 | |
|---|
| 415 | $cat = MT::Category->load({ label => 'subfoo', blog_id => 1}); |
|---|
| 416 | if (!$cat) { |
|---|
| 417 | $cat = new MT::Category; |
|---|
| 418 | $cat->blog_id(1); |
|---|
| 419 | $cat->label('subfoo'); |
|---|
| 420 | $cat->description('subcat'); |
|---|
| 421 | $cat->author_id($bobd->id); |
|---|
| 422 | $cat->parent(1); |
|---|
| 423 | $cat->id(3); |
|---|
| 424 | $cat->save or die "Couldn't save category record 3: ". $cat->errstr; |
|---|
| 425 | diag "Saved subcategory subfoo"; |
|---|
| 426 | } |
|---|
| 427 | |
|---|
| 428 | require MT::Placement; |
|---|
| 429 | foreach my $i (1..@verses) { |
|---|
| 430 | $entry = MT::Entry->load($i+3); |
|---|
| 431 | if (!$entry) { |
|---|
| 432 | $entry = MT::Entry->new(); |
|---|
| 433 | $entry->set_values({ |
|---|
| 434 | blog_id => 1, |
|---|
| 435 | title => "Verse $i", |
|---|
| 436 | text => $verses[$i], |
|---|
| 437 | author_id => ($i == 3 ? $bobd->id : $chuckd->id), |
|---|
| 438 | created_on => sprintf("%04d0131074501", $i + 1960), |
|---|
| 439 | authored_on => sprintf("%04d0131074501", $i + 1960), |
|---|
| 440 | modified_on => sprintf("%04d0131074601", $i + 1960), |
|---|
| 441 | authored_on => sprintf("%04d0131074501", $i + 1960), |
|---|
| 442 | allow_comments => ($i <= 2 ? 0 : 1), |
|---|
| 443 | status => MT::Entry::RELEASE(), |
|---|
| 444 | }); |
|---|
| 445 | $entry->id($i+3); |
|---|
| 446 | if ( $i == 1 || $i == 3 || $i == 5 ) { |
|---|
| 447 | $entry->tags('verse', 'rain'); |
|---|
| 448 | } |
|---|
| 449 | else { |
|---|
| 450 | $entry->tags('verse', 'anemones'); |
|---|
| 451 | } |
|---|
| 452 | $entry->save() |
|---|
| 453 | or die "Couldn't save entry record ".($entry->id).": ". $entry->errstr; |
|---|
| 454 | if ($i == 3) { |
|---|
| 455 | my $place = new MT::Placement; |
|---|
| 456 | $place->entry_id($entry->id); |
|---|
| 457 | $place->blog_id(1); |
|---|
| 458 | $place->category_id(1); |
|---|
| 459 | $place->is_primary(1); |
|---|
| 460 | $place->save |
|---|
| 461 | or die "Couldn't save placement record: ".$place->errstr; |
|---|
| 462 | diag "Placed entry Verse 3 in category foo"; |
|---|
| 463 | } |
|---|
| 464 | if ($i == 4) { |
|---|
| 465 | my $place = new MT::Placement; |
|---|
| 466 | $place->entry_id($entry->id); |
|---|
| 467 | $place->blog_id(1); |
|---|
| 468 | $place->category_id(3); |
|---|
| 469 | $place->is_primary(1); |
|---|
| 470 | $place->save |
|---|
| 471 | or die "Couldn't save placement record: ".$place->errstr; |
|---|
| 472 | diag "Placed entry Verse 4 in category subfoo"; |
|---|
| 473 | } |
|---|
| 474 | } |
|---|
| 475 | } |
|---|
| 476 | |
|---|
| 477 | # entry id 1 - 1 visible comment |
|---|
| 478 | # entry id 4 - no comments, commenting is off |
|---|
| 479 | require MT::Comment; |
|---|
| 480 | unless (MT::Comment->count({entry_id => 1})) { |
|---|
| 481 | my $cmt = new MT::Comment(); |
|---|
| 482 | $cmt->set_values({ |
|---|
| 483 | text => 'Postmodern false consciousness has always been firmly rooted in post-Freudian Lacanian neo-Marxist bojangles. Needless to say, this quickly and asymptotically approches a purpletacular jouissance of etic jumpinmypants.', |
|---|
| 484 | entry_id => 1, |
|---|
| 485 | author => 'v14GrUH 4 cheep', |
|---|
| 486 | visible => 1, |
|---|
| 487 | email => 'jake@fatman.com', |
|---|
| 488 | url => 'http://fatman.com/', |
|---|
| 489 | blog_id => 1, |
|---|
| 490 | ip => '127.0.0.1', |
|---|
| 491 | created_on => '20040914182800', |
|---|
| 492 | }); |
|---|
| 493 | $cmt->id(1); |
|---|
| 494 | $cmt->save() or die "Couldn't save comment record 1: ".$cmt->errstr; |
|---|
| 495 | diag "Saved comment #1"; |
|---|
| 496 | |
|---|
| 497 | $cmt->id(11); |
|---|
| 498 | $cmt->text('Comment reply for comment 1'); |
|---|
| 499 | $cmt->author('Comment 11'); |
|---|
| 500 | $cmt->created_on('20040812182900'); |
|---|
| 501 | $cmt->parent_id(1); |
|---|
| 502 | $cmt->save() or die "Couldn't save comment record 11: ".$cmt->errstr; |
|---|
| 503 | diag "Saved child comment #11"; |
|---|
| 504 | |
|---|
| 505 | $cmt->id(12); |
|---|
| 506 | $cmt->text('Comment reply for comment 11'); |
|---|
| 507 | $cmt->author('Comment 12'); |
|---|
| 508 | $cmt->created_on('20040810183000'); |
|---|
| 509 | $cmt->parent_id(11); |
|---|
| 510 | $cmt->save() or die "Couldn't save comment record 12: ".$cmt->errstr; |
|---|
| 511 | diag "Saved child comment #12"; |
|---|
| 512 | } |
|---|
| 513 | # entry id 5 - 1 comment, commenting is off (closed) |
|---|
| 514 | unless (MT::Comment->count({entry_id => 5})) { |
|---|
| 515 | my $cmt = new MT::Comment(); |
|---|
| 516 | $cmt->set_values({ |
|---|
| 517 | text => 'Comment for entry 5, visible', |
|---|
| 518 | entry_id => 5, |
|---|
| 519 | author => 'Comment 2', |
|---|
| 520 | visible => 1, |
|---|
| 521 | email => 'johnd@doe.com', |
|---|
| 522 | url => 'http://john.doe.com/', |
|---|
| 523 | commenter_id => $johnd->id, |
|---|
| 524 | blog_id => 1, |
|---|
| 525 | ip => '127.0.0.1', |
|---|
| 526 | created_on => '20040912182800', |
|---|
| 527 | }); |
|---|
| 528 | $cmt->id(2); |
|---|
| 529 | $cmt->junk_score(1.5); |
|---|
| 530 | $cmt->save() or die "Couldn't save comment record 2: ".$cmt->errstr; |
|---|
| 531 | } |
|---|
| 532 | # entry id 6 - 3 comment visible, 1 moderated |
|---|
| 533 | unless (MT::Comment->count({entry_id => 6})) { |
|---|
| 534 | my $cmt = new MT::Comment(); |
|---|
| 535 | $cmt->set_values({ |
|---|
| 536 | text => 'Comment for entry 6, visible', |
|---|
| 537 | entry_id => 6, |
|---|
| 538 | author => 'Comment 3', |
|---|
| 539 | visible => 1, |
|---|
| 540 | email => '', |
|---|
| 541 | url => '', |
|---|
| 542 | blog_id => 1, |
|---|
| 543 | ip => '127.0.0.1', |
|---|
| 544 | created_on => '20040911182800', |
|---|
| 545 | }); |
|---|
| 546 | $cmt->id(3); |
|---|
| 547 | $cmt->save() or die "Couldn't save comment record 3: ".$cmt->errstr; |
|---|
| 548 | |
|---|
| 549 | $cmt->id(4); |
|---|
| 550 | $cmt->visible(0); |
|---|
| 551 | $cmt->author('Comment 4'); |
|---|
| 552 | $cmt->text('Comment for entry 6, moderated'); |
|---|
| 553 | $cmt->created_on('20040910182800'); |
|---|
| 554 | $cmt->save() or die "Couldn't save comment record 4: ".$cmt->errstr; |
|---|
| 555 | |
|---|
| 556 | $cmt->text("All your comments are belonged to me."); |
|---|
| 557 | $cmt->commenter_id($chuckd->id); |
|---|
| 558 | $cmt->visible(1); |
|---|
| 559 | $cmt->id(14); |
|---|
| 560 | $cmt->save or die "Couldn't save comment record 1: ".$cmt->errstr; |
|---|
| 561 | |
|---|
| 562 | $cmt->text("All your comments are belonged to us MT Authors."); |
|---|
| 563 | $cmt->commenter_id($bobd->id); |
|---|
| 564 | $cmt->visible(1); |
|---|
| 565 | $cmt->id(15); |
|---|
| 566 | $cmt->save or die "Couldn't save comment record 1: ".$cmt->errstr; |
|---|
| 567 | } |
|---|
| 568 | # entry id 7 - 0 comment visible, 1 moderated |
|---|
| 569 | unless (MT::Comment->count({entry_id => 7})) { |
|---|
| 570 | my $cmt = new MT::Comment(); |
|---|
| 571 | $cmt->set_values({ |
|---|
| 572 | text => 'Comment for entry 7, moderated', |
|---|
| 573 | entry_id => 7, |
|---|
| 574 | author => 'Comment 7', |
|---|
| 575 | visible => 0, |
|---|
| 576 | email => '', |
|---|
| 577 | url => '', |
|---|
| 578 | blog_id => 1, |
|---|
| 579 | ip => '127.0.0.1', |
|---|
| 580 | created_on => '20040909182800', |
|---|
| 581 | }); |
|---|
| 582 | $cmt->id(5); |
|---|
| 583 | $cmt->save() or die "Couldn't save comment record 5: ".$cmt->errstr; |
|---|
| 584 | } |
|---|
| 585 | # entry id 8 - 1 comment visible, 1 moderated, 1 junk |
|---|
| 586 | unless (MT::Comment->count({entry_id => 8})) { |
|---|
| 587 | my $cmt = new MT::Comment(); |
|---|
| 588 | $cmt->set_values({ |
|---|
| 589 | text => 'Comment for entry 8, visible', |
|---|
| 590 | entry_id => 8, |
|---|
| 591 | author => 'Comment 8', |
|---|
| 592 | visible => 1, |
|---|
| 593 | email => '', |
|---|
| 594 | url => '', |
|---|
| 595 | blog_id => 1, |
|---|
| 596 | ip => '127.0.0.1', |
|---|
| 597 | created_on => '20040814182800', |
|---|
| 598 | }); |
|---|
| 599 | $cmt->id(6); |
|---|
| 600 | $cmt->save() or die "Couldn't save comment record 6: ".$cmt->errstr; |
|---|
| 601 | |
|---|
| 602 | $cmt->id(7); |
|---|
| 603 | $cmt->visible(0); |
|---|
| 604 | $cmt->text('Comment for entry 8, moderated'); |
|---|
| 605 | $cmt->author('JD7'); |
|---|
| 606 | $cmt->created_on('20040812182800'); |
|---|
| 607 | $cmt->save() or die "Couldn't save comment record 7: ".$cmt->errstr; |
|---|
| 608 | |
|---|
| 609 | $cmt->id(8); |
|---|
| 610 | $cmt->visible(0); |
|---|
| 611 | $cmt->junk_status(-1); |
|---|
| 612 | $cmt->text('Comment for entry 8, junk'); |
|---|
| 613 | $cmt->author('JD8'); |
|---|
| 614 | $cmt->created_on('20040810182800'); |
|---|
| 615 | $cmt->save() or die "Couldn't save comment record 8: ".$cmt->errstr; |
|---|
| 616 | } |
|---|
| 617 | |
|---|
| 618 | require MT::Template; |
|---|
| 619 | require MT::TemplateMap; |
|---|
| 620 | |
|---|
| 621 | my $tmpl = new MT::Template; |
|---|
| 622 | $tmpl->blog_id(1); |
|---|
| 623 | $tmpl->name('blog-name'); |
|---|
| 624 | $tmpl->text('<MTBlogName>'); |
|---|
| 625 | $tmpl->type('custom'); |
|---|
| 626 | $tmpl->save or die "Couldn't save template record 1: ".$tmpl->errstr; |
|---|
| 627 | diag "Saved blog-name template"; |
|---|
| 628 | |
|---|
| 629 | ### Asset |
|---|
| 630 | use MT::Asset; |
|---|
| 631 | |
|---|
| 632 | my $img_pkg = MT::Asset->class_handler('image'); |
|---|
| 633 | my $file_pkg = MT::Asset->class_handler('file'); |
|---|
| 634 | my $asset = new $img_pkg; |
|---|
| 635 | $asset->blog_id(1); |
|---|
| 636 | $asset->url('http://narnia.na/nana/images/test.jpg'); |
|---|
| 637 | $asset->file_path(File::Spec->catfile($ENV{MT_HOME}, "t", 'images', 'test.jpg')); |
|---|
| 638 | $asset->file_name('test.jpg'); |
|---|
| 639 | $asset->file_ext('jpg'); |
|---|
| 640 | $asset->image_width(640); |
|---|
| 641 | diag "Set image asset's width metadata field"; |
|---|
| 642 | $asset->image_height(480); |
|---|
| 643 | $asset->mime_type('image/jpeg'); |
|---|
| 644 | $asset->label('Image photo'); |
|---|
| 645 | $asset->description('This is a test photo.'); |
|---|
| 646 | $asset->created_by(1); |
|---|
| 647 | $asset->tags('alpha', 'beta', 'gamma'); |
|---|
| 648 | diag "Tagged image asset"; |
|---|
| 649 | $asset->save or die "Couldn't save asset record 1: " . $asset->errstr; |
|---|
| 650 | diag "Saved image asset"; |
|---|
| 651 | |
|---|
| 652 | $asset->set_score('unit test', $bobd, 5, 1); |
|---|
| 653 | $asset->set_score('unit test', $johnd, 3, 1); |
|---|
| 654 | $asset->set_score('unit test', MT::Author->load(1), 4, 1); |
|---|
| 655 | |
|---|
| 656 | $asset = new $file_pkg; |
|---|
| 657 | $asset->blog_id(1); |
|---|
| 658 | $asset->url('http://narnia.na/nana/files/test.tmpl'); |
|---|
| 659 | $asset->file_path(File::Spec->catfile($ENV{MT_HOME}, "t", 'test.tmpl')); |
|---|
| 660 | $asset->file_name('test.tmpl'); |
|---|
| 661 | $asset->file_ext('tmpl'); |
|---|
| 662 | $asset->mime_type('text/plain'); |
|---|
| 663 | $asset->label('Template'); |
|---|
| 664 | $asset->description('This is a test template.'); |
|---|
| 665 | $asset->created_by(1); |
|---|
| 666 | $asset->created_on('19780131074500'); |
|---|
| 667 | $asset->tags('beta'); |
|---|
| 668 | $asset->save or die "Couldn't save file asset record: " . $asset->errstr; |
|---|
| 669 | diag "Saved file asset"; |
|---|
| 670 | |
|---|
| 671 | $asset->set_score('unit test', $chuckd, 2, 1); |
|---|
| 672 | $asset->set_score('unit test', $johnd, 3, 1); |
|---|
| 673 | |
|---|
| 674 | ## ObjectScore |
|---|
| 675 | my $e5 = MT::Entry->load(5); |
|---|
| 676 | $e5->set_score('unit test', $bobd, 5, 1); |
|---|
| 677 | $e5->set_score('unit test', $johnd, 3, 1); |
|---|
| 678 | $e5->set_score('unit test', MT::Author->load(1), 4, 1); |
|---|
| 679 | |
|---|
| 680 | my $e6 = MT::Entry->load(6); |
|---|
| 681 | $e6->set_score('unit test', $chuckd, 1, 1); |
|---|
| 682 | $e6->set_score('unit test', $johnd, 1, 1); |
|---|
| 683 | |
|---|
| 684 | my $e4 = MT::Entry->load(4); |
|---|
| 685 | $e4->set_score('unit test', $chuckd, 2, 1); |
|---|
| 686 | $e4->set_score('unit test', $johnd, 3, 1); |
|---|
| 687 | diag "Saved scores for entry #4"; |
|---|
| 688 | |
|---|
| 689 | ## Page |
|---|
| 690 | require MT::Page; |
|---|
| 691 | my $page = MT::Page->new(); |
|---|
| 692 | $page->set_values({ |
|---|
| 693 | blog_id => 1, |
|---|
| 694 | title => 'Watching the River Flow', |
|---|
| 695 | text => 'What the matter with me,', |
|---|
| 696 | text_more => 'I don\'t have much to say,', |
|---|
| 697 | keywords => 'no folder', |
|---|
| 698 | excerpt => 'excerpt', |
|---|
| 699 | created_on => '19780131074500', |
|---|
| 700 | authored_on => '19780131074500', |
|---|
| 701 | modified_on => '19780131074600', |
|---|
| 702 | author_id => $chuckd->id, |
|---|
| 703 | status => MT::Entry::RELEASE(), |
|---|
| 704 | }); |
|---|
| 705 | $page->id(20); |
|---|
| 706 | $page->tags('river', 'flow', 'watch'); |
|---|
| 707 | $page->save() or die "Couldn't save page record 20: ".$page->errstr; |
|---|
| 708 | |
|---|
| 709 | require MT::Folder; |
|---|
| 710 | my $folder = MT::Folder->new(); |
|---|
| 711 | $folder->blog_id(1); |
|---|
| 712 | $folder->label('info'); |
|---|
| 713 | $folder->description('information'); |
|---|
| 714 | $folder->author_id($chuckd->id); |
|---|
| 715 | $folder->parent(0); |
|---|
| 716 | $folder->id(20); |
|---|
| 717 | $folder->save or die "Could'n sae folder record 20:" . $folder->errstr; |
|---|
| 718 | diag "Saved folder #20"; |
|---|
| 719 | |
|---|
| 720 | $folder = MT::Folder->new(); |
|---|
| 721 | $folder->blog_id(1); |
|---|
| 722 | $folder->label('download'); |
|---|
| 723 | $folder->description('download top'); |
|---|
| 724 | $folder->author_id($chuckd->id); |
|---|
| 725 | $folder->parent(0); |
|---|
| 726 | $folder->id(21); |
|---|
| 727 | $folder->save or die "Could'n sae folder record 21:" . $folder->errstr; |
|---|
| 728 | |
|---|
| 729 | $folder = MT::Folder->new(); |
|---|
| 730 | $folder->blog_id(1); |
|---|
| 731 | $folder->label('nightly'); |
|---|
| 732 | $folder->description('nightly build'); |
|---|
| 733 | $folder->author_id($chuckd->id); |
|---|
| 734 | $folder->parent(21); |
|---|
| 735 | $folder->id(22); |
|---|
| 736 | $folder->save or die "Could'n sae folder record 22:" . $folder->errstr; |
|---|
| 737 | |
|---|
| 738 | $page = MT::Page->new(); |
|---|
| 739 | $page->set_values({ |
|---|
| 740 | blog_id => 1, |
|---|
| 741 | title => 'Page #1', |
|---|
| 742 | text => 'Wish I was back in the city', |
|---|
| 743 | text_more => 'Instead of this old bank of sand,', |
|---|
| 744 | keywords => 'keywords', |
|---|
| 745 | created_on => '19790131074500', |
|---|
| 746 | authored_on => '19790131074500', |
|---|
| 747 | modified_on => '19790131074600', |
|---|
| 748 | author_id => $chuckd->id, |
|---|
| 749 | status => MT::Entry::RELEASE(), |
|---|
| 750 | }); |
|---|
| 751 | $page->id(21); |
|---|
| 752 | $page->tags('page1', 'page2', 'page3'); |
|---|
| 753 | $page->save() or die "Couldn't save page record 21: ".$page->errstr; |
|---|
| 754 | |
|---|
| 755 | my $folder_place = new MT::Placement; |
|---|
| 756 | $folder_place->entry_id(21); |
|---|
| 757 | $folder_place->blog_id(1); |
|---|
| 758 | $folder_place->category_id(20); |
|---|
| 759 | $folder_place->is_primary(1); |
|---|
| 760 | $folder_place->save |
|---|
| 761 | or die "Couldn't save placement record: ".$folder_place->errstr; |
|---|
| 762 | |
|---|
| 763 | $page = MT::Page->new(); |
|---|
| 764 | $page->set_values({ |
|---|
| 765 | blog_id => 1, |
|---|
| 766 | title => 'Page #2', |
|---|
| 767 | text => 'With the sub beating down over the chimney tops', |
|---|
| 768 | text_more => 'And the one I love so close at hand', |
|---|
| 769 | keywords => 'keywords', |
|---|
| 770 | created_on => '19800131074500', |
|---|
| 771 | authored_on => '19800131074500', |
|---|
| 772 | modified_on => '19800131074600', |
|---|
| 773 | author_id => $chuckd->id, |
|---|
| 774 | status => MT::Entry::RELEASE(), |
|---|
| 775 | }); |
|---|
| 776 | $page->id(22); |
|---|
| 777 | $page->tags('page2', 'page3'); |
|---|
| 778 | $page->save() or die "Couldn't save page record 22: ".$page->errstr; |
|---|
| 779 | |
|---|
| 780 | $folder_place = new MT::Placement; |
|---|
| 781 | $folder_place->entry_id(22); |
|---|
| 782 | $folder_place->blog_id(1); |
|---|
| 783 | $folder_place->category_id(21); |
|---|
| 784 | $folder_place->is_primary(1); |
|---|
| 785 | $folder_place->save |
|---|
| 786 | or die "Couldn't save placement record: ".$folder_place->errstr; |
|---|
| 787 | |
|---|
| 788 | $page = MT::Page->new(); |
|---|
| 789 | $page->set_values({ |
|---|
| 790 | blog_id => 1, |
|---|
| 791 | title => 'Page #3', |
|---|
| 792 | text => 'If I had wings and I could fly,', |
|---|
| 793 | text_more => 'I know where I would go.', |
|---|
| 794 | keywords => 'keywords', |
|---|
| 795 | created_on => '19810131074500', |
|---|
| 796 | authored_on => '19810131074500', |
|---|
| 797 | modified_on => '19810131074600', |
|---|
| 798 | author_id => $bobd->id, |
|---|
| 799 | status => MT::Entry::RELEASE(), |
|---|
| 800 | }); |
|---|
| 801 | $page->id(23); |
|---|
| 802 | $page->tags('page3'); |
|---|
| 803 | $page->save() or die "Couldn't save page record 23: ".$page->errstr; |
|---|
| 804 | |
|---|
| 805 | $folder_place = new MT::Placement; |
|---|
| 806 | $folder_place->entry_id(23); |
|---|
| 807 | $folder_place->blog_id(1); |
|---|
| 808 | $folder_place->category_id(22); |
|---|
| 809 | $folder_place->is_primary(1); |
|---|
| 810 | $folder_place->save |
|---|
| 811 | or die "Couldn't save placement record: ".$folder_place->errstr; |
|---|
| 812 | |
|---|
| 813 | unless (MT::Comment->count({entry_id => $page->id})) { |
|---|
| 814 | my $page_cmt = new MT::Comment(); |
|---|
| 815 | $page_cmt->set_values({ |
|---|
| 816 | text => "Your time is limited, so don't waste it living someone else's life. Don't be trapped by dogma - which is living with the results of other people's thinking. Don't let the noise of others' opinions drown out your own inner voice. And most important, have the courage to follow your heart and intuition. They somehow already know what you truly want to become. Everything else is secondary.", |
|---|
| 817 | entry_id => 23, |
|---|
| 818 | author => 'Steve Jobs', |
|---|
| 819 | visible => 1, |
|---|
| 820 | email => 'f@example.com', |
|---|
| 821 | url => 'http://example.com/', |
|---|
| 822 | blog_id => 1, |
|---|
| 823 | ip => '127.0.0.1', |
|---|
| 824 | created_on => '20040114182800', |
|---|
| 825 | modified_on => '20040114182800', |
|---|
| 826 | }); |
|---|
| 827 | $page_cmt->id(13); |
|---|
| 828 | $page_cmt->save() or die "Couldn't save comment record 1: ".$page_cmt->errstr; |
|---|
| 829 | } |
|---|
| 830 | |
|---|
| 831 | my $page_tb = MT::Trackback->new; |
|---|
| 832 | $page_tb->entry_id($page->id); |
|---|
| 833 | $page_tb->blog_id(1); |
|---|
| 834 | $page_tb->title("Page TrackBack Title"); |
|---|
| 835 | $page_tb->description("Page TrackBack Description"); |
|---|
| 836 | $page_tb->category_id(0); |
|---|
| 837 | $page_tb->id(3); |
|---|
| 838 | $page_tb->save or die "Couldn't save Trackback record 1: " . $tb->errstr;; |
|---|
| 839 | |
|---|
| 840 | my $page_ping = MT::TBPing->new; |
|---|
| 841 | $page_ping->tb_id($page_tb->id); |
|---|
| 842 | $page_ping->blog_id(1); |
|---|
| 843 | $page_ping->ip('127.0.0.1'); |
|---|
| 844 | $page_ping->title('Trackbacking to a page'); |
|---|
| 845 | $page_ping->excerpt('Four bridges in the bayarea. Golden Gate, Bay, San Mateo and Dan Burton.'); |
|---|
| 846 | $page_ping->source_url('http://example.com/'); |
|---|
| 847 | $page_ping->blog_name("Example Blog"); |
|---|
| 848 | $page_ping->created_on('20040101000000'); |
|---|
| 849 | $page_ping->modified_on('20040101000000'); |
|---|
| 850 | $page_ping->visible(1); |
|---|
| 851 | $page_ping->id(3); |
|---|
| 852 | $page_ping->save or die "Couldn't save TBPing record 1: " . $ping->errstr; |
|---|
| 853 | |
|---|
| 854 | MT->instance->rebuild( |
|---|
| 855 | BlogId => 1, |
|---|
| 856 | EntryCallback => sub { print STDERR "# Rebuilding entry " . $_[0]->id . "\n" } |
|---|
| 857 | ); |
|---|
| 858 | |
|---|
| 859 | ### Make ObjectAsset mappings |
|---|
| 860 | require MT::ObjectAsset; |
|---|
| 861 | my $map; |
|---|
| 862 | $entry = MT::Entry->load(1); |
|---|
| 863 | if ($entry) { |
|---|
| 864 | $map = new MT::ObjectAsset; |
|---|
| 865 | $map->blog_id($entry->blog_id); |
|---|
| 866 | $map->asset_id(1); |
|---|
| 867 | $map->object_ds($entry->datasource); |
|---|
| 868 | $map->object_id($entry->id); |
|---|
| 869 | $map->save; |
|---|
| 870 | } |
|---|
| 871 | $page = MT::Page->load(20); |
|---|
| 872 | if ($entry) { |
|---|
| 873 | $map = new MT::ObjectAsset; |
|---|
| 874 | $map->blog_id($page->blog_id); |
|---|
| 875 | $map->asset_id(2); |
|---|
| 876 | $map->object_ds($page->datasource); |
|---|
| 877 | $map->object_id($page->id); |
|---|
| 878 | $map->save; |
|---|
| 879 | } |
|---|
| 880 | |
|---|
| 881 | 1; |
|---|
| 882 | } |
|---|
| 883 | |
|---|
| 884 | 1; |
|---|