Esempio n. 1
0
 function use_custom($arr)
 {
     foreach ($arr as $key => $val) {
         to_bool($val);
         $this->use_custom_values[$key] = $val;
     }
 }
Esempio n. 2
0
function to_bool_recursive($vs)
{
    if (is_array($vs)) {
        foreach ($vs as $key => $value) {
            $value = to_bool_recursive($value);
            $vs[$key] = $value;
        }
    } else {
        to_bool($vs);
    }
    return $vs;
}
Esempio n. 3
0
 function __set($var, $val)
 {
     $_var = "_{$var}";
     if (property_exists($this, $_var)) {
         if (substr($var, 0, 3) == 'is_') {
             to_bool($val);
         }
         $this->{$_var} = $val;
     } else {
         parent::__set($var, $val);
     }
 }
Esempio n. 4
0
 function do_load()
 {
     $this->last_modified = filemtime($this->path);
     // load the file
     $data = file($this->path, FILE_IGNORE_NEW_LINES);
     // title, and other attributes
     while (!empty($data)) {
         $attr = array_shift($data);
         if (preg_match('@^(title):\\s*(.*)@', $attr, $ma)) {
             $this->title = $ma[2];
         } elseif (preg_match('@^(date|time):\\s*(.*)@', $attr, $ma)) {
             $this->last_modified = strtotime($ma[2], $this->last_modified);
         } elseif (preg_match('@^(subtitle):\\s*(.*)@', $attr, $ma)) {
             $this->subtitle = $ma[2];
         } elseif (preg_match('@^(icon):\\s*(.*)@', $attr, $ma)) {
             $this->icon = $ma[2];
         } elseif (preg_match('@^(category|section):\\s*(.*)@', $attr, $ma)) {
             $this->category = $ma[2];
         } elseif (preg_match('@^(tags?):\\s*(.*)@', $attr, $ma)) {
             $this->tags = preg_split('@[\\s|,]+@', $ma[2], -1, PREG_SPLIT_NO_EMPTY);
         } elseif (preg_match('@^((?:is[ _-]?)?published):\\s*(.*)@', $attr, $ma)) {
             $this->is_published = to_bool($ma[2]);
         } elseif (preg_match('@^(source[ _-]?link):(.*)@', $attr, $ma)) {
             $this->source_link = "<a href='{$this->path}'>{$ma['2']}</a>";
         } elseif (preg_match('@^(?:show[ _-]?)?(comments):\\s*(.*)@', $attr, $ma)) {
             $this->show_comments = true;
         } else {
             if ($attr != '') {
                 $this->title = $attr;
                 break;
             } else {
                 break;
             }
         }
     }
     if (count($this->tags) && !$this->icon) {
         foreach ($this->tags as $t) {
             $this->icon .= " icon-" . $t;
         }
     }
     // body
     $this->body = '';
     $this->body .= WikiFormat::format($data, true);
 }
Esempio n. 5
0
function emit_message($subtopic, $message)
{
    global $config, $queue;
    # Re-implement some of the logc from fedmsg/core.py
    # We'll have to be careful to keep this up to date.
    $prefix = "org.fedoraproject." . $config['environment'] . ".wiki.";
    $topic = $prefix . $subtopic;
    $message_obj = array("topic" => $topic, "msg" => $message, "timestamp" => round(time(), 3), "msg_id" => date("Y") . "-" . uuid_create(), "username" => "apache", "i" => 1);
    if (array_key_exists('sign_messages', $config) and to_bool($config['sign_messages'])) {
        $message_obj = sign_message($message_obj);
    }
    $envelope = json_encode($message_obj);
    $queue->send($topic, ZMQ::MODE_SNDMORE);
    $queue->send($envelope);
}
Esempio n. 6
0
<?php

// implicitly weak mode code
function to_int(int &$x)
{
}
function to_float(float &$x)
{
}
function to_string(string &$x)
{
}
function to_bool(bool &$x)
{
}
$x = 1.0;
var_dump($x);
to_int($x);
// because $x is by-reference, the weak type hint converts it
var_dump($x);
to_float($x);
var_dump($x);
to_string($x);
var_dump($x);
to_bool($x);
var_dump($x);
Esempio n. 7
0
function ldjam_show_bar()
{
    ld_get_vars();
    // Populate the $ldvar global //
    global $ldvar;
    if (to_bool($ldvar['event_active'])) {
        return "On Now: <strong>{$ldvar['event']}</strong>";
    }
    // No bar //
    return "";
}