Example #1
0
function deleteStyle()
{
    // get id__style
    $id__style = (isset($_GET['id']) and is_numeric($_GET['id'])) ? $_GET['id'] : 0;
    if (empty($id__style)) {
        return true;
    }
    // get style-object
    $Style = new ts_Style($id__style);
    // delete
    if (!$Style->deleteStyle()) {
        // error
        $_SESSION['admin_error'] = 'ERROR__DELETESTYLE';
        return false;
    }
    $_SESSION['admin_info'] = 'INFO__DELETESTYLE';
    return true;
}
 /** Get all styles
  * @param bool $force_update
  *	Force to get new list from database (not a cached one from obj-var)?
  *
  * @return array
  */
 public function getStyles($force_update = false)
 {
     global $Database, $Config;
     // already in obj-var?
     if (!$force_update and isset($this->styles) and !empty($this->styles)) {
         return $this->styles;
     }
     // get module-ids from database
     $sql = "SELECT id__style as id__style\n\t    FROM #__styles\n\t    ORDER BY name ASC;";
     $result = $Database->doSelect($sql);
     if ($result === false) {
         return false;
     }
     // get available sources
     $subfolders = ts_FileHandler::getSubfolders($Config->get('dir_data') . '/source/styles');
     if (!is_array($subfolders)) {
         return false;
     }
     // get style objects and save them in obj-var
     $style_files = array();
     foreach ($subfolders as $index => $value) {
         $style_files[] = new ts_Style(false, $value);
     }
     // add already deleted styles
     $this->styles = array();
     foreach ($style_files as $index => $Value) {
         $this->styles[$Value->getInfo('name') . '__' . $Value->getInfo('nameid')] = $Value;
     }
     foreach ($result as $index => $values) {
         $Style = new ts_Style($values['id__style']);
         if (!isset($this->styles[$Style->getInfo('name') . '__' . $Style->getInfo('nameid')])) {
             $this->styles[$Style->getInfo('name') . '__' . $Style->getInfo('nameid')] = $Style;
         }
     }
     // sort
     ksort($this->styles);
     return $this->styles;
 }