Changeset 1527

Show
Ignore:
Timestamp:
08/09/06 11:06:03 (2 years ago)
Author:
mbonetti
Message:

Fix for #419 - Allow graphical updating of themes

Location:
trunk/gregarius
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • trunk/gregarius/admin/themes.php

    r1372 r1527  
    4545        $active_theme= getConfig('rss.output.theme'); 
    4646    } 
     47 
     48        echo "<form style=\"float:right\" method=\"post\" action=\"" .$_SERVER['PHP_SELF'] ."\">\n" 
     49          . "<p><input type=\"hidden\" name=\"".CST_ADMIN_DOMAIN."\" value=\"".CST_ADMIN_DOMAIN_THEMES."\" />\n" 
     50        ."<input type=\"submit\" name=\"admin_themes_check_for_updates\" value=\"".LBL_ADMIN_CHECK_FOR_UPDATES."\" /></p>\n" 
     51        . "</form>\n"; 
     52        if (isset($_POST['admin_themes_check_for_updates'])) { 
     53            theme_getThemesUpdate(&$themes); 
     54        } 
    4755     
    4856    echo "<h2 class=\"trigger\">".LBL_ADMIN_THEMES."</h2>\n" 
     
    6169        } 
    6270        $active = ($entry ==  $active_theme); 
     71        $updateAvailable = isset($theme['updateVersion']); 
    6372        if ($screenshot) { 
    6473            $screenshotURL = "<img src=\"". getPath() . RSS_THEME_DIR . "/$fsname/$screenshot\"  />"; 
     
    6877        $h4="$name";  
    6978        $h5="By&nbsp;$author | Version:&nbsp;$version"; 
     79        if ($updateAvailable) { 
     80            $h5 .= ' | <a class="update" href="'.$theme['updateUrl'].'">Update to version ' .$theme['updateVersion'] .'</a>'; 
     81        } 
     82         
    7083        if ($htmltheme) { 
    7184            $seturl = "index.php?view=themes&amp;theme=$entry"; 
     
    7386            $seturl = ""; 
    7487        } 
    75         echo "<div class=\"themeframe".($active?" active":"")."\"><span>"; 
     88        echo "<div class=\"themeframe".($active?" active":""). ($updateAvailable?" hilite":"")."\"><span>"; 
    7689        if (!$active && $htmltheme) { 
    7790            echo "<a href=\"$seturl\" class=\"bookmarklet\">".LBL_ADMIN_USE_THIS_THEME."</a>"; 
     
    399412} 
    400413 
     414function theme_getThemesUpdate(&$themes) { 
     415      $themesxml = array(); 
     416    global $themesxml; 
     417    $xml = getUrl('http://themes.gregarius.net/api.php'); 
     418    $xml = str_replace("\r", '', $xml); 
     419    $xml = str_replace("\n", '', $xml); 
     420 
     421    $xp = xml_parser_create() or rss_error("couldn't create parser"); 
     422 
     423    xml_set_element_handler($xp, 'themes_xml_startElement', 'themes_xml_endElement') 
     424    or rss_error("couldnt set XML handlers"); 
     425 
     426    xml_parse($xp, $xml, true) or rss_error("failed parsing xml"); 
     427    xml_parser_free($xp) or rss_error("failed freeing the parser"); 
     428    if (is_array($themesxml)) { 
     429        foreach($themesxml as $theme => $data) { 
     430            list($tversion,$turl) = $data; 
     431            if (isset($themes[$theme]) && $themes[$theme]['version'] < $tversion) { 
     432                $themes[$theme]['updateVersion'] = $tversion; 
     433                $themes[$theme]['updateUrl'] = $turl; 
     434            } 
     435        } 
     436    } 
     437} 
     438 
     439function themes_xml_startElement($xp, $element, $attr) { 
     440    global $themesxml; 
     441 
     442    if ($element == 'THEME' && 
     443            array_key_exists('PID',$attr) && 
     444            array_key_exists('URL',$attr) && 
     445            array_key_exists('VERSION',$attr)) { 
     446 
     447        $themesxml[$attr['PID']] = array($attr['VERSION'],$attr['URL']); 
     448    } 
     449} 
     450 
     451function themes_xml_endElement($xp, $element) { 
     452    ///global $pluginsxml; 
     453    return; 
     454} 
     455 
    401456?> 
  • trunk/gregarius/themes/default/web/css/look.css

    r1435 r1527  
    129129tr.active td { font-weight:900; background-color:#f8f8ff; } 
    130130tr.hilite td { font-weight:900; background-color:#f0fff0; } 
     131.themeframe.hilite span,.themeframe.hilite:hover span { background-color:#f0fff0; } 
    131132 
    132133h3.collapsed { 
     
    404405} 
    405406 
     407.themeframe h5 a.update { color: #447; font-weight: 900 !important; } 
     408 
    406409.themeframe .bookmarklet { 
    407410    float:right; 
     
    420423     
    421424.themeframe span:hover, .themeframe.active span {  
    422  border-color: #eef; 
     425 border-color: #dde; 
    423426 background-color: #f8f8ff; 
    424427 }