PageRenderTime 23ms CodeModel.GetById 14ms RepoModel.GetById 0ms app.codeStats 0ms

/protected/Pages/System/AddPortlet.php

http://pradoportal.googlecode.com/
PHP | 103 lines | 77 code | 16 blank | 10 comment | 11 complexity | 8e7d67b7720495dd558ebeb8de4bee33 MD5 | raw file
  1. <?php
  2. /**
  3. * Prado Portal.
  4. *
  5. * @author Steen Rabol <steen.rabol@gmail.com>
  6. * @link http://www.pradoportal.dk/
  7. * @copyright Copyright &copy; 2006,2007,2008 Steen Rabol
  8. * @license http://www.pradoportal.dk
  9. * @version $Id: AddPortlet.php 396 2010-12-25 13:25:12Z steen.rabol $
  10. *
  11. */
  12. Prado::using('Application.Common.Data.PortalPortletRecord');
  13. class AddPortlet extends PortalSystemPage
  14. {
  15. public function onInit($param)
  16. {
  17. parent::onInit($param);
  18. if(!$this->User)
  19. {
  20. $this->reportError(1,"You need to be logged in to use this page");
  21. }
  22. if($this->User->RoleId != $this->Application->Parameters['AdminRole'])
  23. {
  24. $this->reportError(1,"You need to be logged in to use this page");
  25. }
  26. }
  27. public function onLoad($param)
  28. {
  29. parent::onLoad($param);
  30. $this->Title = $this->Application->Parameters['SiteTitle'] . " - ". Prado::localize("Add element");
  31. if(!$this->IsPostBack)
  32. {
  33. $pid = $this->Request['pid'];
  34. if($pid !== null)
  35. {
  36. $this->pid->Value = $pid;
  37. }
  38. $cid = $this->Request['cid'];
  39. if($cid !== null)
  40. {
  41. $this->cid->Value = $cid;
  42. }
  43. $portlets = PortalPortletRecord::finder()->findAllByactive(1);
  44. if($portlets)
  45. {
  46. $p = array();
  47. foreach($portlets as $portlet)
  48. {
  49. if(!class_exists($portlet->name,false))
  50. {
  51. $class_filename = Prado::getPathOfNamespace('Application.Portlets.' . $portlet->name . '.Common.' . $portlet->name . 'Common') . '.php';
  52. if(file_exists($class_filename))
  53. {
  54. $incFile = 'Application.Portlets.' . $portlet->name . '.Common.' . $portlet->name . 'Common';
  55. Prado::using($incFile);
  56. $pCommonClassName = $portlet->name . 'Common';
  57. if(method_exists($pCommonClassName,'getPortletName'))
  58. {
  59. $pDisplayName = call_user_func($pCommonClassName . '::getPortletName');
  60. $p[] = array("name" => $portlet->name, "displayname" => $pDisplayName);
  61. }
  62. else
  63. {
  64. $p[] = array("name" => $portlet->name, "displayname" => $portlet->displayname);
  65. }
  66. }
  67. }
  68. }
  69. $this->PortletName->DataSource = $p;
  70. $this->PortletName->dataBind();
  71. }
  72. $this->CancelLink->NavigateUrl = $this->Service->constructUrl($this->pid->Value,array("PageMode" => $this->Page->EditMode));
  73. }
  74. }
  75. public function saveButtonClicked($sender,$param)
  76. {
  77. $pid = $this->pid->Value;
  78. $cid = $this->cid->Value;
  79. $portlet = $this->PortletName->getSelectedValue();
  80. $culture = $this->Application->Culture;
  81. $nextorder = $this->DataAccess->createCommand("select count(*) from tblpagecontent where pagename='$pid' && controlname='$cid'")->queryScalar();
  82. $nextorder++;
  83. $this->DataAccess->createCommand("insert into tblpagecontent(pagename,controlname,portlet,displayorder,culture) values('$pid','$cid','$portlet',$nextorder,'$culture')")->execute();
  84. $this->gotoPage($pid,array("PageMode" => $this->EditMode));
  85. }
  86. }
  87. ?>