Skip to content

Instantly share code, notes, and snippets.

if ( $params{categories} ) {
for my $category ( @{$params{categories}}) {
my $cat = MT::Category->load({label => $category,
blog_id => $entry_new->blog_id});
unless ($cat) {
print "Category $category not found. Creating...\n" if $self->{'verbose'};
$cat = MT::Category->new;
$cat->blog_id($entry_new->blog_id);
#!perl -w
use strict;
use warnings;
use Chart::Clicker;
use Chart::Clicker::Data::Series;
use Chart::Clicker::Data::DataSet;
#!perl -w
use strict;
use warnings;
use Template;
use Chart::Clicker;
use Chart::Clicker::Data::Series;
use Chart::Clicker::Data::DataSet;
for ( $i = 0; $i < count($verticals); $i++ )
{
$news_category_id = $verticals[$i]['vertical_news_category_id'];
$blog_category_id = $verticals[$i]['vertical_blog_category_id'];
$wires_category_id = $verticals[$i]['vertical_wires_category_id'];
if ( isset($placement[$blog_category_id]) ) {
$placement_category_id = $blog_category_id;
} elseif ( isset($placement[$news_category_id]) ) {
$placement_category_id = $news_category_id;
tick_list_from_json(Series_id, Json) ->
case probix_series:series(Series_id) of
not_found ->
{error, not_found};
_Series ->
case decode_tick_json(Series_id, Json) of
bad_json -> {error, bad_json};
List -> List
end
end.
tick_list_from_json(Series_id, Json) ->
try mochijson2:decode(Json) of
List when is_list(List) ->
[ json_struct_to_tick(Series_Id, P) || P <- List ];
Struct when is_tuple(Struct) ->
[ json_struct_to_tick(Series_Id, Struct) ]
catch
_Any ->
{error, bad_json}
end.
tick_to_json_object(Rec) when is_record(Rec, tick) ->
Keys = [ <<"timestamp">>, <<"value">> ],
{_Series_id, Timestamp} = Rec#tick.id,
Value = Rec#tick.value,
{struct, lists:zip(Keys, [Timestamp, Value])};
tick_to_json(Tick) ->
Encode = mochijson2:encoder([{utf8, true}]),
try
List = case Tick of
MT::App::CMS->add_callback('CMSPreSave_entry', 9, $plugin, sub {
my ($eh, $app, $entry) = @_;
my $q = $app->{'query'};
# Only AP entries from Wires blog here
return 1 unless $entry->blog_id == 18;
return 1 unless $entry->author->name eq 'AP';
my $extra = huff::EntryExtra->load($entry->id);
return 1 if $extra->ap_edited;
if ($_REQUEST['blog_id'] == 2 || $_REQUEST['blog_id'] == 18)
{
//checking for existing corresponding row in mt_entry_extra
if (!self::IsEntryExtraExist($_REQUEST['entry_id']))
{
self::InsertEntryExtra($_REQUEST['entry_id']);
}
// insert extra data
$affectedRows = self::$Dbh->extended->autoExecute("mt_entry_extra", $extra_values, MDB2_AUTOQUERY_UPDATE, "entry_extra_id=".self::$Dbh->quote($_REQUEST['entry_id']));
}
//checking for existing corresponding row in mt_entry_extra
if (!self::IsEntryExtraExist($_REQUEST['entry_id'])) {
self::InsertEntryExtra($_REQUEST['entry_id']);
}
if ($_REQUEST['blog_id'] == 3) {
$extra_values = array('entry_extra_show_tweets' => $extra_value['entry_extra_show_tweets'] );
}
$affectedRows = self::$Dbh->extended->autoExecute("mt_entry_extra", $extra_values, MDB2_AUTOQUERY_UPDATE, "entry_extra_id=".self::$Dbh->quote($_REQUEST['entry_id']));