当前位置: 首页>>代码示例>>PHP>>正文


PHP clsTinyButStrong::meth_Locator_Replace方法代码示例

本文整理汇总了PHP中clsTinyButStrong::meth_Locator_Replace方法的典型用法代码示例。如果您正苦于以下问题:PHP clsTinyButStrong::meth_Locator_Replace方法的具体用法?PHP clsTinyButStrong::meth_Locator_Replace怎么用?PHP clsTinyButStrong::meth_Locator_Replace使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在clsTinyButStrong的用法示例。


在下文中一共展示了clsTinyButStrong::meth_Locator_Replace方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: meth_Locator_Replace

 /**
  * Redefinition of TBS method to add parameter 'cell' to set value with native OpenDocument format in spreadsheet
  *
  * refactoring code from egroupware/perp_api/inc/report/ooo.inc.php
  *
  * @param  string $Txt       TBS source
  * @param  string $Loc       TBS locator
  * @param  string $Value     TBS data to merge
  * @param  string $CheckSub  TBS checksub ???
  */
 public function meth_Locator_Replace(&$Txt, &$Loc, &$Value, $CheckSub)
 {
     if (!isset($Loc->PrmLst['type']) && !isset($Loc->PrmLst['image']) && !isset($Loc->PrmLst['link'])) {
         return parent::meth_Locator_Replace($Txt, $Loc, $Value, $CheckSub);
     }
     // keep 'Loc' position for the end
     $posBeg = $Loc->PosBeg;
     $posEnd = $Loc->PosEnd;
     // get data
     $data = isset($Value) ? $Value : null;
     foreach ($Loc->SubLst as $sub) {
         $data = isset($Value[$sub]) ? $Value[$sub] : null;
     }
     // ----- parameter = type
     if (isset($Loc->PrmLst['type'])) {
         if ($data == '') {
             $Txt = substr_replace($Txt, '', $Loc->PosBeg, $Loc->PosEnd - $Loc->PosBeg + 1);
             $Loc->PosBeg = $posBeg;
             $Loc->PosEnd = $posEnd;
             return $Loc->PosBeg;
         }
         // get container enlarged to table:table-cell
         $Loc->Enlarged = $this->f_Loc_EnlargeToStr($Txt, $Loc, '<table:table-cell', '/table:table-cell>');
         $container = substr($Txt, $Loc->PosBeg, $Loc->PosEnd - $Loc->PosBeg + 1);
         if ($container == '') {
             throw new tinyDocException(sprintf('<table:table-cell not found in document "%s"', $this->getXmlFilename()));
         }
         // OpenOffice attributes cell - see : http://books.evc-cit.info/odbook/ch05.html#table-cells-section
         switch ($Loc->PrmLst['type']) {
             case 'datetime':
             case 'date':
             case 'dt':
             case 'd':
                 $attribute = sprintf('office:value-type="date" office:date-value="%s"', str_replace(' ', 'T', $data));
                 break;
             case 'time':
             case 't':
                 list($h, $m, $s) = split(":", $data);
                 $attribute = sprintf('office:value-type="time" office:time-value="PT%sH%sM%sS"', $h, $m, $s);
                 break;
             case 'percentage':
             case 'percent':
             case 'p':
                 $attribute = sprintf('office:value-type="percentage" office:value="%s"', $data);
                 break;
             case 'currency':
             case 'cur':
             case 'c':
                 //$attribute = sprintf('office:value-type="currency" office:currency="EUR" office:value="%s"', $data); // still not necessary to fix the currency
                 $attribute = sprintf('office:value-type="currency" office:value="%s"', $data);
                 break;
             case 'number':
             case 'n':
             case 'float':
             case 'f':
                 $attribute = sprintf('office:value-type="float" office:value="%s"', $data);
                 break;
             case 'int':
             case 'i':
                 $attribute = sprintf('office:value-type="float" office:value="%d"', $data);
                 break;
             default:
             case 'string':
             case 's':
                 $attribute = sprintf('office:value-type="string"');
                 break;
         }
         // new container
         $newContainer = preg_replace('/office:value-type="string"/', $attribute, $container);
         // replace the new cell containter in the main Txt
         $Txt = substr_replace($Txt, $newContainer, $Loc->PosBeg, $Loc->PosEnd - $Loc->PosBeg + 1);
         // correct 'Loc' to include the change of the new cell container
         $delta = strlen($newContainer) - strlen($container);
         $Loc->PosBeg = $posBeg + $delta;
         $Loc->PosEnd = $posEnd + $delta;
         $Loc->Enlarged = null;
     }
     // ----- parameter = image
     if (isset($Loc->PrmLst['image'])) {
         // get container enlarged to draw:frame
         $Loc->Enlarged = $this->f_Loc_EnlargeToStr($Txt, $Loc, '<draw:frame', '/draw:frame>');
         $container = substr($Txt, $Loc->PosBeg, $Loc->PosEnd - $Loc->PosBeg + 1);
         if ($container == '') {
             throw new tinyDocException(sprintf('<draw:frame not found in document "%s"', $this->getXmlFilename()));
         }
         // test if data is empty or if file not exists
         if ($data == '' || !file_exists($data)) {
             $Txt = substr_replace($Txt, '', $Loc->PosBeg, $Loc->PosEnd - $Loc->PosBeg + 1);
             $Loc->PosBeg = $posBeg;
             $Loc->PosEnd = $posEnd;
//.........这里部分代码省略.........
开发者ID:cljk,项目名称:kimai,代码行数:101,代码来源:tinyDoc.class.php

示例2: meth_Locator_Replace

 /**
  * Redefinition of TBS method to add parameter 'cell' to set value with native OpenDocument format in spreadsheet
  *
  * refactoring code from egroupware/perp_api/inc/report/ooo.inc.php
  *
  * @param  string $Txt       TBS source
  * @param  string $Loc       TBS locator
  * @param  string $Value     TBS data to merge
  * @param  string $CheckSub  TBS checksub ???
  */
 public function meth_Locator_Replace(&$Txt, &$Loc, &$Value, $CheckSub)
 {
     if (!isset($Loc->PrmLst['type'])) {
         return parent::meth_Locator_Replace($Txt, $Loc, $Value, $CheckSub);
     }
     // keep 'Loc' for the end
     $posBeg = $Loc->PosBeg;
     $posEnd = $Loc->PosEnd;
     // get data
     $data = $Value[$Loc->SubLst[0]];
     // new cell attribute
     // see : http://books.evc-cit.info/odbook/ch05.html#table-cells-section
     switch ($Loc->PrmLst['type']) {
         case 'datetime':
         case 'date':
         case 'dt':
         case 'd':
             $cellAttribute = sprintf('office:value-type="date" office:date-value="%s"', str_replace(' ', 'T', $data));
             break;
         case 'time':
         case 't':
             list($h, $m, $s) = split(":", $data);
             $cellAttribute = sprintf('office:value-type="time" office:time-value="PT%sH%sM%sS"', $h, $m, $s);
             break;
         case 'percentage':
         case 'percent':
         case 'p':
             $cellAttribute = sprintf('office:value-type="percentage" office:value="%s"', $data);
             break;
         case 'currency':
         case 'cur':
         case 'c':
             //$cellAttribute = sprintf('office:value-type="currency" office:currency="EUR" office:value="%s"', $data); // still not necessary to fix the currency
             $cellAttribute = sprintf('office:value-type="currency" office:value="%s"', $data);
             break;
         case 'float':
         case 'f':
             $cellAttribute = sprintf('office:value-type="float" office:value="%s"', $data);
             break;
         case 'int':
         case 'i':
             $cellAttribute = sprintf('office:value-type="float" office:value="%d"', $data);
             break;
         case 'boolean':
         case 'bool':
         case 'b':
             $cellAttribute = sprintf('office:value-type="float" office:value="%d"', $data);
             break;
         default:
         case 'string':
         case 's':
             $cellAttribute = sprintf('office:value-type="string"');
             break;
     }
     // get cell container enlarged to table:table-cell
     $Loc->Enlarged = $this->f_Loc_EnlargeToStr($Txt, $Loc, '<table:table-cell', '>');
     $cellContainer = substr($Txt, $Loc->PosBeg, $Loc->PosEnd - $Loc->PosBeg + 1);
     // new cell container
     $newCellContainer = preg_replace('/office:value-type="string"/', $cellAttribute, $cellContainer);
     // replace the new cell containter in the main Txt
     $Txt = substr_replace($Txt, $newCellContainer, $Loc->PosBeg, $Loc->PosEnd - $Loc->PosBeg + 1);
     // correct 'Loc' to include the change of the new cell container
     $delta = strlen($newCellContainer) - strlen($cellContainer);
     $Loc->PosBeg = $posBeg + $delta;
     $Loc->PosEnd = $posEnd + $delta;
     $Loc->Enlarged = null;
     // call the parent method to insert the value
     $ret = parent::meth_Locator_Replace($Txt, $Loc, $Value, $CheckSub);
     // before return, restore 'Loc' with beginning values (to work with block)
     $Loc->PosBeg = $posBeg;
     $Loc->PosEnd = $posEnd;
     return $ret;
 }
开发者ID:nagiro,项目名称:intra,代码行数:83,代码来源:tinyDoc.class.php


注:本文中的clsTinyButStrong::meth_Locator_Replace方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。