Пример #1
0
 /**
  * This method returns all plugins registered for the current extension point searching at the predefined path.
  * By default, new instances of the classes are returned. If the implementing
  * class requires specific constructor arguments, pass them as the second argument and they will be
  * used during instantiation.
  *
  * @param array $arrConstructorArguments
  *
  * @static
  * @return interface_generic_plugin[]
  */
 public function getPlugins($arrConstructorArguments = array())
 {
     //load classes in passed-folders
     $strKey = md5($this->strSearchPath . $this->strPluginPoint);
     if (!array_key_exists($strKey, self::$arrPluginClasses)) {
         $strPluginPoint = $this->strPluginPoint;
         $arrClasses = class_resourceloader::getInstance()->getFolderContent($this->strSearchPath, array(".php"), false, function ($strOneFile) use($strPluginPoint) {
             $strOneFile = uniSubstr($strOneFile, 0, -4);
             if (uniStripos($strOneFile, "class_") === false || uniStrpos($strOneFile, "class_testbase") !== false) {
                 return false;
             }
             $objReflection = new ReflectionClass($strOneFile);
             if (!$objReflection->isAbstract() && $objReflection->implementsInterface("interface_generic_plugin")) {
                 $objMethod = $objReflection->getMethod("getExtensionName");
                 if ($objMethod->invoke(null) == $strPluginPoint) {
                     return true;
                 }
             }
             return false;
         }, function (&$strOneFile) {
             $strOneFile = uniSubstr($strOneFile, 0, -4);
         });
         self::$arrPluginClasses[$strKey] = $arrClasses;
     }
     $arrReturn = array();
     foreach (self::$arrPluginClasses[$strKey] as $strOneClass) {
         $objReflection = new ReflectionClass($strOneClass);
         if (count($arrConstructorArguments) > 0) {
             $arrReturn[] = $objReflection->newInstanceArgs($arrConstructorArguments);
         } else {
             $arrReturn[] = $objReflection->newInstance();
         }
     }
     return $arrReturn;
 }
Пример #2
0
 public function testCustomLogLevel()
 {
     class_carrier::getInstance()->getObjConfig()->setDebug('debuglogging_overwrite', array('test_logger_custom.log' => 1));
     $objLogger = class_logger::getInstance('test_logger_custom.log');
     $this->assertInstanceOf('class_logger', $objLogger);
     $this->assertEquals(1, $objLogger->getIntLogLevel());
     $objLogger->addLogRow("test log row 3", class_logger::$levelInfo);
     $objLogger->addLogRow("test log row 2", class_logger::$levelWarning);
     $objLogger->addLogRow("test log row 1", class_logger::$levelError);
     $this->assertFileExists(_realpath_ . _projectpath_ . "/log/test_logger_custom.log");
     $this->assertTrue(uniStripos($objLogger->getLogFileContent(), 'test log row 3') === false);
     $this->assertTrue(uniStripos($objLogger->getLogFileContent(), 'test log row 2') === false);
     $this->assertTrue(uniStripos($objLogger->getLogFileContent(), 'test log row 1') !== false);
 }
    /**
     * Processes the content.
     * Make sure to return the string again, otherwise the output will remain blank.
     *
     * @param string $strContent
     *
     * @return string
     */
    public function processContent($strContent)
    {
        $strHighlight = trim(class_carrier::getInstance()->getParam("highlight"));
        if ($strHighlight != "") {
            $strHighlight = strip_tags($strHighlight);
            $strJS = <<<JS
KAJONA.portal.loader.loadFile('/templates/default/js/jquery.highlight.js', function() { \$("body div[class='contentRight']").highlight("{$strHighlight}"); });
JS;
            $strJS = "<script type=\"text/javascript\">" . $strJS . "</script>\n";
            $intBodyClose = uniStripos($strContent, "</body>");
            if ($intBodyClose !== false) {
                $strContent = uniSubstr($strContent, 0, $intBodyClose) . $strJS . uniSubstr($strContent, $intBodyClose);
            }
        }
        return $strContent;
    }
Пример #4
0
 public function testModuleModels()
 {
     echo "preparing object saves...\n";
     class_carrier::getInstance()->getObjRights()->setBitTestMode(true);
     $arrFiles = class_resourceloader::getInstance()->getFolderContent("/system", array(".php"), false, function ($strOneFile) {
         if (uniStripos($strOneFile, "class_module_") !== false) {
             $objClass = new ReflectionClass(uniSubstr($strOneFile, 0, -4));
             if (!$objClass->isAbstract() && $objClass->isSubclassOf("class_model")) {
                 $objAnnotations = new class_reflection(uniSubstr($strOneFile, 0, -4));
                 //block from autotesting?
                 if ($objAnnotations->hasClassAnnotation("@blockFromAutosave")) {
                     echo "skipping class " . uniSubstr($strOneFile, 0, -4) . " due to @blockFromAutosave annotation" . "\n";
                     return false;
                 }
                 return true;
             }
         }
         return false;
     }, function (&$strOneFile) {
         $strOneFile = uniSubstr($strOneFile, 0, -4);
         $strOneFile = new $strOneFile();
     });
     $arrSystemids = array();
     /** @var $objOneInstance class_model */
     foreach ($arrFiles as $objOneInstance) {
         echo "testing object of type " . get_class($objOneInstance) . "@" . $objOneInstance->getSystemid() . "\n";
         $this->assertTrue($objOneInstance->updateObjectToDb(), "saving object " . get_class($objOneInstance));
         $arrSystemids[$objOneInstance->getSystemid()] = get_class($objOneInstance);
         echo " ...saved object of type " . get_class($objOneInstance) . "@" . $objOneInstance->getSystemid() . "\n";
     }
     $objObjectfactory = class_objectfactory::getInstance();
     foreach ($arrSystemids as $strSystemid => $strClass) {
         echo "instantiating " . $strSystemid . "@" . $strClass . "\n";
         $objInstance = $objObjectfactory->getObject($strSystemid);
         $this->assertTrue($objInstance != null);
         $this->assertEquals(get_class($objInstance), $strClass);
         echo "deleting " . $strSystemid . "@" . $strClass . "\n";
         $objInstance->deleteObjectFromDatabase();
     }
     class_carrier::getInstance()->getObjRights()->setBitTestMode(false);
 }
Пример #5
0
 public function testReports()
 {
     if (!defined("_skinwebpath_")) {
         define("_skinwebpath_", "1");
     }
     echo "processing reports...\n";
     $arrReportsInFs = class_resourceloader::getInstance()->getFolderContent("/admin/statsreports", array(".php"), false, function ($strOneFile) {
         if (uniStripos($strOneFile, "class_stats_report") === false) {
             return false;
         }
         return true;
     }, function (&$strOneFile) {
         $strOneFile = uniSubstr($strOneFile, 0, -4);
         $strOneFile = new $strOneFile(class_carrier::getInstance()->getObjDB(), class_carrier::getInstance()->getObjToolkit("admin"), class_carrier::getInstance()->getObjLang());
     });
     $arrReports = array();
     foreach ($arrReportsInFs as $objReport) {
         if ($objReport instanceof interface_admin_statsreports) {
             $arrReports[$objReport->getTitle()] = $objReport;
         }
         $objStartDate = new class_date();
         $objStartDate->setPreviousDay();
         $objEndDate = new class_date();
         $objEndDate->setNextDay();
         $intStartDate = mktime(0, 0, 0, $objStartDate->getIntMonth(), $objStartDate->getIntDay(), $objStartDate->getIntYear());
         $intEndDate = mktime(0, 0, 0, $objEndDate->getIntMonth(), $objEndDate->getIntDay(), $objEndDate->getIntYear());
         $objReport->setEndDate($intEndDate);
         $objReport->setStartDate($intStartDate);
         $objReport->setInterval(2);
     }
     /** @var interface_admin_statsreports $objReport */
     foreach ($arrReports as $objReport) {
         ob_start();
         echo "processing report " . $objReport->getTitle() . "\n";
         $objReport->getReport();
         $objReport->getReportGraph();
     }
 }
Пример #6
0
 /**
  * Does as cache-lookup for prepared statements.
  * Reduces the number of recompiles at the db-side.
  *
  * @param string $strQuery
  *
  * @return resource
  * @since 3.4
  */
 private function getParsedStatement($strQuery)
 {
     if (uniStripos($strQuery, "select") !== false) {
         $strQuery = uniStrReplace(array(" as ", " AS "), array(" ", " "), $strQuery);
     }
     $objStatement = oci_parse($this->linkDB, $strQuery);
     return $objStatement;
 }
 /**
  * Creates a sitemap recursive level by level
  *
  * @param int $intLevel
  * @param array $objStartEntry
  * @param string $strStack
  *
  * @internal param string $strSystemid
  * @return string
  */
 private function sitemapRecursive($intLevel, $objStartEntry, $strStack)
 {
     $strReturn = "";
     $arrChilds = $objStartEntry["subnodes"];
     $intNrOfChilds = count($arrChilds);
     //Anything to do right here?
     if ($intNrOfChilds == 0) {
         return "";
     }
     //Iterate over every child
     for ($intI = 0; $intI < $intNrOfChilds; $intI++) {
         $arrOneChild = $arrChilds[$intI];
         //Check the rights
         if ($arrOneChild["node"]->rightView()) {
             //check if it's a foreign node and whether foreign nodes should be included
             if ($arrOneChild["node"]->getBitIsForeignNode() && $this->arrElementData["navigation_foreign"] === 0) {
                 continue;
             }
             //current point active?
             $bitActive = false;
             if (uniStripos($strStack, $arrOneChild["node"]->getSystemid()) !== false) {
                 $bitActive = true;
             }
             //Create the navigation point
             if ($intI == 0) {
                 $strCurrentPoint = $this->createNavigationPoint($arrOneChild["node"], $bitActive, $intLevel, true);
             } elseif ($intI == $intNrOfChilds - 1) {
                 $strCurrentPoint = $this->createNavigationPoint($arrOneChild["node"], $bitActive, $intLevel, false, true);
             } else {
                 $strCurrentPoint = $this->createNavigationPoint($arrOneChild["node"], $bitActive, $intLevel);
             }
             //And load all points below
             $strChilds = "";
             if (uniStrpos($strCurrentPoint, "level" . ($intLevel + 1)) !== false) {
                 $strChilds = $this->sitemapRecursive($intLevel + 1, $arrOneChild, $strStack);
             }
             //Put the childs below into the current template
             $this->objTemplate->setTemplate($strCurrentPoint);
             $arrTemp = array("level" . ($intLevel + 1) => $strChilds);
             $strTemplate = $this->objTemplate->fillCurrentTemplate($arrTemp);
             $strReturn .= $strTemplate;
         }
     }
     //wrap into the wrapper-section
     $strLevelTemplateID = $this->objTemplate->readTemplate("/module_navigation/" . $this->arrElementData["navigation_template"], "level_" . $intLevel . "_wrapper");
     $strWrappedLevel = $this->fillTemplate(array("level" . $intLevel => $strReturn), $strLevelTemplateID);
     if (uniStrlen($strWrappedLevel) > 0) {
         $strReturn = $strWrappedLevel;
     }
     return $strReturn;
 }
Пример #8
0
echo "</select>";
echo "<input type=\"hidden\" name=\"debugfile\" value=\"autotest.php\" />";
echo "<input type=\"hidden\" name=\"dotest\" value=\"1\" />";
echo "<input type=\"submit\" value=\"Run test\" />";
echo "</form>";
if (issetPost("dotest")) {
    $intStart = time();
    $strFilename = getPost("testname");
    $arrFiles = class_resourceloader::getInstance()->getFolderContent("/tests", array(".php"));
    $strSearched = array_search($strFilename, $arrFiles);
    if ($strSearched !== false && substr($strFilename, 0, 5) == "test_" && substr($strFilename, -4) == ".php") {
        echo " \n\nfound test-script " . $strFilename . " \n";
        include_once _realpath_ . $strSearched;
        $arrClasses = get_php_classes(file_get_contents(_realpath_ . $strSearched));
        foreach ($arrClasses as $strClassName) {
            if (uniStripos($strClassName, "test") !== false) {
                $objTest = new $strClassName();
                if ($objTest instanceof class_testbase) {
                    echo " invoking kajonaTestTrigger() on instance of " . $strClassName . "\n\n\n\n";
                    $objTest->kajonaTestTrigger();
                }
            }
        }
        class_assertions::printStatistics();
        echo "time needed: " . round((time() - $intStart) / 60, 3) . " min\n\n\n";
    }
}
function get_php_classes($php_code)
{
    $classes = array();
    $tokens = token_get_all($php_code);
Пример #9
0
 /**
  * Returns all tables used by the project
  *
  * @param bool $bitAll just the name or with additional information
  *
  * @return array
  */
 public function getTables($bitAll = false)
 {
     if (!$this->bitConnected) {
         $this->dbconnect();
     }
     $arrReturn = array();
     if ($this->objDbDriver != null) {
         if ($bitAll && isset($this->arrTablesCache["all"])) {
             return $this->arrTablesCache["all"];
         } elseif (isset($this->arrTablesCache["filtered"])) {
             return $this->arrTablesCache["filtered"];
         }
         //increase global counter
         $this->intNumber++;
         $arrTemp = $this->objDbDriver->getTables();
         //Filtering tables not used by this project, if dbprefix was given
         if (_dbprefix_ != "") {
             foreach ($arrTemp as $arrTable) {
                 $intPos = uniStripos($arrTable["name"], _dbprefix_);
                 if ($intPos !== false && $intPos == 0) {
                     if ($bitAll) {
                         $arrReturn[] = $arrTable;
                     } else {
                         $arrReturn[] = $arrTable["name"];
                     }
                 }
             }
         } else {
             foreach ($arrTemp as $arrTable) {
                 if ($bitAll) {
                     $arrReturn[] = $arrTable;
                 } else {
                     $arrReturn[] = $arrTable["name"];
                 }
             }
         }
         if ($bitAll) {
             $this->arrTablesCache["all"] = $arrReturn;
         } else {
             $this->arrTablesCache["filtered"] = $arrReturn;
         }
     }
     return $arrReturn;
 }
 /**
  * Adds the portal-editor code to the current page-output - if all requirements are given
  *
  * @param class_module_pages_page $objPageData
  * @param bool $bitEditPermissionOnMasterPage
  * @param string $strPageContent
  *
  * @return string
  */
 private function renderPortalEditorCode(class_module_pages_page $objPageData, $bitEditPermissionOnMasterPage, $strPageContent)
 {
     //add the portaleditor toolbar
     if (class_module_system_setting::getConfigValue("_pages_portaleditor_") == "false") {
         return $strPageContent;
     }
     if (!$this->objSession->isAdmin()) {
         return $strPageContent;
     }
     if (!$objPageData->rightEdit() && !$bitEditPermissionOnMasterPage) {
         return $strPageContent;
     }
     class_adminskin_helper::defineSkinWebpath();
     //save back the current portal text language and set the admin-one
     $strPortalLanguage = class_carrier::getInstance()->getObjLang()->getStrTextLanguage();
     class_carrier::getInstance()->getObjLang()->setStrTextLanguage($this->objSession->getAdminLanguage());
     if ($this->objSession->getSession("pe_disable") != "true") {
         $strPeToolbar = "";
         $arrPeContents = array();
         $arrPeContents["pe_status_page_val"] = $objPageData->getStrName();
         $arrPeContents["pe_status_status_val"] = $objPageData->getIntRecordStatus() == 1 ? "active" : "inactive";
         $arrPeContents["pe_status_autor_val"] = $objPageData->getLastEditUser();
         $arrPeContents["pe_status_time_val"] = timeToString($objPageData->getIntLmTime(), false);
         $arrPeContents["pe_dialog_close_warning"] = $this->getLang("pe_dialog_close_warning", "pages");
         //Add an iconbar
         $arrPeContents["pe_iconbar"] = "";
         $arrPeContents["pe_iconbar"] .= class_link::getLinkAdmin("pages_content", "list", "&systemid=" . $objPageData->getSystemid() . "&language=" . $strPortalLanguage, $this->getLang("pe_icon_edit"), $this->getLang("pe_icon_edit", "pages"), "icon_page");
         $arrPeContents["pe_iconbar"] .= "&nbsp;";
         $strEditUrl = class_link::getLinkAdminHref("pages", "editPage", "&systemid=" . $objPageData->getSystemid() . "&language=" . $strPortalLanguage . "&pe=1");
         $arrPeContents["pe_iconbar"] .= "<a href=\"#\" onclick=\"KAJONA.admin.portaleditor.openDialog('" . $strEditUrl . "'); return false;\">" . class_adminskin_helper::getAdminImage("icon_edit", $this->getLang("pe_icon_page", "pages")) . "</a>";
         $arrPeContents["pe_iconbar"] .= "&nbsp;";
         $strEditUrl = class_link::getLinkAdminHref("pages", "newPage", "&systemid=" . $objPageData->getSystemid() . "&language=" . $strPortalLanguage . "&pe=1");
         $arrPeContents["pe_iconbar"] .= "<a href=\"#\" onclick=\"KAJONA.admin.portaleditor.openDialog('" . $strEditUrl . "'); return false;\">" . class_adminskin_helper::getAdminImage("icon_new", $this->getLang("pe_icon_new", "pages")) . "</a>";
         $arrPeContents["pe_disable"] = "<a href=\"#\" onclick=\"KAJONA.admin.portaleditor.switchEnabled(false); return false;\" title=\"\">" . class_adminskin_helper::getAdminImage("icon_enabled", $this->getLang("pe_disable", "pages")) . "</a>";
         //Load portaleditor javascript (even if it's maybe already loaded in portal and init the ckeditor)
         $strTemplateInitID = $this->objTemplate->readTemplate("/elements.tpl", "wysiwyg_ckeditor_inits");
         $strSkinInit = $this->objTemplate->fillTemplate(array(), $strTemplateInitID);
         $strConfigFile = "'config_kajona_standard.js'";
         if (is_file(_realpath_ . "/project/admin/scripts/ckeditor/config_kajona_standard.js")) {
             $strConfigFile = "KAJONA_WEBPATH+'/project/admin/scripts/ckeditor/config_kajona_standard.js'";
         }
         $strPeToolbar .= "<script type='text/javascript'>\n                KAJONA.admin.lang.pe_rte_unsavedChanges = '" . $this->getLang("pe_rte_unsavedChanges", "pages") . "';\n\n                if(\$) {\n                    KAJONA.portal.loader.loadFile([\n                        '/core/module_pages/admin/scripts/kajona_portaleditor.js',\n                        '/core/module_system/admin/scripts/jqueryui/jquery-ui.custom.min.js',\n                        '/core/module_system/admin/scripts/jqueryui/css/smoothness/jquery-ui.custom.css'\n                    ], function() {\n                        KAJONA.admin.portaleditor.RTE.config = {\n                            language : '" . (class_session::getInstance()->getAdminLanguage() != "" ? class_session::getInstance()->getAdminLanguage() : "en") . "',\n                            filebrowserBrowseUrl : '" . uniStrReplace("&amp;", "&", class_link::getLinkAdminHref("folderview", "browserChooser", "&form_element=ckeditor")) . "',\n                            filebrowserImageBrowseUrl : '" . uniStrReplace("&amp;", "&", class_link::getLinkAdminHref("mediamanager", "folderContentFolderviewMode", "systemid=" . class_module_system_setting::getConfigValue("_mediamanager_default_imagesrepoid_") . "&form_element=ckeditor&bit_link=1")) . "',\n                            customConfig : {$strConfigFile},\n                            " . $strSkinInit . "\n                        }\n                        \$(KAJONA.admin.portaleditor.initPortaleditor);\n                    });\n                }\n                else {\n                    KAJONA.portal.loader.loadFile([\n                        '/core/module_system/admin/scripts/jquery/jquery.min.js',\n                        '/core/module_system/admin/scripts/jqueryui/jquery-ui.custom.min.js',\n                        '/core/module_pages/admin/scripts/kajona_portaleditor.js',\n                        '/core/module_system/admin/scripts/jqueryui/css/smoothness/jquery-ui.custom.css'\n                    ], function() {\n                        KAJONA.admin.portaleditor.RTE.config = {\n                            language : '" . (class_session::getInstance()->getAdminLanguage() != "" ? class_session::getInstance()->getAdminLanguage() : "en") . "',\n                            filebrowserBrowseUrl : '" . uniStrReplace("&amp;", "&", class_link::getLinkAdminHref("folderview", "browserChooser", "&form_element=ckeditor")) . "',\n                            filebrowserImageBrowseUrl : '" . uniStrReplace("&amp;", "&", class_link::getLinkAdminHref("mediamanager", "folderContentFolderviewMode", "systemid=" . class_module_system_setting::getConfigValue("_mediamanager_default_imagesrepoid_") . "&form_element=ckeditor&bit_link=1")) . "',\n                            " . $strSkinInit . "\n                        }\n                        \$(KAJONA.admin.portaleditor.initPortaleditor);\n                    });\n                }\n            </script>";
         //Load portaleditor styles
         $strPeToolbar .= $this->objToolkit->getPeBasicData();
         $strPeToolbar .= $this->objToolkit->getPeToolbar($arrPeContents);
         $objScriptlets = new class_scriptlet_helper();
         $strPeToolbar = $objScriptlets->processString($strPeToolbar, interface_scriptlet::BIT_CONTEXT_ADMIN);
         //The toolbar has to be added right after the body-tag - to generate correct html-code
         $strTemp = uniSubstr($strPageContent, uniStrpos($strPageContent, "<body"));
         //find closing bracket
         $intTemp = uniStrpos($strTemp, ">") + 1;
         //and insert the code
         $strPageContent = uniSubstr($strPageContent, 0, uniStrpos($strPageContent, "<body") + $intTemp) . $strPeToolbar . uniSubstr($strPageContent, uniStrpos($strPageContent, "<body") + $intTemp);
     } else {
         //Button to enable the toolbar & pe
         $strEnableButton = "<div id=\"peEnableButton\" style=\"z-index: 1000; position: fixed; top: 0px; right: 0px;\"><a href=\"#\" onclick=\"KAJONA.admin.portaleditor.switchEnabled(true); return false;\" title=\"\">" . getImageAdmin("icon_disabled", $this->getLang("pe_enable", "pages")) . "</a></div>";
         //Load portaleditor javascript
         $strEnableButton .= "\n<script type=\"text/javascript\" src=\"" . _webpath_ . "/core/module_pages/admin/scripts/kajona_portaleditor.js?" . class_module_system_setting::getConfigValue("_system_browser_cachebuster_") . "\"></script>";
         $strEnableButton .= $this->objToolkit->getPeBasicData();
         //Load portaleditor styles
         //The toobar has to be added right after the body-tag - to generate correct html-code
         $strTemp = uniSubstr($strPageContent, uniStripos($strPageContent, "<body"));
         //find closing bracket
         $intTemp = uniStripos($strTemp, ">") + 1;
         //and insert the code
         $strPageContent = uniSubstr($strPageContent, 0, uniStrpos($strPageContent, "<body") + $intTemp) . $strEnableButton . uniSubstr($strPageContent, uniStrpos($strPageContent, "<body") + $intTemp);
     }
     //reset the portal texts language
     class_carrier::getInstance()->getObjLang()->setStrTextLanguage($strPortalLanguage);
     return $strPageContent;
 }
Пример #11
0
 private function convertOldPath($strOldPath)
 {
     if (uniStripos($strOldPath, "/portal/downloads") !== false) {
         return uniStrReplace("/portal/downloads", "/files/downloads", $strOldPath);
     }
     if (uniStripos($strOldPath, "/portal/pics") !== false) {
         return uniStrReplace("/portal/pics", "/files/images", $strOldPath);
     }
     return $strOldPath;
 }