includes/pageutils.php
changeset 29 e5484a9e0818
parent 28 dd2edcdc6c03
child 32 4d87aad3c4c0
equal deleted inserted replaced
28:dd2edcdc6c03 29:e5484a9e0818
  1331     if(!$e) $db->_die('The number of delete votes was not reset.');
  1331     if(!$e) $db->_die('The number of delete votes was not reset.');
  1332     else return('The number of votes for having this page deleted has been reset to zero.');
  1332     else return('The number of votes for having this page deleted has been reset to zero.');
  1333   }
  1333   }
  1334   
  1334   
  1335   /**
  1335   /**
  1336    * Gets a list of styles for a given theme name.
  1336    * Gets a list of styles for a given theme name. As of Banshee, this returns JSON.
  1337    * @param $id the name of the directory for the theme
  1337    * @param $id the name of the directory for the theme
  1338    * @return string Javascript code
  1338    * @return string JSON string with an array containing a list of themes
  1339    */
  1339    */
  1340    
  1340    
  1341   function getstyles()
  1341   function getstyles()
  1342   {
  1342   {
       
  1343     $json = new Services_JSON(SERVICES_JSON_LOOSE_TYPE);
       
  1344     
  1343     $dir = './themes/'.$_GET['id'].'/css/';
  1345     $dir = './themes/'.$_GET['id'].'/css/';
  1344     $list = Array();
  1346     $list = Array();
  1345     // Open a known directory, and proceed to read its contents
  1347     // Open a known directory, and proceed to read its contents
  1346     if (is_dir($dir)) {
  1348     if (is_dir($dir)) {
  1347       if ($dh = opendir($dir)) {
  1349       if ($dh = opendir($dir)) {
  1353             $list[] = substr($file, 0, strlen($file)-4);
  1355             $list[] = substr($file, 0, strlen($file)-4);
  1354           }
  1356           }
  1355         }
  1357         }
  1356         closedir($dh);
  1358         closedir($dh);
  1357       }
  1359       }
  1358     } else return($dir.' is not a dir');
  1360     }
  1359     $l = 'var list = new Array();';
  1361     else
  1360     $i = -1;
  1362     {
  1361     foreach($list as $li) {
  1363       return(Array('mode' => 'error', 'error' => $dir.' is not a dir'));
  1362       $i++;
  1364     }
  1363       $l .= "list[$i] = '$li';";
  1365     
  1364     }
  1366     return $json->encode($list);
  1365     return $l;
       
  1366   }
  1367   }
  1367   
  1368   
  1368   /**
  1369   /**
  1369    * Assembles a Javascript app with category information
  1370    * Assembles a Javascript app with category information
  1370    * @param $page_id the page ID
  1371    * @param $page_id the page ID