1<?php 2/* 3 * e107 website system 4 * 5 * Copyright (C) 2008-2009 e107 Inc (e107.org) 6 * Released under the terms and conditions of the 7 * GNU General Public License (http://www.gnu.org/licenses/gpl.txt) 8 * 9 * 10 * 11 * $Source: /cvs_backup/e107_0.8/e107_plugins/download/download_shortcodes.php,v $ 12 * $Revision$ 13 * $Date$ 14 * $Author$ 15 */ 16 17if (!defined('e107_INIT')) { exit; } 18 19/** 20 * download_shortcodes 21 */ 22class download_shortcodes extends e_shortcode 23{ 24 public $qry; 25 public $dlsubrow; 26 public $dlsubsubrow; 27 public $mirror; 28 29 public $parent; 30 public $grandparent; 31 32 /** 33 * download_shortcodes constructor 34 */ 35 function __construct() 36 { 37 38 } 39 40 41 public function breadcrumb() 42 { 43 $breadcrumb = array(); 44 45 switch ($this->qry['action']) 46 { 47 case 'mirror': 48 $breadcrumb[] = array('text' => LAN_PLUGIN_DOWNLOAD_NAME, 'url' => e107::url('download', 'index')); 49 $breadcrumb[] = array('text' => $this->var['download_category_name'], 'url' => e107::url('download', 'category', $this->var)); // e_SELF."?action=list&id=".$this->var['download_category_id']); 50 $breadcrumb[] = array('text' => $this->var['download_name'], 'url' => e107::url('download', 'item', $this->var)); // e_SELF."?action=view&id=".$this->var['download_id']); 51 $breadcrumb[] = array('text' => LAN_dl_67, 'url' => null); 52 break; 53 54 case 'maincats': 55 $breadcrumb[] = array('text' => LAN_PLUGIN_DOWNLOAD_NAME, 'url' => e107::url('download','index')); 56 break; 57 58 default: 59 $breadcrumb[] = array('text' => LAN_PLUGIN_DOWNLOAD_NAME, 'url' => e107::url('download','index')); 60 61 if(!empty($this->grandparent)) 62 { 63 $breadcrumb[] = array('text' => $this->grandparent['download_category_name'], 'url' => ($this->grandparent['download_category_id']) ? e107::url('download', 'category', $this->grandparent) : null); 64 } 65 66 if(!empty($this->parent)) 67 { 68 $breadcrumb[] = array('text' => $this->parent['download_category_name'], 'url' => ($this->parent['download_category_id']) ? e107::url('download', 'category', $this->parent) : null); 69 } 70 71 $breadcrumb[] = array('text' => $this->var['download_category_name'], 'url' => ($this->var['download_category_id']) ? e107::url('download', 'category', $this->var) : null); 72 $breadcrumb[] = array('text' => varset($this->var['download_name']), 'url' => null); 73 break; 74 } 75 76 77 e107::breadcrumb($breadcrumb); 78 79 } 80 81 function sc_download_breadcrumb($parm='') 82 { 83 $tp = e107::getParser(); 84 $frm = e107::getForm(); 85 86 $breadcrumb = e107::breadcrumb(); 87 88 return $frm->breadcrumb($breadcrumb); 89 90 } 91 92 93 // Category ************************************************************************************ 94 public function sc_download_cat_main_name() 95 { 96 $tp = e107::getParser(); 97 98 if(!empty($this->var['d_count'])) 99 { 100 $url = e107::url('download', 'category', $this->var); 101 return "<a href='".$url."'>".$tp->toHTML($this->var['download_category_name'], FALSE, 'TITLE')."</a>"; 102 } 103 104 return $tp->toHTML($this->var['download_category_name'], FALSE, 'TITLE'); 105 } 106 107 public function sc_download_cat_main_description() 108 { 109 $tp = e107::getParser(); 110 return $tp->toHTML($this->var['download_category_description'], TRUE, 'DESCRIPTION'); 111 } 112 113 public function sc_download_cat_main_icon() 114 { 115 // Pass count as 1 to force non-empty icon 116 return $this->_sc_cat_icons($this->var['download_category_icon'], 1, $this->var['download_category_name']); 117 } 118 119 public function sc_download_cat_main_count() 120 { 121 if(!empty($this->var['d_count'])) 122 { 123 return intval($this->var['d_count']); 124 } 125 } 126 127 public function sc_download_cat_main_size() 128 { 129 if(!empty($this->var['d_count'])) 130 { 131 return eHelper::parseMemorySize($this->var['d_size']); 132 } 133 } 134 135 136 public function sc_download_cat_main_downloaded() 137 { 138 if(!empty($this->var['d_count'])) 139 { 140 return intval($this->var['d_requests']); 141 } 142 } 143 144 // Sub-Category ******************************************************************************** 145 function sc_download_cat_sub_name($parm = '') 146 { 147 $tp = e107::getParser(); 148 149 $class = 'category-name'; 150 $class .= $this->isNewDownload($this->dlsubrow['d_last']) ? ' new' : ''; 151 152 if($parm == 'raw') 153 { 154 return $tp->toHTML($this->dlsubrow['download_category_name'], FALSE, 'TITLE'); 155 } 156 157 if ($this->dlsubrow['d_count']) 158 { 159 160 $url = e107::url('download', 'category', $this->dlsubrow); 161 return "<a class='".$class."' href='".$url."'>".$tp->toHTML($this->dlsubrow['download_category_name'], FALSE, 'TITLE')."</a>"; 162 163 // return "<a class='".$class."' href='".e_PLUGIN_ABS."download/download.php?action=list&id=".$this->dlsubrow['download_category_id']."'>".$tp->toHTML($this->dlsubrow['download_category_name'], FALSE, 'TITLE')."</a>"; 164 } 165 else 166 { 167 return $tp->toHTML($this->dlsubrow['download_category_name'], FALSE, 'TITLE'); 168 } 169 } 170 171 function sc_download_cat_sub_description() 172 { 173 $tp = e107::getParser(); 174 return $tp->toHTML($this->dlsubrow['download_category_description'], TRUE, 'DESCRIPTION'); 175 } 176 177 function sc_download_cat_sub_icon() 178 { 179 return $this->_sc_cat_icons($this->dlsubrow['download_category_icon'], $this->dlsubrow['d_count'], $this->dlsubrow['download_category_name']); 180 } 181 182 function sc_download_cat_sub_new_icon() 183 { 184 return ($this->isNewDownload($this->dlsubrow['d_last_subs'])) ? $this->renderNewIcon() : ""; 185 } 186 187 function sc_download_cat_sub_count() 188 { 189 return $this->dlsubrow['d_count']; 190 } 191 192 function sc_download_cat_sub_size() 193 { 194 return eHelper::parseMemorySize($this->dlsubrow['d_size']); 195 } 196 197 function sc_download_cat_sub_downloaded() 198 { 199 return intval($this->dlsubrow['d_requests']); 200 } 201 202 203 // Sub-Sub-Category **************************************************************************** 204 205 206 function sc_download_cat_subsub_name($parm = '') 207 { 208 $tp = e107::getParser(); 209 210 // isNewDownload 211 $class = 'category-name'; 212 $class .= $this->isNewDownload($this->dlsubsubrow['d_last']) ? ' new' : ''; 213 214 if($parm == 'raw') 215 { 216 return $tp->toHTML($this->dlsubsubrow['download_category_name'], FALSE, 'TITLE'); 217 } 218 219 if ($this->dlsubsubrow['d_count']) 220 { 221 $url = e107::url('download', 'category', $this->dlsubsubrow); 222 // /list/category', array('id'=>$this->dlsubsubrow['download_category_id'], 'name'=> vartrue($this->dlsubsubrow['download_category_sef'],'--sef-not-set--'))); 223 // e_PLUGIN_ABS."download/download.php?action=list&id=".$this->dlsubsubrow['download_category_id'] 224 return "<a class='".$class."' href='".$url."'>".$tp->toHTML($this->dlsubsubrow['download_category_name'], FALSE, 'TITLE')."</a>"; 225 } 226 else 227 { 228 return $tp->toHTML($this->dlsubsubrow['download_category_name'], FALSE, 'TITLE'); 229 } 230 } 231 232 function sc_download_cat_subsub_description() 233 { 234 return e107::getParser()->toHTML($this->dlsubsubrow['download_category_description'], TRUE, 'DESCRIPTION'); 235 } 236 237 function sc_download_cat_subsub_icon() 238 { 239 return $this->_sc_cat_icons($this->dlsubsubrow['download_category_icon'], $this->dlsubsubrow['d_count'], $this->dlsubsubrow['download_category_name']); 240 } 241 242 function sc_download_cat_subsub_new_icon() 243 { 244 return ($this->isNewDownload($this->dlsubsubrow['d_last'])) ? $this->renderNewIcon() : ""; 245 } 246 247 function sc_download_cat_subsub_count() 248 { 249 return $this->dlsubsubrow['d_count']; 250 } 251 252 function sc_download_cat_subsub_size() 253 { 254 return eHelper::parseMemorySize($this->dlsubsubrow['d_size']); 255 } 256 257 function sc_download_cat_subsub_downloaded() 258 { 259 return intval($this->dlsubsubrow['d_requests']); 260 } 261 262 263 // List **************************************************************************************** 264 265 266 function sc_download_list_caption($parm='') 267 { 268 269 $qry = $this->qry; 270 271 $qry['sort'] = ($qry['sort'] == 'asc') ? 'desc' : 'asc'; // reverse. 272 273 switch ($parm) 274 { 275 case 'name': 276 $qry['order'] = 'name'; 277 $text = LAN_NAME; 278 break; 279 280 case 'datestamp': 281 $qry['order'] = 'datestamp'; 282 $text = LAN_DATE; 283 break; 284 285 case 'author': 286 $qry['order'] = 'author'; 287 $text = LAN_AUTHOR; 288 break; 289 290 case 'filesize': 291 $qry['order'] = 'filesize'; 292 $text = LAN_SIZE; 293 break; 294 295 case 'requested': 296 $qry['order'] = 'requested'; 297 $text = LAN_dl_29; 298 break; 299 300 case 'rating': 301 $text = LAN_RATING; 302 break; 303 304 case 'link': 305 $text = LAN_dl_8; 306 break; 307 308 default: 309 $text = "Missing LAN Column"; // debug. 310 break; 311 } 312 313 314 return "<a href='".e_REQUEST_SELF."?".http_build_query($qry, null, '&')."'>".$text."</a>" ; 315 } 316 317 318 319 function sc_download_list_name($parm='') 320 { 321 $tp = e107::getParser(); 322 $pref = e107::getPref(); 323 324 if ($parm == "nolink") 325 { 326 return $tp->toHTML($this->var['download_name'],TRUE,'LINKTEXT'); 327 } 328 329 if ($parm == "request") 330 { 331 $agreetext = $tp->toJS($tp->toHTML($pref['agree_text'],FALSE,'DESCRIPTION')); 332 333 if ($this->var['download_mirror_type']) 334 { 335 $text = ($pref['agree_flag'] ? "<a href='".e_PLUGIN_ABS."download/download.php?mirror.".$this->var['download_id']."' onclick= \"return confirm('{$agreetext}');\">" : "<a href='".e_PLUGIN_ABS."download/download.php?mirror.".$this->var['download_id']."' title='".LAN_DOWNLOAD."'>"); 336 } 337 else 338 { 339 $text = ($pref['agree_flag'] ? "<a href='".e_PLUGIN_ABS."download/request.php?".$this->var['download_id']."' onclick= \"return confirm('{$agreetext}');\">" : "<a href='".e_PLUGIN_ABS."download/request.php?".$this->var['download_id']."' title='".LAN_DOWNLOAD."'>"); 340 } 341 342 $text .= $tp->toHTML($this->var['download_name'], FALSE, 'TITLE')."</a>"; 343 344 return $text; 345 } 346 347 $url = e107::url('download', 'item', $this->var); 348 return "<a href='".$url."'>".$tp->toHTML($this->var['download_name'],TRUE,'LINKTEXT')."</a>"; 349 350 // return "<a href='".e_PLUGIN_ABS."download/download.php?action=view&id=".$this->var['download_id']."'>".$tp->toHTML($this->var['download_name'],TRUE,'LINKTEXT')."</a>"; 351 } 352 353 function sc_download_list_author() 354 { 355 return $this->var['download_author']; 356 } 357 358 function sc_download_list_requested() 359 { 360 return $this->var['download_requested']; 361 } 362 363 function sc_download_list_newicon() 364 { 365 return $this->isNewDownload($this->var['download_datestamp']) ? $this->renderNewIcon() : ""; 366 } 367 368 function sc_download_list_recenticon() 369 { 370 $pref = e107::getPref(); 371 // convert "recent_download_days" to seconds 372 return ($this->var['download_datestamp'] > time()-($pref['recent_download_days']*86400) ? $this->renderNewIcon() : ''); 373 } 374 375 function sc_download_list_filesize() 376 { 377 return eHelper::parseMemorySize($this->var['download_filesize']); 378 } 379 380 function sc_download_list_datestamp() 381 { 382 383 $tp = e107::getParser(); 384 return $tp->toDate($this->var['download_datestamp'], "short"); 385 } 386 387 function sc_download_list_thumb($parm='') 388 { 389 $tp = e107::getParser(); 390 391 $img = ""; 392 393 if(!empty($this->var['download_thumb'])) 394 { 395 $opts = array( 396 'legacy' => "{e_FILE}downloadthumbs/", 397 'class' => 'download-image img-responsive img-fluid', 398 'alt' => $this->var['download_name'] 399 ); 400 401 $img = $tp->toImage($this->var['download_thumb'], $opts); 402 } 403 404 405 if ($parm == "link" && $this->var['download_thumb']) 406 { 407 $url = e107::url('download', 'item', $this->var); 408 return "<a href='".$url."'>".$img."</a>"; 409 // return "<a href='".e_PLUGIN_ABS."download/download.php?action=view&id=".$this->var['download_id']."'>".$img."</a>"; 410 } 411 else 412 { 413 return $img; 414 } 415 } 416 417 function sc_download_list_id() 418 { 419 return $this->var['download_id']; 420 } 421 422 function sc_download_list_rating() 423 { 424 return e107::getForm()->rate("download", $this->var['download_id']); 425 } 426 427 function sc_download_list_link($parm='') 428 { 429 $tp = e107::getParser(); 430 $pref = e107::getPref(); 431 432 $agreetext = $tp->toJS($tp->toHTML($pref['agree_text'],FALSE,'DESCRIPTION')); 433 434 $img = "<img src='".IMAGE_DOWNLOAD."' alt='".LAN_DOWNLOAD."' title='".LAN_DOWNLOAD."' />"; 435 436 if(deftrue('BOOTSTRAP')) 437 { 438 $img = e107::getParser()->toGlyph('fa-download',false); 439 // $img = '<i class="icon-download"></i>'; 440 } 441 442 if ($this->var['download_mirror_type']) 443 { 444 return "<a class='e-tip' title='".LAN_DOWNLOAD."' href='".e_PLUGIN_ABS."download/download.php?mirror.".$this->var['download_id']."'>{$img}</a>"; 445 } 446 else 447 { 448 $url = $tp->parseTemplate("{DOWNLOAD_REQUEST_URL}",true, $this); // $this->sc_download_request_url(); 449 return ($pref['agree_flag'] ? "<a class='e-tip' title='".LAN_DOWNLOAD."' href='".$url."' onclick= \"return confirm('{$agreetext}');\">{$img}</a>" : "<a class='e-tip' title='".LAN_DOWNLOAD."' href='".$url."' >{$img}</a>"); 450 451 // return ($pref['agree_flag'] ? "<a class='e-tip' title='".LAN_DOWNLOAD."' href='".e_PLUGIN_ABS."download/request.php?".$this->var['download_id']."' onclick= \"return confirm('{$agreetext}');\">{$img}</a>" : "<a class='e-tip' title='".LAN_DOWNLOAD."' href='".e_PLUGIN_ABS."download/request.php?".$this->var['download_id']."' >{$img}</a>"); 452 } 453 } 454 455 456 function sc_download_request_url($parm=null) 457 { 458 return e107::url('download', 'get', $this->var); // /request/item',array('id'=>$this->var['download_id'], 'name'=>$this->var['download_sef'])); 459 460 } 461 462 function sc_download_filename($parm=null) 463 { 464 return basename($this->var['download_url']); 465 466 } 467 468 function sc_download_list_icon($parm='') //XXX FIXME $img. 469 { 470 if ($parm == "link") 471 { 472 $url = e107::url('download', 'item', $this->var); 473 return "<a href='".$url."' >".$img."</a>"; 474 // return "<a href='".e_PLUGIN_ABS."download/download.php?action=view&id=".$this->var['download_id']."' >".$img."</a>"; 475 } 476 else 477 { 478 return $img; 479 } 480 return; 481 } 482 483 function sc_download_list_imagefull($parm='') 484 { 485 486 $img = ""; 487 488 if(!empty($this->var['download_image'])) 489 { 490 $img = $this->sc_download_view_imagefull(); 491 } 492 493 if($parm == "link" && $this->var['download_image']) 494 { 495 $url = e107::url('download', 'item', $this->var); 496 return "<a title=\"".LAN_dl_53."\" href='".$url."'>".$img."</a>"; 497 498 // return "<a title=\"".LAN_dl_53."\" href='".e_PLUGIN_ABS."download/download.php?action=view&id=".$this->var['download_id']."'>".$img."</a>"; 499 } 500 else 501 { 502 return $img; 503 } 504 } 505 506 507 function sc_download_list_nextprev() 508 { 509 global $nextprev_parms; 510 return e107::getParser()->parseTemplate("{NEXTPREV={$nextprev_parms}}"); 511 } 512 513 function sc_download_list_total_amount() 514 { 515 global $dltdownloads; 516 return intval($dltdownloads)." ".LAN_dl_16; 517 } 518 519 function sc_download_list_total_files() 520 { 521 global $dlft; 522 return intval($dlft)." ".strtolower(LAN_FILES); 523 } 524 525 526 527 528 // View **************************************************************************************** 529 530 531 function sc_download_view_id() 532 { 533 return $this->var['download_id']; 534 } 535 536 function sc_download_admin_edit() 537 { 538 $icon = (deftrue('BOOTSTRAP')) ? e107::getParser()->toGlyph('fa-edit') : "<img src='".e_IMAGE_ABS."generic/edit.png' alt='*' style='padding:0px;border:0px' />"; 539 540 $url = e_PLUGIN_ABS."download/admin_download.php?action=edit&id=".$this->var['download_id']; 541 542 return (ADMIN && getperms('6')) ? "<a class='e-tip btn btn-default btn-secondary hidden-print' href='".$url."' title='".LAN_EDIT."'>".$icon."</a>" : ""; 543 } 544 545 function sc_download_category() 546 { 547 return $this->var['download_category_name']; 548 } 549 550 function sc_download_category_description() 551 { 552 global $tp,$dl,$parm; 553 554 $text = $tp -> toHTML($dl['download_category_description'], TRUE,'DESCRIPTION'); 555 if ($parm){ 556 return substr($text,0,$parm); 557 }else{ 558 return $text; 559 } 560 } 561 function sc_download_view_name($parm='') 562 { 563 $tp = e107::getParser(); 564 565 $viewUrl = e107::url('download', 'item', $this->var); 566 $requestUrl = $url = $tp->parseTemplate("{DOWNLOAD_REQUEST_URL}",true,$this); // $this->sc_download_request_url(); 567 568 $link['view'] = "<a href='".$viewUrl."'>".$this->var['download_name']."</a>"; 569 $link['request'] = "<a href='".$requestUrl."' title='".LAN_dl_46."'>".$this->var['download_name']."</a>"; 570 571 // $link['view'] = "<a href='".e_PLUGIN_ABS."download/download.php?action=view&id=".$this->var['download_id']."'>".$this->var['download_name']."</a>"; 572 // $link['request'] = "<a href='".e_PLUGIN_ABS."download/request.php?".$this->var['download_id']."' title='".LAN_dl_46."'>".$this->var['download_name']."</a>"; 573 574 575 if ($parm) 576 { 577 return $tp->toHTML($link[$parm],true, 'TITLE'); 578 } 579 580 return $this->var['download_name']; 581 } 582 583 function sc_download_view_name_linked() 584 { 585 global $dl; 586 $tp = e107::getParser(); 587 $pref = e107::getPref(); 588 $url = $url = $tp->parseTemplate("{DOWNLOAD_REQUEST_URL}",true,$this); //$this->sc_download_request_url(); 589 590 if ($pref['agree_flag'] == 1) 591 { 592 return "<a href='".$url."' onclick= \"return confirm('".$tp->toJS($tp->toHTML($pref['agree_text'],FALSE,'DESCRIPTION'))."');\" title='".LAN_dl_46."'>".$dl['download_name']."</a>"; 593 // return "<a href='".e_PLUGIN_ABS."download/request.php?".$dl['download_id']."' onclick= \"return confirm('".$tp->toJS($tp->toHTML($pref['agree_text'],FALSE,'DESCRIPTION'))."');\" title='".LAN_dl_46."'>".$dl['download_name']."</a>"; 594 } 595 else 596 { 597 return "<a href='".$url."' title='".LAN_dl_46."'>".$dl['download_name']."</a>"; 598 599 // return "<a href='".e_PLUGIN_ABS."download/request.php?".$dl['download_id']."' title='".LAN_dl_46."'>".$dl['download_name']."</a>"; 600 } 601 } 602 603 function sc_download_view_author() 604 { 605 return ($this->var['download_author'] ? $this->var['download_author'] : ""); 606 } 607 608 function sc_download_view_authoremail() 609 { 610 return ($this->var['download_author_email']) ? e107::getParser()->toHTML($this->var['download_author_email'], TRUE, 'LINKTEXT') : ""; 611 } 612 613 function sc_download_view_authorwebsite() 614 { 615 return ($this->var['download_author_website']) ? e107::getParser()->toHTML($this->var['download_author_website'], TRUE,'LINKTEXT') : ""; 616 } 617 618 function sc_download_view_description($parm='') 619 { 620 $maxlen = ($parm ? intval($parm) : 0); 621 $text = ($this->var['download_description'] ? e107::getParser()->toHTML($this->var['download_description'], TRUE, 'DESCRIPTION') : ""); 622 623 if ($maxlen) 624 { 625 return substr($text, 0, $maxlen); 626 } 627 else 628 { 629 return $text; 630 } 631 632 return $text; 633 } 634 635 function sc_download_view_date($parm='') 636 { 637 return ($this->var['download_datestamp']) ? e107::getParser()->toDate($this->var['download_datestamp'], $parm) : ""; 638 } 639 640 /** 641 * @Deprecated DOWNLOAD_VIEW_DATE should be used instead. 642 */ 643 function sc_download_view_date_short() 644 { 645 return $this->sc_download_view_date('short'); 646 } 647 648 /** 649 * @Deprecated DOWNLOAD_VIEW_DATE should be used instead. 650 */ 651 function sc_download_view_date_long() 652 { 653 return $this->sc_download_view_date('long'); 654 } 655 656 function sc_download_view_image() 657 { 658 $tp = e107::getParser(); 659 660 $url = e107::url('download', 'image', $this->var); 661 //$url = e_PLUGIN_ABS . "download/request.php?download." . $this->var['download_id']; 662 663 if($this->var['download_thumb']) 664 { 665 $opts = array( 666 'legacy' => "{e_FILE}downloadthumbs/", 667 'class' => 'download-image dl_image img-responsive img-fluid' 668 ); 669 $image = $tp->toImage($this->var['download_thumb'], $opts); 670 671 672 return ($this->var['download_image'] ? "<a href='" . $url . "'>" . $image . "</a>" : $image); 673 } 674 elseif($this->var['download_image']) 675 { 676 $opts = array( 677 //'legacy' => "{e_FILE}downloadthumbs/", 678 'class' => 'download-image dl_image img-responsive img-fluid', 679 'w' => 200 680 ); 681 $image = $tp->toImage($this->var['download_image'], $opts); 682 683 684 return "<a href='" . $url . "'>" . $image . "</a>"; 685 //return "<a href='" . $url . "'>" . LAN_dl_40 . "</a>"; 686 } 687 else 688 { 689 return LAN_dl_75; 690 } 691 } 692 693 /** 694 * {DOWNLOAD_VIEW_LINK: class=thumbnail} 695 */ 696 function sc_download_view_imagefull($parm=array()) 697 { 698 699 if(!empty($this->var['download_image'])) 700 { 701 702 $opts = array( 703 'legacy' => "{e_FILE}downloadimages/", 704 'class' => 'download-image dl_image download-view-image img-responsive img-fluid '.vartrue($parm['class']), 705 'alt' => basename($this->var['download_image']) 706 ); 707 708 return e107::getParser()->toImage($this->var['download_image'], $opts); 709 } 710 711 } 712 713 /** 714 * {DOWNLOAD_VIEW_LINK: size=2x} 715 */ 716 function sc_download_view_link($parm) 717 { 718 $tp = e107::getParser(); 719 $pref = e107::getPref(); 720 721 $click = ""; 722 723 $img = "<img src='".IMAGE_DOWNLOAD."' alt='".LAN_DOWNLOAD."' title='".LAN_DOWNLOAD."' />"; 724 725 if(deftrue('BOOTSTRAP')) 726 { 727 $img = e107::getParser()->toGlyph('fa-download',$parm); // '<i class="icon-download"></i>'; 728 } 729 730 if ($pref['agree_flag'] == 1) 731 { 732 $click = " onclick='return confirm(\"".$tp->toJS($tp->toHTML($pref['agree_text'],true,'emotes, no_tags'))."\")'"; 733 } 734 735 $url = $url = $tp->parseTemplate("{DOWNLOAD_REQUEST_URL}",true,$this); //$this->sc_download_request_url(); 736 737 if(varset($parm['type']) == 'href') 738 { 739 return $url; 740 } 741 742 $dnld_link = "<a href='".$url."'{$click}>"; 743 744 if ($this->var['download_mirror']) 745 { 746 if ($this->var['download_mirror_type']) 747 { 748 return "<a href='".e_PLUGIN_ABS."download/download.php?mirror.".$this->var['download_id']."'>".LAN_dl_66."</a>"; 749 } 750 else 751 { 752 return $dnld_link.$img."</a>"; 753 } 754 } 755 else 756 { 757 return $dnld_link.$img."</a>"; 758 } 759 } 760 761 function sc_download_view_filesize() 762 { 763 return ($this->var['download_filesize']) ? eHelper::parseMemorySize($this->var['download_filesize'], 0) : ""; 764 } 765 766 function sc_download_view_rating() 767 { 768 769 $frm = e107::getForm(); 770 $options = array('label'=>' ','template'=>'RATE|VOTES|STATUS'); 771 return $frm->rate("download", $this->var['download_id'], $options); 772 773 /* 774 require_once(e_HANDLER."rate_class.php"); 775 $rater = new rater; 776 777 $text = " 778 <table style='width:100%'> 779 <tr> 780 <td style='width:50%'>"; 781 if ($ratearray = $rater->getrating("download", $this->var['download_id'])) { 782 for($c = 1; $c <= $ratearray[1]; $c++) { 783 $text .= "<img src='".e_IMAGE."rate/star.png' alt='*' />"; 784 } 785 if ($ratearray[2]) { 786 $text .= "<img src='".e_IMAGE."rate/".$ratearray[2].".png' alt='*' />"; 787 } 788 if ($ratearray[2] == "") { 789 $ratearray[2] = 0; 790 } 791 $text .= " ".$ratearray[1].".".$ratearray[2]." - ".$ratearray[0]." "; 792 $text .= ($ratearray[0] == 1 ? LAN_dl_43 : LAN_dl_44); 793 } else { 794 $text .= LAN_dl_13; 795 } 796 $text .= "</td><td style='width:50%; text-align:right'>"; 797 if (!$rater->checkrated("download", $this->var['download_id']) && USER) { 798 $text .= $rater->rateselect(" <b>".LAN_dl_14, "download", $this->var['download_id'])."</b>"; 799 } 800 else if (!USER) { 801 $text .= " "; 802 } else { 803 $text .= LAN_THANK_YOU; 804 } 805 $text .= "</td></tr></table>"; 806 return $text; 807 */ 808 } 809 810 function sc_download_report_link() 811 { 812 $pref = e107::getPref(); 813 if(check_class($pref['download_reportbroken'])) 814 { 815 //$url = e_PLUGIN_ABS."download/download.php?action=report&id=".$this->var['download_id']; 816 $url = e107::url('download','report', $this->var); 817 return "<a href='".$url."'>".LAN_dl_45."</a>"; 818 } 819 820 return ''; 821 } 822 823 function sc_download_view_caption() 824 { 825 $text = $this->var['download_category_name']; 826 $text .= ($this->var['download_category_description']) ? " [ ".$this->var['download_category_description']." ]" : ""; 827 return $text; 828 } 829 830 831 // Mirror ************************************************************************************** 832 833 function sc_download_mirror_request() 834 { 835 return $this->var['download_name']; 836 } 837 838 function sc_download_mirror_request_icon() 839 { 840 return ($this->var['download_thumb'] ? "<img src='".e107::getParser()->replaceConstants($this->var['download_thumb'])."' alt='*'/>" : ""); 841 } 842 843 function sc_download_mirror_name() 844 { 845 return "<a href='{$this->mirror['dlmirror']['mirror_url']}' rel='external'>".$this->mirror['dlmirror']['mirror_name']."</a>"; 846 } 847 848 function sc_download_mirror_image() 849 { 850 $tp = e107::getParser(); 851 return ($this->mirror['dlmirror']['mirror_image'] ? "<a href='{$this->mirror['dlmirror']['mirror_url']}' rel='external'><img src='".$tp->replaceConstants($this->mirror['dlmirror']['mirror_image'])."' alt='*'/></a>" : ""); 852 } 853 854 function sc_download_mirror_location() 855 { 856 return ($this->mirror['dlmirror']['mirror_location'] ? $this->mirror['dlmirror']['mirror_location'] : ""); 857 } 858 859 function sc_download_mirror_description() 860 { 861 return ($this->mirror['dlmirror']['mirror_description'] ? e107::getParser()->toHTML($this->mirror['dlmirror']['mirror_description'], TRUE) : ""); 862 } 863 864 function sc_download_mirror_filesize() 865 { 866 return eHelper::parseMemorySize($this->mirror['dlmirrorfile'][3]); 867 } 868 869 function sc_download_mirror_link() 870 { 871 $tp = e107::getParser(); 872 $pref = e107::getPref(); 873 874 $click = " onclick='return confirm(\"".$tp->toJS($tp->toHTML($pref['agree_text'],FALSE,'DESCRIPTION'))."\")'"; 875 876 $img = "<img src='".IMAGE_DOWNLOAD."' alt='".LAN_DOWNLOAD."' title='".LAN_DOWNLOAD."' />"; 877 878 if(deftrue('BOOTSTRAP')) 879 { 880 $img = '<i class="icon-download"></i>'; 881 } 882 883 return "<a href='".e_PLUGIN_ABS."download/download.php?mirror.{$this->var['download_id']}.{$this->mirror['dlmirrorfile'][0]}' title='".LAN_DOWNLOAD."'{$click}>".$img."</a>"; 884 } 885 886 function sc_download_mirror_requests() 887 { 888 return (ADMIN ? LAN_dl_73.$this->mirror['dlmirrorfile'][2] : ""); 889 } 890 891 function sc_download_total_mirror_requests() 892 { 893 return (ADMIN ? LAN_dl_74.$this->mirror['dlmirror']['mirror_count'] : ""); 894 } 895 896 897 // --------- Download View Lans ----------------------------- 898 899 function sc_download_view_author_lan() 900 { 901 902 return ($this->var['download_author']) ? LAN_AUTHOR : ""; 903 } 904 905 function sc_download_view_authoremail_lan() 906 { 907 908 return ($this->var['download_author_email']) ? LAN_dl_30 : ""; 909 } 910 911 function sc_download_view_authorwebsite_lan() 912 { 913 914 return ($this->var['download_author_website']) ? LAN_dl_31 : ""; 915 } 916 917 function sc_download_view_date_lan() 918 { 919 920 return ($this->var['download_datestamp']) ? LAN_DATE: ""; 921 } 922 923 function sc_download_view_image_lan() 924 { 925 return LAN_IMAGE; 926 } 927 928 function sc_download_view_requested() 929 { 930 931 return $this->var['download_requested']; 932 } 933 934 function sc_download_view_rating_lan() 935 { 936 return LAN_RATING; 937 } 938 939 function sc_download_view_filesize_lan() 940 { 941 return LAN_SIZE; 942 } 943 944 function sc_download_view_description_lan() 945 { 946 return LAN_DESCRIPTION; 947 } 948 949 function sc_download_view_requested_lan() 950 { 951 return LAN_dl_77; 952 } 953 954 function sc_download_view_link_lan() 955 { 956 return LAN_DOWNLOAD; 957 } 958 959 960 // ----------- Download View : Previous and Next --------------- 961 962 /** 963 * {DOWNLOAD_VIEW_PREV: x=y} 964 */ 965 function sc_download_view_prev($parm='') 966 { 967 $sql = e107::getDb(); 968 $tp = e107::getParser(); 969 970 $dlrow_id = intval($this->var['download_id']); 971 972 if ($sql->select("download", "*", "download_category='".intval($this->var['download_category_id'])."' AND download_id < {$dlrow_id} AND download_active > 0 && download_visible IN (".USERCLASS_LIST.") ORDER BY download_datestamp DESC LIMIT 1")) 973 { 974 $dlrowrow = $sql->fetch(); 975 976 $url = e107::url('download', 'item', $dlrowrow); 977 978 $icon = (deftrue('BOOTSTRAP')) ? $tp->toGlyph('fa-chevron-left') : '<<'; 979 $class = empty($parm['class']) ? 'e-tip' : $parm['class']; 980 981 return "<a class='".$class."' href='".$url ."' title=\"".$dlrowrow['download_name']."\">".$icon." ".LAN_PREVIOUS."</a>\n"; 982 983 // return "<a href='".e_PLUGIN_ABS."download/download.php?action=view&id=".$dlrowrow['download_id']."'><< ".LAN_dl_33." [".$dlrowrow['download_name']."]</a>\n"; 984 } 985 else 986 { 987 return " "; 988 } 989 } 990 991 /** 992 * {DOWNLOAD_VIEW_NEXT: x=y} 993 */ 994 function sc_download_view_next($parm='') 995 { 996 $sql = e107::getDb(); 997 $tp = e107::getParser(); 998 $dlrow_id = intval($this->var['download_id']); 999 1000 if ($sql->select("download", "*", "download_category='".intval($this->var['download_category_id'])."' AND download_id > {$dlrow_id} AND download_active > 0 && download_visible IN (".USERCLASS_LIST.") ORDER BY download_datestamp ASC LIMIT 1")) 1001 { 1002 $dlrowrow = $sql->fetch(); 1003 extract($dlrowrow); 1004 $url = $url = e107::url('download', 'item', $dlrowrow); 1005 1006 $icon = (deftrue('BOOTSTRAP')) ? $tp->toGlyph('fa-chevron-right') : '>>'; 1007 $class = empty($parm['class']) ? 'e-tip' : $parm['class']; 1008 1009 return "<a class='".$class."' href='".$url."' title=\"".$dlrowrow['download_name']."\">".LAN_NEXT." ".$icon."</a>\n"; 1010 1011 // return "<a href='".e_PLUGIN_ABS."download/download.php?action=view&id=".$dlrowrow['download_id']."'>[".$dlrowrow['download_name']."] ".LAN_dl_34." >></a>\n"; 1012 } 1013 else 1014 { 1015 return " "; 1016 } 1017 } 1018 1019 /** 1020 * {DOWNLOAD_BACK_TO_LIST: x=y} 1021 */ 1022 function sc_download_back_to_list($parm) 1023 { 1024 $url = e107::url('download', 'category', $this->var); 1025 // e_PLUGIN_ABS."download/download.php?action=list&id=".$this->var['download_category'] 1026 1027 $title = "Back to [x]"; 1028 $class = empty($parm['class']) ? 'e-tip' : $parm['class']; 1029 1030 return "<a class='".$class."' title=\"".e107::getParser()->lanVars($title,array('x'=>$this->var['download_category_name']))."\" href='".$url."'>".LAN_BACK."</a>"; 1031 } 1032 1033 function sc_download_back_to_category_list() 1034 { 1035 if(!empty($this->parent)) 1036 { 1037 $link = e107::url('download', 'category', $this->parent); 1038 } 1039 else 1040 { 1041 $link = ($this->var['download_category_id']) ? e107::url('download', 'category', $this->var) : null; 1042 } 1043 1044 return "<a class='btn btn-default btn-secondary btn-xs btn-mini' href='".$link."'>".LAN_dl_9."</a>"; 1045 } 1046 1047 1048 // Misc stuff --------------------------------------------------------------------------------- 1049 function sc_download_cat_newdownload_text() 1050 { 1051 return $this->renderNewIcon()." ".LAN_dl_36; 1052 } 1053 1054 function sc_download_cat_search() 1055 { 1056 $tp = e107::getParser(); 1057 $text = "<form class='form-search form-inline' method='get' action='".e_HTTP."search.php'>"; 1058 $text .= '<div><div class="input-group">'; 1059 $text .= "<input class='tbox form-control search-query' type='text' name='q' size='30' value='' placeholder=\"".LAN_SEARCH."\" maxlength='50' /> 1060 <input type='hidden' name='r' value='0' /> 1061 <input type='hidden' name='t' value='download' /> 1062 "; 1063 1064 $text .= ' 1065 <span class="input-group-btn"> 1066 <button class="btn btn-default btn-secondary" type="submit" name="s" value="1">'; 1067 1068 $text .= $tp->toIcon('fa-search.glyph'); 1069 1070 $text .= '</button> 1071 </span> 1072 </div><!-- /input-group --> 1073 </div></form>'; 1074 1075 return $text; 1076 1077 /* return "<form class='form-search form-inline' method='get' action='".e_HTTP."search.php'> 1078 <div class='input-group'> 1079 <input class='tbox form-control search-query' type='text' name='q' size='30' value='' placeholder=\"".LAN_SEARCH."\" maxlength='50' /> 1080 <button class='btn btn-primary button' type='submit' name='s' value='1' />".LAN_GO."</button> 1081 <input type='hidden' name='r' value='0' /> 1082 </div> 1083 </form>";*/ 1084 } 1085 1086 1087 1088 /** 1089 * @private 1090 */ 1091 function _sc_cat_icons($source, $count, $alt) 1092 { 1093 if (!$source) return " "; 1094 // list($ret[TRUE],$ret[FALSE]) = explode(chr(1), $source.chr(1)); //XXX ??? 1095 // if (!$ret[FALSE]) $ret[FALSE] = $ret[TRUE]; //XXX ??? 1096 $parms = array('legacy'=> "{e_IMAGE}icons/"); 1097 return e107::getParser()->toIcon($source, $parms); 1098 //return "<img src='".e_IMAGE."icons/{$ret[($count!=0)]}' alt='*'/>"; 1099 } 1100 1101 1102 private function isNewDownload($last_val) 1103 { 1104 if (USER && ($last_val > USERLV)) 1105 { 1106 return true; 1107 } 1108 else 1109 { 1110 return false; 1111 } 1112 } 1113 1114 private function renderNewIcon() 1115 { 1116 if(strstr(IMAGE_NEW,'<i ') || strstr(IMAGE_NEW,'<span')) 1117 { 1118 return IMAGE_NEW; 1119 } 1120 1121 return e107::getParser()->toIcon(IMAGE_NEW); 1122 1123 // return "<img src='".IMAGE_NEW."' alt='*' style='vertical-align:middle' />"; 1124 } 1125} 1126 1127