function parse() { require_once PATH_CORE . '/classes/remotefile.class.php'; $rfObj = new remotePageProperty($this->url); $data = array(); $data['title'] = $this->cleanTitle($rfObj->getPageTitle()); $page = $rfObj->page_content; // to do - grab description from meta tag or story content if (preg_match('/<meta name="description"[^>]*content="([^"]+)"/i', $page, $match)) { $data['description'] = $match[1]; } else { $temp = $rfObj->getPageParagraphs(); require_once PATH_CORE . '/classes/utilities.class.php'; $utilObj = new utilities(); $temp = $utilObj->shorten($temp, LENGTH_LONG_CAPTION); $data['description'] = $temp; //$this->log('Caption from gPP: '.$temp); } $data['images'] = $this->parseImages($rfObj); // to do - grab content // to do - use my code to grab keywords using semantic library return $this->jsonData($data); }
function buildPostStoryForm($fData = NULL) { if (is_null($fData)) { // initialize form data $fData = new stdClass(); $fData->state = 'new'; $fData->body = ''; $fData->tags = ''; $fData->imageUrl = ''; $fData->videoEmbed = ''; $fData->mediatype = 'text'; if (isset($_GET['u'])) { $fData->isBookmarklet = true; $fData->url = urldecode($_GET['u']); require_once PATH_CORE . '/classes/parseStory.class.php'; $psObj = new parseStory($fData->url); if (isset($_GET['t'])) { $title = strip_tags(stripslashes(urldecode($_GET['t']))); $fData->title = $psObj->cleanTitle($title); } else { $fData->title = ''; } if (isset($_GET['c']) and $_GET['c'] != '') { $fData->caption = strip_tags(stripslashes(urldecode($_GET['c']))); } else { require_once PATH_CORE . '/classes/remotefile.class.php'; $rfObj = new remotePageProperty($psObj->url); $temp = $rfObj->getPageParagraphs(); if (strlen($temp) > LENGTH_LONG_CAPTION) { require_once PATH_CORE . '/classes/utilities.class.php'; $utilObj = new utilities($this->db); $temp = $utilObj->shorten($temp, LENGTH_LONG_CAPTION); } $fData->caption = $temp; //$psObj->log('Caption from gPP: '.$temp); } } else { $fData->isBookmarklet = false; $fData->url = ''; $fData->title = ''; $fData->caption = ''; } $fData->isFeatureCandidate = 0; $fData->showPreview = false; $fData->alert = ''; $this->fData =& $fData; } else { // on submit, remove second column $this->postTip = false; } // bookmarklet javascript has to be embedded in an iframe // bookmarklet code is in templates directory for now // to do: allow user to hide this in the future $code .= $this->buildScriptInclude('top'); // not embed style below is req to override fb editor style $code .= '<h1>Submit a story from another news site</h1><h5>Add links to ' . strtolower(SITE_TOPIC) . ' related stories you\'ve found from around the Web</h5>'; $code .= '<fb:editor action="?p=postStory&o=link&submit' . ($fData->isBookmarklet ? '&popup' : '') . '" labelwidth="100"> <fb:editor-custom label="Story Web Address (required)"><input style="width:80%;" type="text" name="url" id="url" value="' . $this->fData->url . '"> <a href="#" onclick="loadStoryData();return false;">refresh</a></fb:editor-custom>' . '<fb:editor-text label="Story Headline (required)" name="title" id="title" value="' . stripslashes(htmlentities(strip_tags($this->fData->title), ENT_QUOTES)) . '"/> <fb:editor-custom label="Summary (required)"><textarea rows="7" name="caption" id="caption">' . $this->fData->caption . '</textarea></fb:editor-custom>'; $code .= '<fb:editor-custom><p><strong>Optional elements</strong></p></fb:editor-custom><fb:editor-divider />' . '<fb:editor-text label="Photo Web Address" id="imageUrl" name="imageUrl" value=""/>'; $code .= $this->buildImageSelector(); $code .= '<fb:editor-custom label="Video"><h3>Please paste the URL or embed code for a Facebook or YouTube Video. No other services are currently supported.</h3><input type="text" name="videoEmbed" id="videoEmbed" onChange="videoURLChanged();return false;" value="' . $this->fData->videoEmbed . '"><div id="videoPreview" class="hidden"><div id="videoPreviewMsg">Video Preview</div></div></fb:editor-custom>'; if ($this->session->u->isAdmin) { $code .= '<fb:editor-custom label="Feature Candidate?"><input type="checkbox" name="isFeatureCandidate" ' . ($this->fData->isFeatureCandidate == 1 ? 'CHECKED' : '') . '></fb:editor-custom>'; } else { $code .= '<input type="hidden" name="isFeatureCandidate" value="off">'; } // Button area $code .= '<fb:editor-buttonset> ' . '<fb:editor-button name="submit" value="Submit"/>'; // <fb:editor-text label="Tags" name="tags" value=""/> if (!$this->fData->isBookmarklet) { $code .= '<fb:editor-cancel href="' . URL_CANVAS . '"/>'; } else { // to do: link that javascript close window $code .= '<fb:editor-cancel value="Cancel" href="' . URL_CANVAS . '?p=home" />'; } $code .= '</fb:editor-buttonset>'; $code .= '</fb:editor>'; // Manage scripts $code .= '<script type="text/javascript">'; $code .= 'var url = document.getElementById("url");'; $code .= 'url.addEventListener("blur", loadStoryData, false);'; $code .= 'var title = document.getElementById("title");'; $code .= 'title.addEventListener("blur", updateTitle, false);'; $code .= 'var caption = document.getElementById("caption");'; $code .= 'caption.addEventListener("blur", updateCaption, false);'; if ($fData->isBookmarklet and $fData->url != '') { // fbjs onload requires array push $code .= 'var onload = [];onload.push(function() {loadStoryData();});for(var a = 0;a < onload.length;a++) {onload[a]();}'; } $code .= '</script>'; return $code; }
<?php // verify email address setupAppFramework(); if (isset($_GET['test'])) { require_once PATH_CORE . '/classes/remotefile.class.php'; $rfObj = new remotePageProperty($_GET['url']); echo $rfObj->getPageTitle(); $matches = $rfObj->getPageParagraphs(); print_r($matches); require_once PATH_CORE . '/utilities/calais/opencalais.php'; $oc = new OpenCalais($init['calais']); $entities = $oc->getEntities($matches); foreach ($entities as $idea) { echo $idea . "<br />"; } exit; foreach ($entities as $type => $values) { echo "<b>" . $type . "</b>"; echo "<ul>"; foreach ($values as $entity) { echo "<li>" . $entity . "</li>"; } echo "</ul>"; } exit; } if (!isset($_GET['e']) and !isset($_GET['a'])) { $result = false; $app->facebook->redirect(URL_CANVAS . '?p=home&msgType=error&&msg=' . urlencode('There was a problem with your request.')); } else {