Russian TYPO3 community Форум больше не используется. Присоединяйтесь к каналу #community-ru в Slack for TYPO3 community  

Вернуться   Russian TYPO3 community > Тематические форумы > TypoScript практикум

Ответ
 
Опции темы Опции просмотра
Старый 01.07.2009, 13:59   #1
federico
Новенький
 
Регистрация: 11.12.2008
Сообщений: 18
По умолчанию Передача параметров плагину через линк

Есть плагин skpdfviewer. данные плагин берет из флексформы.
Можно ли как то передать данные плагину через ссылку такого типа:

index.php?id=555&tx_skpdfviewer_pi1[dir]=pdf2

не используя флексформы

Код:
<?php

require_once(PATH_tslib.'class.tslib_pibase.php');

require_once (PATH_t3lib."class.t3lib_stdgraphic.php");


class tx_skpdfviewer_pi1 extends tslib_pibase {

    var $prefixId = 'tx_skpdfviewer_pi1';        // Same as class name

    var $scriptRelPath = 'pi1/class.tx_skpdfviewer_pi1.php';    // Path to this script relative to the extension dir.

    var $extKey = 'sk_pdfviewer';    // The extension key.

    var $pi_checkCHash = TRUE;

    var $CE_ID;       

    

    /**

     * The main method of the PlugIn

     *

     * @param    string        $content: The PlugIn content

     * @param    array        $conf: The PlugIn configuration

     * @return    The content that is displayed on the website

     */

    function main($content,$conf)    {

        $this->conf=$conf;

        $this->pi_setPiVarDefaults();

        $this->pi_loadLL();

        $this->pi_initPIflexForm();  

        

        $CE_ID=substr($this->cObj->currentRecord,11);     

        

        //process flexform

        if($this->pi_getFFvalue($this->cObj->data['pi_flexform'], 'pdf_file', 'sPARAMS')!='') $this->conf['pdf_file'] = $this->pi_getFFvalue($this->cObj->data['pi_flexform'], 'pdf_file', 'sPARAMS');   

        if($this->pi_getFFvalue($this->cObj->data['pi_flexform'], 'format', 'sPARAMS')!='') $this->conf['file_format'] = $this->pi_getFFvalue($this->cObj->data['pi_flexform'], 'format', 'sPARAMS');   

        if($this->pi_getFFvalue($this->cObj->data['pi_flexform'], 'title', 'sPARAMS')!='') $this->conf['title'] = $this->pi_getFFvalue($this->cObj->data['pi_flexform'], 'title', 'sPARAMS');   

        if($this->pi_getFFvalue($this->cObj->data['pi_flexform'], 'width', 'sPARAMS')!='') $this->conf['width'] = $this->pi_getFFvalue($this->cObj->data['pi_flexform'], 'width', 'sPARAMS');   

        if($this->pi_getFFvalue($this->cObj->data['pi_flexform'], 'height', 'sPARAMS')!='') $this->conf['height'] = $this->pi_getFFvalue($this->cObj->data['pi_flexform'], 'height', 'sPARAMS');   

        if($this->pi_getFFvalue($this->cObj->data['pi_flexform'], 'pages', 'sPARAMS')!='') $this->conf['pages'] = $this->pi_getFFvalue($this->cObj->data['pi_flexform'], 'pages', 'sPARAMS');   

        if($this->pi_getFFvalue($this->cObj->data['pi_flexform'], 'startpage', 'sPARAMS')!='') $this->conf['startpage'] = $this->pi_getFFvalue($this->cObj->data['pi_flexform'], 'startpage', 'sPARAMS');   

        if($this->pi_getFFvalue($this->cObj->data['pi_flexform'], 'endpage', 'sPARAMS')!='') $this->conf['endpage'] = $this->pi_getFFvalue($this->cObj->data['pi_flexform'], 'endpage', 'sPARAMS');   

        if($this->pi_getFFvalue($this->cObj->data['pi_flexform'], 'titletag', 'sPARAMS')!='') $this->conf['titletag'] = $this->pi_getFFvalue($this->cObj->data['pi_flexform'], 'titletag', 'sPARAMS');   

        if($this->pi_getFFvalue($this->cObj->data['pi_flexform'], 'alttag', 'sPARAMS')!='') $this->conf['alttag'] = $this->pi_getFFvalue($this->cObj->data['pi_flexform'], 'alttag', 'sPARAMS');   

        if($this->pi_getFFvalue($this->cObj->data['pi_flexform'], 'addparams', 'sPARAMS')!='') $this->conf['addparams'] = $this->pi_getFFvalue($this->cObj->data['pi_flexform'], 'addparams', 'sPARAMS');   

        if($this->pi_getFFvalue($this->cObj->data['pi_flexform'], 'IMparams', 'sPARAMS')!='') $this->conf['IMparams'] = $this->pi_getFFvalue($this->cObj->data['pi_flexform'], 'IMparams', 'sPARAMS');   

        if($this->pi_getFFvalue($this->cObj->data['pi_flexform'], 'link', 'sPARAMS')!='') $this->conf['link.']['parameter'] = $this->pi_getFFvalue($this->cObj->data['pi_flexform'], 'link', 'sPARAMS');   

        if($this->pi_getFFvalue($this->cObj->data['pi_flexform'], 'link2doc', 'sPARAMS')!='') $this->conf['link2doc'] = $this->pi_getFFvalue($this->cObj->data['pi_flexform'], 'link2doc', 'sPARAMS');   

        

        if(intval($this->conf['pages'])==0) $this->conf['pages']=1;    

        if(intval($this->conf['endpage'])==0) $this->conf['endpage']=$this->conf['pages'];

        

        $template=$this->cObj->getSubpart($this->cObj->fileResource($this->conf['templateFile']),'###PDFVIEWER###');  

        

        $pdfID=intval($this->piVars['pdfid']);

        

        $page=intval($this->piVars['page']);

        $nextpage=intval($this->piVars['topage'])-1;

        if(isset($this->piVars['prevpage'])) $page==$nextpage?$page -=1:$page=$nextpage;

        if(isset($this->piVars['nextpage'])) $page==$nextpage?$page +=1:$page=$nextpage;

        

        if($page<intval($this->conf['startpage'])) $page=intval($this->conf['startpage']);

        if($page+1>intval($this->conf['endpage'])) $page=intval($this->conf['endpage'])-1;

        

        

        if($this->conf['file_format']=='') $this->conf['file_format']='gif';

        

        $imageProc = t3lib_div::makeInstance('t3lib_stdGraphic');

        $imageProc->init();

        $imageProc->tempPath = PATH_site.'typo3temp/';



        #imageMagickConvert($imagefile,$newExt='',$w='',$h='',$params='',$frame='',$options='',$mustCreate=0)   

        $ret=$imageProc->imageMagickConvert('uploads/tx_skpdfviewer/'.$this->conf['pdf_file'],$this->conf['file_format'],$this->conf['width'],$this->conf['height'],$this->conf['IMparams'],$page,"",1);

        

        $picurl=substr($ret[3],strpos($ret[3],'typo3temp'));

        //replace Markers

        $markerArray['###HIDDEN###']='<input type="hidden" name="'.$this->prefixId.'[page]" value="'.$page.'" /><input type="hidden" name="'.$this->prefixId.'[pdfid]" value="" />';

        $markerArray['###TITLE###']=$this->conf['title'];

        $markerArray['###L_PAGE###']=$this->pi_getLL('page');

        $markerArray['###PAGE###']=$page+1;

        $markerArray['###L_PAGES###']=$this->pi_getLL('of');

        $markerArray['###PAGES###']=$this->conf['pages'];

        $markerArray['###ID###']=$this->cObj->data['uid'];

        $markerArray['###ACTION###']=$this->cObj->typolink_url(array('parameter'=>$GLOBALS['TSFE']->id,'section'=>'pdf-'.$this->cObj->data['uid']));

        $markerArray['###JUMPTOPAGE_NAME###']=$this->prefixId.'[topage]';

        $markerArray['###JUMPTOTEXT_VALUE###']=$page+1;

        $markerArray['###PIC###']=$picurl;

        $markerArray['###WIDTH###']=$ret[0];

        $markerArray['###HEIGHT###']=$ret[1];

        $markerArray['###TITLETAG###']=$this->conf['titletag'];

        $markerArray['###ALTTAG###']=$this->conf['alttag'];

        $markerArray['###ADDITIONALPARAMS###']=$this->conf['addparams'];

        

        $markerArray['###PREVIOUSPAGE_NAME###']=$this->prefixId.'[prevpage]';

        $markerArray['###PREVIOUSPAGE_VALUE###']='&lt;';

        $markerArray['###NEXTPAGE_NAME###']=$this->prefixId.'[nextpage]';

        $markerArray['###NEXTPAGE_VALUE###']='&gt;';

        

        if($this->conf['link.']['parameter']!='' && !$this->conf['link2doc']) {

            $subpartLinkWrapArray['###LINK###'] = explode('|', $this->cObj->typolink('|',$this->conf['link.']));

        }

        if($this->conf['link2doc']) {

            $subpartLinkWrapArray['###LINK###'] = explode('|', $this->cObj->typolink('|',array('parameter'=>'uploads/tx_skpdfviewer/'.$this->conf['pdf_file'])));

        } 

                

        $content=$this->cObj->substituteMarkerArrayCached($template,$markerArray,$subpartArray,$subpartLinkWrapArray);

    

        return $this->pi_wrapInBaseClass('<div class="pdf" style="width:'.$ret[0].'px;">'.$content.'</div>');

    }

}







if (defined('TYPO3_MODE') && $TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/sk_pdfviewer/pi1/class.tx_skpdfviewer_pi1.php'])    {

    include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['ext/sk_pdfviewer/pi1/class.tx_skpdfviewer_pi1.php']);

}



?>

Последний раз редактировалось federico; 02.07.2009 в 12:13
federico вне форума   Ответить с цитированием
Старый 02.07.2009, 04:53   #2
shuman
Senior Member
 
Регистрация: 21.11.2007
Сообщений: 217
По умолчанию

Цитата:
Сообщение от federico Посмотреть сообщение
Есть плагин skpdfviewer. данные плагин берет из флексформы.
Можно ли как то передать данные плагину через ссылку такого типа:

index.php?id=555&tx_skpdfviewer_pi1[dir]=pdf2

не используя флексформы
вопрос про то как сформировать ссылку или обработать переменную?

если про обработку то здесь ничего сложного - массив piVars должен быть - если класс плагина был создан при помощи kickstartera или основан
как
class tx_my_ext_pi1 extends tslib_pibase

про то как сформировать ссылку тут куча ссылок если искать по typolink
shuman вне форума   Ответить с цитированием
Старый 03.07.2009, 06:53   #3
shuman
Senior Member
 
Регистрация: 21.11.2007
Сообщений: 217
По умолчанию

обработка
$dir=$this->piVars['dir'];

создание ссылки
Цитата:
pi_linkTP:

1: // Get prepared:

2: $dir = t3lib_div::_GP('tx_skpdfviewer_pi1[dir]');

3: $label = 'PDF dir';

4: $params = array (

5: 'tx_skpdfviewer_pi1[dir]' => $dir

);

8: // Create the link:

9: $out = 'The current value is ' . $dir;

$out .= $this->pi_linkTP ($label, $params)
http://hachmeister.org/index.php?id=412&L=0
http://typo3.org/development/article...ntend-plugins/

немного не по теме - интересная статья:
http://forum.typo3.biz/archive/index.php/t-380.html
только я не понял почему HMENU отказался от typolink
shuman вне форума   Ответить с цитированием
Старый 06.07.2009, 12:27   #4
federico
Новенький
 
Регистрация: 11.12.2008
Сообщений: 18
По умолчанию

Огромное спасибо за помощь, shuman!!!
federico вне форума   Ответить с цитированием
Ответ


Ваши права в разделе
Вы не можете создавать новые темы
Вы не можете отвечать в темах
Вы не можете прикреплять вложения
Вы не можете редактировать свои сообщения

BB code is Вкл.
Смайлы Вкл.
[IMG] код Вкл.
HTML код Выкл.

Быстрый переход

Похожие темы
Тема Автор Раздел Ответов Последнее сообщение
Передача параметров в userFunc c0d3r TypoScript практикум 10 15.05.2007 16:19
Передача параметров во flash filippoff Общие вопросы 5 18.02.2007 15:32


Часовой пояс GMT +4, время: 18:35.


Работает на vBulletin® версия 3.8.1.
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Перевод: zCarot

Хостинг и техническая поддержка: TYPO3 Лаборатория