Dotclear


Ignore:
Timestamp:
11/27/13 16:32:38 (12 years ago)
Author:
Dsls
Branch:
twig
Children:
2612:1537212bd291, 2613:014098e27ea0
Parents:
2468:d7fda5a0bd39 (diff), 2589:3d427735ca70 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Fusion avec default

Location:
inc/public
Files:
19 deleted
2 edited

Legend:

Unmodified
Added
Removed
  • inc/public/lib.urlhandlers.php

    r2313 r2593  
    1515{ 
    1616     public $args; 
    17       
     17 
    1818     public function getURLFor($type,$value='') { 
    1919          $core =& $GLOBALS['core']; 
     
    3030          return $url; 
    3131     } 
    32       
     32 
    3333     public function register($type,$url,$representation,$handler) 
    3434     { 
     
    3838          parent::register($t[0],$t[1],$t[2],$t[3]); 
    3939     } 
    40       
     40 
    4141     public static function p404() 
    4242     { 
    4343          throw new Exception ("Page not found",404); 
    4444     } 
    45       
     45 
    4646     public static function default404($args,$type,$e) 
    4747     { 
     
    5151          $_ctx =& $GLOBALS['_ctx']; 
    5252          $core = $GLOBALS['core']; 
    53            
     53 
    5454          header('Content-Type: text/html; charset=UTF-8'); 
    5555          http::head(404,'Not Found'); 
     
    5757          $_ctx->current_tpl = '404.html'; 
    5858          $_ctx->content_type = 'text/html'; 
    59            
     59 
    6060          echo $core->tpl->getData($_ctx->current_tpl); 
    61            
     61 
    6262          # --BEHAVIOR-- publicAfterDocument 
    6363          $core->callBehavior('publicAfterDocument',$core); 
    6464          exit; 
    6565     } 
    66       
     66 
    6767     protected static function getPageNumber(&$args) 
    6868     { 
     
    7474               } 
    7575          } 
    76            
     76 
    7777          return false; 
    7878     } 
    79       
     79 
    8080     protected static function serveDocument($tpl,$content_type='text/html',$http_cache=true,$http_etag=true) 
    8181     { 
    8282          $_ctx =& $GLOBALS['_ctx']; 
    8383          $core =& $GLOBALS['core']; 
    84            
     84 
    8585          if ($_ctx->nb_entry_per_page === null) { 
    8686               $_ctx->nb_entry_per_page = $core->blog->settings->system->nb_post_per_page; 
    8787          } 
    88            
     88          if ($_ctx->nb_entry_first_page === null) { 
     89               $_ctx->nb_entry_first_page = $_ctx->nb_entry_per_page; 
     90          } 
     91 
    8992          $tpl_file = $core->tpl->getFilePath($tpl); 
    90            
     93 
    9194          if (!$tpl_file) { 
    9295               throw new Exception('Unable to find template '); 
    9396          } 
    94            
     97 
    9598          $result = new ArrayObject; 
    96            
     99 
    97100          $_ctx->current_tpl = $tpl; 
    98101          $_ctx->content_type = $content_type; 
     
    100103          $_ctx->http_etag = $http_etag; 
    101104          $core->callBehavior('urlHandlerBeforeGetData',$_ctx); 
    102            
     105 
    103106          if ($_ctx->http_cache) { 
    104107               $GLOBALS['mod_files'][] = $tpl_file; 
     
    111114          $result['tpl'] = $_ctx->current_tpl; 
    112115          $result['blogupddt'] = $core->blog->upddt; 
    113            
     116 
    114117          # --BEHAVIOR-- urlHandlerServeDocument 
    115118          $core->callBehavior('urlHandlerServeDocument',$result); 
    116            
     119 
    117120          if ($_ctx->http_cache && $_ctx->http_etag) { 
    118121               http::etag($result['content'],http::getSelfURI()); 
     
    120123          echo $result['content']; 
    121124     } 
    122       
     125 
    123126     public function getDocument() 
    124127     { 
    125128          $core =& $GLOBALS['core']; 
    126            
     129 
    127130          $type = $args = ''; 
    128            
     131 
    129132          if ($this->mode == 'path_info') 
    130133          { 
     
    134137          { 
    135138               $part = ''; 
    136                 
     139 
    137140               $qs = $this->parseQueryString(); 
    138                 
     141 
    139142               # Recreates some _GET and _REQUEST pairs 
    140143               if (!empty($qs)) 
     
    147150                    $_GET = $qs; 
    148151                    $_REQUEST = array_merge($qs,$_REQUEST); 
    149                      
     152 
    150153                    list($k,$v) = each($qs); 
    151154                    if ($v === null) { 
     
    156159               } 
    157160          } 
    158            
     161 
    159162          $_SERVER['URL_REQUEST_PART'] = $part; 
    160            
     163 
    161164          $this->getArgs($part,$type,$this->args); 
    162            
     165 
    163166          # --BEHAVIOR-- urlHandlerGetArgsDocument 
    164167          $core->callBehavior('urlHandlerGetArgsDocument',$this); 
    165            
     168 
    166169          if (!$type) 
    167170          { 
     
    175178          } 
    176179     } 
    177       
     180 
    178181     public static function home($args) 
    179182     { 
    180183          $n = self::getPageNumber($args); 
    181            
     184 
    182185          if ($args && !$n) 
    183186          { 
    184                # "Then specified URL went unrecognized by all URL handlers and  
     187               # "Then specified URL went unrecognized by all URL handlers and 
    185188               # defaults to the home page, but is not a page number. 
    186189               self::p404(); 
     
    188191          else 
    189192          { 
     193               $_ctx =& $GLOBALS['_ctx']; 
    190194               $core =& $GLOBALS['core']; 
    191                 
     195 
    192196               if ($n) { 
    193197                    $GLOBALS['_page_number'] = $n; 
    194198                    $core->url->type = $n > 1 ? 'default-page' : 'default'; 
    195199               } 
    196                 
     200 
    197201               if (empty($_GET['q'])) { 
     202                    if ($core->blog->settings->system->nb_post_for_home !== null) { 
     203                         $_ctx->nb_entry_first_page = $core->blog->settings->system->nb_post_for_home; 
     204                    } 
    198205                    self::serveDocument('home.html'); 
    199206                    $core->blog->publishScheduledEntries(); 
     
    203210          } 
    204211     } 
    205       
     212 
    206213     public static function search() 
    207214     { 
    208215          $_ctx =& $GLOBALS['_ctx']; 
    209216          $core =& $GLOBALS['core']; 
    210            
     217 
    211218          $core->url->type='search'; 
    212            
     219 
    213220          $GLOBALS['_search'] = !empty($_GET['q']) ? rawurldecode($_GET['q']) : ''; 
    214221          if ($GLOBALS['_search']) { 
     
    217224               $GLOBALS['_search_count'] = $core->blog->getPosts($params,true)->f(0); 
    218225          } 
    219            
     226 
    220227          self::serveDocument('search.html'); 
    221228     } 
    222       
     229 
    223230     public static function lang($args) 
    224231     { 
    225232          $_ctx =& $GLOBALS['_ctx']; 
    226233          $core =& $GLOBALS['core']; 
    227            
     234 
    228235          $n = self::getPageNumber($args); 
    229236          $params = new ArrayObject(array( 
    230237               'lang' => $args)); 
    231            
     238 
    232239          $core->callBehavior('publicLangBeforeGetLangs',$params,$args); 
    233            
     240 
    234241          $_ctx->langs = $core->blog->getLangs($params); 
    235            
     242 
    236243          if ($_ctx->langs->isEmpty()) { 
    237244               # The specified language does not exist. 
     
    247254          } 
    248255     } 
    249       
     256 
    250257     public static function category($args) 
    251258     { 
    252259          $_ctx =& $GLOBALS['_ctx']; 
    253260          $core =& $GLOBALS['core']; 
    254            
     261 
    255262          $n = self::getPageNumber($args); 
    256            
     263 
    257264          if ($args == '' && !$n) { 
    258265               # No category was specified. 
     
    265272                    'post_type' => 'post', 
    266273                    'without_empty' => false)); 
    267                 
     274 
    268275               $core->callBehavior('publicCategoryBeforeGetCategories',$params,$args); 
    269                 
     276 
    270277               $_ctx->categories = $core->blog->getCategories($params); 
    271                 
     278 
    272279               if ($_ctx->categories->isEmpty()) { 
    273280                    # The specified category does no exist. 
     
    283290          } 
    284291     } 
    285       
     292 
    286293     public static function archive($args) 
    287294     { 
    288295          $_ctx =& $GLOBALS['_ctx']; 
    289296          $core =& $GLOBALS['core']; 
    290            
     297 
    291298          $year = $month = $cat_url = null; 
    292299          # Nothing or year and month 
     
    301308                    'month' => $m[2], 
    302309                    'type' => 'month')); 
    303                 
     310 
    304311               $core->callBehavior('publicArchiveBeforeGetDates',$params,$args); 
    305                 
     312 
    306313               $_ctx->archives = $core->blog->getDates($params); 
    307                 
     314 
    308315               if ($_ctx->archives->isEmpty()) { 
    309316                    # There is no entries for the specified period. 
     
    320327          } 
    321328     } 
    322       
     329 
    323330     public static function post($args) 
    324331     { 
     
    331338               $_ctx =& $GLOBALS['_ctx']; 
    332339               $core =& $GLOBALS['core']; 
    333                 
     340 
    334341               $core->blog->withoutPassword(false); 
    335                 
     342 
    336343               $params = new ArrayObject(array( 
    337344                    'post_url' => $args)); 
    338                 
     345 
    339346               $core->callBehavior('publicPostBeforeGetPosts',$params,$args); 
    340347 
    341348               $_ctx->posts = $core->blog->getPosts($params); 
    342                 
     349 
    343350               $_ctx->comment_preview = new ArrayObject(); 
    344351               $_ctx->comment_preview['content'] = ''; 
     
    349356               $_ctx->comment_preview['preview'] = false; 
    350357               $_ctx->comment_preview['remember'] = false; 
    351                 
     358 
    352359               $core->blog->withoutPassword(true); 
    353                 
     360 
    354361               if ($_ctx->posts->isEmpty()) 
    355362               { 
     
    361368                    $post_id = $_ctx->posts->post_id; 
    362369                    $post_password = $_ctx->posts->post_password; 
    363                      
     370 
    364371                    # Password protected entry 
    365372                    if ($post_password != '' && !$_ctx->preview) 
     
    371378                              $pwd_cookie = array(); 
    372379                         } 
    373                           
     380 
    374381                         # Check for match 
    375382                         if ((!empty($_POST['password']) && $_POST['password'] == $post_password) 
     
    385392                         } 
    386393                    } 
    387                      
     394 
    388395                    $post_comment = 
    389396                         isset($_POST['c_name']) && isset($_POST['c_mail']) && 
    390397                         isset($_POST['c_site']) && isset($_POST['c_content']) && 
    391398                         $_ctx->posts->commentsActive(); 
    392                      
     399 
    393400                    # Posting a comment 
    394401                    if ($post_comment) 
     
    402409                              exit; 
    403410                         } 
    404                           
     411 
    405412                         $name = $_POST['c_name']; 
    406413                         $mail = $_POST['c_mail']; 
     
    408415                         $content = $_POST['c_content']; 
    409416                         $preview = !empty($_POST['preview']); 
    410                           
     417 
    411418                         if ($content != '') 
    412419                         { 
    413                               if ($core->blog->settings->system->wiki_comments) { 
    414                                    $core->initWikiComment(); 
     420                              # --BEHAVIOR-- publicBeforeCommentTransform 
     421                              $buffer = $core->callBehavior('publicBeforeCommentTransform',$content); 
     422                              if ($buffer != '') { 
     423                                   $content = $buffer; 
    415424                              } else { 
    416                                    $core->initWikiSimpleComment(); 
     425                                   if ($core->blog->settings->system->wiki_comments) { 
     426                                        $core->initWikiComment(); 
     427                                   } else { 
     428                                        $core->initWikiSimpleComment(); 
     429                                   } 
     430                                   $content = $core->wikiTransform($content); 
    417431                              } 
    418                               $content = $core->wikiTransform($content); 
    419432                              $content = $core->HTMLfilter($content); 
    420433                         } 
    421                           
     434 
    422435                         $_ctx->comment_preview['content'] = $content; 
    423436                         $_ctx->comment_preview['rawcontent'] = $_POST['c_content']; 
     
    425438                         $_ctx->comment_preview['mail'] = $mail; 
    426439                         $_ctx->comment_preview['site'] = $site; 
    427                           
     440 
    428441                         if ($preview) 
    429442                         { 
    430443                              # --BEHAVIOR-- publicBeforeCommentPreview 
    431444                              $core->callBehavior('publicBeforeCommentPreview',$_ctx->comment_preview); 
    432                                
     445 
    433446                              $_ctx->comment_preview['preview'] = true; 
    434447                         } 
     
    444457                              $cur->comment_status = $core->blog->settings->system->comments_pub ? 1 : -1; 
    445458                              $cur->comment_ip = http::realIP(); 
    446                                
     459 
    447460                              $redir = $_ctx->posts->getURL(); 
    448461                              $redir .= $core->blog->settings->system->url_scan == 'query_string' ? '&' : '?'; 
    449                                
     462 
    450463                              try 
    451464                              { 
     
    453466                                        throw new Exception(__('You must provide a valid email address.')); 
    454467                                   } 
    455                                     
     468 
    456469                                   # --BEHAVIOR-- publicBeforeCommentCreate 
    457470                                   $core->callBehavior('publicBeforeCommentCreate',$cur); 
    458                                    if ($cur->post_id) {                          
     471                                   if ($cur->post_id) { 
    459472                                        $comment_id = $core->blog->addComment($cur); 
    460                                          
     473 
    461474                                        # --BEHAVIOR-- publicAfterCommentCreate 
    462475                                        $core->callBehavior('publicAfterCommentCreate',$cur,$comment_id); 
    463476                                   } 
    464                                     
     477 
    465478                                   if ($cur->comment_status == 1) { 
    466479                                        $redir_arg = 'pub=1'; 
     
    468481                                        $redir_arg = 'pub=0'; 
    469482                                   } 
    470                                     
     483 
    471484                                   header('Location: '.$redir.$redir_arg); 
    472485                              } 
     
    478491                         } 
    479492                    } 
    480                      
     493 
    481494                    # The entry 
    482495                    if ($_ctx->posts->trackbacksActive()) { 
     
    487500          } 
    488501     } 
    489       
     502 
    490503     public static function preview($args) 
    491504     { 
    492505          $core = $GLOBALS['core']; 
    493506          $_ctx = $GLOBALS['_ctx']; 
    494            
     507 
    495508          if (!preg_match('#^(.+?)/([0-9a-z]{40})/(.+?)$#',$args,$m)) { 
    496509               # The specified Preview URL is malformed. 
     
    513526          } 
    514527     } 
    515       
     528 
    516529     public static function feed($args) 
    517530     { 
     
    521534          $post_id = null; 
    522535          $subtitle = ''; 
    523            
     536 
    524537          $mime = 'application/xml'; 
    525            
     538 
    526539          $_ctx =& $GLOBALS['_ctx']; 
    527540          $core =& $GLOBALS['core']; 
    528            
     541 
    529542          if (preg_match('!^([a-z]{2}(-[a-z]{2})?)/(.*)$!',$args,$m)) { 
    530543               $params = new ArrayObject(array('lang' => $m[1])); 
    531                 
     544 
    532545               $args = $m[3]; 
    533                 
     546 
    534547               $core->callBehavior('publicFeedBeforeGetLangs',$params,$args); 
    535                 
     548 
    536549               $_ctx->langs = $core->blog->getLangs($params); 
    537                 
     550 
    538551               if ($_ctx->langs->isEmpty()) { 
    539552                    # The specified language does not exist. 
     
    544557               } 
    545558          } 
    546            
     559 
    547560          if (preg_match('#^rss2/xslt$#',$args,$m)) 
    548561          { 
     
    573586               return; 
    574587          } 
    575            
     588 
    576589          if ($cat_url) 
    577590          { 
     
    579592                    'cat_url' => $cat_url, 
    580593                    'post_type' => 'post')); 
    581                 
     594 
    582595               $core->callBehavior('publicFeedBeforeGetCategories',$params,$args); 
    583                 
     596 
    584597               $_ctx->categories = $core->blog->getCategories($params); 
    585                 
     598 
    586599               if ($_ctx->categories->isEmpty()) { 
    587600                    # The specified category does no exist. 
     
    589602                    return; 
    590603               } 
    591                 
     604 
    592605               $subtitle = ' - '.$_ctx->categories->cat_title; 
    593606          } 
     
    597610                    'post_id' => $post_id, 
    598611                    'post_type' => '')); 
    599                      
     612 
    600613               $core->callBehavior('publicFeedBeforeGetPosts',$params,$args); 
    601                 
     614 
    602615               $_ctx->posts = $core->blog->getPosts($params); 
    603                 
     616 
    604617               if ($_ctx->posts->isEmpty()) { 
    605618                    # The specified post does not exist. 
     
    607620                    return; 
    608621               } 
    609                 
     622 
    610623               $subtitle = ' - '.$_ctx->posts->post_title; 
    611624          } 
    612            
     625 
    613626          $tpl = $type; 
    614627          if ($comments) { 
     
    620633          } 
    621634          $tpl .= '.xml'; 
    622            
     635 
    623636          if ($type == 'atom') { 
    624637               $mime = 'application/atom+xml'; 
    625638          } 
    626            
     639 
    627640          $_ctx->feed_subtitle = $subtitle; 
    628            
     641 
    629642          header('X-Robots-Tag: '.context::robotsPolicy($core->blog->settings->system->robots_policy,'')); 
    630643          self::serveDocument($tpl,$mime); 
     
    633646          } 
    634647     } 
    635       
     648 
    636649     public static function trackback($args) 
    637650     { 
     
    644657          } 
    645658     } 
    646       
     659 
    647660     public static function rsd($args) 
    648661     { 
    649662          $core =& $GLOBALS['core']; 
    650663          http::cache($GLOBALS['mod_files'],$GLOBALS['mod_ts']); 
    651            
     664 
    652665          header('Content-Type: text/xml; charset=UTF-8'); 
    653666          echo 
     
    658671          "  <engineLink>http://www.dotclear.org/</engineLink>\n". 
    659672          '  <homePageLink>'.html::escapeHTML($core->blog->url)."</homePageLink>\n"; 
    660            
     673 
    661674          if ($core->blog->settings->system->enable_xmlrpc) 
    662675          { 
    663676               $u = sprintf(DC_XMLRPC_URL,$core->blog->url,$core->blog->id); 
    664                 
     677 
    665678               echo 
    666679               "  <apis>\n". 
     
    671684               "  </apis>\n"; 
    672685          } 
    673            
     686 
    674687          echo 
    675688          "</service>\n". 
    676689          "</rsd>\n"; 
    677690     } 
    678       
     691 
    679692     public static function xmlrpc($args) 
    680693     { 
     
    685698     } 
    686699} 
    687 ?> 
  • inc/public/prepend.php

    r2313 r2593  
    101101     } 
    102102} 
    103       
     103 
    104104# If theme doesn't exist, stop everything 
    105105if (!$core->themes->moduleExists($__theme)) { 
     
    134134     $__theme_tpl_path[] = $core->blog->themes_path.'/'.$__parent_theme.'/tpl'; 
    135135} 
    136  
    137 $core->tpl->setPath( 
    138      $__theme_tpl_path, 
    139      dirname(__FILE__).'/default-templates', 
    140      $core->tpl->getPath()); 
    141  
     136$tplset = $core->themes->moduleInfo($core->blog->settings->system->theme,'tplset'); 
     137if (!empty($tplset) && is_dir(dirname(__FILE__).'/default-templates/'.$tplset)) { 
     138     $core->tpl->setPath( 
     139          $__theme_tpl_path, 
     140          dirname(__FILE__).'/default-templates/'.$tplset, 
     141          $core->tpl->getPath()); 
     142} else { 
     143     $core->tpl->setPath( 
     144          $__theme_tpl_path, 
     145          $core->tpl->getPath()); 
     146} 
    142147$core->url->mode = $core->blog->settings->system->url_scan; 
    143148 
     
    145150     # --BEHAVIOR-- publicBeforeDocument 
    146151     $core->callBehavior('publicBeforeDocument',$core); 
    147       
     152 
    148153     $core->url->getDocument(); 
    149       
     154 
    150155     # --BEHAVIOR-- publicAfterDocument 
    151156     $core->callBehavior('publicAfterDocument',$core); 
     
    155160          ,660); 
    156161} 
    157 ?> 
Note: See TracChangeset for help on using the changeset viewer.

Sites map