public function genDownloadBadge()
 {
     $html = '';
     if ($this->hasDownloadUri()) {
         $downloadUri = htmlspecialchars($this->downloadUri);
         $title = htmlspecialchars($this->title);
         $html .= "<div class=\"icon\">" . "<a href=\"{$downloadUri}\"" . " title=\"Download &#39;{$title}&#39;\">" . "<img src=\"images/packageicon.png\" alt=\"Package icon\" /></a></div>";
         $html .= "<a href=\"{$downloadUri}\"" . " title=\"Download &#39;{$title}&#39;\">";
     } else {
         if ($this->hasHomepageUri()) {
             $title = htmlspecialchars($this->title);
             $homepageUri = htmlspecialchars($this->homepageUri());
             $homepageUriLabel = htmlspecialchars("Visit &#39;{$this->title}&#39; homepage");
             $html .= "<a href=\"{$homepageUri}\"" . " title=\"{$homepageUriLabel}\">";
         }
     }
     $html .= '<span class="name">' . htmlspecialchars($this->title()) . '</span>';
     if ($this->hasDescription()) {
         $html .= '<span class="description">' . htmlspecialchars($this->description()) . '</span>';
     }
     if ($this->hasDownloadUri() || $this->hasHomepageUri()) {
         $html .= '</a>';
     }
     $html .= '<div class="metadata">';
     if ($this->hasDownloadUri()) {
         $html .= '<span class="version">Version: ' . htmlspecialchars($this->version()) . '</span>';
         if (!isset($this->games)) {
             $gameString = '<label title="For use with all games">Any</label>';
         } else {
             if ($this->supportsAllGameModes(AddonRepositoryPlugin::$doomGameModes)) {
                 $gameString = '<label title="For use with any version of DOOM">Any DOOM</label>';
             } else {
                 if ($this->supportsAllGameModes(AddonRepositoryPlugin::$hereticGameModes)) {
                     $gameString = '<label title="For use with any version of Heretic">Any Heretic</label>';
                 } else {
                     if ($this->supportsAllGameModes(AddonRepositoryPlugin::$hexenGameModes)) {
                         $gameString = '<label title="For use with any version of Hexen">Any Hexen</label>';
                     } else {
                         $gameString = '<label title="For use with these games only">' . htmlspecialchars(implode_keys('|', $this->games)) . '</label>';
                     }
                 }
             }
         }
         $html .= '<br /><span class="games">Games: ' . $gameString . '</span>';
     } else {
         // We have no interesting meta data for simple links. What to say here?
     }
     $html .= '</div>';
     /*if($this->hasNotes())
       {
           $html .= '<br /><p>'. $this->notes() .'</p>';
       }*/
     return '<div class="addon_badge">' . $html . '</div>';
 }
Example #2
0
function insert_array_db_multi($table, $arr_columns)
{
    # multiple inserts allowed in one sentence
    # input $arr_columns must be like:
    /*Array
    	(
        [Temperature] => Array
            (
                [0] => 16.4
                [1] => 16.4
                [2] => 16.4
            )
    
        [Wattage] => Array
            (
                [0] => 00383
                [1] => 00403
                [2] => 00395
            )
    
        [CC_Time] => Array
            (
                [0] => 2015-02-06 06:00:03
                [1] => 2015-02-06 06:00:09
                [2] => 2015-02-06 06:00:15
            )
    	)*/
    global $conex;
    $columns = '(' . implode_keys(', ', $arr_columns) . ')';
    $arr_keys = array_keys($arr_columns);
    $str_values = '';
    $first = true;
    foreach ($arr_columns[$arr_keys[0]] as $i => $value) {
        if ($first) {
            $first = false;
        } else {
            $str_values .= ',';
        }
        $str_values .= '(';
        $first2 = true;
        foreach ($arr_keys as $key) {
            if ($first2) {
                $first2 = false;
            } else {
                $str_values .= ',';
            }
            $str_values .= '\'' . $arr_columns[$key][$i] . '\'';
        }
        $str_values .= ')';
    }
    $sql = 'INSERT INTO ' . $table . $columns . ' VALUES ' . $str_values;
    $insert = my_query($sql, $conex);
    if ($insert) {
        return true;
    } else {
        return false;
    }
}