function run()
 {
     echo '<div id="kalturaUploadModule">' . "\n";
     if (!empty($this->request['thanks']) && 1 == $this->request['thanks']) {
         echo $this->_get_thanks_message();
     } elseif (!empty($this->params['close_datetime']) && datetime_to_unix($this->params['close_datetime']) < time()) {
         echo $this->_get_closed_message();
     } else {
         $d = $this->_get_form();
         $d->run();
     }
     echo '</div>' . "\n";
 }
 function run()
 {
     echo '<div id="mediaUploadModule">' . "\n";
     if ($this->params['require_login'] && !reason_check_authentication()) {
         echo '<p>You must be logged in to view this form.</p>' . "\n";
     } else {
         if (!empty($this->request['thanks']) && 1 == $this->request['thanks']) {
             echo $this->_get_thanks_message();
         } elseif (!empty($this->params['close_datetime']) && datetime_to_unix($this->params['close_datetime']) < time()) {
             echo $this->_get_closed_message();
         } else {
             if ($this->_integration_library) {
                 $d = $this->_get_form();
                 $d->run();
             } else {
                 echo '<p>Sorry, the upload form cannot be displayed.</p>' . "\n";
             }
         }
     }
     echo '</div>' . "\n";
 }
 /**
  * Build the items and augment them into shape for the feed - here is a rough description of how we do this - it is not pretty
  *
  * - Grab all the pages that use the publication module and have a page_to_publication relationship (with the publication id)
  * - Consider each publication id on each page
  * - If the publication is issued, grab all news items along with relationships to published issues (handled in helper)
  * - If the publication is not issued, grab all published news items (handled in helper)
  * - Merge news items from each publication into a master array - build index of date_created
  * - If there are news items in multiple places on the site, prefer the one that appears on the page deepest in the site
  * - Create array from master array that consists of the correct number of most recent items
  * - Loop through the items and augment with URLs and any other needed info that is not already present
  *
  * @todo consider alternative constructions to select all at once (performance enhancement)
  * @return array augmented news item entities
  * @access private;
  */
 function &_build_items()
 {
     // grab all site publications
     $pages =& $this->_get_site_pages_with_valid_publications();
     foreach ($pages as $k => $v) {
         $page_to_pub_ids[$k] = $v->get_value('pub_id');
     }
     if (isset($page_to_pub_ids)) {
         foreach ($page_to_pub_ids as $page_id => $pub_id) {
             $ph[$pub_id] = new publicationHelper($pub_id);
             $pub_items =& $ph[$pub_id]->get_published_items();
             foreach ($pub_items as $k => $v) {
                 // if this item is already in the raw_items array, check to see if the URL of the publication page
                 // is shorter than what already is there. If so, continue to the next item.
                 if (isset($raw_items[$k])) {
                     if ($raw_items[$k]->has_value('url') == false) {
                         $page =& $pages[$raw_items[$k]->get_value('page_id')];
                         $raw_items[$k]->set_value('url', $this->get_item_url($k, $page));
                     }
                     $current_url = $raw_items[$k]->get_value('url');
                     $pub_item_url = $this->get_item_url($k, $pages[$page_id]);
                     if (strlen($pub_item_url) < strlen($current_url)) {
                         continue;
                     } else {
                         $pub_items[$k]->set_value('url', $pub_item_url);
                     }
                 }
                 $pub_items[$k]->set_value('pub_id', $pub_id);
                 $pub_items[$k]->set_value('page_id', $page_id);
                 $date = $v->get_value('datetime');
                 $date_index[datetime_to_unix($date)] = $k;
                 $raw_items[$k] =& $pub_items[$k];
             }
         }
         if ($raw_items) {
             krsort($date_index);
             $item_keys = isset($this->num_to_display) ? array_slice($date_index, 0, $this->num_to_display) : $date_index;
             foreach ($item_keys as $key) {
                 $items[$key] =& $raw_items[$key];
                 $pub_id = $items[$key]->get_value('pub_id');
                 $page_id = $items[$key]->get_value('page_id');
                 $this->augment_item($items[$key], $pages[$page_id], $ph[$pub_id]);
                 // pass a reference to the item, its page, and its publication helper
             }
         }
     } else {
         $items = false;
     }
     $this->set_items($items);
     $this->_set_item_cache($items);
     return $items;
 }
示例#4
0
/**
 * This function attempts to get a UNIX timestamp by testing
 * the date given through a number of known date types.
 * if the date is not in one of these types, it will simply
 * return false.
 * NOTE: This function may now return 64-bit timestamps, 
 * so its output should be passed to carl_date() or a similar 
 * 64-bit compatible function.
 * @param mixed $value the date string or integer to be converted into timestamp
 * @return $timestamp
 */
function get_unix_timestamp($value)
{
    // in php5 the string 0000-00-00 00:00:00 returns a timestamp - in php4 it does not ... accordingly we do this:
    if ($value === '0000-00-00 00:00:00') {
        return false;
    }
    $format = get_date_format($value);
    if ($format == 'mysql_datetime') {
        $value = datetime_to_unix($value, false);
    } elseif ($format == 'mysql_timestamp') {
        $value = timestamp_to_unix($value);
    } elseif ($format == 'exif_datetime') {
        $value = exif_datetime_to_unix($value);
    } elseif ($format == 'mysql_date') {
        $value = mysql_date_to_unix($value);
    } elseif ($format == 'unix_timestamp') {
        $value = $value;
    } else {
        if (!empty($format)) {
            trigger_error('get_date_format() returned unknown string: ' . $format);
        }
        $value = false;
    }
    // mktime can return funky results if it is given a bad date.
    // generally, -1 is returned for a bad date.
    if ($value == -1) {
        return false;
    } else {
        return $value;
    }
}
        }
        break;
    case 'modify':
        $event_owner = $user_name;
        $event_name = NULL;
        $event_time = NULL;
        $event_rsvp_time = NULL;
        $event_note = NULL;
        if (preg_match('/^modify ([\\d\\w]+) ([\\d]{4}-[\\d]{2}-[\\d]{2} [\\d]{2}:[\\d]{2}) ([\\d]{4}-[\\d]{2}-[\\d]{2} [\\d]{2}:[\\d]{2}) (.*)$/i', $text, $matches)) {
            $event_name = $matches[1];
            $event_time = $matches[2];
            $event_rsvp_time = $matches[3];
            $event_note = $matches[4];
        } else {
            if (preg_match('/^create ([\\d\\w]+) ([\\d]{4}-[\\d]{2}-[\\d]{2} [\\d]{2}:[\\d]{2}) ([\\d]{4}-[\\d]{2}-[\\d]{2} [\\d]{2}:[\\d]{2})$/i', $text, $matches)) {
                $event_name = $matches[1];
                $event_time = $matches[2];
                $event_rsvp_time = $matches[3];
            } else {
                if (preg_match('/^create ([\\d\\w]+) ([\\d]{4}-[\\d]{2}-[\\d]{2} [\\d]{2}:[\\d]{2})$/i', $text, $matches)) {
                    $event_name = $matches[1];
                    $event_time = $matches[2];
                } else {
                    echo "Nothing to change!";
                }
            }
        }
        dbModifyEvent($db, $event_name, $event_owner, datetime_to_unix($event_time), datetime_to_unix($event_rsvp_time), $event_note);
        break;
}
// /feedme create CCC 2015-12-17 19:00 2015-12-16 16:00