PageRenderTime 57ms CodeModel.GetById 19ms RepoModel.GetById 1ms app.codeStats 0ms

/t3consultancies/pi1/class.tx_t3consultancies_pi1.php

https://github.com/michael-cannon/typo3-extensions
PHP | 1714 lines | 1245 code | 230 blank | 239 comment | 86 complexity | 438ea8738c01c45a5461df729726d7e2 MD5 | raw file
Possible License(s): LGPL-2.1
  1. <?php
  2. /***************************************************************
  3. * Copyright notice
  4. *
  5. * (c) 2002 Kasper Skĺrhřj (kasper@typo3.com)
  6. * All rights reserved
  7. *
  8. * This script is part of the Typo3 project. The Typo3 project is
  9. * free software; you can redistribute it and/or modify
  10. * it under the terms of the GNU General Public License as published by
  11. * the Free Software Foundation; either version 2 of the License, or
  12. * (at your option) any later version.
  13. *
  14. * The GNU General Public License can be found at
  15. * http://www.gnu.org/copyleft/gpl.html.
  16. *
  17. * This script is distributed in the hope that it will be useful,
  18. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  19. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  20. * GNU General Public License for more details.
  21. *
  22. * This copyright notice MUST APPEAR in all copies of the script!
  23. ***************************************************************/
  24. /**
  25. * Plugin 'Consultancies' for the 't3consultancies' extension.
  26. *
  27. * @author Kasper Skĺrhřj <kasper@typo3.com>
  28. */
  29. /**
  30. * @author Michael Cannon <michael@peimic.com>
  31. * @version $Id: class.tx_t3consultancies_pi1.php,v 1.1.1.1 2010/04/15 10:04:06 peimic.comprock Exp $
  32. */
  33. require_once(PATH_tslib."class.tslib_pibase.php");
  34. class tx_t3consultancies_pi1 extends tslib_pibase {
  35. var $prefixId = "tx_t3consultancies_pi1"; // Same as class name
  36. var $scriptRelPath = "pi1/class.tx_t3consultancies_pi1.php"; // Path to this script relative to the extension dir.
  37. var $extKey = "t3consultancies"; // The extension key.
  38. // Internal
  39. var $categories=array();
  40. var $countries=array();
  41. var $showRef=0; // If set, then references for consultancies are shown.
  42. var $singleViewOn=0; // If set, a single item is shown
  43. // limit selection of categories
  44. var $categoriesList = '';
  45. // default template file
  46. var $templateFile = 'EXT:t3consultancies/pi1/t3consultancies.html';
  47. // template marker contents
  48. var $markerArray = array();
  49. var $db = null;
  50. /**
  51. * Main function
  52. */
  53. function main($content,$conf) {
  54. $this->pi_setPiVarDefaults();
  55. // Loading the LOCAL_LANG values
  56. $this->pi_loadLL();
  57. // current database object
  58. $this->db = $GLOBALS[ 'TYPO3_DB' ];
  59. $this->db->debugOutput = true;
  60. $this->showRef = $conf["t3references_disabled"]
  61. ? 0
  62. : t3lib_extMgm::isLoaded("t3references");
  63. $this->sitesMade = ! $conf["sites_made_disabled"];
  64. if (strstr($this->cObj->currentRecord,"tt_content"))
  65. {
  66. $conf["pidList"] = $this->cObj->data["pages"];
  67. $conf["recursive"] = $this->cObj->data["recursive"];
  68. $conf["selectedOnly"] = $this->cObj->data["tx_t3consultancies_selected_only"];
  69. // allow tt_content to define what to show here
  70. $conf[ 'CMD' ] = $this->cObj->data[
  71. 'tx_t3consultancies_command' ];
  72. $this->conf[ 'categoryListingPage' ] = ( $this->cObj->data[
  73. 'tx_t3consultancies_categorylisting' ]
  74. )
  75. ? $this->cObj->data[
  76. 'tx_t3consultancies_categorylisting' ]
  77. : $this->conf[ 'categoryListingPage' ];
  78. $this->conf[ 'alphabeticalListingPage' ] = ( $this->cObj->data[
  79. 'tx_t3consultancies_alphabeticallisting' ]
  80. )
  81. ? $this->cObj->data[
  82. 'tx_t3consultancies_alphabeticallisting' ]
  83. : $this->conf[ 'alphabeticalListingPage' ];
  84. // check for tt_content defined templateFile
  85. $conf[ 'templateFile' ] = ( $this->cObj->data[
  86. 'tx_t3consultancies_template' ]
  87. )
  88. ? "uploads/tx_t3consultancies/"
  89. . $this->cObj->data[
  90. 'tx_t3consultancies_template' ]
  91. : $conf[ 'templateFile' ];
  92. // set templateFile to use for remainder
  93. $this->templateFile = ( $conf[ 'templateFile' ] )
  94. ? $conf[ 'templateFile' ]
  95. : $this->templateFile;
  96. $categoriesList = $this->cObj->data[
  97. 'tx_t3consultancies_categories' ];
  98. if ( $categoriesList )
  99. {
  100. $this->categoriesList = ( 'featuredAd' != $conf[ 'CMD' ] )
  101. ? " AND tx_t3consultancies_cat.uid IN ( $categoriesList )"
  102. : " AND tx_t3consultancies_services_mm.uid_foreign IN ( $categoriesList )";
  103. }
  104. }
  105. $conf = $this->buildTextImageConf( $conf );
  106. $this->conf = $conf;
  107. switch( $conf["CMD"] )
  108. {
  109. case "navigation":
  110. return $this->pi_wrapInBaseClass( $this->navigationView(
  111. $content
  112. , $conf
  113. ) );
  114. break;
  115. // force if a single element should be displayed:
  116. case "singleView":
  117. case ( isset( $this->piVars[ 'showUid' ] ) ):
  118. $this->internal["currentTable"] = "tx_t3consultancies";
  119. $this->internal["currentRow"] = $this->pi_getRecord("tx_t3consultancies",$this->piVars["showUid"]);
  120. return $this->pi_wrapInBaseClass($this->singleView($content,$conf));
  121. return $content;
  122. break;
  123. case "featuredAd":
  124. case "alphabetical":
  125. return $this->pi_wrapInBaseClass( $this->multipleItemView(
  126. $content
  127. , $conf
  128. ) );
  129. break;
  130. case "category":
  131. return $this->pi_wrapInBaseClass( $this->categoryView(
  132. $content
  133. , $conf
  134. ) );
  135. break;
  136. case "listView":
  137. default:
  138. return $this->pi_wrapInBaseClass($this->listView($content,$conf));
  139. break;
  140. }
  141. }
  142. /**
  143. * Makes the list view of consultancies
  144. */
  145. function listView($content,$conf) {
  146. $lConf = $this->conf["listView."]; // Local settings for the listView function
  147. $this->pi_autoCacheEn=1;
  148. $this->pi_autoCacheFields = Array();
  149. $this->pi_autoCacheFields["pointer"] = array("range"=>array(0,10));
  150. if ($this->conf["selectCountryFirst"]) {
  151. $this->pi_autoCacheFields["lang"] = array("range"=>array(0,1000));
  152. # $this->pi_isOnlyFields = "mode,pointer,lang";
  153. # $this->pi_lowerThan=1000;
  154. }
  155. # So the preview button will always be shown...
  156. $this->pi_alwaysPrev=1;
  157. $this->editAdd=0;
  158. if ((string)$this->piVars["editAdd"]) {
  159. $this->editAdd=1;
  160. $GLOBALS["TSFE"]->set_no_cache();
  161. }
  162. if ($this->editAdd && !$GLOBALS["TSFE"]->loginUser)
  163. {
  164. return '<p>'.sprintf($this->pi_getLL("noUserLoggedInWarning"),'<a href="'.$this->pi_getPageLink($this->conf["loginPageId"]).'">','</a>').'</p>';
  165. }
  166. elseif ($this->editAdd)
  167. {
  168. # $GLOBALS["TSFE"]->set_no_cache();
  169. $fullTable="";
  170. $feAConf=$this->getFe_adminLibConf();
  171. $fullTable.= $this->cObj->cObjGetSingle($this->conf["fe_adminLib"],$feAConf);
  172. $fullTable.= '<p>'.$this->pi_linkTP_keepPIvars($this->pi_getLL("Return_to_listing"),array("editAdd"=>"")).'</p>';
  173. // Returns the content from the plugin.
  174. return $fullTable;
  175. }
  176. else
  177. {
  178. if (!isset($this->piVars["pointer"]))
  179. {
  180. $this->piVars["pointer"]=0;
  181. }
  182. // Initializing the query parameters:
  183. $this->internal["results_at_a_time"]=t3lib_div::intInRange($lConf["results_at_a_time"],0,1000,30); // Number of results to show in a listing.
  184. $this->internal["maxPages"]=t3lib_div::intInRange($lConf["maxPages"],0,1000,5);; // The maximum number of "pages" in the browse-box: "Page 1", "Page 2", etc.
  185. $this->internal["searchFieldList"]="title,description,url,contact_email,contact_name";
  186. $this->addWhere="";
  187. // Only selected:
  188. $this->addWhere.= $this->conf["selectedOnly"] ? ' AND tx_t3consultancies.selected' : '';
  189. // Getting the list of countries used - piVars["lang"]
  190. $this->loadCountries();
  191. // Getting the categories used - piVars["service"]
  192. $this->loadCategories();
  193. #debug($this->countries);
  194. #debug($this->categories);
  195. // Countries:
  196. $this->addWhere.= $this->piVars["lang"] ? ' AND tx_t3consultancies.cntry='.intval($this->piVars["lang"]) : '';
  197. #debug($this->addWhere);
  198. if ($this->piVars["service"]) {
  199. $mm_cat=array();
  200. $mm_cat["mmtable"]="tx_t3consultancies_services_mm";
  201. $mm_cat["table"]="tx_t3consultancies_cat";
  202. $mm_cat["catUidList"]=intval($this->piVars["service"]);
  203. } else $mm_cat="";
  204. // Get number of records:
  205. $query = $this->pi_list_query('tx_t3consultancies',1,$this->addWhere,$mm_cat);
  206. $res = mysql(TYPO3_db,$query);
  207. if (mysql_error()) debug(array(mysql_error(),$query));
  208. list($this->internal["res_count"]) = mysql_fetch_row($res);
  209. // Make listing query, pass query to MySQL:
  210. $query = $this->pi_list_query("tx_t3consultancies",0,$this->addWhere,$mm_cat,""," ORDER BY tx_t3consultancies.weight DESC, tx_t3consultancies.title");
  211. $res = mysql(TYPO3_db,$query);
  212. if (mysql_error()) debug(array(mysql_error(),$query));
  213. $this->internal["currentTable"] = "tx_t3consultancies";
  214. // Put the whole list together:
  215. $fullTable=""; // Clear var;
  216. if (!$this->conf["selectCountryFirst"] || $this->piVars["lang"]) {
  217. $fullTable.=$this->makeSelectors();
  218. if ($this->internal["res_count"] > $this->internal["results_at_a_time"]) {
  219. // Adds the result browser:
  220. $fullTable.=$this->pi_list_browseresults();
  221. }
  222. // Adds the whole list table
  223. $fullTable.=$this->pi_list_makelist($res);
  224. // Adds the search box:
  225. $fullTable.=$this->pi_list_searchBox();
  226. } else {
  227. $fullTable.=$this->makeSelectors(1);
  228. }
  229. $fullTable.=$this->makeEditAddButton();
  230. // Returns the content from the plugin.
  231. return $fullTable;
  232. }
  233. }
  234. /**
  235. * Make selector boxes in the top of page
  236. */
  237. function makeSelectors($noServiceBox=0) {
  238. $fullTable.=$this->makeCountrySelect($noServiceBox);
  239. if (!$noServiceBox) $fullTable.=$this->makeServiceSelect();
  240. return '<DIV'.$this->pi_classParam("modeSelector").'>'.
  241. $fullTable.
  242. '</DIV>';
  243. }
  244. /**
  245. * Make the selectorbox with countries.
  246. */
  247. function makeCountrySelect($altLabel=0) {
  248. $opt=array();
  249. reset($this->countries);
  250. $this->pi_linkTP_keepPIvars($v,array("lang"=>"","pointer"=>""));
  251. $opt[]='<option value="'.htmlentities($this->cObj->lastTypoLinkUrl).'">'.$this->pi_getLL(!$altLabel?'All_countries':'Sel_countries').'</option>';
  252. while(list($k,$v)=each($this->countries)) {
  253. $this->pi_linkTP_keepPIvars($v,array("lang"=>$k,"pointer"=>""));
  254. $opt[]='<option value="'.htmlentities($this->cObj->lastTypoLinkUrl).'"'.($this->piVars["lang"]==$k?" SELECTED":"").'>'.htmlentities($v).'</option>';
  255. }
  256. return '<select onChange="document.location=this.options[this.selectedIndex].value;">'.implode("",$opt).'</select>';
  257. }
  258. /**
  259. * Make the selectorbox with categories/services.
  260. */
  261. function makeServiceSelect() {
  262. $opt=array();
  263. reset($this->categories);
  264. $this->pi_linkTP_keepPIvars($v,array("service"=>"","pointer"=>""));
  265. $opt[]='<option value="'.htmlentities($this->cObj->lastTypoLinkUrl).'">'.$this->pi_getLL('All_services').'</option>';
  266. while(list($k,$v)=each($this->categories)) {
  267. $url = $this->categoryUrl( $k );
  268. $opt[]='<option value="'.htmlentities($url).'"'.($this->piVars["service"]==$k?" SELECTED":"").'>'.htmlentities($v).'</option>';
  269. }
  270. # return '<select onChange="document.location=unescape(\''.rawurlencode($this->cObj->lastTypoLinkUrl).'\')+\'&tx_t3consultancies_pi1[service]=\'+this.options[this.selectedIndex].value;">'.implode("",$opt).'</select>';
  271. return '<select onChange="document.location=this.options[this.selectedIndex].value;">'.implode("",$opt).'</select>';
  272. }
  273. /**
  274. * Makes a link to/from edit mode
  275. */
  276. function makeEditAddButton() {
  277. if ($this->conf["editAdd_enabled"]) {
  278. if (!$this->editAdd) {
  279. $this->pi_moreParams="&cmd=edit";
  280. return '<p>'.$this->pi_linkTP_keepPIvars($this->pi_getLL("Edit_or_add_entries"),array("editAdd"=>1),1,1).'</p>';
  281. } else {
  282. return '<p>'.$this->pi_linkTP_keepPIvars($this->pi_getLL("Cancel_edit_mode"),array("editAdd"=>""),1,1).'</p>';
  283. }
  284. }
  285. }
  286. /**
  287. * Loading the countries used in the list into an internal array, $this->countries
  288. */
  289. function loadCountries() {
  290. $pidList = $this->pi_getPidList($this->conf["pidList"],$this->conf["recursive"]);
  291. $query = "SELECT static_countries.cn_short_en,static_countries.uid
  292. FROM static_countries,tx_t3consultancies
  293. WHERE tx_t3consultancies.cntry=static_countries.uid AND tx_t3consultancies.pid IN (".$pidList.")".
  294. $this->cObj->enableFields("tx_t3consultancies").
  295. $this->addWhere.
  296. " GROUP BY tx_t3consultancies.cntry ORDER BY static_countries.cn_short_en";
  297. $res = mysql(TYPO3_db,$query);
  298. $this->countries=array();
  299. while($row=mysql_fetch_assoc($res)) {
  300. $this->countries[$row["uid"]]=$row["cn_short_en"];
  301. }
  302. }
  303. /**
  304. * Loading the categories into an internal array, $this->categories
  305. */
  306. function loadCategories()
  307. {
  308. $query = $this->pi_categoriesUsed(
  309. "tx_t3consultancies_cat"
  310. , "tx_t3consultancies_services_mm"
  311. , "tx_t3consultancies"
  312. , $this->addWhere
  313. . $this->categoriesList
  314. );
  315. $res = mysql(TYPO3_db,$query);
  316. $this->categories = array();
  317. while( $row=mysql_fetch_assoc($res) )
  318. {
  319. $this->categories[$row["uid"]]=$row["title"];
  320. }
  321. }
  322. function pi_categoriesUsed($cat_table,$mm_table,$table,$addWhere="") {
  323. // Fetches the list of PIDs to select from.
  324. // TypoScript property .pidList is a comma list of pids. If blank, current page id is used.
  325. // TypoScript property .recursive is a int+ which determines how many levels down from the pids in the pid-list subpages should be included in the select.
  326. $pidList = $this->pi_getPidList($this->conf["pidList"],$this->conf["recursive"]);
  327. // Begin Query:
  328. $query="FROM ".$table.",".$cat_table.",".$mm_table.chr(10).
  329. " WHERE ".$table.".uid=".$mm_table.".uid_local AND ".$cat_table.".uid=".$mm_table.".uid_foreign ".chr(10).
  330. " AND ".$table.".pid IN (".$pidList.")".chr(10).
  331. $this->cObj->enableFields($cat_table).
  332. $this->cObj->enableFields($table).chr(10);
  333. if ($addWhere) {$query.=" ".$addWhere.chr(10);}
  334. $query.=" GROUP BY ".$cat_table.".uid";
  335. $query = "SELECT ".$cat_table.".title,".$cat_table.".uid ".chr(10).$query;
  336. return $query;
  337. }
  338. /**
  339. * Renders a single entry
  340. */
  341. function singleView( $content, $conf )
  342. {
  343. if ( ! $this->internal["currentRow"]["uid"] )
  344. {
  345. return $this->pi_getLL( 'no_record' );
  346. }
  347. if ( $this->conf["selectCountryFirst"] && ! $this->piVars["lang"] )
  348. {
  349. $GLOBALS["TSFE"]->set_no_cache();
  350. }
  351. $this->singleViewOn = 1;
  352. // This sets the title of the page for use in indexed search results:
  353. if ($this->internal["currentRow"]["title"])
  354. {
  355. $GLOBALS["TSFE"]->indexedDocTitle =
  356. $this->internal["currentRow"]["title"];
  357. }
  358. $templatePart = '###TEMPLATE_SINGLE###';
  359. $string = $this->parseTemplate( $templatePart );
  360. $content = $this->cObj->substituteMarkerArrayCached(
  361. $string
  362. , $this->markerArray
  363. // , array()
  364. );
  365. return $content;
  366. }
  367. /**
  368. * Renders multiple ad entries by category selection
  369. *
  370. * @param string incoming text
  371. * @param array configuration ( not used )
  372. * @return string
  373. */
  374. function categoryView( $content, $conf )
  375. {
  376. switch ( $this->conf[ 'CMD' ] )
  377. {
  378. case 'category':
  379. default:
  380. $templatePart = '###TEMPLATE_CATEGORY###';
  381. break;
  382. }
  383. $string = '';
  384. // Local settings for the listView function
  385. $lConf = $this->conf["listView."];
  386. // look in database for featured records
  387. $selectedOnly = ( $this->conf[ 'selectedOnly' ] )
  388. ? ' AND tx_t3consultancies.selected'
  389. : '';
  390. // grab inputted service
  391. $serviceSelection = ( $this->piVars[ 'service' ] )
  392. ? " AND tx_t3consultancies_services_mm.uid_foreign IN (
  393. {$this->piVars[ 'service' ]}
  394. )"
  395. : '';
  396. // build up query
  397. $query = "
  398. SELECT
  399. tx_t3consultancies.*
  400. FROM
  401. tx_t3consultancies
  402. LEFT JOIN tx_t3consultancies_services_mm
  403. ON tx_t3consultancies.uid =
  404. tx_t3consultancies_services_mm.uid_local
  405. WHERE
  406. 1 = 1
  407. $selectedOnly
  408. /* {$this->categoriesList} */
  409. $serviceSelection
  410. ";
  411. $query .= $this->cObj->enableFields(
  412. 'tx_t3consultancies' );
  413. // this is okay while advertiser list is small, less a few hundred
  414. $query .= "
  415. GROUP BY tx_t3consultancies.uid ASC
  416. ORDER BY tx_t3consultancies.weight DESC
  417. , tx_t3consultancies.title ASC
  418. ";
  419. $result = $this->db->sql( TYPO3_db, $query );
  420. // if results, grab template
  421. if ( $result && $ad = $this->db->sql_fetch_assoc( $result ) )
  422. {
  423. // cycle through template for each record
  424. do
  425. {
  426. $string .= $this->parseTemplate(
  427. $templatePart
  428. , true
  429. , $ad
  430. );
  431. } while ( $ad = $this->db->sql_fetch_assoc( $result ) );
  432. }
  433. else
  434. {
  435. $string .= $this->pi_getLL( 'no_record' );
  436. }
  437. // build up category selection query
  438. $query = "
  439. SELECT
  440. tx_t3consultancies_cat.*
  441. FROM
  442. tx_t3consultancies_cat
  443. LEFT JOIN tx_t3consultancies_services_mm
  444. ON tx_t3consultancies_cat.uid =
  445. tx_t3consultancies_services_mm.uid_foreign
  446. WHERE
  447. 1 = 1
  448. /* {$this->categoriesList} */
  449. $serviceSelection
  450. ";
  451. $query .= $this->cObj->enableFields(
  452. 'tx_t3consultancies_cat' );
  453. // this is okay while advertiser list is small, less a few hundred
  454. $query .= "
  455. ORDER BY tx_t3consultancies_cat.title ASC
  456. ";
  457. $result = $this->db->sql( TYPO3_db, $query );
  458. $contentMarkerArray = array();
  459. $contentMarkerArray[ '###CONTENT###' ] = $string;
  460. // if results, grab template
  461. if ( $result && $category = $this->db->sql_fetch_assoc( $result ) )
  462. {
  463. $contentMarkerArray[ '###TITLE###' ] = $category[ 'title' ];
  464. $contentMarkerArray[ '###TITLE_IMAGE###' ] = $this->textImage(
  465. $category[ 'title' ]
  466. );
  467. if ( $category[ 'image' ] )
  468. {
  469. $image = $this->cObj->imageLinkWrap( $this->getImage(
  470. $category[ 'image' ]
  471. , $this->conf[ 'featuredLogo.' ]
  472. )
  473. , "uploads/tx_t3consultancies/"
  474. . $category[ 'image' ]
  475. , $this->conf[ 'enlargeImage.' ]
  476. );
  477. }
  478. else
  479. {
  480. $image = '';
  481. }
  482. $contentMarkerArray[ '###IMAGE###' ] = $image;
  483. $contentMarkerArray[ '###DESCRIPTION###' ] = $category[
  484. 'description' ];
  485. }
  486. else
  487. {
  488. $contentMarkerArray[ '###TITLE###' ] = '';
  489. $contentMarkerArray[ '###IMAGE###' ] = '';
  490. $contentMarkerArray[ '###DESCRIPTION###' ] = '';
  491. }
  492. $subpart = $this->templateSubpart ( $templatePart );
  493. $content = $this->cObj->substituteMarkerArrayCached(
  494. $subpart
  495. , $this->markerArray
  496. , $contentMarkerArray
  497. );
  498. // Returns the content from the plugin.
  499. return $content;
  500. }
  501. /**
  502. * Renders multiple ad entries by selection
  503. *
  504. * @param string incoming text
  505. * @param array configuration ( not used )
  506. * @return string
  507. */
  508. function multipleItemView( $content, $conf )
  509. {
  510. switch ( $this->conf[ 'CMD' ] )
  511. {
  512. case 'featuredAd':
  513. $templatePart = '###TEMPLATE_FEATURED_AD###';
  514. break;
  515. case 'alphabetical':
  516. $templatePart = '###TEMPLATE_ALPHABETICAL###';
  517. break;
  518. case 'listView':
  519. $templatePart = '###TEMPLATE_CATEGORY###';
  520. break;
  521. }
  522. $string = '';
  523. // Local settings for the listView function
  524. $lConf = $this->conf["listView."];
  525. // look in database for featured records
  526. $selectedOnly = ( 'featuredAd' == $this->conf[ 'CMD' ]
  527. || $this->conf[ 'selectedOnly' ]
  528. )
  529. ? ' AND tx_t3consultancies.selected'
  530. : '';
  531. // build up query
  532. $query = "
  533. SELECT
  534. tx_t3consultancies.*
  535. FROM
  536. tx_t3consultancies
  537. LEFT JOIN tx_t3consultancies_services_mm
  538. ON tx_t3consultancies.uid =
  539. tx_t3consultancies_services_mm.uid_local
  540. WHERE
  541. 1 = 1
  542. $selectedOnly
  543. {$this->categoriesList}
  544. ";
  545. $query .= $this->cObj->enableFields(
  546. 'tx_t3consultancies' );
  547. // this is okay while advertiser list is small, less a few hundred
  548. $query .= "
  549. GROUP BY tx_t3consultancies.uid ASC
  550. ORDER BY tx_t3consultancies.weight DESC
  551. , tx_t3consultancies.title ASC
  552. ";
  553. $result = $this->db->sql( TYPO3_db, $query );
  554. // if results, grab template
  555. if ( $result && $ad = $this->db->sql_fetch_assoc( $result ) )
  556. {
  557. // cycle through template for each record
  558. do
  559. {
  560. $string .= $this->parseTemplate(
  561. $templatePart
  562. , true
  563. , $ad
  564. );
  565. } while ( $ad = $this->db->sql_fetch_assoc( $result ) );
  566. }
  567. $contentMarkerArray = array();
  568. $contentMarkerArray[ '###CONTENT###' ] = $string;
  569. $subpart = $this->templateSubpart ( $templatePart );
  570. $content = $this->cObj->substituteMarkerArrayCached(
  571. $subpart
  572. , $this->markerArray
  573. , $contentMarkerArray
  574. );
  575. // Returns the content from the plugin.
  576. return $content;
  577. }
  578. /**
  579. * Renders navigation entries
  580. *
  581. * @param string incoming text
  582. * @param array configuration ( not used )
  583. * @return string
  584. */
  585. function navigationView( $content, $conf )
  586. {
  587. $templatePart = '###TEMPLATE_MENU###';
  588. // $templatePart = '###TEMPLATE_MENU_ALPHA###';
  589. $string = '';
  590. // Local settings for the listView function
  591. $lConf = $this->conf["listView."];
  592. // build up query
  593. $query = "
  594. SELECT
  595. tx_t3consultancies_cat.*
  596. FROM
  597. tx_t3consultancies_cat
  598. WHERE
  599. 1 = 1
  600. {$this->categoriesList}
  601. ";
  602. $query .= $this->cObj->enableFields(
  603. 'tx_t3consultancies_cat' );
  604. // this is okay while advertiser list is small, less a few hundred
  605. $query .= "
  606. ORDER BY tx_t3consultancies_cat.title ASC
  607. ";
  608. $result = $this->db->sql( TYPO3_db, $query );
  609. // if results, grab template
  610. if ( $result && $category = $this->db->sql_fetch_assoc( $result ) )
  611. {
  612. // cycle through template for each record
  613. do
  614. {
  615. $string .= $this->parseTemplate(
  616. $templatePart
  617. , true
  618. , $category
  619. );
  620. } while ( $category = $this->db->sql_fetch_assoc( $result ) );
  621. }
  622. $contentMarkerArray = array();
  623. $contentMarkerArray[ '###CONTENT###' ] =
  624. $string;
  625. $contentMarkerArray[ '###TITLE_ALPHABETICAL###' ] =
  626. $this->pi_linkToPage(
  627. $this->pi_getLL( 'alphabetical_title' )
  628. , $this->alphabeticalUrl()
  629. );
  630. $subpart = $this->templateSubpart ( $templatePart );
  631. $content = $this->cObj->substituteMarkerArrayCached(
  632. $subpart
  633. , $this->markerArray
  634. , $contentMarkerArray
  635. );
  636. // Returns the content from the plugin.
  637. return $content;
  638. }
  639. /**
  640. * Return string containing tempalte subpart.
  641. *
  642. * @param string template part
  643. * @return string
  644. */
  645. function templateSubpart ( $templatePart )
  646. {
  647. static $template;
  648. // try not to grab the template more than once if necessary
  649. // TODO ensure this doesn't mess up for multiple same page instances
  650. if ( ! $template )
  651. {
  652. $template = $this->cObj->fileResource(
  653. $this->templateFile
  654. );
  655. }
  656. // grab subpart
  657. $subpart = $this->cObj->getSubpart(
  658. $template
  659. , $templatePart
  660. );
  661. return $subpart;
  662. }
  663. /**
  664. * Return string containing string parsed for given template.
  665. *
  666. * @param string template part name
  667. * @param boolean true - content repeated
  668. * @param array data
  669. * @return string
  670. */
  671. function parseTemplate( $templatePart, $repeating = false, $data = false )
  672. {
  673. $subpartEach = $this->templateSubpart ( $templatePart );
  674. if ( $repeating )
  675. {
  676. $subpartEach = $this->cObj->getSubpart(
  677. $subpartEach
  678. , '###EACH###'
  679. );
  680. }
  681. // set internal current row to our input data
  682. if ( ! $data )
  683. {
  684. $data = $this->internal[ 'currentRow' ];
  685. }
  686. else
  687. {
  688. $this->internal[ 'currentRow' ] = $data;
  689. }
  690. // create link to detail page
  691. $this->markerArray[ '###DETAILS###' ] = $this->pi_linkToPage(
  692. $this->pi_getLL( 'Details' )
  693. , $this->detailsUrl()
  694. );
  695. $this->markerArray[ '###BACK###' ] = $this->pi_linkToPage(
  696. $this->pi_getLL( 'Back' )
  697. , $_SERVER[ 'HTTP_REFERER' ]
  698. );
  699. // create title as image
  700. if ( isset( $data[ 'title' ] ) )
  701. {
  702. $this->markerArray[ '###TITLE_IMAGE###' ] = $this->textImage(
  703. $data[ 'title' ]
  704. );
  705. }
  706. foreach( $data as $key => $value )
  707. {
  708. $upperKey = strtoupper( $key ) . '###';
  709. $dataKey = '###' . $upperKey;
  710. $labelKey = '###LABEL_' . $upperKey;
  711. $this->markerArray[ $dataKey ] = $this->getFieldContent(
  712. $key
  713. );
  714. $this->markerArray[ $labelKey ] = $this->pi_getLL(
  715. 'listFieldHeader_' . $key
  716. );
  717. }
  718. $string .= $this->cObj->substituteMarkerArrayCached(
  719. $subpartEach
  720. , $this->markerArray
  721. );
  722. return $string;
  723. }
  724. /**
  725. * Return string of alphabetical page URL
  726. *
  727. * @return string
  728. */
  729. function alphabeticalUrl()
  730. {
  731. $pid = ( $this->conf[ 'alphabeticalListingPage' ] )
  732. ? $this->conf[ 'alphabeticalListingPage' ]
  733. : $this->cObj->data[ 'pid' ];
  734. $linkArray = array(
  735. 'parameter' => $pid
  736. , 'returnLast' => 'url'
  737. , 'no_cache' => 0
  738. , 'useCacheHash' => 0
  739. , 'additionalParams' => ''
  740. );
  741. $url = '/'
  742. . $this->cObj->typolink(
  743. ''
  744. , $linkArray
  745. );
  746. return $url;
  747. }
  748. /**
  749. * Return string of category page URL
  750. *
  751. * @param integer category uid
  752. * @return string
  753. */
  754. function categoryUrl( $uid )
  755. {
  756. $pid = ( $this->conf[ 'categoryListingPage' ] )
  757. ? $this->conf[ 'categoryListingPage' ]
  758. : $this->cObj->data[ 'pid' ];
  759. $linkArray = array(
  760. 'parameter' => $pid
  761. , 'returnLast' => 'url'
  762. , 'no_cache' => 0
  763. , 'useCacheHash' => 0
  764. , 'additionalParams' =>
  765. "&tx_t3consultancies_pi1[service]={$uid}"
  766. );
  767. $url = '/'
  768. . $this->cObj->typolink(
  769. ''
  770. , $linkArray
  771. );
  772. return $url;
  773. }
  774. /**
  775. * Return string of detail URL
  776. *
  777. * @return string
  778. */
  779. function detailsUrl()
  780. {
  781. $linkArray = array(
  782. 'parameter' => $this->conf[
  783. 'detailPid' ]
  784. , 'returnLast' => 'url'
  785. , 'no_cache' => 0
  786. , 'useCacheHash' => 0
  787. , 'additionalParams' => "&tx_t3consultancies_pi1[showUid]={$this->internal['currentRow']['uid']}"
  788. );
  789. $url = '/'
  790. . $this->cObj->typolink(
  791. ''
  792. , $linkArray
  793. );
  794. return $url;
  795. }
  796. /**
  797. * Selects and renders the referencelist for the consultancy.
  798. */
  799. function getRefListForRecord() {
  800. if ($this->showRef) {
  801. $value="";
  802. $pLR = $this->pidListForReferences();
  803. if ($pLR) {
  804. $pLR="pid IN (".$pLR.") AND";
  805. } else $pLR="";
  806. $query = "SELECT * FROM tx_t3references WHERE ".$pLR." dev_rel=".intval($this->internal["currentRow"]["uid"]).
  807. ($this->conf["selectedOnly"] ? ' AND tx_t3references.selected' : '').
  808. $this->cObj->enableFields("tx_t3references").
  809. " ORDER BY tx_t3references.weight DESC, tx_t3references.launchdate DESC, tx_t3references.title";
  810. $res = mysql(TYPO3_db,$query);
  811. #echo mysql_error();
  812. $marginBetweenRefs = t3lib_div::intInRange($this->conf["singleView."]["showRefList."]["marginBetweenRefs"],1,100,10);
  813. $marginToImg = t3lib_div::intInRange($this->conf["singleView."]["showRefList."]["marginToImg"],1,100,10);
  814. $refPage = intval($this->conf["singleView."]["showRefList."]["refPage"]);
  815. $items=array();
  816. while ($row=mysql_fetch_assoc($res)) {
  817. list($srcDump) = t3lib_div::trimExplode(",",$row["screendump"],1);
  818. $img = $this->getReferencesImage($srcDump,$this->conf["singleView."]["showRefList."]["screenDump."]);
  819. $descr = t3lib_div::fixed_lgd(strip_tags($row["description"]),200).
  820. " ".$this->linkSingleRef($this->pi_getLL("more"),$row["uid"],$refPage);
  821. $title = $row["title"];
  822. $url = 'URL: ';
  823. $url .= $this->pi_linkToPage(
  824. $this->internal["currentRow"][ 'url' ]
  825. , ( $this->internal["currentRow"][ 'real_url' ] )
  826. ? $this->internal["currentRow"][ 'real_url' ]
  827. : $this->internal["currentRow"][ 'url' ]
  828. );
  829. $items[]='<tr>
  830. <td width="95%" valign="top">
  831. <h3>'.$title.'</h3>
  832. <p>'.$descr.'</p>
  833. <p'.$this->pi_classParam("reflist-url").'>'.$url.'</p>
  834. </td>
  835. <td><img src="clear.gif" width='.$marginToImg.' height=1></td>
  836. <td valign="top">'.$img.'</td>
  837. </tr>
  838. <tr>
  839. <td colspan=3><img src="clear.gif" width=1 height='.$marginBetweenRefs.'></td>
  840. </tr>';
  841. }
  842. if (count($items)) {
  843. $retVal = '<table '.$this->conf["singleView."]["showRefList."]["tableParams"].'>'.implode("",$items).'</table>';
  844. } else {
  845. $retVal = '<p>Currently no references is available for this consultancy.</p>';
  846. }
  847. $retVal = '<h2>References:</h2>'.$retVal;
  848. $retVal = '<div'.$this->pi_classParam("reflist").'>'.$retVal.'</div>';
  849. return $retVal;
  850. } else {
  851. return '<font color="red">Sorry, the references could not be listed, because the reference plugin is not enabled</font>';
  852. }
  853. }
  854. /**
  855. * Wraps the $str in a link to a single display of the record.
  856. */
  857. function linkSingleRef($str,$uid,$refPage) {
  858. if ($refPage) {
  859. $this->pi_tmpPageId=$refPage;
  860. $str = $this->pi_linkTP($str,array("tx_t3references_pi1[showUid]" => $uid),1);
  861. }
  862. $this->pi_tmpPageId=0;
  863. return $str;
  864. }
  865. /**
  866. * Returns the list of items.
  867. */
  868. function pi_list_makelist($res) {
  869. // Make list table header:
  870. $tRows=array();
  871. $this->internal["currentRow"]="";
  872. $tRows[]=$this->pi_list_header();
  873. // Make list table rows
  874. $c=0;
  875. while($this->internal["currentRow"] = mysql_fetch_assoc($res)) {
  876. $tRows[]=$this->pi_list_row_2($c);
  877. $c++;
  878. }
  879. $out = '<DIV'.$this->pi_classParam("listrow").'><table>'.implode("",$tRows).'</table></DIV>';
  880. return $out;
  881. }
  882. /**
  883. * Displays the consultancy list:
  884. */
  885. function pi_list_row_2($c) {
  886. $editPanel = $this->pi_getEditPanel();
  887. if ($editPanel) $editPanel="<TD>".$editPanel."</TD>";
  888. return '<tr'.($c%2 ? $this->pi_classParam("listrow-odd") : "").'>
  889. <td valign="top"><P>'.$this->getFieldContent("title").'</P></td>
  890. <td valign="top"><P>'.$this->getFieldContent("cntry").'</P></td>
  891. <td valign="top"><P>'.$this->getFieldContent("services").'</P></td>
  892. '.($this->showRef && $this->sitesMade?'<td valign="top" align="center"><P>'.$this->getFieldContent("_ref").'</P></td>':'').'
  893. <td valign="top"><P>'.$this->getFieldContent("details").'</P></td>
  894. '.$editPanel.'
  895. </tr>';
  896. }
  897. /**
  898. * Displays consultancy list header
  899. */
  900. function pi_list_header() {
  901. return '<tr'.$this->pi_classParam("listrow-header").'>
  902. <td nowrap><P>'.$this->getFieldHeader("title").'</P></td>
  903. <td nowrap><P>'.$this->getFieldHeader("cntry").'</P></td>
  904. <td nowrap><P>'.$this->getFieldHeader("services").'</P></td>
  905. '.($this->showRef && $this->sitesMade?'<td><P>'.$this->getFieldHeader("references").'</P></td>':'').'
  906. <td><P>'.$this->getFieldHeader("details").'</P></td>
  907. </tr>';
  908. }
  909. /**
  910. * Returns processed content for a given fieldname ($fN) from the current row
  911. *
  912. * @param array optional data
  913. * @return string
  914. */
  915. function getFieldContent($fN, $data = false )
  916. {
  917. switch($fN) {
  918. case "details":
  919. return $this->pi_list_linkSingle($this->pi_getLL("Details"),$this->internal["currentRow"]["uid"],1,array("lang"=>$this->conf["selectCountryFirst"]?$this->piVars["lang"]:"", "pointer"=>$this->piVars["pointer"]));
  920. break;
  921. case "description":
  922. $content = implode("<br/>",t3lib_div::trimExplode(chr(10),strip_tags(t3lib_div::fixed_lgd($this->internal["currentRow"]["description"],t3lib_div::intInRange($this->conf["truncate_limit"],1,100000,1000),$this->pi_getLL("trunc")),"<b><i><u><strong><em><a>"),1));
  923. return $content;
  924. break;
  925. case "title":
  926. $title = $this->internal["currentRow"]["title"];
  927. if ( 'navigation' == $this->conf[ 'CMD' ] )
  928. {
  929. return $this->pi_linkToPage(
  930. $title
  931. , $this->categoryUrl(
  932. $this->internal[ 'currentRow' ][ 'uid' ]
  933. )
  934. );
  935. }
  936. elseif ( $this->singleViewOn
  937. && ( $this->internal["currentRow"]["real_url"]
  938. || $this->internal["currentRow"]["url"]
  939. )
  940. && $this->conf["linkTitle"]
  941. )
  942. {
  943. // show real_url if it exists
  944. return $this->pi_linkToPage(
  945. // todo image version of title
  946. $title
  947. , ( $this->internal["currentRow"][ 'real_url' ] )
  948. ? $this->internal["currentRow"][ 'real_url' ]
  949. : $this->internal["currentRow"][ 'url' ]
  950. );
  951. }
  952. elseif ( $this->singleViewOn && ! $this->conf["linkTitle"] )
  953. {
  954. return $title;
  955. }
  956. else
  957. {
  958. return $this->pi_linkToPage(
  959. $title
  960. , $this->detailsUrl()
  961. );
  962. }
  963. break;
  964. case "cntry":
  965. if (isset($this->countries[$this->internal["currentRow"][$fN]])) {
  966. return $this->countries[$this->internal["currentRow"][$fN]];
  967. } else {
  968. $cntryRec = $this->pi_getRecord("static_countries",$this->internal["currentRow"][$fN]);
  969. return $cntryRec["cn_short_en"];
  970. }
  971. break;
  972. case "services":
  973. $query = "SELECT uid_foreign FROM tx_t3consultancies_services_mm WHERE uid_local=".intval($this->internal["currentRow"]["uid"])." ORDER BY sorting";
  974. $res = mysql(TYPO3_db,$query);
  975. $services=array();
  976. while($row=mysql_fetch_assoc($res)) {
  977. if (isset($this->categories[$row["uid_foreign"]])) {
  978. $services[]=$this->categories[$row["uid_foreign"]];
  979. } else {
  980. $catRec = $this->pi_getRecord("tx_t3consultancies_cat",$row["uid_foreign"]);
  981. $services[]=$catRec["title"];
  982. }
  983. }
  984. return implode($this->singleViewOn?', ':'</BR>',$services);
  985. break;
  986. case "_ref":
  987. if ($this->showRef) {
  988. $value="";
  989. $pLR = $this->pidListForReferences();
  990. if ($pLR) {
  991. $pLR="pid IN (".$pLR.") AND";
  992. } else $pLR="";
  993. $query = "SELECT count(*) FROM tx_t3references WHERE ".$pLR." dev_rel=".intval($this->internal["currentRow"]["uid"]).
  994. ($this->conf["selectedOnly"] ? ' AND tx_t3references.selected' : '').
  995. $this->cObj->enableFields("tx_t3references");
  996. $res = mysql(TYPO3_db,$query);
  997. if ($row=mysql_fetch_assoc($res)) {
  998. $value=$row["count(*)"]?$row["count(*)"]:"-";
  999. }
  1000. return $value;
  1001. }
  1002. break;
  1003. case "contact_email":
  1004. if ($this->internal["currentRow"][$fN])
  1005. {
  1006. return $this->pi_linkToPage(
  1007. $this->internal["currentRow"][$fN]
  1008. , $this->internal["currentRow"][$fN]
  1009. );
  1010. }
  1011. break;
  1012. case "fe_owner_user":
  1013. $fe_user = $this->pi_getRecord("fe_users",$this->internal["currentRow"][$fN]);
  1014. if (is_array($fe_user)) {
  1015. return '<strong>'.$fe_user["username"].'</strong>';
  1016. } else {
  1017. return '<em>'.$this->pi_getLL("NA").'</em>';
  1018. }
  1019. break;
  1020. case 'url':
  1021. if ($this->internal['currentRow']['url'])
  1022. {
  1023. // show real_url if it exists
  1024. return $this->pi_linkToPage(
  1025. $this->internal["currentRow"][$fN]
  1026. , ( $this->internal["currentRow"][ 'real_url' ] )
  1027. ? $this->internal["currentRow"][ 'real_url' ]
  1028. : $this->internal["currentRow"][$fN]
  1029. );
  1030. }
  1031. break;
  1032. case 'map_url':
  1033. if ( $this->internal['currentRow'][ $fN ] )
  1034. {
  1035. $name = $this->pi_getLL( 'map_url' );
  1036. $value = '<a href="'
  1037. . $this->internal['currentRow'][$fN]
  1038. . '" target="_blank">'
  1039. . $name
  1040. . '</a>';
  1041. return $value;
  1042. }
  1043. break;
  1044. case 'logo':
  1045. if ( $this->internal[ 'currentRow' ][ $fN ] )
  1046. {
  1047. return $this->cObj->imageLinkWrap( $this->getImage(
  1048. $this->internal[ 'currentRow' ][ $fN ]
  1049. , $this->conf[ 'logoImage.' ]
  1050. )
  1051. , "uploads/tx_t3consultancies/"
  1052. . $this->internal[ 'currentRow' ][ $fN ]
  1053. , $this->conf[ 'logoImage.' ]
  1054. );
  1055. }
  1056. break;
  1057. case 'featured_logo':
  1058. if ( $this->internal[ 'currentRow' ][ $fN ] )
  1059. {
  1060. return $this->cObj->imageLinkWrap( $this->getImage(
  1061. $this->internal[ 'currentRow' ][ $fN ]
  1062. , $this->conf[ 'logo.' ]
  1063. )
  1064. , "uploads/tx_t3consultancies/"
  1065. . $this->internal[ 'currentRow' ][ $fN ]
  1066. , $this->conf[ 'enlargeImage.' ]
  1067. );
  1068. }
  1069. break;
  1070. case 'coupon':
  1071. if ( $this->internal[ 'currentRow' ][ $fN ] )
  1072. {
  1073. return $this->cObj->imageLinkWrap( $this->getImage(
  1074. $this->internal[ 'currentRow' ][ $fN ]
  1075. , $this->conf[ 'coupon.' ]
  1076. )
  1077. , "uploads/tx_t3consultancies/"
  1078. . $this->internal[ 'currentRow' ][ $fN ]
  1079. , $this->conf[ 'coupon.' ]
  1080. );
  1081. }
  1082. break;
  1083. case 'address':
  1084. return nl2br( $this->internal[ 'currentRow' ][ $fN ] );
  1085. break;
  1086. case 'city':
  1087. default:
  1088. return ( $this->internal[ 'currentRow' ][ $fN ] )
  1089. ? $this->internal[ 'currentRow' ][ $fN ] . ','
  1090. : '';
  1091. break;
  1092. case '':
  1093. default:
  1094. return $this->internal[ 'currentRow' ][ $fN ];
  1095. break;
  1096. }
  1097. return '';
  1098. }
  1099. /**
  1100. * Returns a list of integer-pids for selecting the references belonging to consultancies
  1101. */
  1102. function pidListForReferences() {
  1103. $v= implode(",",t3lib_div::intExplode(",",$this->conf["pidList_references"]));
  1104. return $v;
  1105. }
  1106. /**
  1107. * Returns the header text of a field (from locallang)
  1108. */
  1109. function getFieldHeader($fN) {
  1110. switch($fN) {
  1111. default:
  1112. return $this->pi_getLL("listFieldHeader_".$fN,"[".$fN."]");
  1113. break;
  1114. }
  1115. }
  1116. /**
  1117. * Returns an image given by $TSconf
  1118. */
  1119. function getImage($filename,$TSconf) {
  1120. list($theImage)=explode(",",$filename);
  1121. $TSconf["file"] = "uploads/tx_t3consultancies/".$theImage;
  1122. $img = $this->cObj->IMAGE($TSconf);
  1123. return $img;
  1124. }
  1125. /**
  1126. * Returns an image given by $TSconf for references
  1127. */
  1128. function getReferencesImage($filename,$TSconf) {
  1129. list($theImage)=explode(",",$filename);
  1130. $TSconf["file"] = "uploads/tx_t3references/".$theImage;
  1131. $img = $this->cObj->IMAGE($TSconf);
  1132. return $img;
  1133. }
  1134. /**
  1135. * Makes the editing form for submitting information by frontend users.
  1136. */
  1137. function getFe_adminLibConf() {
  1138. $feAConf = $this->conf["fe_adminLib."];
  1139. $feAConf["templateContent"]='
  1140. <!-- ###TEMPLATE_EDIT### -->
  1141. <h3>Edit "###FIELD_title###"</h3>
  1142. <table border=0 cellpadding=1 cellspacing=2>
  1143. <FORM name="tx_t3consultancies_form" method="post" action="###FORM_URL###" enctype="'.$GLOBALS["TYPO3_CONF_VARS"]["SYS"]["form_enctype"].'">
  1144. '.$this->makeFormFromConfig($feAConf["edit."],$feAConf["table"]).'
  1145. <tr>
  1146. <td></td>
  1147. <td></td>
  1148. <td>
  1149. ###HIDDENFIELDS###
  1150. <input type="Submit" name="submit" value="'.$this->pi_getLL("feAL_save").'">
  1151. </td>
  1152. </tr>
  1153. </FORM>
  1154. </table>
  1155. <p>&nbsp;</p>
  1156. <p style="color: red;"><a href="###FORM_URL###&cmd=delete&backURL=###FORM_URL_ENC###&rU=###REC_UID###" onClick="return confirm(\'Are you sure?\');">'.$this->pi_getLL("feAL_delete").'</a></p>
  1157. <p>&nbsp;</p>
  1158. <!-- ###TEMPLATE_EDIT### end-->
  1159. <!-- ###TEMPLATE_EDIT_SAVED### begin-->
  1160. <h3>'.$this->pi_getLL("Managing_consultancies").'</h3>
  1161. <p>'.$this->pi_getLL("feAL_contentSaved").'</p>
  1162. <p>&nbsp;</p>
  1163. <!-- ###TEMPLATE_EDIT_SAVED### end-->
  1164. <!-- ###TEMPLATE_CREATE_LOGIN### -->
  1165. <h3>Create new consultancy entry</h3>
  1166. <table border=0 cellpadding=1 cellspacing=2>
  1167. <FORM name="tx_t3consultancies_form" method="post" action="###FORM_URL###" enctype="'.$GLOBALS["TYPO3_CONF_VARS"]["SYS"]["form_enctype"].'">
  1168. '.$this->makeFormFromConfig($feAConf["create."],$feAConf["table"]).'
  1169. <tr>
  1170. <td></td>
  1171. <td></td>
  1172. <td>
  1173. ###HIDDENFIELDS###
  1174. <input type="Submit" name="submit" value="'.$this->pi_getLL("feAL_save").'">
  1175. </td>
  1176. </tr>
  1177. </FORM>
  1178. </table>
  1179. <!-- ###TEMPLATE_CREATE_LOGIN### end-->
  1180. <!-- ###TEMPLATE_CREATE_SAVED### begin-->
  1181. <h3>'.$this->pi_getLL("Managing_consultancies").'</h3>
  1182. <p>'.$this->pi_getLL("feAL_contentSaved").'</p>
  1183. <p>&nbsp;</p>
  1184. <!-- ###TEMPLATE_CREATE_SAVED### end-->
  1185. <!-- ###TEMPLATE_DELETE_SAVED### begin-->
  1186. <h3>'.$this->pi_getLL("Managing_consultancies").'</h3>
  1187. <p>'.$this->pi_getLL("feAL_deleteSaved").'</p>
  1188. <p>&nbsp;</p>
  1189. <!-- ###TEMPLATE_DELETE_SAVED### end-->
  1190. <!-- ###TEMPLATE_EDITMENU### begin -->
  1191. <h3>'.$this->pi_getLL("Managing_consultancies").'</h3>
  1192. <p>'.$this->pi_getLL("feAL_listOfItems").'</p>
  1193. <p>--</p>
  1194. <!-- ###ALLITEMS### begin -->
  1195. <!-- ###ITEM### begin -->
  1196. <p><a href="###FORM_URL###&rU=###FIELD_uid###&cmd=edit">###FIELD_title###</a></p>
  1197. <!-- ###ITEM### end -->
  1198. <!-- ###ALLITEMS### end -->
  1199. <p>--</p>
  1200. <p><a href="###FORM_URL###&cmd=">'.$this->pi_getLL("feAL_createNew").'</a></p>
  1201. <p>&nbsp;</p>
  1202. <!-- ###TEMPLATE_EDITMENU### -->
  1203. <!-- ###TEMPLATE_EDITMENU_NOITEMS### begin -->
  1204. <h3>'.$this->pi_getLL("Managing_consultancies").'</h3>
  1205. <p>'.$this->pi_getLL("feAL_noItems").'</p>
  1206. <p><a href="###FORM_URL###&cmd=">'.$this->pi_getLL("feAL_createNew").'</a></p>
  1207. <p>&nbsp;</p>
  1208. <!-- ###TEMPLATE_EDITMENU_NOITEMS### -->
  1209. <!-- ###EMAIL_TEMPLATE_CREATE_SAVED-ADMIN### begin -->
  1210. New consultancy created.
  1211. <!--###SUB_RECORD###-->
  1212. Title: ###FIELD_title###
  1213. Description: ###FIELD_description###
  1214. Contact email: ###FIELD_contact_email###
  1215. Contact name: ###FIELD_contact_name###
  1216. Approve:
  1217. ###THIS_URL######FORM_URL######SYS_SETFIXED_approve###
  1218. Delete:
  1219. ###THIS_URL######FORM_URL######SYS_SETFIXED_DELETE###
  1220. <!--###SUB_RECORD###-->
  1221. <!-- ###EMAIL_TEMPLATE_CREATE_SAVED-ADMIN### end-->
  1222. <!-- ###EMAIL_TEMPLATE_EDIT_SAVED-ADMIN### begin -->
  1223. Consultancy record edited.
  1224. <!--###SUB_RECORD###-->
  1225. Title: ###FIELD_title###
  1226. Description: ###FIELD_description###
  1227. Contact email: ###FIELD_contact_email###
  1228. Contact name: ###FIELD_contact_name###
  1229. Approve:
  1230. ###THIS_URL######FORM_URL######SYS_SETFIXED_approve###
  1231. Delete:
  1232. ###THIS_URL######FORM_URL######SYS_SETFIXED_DELETE###
  1233. <!--###SUB_RECORD###-->
  1234. <!-- ###EMAIL_TEMPLATE_EDIT_SAVED-ADMIN### end-->
  1235. <!-- ###EMAIL_TEMPLATE_SETFIXED_DELETE### begin -->
  1236. Consultancy DELETED!
  1237. <!--###SUB_RECORD###-->
  1238. Title: ###FIELD_title###
  1239. Description: ###FIELD_description###
  1240. Your entry has been deleted by the admin for some reason.
  1241. - kind regards.
  1242. <!--###SUB_RECORD###-->
  1243. <!-- ###EMAIL_TEMPLATE_SETFIXED_DELETE### begin -->
  1244. <!-- ###EMAIL_TEMPLATE_SETFIXED_approve### begin -->
  1245. Consultancy approved
  1246. <!--###SUB_RECORD###-->
  1247. Title: ###FIELD_title###
  1248. Description: ###FIELD_description###
  1249. Your consultancy entry has been approved!
  1250. - kind regards.
  1251. <!--###SUB_RECORD###-->
  1252. <!-- ###EMAIL_TEMPLATE_SETFIXED_approve### begin -->
  1253. <!-- ###TEMPLATE_SETFIXED_OK### -->
  1254. <h3>Setfixed succeeded</h3>
  1255. Record uid; ###FIELD_uid###
  1256. <!-- ###TEMPLATE_SETFIXED_OK### end-->
  1257. <!-- ###TEMPLATE_SETFIXED_OK_DELETE### -->
  1258. <h3>Setfixed delete record "###FIELD_uid###"</h3>
  1259. <!-- ###TEMPLATE_SETFIXED_OK_DELETE### end-->
  1260. <!-- ###TEMPLATE_SETFIXED_FAILED### -->
  1261. <h3>Setfixed failed!</h3>
  1262. <p>May happen if you click the setfixed link a second time (if the record has changed since the setfixed link was generated this error will happen!)</p>
  1263. <!-- ###TEMPLATE_SETFIXED_FAILED### end-->
  1264. <!-- ###TEMPLATE_AUTH### -->
  1265. <h3>Authentication failed</h3>
  1266. <p>Of some reason the authentication failed. </p>
  1267. <!-- ###TEMPLATE_AUTH### end-->
  1268. <!-- ###TEMPLATE_NO_PERMISSIONS### -->
  1269. <h3>No permissions to edit record</h3>
  1270. <p>Sorry, you did not have permissions to edit the record.</p>
  1271. <!-- ###TEMPLATE_NO_PERMISSIONS### end-->
  1272. ';
  1273. $feAConf["addParams"]=$this->conf["parent."]["addParams"].t3lib_div::implodeArrayForUrl($this->prefixId,$this->piVars,"",1);
  1274. return $feAConf;
  1275. }
  1276. /**
  1277. *
  1278. */
  1279. function makeFormFromConfig($conf,$table) {
  1280. # debug($table);
  1281. $fields = array_unique(t3lib_div::trimExplode(",",$conf["fields"],1));
  1282. $reqFields = array_unique(t3lib_div::trimExplode(",",$conf["required"],1));
  1283. #debug($conf);
  1284. $tableRows = array();
  1285. while(list(,$fN)=each($fields)) {
  1286. $fieldCode = $this->getFormFieldCode($fN,'FE['.$table.']['.$fN.']');
  1287. if ($fieldCode) {
  1288. if (in_array($fN,$reqFields)) {
  1289. $reqMsg='<!--###SUB_REQUIRED_FIELD_'.$fN.'###--><p style="color: red; font-weight: bold;">'.$this->pi_getLL("feAL_required").'</p><!--###SUB_REQUIRED_FIELD_'.$fN.'###-->';
  1290. $reqMarker=$this->pi_getLL("feAL_requiredMark");
  1291. } else {
  1292. $reqMsg='';
  1293. $reqMarker='';
  1294. }
  1295. $tableRows[]='<tr>
  1296. <td><p>'.$this->pi_getLL("feAL_fN_".$fN,"feAL_fN_".$fN).' '.$reqMarker.'</p></td>
  1297. <td><img src="clear.gif" width=10 height=1></td>
  1298. <td>'.$reqMsg.$fieldCode.'</td>
  1299. </tr>';
  1300. }
  1301. }
  1302. return implode(chr(10),$tableRows);
  1303. # debug($tableRows);
  1304. }
  1305. function getFormFieldCode($fN,$fieldName) {
  1306. switch($fN) {
  1307. case "description":
  1308. return '<textarea name="'.$fieldName.'" rows="5" wrap="virtual" style="width: 300px;"></textarea>';
  1309. break;
  1310. case "logo":
  1311. return '<input type="file" name="'.$fieldName.'[]" style="width: 300px;">';
  1312. break;
  1313. case "hidden":
  1314. return "";
  1315. break;
  1316. case "cntry":
  1317. $opt=array();
  1318. $opt[]='<option value="0"></option>';
  1319. $query = "SELECT uid,cn_short_en FROM static_countries ORDER BY cn_short_en";
  1320. $res = mysql(TYPO3_db,$query);
  1321. while($row=mysql_fetch_assoc($res)) {
  1322. $opt[]='<option value="'.$row["uid"].'">'.$row["cn_short_en"].'</option>';
  1323. }
  1324. return '<select name="'.$fieldName.'">'.implode("",$opt).'</select>';
  1325. break;
  1326. case "services":
  1327. $opt=array();
  1328. $query = "SELECT uid,title FROM tx_t3consultancies_cat WHERE 1=1 ".
  1329. $this->cObj->enableFields("tx_t3consultancies_cat").
  1330. " ORDER BY title";
  1331. $res = mysql(TYPO3_db,$query);
  1332. while($row=mysql_fetch_assoc($res)) {
  1333. $opt[]='<option value="'.$row["uid"].'">'.$row["title"].'</option>';
  1334. }
  1335. return '<select name="'.$fieldName.'[]" multiple size='.count($opt).'>'.implode("",$opt).'</select>';
  1336. break;
  1337. default:
  1338. return '<input type="text" name="'.$fieldName.'" style="width: 300px;">';
  1339. break;
  1340. }
  1341. }
  1342. function afterSave($content,$conf) {
  1343. $inVar = t3lib_div::GPvar("FE",1);
  1344. $services = $inVar["tx_t3consultancies"]["services"];
  1345. $uid = $content["rec"]["uid"];
  1346. if (intval($uid)>0 && is_array($services)) {
  1347. $query = "DELETE FROM tx_t3consultancies_services_mm WHERE uid_local=".intval($uid);
  1348. $res = mysql(TYPO3_db,$query);
  1349. if (is_array($services)) {
  1350. reset($services);
  1351. while(list($k,$sId)=each($services)) {
  1352. $query = "INSERT INTO tx_t3consultancies_services_mm (uid_local,uid_foreign,tablenames,sorting) VALUES (".intval($uid).",".intval($sId).",'',".intval($k).")";
  1353. $res = mysql(TYPO3_db,$query);
  1354. }
  1355. }
  1356. }
  1357. }
  1358. function updateArray($content,$conf) {
  1359. $content["services"]=array();
  1360. $query = "SELECT uid_foreign FROM tx_t3consultancies_services_mm WHERE uid_local=".intval($content["uid"]);
  1361. $res = mysql(TYPO3_db,$query);
  1362. while($row=mysql_fetch_assoc($res)) {
  1363. $content["services"][]=$row["uid_foreign"];
  1364. }
  1365. unset($content["weight"]);
  1366. unset($content["selected"]);
  1367. return $content;
  1368. }
  1369. /**
  1370. * Returns array containing textImage helper
  1371. *
  1372. * @param array conf
  1373. * @return array
  1374. */
  1375. function buildTextImageConf( $conf )
  1376. {
  1377. $title = $conf[ 'title.' ];
  1378. $temp = array();
  1379. $temp['alttext.']['current'] = 1;
  1380. $temp['stdWrap.']['wrap'] =
  1381. '<div style="border: 0;"> | </div>';
  1382. $temp['file'] = 'GIFBUILDER';
  1383. $temp['file.']['XY'] = '[10.w],[10.h]';
  1384. $temp['file.']['backColor'] = $title[ 'backColor' ];
  1385. $temp['file.']['10'] = 'TEXT';
  1386. $temp['file.']['10.']['fontColor'] = $title[ 'fontColor' ];
  1387. $temp['file.']['10.']['fontFile'] = $title[ 'fontFile' ];
  1388. $temp['file.']['10.']['fontSize'] = $title[ 'fontSize' ];
  1389. $temp['file.']['10.']['maxWidth'] = 600;
  1390. $temp['file.']['10.']['align'] = 'left';
  1391. $temp['file.']['10.']['offset'] = '0,17';
  1392. $temp['file.']['10.']['niceText'] = 1;
  1393. $conf[ 'textImage' ] = $temp;
  1394. return $conf;
  1395. }
  1396. /**
  1397. * Return string of textual image.
  1398. *
  1399. * @param string image text
  1400. * @return string
  1401. */
  1402. function textImage( $text )
  1403. {
  1404. $this->conf[ 'textImage' ]['file.']['10.']['text'] = $text;
  1405. $image = $this->cObj->cObjGetSingle( 'IMAGE'
  1406. , $this->conf[ 'textImage' ]
  1407. );
  1408. return $image;
  1409. }
  1410. }
  1411. if (defined("TYPO3_MODE") && $TYPO3_CONF_VARS[TYPO3_MODE]["XCLASS"]["ext/t3consultancies/pi1/class.tx_t3consultancies_pi1.php"]) {
  1412. include_once($TYPO3_CONF_VARS[TYPO3_MODE]["XCLASS"]["ext/t3consultancies/pi1/class.tx_t3consultancies_pi1.php"]);
  1413. }
  1414. ?>