当前位置: 首页>>代码示例>>PHP>>正文


PHP DataModel::getSites方法代码示例

本文整理汇总了PHP中DataModel::getSites方法的典型用法代码示例。如果您正苦于以下问题:PHP DataModel::getSites方法的具体用法?PHP DataModel::getSites怎么用?PHP DataModel::getSites使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DataModel的用法示例。


在下文中一共展示了DataModel::getSites方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: showAll

 function showAll()
 {
     $idSite = getRequestVar('site', -1, 'int');
     if ($idSite == -1) {
         $allSiteArchive = DataModel::getSites();
     } else {
         $allSiteArchive[] = new Site($idSite);
     }
     $uniqCacheId = DataModel::getSitesSignature() . date("Y-m-d") . serialize($_GET) . '.rss';
     // Set a few options
     $options = array('cacheDir' => DIR_CACHE_RSS, 'lifeTime' => CACHE_RSS_LIFETIME);
     // Create a Cache_Lite object
     $Cache_Lite = new Cache_Lite($options);
     if (time() % 500 === 0) {
         $Cache_Lite->clean();
     }
     // Test if thereis a valide cache for this id
     if (SMARTY_DEBUG || !($allData = $Cache_Lite->get($uniqCacheId))) {
         $dataTmp = $this->data;
         $o_config =& PmvConfig::getInstance();
         $allItems = array();
         foreach ($allSiteArchive as $id => $infoSite) {
             $allArchives = $dataTmp->getLastArchives(NB_DAYS_FOR_RSS_ITEMS, 0, DATE_NORMAL, $infoSite);
             $i = 0;
             foreach ($allArchives as $date => $o_archive) {
                 //var_dump($date);
                 $this->request->setDate($o_archive->date->get());
                 $this->request->setModuleName('view_visits_rss');
                 $o_mod = new ViewVisitsRss($infoSite);
                 $o_mod->init($this->request, $this->tpl, $o_archive);
                 //var_dump($o_mod->data->archive->date->get());
                 $rssContent = $o_mod->showAll(true);
                 $dateRss = date("r", time() - 100 * $i++ - 10 * $id);
                 $item['pubDate'] = $dateRss;
                 $url = PHPMV_URL . "/?site=" . $infoSite->getId() . "&mod=view_visits&date=" . $o_archive->date->get();
                 $item['guid'] = $url;
                 //"http://www.phpmyvisites.us/".md5($dateRss);
                 $item['link'] = $url;
                 $item['title'] = vsprintf($GLOBALS['lang']['rss_titre'], array($infoSite->getName(), $date));
                 $rssContent = $item['title'] . $rssContent;
                 $item['author'] = "phpmyvisites@gmail.com (phpMyVisites)";
                 $item['date_ts'] = time() - 10 * $id;
                 $item['description'] = $rssContent;
                 $item['date_ts'] = $o_archive->date->getTimestamp();
                 $allItems[] = $item;
                 $urls[] = $url;
             }
         }
         $GLOBALS['sorting_index'] = 'date_ts';
         uasort($allItems, "sortingDataInfo");
         $channel['title'] = "phpMyVisites stats by RSS";
         $channel['link'] = "http://www.phpmyvisites.us";
         $channel['description'] = "Enjoy phpmyvisites power ! :)";
         $channel['pubDate'] = date("r");
         $channel['generator'] = "phpMyVisites";
         $channel['language'] = $GLOBALS['lang']['lang_iso'];
         $channel['lastBuildDate'] = date("r");
         foreach ($allItems as $chan) {
             unset($chan['date_ts']);
             $channel[] = $chan;
         }
         $rss = array('channel' => $channel);
         // An array of serializer options
         $serializer_options = array('addDecl' => TRUE, 'encoding' => 'UTF-8', 'indent' => '  ', 'rootName' => 'rss', 'defaultTagName' => 'item', 'rootAttributes' => array('version' => '2.0'));
         $Serializer =& new XML_Serializer($serializer_options);
         // Serialize the data structure
         $Serializer->setOption("keyAttribute", "rdf:about");
         $status = $Serializer->serialize($rss);
         $allData = $Serializer->getSerializedData();
         $Cache_Lite->save($allData);
     }
     $this->displayRss($allData);
 }
开发者ID:ber5ien,项目名称:www.jade-palace.co.uk,代码行数:73,代码来源:ViewRss.class.php

示例2: showAll

    function showAll()
    {
        $this->tpl->setMainTemplate("structure_mail.tpl");
        $this->request->setModuleName('view_visits_rss');
        $allSiteArchive = DataModel::getSites();
        /**
         * Cache Lite
         */
        $options = array('cacheDir' => DIR_CACHE_MAIL, 'lifeTime' => CACHE_MAIL_LIFETIME);
        $Cache_Lite = new Cache_Lite($options);
        $lang =& Lang::getInstance();
        // case update to 2.2RC1 without executing global info
        if (!defined('INTERFACE_DEFAULT_LANG')) {
            define('INTERFACE_DEFAULT_LANG', 'en-utf-8.php');
        }
        $lang->setNewLang(INTERFACE_DEFAULT_LANG);
        /**
         * Compute mails
         */
        $o_config =& PmvConfig::getInstance();
        foreach ($allSiteArchive as $infoSite) {
            /**
             * php Mailer
             */
            $mail = new MyMailer();
            $mail->IsHTML(true);
            $imgUrl = INCLUDE_PATH . "/themes/default/images/phpmv.png";
            $mail->AddEmbeddedImage($imgUrl, "my-attach", $GLOBALS['lang']['logo_description'], "base64", "image/png");
            $uniqCacheId = md5(serialize($infoSite) . date("Y-m-d")) . '.mail';
            // Test if thereis a valide cache for this id
            if (true) {
                $o_mod = new ViewVisitsRss($infoSite);
                $this->request->date = getDateFromTimestamp(time() - 86400);
                $o_mod->init($this->request);
                $dateLiteral = $o_mod->data->archive->getLiteralDate();
                $body = '<html xml:lang="fr" >
						<head>
							<meta http-equiv="content-type" content="text/html; charset=utf-8" />
						</head>
						
						<body>
						';
                $body .= $o_mod->showAll(true, true);
                $body .= '</body></html>';
                $textBody = strip_tags($body);
                $subject = vsprintf($GLOBALS['lang']['rss_titre'], array($infoSite->getName(), $dateLiteral));
                print "<br>Subject : {$subject}<hr>";
                print "<br>Content : {$body}<hr>";
                //$Cache_Lite->save($body);
            }
            $mail->Subject = $subject;
            $mail->Body = $body;
            $mail->AltBody = $textBody;
            $mail->CharSet = $GLOBALS['lang']['charset'];
            $user = new UserConfigDb();
            $groups = $user->getGroups();
            $users = array_merge(array(0 => array('email' => SU_EMAIL, 'alias' => 'phpMyVisites Administrator', 'send_mail' => SEND_MAIL == "yes" ? 1 : 0)), $user->getUserByGroup(1, $infoSite->getId()), $user->getUserByGroup(2, $infoSite->getId()));
            // we send all emails once
            $emailsToSend_infos = array('object' => $mail, 'to' => array());
            // add recipients for the mail
            foreach ($users as $userInfo) {
                //print_r($userInfo);
                if (!empty($userInfo['email']) && $userInfo['send_mail'] == 1) {
                    $emailsToSend_infos['to'][] = array($userInfo['email'], $userInfo['alias']);
                }
            }
            $emailsToSend[] = $emailsToSend_infos;
        }
        // send all emails
        foreach ($emailsToSend as $currMail) {
            $mail =& $currMail['object'];
            foreach ($currMail['to'] as $recipient) {
                $mail->AddAddress($recipient[0], $recipient[1]);
                if (!@$mail->Send()) {
                    echo "<u><b>There was an error sending the message to " . $userInfo['email'] . "</u></b><br>";
                } else {
                    echo "<u><b>Message was sent successfully to " . $userInfo['email'] . "</u></b><br>";
                }
                $mail->ClearAddresses();
            }
        }
    }
开发者ID:ber5ien,项目名称:www.jade-palace.co.uk,代码行数:82,代码来源:SendMail.class.php


注:本文中的DataModel::getSites方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。