/** * Remove isotope js, as we dont want to use mootools * * @param $strBuffer * * @return mixed */ public function hookReplaceDynamicScriptTags($strBuffer) { if (!is_array($GLOBALS['TL_JAVASCRIPT'])) { return $strBuffer; } $arrJs = $GLOBALS['TL_JAVASCRIPT']; foreach ($arrJs as $key => $strValue) { $arrData = trimsplit('|', $strValue); if (\HeimrichHannot\Haste\Util\StringUtil::endsWith($arrData[0], 'system/modules/isotope/assets/js/isotope.min.js')) { unset($GLOBALS['TL_JAVASCRIPT'][$key]); break; } } return $strBuffer; }
public static function replaceRelation(array $arrRelation, $strTag) { $params = preg_split('/::/', $strTag); if (!isset($arrRelation['insertTagLink']) || !isset($arrRelation['table'])) { return false; } $relParams = str_replace(array('{', '}'), '', $arrRelation['insertTagLink']); $relParams = preg_split('/::/', $relParams); // check if given relation inserttag is provided if ($relParams[0] != $params[0]) { return false; } $pageId = null; $moduleId = null; $entityId = null; if (($pageIdx = array_search('PAGE_ID', $relParams)) !== false) { $pageId = $params[$pageIdx]; } if (($entityIdx = array_search('ENTITY_ID', $relParams)) !== false) { $entityId = $params[$entityIdx]; } if (($moduleIdx = array_search('MODULE_ID', $relParams)) !== false) { $moduleId = $params[$moduleIdx]; } if ($pageId === null || ($objPage = \PageModel::findPublishedByIdOrAlias($pageId)) === null) { return false; } if ($moduleId === null || ($objModule = \ModuleModel::findByPk($moduleId)) === null) { return false; } if ($entityId === null || ($objEntity = SubmissionCreator::findRelatedEntity($entityId, $arrRelation, $objModule->current())) === null) { return false; } if (StringUtil::endsWith($params[0], '_link')) { return SubmissionCreator::getRelationLink($objPage->current(), $objEntity->current(), $arrRelation); } return false; }
/** * @dataProvider endsWithProvider * @test */ public function testEndsWith($haystack, $needle, $expectedResult) { $this->assertSame($expectedResult, StringUtil::endsWith($haystack, $needle)); }
public function addTwitterBootstrap() { $arrJs = $GLOBALS['TL_JAVASCRIPT']; // do not include more than once if (isset($arrJs['bootstrap'])) { return false; } $in = BOOTSTRAPJSDIR . 'bootstrap' . (!$GLOBALS['TL_CONFIG']['debugMode'] ? '.min' : '') . '.js'; if (!file_exists(TL_ROOT . '/' . $in)) { return false; } $intJqueryIndex = 0; $i = 0; // detemine jquery index from file name, as we should append bootstrapper always after jquery foreach ($arrJs as $index => $strFile) { if (!StringUtil::endsWith($strFile, 'jquery.min.js|static')) { $i++; continue; } $intJqueryIndex = $i + 1; break; } array_insert($arrJs, $intJqueryIndex, array('bootstrap' => $in . (!$GLOBALS['TL_CONFIG']['debugMode'] ? '|static' : ''))); $GLOBALS['TL_JAVASCRIPT'] = $arrJs; }
/** * Get relation table, field and model class, from a foreignKey * * @param $varValue The foreignKey as String (e.g tl_page.id) * * @return array|bool Return list with relation table, field and model class or false if no valid foreignKey */ protected function getRelationData($varValue) { $arrRelation = trimsplit('.', $varValue); if (is_array($arrRelation) && !$arrRelation[0]) { return false; } $strTable = $arrRelation[0]; $strField = $arrRelation[1]; if (\HeimrichHannot\Haste\Util\StringUtil::startsWith($arrRelation[0], '%') && \HeimrichHannot\Haste\Util\StringUtil::endsWith($arrRelation[0], '%')) { $strField = str_replace('%', '', $arrRelation[0]); if (!$this->activeRecord->{$strField}) { return false; } $strTable = $this->activeRecord->{$strField}; } $strModelClass = \Model::getClassFromTable($strTable); if (!class_exists($strModelClass)) { return false; } return array($strTable, $strField, $strModelClass); }