public function run($request) { // output echo "<br />\n<br />\nPurging...<br />\n<br />\n"; flush(); ob_flush(); foreach (FBUpdate::get() as $page) { echo "Deleting " . $page->Title . "\n"; $page->delete(); } foreach (Versioned::get_by_stage('FBUpdate', 'Stage') as $page) { echo "Deleting From Stage: " . $page->Title . "\n"; $page->deleteFromStage('Stage'); } foreach (Versioned::get_by_stage('FBUpdate', 'Live') as $page) { echo "Deleting From Live: " . $page->Title . "\n"; $page->deleteFromStage('Live'); } }
public function run($request) { // eol $eol = php_sapi_name() == 'cli' ? "\n" : "<br>\n"; // output echo $eol . $eol . 'Purging...' . $eol . $eol; flush(); @ob_flush(); foreach (FBUpdate::get() as $page) { echo "Deleting " . $page->Title . $eol; $page->delete(); } foreach (Versioned::get_by_stage('FBUpdate', 'Stage') as $page) { echo "Deleting From Stage: " . $page->Title . $eol; $page->deleteFromStage('Stage'); } foreach (Versioned::get_by_stage('FBUpdate', 'Live') as $page) { echo "Deleting From Live: " . $page->Title . $eol; $page->deleteFromStage('Live'); } }
function run($request) { // eol $eol = php_sapi_name() == 'cli' ? "\n" : "<br>\n"; // output echo $eol . $eol . 'Syncing' . $eol . $eol; flush(); @@ob_flush(); if (!$this->conf->FacebookPullUpdates) { echo 'Sync disabled' . $eol . $eol; return; } // find any updates that are less than a week old with no image $updates = FBUpdate::get()->where(' UNIX_TIMESTAMP(OriginalCreated) > ' . (time() - 60 * 60 * 24 * 14) . ' AND (Page.PrimaryImageID IS NULL OR Page.PrimaryImageID = \'\' OR Page.PrimaryImageID = 0) '); // helpful output echo 'Processing ' . $updates->count() . ' updates...' . $eol . $eol; // loop the loop foreach ($updates as $update) { $update->updateFromUpdate((object) json_decode($update->OriginalUpdate)); } }
<?php // Define path constant $path = str_replace('\\', '/', __DIR__); $path_fragments = explode('/', $path); $dir_name = $path_fragments[count($path_fragments) - 1]; define('ABC_SOCIAL_DIR', $dir_name); // attach the social extensions to the config and page classes SiteConfig::add_extension('SocialMediaConfig'); Page::add_extension('SocialMediaPageExtension'); // attach common behaviours to the social updates FBUpdate::add_extension('SocialUpdatePageExtension'); Tweet::add_extension('SocialUpdatePageExtension'); InstagramUpdate::add_extension('SocialUpdatePageExtension'); // add the embed functionality if (!Config::inst()->get('SocialGlobalConf', 'disable_wysiwyg_embed')) { ShortcodeParser::get('default')->register('social_embed', array('SocialMediaPageExtension', 'SocialEmbedParser')); HtmlEditorConfig::get('cms')->enablePlugins(array('social_embed' => '../../../' . ABC_SOCIAL_DIR . '/js/editor-plugin.js')); HtmlEditorConfig::get('cms')->addButtonsToLine(2, 'social_embed'); } // allow script tags // maybe we could try using requirements and stripping the script tags // HtmlEditorConfig::get('cms') // ->setOption( // 'extended_valid_elements', // 'img[class|src|alt|title|hspace|vspace|width|height|align|onmouseover|onmouseout|name|usemap|data*],' . // 'iframe[src|name|width|height|align|frameborder|marginwidth|marginheight|scrolling],' . // 'object[width|height|data|type],' . // 'param[name|value],' . // 'map[class|name|id],' . // 'area[shape|coords|href|target|alt],ol[class|start],' .
public function processResponse(array $resp) { $noNew = true; foreach ($resp as $data) { // type cast $data = (object) $data; if (!($savedUpdate = DataObject::get_one('FBUpdate', "UpdateID='" . $data->id . "'"))) { if (!($pubUpdate = DataObject::get_one('PublicationFBUpdate', "FBUpdateID='" . $data->id . "'"))) { // push output echo "Adding Update " . $data->id . "<br />\n"; flush(); ob_flush(); // get extended info // $res = (object) $this->facebook->sendRequest('get', '/' . $data->id)->getDecodedBody(); // die(print_r($res,1)); // create the tweet data object $update = new FBUpdate(); if ($update->updateFromUpdate($data)) { $update->write(); if (!$update->doPublish()) { echo 'Failed to Publish ' . $update->Title . "\n"; } } // set no new flag $noNew = false; } else { // push output echo "Update " . $data->id . " came from the website<br />\n"; flush(); ob_flush(); } } else { // this should only happen during initial population because we should have only got in tweets that are newer than x // push output echo "Already added Update " . $data->id . "<br />\n"; flush(); ob_flush(); } } return $noNew; }