PageRenderTime 61ms CodeModel.GetById 34ms RepoModel.GetById 1ms app.codeStats 0ms

/MyDevSite/templates/scripts/GetArticleMediaFiles.php5

https://github.com/BalaVaradha/NewEmbedAssets
PHP | 79 lines | 78 code | 0 blank | 1 comment | 26 complexity | 09171e430192acd6e460d9dad148f7ca MD5 | raw file
  1. define("OK", 1);
  2. date_default_timezone_set($SOSE->GetVar('timezone'));
  3. $SiteDebug = $SOSE->GetVar("@SiteDebug");
  4. $ForReading = 1;
  5. $adCmdText = 1;
  6. $adCmdStoredProc = 4;
  7. $adTypeBinary = 1;
  8. $adParamInput = 1;
  9. $adParamLong = 128;
  10. $adInteger = 3;
  11. $adSmallint = 2;
  12. $adTinyint = 16;
  13. $adVarchar = 200;
  14. $adDate = 7;
  15. $adBinary = 128;
  16. $adLongVarBinary = 205;
  17. $adLongVarChar = 201;
  18. $adDBTimeStamp = 135;
  19. try {
  20. $StorySite = $SOSE->GetVar("StorySite");
  21. $StoryDate = $SOSE->GetVar("StoryDate");
  22. $StoryCategory = $SOSE->GetVar("StoryCategory");
  23. $StoryID = $SOSE->GetVar("StoryID");
  24. if ($StoryID == "")
  25. $StoryID = -1;
  26. $IncludeMediaFileTypes = $SOSE->GetVar("IncludeMediaFileTypes");
  27. $ExcludeMediaFileTypes = $SOSE->GetVar("ExcludeMediaFileTypes");
  28. $AssetCount = $SOSE->GetVar("AssetCount");
  29. if ($AssetCount == "")
  30. $AssetCount = 0;
  31. $MediaCount = $SOSE->GetVar("MediaCount");
  32. if ($MediaCount == "")
  33. $MediaCount = 1;
  34. $SortOrder = $SOSE->GetVar("SortOrder");
  35. if ($SortOrder == "")
  36. $SortOrder = 0;
  37. $Test = $SOSE->GetVar("Test");
  38. if ($Test == "")
  39. $Test = 0;
  40. $ObjectName = $SOSE->GetVar("ObjectName");
  41. if ($ObjectName == "")
  42. $ObjectName = "ArticleMediaFileEmbed";
  43. $ObjectClassNumber = $SOSE->GetVar("ObjectClassNumber");
  44. $sql = "exec custom.dbo.GetArticleMediaFiles @StorySite = '".$StorySite."', @StoryDate = '".$StoryDate."', @StoryCategory = '".$StoryCategory."', @StoryID = ".$StoryID.", @IncludeMediaFileTypes = '".$IncludeMediaFileTypes."', @ExcludeMediaFileTypes = '".$ExcludeMediaFileTypes."', @AssetCount = ".$AssetCount.", @SortOrder = ".$SortOrder.", @Test = ".$Test.", @MediaCount = '".$MediaCount."';";
  45. //$SOSE->Echo('Query is '.$sql);
  46. $rows = 0;
  47. $res = $SOSE->ROServerConnection->execute($sql, $rows, 1);
  48. if (($res) && ($res->State == OK)) {
  49. $tplWrapper = $SOSE->LocateObject($ObjectName.$ObjectClassNumber);
  50. $tplDefault = $SOSE->LocateObject($ObjectName."Item".$ObjectClassNumber);
  51. $items = "";
  52. if (!$res->eof) {
  53. while (!$res->eof) {
  54. $SOSE->CLEARVARLIST();
  55. for ($x = 0; $x < $res->fields->Count; $x++) {
  56. if (($res->fields[$x]->value != "") && ($res->fields[$x]->type == $adDBTimeStamp)) {
  57. $SOSE->SetVar($res->fields[$x]->name, $SOSE->FormatDateTime("yyyymmddhhmmss", $res->fields[$x]->value));
  58. } elseif ($res->fields[$x]->value != "") {
  59. $SOSE->SetVar($res->fields[$x]->name, $res->fields[$x]->value);
  60. if ($res->fields[$x]->name == "Extension"){
  61. $tpl1 = $SOSE->LocateObject($ObjectName."Item".$res->fields[$x]->value.$ObjectClassNumber);
  62. }
  63. }
  64. }
  65. if (stripos($tpl1, "ERROR:") === false)
  66. $items .= $SOSE->PBOScript($tpl1);
  67. else
  68. $items .= $SOSE->PBOScript($tplDefault);
  69. $res->MoveNext();
  70. }
  71. }
  72. $SOSE->SetVar("Items", $items);
  73. $SOSE->Echo($SOSE->PBOScript($tplWrapper));
  74. }else{
  75. $SOSE->Echo('Error Found while connecting with server');
  76. }
  77. } catch (Exception $e){
  78. $SOSE->Echo('<!-- Caught exception: '.$e->getMessage()."\nSQL: ".$sql." -->");
  79. }