コード例 #1
0
ファイル: detail.php プロジェクト: roycefu/MIT-Mobile-Web
<?php
$docRoot = getenv("DOCUMENT_ROOT");

require_once $docRoot . "/mobi-config/mobi_web_constants.php";
require_once WEBROOT . "page_builder/page_header.php";
require_once WEBROOT . "page_builder/page_tools.php";

require_once LIBDIR . "NewsOffice.php";
require_once "story_request_lib.php";

$story = getStoryFromRequest();
$story_html = new HTMLFragment($story['body']);
$pages = $story_html->pages();
$page_count = sizeof($pages);
$current_page = isset($_REQUEST['page']) ? intval($_REQUEST['page']) : 0;
$page_html = $pages[$current_page];
$page_content = $page_html->getBody();

$previous_page = ($current_page != 0) ? $current_page-1 : NULL;
$next_page = ($current_page+1 != $page_count) ? $current_page+1 : NULL;

$email_query = "mailto:?subject=" . rawurlencode($story['title']);
$email_query .= "&body=" . rawurlencode($story['description'] . "\n\n" . NewsOffice::story_link($story['story_id']));

if(isset($story['main_image']) && $story['main_image']) {
  $main_image = $story['main_image'];
  $total_photos = sizeof($story['images']) + 1;
}

if($total_photos == 1) {
  $see_instructions = "See 1 photo";
コード例 #2
0
ファイル: page_tools.php プロジェクト: roycefu/MIT-Mobile-Web
  public function trim() {
    $new = new HTMLFragment($this->getBody());
    $body = $new->bodyElement();    

    // trim beginning
    while($body->firstChild && self::is_white_space($body->firstChild)) {
      $body->removeChild($body->firstChild);
    }
    if($body->firstChild && $body->firstChild->nodeName == '#text') {
      $body->firstChild->nodeValue = ltrim($body->firstChild->nodeValue);
    }

    // trim end
    while($body->lastChild && self::is_white_space($body->lastChild)) {
      $body->removeChild($body->lastChild);
    }
    if($body->lastChild && $body->lastChild->nodeName == '#text') {
      $body->lastChild->nodeValue = rtrim($body->lastChild->nodeValue);
    }

    // only return pages with non empty text
    if(trim($new->getBody())) {
      return $new;
    }
  }