Jump to content

iwato

Members
  • Content count

    1,188
  • Joined

  • Last visited

Community Reputation

11 Good

1 Follower

About iwato

  • Rank
    Dedicated Member

Contact Methods

  • AIM
    moogoonghwa
  • Website URL
    http://www.grammarcaptive.com
  • Yahoo
    iddor
  • Skype
    kiusau

Profile Information

  • Gender
    Male
  • Location
    Seattle, Washington USA 98104

Previous Fields

  • Languages
    HTML, CSS, Javascript, PHP, MySQL and Spoken Language

Recent Profile Visitors

15,072 profile views
  1. iwato

    Matomo - PHP Direct (for Dummies)

    So, in addition to including the file in which the class is defined and calling a public static function within the file with its name and namespace as I have done what is a likely reason for not finding the class? Please allow me to try a different line of questioning. Consider the following list of uses and the corresponding namespace taken from the ExceptionHandler.php file. Must each file containing the respective listed class be included by PHP in order for the class to become available, or will PHP find the listed classes on its own? namespace Piwik; use Exception; use Piwik\API\Request; use Piwik\API\ResponseBuilder; use Piwik\Container\ContainerDoesNotExistException; use Piwik\Plugins\CoreAdminHome\CustomLogo; And, to take the matter one-step further must I include the additional uses included in each of the above, respective, class files in order to achieve my goal? I ask this for there is hardly a file that does not contain its own unique set of uses. Roddy
  2. iwato

    Matomo - PHP Direct (for Dummies)

    NATURE: This is part of a steadfast effort to hack through the thicket of PHP classes and namespaces of which the Matomo application consists. It is not an endeavor for the weak or timid, as the thicket is formidable and the documentation obscure. BACKGROUND: In order to submit a proper report request to the Matomo application the values of certain variables must be known. Although there are generators within the application that have been created to achieve this task, they are not easily accessible, as the thicket is, well, thick. Please find below both the file and code that produces the error message provided. The FILE: <?php /** * Piwik - free/libre analytics platform * * @link http://piwik.org * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later * * @package Piwik */ use Piwik\ErrorHandler; use Piwik\ExceptionHandler; use Piwik\FrontController; if (!defined('PIWIK_ENABLE_ERROR_HANDLER') || PIWIK_ENABLE_ERROR_HANDLER) { ErrorHandler::registerErrorHandler(); ExceptionHandler::setUp(); } FrontController::setUpSafeMode(); if (!defined('PIWIK_ENABLE_DISPATCH')) { define('PIWIK_ENABLE_DISPATCH', true); } if (PIWIK_ENABLE_DISPATCH) { $environment = new \Piwik\Application\Environment(null); $environment->init(); $controller = FrontController::getInstance(); try { $controller->init(); $response = $controller->dispatch(); if (!is_null($response)) { echo $response; } } catch (Exception $ex) { ExceptionHandler::dieWithHtmlErrorPage($ex); } } The CODE: require_once ('../../../../nudge.online/_utilities/php/matomo/core/dispatch.php'); The ERROR MESSAGE: LINE 16 ErrorHandler::registerErrorHandler(); Now, including the file ErrorHandler.php does not help. Neither does a call to the static function registerErrorHandler() appear to make a difference. Piwik\ErrorHandler::registerErrorHandler(); For the response is always the same Any ideas? Roddy
  3. No, I am saying that adding the script <script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script> via the str_replace() removes the namespace problem, but it generates a new problem that I do not understand. For the moment, I have decided to return to the old problem of getting Matomo to work without HTTP requests. There must be a way to simply enter the information contained in the query statement without having to generate an HTTP request. In exploration of this route I have stumbled on something that I have never seen before: a class without a constructor function. The whole of it is given below. It is brief. <?php /** * Piwik - free/libre analytics platform * * @link http://piwik.org * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later */ namespace Piwik\Http; use Piwik\Url; /** * Router */ class Router { /** * Filters some malformed URL by suggesting to redirect them. * * E.g. /index.php/.html?... can be interpreted as HTML by old browsers * even though the Content-Type says JSON. * @link https://github.com/piwik/piwik/issues/6156 * * @param string $url The URL to filter. * * @return string|null If not null, then the application should redirect to that URL. */ public function filterUrl($url) { $path = parse_url($url, PHP_URL_PATH); if (strpos($path, 'index.php/') !== false) { return preg_replace('#index\.php/([^\?]*)#', 'index.php', $url, 1); } return null; } } How do you explain such a thing? Roddy
  4. Using str_replace( ) was a great idea, and I am a little embarrassed that I did not think of it myself. Although it achieves the task, it does not solve the problem, for as soon as the ready() function is successfully invoked an error is triggered ReferenceError: broadcast is not defined <anonymous> n.Callbacks/j() jquery.min.js:2 n.Callbacks/k.fireWith() jquery.min.js:2 K() widget_map.php:61:13 POST XHR https://www.nudge.online/_utilities/php/matomo/index.php [HTTP/1.1 200 OK 1201ms] and then the POST call is repeated over and over as if in an unending loop. The line of code that triggers the error is, of course, var segment = broadcast.getValueFromHash('segment'); Roddy
  5. Do you agree with the following statement from StackOverflow? Roddy
  6. But where, and how? If I knew how to do this, I would have done it long ago. Already, before I wrote the above entry, i had tried placing a <script> tag with a src attribute pointing to the jQuery library outside of the <?php ... ?> in the same file in which the cURL resides. It was simply ignored -- perhaps due to the absence of a document or head tag. I know to little about the general use of headers and browsers to know why it failed. Roddy (spelled correctly)
  7. If the absence of the jQuery library is, indeed, the source of the problem, then how would I add the <script> element that loads the library to the file imported by the cURL call? It appears that cURL has several options to achieve such a task. Roccy
  8. In answer to your question: I am including one of two script tags referenced by the FireFox Debugger panel whose $ namespace is not defined. In this example, the Debugger panel points specifically to the jQuery ready function. <body ng-app="app" class="widgetized"> <div piwik-popover-handler></div> <div class="widget"> <script type="text/javascript" charset="utf-8"> $(document).ready(function () { var segment = broadcast.getValueFromHash('segment'); if (!segment) { segment = broadcast.getValueFromUrl('segment'); } $('#visitsLive').liveWidget({ interval: 5000, onUpdate: function () { //updates the numbers of total visits in startbox var ajaxRequest = new ajaxHelper(); ajaxRequest.setFormat('html'); ajaxRequest.addParams({ module: 'Live', action: 'ajaxTotalVisitors', segment: segment }, 'GET'); ajaxRequest.setCallback(function (r) { $("#visitsTotal").html(r); }); ajaxRequest.send(false); }, maxRows: 10, fadeInSpeed: 600, dataUrlParams: { module: 'Live', action: 'getLastVisitsStart', segment: segment } }); }); </script> In the <head> tag the following several additional scripts appear. The three dots ... represent script content that I have eliminated for the sake of brevity and better clarity. <script type="text/javascript"> var piwik = {}; piwik.token_auth = "..."; piwik.piwik_url = "https://.../matomo/"; piwik.cacheBuster = "..."; piwik.numbers = { patternNumber: "#,##0.###", patternPercent: "#,##0%", patternCurrency: "ยค#,##0.00", symbolPlus: "+", symbolMinus: "-", symbolPercent: "%", symbolGroup: ",", symbolDecimal: "." }; piwik.userLogin = "..."; piwik.idSite = "1"; piwik.siteName = "Grammar\x20Captive"; piwik.siteMainUrl = "https\x3A\x2F\x2F...matomo"; piwik.period = "day"; piwik.currentDateString = "2018-06-09"; piwik.startDateString = "2018-06-09"; piwik.endDateString = "2018-06-09"; piwik.minDateYear = 2018; piwik.minDateMonth = parseInt("02", 10); piwik.minDateDay = parseInt("22", 10); piwik.maxDateYear = 2018; piwik.maxDateMonth = parseInt("06", 10); piwik.maxDateDay = parseInt("09", 10); piwik.language = "en"; piwik.hasSuperUserAccess = 1; piwik.config = {}; piwik.config = {"action_url_category_delimiter":"\/","action_title_category_delimiter":"\/","autocomplete_min_sites":5,"datatable_export_range_as_day":"rss","datatable_row_limits":["5","10","25","50","100","250","500","-1"],"are_ads_enabled":true}; piwik.hasServerDetectedHttps = true; piwik.languageName = 'English'; </script> <!--[if lt IE 9]> <script language="javascript" type="text/javascript" src="libs/jqplot/excanvas.min.js"></script> <![endif]--> <link rel="stylesheet" type="text/css" href="index.php?module=Proxy&amp;action=getCss&amp;cb=..." /> <script type="text/javascript"> var translations = {"CorePluginsAdmin_NoZipFileSelected":"Please select a ZIP file.", ... { piwik_translations[i] = translations[i];} </script> <script type="text/javascript"> var translations = {"CorePluginsAdmin_NoZipFileSelected":"Please select a ZIP file."," ... ", LogViewer_ExportThisSearch":"Export this search as %1$s containing the latest %2$s entries. The download may take a few minutes..."}; if (typeof(piwik_translations) == 'undefined') { var piwik_translations = new Object; }for(var i in translations) { piwik_translations[i] = translations[i];} </script><script type="text/javascript" src="index.php?module=Proxy&action=getCoreJs&cb=..."></script> <script type="text/javascript" src="index.php?module=Proxy&action=getNonCoreJs&cb=..."></script> For what it is worth I am also including the attributes of the <html> tag. <!DOCTYPE html> <html id="ng-app" ng-app="piwikApp"> Roddy
  9. QUESTION: As far as the loading of jQuery -- or Javascript of any sort, for that matter -- is there any difference between an HTTP Request using say, "https://..." or "http://...", and a relative link say, "../../widget.html"? Please allow me to explain. I have a file located on my local server. When this file is loaded the following things happen: 1) The jQuery library is loaded in the <head> element with a <script> tag. 2) An iframe is created with a src attribute that makes a request to the Matomo reporting API on a third party server The prefix used to make the HTTP request is https://. 3) An iframe is created with a src attribute whose value is a relative link that points to another file on my local server. This file bears a .php extension and makes an HTTP request via cURL to the same address as indicated in Item 2) above. The iframe filled in Item 2) is filled with a fully functional widget produced by Matomo. The iframe filled in Item 3) contains much of the same data and text that the widget in Item 2) contains, but much of the widgets formatting and all of its functionality are missing. When the PHP file that makes the request is examined via the Firefox Debugger tab, Firefox reports that the jQuery namespace -- namely, $ -- cannot be found. What I understand from this is: 1) the contents of the iframe must be complete before it is introduced into the page, else it will not render properly. 2) the cURL call to the Matomo API is improperly specified and is capturing the full nature of the widget -- namely, the missing jQuery. Does this make sense to you? If so, can you provide any suggesting in regard to what is missing in the cURL request. Roddy
  10. Alas! I believe that I have discovered the reason why the Matomo widgets are not rendering properly when I import them indirectly via a relative link. While using FireFox's Debugger Menu in the WebConsole I discovered that the imported widget does not recognize the $ sign. Upon closer examination it was determined that, yes, like me, Matomo makes use of jQuery. This raises at least two questions: Why does the jQuery present on the page when the Matomo widget is introduced via an HTTP request allow the widget to behave properly, but the jQuery on the page does not permit the widget to function properly when the widget is introduced via a relative link to a page whose contents are filled with a cURL call to the Matomo reporting API. Is it a matter of timing -- i.e. when the Javascript is called? If all that is missing is a link to the jQuery CDN (this is still an untested hypothesis) where must I enter it so that it is called "on time"? And, via what means? If my hypothesis is true, and the above two problems are solved, then what is the best way to read the widget into the iframe element, if it is not recommended to fill a src tag with a relative link. Is this a job for the jQuery $.get() request? Roddy
  11. Matomo does so much more, and it is the only free package that I know that offers so much. What is more, I did not discover the current hurdle until I was already far along into understanding how the package works. It is quite involved. Roddy
  12. iwato

    Failed Button Alert

    Please, I can make the second button work by simply declaring the secTranslate( ) function in the body of the document -- thus, placing it within the scope of the document -- this, I have known for a very long time. At least, now I have a good explanation for why this works. It is something that has always worked, but I have never clearly understood. The problem, then, has to do with the ready( ) function, and why it sometimes works and sometimes does not in similar, but obviously different contexts. Even now I believe to have the answer to this. According to StackOverflow functions declared within the ready() function are not within the global scope, and it is within the global scope that the onclick() function is looking. Surely you must agree with this interpretation. It has been a great lesson for me! Hooray! Hooray! Roddy
  13. iwato

    Failed Button Alert

    Great! This means that we are making progress. Now, if you are able, why would the first button-alert work, but not the second. For, this is, indeed, the issue, is it not? Roddy
  14. iwato

    Failed Button Alert

    And, I would not expect there to be. For, I have already stated that I can achieve the same on load in the ready() function without the alert-button. Roddy
  15. iwato

    Failed Button Alert

    The problem is where you are using it, the scope. You haven't shown that context, so this is a lot of assuming from me but it's all I can do with the limited information. But, I have shown the context. All that is left is HTML, and I have checked this as well. Nothing bad is reported.
×