Dotclear

Changeset 2334


Ignore:
Timestamp:
06/08/10 17:25:04 (13 years ago)
Author:
bruno
Message:

New fixes... added custom template file to serve for a given mymeta

Location:
plugins/mymeta/trunk
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • plugins/mymeta/trunk/_public.php

    r2333 r2334  
    2525$core->tpl->addValue('MetaType',array('tplMyMeta','MetaType')); 
    2626$core->tpl->addValue('MyMetaTypePrompt',array('tplMyMeta','MyMetaTypePrompt')); 
    27 $core->tpl->addValue('EntryMyMetaValue',array('tplMyMeta','EntryMyMetaValue')); 
    2827$core->tpl->addValue('EntryMyMetaValue',array('tplMyMeta','EntryMyMetaValue')); 
    2928$core->tpl->addValue('MyMetaValue',array('tplMyMeta','MyMetaValue')); 
     
    267266 
    268267               if (sizeof($values)==1) { 
    269                     self::serveDocument('mymetas.html'); 
    270                } else {             
     268                    $tpl = ($mymeta->tpl_list=='')?'mymetas.html':$mymeta->tpl_list; 
     269                    if ($mymeta->url_list_enabled && $core->tpl->getFilePath($tpl)) { 
     270                         self::serveDocument($tpl); 
     271                    } else { 
     272                         self::p404(); 
     273                    } 
     274               } else { 
    271275                    $mymeta_value=$values[1]; 
    272276                    $_ctx->meta = $core->mymeta->dcmeta->getMeta($mymeta->id,null,$mymeta_value); 
    273                     if ($_ctx->meta->isEmpty()) { 
     277                    $tpl = ($mymeta->tpl_single=='')?'mymeta.html':$mymeta->tpl_single; 
     278                    if (!$_ctx->meta->isEmpty() && $mymeta->url_single_enabled && $core->tpl->getFilePath($tpl)) { 
     279                         self::serveDocument($tpl); 
     280                    } else { 
    274281                         self::p404(); 
    275                     } else { 
    276                          self::serveDocument('mymeta.html'); 
     282                         return; 
    277283                    } 
    278284               } 
  • plugins/mymeta/trunk/class.mymeta.php

    r2324 r2334  
    315315                    $inSection=true; 
    316316               } elseif ($meta->enabled) { 
    317                     if (!isset($post->post_type) || $meta->isEnabledFor($post->post_type)) { 
     317                    if (!isset($post) || $meta->isEnabledFor($post->post_type)) { 
    318318                         if (!$inSection) { 
    319319                              $res .= '<fieldset><legend>'.__('My Meta').'</legend>'; 
  • plugins/mymeta/trunk/class.mymetatypes.php

    r2333 r2334  
    4040     public $contexts; 
    4141     public $post_types; 
    42      public $template_list = null; 
    43      public $template_single = null; 
     42     public $tpl_list = ''; 
     43     public $url_list_enabled = true; 
     44     public $tpl_single = ''; 
     45     public $url_single_enabled = true; 
    4446 
    4547 
  • plugins/mymeta/trunk/index_edit.php

    r2324 r2334  
    2525require DC_ROOT.'/inc/admin/lib.pager.php'; 
    2626 
     27 
     28function filterTplFile($file,$default) { 
     29     $f = trim($file); 
     30     if (preg_match('#[/\\]#',$f) || $f == $default) 
     31          return ''; 
     32     else 
     33          return $f; 
     34} 
     35 
     36 
    2737if (!empty($_POST['mymeta_id'])) { 
    2838     $mymetaid = preg_replace('#[^a-zA-Z0-9_-]#','',$_POST['mymeta_id']); 
     
    3747          } 
    3848     } 
    39       
     49     $mymetaEntry->url_list_enabled = isset($_POST['enable_list']); 
     50     $mymetaEntry->url_single_enabled = isset($_POST['enable_single']); 
     51     $mymetaEntry->tpl_single = filterTplFile($_POST['single_tpl'],"mymeta.html"); 
     52     $mymetaEntry->tpl_list = filterTplFile($_POST['list_tpl'],"mymetas.html"); 
    4053      
    4154     $mymetaEntry->adminUpdate($_POST); 
    4255     $mymeta->update($mymetaEntry); 
    4356     $mymeta->store(); 
    44      http::redirect('plugin.php?p=mymeta'); 
     57     http::redirect($p_url.'&status=mmupd'); 
    4558     exit; 
    4659} 
     
    6679$type_label = array_search ($mymeta_type,$types); 
    6780if (!$type_label) 
    68      http::redirect('plugin.php?p=mymeta'); 
     81     http::redirect($p_url); 
    6982 
    7083 
     
    107120          </fieldset> 
    108121          <fieldset> 
     122               <legend><?php echo __('Metadata URLs'); ?></legend> 
     123                    <?php  
     124                    $base_url = $core->blog->url.$core->url->getBase("mymeta").'/'.$mymetaentry->id; 
     125                    $tpl_single = $mymetaentry->tpl_single; 
     126                    $tpl_list = $mymetaentry->tpl_list; 
     127                    echo  
     128                         '<p><label class="classic">'. 
     129                         form::checkbox(array('enable_list'),1,$mymetaentry->url_list_enabled). 
     130                         __('Enable metadata values list public page').'</label><br />'. 
     131                         '<label class="classic">'.__('List template file (leave empty for default mymetas.html)').' : '. 
     132                         form::field(array('list_tpl'), 40, 255, empty($tpl_list)?'mymetas.html':$tpl_list). 
     133                         '</label></p>'. 
     134                         '<p><label class="classic">'. 
     135                         form::checkbox(array('enable_single'),1,$mymetaentry->url_single_enabled). 
     136                         __('Enable single metadata value public page'). 
     137                         '</label><br />'. 
     138                         '<label class="classic">'.__('Single template file (leave empty for default mymeta.html)').' : '. 
     139                         form::field(array('single_tpl'), 40, 255, empty($tpl_single)?'mymeta.html':$tpl_single). 
     140                         '</label></p>'; ?> 
     141          </fieldset> 
     142          <fieldset> 
    109143               <legend><?php echo __('Metadata restrictions'); ?></legend> 
    110144               <p> 
  • plugins/mymeta/trunk/index_edit_section.php

    r2324 r2334  
    3535          $mymeta->store(); 
    3636     } 
    37      http::redirect('plugin.php?p=mymeta'); 
     37     http::redirect($p_url.'&status=secupd'); 
    3838     exit; 
    3939} 
     
    4444     $mymetasection=$mymeta->getByID($_REQUEST['id']); 
    4545     if (!($mymetasection instanceof myMetaSection)) { 
    46           http::redirect('plugin.php?p=mymeta'); 
     46          http::redirect($p_url); 
    4747          exit; 
    4848     } 
    4949 
    5050} else { 
    51      http::redirect('plugin.php?p=mymeta'); 
     51     http::redirect($p_url); 
    5252     exit; 
    5353} 
  • plugins/mymeta/trunk/index_home.php

    r2324 r2334  
    7777$combo_action[__('disable')] = 'disable'; 
    7878$combo_action[__('delete')] = 'delete'; 
     79 
     80$statuses = array( 
     81     'mmupd' => __('MyMeta has been successfully updated'), 
     82     'secupd' => __('Section has been successfully updated') 
     83); 
     84 
    7985?> 
    8086<html> 
     
    8894</head> 
    8995<body> 
    90  
     96<?php 
     97if (isset($_GET['status']) && in_array($_GET['status'], $statuses)) { 
     98     echo '<p class="message">'.$statuses[$_GET['status']].'</p>'; 
     99} 
     100?> 
    91101<h2><?php echo html::escapeHTML($core->blog->name); ?> &gt; 
    92102<?php echo __('My Metadata').' > '.__('Main menu'); ?></h2> 
     
    141151          '<td class="minimal">'.form::checkbox(array('entries[]'),$meta->id).'</td>'. 
    142152          '<td class="nowrap minimal"><a href="plugin.php?p=mymeta&amp;m=editsection&amp;id='.$meta->id.'">'. 
    143           '<img src="images/menu/edit.png" alt="'.__('edit Metadata').'" /></td>'. 
     153          '<img src="images/menu/edit.png" alt="'.__('edit Metadata').'" /></a></td>'. 
    144154          '<td class="nowrap" colspan="6">'. 
    145155          '<strong>Section: '.html::escapeHTML($meta->prompt).'</strong></td>'. 
     
    162172          '<td class="minimal">'.form::checkbox(array('entries[]'),$meta->id).'</td>'. 
    163173          '<td class="nowrap minimal"><a href="plugin.php?p=mymeta&amp;m=edit&amp;id='.$meta->id.'">'. 
    164           '<img src="images/menu/edit.png" alt="'.__('edit Metadata').'" /></td>'. 
     174          '<img src="images/menu/edit.png" alt="'.__('edit Metadata').'" /></a></td>'. 
    165175          '<td class="nowrap"><a href="plugin.php?p=mymeta&amp;m=view&amp;id='.$meta->id.'">'. 
    166176          html::escapeHTML($meta->id).'</a></td>'. 
  • plugins/mymeta/trunk/index_view.php

    r2324 r2334  
    2525require DC_ROOT.'/inc/admin/lib.pager.php'; 
    2626if (empty($_GET['id'])) { 
    27      http::redirect('plugin.php?p=mymeta'); 
     27     http::redirect($p_url); 
    2828     exit; 
    2929} 
     
    3131$mymetaEntry = $mymeta->getByID($_GET['id']); 
    3232if ($mymetaEntry == null) { 
    33      http::redirect('plugin.php?p=mymeta'); 
     33     http::redirect($p_url); 
    3434     exit; 
    3535} 
     
    9090     } 
    9191} 
     92$statuses = array( 
     93     'valchg' => __('Value has been successfully changed') 
     94); 
    9295 
    9396?> 
     
    99102<body> 
    100103<?php 
     104 
     105if (isset($_GET['status']) && array_key_exists($_GET['status'], $statuses)) { 
     106     echo '<p class="message">'.$statuses[$_GET['status']].'</p>'; 
     107} 
     108echo '<h2>'.html::escapeHTML($core->blog->name).'&gt;'.__('My Metadata').' &gt; </h2>'; 
     109 
    101110echo '<p><a href="plugin.php?p=mymeta" class="multi-part">'.__('My metadata').'</a></p>'; 
    102111echo '<div class="multi-part" id="mymeta" title="'.__('Metadata').' : '.html::escapeHTML($mymetaEntry->id).'">'; 
  • plugins/mymeta/trunk/index_view_posts.php

    r2324 r2334  
    4848     try { 
    4949          if ($core->meta->updateMeta($value,$new_value,$mymetaEntry->id)) { 
    50                http::redirect($p_url.'&m=view&id='.$mymetaEntry->id); 
     50               http::redirect($p_url.'&m=view&id='.$mymetaEntry->id.'&status=valchg'); 
    5151          } 
    5252     } catch (Exception $e) { 
  • plugins/mymeta/trunk/locales/_pot/main.pot

    r2324 r2334  
    88"Project-Id-Version: Dotclear 2 mymeta module\n" 
    99"Report-Msgid-Bugs-To: \n" 
    10 "POT-Creation-Date: 2010-06-07 23:10+0200\n" 
     10"POT-Creation-Date: 2010-06-08 17:17+0200\n" 
    1111"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" 
    1212"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" 
     
    3232msgstr "" 
    3333 
    34 #: plugins/mymeta/_admin.php:27 plugins/mymeta/index_edit.php:81 
    35 #: plugins/mymeta/index_edit_section.php:65 plugins/mymeta/index_home.php:82 
    36 #: plugins/mymeta/index_home.php:92 plugins/mymeta/index_home.php:93 
     34#: plugins/mymeta/_admin.php:27 plugins/mymeta/index_edit.php:94 
     35#: plugins/mymeta/index_edit_section.php:65 plugins/mymeta/index_home.php:88 
     36#: plugins/mymeta/index_home.php:102 plugins/mymeta/index_home.php:103 
     37#: plugins/mymeta/index_view.php:108 
    3738msgid "My Metadata" 
    3839msgstr "" 
     
    5455msgstr "" 
    5556 
    56 #: plugins/mymeta/class.mymetatypes.php:222 
     57#: plugins/mymeta/class.mymetatypes.php:226 
    5758msgid "String" 
    5859msgstr "" 
    5960 
    60 #: plugins/mymeta/class.mymetatypes.php:235 
     61#: plugins/mymeta/class.mymetatypes.php:239 
    6162msgid "Items List" 
    6263msgstr "" 
    6364 
    64 #: plugins/mymeta/class.mymetatypes.php:281 
     65#: plugins/mymeta/class.mymetatypes.php:288 
    6566msgid "Values : enter 1 value per line (syntax for each line : ID: description)" 
    6667msgstr "" 
    6768 
    68 #: plugins/mymeta/class.mymetatypes.php:304 
     69#: plugins/mymeta/class.mymetatypes.php:311 
    6970msgid "Checkbox" 
    7071msgstr "" 
    7172 
    72 #: plugins/mymeta/index_edit.php:49 
     73#: plugins/mymeta/index_edit.php:62 
    7374msgid "Edit Metadata" 
    7475msgstr "" 
    7576 
    76 #: plugins/mymeta/index_edit.php:60 plugins/mymeta/index_home.php:96 
     77#: plugins/mymeta/index_edit.php:73 plugins/mymeta/index_home.php:106 
    7778msgid "New Metadata" 
    7879msgstr "" 
    7980 
    80 #: plugins/mymeta/index_edit.php:74 plugins/mymeta/index_edit.php:83 
     81#: plugins/mymeta/index_edit.php:87 plugins/mymeta/index_edit.php:96 
    8182#: plugins/mymeta/index_edit_section.php:58 
    82 #: plugins/mymeta/index_edit_section.php:67 plugins/mymeta/index_view.php:96 
    83 #: plugins/mymeta/index_view.php:101 plugins/mymeta/index_view_posts.php:132 
     83#: plugins/mymeta/index_edit_section.php:67 plugins/mymeta/index_view.php:99 
     84#: plugins/mymeta/index_view.php:110 plugins/mymeta/index_view_posts.php:146 
    8485msgid "My metadata" 
    8586msgstr "" 
    8687 
    87 #: plugins/mymeta/index_edit.php:90 plugins/mymeta/index_edit_section.php:74 
     88#: plugins/mymeta/index_edit.php:103 plugins/mymeta/index_edit_section.php:74 
    8889msgid "Metadata definition" 
    8990msgstr "" 
    9091 
    91 #: plugins/mymeta/index_edit.php:92 
     92#: plugins/mymeta/index_edit.php:105 
    9293msgid "Identifier (as stored in meta_type in database):" 
    9394msgstr "" 
    9495 
    95 #: plugins/mymeta/index_edit.php:97 
     96#: plugins/mymeta/index_edit.php:110 
    9697msgid "Metadata type" 
    9798msgstr "" 
    9899 
    99 #: plugins/mymeta/index_edit.php:102 plugins/mymeta/index_home.php:120 
     100#: plugins/mymeta/index_edit.php:115 plugins/mymeta/index_home.php:130 
    100101msgid "Prompt" 
    101102msgstr "" 
    102103 
    103 #: plugins/mymeta/index_edit.php:109 
     104#: plugins/mymeta/index_edit.php:122 
     105msgid "Metadata URLs" 
     106msgstr "" 
     107 
     108#: plugins/mymeta/index_edit.php:130 
     109msgid "Enable metadata values list public page" 
     110msgstr "" 
     111 
     112#: plugins/mymeta/index_edit.php:131 
     113msgid "List template" 
     114msgstr "" 
     115 
     116#: plugins/mymeta/index_edit.php:136 
     117msgid "Enable single metadata value public page" 
     118msgstr "" 
     119 
     120#: plugins/mymeta/index_edit.php:138 
     121msgid "Single template" 
     122msgstr "" 
     123 
     124#: plugins/mymeta/index_edit.php:143 
    104125msgid "Metadata restrictions" 
    105126msgstr "" 
    106127 
    107 #: plugins/mymeta/index_edit.php:113 
     128#: plugins/mymeta/index_edit.php:147 
    108129msgid "Display meta field for any post type" 
    109130msgstr "" 
    110131 
    111 #: plugins/mymeta/index_edit.php:115 
    112 msgid " Restrict to the following post types :" 
     132#: plugins/mymeta/index_edit.php:149 
     133msgid "Restrict to the following post types :" 
    113134msgstr "" 
    114135 
     
    125146msgstr "" 
    126147 
    127 #: plugins/mymeta/index_home.php:92 
     148#: plugins/mymeta/index_home.php:81 
     149msgid "MyMeta has been successfully updated" 
     150msgstr "" 
     151 
     152#: plugins/mymeta/index_home.php:82 
     153msgid "Section has been successfully updated" 
     154msgstr "" 
     155 
     156#: plugins/mymeta/index_home.php:102 
    128157msgid "Main menu" 
    129158msgstr "" 
    130159 
    131 #: plugins/mymeta/index_home.php:98 
     160#: plugins/mymeta/index_home.php:108 
    132161msgid "Create Metadata" 
    133162msgstr "" 
    134163 
    135 #: plugins/mymeta/index_home.php:106 
     164#: plugins/mymeta/index_home.php:116 
    136165msgid "New section" 
    137166msgstr "" 
    138167 
    139 #: plugins/mymeta/index_home.php:108 
     168#: plugins/mymeta/index_home.php:118 
    140169msgid "Create section" 
    141170msgstr "" 
    142171 
    143 #: plugins/mymeta/index_home.php:118 
     172#: plugins/mymeta/index_home.php:128 
    144173msgid "ID" 
    145174msgstr "" 
    146175 
    147 #: plugins/mymeta/index_home.php:121 
     176#: plugins/mymeta/index_home.php:131 
    148177msgid "Post types" 
    149178msgstr "" 
    150179 
    151 #: plugins/mymeta/index_home.php:122 
     180#: plugins/mymeta/index_home.php:132 
    152181msgid "Number of Posts" 
    153182msgstr "" 
    154183 
    155 #: plugins/mymeta/index_home.php:155 
     184#: plugins/mymeta/index_home.php:153 plugins/mymeta/index_home.php:174 
     185msgid "edit Metadata" 
     186msgstr "" 
     187 
     188#: plugins/mymeta/index_home.php:167 
    156189msgid "All" 
    157190msgstr "" 
    158191 
    159 #: plugins/mymeta/index_home.php:187 
     192#: plugins/mymeta/index_home.php:200 
    160193msgid "Selected metas action:" 
    161194msgstr "" 
     
    169202msgstr "" 
    170203 
    171 #: plugins/mymeta/index_view.php:102 plugins/mymeta/index_view_posts.php:133 
     204#: plugins/mymeta/index_view.php:93 
     205msgid "Value has been successfully changed" 
     206msgstr "" 
     207 
     208#: plugins/mymeta/index_view.php:111 plugins/mymeta/index_view_posts.php:147 
    172209msgid "Metadata" 
    173210msgstr "" 
    174211 
    175 #: plugins/mymeta/index_view.php:108 
     212#: plugins/mymeta/index_view.php:117 
    176213msgid "Values" 
    177214msgstr "" 
    178215 
    179 #: plugins/mymeta/index_view_posts.php:125 
     216#: plugins/mymeta/index_view_posts.php:139 
    180217msgid "Edit MyMeta" 
    181218msgstr "" 
    182219 
    183 #: plugins/mymeta/index_view_posts.php:129 
     220#: plugins/mymeta/index_view_posts.php:143 
    184221msgid "MyMeta has been successfully renamed" 
    185222msgstr "" 
    186223 
    187 #: plugins/mymeta/index_view_posts.php:134 
     224#: plugins/mymeta/index_view_posts.php:148 
    188225msgid "MyMeta Posts" 
    189226msgstr "" 
    190227 
    191 #: plugins/mymeta/index_view_posts.php:138 
     228#: plugins/mymeta/index_view_posts.php:152 
    192229msgid "Current value :" 
    193230msgstr "" 
    194231 
    195 #: plugins/mymeta/index_view_posts.php:142 
     232#: plugins/mymeta/index_view_posts.php:156 
    196233msgid "Change MyMeta value" 
    197234msgstr "" 
  • plugins/mymeta/trunk/locales/fr/main.po

    r2324 r2334  
    55"Project-Id-Version: \n" 
    66"Report-Msgid-Bugs-To: \n" 
    7 "POT-Creation-Date: 2010-06-07 23:10+0200\n" 
     7"POT-Creation-Date: 2010-06-08 17:17+0200\n" 
    88"PO-Revision-Date: \n" 
    99"Last-Translator: Kozlika <kozlika@free.fr>\n" 
     
    3838 
    3939msgid "Mymeta errors :" 
    40 msgstr "Erreurs Mymeta" 
     40msgstr "Erreurs Mymeta :" 
    4141 
    4242msgid "String" 
     
    7373msgstr "Invite" 
    7474 
    75 #, fuzzy 
     75msgid "Metadata URLs" 
     76msgstr "URL des Métadonnées" 
     77 
     78msgid "Enable metadata values list public page" 
     79msgstr "Activer les pages publiques des listes de valeurs de la métadonnée" 
     80 
     81msgid "List template file (leave empty for default mymetas.html)" 
     82msgstr "Fichier de template pour les listes (laisser vide pour mymetas.html)" 
     83 
     84msgid "Enable single metadata value public page" 
     85msgstr "Activer les pages publiques des bilelts d'une valeur donnée de la métadonnée" 
     86 
     87msgid "Single template file (leave empty for default mymeta.html)" 
     88msgstr "Fichier de template pour les listes de billets (laisser vide pour mymeta.html)" 
     89 
     90 
    7691msgid "Metadata restrictions" 
    7792msgstr "Restrictions sur la métadonnée" 
     
    92107msgstr "désactiver" 
    93108 
     109 
     110msgid "MyMeta has been successfully updated" 
     111msgstr "La métadonnée a été mise à jour avec succès" 
     112 
     113msgid "Section has been successfully updated" 
     114msgstr "La section a été mise à jour avec succès" 
     115 
    94116msgid "Main menu" 
    95117msgstr "Menu principal" 
     
    108130 
    109131msgid "Post types" 
    110 msgstr "" 
     132msgstr "Types de billets" 
    111133 
    112134msgid "Number of Posts" 
    113135msgstr "Nombre de billets" 
     136 
     137 
     138msgid "edit Metadata" 
     139msgstr "Editer la métadonnée" 
    114140 
    115141msgid "All" 
     
    125151msgstr "Nombre de billets" 
    126152 
     153#, fuzzy 
     154msgid "Value has been successfully changed" 
     155msgstr "La métadonnée a été renommée avec succès" 
     156 
    127157msgid "Metadata" 
    128158msgstr "Métadonnées" 
     
    132162 
    133163msgid "Edit MyMeta" 
    134 msgstr "Editer la métadonnée" 
     164msgstr "Editer les métadonnées" 
    135165 
    136166msgid "MyMeta has been successfully renamed" 
Note: See TracChangeset for help on using the changeset viewer.

Sites map