Changeset 18628


Ignore:
Timestamp:
Oct 12, 2012, 9:56:12 PM (12 years ago)
Author:
rvelices
Message:
  • remove unsed code; shorten existing code and improve readability ...
Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/admin.php

    r18463 r18628  
    254254        'cat_move',     // ?only POST
    255255        'cat_options',  // ?only POST; public/private; lock/unlock
    256         'picture_modify', // ?only POST; associate/dissociate
    257256        'user_perm',
    258257        'group_perm',
  • trunk/admin/include/functions.php

    r17980 r18628  
    3434  WHERE site_id = '.$id.'
    3535;';
    36   $result = pwg_query($query);
    37   $category_ids = array();
    38   while ($row = pwg_db_fetch_assoc($result))
    39   {
    40     array_push($category_ids, $row['id']);
    41   }
     36  $category_ids = array_from_query($query, 'id');
    4237  delete_categories($category_ids);
    4338
     
    8075'.wordwrap(implode(', ', $ids), 80, "\n").')
    8176;';
    82   $result = pwg_query($query);
    83   $element_ids = array();
    84   while ($row = pwg_db_fetch_assoc($result))
    85   {
    86     array_push($element_ids, $row['id']);
    87   }
     77  $element_ids = array_from_query($query, 'id');
    8878  delete_elements($element_ids);
    8979
     
    396386    foreach ($orphan_tags as $tag)
    397387    {
    398       array_push($orphan_tag_ids, $tag['id']);
     388      $orphan_tag_ids[] = $tag['id'];
    399389    }
    400390
     
    413403function get_orphan_tags()
    414404{
    415   $orphan_tags = array();
    416 
    417405  $query = '
    418406SELECT
     
    423411  WHERE tag_id IS NULL
    424412;';
    425   $result = pwg_query($query);
    426   while ($row = pwg_db_fetch_assoc($result))
    427   {
    428     array_push($orphan_tags, $row);
    429   }
    430 
    431   return $orphan_tags;
     413  return array_from_query($query);
    432414}
    433415
     
    786768
    787769  // categories : id, site_id, uppercats
    788   $categories = array();
    789 
    790770  $query = '
    791771SELECT id, uppercats, site_id
     
    795775'.wordwrap(implode(', ', $cat_ids), 80, "\n").')
    796776;';
    797   $result = pwg_query($query);
    798   while ($row = pwg_db_fetch_assoc($result))
    799   {
    800     array_push($categories, $row);
    801   }
     777  $categories = array_from_query($query);
    802778
    803779  // filling $cat_fulldirs
     
    16041580  WHERE id IN ('.implode(',', $images).')
    16051581';
    1606  
     1582
    16071583  if (is_array($categories) and count($categories) > 0)
    16081584  {
     
    20842060    case 'rating':
    20852061    case 'tags':
    2086     case 'picture_modify':
    20872062    case 'batch_manager':
    20882063      return 0;
     
    21462121    {
    21472122      $alt_names = trigger_event('get_tag_alt_names', array(), $raw_name);
    2148 
    2149       // TEMP 2.4
    2150       if (count($alt_names)==0 and preg_match_all('#\[lang=(.*?)\](.*?)\[/lang\]#is', $row['name'], $matches))
    2151       {
    2152         foreach ($matches[2] as $alt)
    2153         {
    2154           $alt_names[] = $alt;
    2155         }
    2156       }
    21572123
    21582124      foreach( array_diff( array_unique($alt_names), array($name) ) as $alt)
  • trunk/admin/include/themes.class.php

    r16179 r18628  
    7979        {
    8080          array_push(
    81             $errors, 
     81            $errors,
    8282            sprintf(
    8383              l10n('Impossible to activate this theme, the parent theme is missing: %s'),
     
    8585              )
    8686            );
    87          
     87
    8888          break;
    8989        }
     
    212212          break;
    213213        }
    214        
     214
    215215        if (!$this->deltree(PHPWG_THEMES_PATH.$theme_id))
    216216        {
     
    221221      case 'set_default':
    222222        // first we need to know which users are using the current default theme
    223         $this->set_default_theme($theme_id);       
     223        $this->set_default_theme($theme_id);
    224224        break;
    225225    }
     
    233233      return null;
    234234    }
    235    
     235
    236236    $parent = $this->fs_themes[$theme_id]['parent'];
    237      
     237
    238238    if ('default' == $parent)
    239239    {
    240240      return null;
    241241    }
    242      
     242
    243243    if (!isset($this->fs_themes[$parent]))
    244244    {
     
    252252  {
    253253    $children = array();
    254    
     254
    255255    foreach ($this->fs_themes as $test_child)
    256256    {
     
    262262
    263263    return $children;
    264   } 
     264  }
    265265
    266266  function set_default_theme($theme_id)
    267267  {
    268268    global $conf;
    269    
     269
    270270    // first we need to know which users are using the current default theme
    271271    $default_theme = get_default_theme();
    272    
     272
    273273    $query = '
    274274SELECT
     
    301301    *
    302302  FROM '.THEMES_TABLE;
    303    
     303
    304304    $clauses = array();
    305305    if (!empty($id))
     
    322322  }
    323323
    324  
     324
    325325  /**
    326326  *  Get themes defined in the theme directory
    327   */ 
     327  */
    328328  function get_fs_themes()
    329329  {
    330330    $dir = opendir(PHPWG_THEMES_PATH);
    331    
     331
    332332    while ($file = readdir($dir))
    333333    {
     
    532532    return false;
    533533  }
    534  
     534
    535535  /**
    536536   * Sort $server_themes
     
    654654    return $status;
    655655  }
    656  
     656
    657657  /**
    658658   * delete $path directory
     
    775775  }
    776776
    777   // themes specific methods
    778   function get_fs_themes_with_ini()
    779   {
    780     $themes_dir = PHPWG_ROOT_PATH.'themes';
    781 
    782     $fs_themes = array();
    783 
    784     foreach (get_dirs($themes_dir) as $theme)
    785     {
    786       $conf_file = $themes_dir.'/'.$theme.'/themeconf.inc.php';
    787       if (file_exists($conf_file))
    788       {
    789         $theme_data = array(
    790           'name' => $theme,
    791           );
    792        
    793         $ini_file = $themes_dir.'/'.$theme.'/theme.ini';
    794         if (file_exists($ini_file))
    795         {
    796           $theme_ini = parse_ini_file($ini_file);
    797           if (isset($theme_ini['extension_id']))
    798           {
    799             $theme_data['extension_id'] = $theme_ini['extension_id'];
    800           }
    801         }
    802 
    803         array_push($fs_themes, $theme_data);
    804       }
    805     }
    806 
    807     echo '<pre>'; print_r($fs_themes); echo '</pre>';
    808   }
    809 
    810  
    811777}
    812778?>
Note: See TracChangeset for help on using the changeset viewer.