本文整理汇总了PHP中System::importStatic方法的典型用法代码示例。如果您正苦于以下问题:PHP System::importStatic方法的具体用法?PHP System::importStatic怎么用?PHP System::importStatic使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System
的用法示例。
在下文中一共展示了System::importStatic方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: handle
/**
* {@inheritdoc}
*/
public function handle(\Input $input)
{
$this->handleRunOnce();
// PATCH
if ($input->post('FORM_SUBMIT') == 'database-update') {
$count = 0;
$sql = deserialize($input->post('sql'));
if (is_array($sql)) {
foreach ($sql as $key) {
if (isset($_SESSION['sql_commands'][$key])) {
$this->Database->query(str_replace('DEFAULT CHARSET=utf8;', 'DEFAULT CHARSET=utf8 COLLATE ' . $GLOBALS['TL_CONFIG']['dbCollation'] . ';', $_SESSION['sql_commands'][$key]));
$count++;
}
}
}
$_SESSION['sql_commands'] = array();
Messages::addConfirmation(sprintf($GLOBALS['TL_LANG']['composer_client']['databaseUpdated'], $count));
$this->reload();
}
/** @var \Contao\Database\Installer $installer */
$installer = \System::importStatic('Database\\Installer');
$form = $installer->generateSqlForm();
if (empty($form)) {
Messages::addInfo($GLOBALS['TL_LANG']['composer_client']['databaseUptodate']);
$this->redirect('contao/main.php?do=composer');
}
$form = preg_replace('#(<label for="sql_\\d+")>(CREATE TABLE)#', '$1 class="create_table">$2', $form);
$form = preg_replace('#(<label for="sql_\\d+")>(ALTER TABLE `[^`]+` ADD)#', '$1 class="alter_add">$2', $form);
$form = preg_replace('#(<label for="sql_\\d+")>(ALTER TABLE `[^`]+` DROP)#', '$1 class="alter_drop">$2', $form);
$form = preg_replace('#(<label for="sql_\\d+")>(DROP TABLE)#', '$1 class="drop_table">$2', $form);
$template = new \BackendTemplate('be_composer_client_update');
$template->composer = $this->composer;
$template->form = $form;
return $template->parse();
}
示例2: getActiveLayoutSections
public function getActiveLayoutSections(\DataContainer $dc)
{
$callback = $GLOBALS['TL_DCA']['tl_article']['fields']['inColumn']['bit3_merger_original_options_callback'];
if (is_array($callback)) {
$object = \System::importStatic($callback[0]);
$methodName = $callback[1];
$sections = $object->{$methodName}($dc);
} else {
$sections = call_user_func($callback, $dc);
}
if ($dc->activeRecord->pid) {
$page = \PageModel::findWithDetails($dc->activeRecord->pid);
// Get the layout sections
foreach (array('layout', 'mobileLayout') as $key) {
if (!$page->{$key}) {
continue;
}
$layout = \LayoutModel::findByPk($page->{$key});
if ($layout === null) {
continue;
}
$modules = deserialize($layout->modules);
if (empty($modules) || !is_array($modules)) {
continue;
}
// Find all sections with an article module (see #6094)
foreach ($modules as $module) {
if ($module['mod'] != 0 && $module['enable']) {
$this->joinModule($module['col'], $module['mod'], $sections);
}
}
}
}
return array_values(array_unique($sections));
}
示例3: compile
protected function compile()
{
$arrProducts = $this->findProducts();
// No products found
if (!is_array($arrProducts) || empty($arrProducts)) {
// Do not index or cache the page
$objPage->noSearch = 1;
$objPage->cache = 0;
$this->Template->empty = true;
$this->Template->type = 'empty';
$this->Template->message = $GLOBALS['TL_LANG']['MSC']['noProducts'];
$this->Template->products = array();
return;
}
$arrBuffer = array();
foreach ($arrProducts as $objProduct) {
$arrConfig = array('module' => $this, 'template' => $this->iso_list_layout ?: $objProduct->getRelated('type')->list_template, 'gallery' => $this->iso_gallery ?: $objProduct->getRelated('type')->list_gallery, 'buttons' => deserialize($this->iso_buttons, true), 'useQuantity' => $this->iso_use_quantity, 'jumpTo' => $this->findJumpToPage($objProduct));
if (\Environment::get('isAjaxRequest') && \Input::post('AJAX_MODULE') == $this->id && \Input::post('AJAX_PRODUCT') == $objProduct->getProductId()) {
$objResponse = new HtmlResponse($objProduct->generate($arrConfig));
$objResponse->send();
}
$arrCSS = deserialize($objProduct->cssID, true);
$arrBuffer[] = array('cssID' => $arrCSS[0] != '' ? ' id="' . $arrCSS[0] . '"' : '', 'class' => trim('product ' . ($objProduct->isNew() ? 'new ' : '') . $arrCSS[1]), 'html' => $objProduct->generate($arrConfig), 'product' => $objProduct);
}
// HOOK: to add any product field or attribute to mod_iso_productlist template
if (isset($GLOBALS['ISO_HOOKS']['generateProductList']) && is_array($GLOBALS['ISO_HOOKS']['generateProductList'])) {
foreach ($GLOBALS['ISO_HOOKS']['generateProductList'] as $callback) {
$objCallback = \System::importStatic($callback[0]);
$arrBuffer = $objCallback->{$callback}[1]($arrBuffer, $arrProducts, $this->Template, $this);
}
}
RowClass::withKey('class')->addCount('product_')->addEvenOdd('product_')->addFirstLast('product_')->addGridRows($this->iso_cols)->addGridCols($this->iso_cols)->applyTo($arrBuffer);
$this->Template->products = $arrBuffer;
}
示例4: isAvailable
/**
* Check if collection item is available
*
* @return bool
*/
public function isAvailable()
{
if ($this->isLocked()) {
return true;
}
if (isset($GLOBALS['ISO_HOOKS']['itemIsAvailable']) && is_array($GLOBALS['ISO_HOOKS']['itemIsAvailable'])) {
foreach ($GLOBALS['ISO_HOOKS']['itemIsAvailable'] as $callback) {
$objCallback = \System::importStatic($callback[0]);
$available = $objCallback->{$callback}[1]($this);
// If return value is boolean then we accept it as result
if (true === $available || false === $available) {
return $available;
}
}
}
if (!$this->hasProduct() || !$this->getProduct()->isAvailableForCollection($this->getRelated('pid'))) {
return false;
}
// @todo change to ->getConfiguration() in Isotope 3.0
$arrConfig = $this->getOptions();
foreach ($this->getProduct()->getOptions() as $k => $v) {
if ($arrConfig[$k] !== $v) {
return false;
}
}
return true;
}
示例5: initialize
/**
* Initialize the backend view.
*
* @param DataContainer $dataContainer The data container.
*
* @return void
*/
public function initialize($dataContainer)
{
if (TL_MODE !== 'BE') {
return;
}
$this->getServiceContainer()->getAssetsManager()->addStylesheet('system/modules/content-node/assets/css/backend.css');
$callback = $this->definition->get('list/sorting/child_record_callback');
if (is_array($callback)) {
$callback[0] = \System::importStatic($callback[0]);
}
$renderer = new BackendRenderer($this->registry, $callback);
$definition = $this->getServiceContainer()->getDcaManager()->get('tl_content');
$definition->set('list/sorting/child_record_callback', $renderer);
$parentType = null;
if ($dataContainer->parentTable === 'tl_content_node') {
$parent = \ContentModel::findByPk(CURRENT_ID);
if ($parent && $this->registry->hasNodeType($parent->tye)) {
$parentType = $this->registry->getNode($parent->type);
}
}
try {
$restriction = new ContentElementAccess($this->definition, $this->registry, $this->getServiceContainer()->getDatabaseConnection(), $this->getServiceContainer()->getSession(), $this->getServiceContainer()->getInput());
$restriction->restrict($dataContainer->id, $parentType);
} catch (AccessDeniedException $e) {
\Controller::log($e->getMessage(), 'ContentElementAccess::resitrct', TL_ACCESS);
\Controller::redirect(\Environment::get('script') . '?act=error');
}
}
示例6: invoke
/**
* Handle the callback.
*
* @param array|callable $callback Callback as Contao array notation or as PHP callable.
* @param array $arguments List of arguments being passed to the callback.
*
* @return mixed
* @throws InvalidArgumentException On callback is not callable.
*/
public function invoke($callback, array $arguments = [])
{
if (is_array($callback)) {
$callback[0] = \System::importStatic($callback[0]);
}
Assert::isCallable($callback);
return call_user_func_array($callback, $arguments);
}
示例7: callButtonCallback
/**
* Call the button callback.
*
* @param array $button The button definition.
* @param array $row The current row.
* @param string $label The label.
* @param string $title The title.
* @param string $attributes The attributes.
*
* @return string
*/
private function callButtonCallback($button, $row, $label, $title, $attributes)
{
if (is_array($button['button_callback'])) {
$button['button_callback'][0] = \System::importStatic($button['button_callback'][0]);
}
if (is_callable($button['button_callback'])) {
return call_user_func($button['button_callback'], $row, $button['href'] .= '&nodes=1', $label, $title, $button['icon'], $attributes, $this->definition->getName(), array(), null, false, null, null);
}
return '';
}
示例8: generateItemLabel
/**
* Generate item label and return it as HTML string
* @param object
* @param string
* @param object
* @param string
* @param mixed
* @return string
*/
public static function generateItemLabel($objItem, $strForeignTable, $objDca = null, $strTitleField = '', $varCallback = null)
{
$args = array();
$label = '';
$blnSimple = false;
$showFields = $GLOBALS['TL_DCA'][$strForeignTable]['list']['label']['fields'];
// Generate simple label, e.g. for breadcrumb
if ($strTitleField != '') {
$blnSimple = true;
$showFields['titleField'] = $strTitleField;
}
foreach ($showFields as $k => $v) {
// Decrypt the value
if ($GLOBALS['TL_DCA'][$strForeignTable]['fields'][$v]['eval']['encrypt']) {
$objItem->{$v} = \Encryption::decrypt(deserialize($objItem->{$v}));
}
if (strpos($v, ':') !== false) {
list($strKey, $strTable) = explode(':', $v);
list($strTable, $strField) = explode('.', $strTable);
$objRef = \Database::getInstance()->prepare("SELECT " . $strField . " FROM " . $strTable . " WHERE id=?")->limit(1)->execute($objItem->{$strKey});
$args[$k] = $objRef->numRows ? $objRef->{$strField} : '';
} elseif (in_array($GLOBALS['TL_DCA'][$strForeignTable]['fields'][$v]['flag'], array(5, 6, 7, 8, 9, 10))) {
$args[$k] = \Date::parse($GLOBALS['TL_CONFIG']['datimFormat'], $objItem->{$v});
} elseif ($GLOBALS['TL_DCA'][$strForeignTable]['fields'][$v]['inputType'] == 'checkbox' && !$GLOBALS['TL_DCA'][$strForeignTable]['fields'][$v]['eval']['multiple']) {
$args[$k] = $objItem->{$v} != '' ? isset($GLOBALS['TL_DCA'][$strForeignTable]['fields'][$v]['label'][0]) ? $GLOBALS['TL_DCA'][$strForeignTable]['fields'][$v]['label'][0] : $v : '';
} else {
$args[$k] = $GLOBALS['TL_DCA'][$strForeignTable]['fields'][$v]['reference'][$objItem->{$v}] ?: $objItem->{$v};
}
}
$label = vsprintf(strlen($GLOBALS['TL_DCA'][$strForeignTable]['list']['label']['format']) ? $GLOBALS['TL_DCA'][$strForeignTable]['list']['label']['format'] : '%s', $args);
// Shorten the label if it is too long
if ($GLOBALS['TL_DCA'][$strForeignTable]['list']['label']['maxCharacters'] > 0 && $GLOBALS['TL_DCA'][$strForeignTable]['list']['label']['maxCharacters'] < utf8_strlen(strip_tags($label))) {
$label = trim(\String::substrHtml($label, $GLOBALS['TL_DCA'][$strForeignTable]['list']['label']['maxCharacters'])) . ' …';
}
$label = preg_replace('/\\(\\) ?|\\[\\] ?|\\{\\} ?|<> ?/', '', $label);
// Use the default callback if none provided
if ($varCallback === null) {
$varCallback = $GLOBALS['TL_DCA'][$strForeignTable]['list']['label']['label_callback'];
}
// Call the label_callback ($row, $label, $this)
if (is_array($varCallback)) {
$strClass = $varCallback[0];
$strMethod = $varCallback[1];
$label = \System::importStatic($strClass)->{$strMethod}($objItem->row(), $label, $objDca, '', $blnSimple, false);
} elseif (is_callable($varCallback)) {
$label = $varCallback($objItem->row(), $label, $objDca, '', $blnSimple, false);
} else {
$label = \Image::getHtml('iconPLAIN.gif') . ' ' . ($blnSimple ? $args['titleField'] : $label);
}
return $label;
}
示例9: __construct
/**
* Must be defined cause parent is protected.
*
* @access public
* @return void
*/
public function __construct()
{
parent::__construct();
// Contao Hooks are not save to be run on the postsale script (e.g. parseFrontendTemplate)
unset($GLOBALS['TL_HOOKS']);
// Need to load our own Hooks (e.g. loadDataContainer)
include TL_ROOT . '/system/modules/isotope/config/hooks.php';
// Default parameters
$this->setModule(strlen(\Input::post('mod')) ? \Input::post('mod') : \Input::get('mod'));
$this->setModuleId(strlen(\Input::post('id')) ? \Input::post('id') : \Input::get('id'));
// HOOK: allow to add custom hooks for postsale script
if (isset($GLOBALS['ISO_HOOKS']['initializePostsale']) && is_array($GLOBALS['ISO_HOOKS']['initializePostsale'])) {
foreach ($GLOBALS['ISO_HOOKS']['initializePostsale'] as $callback) {
$objCallback = \System::importStatic($callback[0]);
$objCallback->{$callback}[1]($this);
}
}
}
示例10: run
/**
* Send data submissions to Salesforce
*
* Class: Form
* Method: processFormData
* Hook: $GLOBALS['TL_HOOKS']['processFormData']
*
* @access public
* @param array
* @param array
* @param array
* @param array
* @return void
*/
public function run($arrSubmitted, $arrFormData, $arrFiles, $arrLabels, $objForm)
{
try {
if ($objForm->useSalesforce && $objForm->salesforceAPIConfig && $objForm->salesforceSObject) {
if ($this->connectToSalesforce($objForm->salesforceAPIConfig)) {
$arrSObjectConfig = $GLOBALS['TL_SOBJECTS'][$objForm->salesforceSObject];
if (is_array($arrSObjectConfig) && count($arrSObjectConfig) && $arrSObjectConfig['class'] && class_exists($arrSObjectConfig['class'])) {
$strMethod = 'create';
// Todo: Maybe we make this an option? create, update, etc.
$strClass = $arrSObjectConfig['class'];
$arrData = static::getSalesforceFields($arrSubmitted, $objForm->id);
// todo: check mandatory fields for different object types
// !HOOK: alter Salesforce data before sending
if (isset($GLOBALS['TL_HOOKS']['preSendSalesforceData']) && is_array($GLOBALS['TL_HOOKS']['preSendSalesforceData'])) {
foreach ($GLOBALS['TL_HOOKS']['preSendSalesforceData'] as $callback) {
$objCallback = \System::importStatic($callback[0]);
$arrData = $objCallback->{$callback}[1]($strClass, $arrData, $arrSubmitted, $arrFormData, $arrFiles, $arrLabels, $objForm, $this->objClient, $strMethod);
}
}
// Create the Salesforce object
$objSObject = new $strClass($arrData);
// Send the data to Salesforce
$response = $this->objClient->{$strMethod}(array($objSObject), $strClass::getType());
// !HOOK: execute custom actions after sending data to Salesforce
if (isset($GLOBALS['TL_HOOKS']['postSendSalesforceData']) && is_array($GLOBALS['TL_HOOKS']['postSendSalesforceData'])) {
foreach ($GLOBALS['TL_HOOKS']['postSendSalesforceData'] as $callback) {
$objCallback = \System::importStatic($callback[0]);
$objCallback->{$callback}[1]($response, $objSObject, $arrData, $arrSubmitted, $arrFormData, $arrFiles, $arrLabels, $objForm, $this->objClient, $strMethod);
}
}
if ($response[0]->isSuccess()) {
\System::log('Salesforce ' . $objForm->salesforceSObject . ' (ID ' . $response[0]->getId() . ') successful.', __METHOD__, TL_FORMS);
} else {
$errors = $response[0]->getErrors();
\System::log('Salesforce object creation failed: ' . $errors[0]->getMessage(), __METHOD__, TL_ERROR);
}
}
}
}
} catch (\Exception $e) {
\System::log('Failed to send data to Salesforce: ' . $e->getMessage(), __METHOD__, TL_ERROR);
}
return false;
}
示例11: toggleVisibility
/**
* Publish/unpublish rule
* @param integer
* @param boolean
* @param \DataContainer
*/
public function toggleVisibility($intId, $blnVisible, \DataContainer $dc = null)
{
$objVersions = new \Versions('tl_css_class_replacer', $intId);
$objVersions->initialize();
// Trigger the save_callback
if (is_array($GLOBALS['TL_DCA']['tl_css_class_replacer']['fields']['published']['save_callback'])) {
foreach ($GLOBALS['TL_DCA']['tl_css_class_replacer']['fields']['published']['save_callback'] as $callback) {
if (is_array($callback)) {
$blnVisible = \System::importStatic($callback[0])->{$callback}[1]($blnVisible, $dc ?: $this);
} elseif (is_callable($callback)) {
$blnVisible = $callback($blnVisible, $dc ?: $this);
}
}
}
// Update the database
\Database::getInstance()->prepare("UPDATE tl_css_class_replacer SET tstamp=" . time() . ", published='" . ($blnVisible ? 1 : '') . "' WHERE id=?")->execute($intId);
$objVersions->create();
\System::log('A new version of record "tl_css_class_replacer.id=' . $intId . '" has been created', __METHOD__, TL_GENERAL);
}
示例12: send
/**
* Send this message using its gateway
* @param array
* @param string
* @return bool
*/
public function send(array $arrTokens, $strLanguage = '')
{
/** @var Gateway $objGatewayModel */
if (($objGatewayModel = $this->getRelated('gateway')) === null) {
\System::log(sprintf('Could not find gateway ID "%s".', $this->gateway), __METHOD__, TL_ERROR);
return false;
}
if (null === $objGatewayModel->getGateway()) {
\System::log(sprintf('Could not find gateway class for gateway ID "%s".', $objGatewayModel->id), __METHOD__, TL_ERROR);
return false;
}
if (isset($GLOBALS['TL_HOOKS']['sendNotificationMessage']) && is_array($GLOBALS['TL_HOOKS']['sendNotificationMessage'])) {
foreach ($GLOBALS['TL_HOOKS']['sendNotificationMessage'] as $arrCallback) {
$blnSuccess = \System::importStatic($arrCallback[0])->{$arrCallback}[1]($this, $arrTokens, $strLanguage, $objGatewayModel);
if (!$blnSuccess) {
return false;
}
}
}
return $objGatewayModel->getGateway()->send($this, $arrTokens, $strLanguage);
}
示例13: buildCache
protected function buildCache(\TwigBackendTemplate $template, Cache $cache, \Session $session)
{
// clear the existing caches
/** @var \Automator $automator */
$automator = \System::importStatic('Automator');
$automator->purgeScriptCache();
if ($cache instanceof CacheProvider) {
$cache->deleteAll();
}
// overwrite frontend username
$template->frontendUsername = \Input::post('user');
$session->set(self::SESSION_LAST_USERNAME, $template->frontendUsername);
// Use searchable pages to generate assets
// TODO this seems to be not a good idea...
// $GLOBALS['TL_CONFIG']['indexProtected'] = true;
// $template->urls = \Backend::findSearchablePages(0, '', true);
list($guestUrls, $memberUrls) = $this->buildPageUrls(0, \Environment::get('base') . '/');
$template->guestUrls = $guestUrls;
$template->memberUrls = $memberUrls;
$cache->save(ThemePlus::CACHE_CREATION_TIME, time());
}
示例14: getName
/**
* Get the filename from a database config.
*
* @param \Database\Result $config
* @return string
*/
public static function getName($config)
{
if ($config->filename == '') {
$filename = 'export_' . md5(uniqid());
if ($config->type) {
$filename .= '.' . $config->type;
}
return $filename;
}
$tokens = array('time' => \Date::parse($GLOBALS['TL_CONFIG']['timeFormat']), 'date' => \Date::parse($GLOBALS['TL_CONFIG']['dateFormat']), 'datim' => \Date::parse($GLOBALS['TL_CONFIG']['datimFormat']));
// Add custom logic
if (isset($GLOBALS['TL_HOOKS']['getLeadsFilenameTokens']) && is_array($GLOBALS['TL_HOOKS']['getLeadsFilenameTokens'])) {
foreach ($GLOBALS['TL_HOOKS']['getLeadsFilenameTokens'] as $callback) {
if (is_array($callback)) {
$tokens = \System::importStatic($callback[0])->{$callback[1]}($tokens, $config);
} elseif (is_callable($callback)) {
$tokens = $callback($tokens, $config);
}
}
}
return \String::parseSimpleTokens($config->filename, $tokens);
}
示例15: getForTemplate
/**
* Generate array representation for download
*
* @param bool $blnOrderPaid
*
* @return array
*/
public function getForTemplate($blnOrderPaid = false)
{
global $objPage;
$objDownload = $this->getRelated('download_id');
if (null === $objDownload) {
return array();
}
$arrDownloads = array();
$allowedDownload = trimsplit(',', strtolower($GLOBALS['TL_CONFIG']['allowedDownload']));
foreach ($objDownload->getFiles() as $objFileModel) {
$objFile = new \File($objFileModel->path, true);
if (!in_array($objFile->extension, $allowedDownload) || preg_match('/^meta(_[a-z]{2})?\\.txt$/', $objFile->basename)) {
continue;
}
// Send file to the browser
if ($blnOrderPaid && $this->canDownload() && \Input::get('download') == $objDownload->id && \Input::get('file') == $objFileModel->path) {
$path = $objFileModel->path;
if (isset($GLOBALS['ISO_HOOKS']['downloadFromProductCollection']) && is_array($GLOBALS['ISO_HOOKS']['downloadFromProductCollection'])) {
foreach ($GLOBALS['ISO_HOOKS']['downloadFromProductCollection'] as $callback) {
$objCallback = \System::importStatic($callback[0]);
$path = $objCallback->{$callback}[1]($path, $objFileModel, $objDownload, $this);
}
}
$this->download($objFileModel->path);
}
$arrMeta = \Frontend::getMetaData($objFileModel->meta, $objPage->language);
// Use the file name as title if none is given
if ($arrMeta['title'] == '') {
$arrMeta['title'] = specialchars(str_replace('_', ' ', preg_replace('/^[0-9]+_/', '', $objFile->filename)));
}
$strHref = '';
if (TL_MODE == 'FE') {
$strHref = \Haste\Util\Url::addQueryString('download=' . $objDownload->id . '&file=' . $objFileModel->path);
}
// Add the image
$arrDownloads[] = array('id' => $this->id, 'name' => $objFile->basename, 'title' => $arrMeta['title'], 'link' => $arrMeta['title'], 'caption' => $arrMeta['caption'], 'href' => $strHref, 'filesize' => \System::getReadableSize($objFile->filesize, 1), 'icon' => TL_ASSETS_URL . 'assets/contao/images/' . $objFile->icon, 'mime' => $objFile->mime, 'meta' => $arrMeta, 'extension' => $objFile->extension, 'path' => $objFile->dirname, 'remaining' => $objDownload->downloads_allowed > 0 ? sprintf($GLOBALS['TL_LANG']['MSC']['downloadsRemaining'], intval($this->downloads_remaining)) : '', 'downloadable' => $blnOrderPaid && $this->canDownload());
}
return $arrDownloads;
}