Ejemplo n.º 1
0
 public function testSimpleObject()
 {
     $Object = new Single(array(Single::NAME => 'T-Shirt', Single::SHORT_NAME => 'Shirt', Single::GROUP_ORDER => 3));
     $this->assertEquals('T-Shirt', $Object->name());
     $this->assertEquals('Shirt', $Object->shortName());
     $this->assertEquals(3, $Object->groupOrder());
 }
Ejemplo n.º 2
0
 public function getXmlResult()
 {
     $this->getRawResult();
     if ($this->_httpCode == '200') {
         $this->_rawResult = '<success>true</success>';
     }
     return parent::getXmlResult();
 }
Ejemplo n.º 3
0
 public static function getInstance()
 {
     if (!self::$_single instanceof self) {
         echo 'ok';
         self::$_single = new self();
     }
     return self::$_single;
 }
Ejemplo n.º 4
0
 public static function getInstance()
 {
     //使用instanceof关键字可以确定一个对象是类的实例、类的子类,还是实现了某个特定接口,并进行相应的操作。
     if (!self::$_instance instanceof self) {
         self::$_instance = new self();
     }
     return self::$_instance;
 }
Ejemplo n.º 5
0
 /**
  * Generates HTML to display a given array of entries
  *
  * @param array $entries an array of entries to be formatted
  * @return string HTML markup to display the entry
  */
 protected function generate_template_tags()
 {
     parent::generate_template_tags();
     // Add custom tags here
     foreach ($this->entries as $entry) {
         $entry->contact_form = $this->generate_contact_form();
     }
 }
Ejemplo n.º 6
0
 public function __construct($propertyName, Entity\Reflection $sourceReflection, Entity\Reflection $targetReflection, array $mapBy)
 {
     parent::__construct($propertyName, $sourceReflection, $targetReflection, $mapBy);
     if (!isset($mapBy[0])) {
         throw new Exception\AssociationException("You must define referencing key!");
     }
     if (!$targetReflection->hasPrimary()) {
         throw new Exception\AssociationException("Target entity must have defined primary when 1:1 relation used!");
     }
 }
Ejemplo n.º 7
0
 public static function getSingleResults($electionId)
 {
     $singles = Single::getListWithTickets($electionId, true, false);
     $votes = Vote::getSingleVotes($electionId);
     if (empty($votes)) {
         return self::noTicketVotes();
     }
     $total_cast_votes = 0;
     foreach ($votes as $v) {
         $total_cast_votes += $v['votes'];
         $key = $v['singleId'];
         $sorted_votes[$key][$v['ticketId']] = $v['votes'];
     }
     // sorted_votes   array(singleId => array(ticketId => votes))
     if (empty($singles)) {
         return null;
     }
     foreach ($singles as $ballot) {
         $ballot_row['title'] = $ballot['title'];
         foreach ($ballot['tickets'] as $ticket) {
             if (isset($sorted_votes[$ticket['singleId']][$ticket['id']])) {
                 $vote = $sorted_votes[$ticket['singleId']][$ticket['id']];
                 $percentage = round($vote / $total_cast_votes * 100, 1);
                 $ticket['votes'] = "{$vote} ({$percentage}%)";
                 $ticket_rows[$vote . '.' . $ticket['id']] = self::ticketTemplate($ticket);
             }
         }
         krsort($ticket_rows);
         $ballot_row['tickets'] = implode("\n", $ticket_rows);
         $tpl['ballots'][] = $ballot_row;
     }
     $template = new \Template();
     $template->addVariables($tpl);
     $template->setModuleTemplate('election', 'Admin/Report/Single.html');
     return $template->get();
 }
Ejemplo n.º 8
0
 /**
  * @param  array $count
  * @return string
  */
 protected function getKeysLine(array $count)
 {
     return 'Date,' . parent::getKeysLine($count);
 }
Ejemplo n.º 9
0
 public static function load($tpl, $css_files = array(), $js_files = array())
 {
     \CODOF\Util::inc_global_views();
     //This sets all variables which will be used by the theme
     require CURR_THEME_PATH . 'theme.php';
     $page = array();
     \CODOF\Hook::call('before_site_head');
     \CODOF\Hook::call('tpl_before_' . str_replace("/", "_", $tpl));
     $asset = new \CODOF\Asset\Stream();
     $page["head"]["css"] = $asset->dumpCSS();
     //\CODOF\Theme\Js::sort_js();
     $page["head"]["js"] = $asset->dumpJS('head');
     $page["body"]["js"] = $asset->dumpJS('body');
     $page["defer"] = json_encode($asset->deferred());
     //after all modification its time for smarty to display the mod data
     $smarty = Single::get_instance();
     $site_title = \CODOF\Util::get_opt('site_title');
     $sub_title = \CODOF\Store::get('sub_title');
     $smarty->assign('site_title', $site_title);
     $smarty->assign('sub_title', $sub_title);
     $smarty->assign('home_title', \CODOF\Store::get('home_title', _t('All topics')));
     $smarty->assign('site_url', \CODOF\Util::get_opt('site_url'));
     $smarty->assign('logged_in', \CODOF\User\CurrentUser\CurrentUser::loggedIn());
     $smarty->assign('login_url', \CODOF\User\User::getLoginUrl());
     $smarty->assign('logout_url', \CODOF\User\User::getLogoutUrl());
     $smarty->assign('register_url', \CODOF\User\User::getRegisterUrl());
     $smarty->assign('profile_url', \CODOF\User\User::getProfileUrl());
     $smarty->assign('page', $page);
     $smarty->assign('CSRF_token', \CODOF\Access\CSRF::get_token());
     $smarty->assign('php_time_now', time());
     $category = new \CODOF\Forum\Category();
     $canCreateTopicInAtleastOneCategory = $category->canCreateTopicInAtleastOne();
     $smarty->assign('canCreateTopicInAtleastOneCategory', $canCreateTopicInAtleastOneCategory);
     $page = \CODOF\Store::get('rel:canonical_page', isset($_GET['u']) ? $_GET['u'] : '');
     $smarty->assign('canonical', rtrim(RURI, '/') . strip_tags($page));
     if (\CODOF\Store::has('rel:prev')) {
         $smarty->assign('rel_prev', \CODOF\Store::get('rel:prev'));
     }
     if (\CODOF\Store::has('rel:next')) {
         $smarty->assign('rel_next', \CODOF\Store::get('rel:next'));
     }
     if (\CODOF\Store::has('meta:robots')) {
         $smarty->assign('meta_robots', \CODOF\Store::get('meta:robots'));
     }
     $og = array("type" => \CODOF\Store::get('og:type', 'website'), "title" => \CODOF\Store::get('og:title', $sub_title . ' | ' . $site_title));
     if (\CODOF\Store::has('og:url')) {
         $og['url'] = \CODOF\Store::get('og:url');
     }
     if (\CODOF\Store::has('og:desc')) {
         $og['desc'] = \CODOF\Store::get('og:desc');
     } else {
         $og['desc'] = \CODOF\Util::get_opt('site_description');
     }
     if (\CODOF\Store::has('og:image')) {
         $og['image'] = \CODOF\Store::get('og:image');
     }
     $smarty->assign('og', $og);
     if (\CODOF\Store::has('article:published')) {
         $smarty->assign('article_published', \CODOF\Store::get('article:published'));
     }
     if (\CODOF\Store::has('article:modified')) {
         $smarty->assign('article_modified', \CODOF\Store::get('article:modified'));
     }
     $I = \CODOF\User\User::get();
     //current user details
     $smarty->assign('I', $I);
     $smarty->assign('can_moderate_posts', $I->can('moderate posts'));
     if (\CODOF\User\CurrentUser\CurrentUser::loggedIn()) {
         $notifier = new \CODOF\Forum\Notification\Notifier();
         $smarty->assign('unread_notifications', $notifier->getNoOfUnread());
     }
     $html = $smarty->fetch("{$tpl}.tpl");
     require_once SYSPATH . 'Ext/simplehtmldom/simple_html_dom.php';
     $dom = new \simple_html_dom();
     $dom->load($html, true, false);
     //let plugins modify html
     \CODOF\Hook::call('tpl_after_' . str_replace("/", "_", $tpl), $dom);
     \CODOF\Hook::call('after_site_head', $dom);
     echo $dom->save();
 }
Ejemplo n.º 10
0
<?php

// Define a path for loading the CMS. Default is ../ennui-cms/
define('CMS_PATH', '../ennui-cms/');
// Initializes the core functionality of the CMS
require_once CMS_PATH . 'core/init.inc.php';
FB::info("Developers: FirePHP is included in the core for easy debugging!");
// Initialize classes used in the sidebar or in widgets
$sidebar = new Single($dbo, array('sidebar'));
?>
<!DOCTYPE html>

<html lang="en">

<head>
    <meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
    <title><?php 
echo $title;
?>
</title>
    <meta name="description" content="<?php 
echo SITE_DESCRIPTION;
?>
" />

    <!-- CSS File Includes -->
    <link rel="stylesheet" type="text/css" media="screen,projection"
          href="/assets/css/default.css" />
<?php 
if (file_exists(dirname($_SERVER['SCRIPT_FILENAME']) . "/assets/css/{$obj->url0}.css")) {
    ?>
Ejemplo n.º 11
0
 /**
  * Converts an IP address or range into a range to easily check for access
  *
  * @param string $address The IP address / range
  *
  * @return double[] Array containing the first and last ip in the range
  */
 public function convert($address)
 {
     return parent::convert('127.0.0.1');
 }
Ejemplo n.º 12
0
 /**
  * @param array $count
  *
  * @return string
  */
 protected function getKeysLine(array $count)
 {
     $keys = ['Date', 'Commit'];
     return implode(',', $keys) . ',' . parent::getKeysLine($count);
 }
Ejemplo n.º 13
0
 /**
  * @dataProvider dataProviderForMin
  */
 public function testMin(array $xs, $value, array $mins)
 {
     $this->assertEquals($mins, Single::min($xs, $value));
 }
Ejemplo n.º 14
0
<?php

/**
 * Created by PhpStorm.
 * User: KeenSting
 * Date: 2015/11/25
 * Time: 23:46
 */
require 'single.php';
//exit;
$single = Single::getInstance();
$single->run();
//正确方法,用双冒号::操作符访问静态方法获取实例
//$danli = Danli::getInstance();
//$danli->test();
Ejemplo n.º 15
0
 /**
  * 添加Request_Single请求
  *
  * @param string                $k       KEY名
  * @param \Comm\Request\Single $request Helper_Request_Single请求
  *
  * @return \Comm\Request\Multi
  */
 public function addRequest($k, Single $request)
 {
     return $this->addCurl($k, $request->fetchCurl());
 }
Ejemplo n.º 16
0
 public static function fromArray($data)
 {
     $settings = new TransactionOptions();
     foreach ($data as $key => $value) {
         if (property_exists(get_class($settings), $key)) {
             if (is_array($value)) {
                 if ($key == "single") {
                     $settings->{$key} = Single::fromArray($value);
                 }
                 if ($key == "recurringBills") {
                     $settings->{$key} = RecurringBills::fromArray($value);
                 }
             } else {
                 $settings->{$key} = $value;
             }
         }
     }
     return $settings;
 }