/**
  * Executes a select based on input query parts array
  *
  * @param    array   $queryParts Query parts array
  * @param    boolean $debug
  * @return   pointer        MySQL select result pointer / DBAL object
  * @see exec_SELECTquery()
  */
 public static function exec_SELECT_queryArray($queryParts, $debug = false)
 {
     $res = $GLOBALS['TYPO3_DB']->exec_SELECT_queryArray($queryParts);
     if ($GLOBALS['TYPO3_DB']->sql_error() || $debug === true) {
         $debug = array();
         $debug['queryParts'] = $queryParts;
         $debug['sql'] = self::SELECT_queryArray($queryParts);
         $debug['error'] = $GLOBALS['TYPO3_DB']->sql_error();
         $debug['php'] = tx_t3devapi_miscellaneous::get_caller_method();
         tx_t3devapi_miscellaneous::debug($debug, $GLOBALS['TYPO3_DB']->sql_error());
     }
     return $res;
 }
        if ($weekday > 0) {
            for ($i = 1; $i <= $weekday; $i++) {
                $calendar .= '<td class="noDay">&nbsp;</td>';
            }
        }
        for ($day = 1, $days_in_month = gmdate('t', $first_of_month); $day <= $days_in_month; $day++, $weekday++) {
            if ($weekday == 7) {
                $weekday = 0;
                //start a new week
                $calendar .= "</tr>\n<tr>";
            }
            if (isset($days[$day]) and is_array($days[$day])) {
                @(list($link, $classes, $content) = $days[$day]);
                if (is_NULL($content)) {
                    $content = $day;
                }
                $calendar .= '<td' . ($classes ? ' class="' . htmlspecialchars($classes) . '">' : '>') . ($link ? '<a href="' . htmlspecialchars($link) . '">' . $content . '</a>' : $content) . '</td>';
            } else {
                $calendar .= "<td>{$day}</td>";
            }
        }
        if ($weekday != 7) {
            for ($i = 1; $i <= 7 - $weekday; $i++) {
                $calendar .= '<td class="noDay">&nbsp;</td>';
            }
        }
        return $calendar . "</tr>\n</table>\n";
    }
}
tx_t3devapi_miscellaneous::XCLASS('ext/t3devapi/class.tx_t3devapi_calendar.php');
Esempio n. 3
0
 /**
  * This function get all configurations from ts, flexform, getpost...
  *
  * @param boolean $debug
  * @return array
  */
 public function getArrayConfig($debug = false)
 {
     // TYPOSCRIPT = template with plugin.tx_xxxx_pi1.xxxx = xxxx
     $arrayConfig = $this->conf;
     // Init and get the flexform data of the plugin
     $this->pi_initPIflexForm();
     $flexConfig = array();
     $piFlexForm = array();
     $piFlexForm = $this->cObj->data['pi_flexform'];
     if (isset($piFlexForm['data'])) {
         foreach ($piFlexForm['data'] as $sheet => $data) {
             foreach ($data as $lang => $value) {
                 foreach ($value as $key => $val) {
                     $flexConfig[$key] = $this->pi_getFFvalue($piFlexForm, $key, $sheet);
                 }
             }
         }
     }
     // test contentId to know if this content is concerned by piVars
     $arrayConfig['contentId'] == $this->cObj->data['uid'] ? $arrayConfig['piVars'] = 1 : ($arrayConfig['piVars'] = 0);
     // add "ext_conf_template.txt"
     if ($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf'][$this->extKey]) {
         $extConf = unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf'][$this->extKey]);
         $arrayConfig = array_merge($arrayConfig, $extConf);
     }
     // add the pi config "plugin.tx_xxxx_pi1 = xxxx" which is not imported in the $conf
     if (is_array($GLOBALS['TSFE']->tmpl->setup['plugin.'][$this->prefixId . '.'])) {
         $arrayConfig = array_merge($arrayConfig, $GLOBALS['TSFE']->tmpl->setup['plugin.'][$this->prefixId . '.']);
     }
     // add $piVars
     $arrayConfig = array_merge($arrayConfig, $this->piVars);
     // merge TYPOSCRIPT with FLEXFORM
     $arrayConfig = array_merge($flexConfig, $arrayConfig);
     if ($debug == true) {
         tx_t3devapi_miscellaneous::debug($arrayConfig);
     }
     return $arrayConfig;
 }
Esempio n. 4
0
     *
     * @param mixed $template
     */
    public function __construct($template)
    {
        $this->template = $template;
    }
    /**
     * Loads a template file and generate the content
     *
     * @param array $context datas to send
     * @return string
     */
    public function fluidView($context = array())
    {
        $renderer = TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('Tx_Fluid_View_TemplateView');
        $controllerContext = TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('Tx_Extbase_MVC_Controller_ControllerContext');
        $controllerContext->setRequest(TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('Tx_Extbase_MVC_Web_Request'));
        $renderer->setControllerContext($controllerContext);
        $renderer->setPartialRootPath(TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath($this->extKey) . "res/partials/");
        $renderer->setTemplateRootPath(TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath($this->extKey) . "res/templates/");
        $renderer->setLayoutRootPath(TYPO3\CMS\Core\Utility\ExtensionManagementUtility::extPath($this->extKey) . "res/layouts");
        $renderer->setTemplatePathAndFilename($this->template);
        foreach ($context as $key => $value) {
            $renderer->assign($key, $value);
        }
        return $renderer->render();
    }
}
tx_t3devapi_miscellaneous::XCLASS('ext/t3devapi/class.tx_t3devapi_fluid.php');
 /**
  * Set the table to process
  *
  * @param string $table
  * @return void
  */
 public function setTable($table)
 {
     $this->table = $table;
     $this->tca = tx_t3devapi_miscellaneous::getTableTCA($table);
     $this->addTsTca();
 }
Esempio n. 6
0
            // Next
            if ($currentPage + 1 <= $totalPages) {
                $labelNext = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_common.xml:next');
                $next = '<a href="' . $listURL . '&pointer=' . $currentPage * $iLimit . '"><img width="16" height="16" title="' . $labelNext . '" alt="' . $labelNext . '" src="sysext/t3skin/icons/gfx/control_next.gif"></a>';
            } else {
                $next = '<img width="16" height="16" title="" alt="" src="sysext/t3skin/icons/gfx/control_next_disabled.gif">';
            }
            // Last
            if ($currentPage != $totalPages) {
                $labelLast = $GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_common.xml:last');
                $last = '<a href="' . $listURL . '&pointer=' . ($totalPages - 1) * $iLimit . '"><img width="16" height="16" title="' . $labelLast . '" alt="' . $labelLast . '" src="sysext/t3skin/icons/gfx/control_last.gif"></a>';
            } else {
                $last = '<img width="16" height="16" title="" alt="" src="sysext/t3skin/icons/gfx/control_last_disabled.gif">';
            }
            $pageNumberInput = '<span>' . $currentPage . '</span>';
            $pageIndicator = '<span class="pageIndicator">' . sprintf($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_mod_web_list.xml:pageIndicator'), $pageNumberInput, $totalPages) . '</span>';
            if ($totalItems > $firstElementNumber + $iLimit) {
                $lastElementNumber = $firstElementNumber + $iLimit;
            } else {
                $lastElementNumber = $totalItems;
            }
            $rangeIndicator = '<span class="pageIndicator">' . sprintf($GLOBALS['LANG']->sL('LLL:EXT:lang/locallang_mod_web_list.xml:rangeIndicator'), $firstElementNumber + 1, $lastElementNumber) . '</span>';
            $reload = '<input type="text" name="nbPerPage" id="nbPerPage" size="5" value="' . $iLimit . '"/> / page ' . '<a href="#"  onClick="jumpToUrl(\'' . $listURLOrig . '&nbPerPage=\'+document.getElementById(\'nbPerPage\').value);">' . '<img width="16" height="16" title="" alt="" src="sysext/t3skin/icons/gfx/refresh_n.gif"></a>';
            $content .= '<div id="typo3-dblist-pagination">' . $first . $previous . '<span class="bar">&nbsp;</span>' . $rangeIndicator . '<span class="bar">&nbsp;</span>' . $pageIndicator . '<span class="bar">&nbsp;</span>' . $next . $last . '<span class="bar">&nbsp;</span>' . $reload . '</div>';
            $returnContent = $content;
        }
        return $returnContent;
    }
}
tx_t3devapi_miscellaneous::XCLASS('ext/t3devapi/class.tx_t3devapi_befunc.php');
Esempio n. 7
0
{
    /**
     * Constructor
     */
    public function __construct()
    {
    }
    /**
     * tx_t3devapi_export::exportRecordsToXML()
     * Example :
     * $query['SELECT'] = 'uid,title,category';
     * $query['FROM'] = 'tt_news';
     * $query['WHERE'] = '';
     *
     * @param array $query
     * @return string
     */
    public function exportRecordsToXML($query)
    {
        $xmlObj = TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('t3lib_xml', 'typo3_export');
        $xmlObj->setRecFields($query['FROM'], $query['SELECT']);
        $xmlObj->renderHeader();
        $res = $GLOBALS['TYPO3_DB']->exec_SELECTquery($query['SELECT'], $query['FROM'], $query['WHERE'], $query['GROUPBY'], $query['ORDERBY'], $query['LIMIT']);
        $xmlObj->renderRecords($query['FROM'], $res);
        $xmlObj->renderFooter();
        $GLOBALS['TYPO3_DB']->sql_free_result($res);
        return $xmlObj->getResult();
    }
}
tx_t3devapi_miscellaneous::XCLASS('ext/t3devapi/class.tx_t3devapi_export.php');
     * @param string $value
     * @param string $param
     * @param string $error
     * @return bool
     */
    public function isRegexp($value, $param, $error)
    {
        if (!preg_match($param, $value)) {
            $this->setError($error);
            return false;
        }
        return true;
    }
    /**
     * Check if teh value is an URI
     *
     * @param string $value
     * @param string $error
     * @return bool
     */
    public function isUri($value, $error)
    {
        if (!preg_match('/^(?#Protocol)(?:(?:ht|f)tp(?:s?)\\:\\/\\/|~\\/|\\/)?(?#Username:Password)(?:\\w+:\\w+@)?(?#Subdomains)(?:(?:[-\\w]+\\.)+(?#TopLevel Domains)(?:com|org|net|gov|mil|biz|info|mobi|name|aero|jobs|museum|travel|[a-z]{2}))(?#Port)(?::[\\d]{1,5})?(?#Directories)(?:(?:(?:\\/(?:[-\\w~!$+|.,=]|%[a-f\\d]{2})+)+|\\/)+|\\?|#)?(?#Query)(?:(?:\\?(?:[-\\w~!$+|.,*:]|%[a-f\\d{2}])+=?(?:[-\\w~!$+|.,*:=]|%[a-f\\d]{2})*)(?:&(?:[-\\w~!$+|.,*:]|%[a-f\\d{2}])+=?(?:[-\\w~!$+|.,*:=]|%[a-f\\d]{2})*)*)*(?#Anchor)(?:#(?:[-\\w~!$+|.,*:=]|%[a-f\\d]{2})*)?$/', $value)) {
            $this->setError($error);
            return false;
        }
        return true;
    }
}
tx_t3devapi_miscellaneous::XCLASS('ext/t3devapi/class.tx_t3devapi_validate.php');
 /**
  * Template rendering for subdatas and principal datas
  *
  * @param array   $templateMarkers
  * @param string  $templateSection
  * @param boolean $debug
  * @return string HTML code
  */
 public function renderAllTemplate($templateMarkers, $templateSection, $debug = false)
 {
     // Check if the template is loaded
     if (!$this->templateContent) {
         return false;
     }
     // Check argument
     if (!is_array($templateMarkers)) {
         return false;
     }
     if ($debug === true) {
         tx_t3devapi_miscellaneous::debug($templateMarkers, 'Markers for ' . $templateSection);
     }
     $content = '';
     if (is_array($templateMarkers[0])) {
         foreach ($templateMarkers as $markers) {
             $content .= $this->renderAllTemplate($markers, $templateSection, $debug);
         }
     } else {
         $content = $this->renderSingle($templateMarkers, $templateSection);
     }
     return $this->cleanTemplate($content);
 }
Esempio n. 10
0
     * Start to profile with xhprof
     *
     * @return void
     */
    public function profilerStart()
    {
        if (extension_loaded('xhprof')) {
            include_once $this->xhprofLibPath . 'utils/xhprof_lib.php';
            include_once $this->xhprofLibPath . 'utils/xhprof_runs.php';
            xhprof_enable(XHPROF_FLAGS_CPU + XHPROF_FLAGS_MEMORY);
        }
    }
    /**
     * Stop to profile with xhprof
     *
     * @return void
     */
    public function profilerStop()
    {
        if (extension_loaded('xhprof')) {
            $xhprofData = xhprof_disable();
            $xhprofRuns = new XHProfRuns_Default();
            $runId = $xhprofRuns->save_run($xhprofData, $this->xhprofNamespace);
            $profilerUrl = sprintf($this->xhprofHtmlPath . 'index.php?run=%s&source=%s', $runId, $this->xhprofNamespace);
            $styles = ' style="display: block; position: absolute; left: 5px; bottom: 5px; background: red; padding: 8px; z-index: 10000; color: #fff;"';
            echo '<a href="' . $profilerUrl . '" target="_blank" ' . $styles . '>Profiler output</a>';
        }
    }
}
tx_t3devapi_miscellaneous::XCLASS('ext/t3devapi/class.tx_t3devapi_profiler.php');
 /**
  * renderLink
  *
  * @test
  */
 public function renderLink()
 {
     $uidPage = 1;
     $this->assertFalse($this->checkPageExist($uidPage), 'Page with uid ' . $uidPage . ' should exist and be displayed');
     tx_t3devapi_miscellaneous::buildTSFE($uidPage);
     $this->cObj = $GLOBALS['TSFE']->cObj;
     $this->setUp();
     $markersArray = array();
     $htmlGenerated = $this->template->renderAllTemplate($markersArray, '###ITEM_LINK###');
     $this->assertEquals($htmlGenerated, $this->getContentTemplateFile('renderLink.html'));
 }