Changeset 9449


Ignore:
Timestamp:
Mar 1, 2011, 1:00:44 PM (9 years ago)
Author:
patdenice
Message:

Optimizations.

Location:
extensions/PWG_Stuffs
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • extensions/PWG_Stuffs/admin/manage.inc.php

    r9410 r9449  
    3030    pwg_query('
    3131UPDATE ' . STUFFS_TABLE . '
    32 SET datas = "'.addslashes(serialize(array('hide' => isset($_POST['hidemb'])))).'"
     32SET datas = "'.addslashes(serialize(!isset($_POST['hidemb']))).'"
    3333WHERE id=0;');
    3434
     
    6060  $module['name'] = !empty($module['path']) ? $module['name'] : l10n('stuffs_main_block');
    6161
    62   $missing = false;
     62  $missing_message = '';
     63  if ($module['path'] == PHPWG_PLUGINS_PATH.'piclens/stuffs_module/' and !file_exists(PICLENS_PATH.'stuffs_module/main.inc.php'))
     64  {
     65    $missing_message = l10n('stuffs_piclens_need_upgrade');
     66  }
    6367  if (!empty($module['path']))
    6468  {
    6569    preg_match('#^'.preg_quote(PHPWG_PLUGINS_PATH).'([^/]*?)/#', $module['path'], $match);
    66     $missing = !isset($pwg_loaded_plugins[$match[1]]);
     70    if (!isset($pwg_loaded_plugins[$match[1]]))
     71    {
     72      $missing_message = l10n('stuffs_parent_plugin_is_missing');
     73    }
    6774  }
    6875
     
    8087    'U_EDIT' => PHPWG_ROOT_PATH . 'admin.php?page=plugin&section=' . STUFFS_DIR . '%2Fadmin%2Fadmin.php&tab=edit_module&edit='.$module['id'],
    8188    'U_DELETE' => !is_adviser() ? PHPWG_ROOT_PATH . 'admin.php?page=plugin&section=' . STUFFS_DIR . '%2Fadmin%2Fadmin.php&del=' . $module['id'] : '',
    82     'MISSING' => $missing,
     89    'MISSING' => $missing_message,
    8390    )
    8491  );
    8592
    86   if (empty($module['path']) and !empty($module['datas']))
     93  if (empty($module['path']))
    8794  {
    88     $datas = unserialize($module['datas']);
    89     $template->assign('HIDEMB', $datas['hide']);
     95    $show = unserialize($module['datas']);
     96    $template->assign('HIDEMB', !$show);
    9097  }
    9198}
  • extensions/PWG_Stuffs/admin/template/manage.tpl

    r9369 r9449  
    6363          <input type="text" size="2" maxlength="2" value="{$module.WIDTH}" name="width[{$module.ID}]" > %
    6464        </li>
    65         {if !$module.MISSING}
     65        {if empty($module.MISSING)}
    6666        <li><a href="{$module.U_EDIT}" title="{'stuffs_edit'|@translate}"><img src="{$themeconf.admin_icon_dir}/category_edit.png" class="button" alt="{'stuffs_edit'|@translate}"/></a></li>
    6767        {/if}
     
    7878      </p>
    7979
    80       {if $module.MISSING}
    81         <p style="margin-left: 30px;">{'stuffs_parent_plugin_is_missing'|@translate}</p>
     80      {if !empty($module.MISSING)}
     81        <p style="margin-left: 30px;">{$module.MISSING}</p>
    8282      {elseif !empty($module.DESC)}
    8383        <p style="margin-left: 30px;"><i>{$module.DESC}</i></p>
  • extensions/PWG_Stuffs/admin/template/new.tpl

    r9369 r9449  
    33</div>
    44
    5 <form method="post" action="" class="general">
     5<form method="post" action="" class="properties">
    66
    7 <fieldset>
    8         <legend>{'stuffs_add_mod'|@translate}</legend>
    9 
    10         <table>
    11         {foreach from=$add_module item=module}
    12         <tr>
    13                 <td><input type="radio" value="{$module.MODULE_PATH}" name="module"/>
    14                         <b>{$module.NAME}</b> : {$module.DESC}</td>
    15         </tr>
    16         {/foreach}
    17         </table>
    18 <br>
    19 <div style="text-align:center;">
    20 <input class="submit" name="addModule" type="submit" value="{'stuffs_add_mod'|@translate}" {$TAG_INPUT_ENABLED} />
    21 </div>
    22 
     7<fieldset id="indexDisplayConf" style="padding-top:25px;">
     8  <legend>{'stuffs_add_mod'|@translate}</legend>
     9  <ul>
     10    {foreach from=$add_module item=module}
     11    <li>
     12      <label>
     13        <span class="property">{$module.NAME} <span style="font-weight:normal;">: {$module.DESC}</span></span>
     14        <input type="radio" value="{$module.MODULE_PATH}" name="module"/>
     15      </label>
     16    </li>
     17    {/foreach}
     18  </ul>
    2319</fieldset>
    24 
     20<p><input class="submit" name="addModule" type="submit" value="{'stuffs_add_mod'|@translate}"/></p>
    2521</form>
  • extensions/PWG_Stuffs/admin/upgrade.inc.php

    r9410 r9449  
    55global $prefixeTable, $conf;
    66
    7 $query = 'SHOW FULL COLUMNS FROM ' . $prefixeTable . 'stuffs;';
     7$query = 'SHOW FULL COLUMNS FROM '.STUFFS_TABLE.';';
    88$result = array_from_query($query, 'Field');
    99if ($result[5] == 'params')
    1010{
    11   $query = 'ALTER TABLE ' . $prefixeTable . 'stuffs
     11  $query = 'ALTER TABLE '.STUFFS_TABLE.'
    1212MODIFY COLUMN name TEXT CHARACTER SET utf8 NOT NULL,
    1313MODIFY COLUMN descr VARCHAR(255) CHARACTER SET utf8 default NULL,
     
    3030  pwg_query($query);
    3131 
    32   $query = 'SELECT id, name, type, params, datas FROM ' . $prefixeTable . 'stuffs;';
     32  $query = 'SELECT id, name, type, params, datas FROM '.STUFFS_TABLE.';';
    3333  $result = pwg_query($query);
    3434 
     
    7676  }
    7777
    78   $query = 'ALTER TABLE ' . $prefixeTable . 'stuffs DROP params;';
     78  $query = 'ALTER TABLE '.STUFFS_TABLE.' DROP params;';
    7979  pwg_query($query);
    8080
     
    8686}
    8787
    88 $query = 'SHOW FULL COLUMNS FROM ' . $prefixeTable . 'stuffs;';
     88$query = 'SHOW FULL COLUMNS FROM '.STUFFS_TABLE.';';
    8989$result = array_from_query($query, 'Field');
    9090if ($result[4] != 'path')
    9191{
    92   $query = 'ALTER TABLE ' . $prefixeTable . 'stuffs
     92  $path = $plugin['id'];
     93  $conf['Stuffs'] = array();
     94
     95  $query = 'ALTER TABLE '.STUFFS_TABLE.'
    9396CHANGE `type` `path` VARCHAR( 255 ) NULL DEFAULT NULL,
    9497ADD `level` TINYINT( 3 ) NOT NULL default "0" AFTER `groups`,
     
    97100  pwg_query($query);
    98101
    99   $query = 'UPDATE ' . $prefixeTable . 'stuffs
     102  $query = 'UPDATE '.STUFFS_TABLE.'
    100103SET on_root = "false"
    101 WHERE on_cats = "false"
     104WHERE on_cats <> "true"
    102105;';
    103106  pwg_query($query);
    104107
    105   $query = 'UPDATE ' . $prefixeTable . 'stuffs
    106 SET path = CONCAT("'.PHPWG_ROOT_PATH.'", "plugins/PWG_Stuffs/", path, "/")
    107 WHERE path <> "MainBlock"
     108  $query = 'SELECT * FROM '.STUFFS_TABLE.';';
     109  $result = pwg_query($query);
     110
     111  while ($row = pwg_db_fetch_assoc($result))
     112  {
     113    if ($row['path'] == 'Personal')
     114    {
     115      $data = unserialize($row['datas']);
     116      $row['datas'] = serialize($data[0]);
     117    }
     118    if ($row['path'] == 'piclenswall')
     119    {
     120      $row['path'] = PHPWG_PLUGINS_PATH.'piclens/stuffs_module/';
     121      $conf['Stuffs']['piclens_upgrade'] = true;
     122    }
     123    elseif ($row['path'] != 'MainBlock')
     124    {
     125      $row['path'] = PHPWG_PLUGINS_PATH.$path.'/modules/'.$row['path'].'/';
     126    }
     127    else
     128    {
     129      // Main Block
     130      $row['path'] = null;
     131      if (!empty($row['datas']))
     132      {
     133        $data = unserialize($row['datas']);
     134        $row['datas'] = serialize(!$data['hide']);
     135      }
     136      else
     137      {
     138        $row['datas'] = serialize(true);
     139      }
     140    }
     141
     142    $query = 'UPDATE '.STUFFS_TABLE.'
     143SET path = '.(is_null($row['path']) ? 'NULL' : '"'.$row['path'].'"').',
     144    datas = "'.addslashes($row['datas']).'"
     145WHERE id = '.$row['id'].'
    108146;';
    109   pwg_query($query);
     147    pwg_query($query);
     148  }
    110149
    111   $query = 'UPDATE ' . $prefixeTable . 'stuffs
    112 SET path = NULL
    113 WHERE path = "MainBlock"
    114 ;';
    115   pwg_query($query);
    116 
    117   $conf['Stuffs'] = array('level_perm' => false);
     150  $conf['Stuffs']['level_perm'] = false;
    118151
    119152  $query = 'SELECT id
    120 FROM '.$prefixeTable.'stuffs
     153FROM '.STUFFS_TABLE.'
    121154WHERE users <> "guest,generic,normal,admin,webmaster"
    122155;';
     
    125158
    126159  $query = 'SELECT id
    127 FROM '.$prefixeTable.'stuffs
     160FROM '.STUFFS_TABLE.'
    128161WHERE groups IS NOT NULL
    129162;';
     
    132165
    133166  $query = 'INSERT INTO ' . CONFIG_TABLE . ' (param,value,comment)
    134 VALUES ("PWG_Stuffs" , "'.pwg_db_real_escape_string(serialize($conf['Stuffs'])).'" , "PWG Stuffs configuration");';
    135   pwg_query($query); 
     167VALUES ("PWG_Stuffs" , "'.pwg_db_real_escape_string(serialize($conf['Stuffs'])).'" , "PWG Stuffs plugin configuration");';
     168  pwg_query($query);
     169}
     170
     171// Display Piclens upgrade message
     172if (isset($conf['Stuffs']['piclens_upgrade']) and isset($menu))
     173{
     174  if (file_exists(PHPWG_PLUGINS_PATH.'piclens/stuffs_module/main.inc.php'))
     175  {
     176    unset($conf['Stuffs']['piclens_upgrade']);
     177  }
     178  else
     179  {
     180    if (get_db_plugins('active','piclens'))
     181    {
     182      global $page;
     183      load_language('plugin.lang', STUFFS_PATH);
     184      array_push($page['errors'], l10n('stuffs_piclens_need_upgrade'));
     185    }
     186  }
     187  conf_update_param('PWG_Stuffs', pwg_db_real_escape_string(serialize($conf['Stuffs'])));
    136188}
    137189
  • extensions/PWG_Stuffs/class.inc.php

    r9410 r9449  
    8181      {
    8282        $this->pos = 'end';
    83         if (!empty($module['datas'])
    84           and $datas = unserialize($module['datas'])
    85           and $datas['hide'])
     83        $show = unserialize($module['datas']);
     84        if (!$show)
    8685        {
    8786          add_event_handler('loc_end_index', 'hide_main_block');
     
    189188  {
    190189    $css = array(
    191       '<link rel="stylesheet" type="text/css" href="{$ROOT_URL}plugins/PWG_Stuffs/theme/stuffs_index.css">'
     190      '<link rel="stylesheet" type="text/css" href="{$ROOT_URL}plugins/'.STUFFS_DIR.'/theme/stuffs_index.css">'
    192191    );
    193192
     
    208207  {
    209208    $css = array(
    210       '<link rel="stylesheet" type="text/css" href="{$ROOT_URL}plugins/PWG_Stuffs/theme/stuffs_picture.css">'
     209      '<link rel="stylesheet" type="text/css" href="{$ROOT_URL}plugins/'.STUFFS_DIR.'/theme/stuffs_picture.css">'
    211210    );
    212211
  • extensions/PWG_Stuffs/language/en_UK/plugin.lang.php

    r9383 r9449  
    1717$lang['stuffs_confirm_delete'] = 'Are you sure you want to delete module %s?';
    1818$lang['stuffs_main_block'] = 'Main block';
     19$lang['Hide on home page'] = 'Hide on home page';
    1920
    2021$lang['stuffs_add_module'] = 'Add new module';
     
    2829$lang['stuffs_show_module_on'] = 'Show module :';
    2930$lang['stuffs_show_on_home'] = 'On main page';
     31$lang['stuffs_show_on_root'] = 'On categories root page';
    3032$lang['stuffs_show_on_cats'] = 'On all categories pages';
    3133$lang['stuffs_show_on_picture'] = 'On picture pages';
    3234$lang['stuffs_no_options'] = 'No options for this module';
    33 $lang['Hide on home page'] = 'Hide on home page';
    3435
    3536$lang['stuffs_perm'] = 'Activate authorization management:';
     
    3738$lang['stuffs_user_perm'] = 'by user type';
    3839$lang['stuffs_level_perm'] = 'by privacy level';
    39 $lang['stuffs_show_on_root'] = 'On root categories';
     40
     41$lang['stuffs_select_all'] = 'Select all';
     42$lang['stuffs_unselect_all'] = 'Unselect all';
    4043
    4144//Messages d'infos
    4245$lang['stuffs_order_saved'] = 'Order successfully saved.';
    43 
     46$lang['stuffs_upgrade_message'] = 'PWG Stuffs plugin as been renamed. It is now called "Blocks".';
    4447
    4548// Messages d'erreurs
     
    4750$lang['stuffs_no_name'] = 'You must specify name module';
    4851$lang['stuffs_parent_plugin_is_missing'] = 'PARENT PLUGIN IS NOT ACTIVATED. You should remove this module or re-activate parent plugin.';
     52$lang['stuffs_piclens_need_upgrade'] = 'PICLENS PLUGIN MUST BE UPDATED. PWG Stuffs is not compatible with this version of Piclens.';
    4953
    5054//------------------------------------------------------------------------------
     
    6569$lang['lastcoms_taille_cadres'] = 'Frame height';
    6670
    67 
    6871//------------------------------------------------------------------------------
    6972//              Module Logon
     
    7578$lang['logon_remove_menubar_block'] = 'Remove "Quick connect" block from menubar';
    7679
    77 
    7880//------------------------------------------------------------------------------
    7981//              Module Personal
     
    8486
    8587$lang['personal_content'] = 'content';
    86 
    8788
    8889//------------------------------------------------------------------------------
     
    9798$lang['stuffs_tags_letters'] = 'Group by lettters';
    9899$lang['stuffs_tags_cumulus'] = 'Use cumulus mode (plugin <a href=http://piwigo.org/ext/extension_view.php?eid=263 target="_blank">Cumulus Tags Cloud</a> must be installed)';
    99 
    100 
    101 //------------------------------------------------------------------------------
    102 //              Module Piclenswall
    103 //------------------------------------------------------------------------------
    104 
    105 $lang['module_name_piclenswall'] = 'Piclens 3DWall';
    106 $lang['module_desc_piclenswall'] = 'Display piclens 3D wall (plugin <a href="http://piwigo.org/ext/extension_view.php?eid=234" target="_blank">Cooliris/piclens</a> must be installed)';
    107 
    108 $lang['piclenswall_height'] = 'Wall height';
    109 $lang['piclenswall_background_color'] = 'Background color';
    110 $lang['piclenswall_black'] = 'Black';
    111 $lang['piclenswall_white'] = 'White';
    112 $lang['piclenswall_info'] = 'So that the wall is working properly';
    113 $lang['piclenswall_info_piclens'] = 'You must install and activate <a href="http://piwigo.org/ext/extension_view.php?eid=234">Cooliris/piclens</a> plugin.';
    114 $lang['piclenswall_info_crossdomain'] = 'You must copy <a href="%s">crossdomain.xml</a> file to the root of your site (or moddify existing file).';
    115 $lang['piclenswall_info_param'] = '3D Wall Settings must be modified in <b>Cooliris-piclens/b> plugin configuration page.';
    116100
    117101//------------------------------------------------------------------------------
  • extensions/PWG_Stuffs/language/fr_FR/plugin.lang.php

    r9383 r9449  
    2929$lang['stuffs_show_module_on'] = 'Afficher le module :';
    3030$lang['stuffs_show_on_home'] = 'Sur la page d\'accueil du site';
     31$lang['stuffs_show_on_root'] = 'A la racine des catégories';
    3132$lang['stuffs_show_on_cats'] = 'Sur toutes les pages des catégories';
    3233$lang['stuffs_show_on_picture'] = 'Sur les pages des images';
     
    3738$lang['stuffs_user_perm'] = 'par type d\'utilisateurs';
    3839$lang['stuffs_level_perm'] = 'par niveau de confidentialité';
    39 $lang['stuffs_show_on_root'] = 'A la racine des catégories';
     40
     41$lang['stuffs_select_all'] = 'Sélectionner tout';
     42$lang['stuffs_unselect_all'] = 'Déselectionner tout';
    4043
    4144//Messages d'infos
    4245$lang['stuffs_order_saved'] = 'L\'ordre a été sauvegardé.';
    43 
     46$lang['stuffs_upgrade_message'] = 'Le plugin PWG Stuffs a été renommé. Il s\'appelle désormais "Blocks".';
    4447
    4548// Messages d'erreurs
     
    4750$lang['stuffs_no_name'] = 'Vous devez indiquer un nom pour le module';
    4851$lang['stuffs_parent_plugin_is_missing'] = 'LE PLUGIN PARENT N\'EST PLUS ACTIVÉ. Veuillez supprimer ce module ou réactiver le plugin parent.';
     52$lang['stuffs_piclens_need_upgrade'] = 'LE PLUGIN PICLENS DOIT ÊTRE MIS À JOUR. PWG Stuffs n\'est pas compatible avec cette version de Piclens.';
    4953
    5054//------------------------------------------------------------------------------
     
    6569$lang['lastcoms_taille_cadres'] = 'Hauteur des cadres';
    6670
    67 
    6871//------------------------------------------------------------------------------
    6972//              Module Logon
     
    7578$lang['logon_remove_menubar_block'] = 'Retirer le bloc "identification rapide" du menubar';
    7679
    77 
    7880//------------------------------------------------------------------------------
    7981//              Module Personal
     
    8486
    8587$lang['personal_content'] = 'contenu';
    86 
    8788
    8889//------------------------------------------------------------------------------
     
    9798$lang['stuffs_tags_letters'] = 'Regrouper par lettres';
    9899$lang['stuffs_tags_cumulus'] = 'Utiliser le mode Cumulus (le plugin <a href=http://piwigo.org/ext/extension_view.php?eid=263 target="_blank">Cumulus Tags Cloud</a> doit etre installé)';
    99 
    100 
    101 //------------------------------------------------------------------------------
    102 //              Module Piclenswall
    103 //------------------------------------------------------------------------------
    104 
    105 $lang['module_name_piclenswall'] = 'Piclens 3DWall';
    106 $lang['module_desc_piclenswall'] = 'Affiche un mur 3D piclens (le plugin <a href="http://piwigo.org/ext/extension_view.php?eid=234" target="_blank">Cooliris/piclens</a> doit etre installé)';
    107 
    108 $lang['piclenswall_height'] = 'Hauteur du mur Cooliris';
    109 $lang['piclenswall_background_color'] = 'Couleur de l\'arrière plan';
    110 $lang['piclenswall_black'] = 'Noir';
    111 $lang['piclenswall_white'] = 'Blanc';
    112 $lang['piclenswall_info'] = 'Important pour que 3DWall fonctionne';
    113 $lang['piclenswall_info_piclens'] = 'Vous devez installer et activer le plugin <a href="http://piwigo.org/ext/extension_view.php?eid=234">Cooliris/piclens</a>.';
    114 $lang['piclenswall_info_crossdomain'] = 'Vous devez copier le fichier <a href="%s">crossdomain.xml</a> à la racine du site (ou modifier le fichier existant).';
    115 $lang['piclenswall_info_param'] = 'Les paramètres du mur sont à modifier directement dans la page de configuration du plugin <b>Cooliris-piclens</b>';
    116100
    117101//------------------------------------------------------------------------------
  • extensions/PWG_Stuffs/main.inc.php

    r9410 r9449  
    1313global $prefixeTable, $conf;
    1414
     15$conf['Stuffs'] = @unserialize($conf['PWG_Stuffs']);
     16
    1517define('STUFFS_DIR' , basename(dirname(__FILE__)));
    1618define('STUFFS_PATH' , PHPWG_PLUGINS_PATH . STUFFS_DIR . '/');
    1719define('STUFFS_TABLE' , $prefixeTable . 'stuffs');
    18 
    19 $conf['Stuffs'] = @unserialize($conf['PWG_Stuffs']);
    2020
    2121// Need upgrade?
     
    2525function stuffs_admin_menu($menu)
    2626{
     27  global $conf;
     28
     29  if (isset($conf['Stuffs']['piclens_upgrade']))
     30    include('admin/upgrade.inc.php');
     31
    2732  array_push($menu, array(
    2833    'NAME' => 'PWG Stuffs',
  • extensions/PWG_Stuffs/maintain.inc.php

    r9410 r9449  
    3535    pwg_query($q);
    3636 
    37     $q = "INSERT INTO `" . $prefixeTable . "stuffs` (`id`, `pos`, `name`, `users`, `show_title`, `on_home`, `on_cats`, `on_picture`)
    38 VALUES (0, 1, 'MainBlock', 'guest,generic,normal,admin,webmaster', 'true', 'true', 'true', 'true');";
     37    $q = "INSERT INTO `" . $prefixeTable . "stuffs` (`id`, `pos`, `name`, `datas`, `users`, `show_title`, `on_home`, `on_cats`, `on_picture`)
     38VALUES (0, 1, 'MainBlock', '".addslashes(serialize(true))."', 'guest,generic,normal,admin,webmaster', 'true', 'true', 'true', 'true');";
    3939    pwg_query($q);
    4040  }
     
    4949
    5050    $query = 'INSERT INTO ' . CONFIG_TABLE . ' (param,value,comment)
    51 VALUES ("PWG_Stuffs" , "'.pwg_db_real_escape_string(serialize($config)).'" , "PWG Stuffs configuration");';
     51VALUES ("PWG_Stuffs" , "'.pwg_db_real_escape_string(serialize($config)).'" , "PWG Stuffs plugin configuration");';
    5252    pwg_query($query);
    5353  }
  • extensions/PWG_Stuffs/modules/Personal/config.inc.php

    r9369 r9449  
    77// Enregistrement de la configuration
    88if (isset($_POST['submit']) and !is_adviser()) {
    9   $datas = array(stripslashes($_POST['personal_content']));
     9  $datas = stripslashes($_POST['personal_content']);
    1010}
    1111
    1212// Parametrage du template
    1313$template->assign('cat_style', array());
    14 $template->assign(array('PERSONAL_CONTENT' => $datas[0]));
    15 
    16 // TinyMCE
    17 trigger_action('tinymce', 'pwgstuffs');
     14$template->assign(array('PERSONAL_CONTENT' => $datas));
    1815
    1916$template->set_filenames(array('module_options' => dirname(__FILE__) . '/config.tpl'));
  • extensions/PWG_Stuffs/modules/Personal/main.inc.php

    r9369 r9449  
    33if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
    44
    5 $block['CONTENT'] = $datas[0];
     5$block['CONTENT'] = $datas;
    66
    77// Extended description
Note: See TracChangeset for help on using the changeset viewer.