コード例 #1
0
ファイル: Statistics.php プロジェクト: bwgraves/forkcms
 /**
  * Load the datagrid for statistics
  */
 private function loadStatistics()
 {
     // fetch the latest mailing
     $mailing = BackendMailmotorModel::getSentMailings(1);
     // check if a mailing was found
     if (empty($mailing)) {
         return false;
     }
     // check if a mailing was set
     if (!isset($mailing[0])) {
         return false;
     }
     // show the sent mailings block
     $this->tpl->assign('oSentMailings', true);
     // fetch the statistics for this mailing
     $stats = BackendMailmotorCMHelper::getStatistics($mailing[0]['id'], true);
     // reformat the send date
     $mailing[0]['sent'] = \SpoonDate::getDate('d-m-Y', $mailing[0]['sent']) . ' ' . BL::lbl('At') . ' ' . \SpoonDate::getDate('H:i', $mailing);
     // get results
     $results[] = array('label' => BL::lbl('MailmotorLatestMailing'), 'value' => $mailing[0]['name']);
     $results[] = array('label' => BL::lbl('MailmotorSendDate'), 'value' => $mailing[0]['sent']);
     $results[] = array('label' => BL::lbl('MailmotorSent'), 'value' => $stats['recipients'] . ' (' . $stats['recipients_percentage'] . ')');
     $results[] = array('label' => BL::lbl('MailmotorOpened'), 'value' => $stats['unique_opens'] . ' (' . $stats['unique_opens_percentage'] . ')');
     $results[] = array('label' => BL::lbl('MailmotorClicks'), 'value' => $stats['clicks_total'] . ' (' . $stats['clicks_percentage'] . ')');
     // there are some results
     if (!empty($results)) {
         // get the datagrid
         $dataGrid = new BackendDataGridArray($results);
         // no pagination
         $dataGrid->setPaging(false);
         // parse the datagrid
         $this->tpl->assign('dgMailmotorStatistics', $dataGrid->getContent());
     }
 }
コード例 #2
0
 /**
  * Formats a language specific date.
  *
  * @return	string						The formatted date according to the timestamp, format and provided language.
  * @param	mixed $timestamp			The timestamp or date that you want to apply the format to.
  * @param	string[optional] $format	The optional format that you want to apply on the provided timestamp.
  * @param	string[optional] $language	The optional language that you want this format in (Check SpoonLocale for the possible languages).
  */
 public static function date($timestamp, $format = 'Y-m-d H:i:s', $language = 'en')
 {
     if (is_string($timestamp) && !is_numeric($timestamp)) {
         // use strptime if you want to restrict the input format
         $timestamp = strtotime($timestamp);
     }
     return SpoonDate::getDate($format, $timestamp, $language);
 }
コード例 #3
0
ファイル: rss.php プロジェクト: netconstructor/forkcms
 /**
  * The default constructor
  *
  * @return	void
  * @param	string $title			The title off the feed.
  * @param	string $link			The link of the feed.
  * @param	string $description		The description of the feed.
  * @param	array[optional] $items	An array with SpoonRSSItems.
  */
 public function __construct($title, $link, $description, array $items = array())
 {
     // decode
     $title = SpoonFilter::htmlspecialcharsDecode($title);
     $description = SpoonFilter::htmlspecialcharsDecode($description);
     // call the parent
     parent::__construct($title, FrontendModel::addURLParameters($link, array('utm_source' => 'feed', 'utm_medium' => 'rss', 'utm_campaign' => SpoonFilter::urlise($title))), $description, $items);
     // set feed properties
     $this->setLanguage(FRONTEND_LANGUAGE);
     $this->setCopyright(SpoonDate::getDate('Y') . ' ' . SpoonFilter::htmlspecialcharsDecode(FrontendModel::getModuleSetting('core', 'site_title_' . FRONTEND_LANGUAGE)));
     $this->setGenerator(SITE_RSS_GENERATOR);
     $this->setImage(SITE_URL . FRONTEND_CORE_URL . '/layout/images/rss_image.png', $title, $link);
     // theme was set
     if (FrontendModel::getModuleSetting('core', 'theme', null) != null) {
         // theme name
         $theme = FrontendModel::getModuleSetting('core', 'theme', null);
         // theme rss image exists
         if (SpoonFile::exists(PATH_WWW . '/frontend/themes/' . $theme . '/core/images/rss_image.png')) {
             // set rss image
             $this->setImage(SITE_URL . '/frontend/themes/' . $theme . '/core/images/rss_image.png', $title, $link);
         }
     }
 }
コード例 #4
0
ファイル: Rss.php プロジェクト: forkcms/forkcms
 /**
  * The default constructor
  *
  * @param string $title       The title off the feed.
  * @param string $link        The link of the feed.
  * @param string $description The description of the feed.
  * @param array  $items       An array with SpoonRSSItems.
  */
 public function __construct($title, $link, $description, array $items = array())
 {
     // decode
     $title = \SpoonFilter::htmlspecialcharsDecode($title);
     $description = \SpoonFilter::htmlspecialcharsDecode($description);
     // call the parent
     parent::__construct($title, Model::addURLParameters($link, array('utm_source' => 'feed', 'utm_medium' => 'rss', 'utm_campaign' => CommonUri::getUrl($title))), $description, $items);
     $siteTitle = \SpoonFilter::htmlspecialcharsDecode(Model::get('fork.settings')->get('Core', 'site_title_' . LANGUAGE));
     // set feed properties
     $this->setLanguage(LANGUAGE);
     $this->setCopyright(\SpoonDate::getDate('Y') . ' ' . $siteTitle);
     $this->setGenerator($siteTitle);
     $this->setImage(SITE_URL . FRONTEND_CORE_URL . '/Layout/images/rss_image.png', $title, $link);
     // theme was set
     if (Model::get('fork.settings')->get('Core', 'theme', null) != null) {
         // theme name
         $theme = Model::get('fork.settings')->get('Core', 'theme', null);
         // theme rss image exists
         if (is_file(PATH_WWW . '/src/Frontend/Themes/' . $theme . '/Core/images/rss_image.png')) {
             // set rss image
             $this->setImage(SITE_URL . '/src/Frontend/Themes/' . $theme . '/Core/images/rss_image.png', $title, $link);
         }
     }
 }
コード例 #5
0
ファイル: model.php プロジェクト: naujasdizainas/forkcms
 /**
  * Fetch the list of time formats including examples of these formats.
  *
  * @return array
  */
 public static function getTimeFormats()
 {
     $possibleFormats = array();
     // loop available formats
     foreach (self::getModuleSetting('core', 'time_formats') as $format) {
         // get time based on given format
         $possibleFormats[$format] = SpoonDate::getDate($format, null, BackendAuthentication::getUser()->getSetting('interface_language'));
     }
     return $possibleFormats;
 }
コード例 #6
0
ファイル: DataGridFunctions.php プロジェクト: forkcms/forkcms
 /**
  * Get time ago as a string for use in a datagrid
  *
  * @param int $timestamp The UNIX-timestamp to convert in a time-ago-string.
  *
  * @return string
  */
 public static function getTimeAgo($timestamp)
 {
     $timestamp = (int) $timestamp;
     // get user setting for long dates
     $format = Authentication::getUser()->getSetting('datetime_format');
     // get the time ago as a string
     $timeAgo = \SpoonDate::getTimeAgo($timestamp, BackendLanguage::getInterfaceLanguage(), $format);
     return '<time data-toggle="tooltip" datetime="' . \SpoonDate::getDate('Y-m-d H:i:s', $timestamp) . '" title="' . \SpoonDate::getDate($format, $timestamp, BackendLanguage::getInterfaceLanguage()) . '">' . $timeAgo . '</time>';
 }
コード例 #7
0
 /**
  * Get time ago as a string for use in a datagrid
  *
  * @param int $timestamp The UNIX-timestamp to convert in a time-ago-string.
  * @return string
  */
 public static function getTimeAgo($timestamp)
 {
     $timestamp = (int) $timestamp;
     // get user setting for long dates
     $format = Authentication::getUser()->getSetting('datetime_format');
     // get the time ago as a string
     $timeAgo = \SpoonDate::getTimeAgo($timestamp, Language::getInterfaceLanguage(), $format);
     return '<abbr title="' . \SpoonDate::getDate($format, $timestamp, Language::getInterfaceLanguage()) . '">' . $timeAgo . '</abbr>';
 }
コード例 #8
0
        //check if the user has a fb account authenticated
        if (!$recent[$i]['fb_uid']) {
            //else, use standard fb icon
            $recent[$i]['fb_uid'] = 1;
        }
    }
    usort($recentDrinks, 'compare_time');
    $test = array();
    for ($i = 0; $i < 100; $i++) {
        if ($recentDrinks[$i] !== null) {
            $test[] = $recentDrinks[$i];
        }
    }
    $recentDrinks = $test;
    for ($i = 0; $i < sizeof($recentDrinks); $i++) {
        $recentDrinks[$i]['timestamp'] = SpoonDate::getTimeAgo(strtotime($recentDrinks[$i]['timestamp']));
        //check if the user has a fb account authenticated
        if (!$recentDrinks[$i]['fb_uid']) {
            //else, use standard fb icon
            $recentDrinks[$i]['fb_uid'] = 1;
        }
    }
    if ($recent !== null) {
        //$tpl->assign('oRecent', true);
        $tpl->assign('iRecent', $recent);
        $tpl->assign('iRecentt', $recentDrinks);
    }
    //else
    //$tpl->assign('oNoRecent', true);
    /*end code max*/
} else {
コード例 #9
0
ファイル: TemplateModifiers.php プロジェクト: forkcms/forkcms
 /**
  * Formats a timestamp as a string that indicates the time ago
  *    syntax: {{ $string|timeago }}.
  *
  * @param string $string A UNIX-timestamp that will be formatted as a time-ago-string.
  *
  * @return string
  */
 public static function timeAgo($string = null)
 {
     $string = (int) $string;
     // invalid timestamp
     if ($string == 0) {
         return '';
     }
     // return
     return '<abbr title="' . \SpoonDate::getDate(FrontendModel::get('fork.settings')->get('Core', 'date_format_long') . ', ' . FrontendModel::get('fork.settings')->get('Core', 'time_format'), $string, Locale::frontendLanguage()) . '">' . \SpoonDate::getTimeAgo($string, Locale::frontendLanguage()) . '</abbr>';
 }
コード例 #10
0
 /**
  * Format a UNIX-timestamp as a date
  * syntac: {$var|formatdate}
  *
  * @param int $var The UNIX-timestamp to format.
  * @return string
  */
 public static function formatTime($var)
 {
     // get setting
     $format = BackendAuthentication::getUser()->getSetting('time_format');
     // format the date
     return SpoonDate::getDate($format, (int) $var, BackendLanguage::getInterfaceLanguage());
 }
コード例 #11
0
ファイル: checkin.php プロジェクト: JonckheereM/Public
// set include path
ini_set("include_path", ".:../../library/");
// required classes
require_once 'spoon/spoon.php';
require_once 'publicApp/publicApp.php';
$tpl = new SpoonTemplate();
$tpl->setForceCompile(true);
$tpl->setCompileDirectory('./compiled_templates');
SpoonSession::start();
//Content layout
if (SpoonSession::exists('id') === false) {
    SpoonHTTP::redirect('index.php');
}
$latestCheckIn = CheckIn::getLatestCheckinByUserId(SpoonSession::get('id'));
$daysAgo = (SpoonDate::getDate("m.d.j") - SpoonDate::getDate("m.d.j", strtotime($latestCheckIn->timestamp))) * 100;
$timeAgo = SpoonDate::getDate("H:i:s") - SpoonDate::getDate("H:i:s", strtotime($latestCheckIn->timestamp));
//If the checkin is within 5 hours
//if($timeAgo > -6){
$tpl->assign('oCheckIn', true);
if (SpoonFilter::getGetValue('event', null, '') === 'plus') {
    $latestCheckIn->AddTab(SpoonFilter::getGetValue('drinkid', null, ''));
    SpoonHTTP::redirect('checkin.php');
} else {
    if (SpoonFilter::getGetValue('event', null, '') === 'min') {
        $latestCheckIn->DeleteTab(SpoonFilter::getGetValue('drinkid', null, ''));
        SpoonHTTP::redirect('checkin.php');
    }
}
$tpl->assign('pub_id', $latestCheckIn->pub->pub_id);
$tpl->assign('name', $latestCheckIn->pub->name);
$tpl->assign('longitude', $latestCheckIn->pub->longitude);
コード例 #12
0
ファイル: get_data.php プロジェクト: netconstructor/forkcms
 /**
  * Cleanup database
  *
  * @return	void
  */
 private function cleanupDatabase()
 {
     // cleanup pages
     BackendModel::getDB(true)->delete('analytics_pages', 'date_viewed < ?', array(SpoonDate::getDate('Y-m-d H:i:s', strtotime('-1 week'))));
 }
コード例 #13
0
ファイル: ical.php プロジェクト: sunkangtaichi/library
 /**
  * Build the SpooncalEvent Object
  *
  * @return	string
  */
 public function build()
 {
     // start
     $string = 'BEGIN:VEVENT' . "\r\n";
     // required
     // dtstrart
     if ($this->dtStamp == null) {
         $this->dtStamp = time();
     }
     $string .= 'DTSTAMP:' . SpoonDate::getDate('Ymd\\THis', $this->dtStamp, 'en', true) . "z\r\n";
     // uid
     if ($this->uid == '') {
         throw new SpoonIcalException('No UID set.');
     }
     $string .= 'UID:' . $this->uid . "\r\n";
     // if method is not set this is required
     // dtstart
     if ($this->dtStart !== null) {
         $string .= 'DTSTART:' . SpoonDate::getDate('Ymd\\THis', $this->dtStart, 'en', true) . "Z\r\n";
     }
     // optional (single)
     // class
     if ($this->class !== null) {
         $string .= 'CLASS:' . $this->class . "\r\n";
     }
     // created
     if ($this->created !== null) {
         $string .= 'CREATED:' . SpoonDate::getDate('Ymd\\THis', $this->created, 'en', true) . "Z\r\n";
     }
     // description
     if ($this->description !== '') {
         $value = trim($this->description);
         $value = str_replace(array("\n"), array("\n"), $value);
         $value = str_replace(array("\n", "\r"), '', $value);
         $string .= 'DESCRIPTION:' . $value . "\r\n";
     }
     // geo
     if (isset($this->geo['lat']) && isset($this->geo['lon'])) {
         $string .= 'GEO:' . $this->geo['lat'] . ';' . $this->geo['lon'] . "\r\n";
     }
     // last-mod
     if ($this->lastModified !== null) {
         $string .= 'LAST-MODIFIED:' . SpoonDate::getDate('Ymd\\THis', $this->lastModified, 'en', true) . "Z\r\n";
     }
     // location
     if ($this->location !== null) {
         $value = trim($this->location);
         $value = str_replace(array("\n"), array("\n"), $value);
         $value = str_replace(array("\n", "\r"), '', $value);
         $string .= 'LOCATION:' . $value . "\r\n";
     }
     // organizer
     if ($this->organizer !== null) {
         $organizer = 'ORGANIZER';
         // set optional params
         foreach ($this->organizer as $key => $value) {
             if ($key != 'email') {
                 $organizer .= ';' . $key . '=' . $value;
             }
         }
         // set email
         $organizer .= ':mailto:' . $this->organizer['email'];
         $value = trim($organizer);
         $value = str_replace(array("\n"), array("\n"), $value);
         $value = str_replace(array("\n", "\r"), '', $value);
         $string .= $value . "\r\n";
     }
     // priority
     if ($this->priority !== null) {
         $string .= 'PRIORITY:' . $this->priority . "\r\n";
     }
     // seq
     if ($this->sequence !== null) {
         $string .= 'SEQUENCE:' . $this->sequence . "\r\n";
     }
     // status
     if ($this->status !== null) {
         $value = trim($this->status);
         $string .= 'STATUS:' . $value . "\r\n";
     }
     // summary
     if ($this->summary !== null) {
         $string .= 'SUMMARY:' . $this->summary . "\r\n";
     }
     // transp
     if ($this->transp !== null) {
         $string .= 'TRANSP:' . $this->transp . "\r\n";
     }
     // url
     if ($this->url !== null) {
         $string .= 'URL:' . $this->url . "\r\n";
     }
     // recurid
     if ($this->recurId !== null) {
         $string .= 'RECURRENCE-ID:' . SpoonDate::getDate('Ymd\\THis', $this->recurId, 'en', true) . "Z\r\n";
     }
     // if dtend AND duration are set. FREAK THE F**K OUT
     if ($this->dtEnd !== null && $this->duration !== null) {
         throw new SpoonIcalException('Either Duration or DateEnd can be set. Not both');
     }
     // dtend
     if ($this->dtEnd !== null) {
         $string .= 'DTEND:' . SpoonDate::getDate('Ymd\\THis', $this->dtEnd, 'en', true) . "Z\r\n";
     }
     // duration
     if ($this->duration !== null) {
         $string .= 'DURATION:PTS' . $this->duration . "\r\n";
     }
     // rrule
     if ($this->rrule !== null) {
         $string .= 'RRULE:' . $this->rrule . "\r\n";
     }
     // multiple optional
     // attach
     if ($this->attach !== null) {
         foreach ($this->attach as $attachment) {
             $string .= 'ATTACH';
             if ($attachment['VALUE'] == 'URI') {
                 $string .= ':' . $attachment['content'] . "\r\n";
             } else {
                 if ($attachment['FMTTYPE'] !== null) {
                     $string .= ';FMTTYPE=' . $attachment['FMTTYPE'];
                 }
                 $string .= ';ENCODING=' . $attachment['ENCODING'];
                 $string .= ';VALUE=' . $attachment['BINARY'];
                 $string .= ':' . $attachment['content'];
             }
         }
     }
     // attendee
     if ($this->attendees !== null) {
         foreach ($this->attendees as $attendee) {
             $string .= 'ATTENDEE';
             if ($attendee['CN'] != null) {
                 $string .= ';CN=' . $attendee['CN'];
             }
             $string .= ':mailto:' . $attendee['email'];
         }
     }
     // categories
     if ($this->categories !== null) {
         $string .= 'CATEGORIES:' . implode(',', $this->categories) . "\r\n";
     }
     // comment
     if ($this->comments !== null) {
         foreach ($this->comments as $comment) {
             $string .= 'COMMENT:' . $comment . "\r\n";
         }
     }
     // contact
     if ($this->contacts !== null) {
         foreach ($this->contacts as $contact) {
             $string .= 'CONTACT:' . $contact . "\r\n";
         }
     }
     // exdate
     if ($this->exceptions !== null) {
         $exceptionDates = array();
         foreach ($this->exceptions as $exception) {
             $exceptionDates[] = SpoonDate::getDate('Ymd\\THis', $exception, 'en', true) . 'Z';
         }
         $string .= 'EXDATE:' . implode(',', $exceptionDates) . "\r\n";
     }
     // rstatus
     if ($this->rstatus !== null) {
         foreach ($this->rstatus as $requestStatus) {
             $string .= 'REQUEST-STATUS:' . $requestStatus['code'];
             if ($requestStatus['description'] !== null) {
                 $string .= ';' . $requestStatus['description'];
             }
             $string .= "\n";
         }
     }
     // related
     if ($this->related !== null) {
         foreach ($this->related as $relationship) {
             $string .= 'RELATED;' . $relationship['RELTYPE'] . ':' . $relationship['other'] . "\r\n";
         }
     }
     // resources
     if ($this->related !== null) {
         $string .= 'RESOURCES:' . implode(',', $this->resources) . "\r\n";
     }
     // rdate
     if ($this->rdates !== null) {
         $reccurrenceDates = array();
         foreach ($this->rdates as $rdate) {
             $reccurrenceDates[] = SpoonDate::getDate('Ymd\\THis', $rdate, 'en', true) . 'Z';
         }
         $string .= 'RDATE:' . implode(',', $reccurrenceDates) . "\r\n";
     }
     // x-prop
     if ($this->xProperties != null) {
         foreach ($this->xProperties as $key => $property) {
             $string .= $key . ':' . $property . "\r\n";
         }
     }
     // iana-prop
     if ($this->ianaProperties != null) {
         foreach ($this->ianaProperties as $key => $property) {
             $string .= $key . ':' . $property . "\r\n";
         }
     }
     // end
     $string .= 'END:VEVENT' . "\r\n";
     // return
     return $string;
 }
コード例 #14
0
ファイル: modifiers.php プロジェクト: JonckheereM/Public
 /**
  * Formats a language specific date.
  *
  * @return	string						The formatted date according to the timestamp, format and provided language.
  * @param	int $timestamp				The timestamp that you want to apply the format to.
  * @param	string[optional] $format	The optional format that you want to apply on the provided timestamp.
  * @param	string[optional] $language	The optional language that you want this format in. (Check SpoonLocale for the possible languages)
  */
 public static function date($timestamp, $format = 'Y-m-d H:i:s', $language = 'en')
 {
     return SpoonDate::getDate($format, $timestamp, $language);
 }
コード例 #15
0
 /**
  * Parse the data into the template
  */
 private function parse()
 {
     // get RSS-link
     $rssLink = FrontendModel::getModuleSetting('blog', 'feedburner_url_' . FRONTEND_LANGUAGE);
     if ($rssLink == '') {
         $rssLink = FrontendNavigation::getURLForBlock('blog', 'rss');
     }
     // add RSS-feed
     $this->header->addLink(array('rel' => 'alternate', 'type' => 'application/rss+xml', 'title' => FrontendModel::getModuleSetting('blog', 'rss_title_' . FRONTEND_LANGUAGE), 'href' => $rssLink), true);
     // add into breadcrumb
     $this->breadcrumb->addElement(SpoonFilter::ucfirst(FL::lbl('Archive')));
     $this->breadcrumb->addElement($this->year);
     if ($this->month !== null) {
         $this->breadcrumb->addElement(SpoonDate::getDate('F', $this->startDate, FRONTEND_LANGUAGE, true));
     }
     // set pageTitle
     $this->header->setPageTitle(SpoonFilter::ucfirst(FL::lbl('Archive')));
     $this->header->setPageTitle($this->year);
     if ($this->month !== null) {
         $this->header->setPageTitle(SpoonDate::getDate('F', $this->startDate, FRONTEND_LANGUAGE, true));
     }
     // assign category
     $this->tpl->assign('archive', array('start_date' => $this->startDate, 'end_date' => $this->endDate, 'year' => $this->year, 'month' => $this->month));
     // assign items
     $this->tpl->assign('items', $this->items);
     // parse the pagination
     $this->parsePagination();
 }
コード例 #16
0
ファイル: Model.php プロジェクト: Comsa-Veurne/modules
 /**
  *
  * Export users
  *
  * @param int $id
  */
 public static function exportUsers($id = 0)
 {
     if ($id > 0) {
         $users = BackendModel::getContainer()->get('database')->getRecords(self::QRY_EXPORT_USERS_IN_GROUP, array($id, 'Y'));
     } else {
         $users = BackendModel::getContainer()->get('database')->getRecords(self::QRY_EXPORT_USERS, array('Y'));
     }
     // set the filename and path
     $filename = 'addresses-mailengine' . \SpoonDate::getDate('YmdHi') . '.csv';
     $path = BACKEND_CACHE_PATH . '/mailengine/' . $filename;
     // generate the CSV and download the file
     BackendCSV::arrayToFile($path, $users, array(BL::lbl('Email'), BL::lbl('Name'), BL::lbl('Created')), null, ';', '"', true);
 }
コード例 #17
0
ファイル: Archive.php プロジェクト: bwgraves/forkcms
 /**
  * Parse the data into the template
  */
 private function parse()
 {
     // get RSS-link
     $rssTitle = $this->get('fork.settings')->get('Blog', 'rss_title_' . FRONTEND_LANGUAGE);
     $rssLink = FrontendNavigation::getURLForBlock('Blog', 'Rss');
     // add RSS-feed
     $this->header->addRssLink($rssTitle, $rssLink);
     // add into breadcrumb
     $this->breadcrumb->addElement(\SpoonFilter::ucfirst(FL::lbl('Archive')));
     $this->breadcrumb->addElement($this->year);
     if ($this->month !== null) {
         $this->breadcrumb->addElement(\SpoonDate::getDate('F', $this->startDate, FRONTEND_LANGUAGE, true));
     }
     // set pageTitle
     $this->header->setPageTitle(\SpoonFilter::ucfirst(FL::lbl('Archive')));
     $this->header->setPageTitle($this->year);
     if ($this->month !== null) {
         $this->header->setPageTitle(\SpoonDate::getDate('F', $this->startDate, FRONTEND_LANGUAGE, true));
     }
     // assign category
     $this->tpl->assign('archive', array('start_date' => $this->startDate, 'end_date' => $this->endDate, 'year' => $this->year, 'month' => $this->month));
     // assign items
     $this->tpl->assign('items', $this->items);
     // assign allowComments
     $this->tpl->assign('allowComments', $this->get('fork.settings')->get('Blog', 'allow_comments'));
     // parse the pagination
     $this->parsePagination();
 }
コード例 #18
0
ファイル: Model.php プロジェクト: newaltcoin/forkcms
 /**
  * Delete the feedback
  *
  * @param int $itemId
  */
 public static function deleteFeedback($itemId)
 {
     BackendModel::getContainer()->get('database')->update('faq_feedback', array('processed' => 'Y', 'edited_on' => \SpoonDate::getDate('Y-m-d H:i:s')), 'id = ?', (int) $itemId);
 }
コード例 #19
0
ファイル: model.php プロジェクト: naujasdizainas/forkcms
 /**
  * Exports the statistics of all mailings for a given campaign ID in CSV format. This function
  * will send headers to download the CSV and exit your script after use.
  *
  * @param int $id The ID of the campaign.
  */
 public static function exportStatisticsByCampaignID($id)
 {
     // set the filename and path
     $filename = 'statistics-' . SpoonDate::getDate('YmdHi') . '.csv';
     // fetch the addresses by group
     $records = array();
     $records[] = BackendMailmotorCMHelper::getStatisticsByCampaignID($id);
     // unset some records
     unset($records[0]['opens'], $records[0]['clicks'], $records[0]['clicks_percentage'], $records[0]['recipients_total'], $records[0]['recipients_percentage']);
     // set columns
     $columns = array();
     $columns[] = BL::msg('MailingCSVRecipients');
     $columns[] = BL::msg('MailingCSVUniqueOpens');
     $columns[] = BL::msg('MailingCSVUnsubscribes');
     $columns[] = BL::msg('MailingCSVBounces');
     $columns[] = BL::msg('MailingCSVUnopens');
     $columns[] = BL::msg('MailingCSVBouncesPercentage');
     $columns[] = BL::msg('MailingCSVUniqueOpensPercentage');
     $columns[] = BL::msg('MailingCSVUnopensPercentage');
     // set start of the CSV
     $csv = BackendCSV::arrayToString($records, $columns);
     // fetch all mailings in this campaign
     $mailings = BackendModel::getDB()->getRecords(BackendMailmotorModel::QRY_DATAGRID_BROWSE_SENT_FOR_CAMPAIGN, array('sent', $id));
     // mailings set
     if (!empty($mailings)) {
         // set mailings columns
         $mailingColumns = array();
         $mailingColumns['name'] = BL::lbl('Name');
         $mailingColumns['language'] = BL::lbl('Language');
         // add the records to the csv string
         $csv .= PHP_EOL . 'Mailings:' . PHP_EOL . BackendCSV::arrayToString($mailings, $mailingColumns, array('id', 'campaign_id', 'campaign_name', 'send_on', 'status'));
     }
     // set headers for download
     $headers = array();
     $headers[] = 'Content-type: application/octet-stream';
     $headers[] = 'Content-Disposition: attachment; filename="' . $filename . '"';
     // overwrite the headers
     SpoonHTTP::setHeaders($headers);
     // output the CSV string
     echo $csv;
     // exit here
     exit;
 }
コード例 #20
0
ファイル: model.php プロジェクト: naujasdizainas/forkcms
 /**
  * Fetch the list of time formats including examples of these formats.
  *
  * @return array
  */
 public static function getTimeFormats()
 {
     // init var
     $possibleFormats = array();
     // loop available formats
     foreach (BackendModel::getModuleSetting('users', 'time_formats') as $format) {
         $possibleFormats[$format] = SpoonDate::getDate($format, null, BackendAuthentication::getUser()->getSetting('interface_language'));
     }
     // return
     return $possibleFormats;
 }
コード例 #21
0
ファイル: email.php プロジェクト: richsage/forkcms
 /**
  * Builds the e-mail headers.
  */
 private function getHeaders()
 {
     // create boundaries
     $uniqueId = md5(uniqid(time()));
     $boundary = 'SEB1_' . $uniqueId;
     $secondBoundary = 'SEB2_' . $uniqueId;
     // if plain body is not set, we'll strip the HTML tags from the HTML body
     if (empty($this->content['plain'])) {
         $this->content['plain'] = SpoonFilter::stripHTML($this->content['html'], null, true);
     }
     // encode the content
     $this->content['html'] = $this->encodeContent($this->content['html']);
     $this->content['plain'] = $this->encodeContent($this->content['plain']);
     // build headers
     $this->addHeader('Date: ' . SpoonDate::getDate('r'));
     $this->addHeader('From: ' . $this->from['name'] . ' <' . $this->from['email'] . '>');
     // check mailmethod, some media don't need these (like mail())
     if ($this->method == 'smtp') {
         // set subject
         $this->addHeader('Subject: ' . $this->subject);
         // set general To: header. useful if you prefer to customize it
         if (!empty($this->to['name'])) {
             $this->addHeader('To: ' . $this->to['name'] . ' <' . $this->to['email'] . '>');
         } else {
             $this->addHeader('To: ' . $this->reformatRecipientString($this->recipients));
         }
     }
     // loop and add CCs to headers
     if (!empty($this->CC)) {
         $this->addHeader('cc: ' . $this->reformatRecipientString($this->CC));
     }
     // loop and add BCCs to headers
     if (!empty($this->BCC)) {
         $this->addHeader('bcc: ' . $this->reformatRecipientString($this->BCC));
     }
     // add Reply-To header to headers
     if (!empty($this->replyTo)) {
         $this->addHeader('Reply-To: ' . $this->reformatRecipientString($this->replyTo));
     }
     // if attachments are set, change the mail content type
     if (!empty($this->attachments)) {
         $this->contentType = 'multipart/mixed';
     }
     // continue the rest of the headers
     $this->addHeader('X-Priority: ' . $this->priority);
     $this->addHeader('X-Mailer: SpoonEmail (part of Spoon library - http://www.spoon-library.com)');
     $this->addHeader('MIME-Version: 1.0');
     $this->addHeader('Content-Type: ' . $this->contentType . '; charset="' . $this->charset . '"; boundary="' . $boundary . '"' . self::LF);
     $this->addHeader('Importance: normal');
     $this->addHeader('Priority: normal');
     $this->addHeader('This is a multi-part message in MIME format.' . self::LF);
     $this->addHeader('--' . $boundary);
     // attachments found
     if (!empty($this->attachments)) {
         // means we need a second boundary defined to send html/plain mails.
         $this->addHeader('Content-Type: multipart/alternative; boundary="' . $secondBoundary . '"' . self::LF);
         $this->addHeader('--' . $secondBoundary);
         $this->addHeader('Content-Type: text/plain; charset="' . $this->charset . '"');
         $this->addHeader('Content-Disposition: inline');
         $this->addHeader('Content-Transfer-Encoding: ' . $this->contentTransferEncoding . self::LF);
         $this->addHeader($this->content['plain'] . self::LF);
         $this->addHeader('--' . $secondBoundary);
         $this->addHeader('Content-Type: text/html; charset="' . $this->charset . '"');
         $this->addHeader('Content-Disposition: inline');
         $this->addHeader('Content-Transfer-Encoding: ' . $this->contentTransferEncoding . self::LF);
         $this->addHeader($this->content['html'] . self::LF);
         $this->addHeader('--' . $secondBoundary . '--');
     } else {
         // continue the rest of the headers
         $this->addHeader('Content-Type: text/plain; charset="' . $this->charset . '"');
         $this->addHeader('Content-Disposition: inline');
         $this->addHeader('Content-Transfer-Encoding: ' . $this->contentTransferEncoding . self::LF);
         $this->addHeader($this->content['plain'] . self::LF);
         $this->addHeader('--' . $boundary);
         $this->addHeader('Content-Type: text/html; charset="' . $this->charset . '"');
         $this->addHeader('Content-Disposition: inline');
         $this->addHeader('Content-Transfer-Encoding: ' . $this->contentTransferEncoding . self::LF);
         $this->addHeader($this->content['html'] . self::LF);
     }
     // attachments found
     if (!empty($this->attachments)) {
         // loop attachments
         foreach ($this->attachments as $attachment) {
             // set attachment headers
             $this->addHeader('--' . $boundary);
             $this->addHeader('Content-Type: ' . $attachment['type'] . '; name="' . $attachment['name'] . '"');
             $this->addHeader('Content-Transfer-Encoding: ' . $attachment['encoding']);
             $this->addHeader('Content-Disposition: ' . $attachment['disposition'] . '; filename="' . $attachment['name'] . '"' . self::LF);
             $this->addHeader($attachment['data'] . self::LF);
         }
     }
     // final boundary, closes the headers
     $this->headers .= '--' . $boundary . '--';
     // return headers string
     return $this->headers;
 }
コード例 #22
0
ファイル: Edit.php プロジェクト: bwgraves/forkcms
 /**
  * Load the form for step 4
  */
 private function loadFormForStep4()
 {
     // check if we have to redirect back to step 3 (HTML content is not set)
     if (empty($this->record['content_html'])) {
         $this->redirect(BackendModel::createURLForAction('Edit') . '&id=' . $this->id . '&step=3&error=complete-step-3');
     }
     // get preview URL
     $previewURL = BackendMailmotorModel::getMailingPreviewURL($this->record['id'], 'html', true);
     // check if the mailmotor is linked
     if (BackendModel::getURLForBlock($this->getModule(), 'detail') == BackendModel::getURL(404)) {
         $previewURL = false;
     }
     // parse the preview URL
     $this->tpl->assign('previewURL', $previewURL);
     // create form
     $this->frm = new BackendForm('step4');
     // subject
     $this->frm->addText('email');
     $this->frm->addDate('send_on_date', $this->record['send_on']);
     $this->frm->addTime('send_on_time', \SpoonDate::getDate('H:i', $this->record['send_on']));
     // show the form
     $this->tpl->assign('step4', true);
 }
コード例 #23
0
 /**
  * Fetch data for this form from the database and reformat to csv rows.
  */
 private function setItems()
 {
     // init header labels
     $lblSessionId = SpoonFilter::ucfirst(BL::lbl('SessionId'));
     $lblSentOn = SpoonFilter::ucfirst(BL::lbl('SentOn'));
     $this->columnHeaders = array($lblSessionId, $lblSentOn);
     // fetch query and parameters
     list($query, $parameters) = $this->buildQuery();
     // get the data
     $records = (array) BackendModel::getDB()->getRecords($query, $parameters);
     $data = array();
     // reformat data
     foreach ($records as $row) {
         // first row of a submission
         if (!isset($data[$row['data_id']])) {
             $data[$row['data_id']][$lblSessionId] = $row['session_id'];
             $data[$row['data_id']][$lblSentOn] = SpoonDate::getDate('Y-m-d H:i:s', $row['sent_on'], BackendLanguage::getWorkingLanguage());
         }
         // value is serialized
         $value = unserialize($row['value']);
         // flatten arrays
         if (is_array($value)) {
             $value = implode(', ', $value);
         }
         // group submissions
         $data[$row['data_id']][$row['label']] = SpoonFilter::htmlentitiesDecode($value, null, ENT_QUOTES);
         // add into headers if not yet added
         if (!in_array($row['label'], $this->columnHeaders)) {
             $this->columnHeaders[] = $row['label'];
         }
     }
     // reorder data so they are in the correct column
     foreach ($data as $id => $row) {
         foreach ($this->columnHeaders as $header) {
             // submission has this field so add it
             if (isset($row[$header])) {
                 $this->rows[$id][] = $row[$header];
             } else {
                 $this->rows[$id][] = '';
             }
         }
     }
     // remove the keys
     $this->rows = array_values($this->rows);
 }
コード例 #24
0
ファイル: Model.php プロジェクト: bwgraves/forkcms
 /**
  * Fetch the list of time formats including examples of these formats.
  *
  * @return array
  */
 public static function getTimeFormats()
 {
     $possibleFormats = array();
     foreach (self::get('fork.settings')->get('Core', 'time_formats') as $format) {
         $possibleFormats[$format] = \SpoonDate::getDate($format, null, Authentication::getUser()->getSetting('interface_language'));
     }
     return $possibleFormats;
 }
コード例 #25
0
 public function testGetDate()
 {
     $this->assertEquals(date('Y-m-d H:i'), SpoonDate::getDate('Y-m-d H:i'));
     $this->assertEquals(SpoonDate::getDate('l j F Y', mktime(13, 20, 0, 8, 3, 1983)), 'Wednesday 3 August 1983');
 }
コード例 #26
0
ファイル: template.php プロジェクト: naujasdizainas/forkcms
 /**
  * Formats a timestamp as a string that indicates the time ago
  * 	syntax: {$var|timeago}
  *
  * @param string[optional] $var A UNIX-timestamp that will be formated as a time-ago-string.
  * @return string
  */
 public static function timeAgo($var = null)
 {
     $var = (int) $var;
     // invalid timestamp
     if ($var == 0) {
         return '';
     }
     // return
     return '<abbr title="' . SpoonDate::getDate(FrontendModel::getModuleSetting('core', 'date_format_long') . ', ' . FrontendModel::getModuleSetting('core', 'time_format'), $var, FRONTEND_LANGUAGE) . '">' . SpoonDate::getTimeAgo($var, FRONTEND_LANGUAGE) . '</abbr>';
 }
コード例 #27
0
ファイル: model.php プロジェクト: netconstructor/forkcms
 /**
  * Updates the date viewed for a certain page.
  *
  * @return	void
  * @param	int $pageId		The id of the page to update.
  */
 public static function updatePageDateViewed($pageId)
 {
     // update the page
     BackendModel::getDB(true)->update('analytics_pages', array('date_viewed' => SpoonDate::getDate('Y-m-d H:i:s')), 'id = ?', array((int) $pageId));
 }
コード例 #28
0
 /**
  * Formats a timestamp as a string that indicates the time ago
  *    syntax: {$var|timeago}
  *
  * @param string $var A UNIX-timestamp that will be formatted as a time-ago-string.
  * @return string
  */
 public static function timeAgo($var = null)
 {
     $var = (int) $var;
     // invalid timestamp
     if ($var == 0) {
         return '';
     }
     // return
     return '<abbr title="' . \SpoonDate::getDate(Model::get('fork.settings')->get('Core', 'date_format_long') . ', ' . Model::get('fork.settings')->get('Core', 'time_format'), $var, FRONTEND_LANGUAGE) . '">' . \SpoonDate::getTimeAgo($var, FRONTEND_LANGUAGE) . '</abbr>';
 }