/** * * * * Static methods for work with template injections * * * * * Static method is used to add/replace the content of some key in the template. * It's usefull when you don't want to modify existing template but need to add some data to existing template key. * * @param integer $iPageIndex - page index where injections would processed. Use 0 if you want it to be done on all the pages. * @param string $sKey - template key. * @param string $sValue - the data to be added. * @return string the result of operation. */ function processInjection($iPageIndex, $sKey, $sValue = "") { if ($iPageIndex != 0 && isset($this->aPage['injections']['page_0'][$sKey]) && isset($this->aPage['injections']['page_' . $iPageIndex][$sKey])) { $aSelection = @array_merge($this->aPage['injections']['page_0'][$sKey], $this->aPage['injections']['page_' . $iPageIndex][$sKey]); } else { if (isset($this->aPage['injections']['page_0'][$sKey])) { $aSelection = $this->aPage['injections']['page_0'][$sKey]; } else { if (isset($this->aPage['injections']['page_' . $iPageIndex][$sKey])) { $aSelection = $this->aPage['injections']['page_' . $iPageIndex][$sKey]; } else { $aSelection = array(); } } } if (is_array($aSelection)) { foreach ($aSelection as $aInjection) { if (isset($GLOBALS['bx_profiler'])) { $GLOBALS['bx_profiler']->beginInjection($sRand = time() . rand()); } $sInjData = ''; switch ($aInjection['type']) { case 'text': $sInjData = $aInjection['data']; break; case 'service': if (BxDolService::isSerializedService($aInjection['data'])) { $sInjData = BxDolService::callSerialized($aInjection['data']); } break; } if ((int) $aInjection['replace'] == 1) { $sValue = $sInjData; } else { $sValue .= $sInjData; } if (isset($GLOBALS['bx_profiler'])) { $GLOBALS['bx_profiler']->endInjection($sRand, $aInjection); } } } return $sValue != '__' . $sKey . '__' ? str_replace('__' . $sKey . '__', '', $sValue) : $sValue; }
protected function _getRequestedDataBySystem($aSystem, $iCachedData = 0) { if (!BxDolService::isSerializedService($aSystem['service_call'])) { return false; } $aResponce = BxDolService::callSerialized($aSystem['service_call'], array('count' => (int) $iCachedData)); if (empty($aResponce) || !is_array($aResponce) || !isset($aResponce['count'], $aResponce['method'])) { return false; } return $aResponce; }
protected function _getMenuAddon($aMenuItem) { if (empty($aMenuItem['addon'])) { return ''; } return BxDolService::callSerialized($aMenuItem['addon'], $this->_aMarkers); }
function runJob($aJob) { if (!empty($aJob['file']) && !empty($aJob['class']) && file_exists(BX_DIRECTORY_PATH_ROOT . $aJob['file'])) { if (!class_exists($aJob['class'])) { require_once BX_DIRECTORY_PATH_ROOT . $aJob['file']; } $oHandler = new $aJob['class'](); $oHandler->processing(); } else { if (!empty($aJob['service_call']) && BxDolService::isSerializedService($aJob['service_call'])) { BxDolService::callSerialized($aJob['service_call']); } } }
/** * Get content for 'service' block type. * @return string */ protected function _getBlockService($aBlock) { return BxDolService::callSerialized($aBlock['content'], $this->_aMarkers); }
protected function field($aItem) { $aField = array(); switch ($aItem['type']) { case 'digit': $aField = array('type' => 'text', 'name' => $aItem['name'], 'caption' => _t($aItem['caption']), 'value' => $aItem['value'], 'db' => array('pass' => 'Xss')); break; case 'text': $aField = array('type' => 'textarea', 'name' => $aItem['name'], 'caption' => _t($aItem['caption']), 'value' => $aItem['value'], 'db' => array('pass' => 'XssHtml')); break; case 'checkbox': $aField = array('type' => 'checkbox', 'name' => $aItem['name'], 'caption' => _t($aItem['caption']), 'value' => 'on', 'checked' => $aItem['value'] == 'on', 'db' => array('pass' => 'Xss')); break; case 'list': case 'rlist': $aField = array('type' => 'checkbox_set', 'name' => $aItem['name'], 'caption' => _t($aItem['caption']), 'value' => !empty($aItem['value']) ? explode(',', $aItem['value']) : array(), 'reverse' => $aItem['type'] == 'rlist', 'db' => array('pass' => 'Xss')); if (BxDolService::isSerializedService($aItem['extra'])) { $aField['values'] = BxDolService::callSerialized($aItem['extra']); } else { foreach (explode(',', $aItem['extra']) as $sValue) { $aField['values'][$sValue] = $sValue; } } break; case 'select': $aField = array('type' => 'select', 'name' => $aItem['name'], 'caption' => _t($aItem['caption']), 'value' => $aItem['value'], 'values' => array(), 'db' => array('pass' => 'Xss')); if (BxDolService::isSerializedService($aItem['extra'])) { $aField['values'] = BxDolService::callSerialized($aItem['extra']); } else { foreach (explode(',', $aItem['extra']) as $sValue) { $aField['values'][] = array('key' => $sValue, 'value' => $sValue); } } break; case 'file': $aField = array('type' => 'file', 'name' => $aItem['name'], 'caption' => _t($aItem['caption']), 'value' => $aItem['value'], 'db' => array('pass' => 'Xss')); break; } return $aField; }
protected function _getRequestedData($iIndex = 0, $bIndexCheck = false) { $aResult = array(); foreach ($this->_aSystems as $aSystem) { if (empty($aSystem) || !is_array($aSystem) || (int) $aSystem['active'] != 1) { continue; } if ($bIndexCheck && $iIndex % (int) $aSystem['frequency'] != 0) { continue; } if (!BxDolService::isSerializedService($aSystem['service_call'])) { continue; } $aResponce = BxDolService::callSerialized($aSystem['service_call']); if (empty($aResponce) || !is_array($aResponce) || !isset($aResponce['count'], $aResponce['method'])) { continue; } $aResult[$aSystem['name']] = $aResponce; } return $aResult; }
protected function getEmptyValue($aOption) { $mixedValue = ''; switch ($aOption['type']) { case 'digit': $mixedValue = 0; break; case 'select': if (BxDolService::isSerializedService($aOption['extra'])) { $aValues = BxDolService::callSerialized($aOption['extra']); } else { $aValues = explode(',', $aOption['extra']); } $mixedValue = $aValues[0]; break; case 'text': case 'checkbox': case 'file': $mixedValue = ""; break; } return $mixedValue; }