Development

Changeset 14249

You must first sign up to be able to contribute.

Changeset 14249

Show
Ignore:
Timestamp:
12/22/08 17:25:22 (4 years ago)
Author:
johnwards
Message:

First go at 1.2 compatablity

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • plugins/sfXSLTViewPlugin/trunk/lib/sfArray2XML.php

    r12290 r14249  
    11<?php 
    2  
     2sfContext::getInstance()->getConfiguration()->loadHelpers('Helper'); 
     3  
     4use_helper('Date'); 
    35/** 
    46* associative array to xml transformation class 
     
    159161        $newKey = $key; 
    160162      } 
    161  
     163     
    162164      if ( strpos($newKey, ' ') !== False || $newKey=='') 
    163165      { 
     
    165167        continue; 
    166168      } 
    167  
     169      //If key is not alpha numeric 
     170      if(!preg_match('|^\w+$|', $newKey)){ 
     171        // Bad key name, skip this entry 
     172        continue; 
     173      } 
     174       
    168175      $node = $this->doc->createElement($newKey); 
     176       
    169177      $append=false; 
    170178      if (is_array($val)){ 
    171         $this->addArray($arr[$key], $node, $key); 
     179        $this->addArray($arr[$key], $node, $newKey); 
    172180        $append=true; 
    173181      } 
     
    186194      } 
    187195      elseif(is_string($val)){ 
    188         $nodeText = $this->doc->createCDATASection($val); 
    189         $node->appendChild($nodeText); 
    190         $append=true; 
     196        if(isValidDateTime($val)){ 
     197          $ts = strtotime($val); 
     198          $timeinwords = distance_of_time_in_words($ts); 
     199          $nodeText = $this->doc->createCDATASection($val); 
     200          $node->setAttribute("timeinwords", $timeinwords); 
     201          $node->setAttribute("ts", $ts); 
     202          $node->setAttribute("d", date("d",$ts)); 
     203          $node->setAttribute("D", date("D",$ts)); 
     204          $node->setAttribute("l", date("l",$ts)); 
     205          $node->setAttribute("S", date("S",$ts)); 
     206          $node->setAttribute("m", date("m",$ts)); 
     207          $node->setAttribute("M", date("M",$ts)); 
     208          $node->setAttribute("F", date("F",$ts)); 
     209          $node->setAttribute("n", date("n",$ts)); 
     210          $node->setAttribute("t", date("t",$ts)); 
     211          $node->setAttribute("y", date("y",$ts)); 
     212          $node->setAttribute("Y", date("Y",$ts)); 
     213          $node->setAttribute("g", date("g",$ts)); 
     214          $node->setAttribute("G", date("G",$ts)); 
     215          $node->setAttribute("h", date("h",$ts)); 
     216          $node->setAttribute("H", date("H",$ts)); 
     217          $node->setAttribute("i", date("i",$ts)); 
     218          $node->setAttribute("s", date("s",$ts)); 
     219          $node->appendChild($nodeText); 
     220          $append=true; 
     221        }else{ 
     222          $nodeText = $this->doc->createCDATASection($val); 
     223          $node->appendChild($nodeText); 
     224          $append=true; 
     225        } 
    191226      } 
    192227      elseif(is_bool($val)){ 
     
    194229        $node->appendChild($nodeText); 
    195230        $append=true; 
     231      } 
     232      elseif(true===method_exists($val,"toDom")){ 
     233        $fragment = $val->toDom($this->doc); 
     234        if ($fragment instanceof DOMDocumentFragment) 
     235        { 
     236          $node->appendChild($fragment); 
     237          $append=true; 
     238        } 
    196239      } 
    197240      elseif(true===method_exists($val,"toArray")){ 
     
    232275          } 
    233276        } 
     277        if(true===method_exists($val,"loadThese")){ 
     278          //Add what ever the values of each of the array to the data array 
     279          $these = $val->loadThese(); 
     280          if(is_array($these)){ 
     281            foreach($these as $loadkey => $loadmethod){ 
     282              $data[$loadkey]=call_user_func(array($val,$loadmethod)); 
     283            } 
     284          } 
     285        } 
    234286        $this->addArray($data, $node, $key); 
    235287        $append=true; 
     
    257309        $data = $val->getResults(); 
    258310        if ($val->haveToPaginate()){ 
    259           $data["pages"] = $val->getLinks(); 
     311          $data["pagelinks"] = $val->getLinks(); 
    260312          $data["pages"]['ResultCount'] = $val->getNbResults(); 
    261313          $data["pages"]['FirstPage'] = $val->getFirstPage(); 
     
    265317          $data["pages"]['CurrentPage'] = $val->getPage(); 
    266318          $data["pages"]['CurrentMaxLink'] = $val->getCurrentMaxLink(); 
    267         } 
     319          $data["pages"]['MaxPerPage'] = $val->getMaxPerPage(); 
     320        } 
     321        $data["total"] = $val->getNbResults(); 
    268322        if($data){ 
    269323          $this->addArray($data, $node, $key); 
     
    300354} 
    301355 
    302 ?> 
     356function isValidDateTime($dateTime) 
     357
     358  $matches = array(); 
     359    if (preg_match("/^(\d{4})-(\d{2})-(\d{2}) ([01][0-9]|2[0-3]):([0-5][0-9]):([0-5][0-9])$/", $dateTime, $matches)) { 
     360      if(isset($matches[1]) && isset($matches[2]) && isset($matches[3])){ 
     361          if (checkdate($matches[2], $matches[3], $matches[1])) { 
     362              return true; 
     363          } 
     364      } 
     365    } 
     366 
     367    return false; 
     368
  • plugins/sfXSLTViewPlugin/trunk/lib/sfXSLTView.class.php

    r12290 r14249  
    11<?php 
    22 
    3  
    4 $e = error_reporting(0); 
    5 error_reporting($e); 
     3//Not sure why i have this set..commenting out for now 
     4//$e = error_reporting(0); 
     5//error_reporting($e); 
    66 
    77/** 
     
    4747    $this->buildcomp = $buildcomponents; 
    4848    $this->context = $context; 
    49     $this->attributeHolder = new sfParameterHolder(); 
     49   
     50      $this->dispatcher = $context->getEventDispatcher(); 
     51     
     52    $this->attributeHolder = $this->initializeAttributeHolder(); 
    5053    $this->parameterHolder = new sfParameterHolder(); 
    5154    $this->parameterHolder->add(sfConfig::get('mod_'.strtolower($moduleName).'_view_param', array())); 
     
    202205 
    203206    $timer = sfTimerManager::getTimer('renderFile'); 
     207     
    204208    if (sfConfig::get('sf_logging_enabled')) 
    205     { 
    206       $this->getContext()->getLogger()->info('{sfView} render "'.$_sfFile.'"'); 
    207     } 
    208     $_escaping = $this->getEscaping(); 
     209      { 
     210          $this->dispatcher->notify(new sfEvent($this, 'application.log', array(sprintf('Render "%s"', $_sfFile)))); 
     211      } 
    209212 
    210213    $this->loadCoreAndStandardHelpers(); 
     
    216219    $this->attributeHolder->set("UploadPath", sfContext::getInstance()->getRequest()->getRelativeUrlRoot().'/'.sfConfig::get('sf_upload_dir_name')); 
    217220 
    218  
    219  
    220     // Add any request errors that have been generated 
    221     if (sfContext::getInstance()->getRequest()->hasErrors()) 
    222     { 
    223       $this->attributeHolder->set('RequestErrors',sfContext::getInstance()->getRequest()->getErrors()); 
    224     } 
    225  
    226221    $array2xml = new sfArray2XML(); 
    227222 
     
    230225    $xmlstr=$array2xml->saveArray("","XML",true); 
    231226    $GLOBALS['XMLSTR'] = $xmlstr; 
    232     if($this->context->getRequest()->getParameter("dumpXML") && SF_DEBUG==true && $this->buildcomp==true){ 
     227    if($this->context->getRequest()->hasParameter("dumpXML") && $this->buildcomp==true){ 
    233228      header('Content-type: text/xml'); 
    234229      echo $xmlstr; 
     
    256251 
    257252} 
    258  
    259  
    260 ?>