function createTempContent($userinfo = NULL, $wireid = 0) { require_once PATH_CORE . '/classes/content.class.php'; $cObj = new content($this->db); $info = $this->getWireStory($wireid); require_once PATH_CORE . '/classes/parseStory.class.php'; $psObj = new parseStory(); require_once PATH_CORE . '/classes/utilities.class.php'; $this->utilObj = new utilities($this->db); $info->title = stripslashes($info->title); $info->caption = stripslashes($this->utilObj->shorten($info->caption)); // to do - replace proxy feed urls with final redirect $info->title = $psObj->cleanTitle($info->title); // create permalink $info->permalink = $cObj->buildPermalink($info->title); // serialize the content $info->title = mysql_real_escape_string($info->title); $info->caption = mysql_real_escape_string($info->caption); $story = $cObj->serialize(0, $info->title, $info->caption, $info->source, $info->url, $info->permalink, $userinfo->ncUid, $userinfo->name, $userinfo->userid, '', $userinfo->votePower, 0, 0); // post wire story to content $siteContentId = $cObj->add($story); return $siteContentId; }
function loadStory($wire = null, $feed = null) { $this->db->log('entering loadStory '); $this->db->log($wire); // post a story from a feed to Content table for the user who owns the bookmark feed $this->psObj->refreshUrl($wire->url); // $id is feed id, $wire is serialized newswire object, $feed->userid is posted by userid // clean headlines $wire->title = $this->psObj->cleanTitle($wire->title); $this->db->log('clean title:' . $wire->title); // check for duplicates from final url or initial url or title $error = false; $cleanUrl = $this->psObj->cleanUrl($wire->url); $isDup = $this->db->queryC("SELECT siteContentId FROM Content WHERE url = '" . $wire->url . "' OR url = '" . $cleanUrl . "' OR title = '" . $wire->title . "'"); if ($isDup === false) { $wire->url = $cleanUrl; $this->psObj->log('Cleaned url: ' . $cleanUrl . ' <= ' . $wire->url); // load user wire record $this->db->log('not a dup'); require_once PATH_CORE . '/classes/user.class.php'; $userTable = new UserTable($this->db); $user = $userTable->getRowObject(); // to do if $feed->userid==0 use admin if ($feed->userid == 0) { $user->loadWhere("isAdmin=1"); } else { $user->load($feed->userid); } // create temporary content item, temp permalink require_once PATH_CORE . '/classes/utilities.class.php'; $utilObj = new utilities(); require_once PATH_CORE . '/classes/content.class.php'; $cObj = new content($this->db); // clean caption, strip tags, trim for length $wire->caption = $utilObj->shorten($wire->caption, LENGTH_LONG_CAPTION); $wire->source = $this->stripit(parse_url($wire->url, PHP_URL_HOST)); // create permalink $wire->permalink = $cObj->buildPermalink($wire->title); // get images, check size of each and pick most likely candidate with minimum require_once PATH_CORE . '/classes/remotefile.class.php'; $rfObj = new remotePageProperty($wire->url); $imgArr = $this->psObj->parseImages($rfObj, 7500); // 7500 is min jpg size for automatically selecting images // $this->db->log($imgArr); if (count($imgArr) > 0) { $wire->imageUrl = $imgArr[0]; } else { $wire->imageUrl = ''; } // serialize the content $isBlogEntry = 0; $story = $cObj->serialize(0, $wire->title, $wire->caption, $wire->source, $wire->url, $wire->permalink, $user->ncUid, $user->name, $user->userid, '', 1, 0, 0, $wire->imageUrl, 0, $isBlogEntry, 1); //$this->db->log($story); // add to content by this userid $siteContentId = $cObj->add($story); if ($siteContentId !== false) { require_once PATH_CORE . '/classes/log.class.php'; $this->logObj = new log($this->db); // add to user journal $logItem = $this->logObj->serialize(0, $user->userid, 'postStory', $siteContentId); $inLog = $this->logObj->update($logItem); if ($inLog) { $logItem = $this->logObj->serialize(0, $user->userid, 'vote', $siteContentId); $inLog = $this->logObj->update($logItem); } } // set new story loaded flag - so that features can be updated $this->newStoryLoaded = true; } else { $error = true; } }