コード例 #1
0
ファイル: template.php プロジェクト: DarneoStudio/bitrix
 /**
  * @return array
  * @throws \Bitrix\Main\ArgumentException
  */
 public static function onPresetTemplateList()
 {
     $resultList = array();
     $localPathOfIcon = static::LOCAL_DIR_IMG . 'my.png';
     $fullPathOfIcon = \Bitrix\Main\Loader::getLocal($localPathOfIcon);
     $templateDb = static::getList(array('filter' => array('ACTIVE' => 'Y')));
     while ($template = $templateDb->fetch()) {
         $resultList[] = array('TYPE' => 'USER', 'NAME' => $template['NAME'], 'ICON' => !empty($fullPathOfIcon) ? '/bitrix' . $localPathOfIcon : '', 'HTML' => $template['CONTENT']);
     }
     return $resultList;
 }
コード例 #2
0
 public static function runInitScripts()
 {
     if (($includePath = \Bitrix\Main\Loader::getLocal("init.php")) !== false) {
         require_once $includePath;
     }
     if (($includePath = \Bitrix\Main\Loader::getPersonal("php_interface/init.php")) !== false) {
         require_once $includePath;
     }
     if (($includePath = \Bitrix\Main\Loader::getPersonal("php_interface/" . SITE_ID . "/init.php")) !== false) {
         require_once $includePath;
     }
 }
コード例 #3
0
ファイル: date.php プロジェクト: DarneoStudio/bitrix
 /**
  * @param FieldType $fieldType
  * @param array $field
  * @param mixed $value
  * @param bool $allowSelection
  * @param int $renderMode
  * @return string
  */
 protected static function renderControl(FieldType $fieldType, array $field, $value, $allowSelection, $renderMode)
 {
     $name = static::generateControlName($field);
     $renderResult = '';
     if ($renderMode & FieldType::RENDER_MODE_ADMIN) {
         require_once Loader::getLocal('/modules/main/interface/init_admin.php');
         $renderResult = \CAdminCalendar::calendarDate($name, $value, 19, static::getType() == FieldType::DATETIME);
     } else {
         ob_start();
         global $APPLICATION;
         $APPLICATION->includeComponent('bitrix:main.calendar', '', array('SHOW_INPUT' => 'Y', 'FORM_NAME' => $field['Form'], 'INPUT_NAME' => $name, 'INPUT_VALUE' => $value, 'SHOW_TIME' => static::getType() == FieldType::DATETIME ? 'Y' : 'N'), false, array('HIDE_ICONS' => 'Y'));
         $renderResult = ob_get_contents();
         ob_end_clean();
     }
     return $renderResult;
 }
コード例 #4
0
ファイル: template.php プロジェクト: Hawkart/megatv
 /**
  * Handler of event that return array of templates
  *
  * @param string|null $templateType
  * @param string|null $templateId
  * @return array
  * @throws \Bitrix\Main\ArgumentException
  */
 public static function onPresetTemplateList($templateType = null, $templateId = null)
 {
     $resultList = array();
     if ($templateType && $templateType !== 'USER') {
         return $resultList;
     }
     $localPathOfIcon = static::LOCAL_DIR_IMG . 'my.png';
     $fullPathOfIcon = \Bitrix\Main\Loader::getLocal($localPathOfIcon);
     // return only active templates, but if requested template by id return any
     $filter = array();
     if ($templateId) {
         $filter['ID'] = $templateId;
     } else {
         $filter['ACTIVE'] = 'Y';
     }
     $templateDb = static::getList(array('filter' => $filter, 'order' => array('ID' => 'DESC')));
     while ($template = $templateDb->fetch()) {
         $resultList[] = array('TYPE' => 'USER', 'ID' => $template['ID'], 'NAME' => $template['NAME'], 'ICON' => !empty($fullPathOfIcon) ? '/bitrix' . $localPathOfIcon : '', 'HTML' => $template['CONTENT']);
     }
     return $resultList;
 }
コード例 #5
0
ファイル: eventmanager.php プロジェクト: ASDAFF/bxApiDocs
 private function sendToEventHandler(array $handler, Event $event)
 {
     try {
         $result = true;
         $event->addDebugInfo($handler);
         if (isset($handler["TO_MODULE_ID"]) && !empty($handler["TO_MODULE_ID"]) && $handler["TO_MODULE_ID"] != 'main') {
             $result = Loader::includeModule($handler["TO_MODULE_ID"]);
         } elseif (isset($handler["TO_PATH"]) && !empty($handler["TO_PATH"])) {
             $path = ltrim($handler["TO_PATH"], "/");
             if (($path = Loader::getLocal($path)) !== false) {
                 $result = (include_once $path);
             }
         } elseif (isset($handler["FULL_PATH"]) && !empty($handler["FULL_PATH"]) && IO\File::isFileExists($handler["FULL_PATH"])) {
             $result = (include_once $handler["FULL_PATH"]);
         }
         $event->addDebugInfo($result);
         if (isset($handler["TO_METHOD_ARG"]) && is_array($handler["TO_METHOD_ARG"]) && !empty($handler["TO_METHOD_ARG"])) {
             $args = $handler["TO_METHOD_ARG"];
         } else {
             $args = array();
         }
         if ($handler["VERSION"] > 1) {
             $args[] = $event;
         } else {
             $args = array_merge($args, array_values($event->getParameters()));
         }
         $callback = null;
         if (isset($handler["CALLBACK"])) {
             $callback = $handler["CALLBACK"];
         } elseif (!empty($handler["TO_CLASS"]) && !empty($handler["TO_METHOD"]) && class_exists($handler["TO_CLASS"])) {
             $callback = array($handler["TO_CLASS"], $handler["TO_METHOD"]);
         }
         if ($callback != null) {
             $result = call_user_func_array($callback, $args);
         }
         if ($result != null && !$result instanceof EventResult) {
             $result = new EventResult(EventResult::UNDEFINED, $result, $handler["TO_MODULE_ID"]);
         }
         $event->addDebugInfo($result);
         if ($result != null) {
             $event->addResult($result);
         }
     } catch (\Exception $ex) {
         if ($event->isDebugOn()) {
             $event->addException($ex);
         } else {
             throw $ex;
         }
     }
 }
コード例 #6
0
ファイル: cache.php プロジェクト: ASDAFF/entask.ru
 public static function createCacheEngine()
 {
     $cacheEngine = null;
     // Events can't be used here because events use cache
     $cacheType = "files";
     $v = Config\Configuration::getValue("cache");
     if ($v != null && isset($v["type"]) && !empty($v["type"])) {
         $cacheType = $v["type"];
     }
     if (is_array($cacheType)) {
         if (isset($cacheType["class_name"])) {
             if (!isset($cacheType["extension"]) || extension_loaded($cacheType["extension"])) {
                 if (isset($cacheType["required_file"]) && ($requiredFile = Main\Loader::getLocal($cacheType["required_file"])) !== false) {
                     require_once $requiredFile;
                 }
                 if (isset($cacheType["required_remote_file"])) {
                     require_once $cacheType["required_remote_file"];
                 }
                 $className = $cacheType["class_name"];
                 if (class_exists($className)) {
                     $cacheEngine = new $className();
                 }
             }
         }
     } else {
         switch ($cacheType) {
             case "memcache":
                 if (extension_loaded('memcache')) {
                     $cacheEngine = new CacheEngineMemcache();
                 }
                 break;
             case "eaccelerator":
                 if (extension_loaded('eaccelerator')) {
                     $cacheEngine = new CacheEngineEAccelerator();
                 }
                 break;
             case "apc":
                 if (extension_loaded('apc')) {
                     $cacheEngine = new CacheEngineApc();
                 }
                 break;
             case "xcache":
                 if (extension_loaded('xcache')) {
                     $cacheEngine = new CacheEngineXCache();
                 }
                 break;
             case "files":
                 $cacheEngine = new CacheEngineFiles();
                 break;
             case "none":
                 $cacheEngine = new CacheEngineNone();
                 break;
             default:
                 break;
         }
     }
     if ($cacheEngine == null) {
         $cacheEngine = new CacheEngineNone();
         trigger_error("Cache engine is not found", E_USER_WARNING);
     }
     if (!$cacheEngine->isAvailable()) {
         $cacheEngine = new CacheEngineNone();
         trigger_error("Cache engine is not available", E_USER_WARNING);
     }
     return $cacheEngine;
 }
コード例 #7
0
 /**
  * Read messages from user defined lang file
  */
 private static function loadCustomMessages($lang)
 {
     $customMess = array();
     $documentRoot = \Bitrix\Main\Application::getDocumentRoot();
     if (($fname = Main\Loader::getLocal("php_interface/user_lang/" . $lang . "/lang.php", $documentRoot)) !== false) {
         $mess = self::includeFile($fname);
         // typical call is Loc::loadMessages(__FILE__)
         // __FILE__ can differ from path used in the user file
         foreach ($mess as $key => $val) {
             $customMess[str_replace("\\", "/", realpath($documentRoot . $key))] = $val;
         }
     }
     return $customMess;
 }
コード例 #8
0
ファイル: application.php プロジェクト: ASDAFF/bitrix-5
 protected function runInitScripts()
 {
     if (!$this->dispatcher instanceof Dispatcher) {
         throw new \Exception();
     }
     if (($includePath = Loader::getLocal("init_d7.php")) !== false) {
         require_once $includePath;
     }
     if (($includePath = Loader::getPersonal("php_interface/init_d7.php")) !== false) {
         require_once $includePath;
     }
     // константы после init.php
     define("BX_CRONTAB_SUPPORT", defined("BX_CRONTAB"));
     if (!defined("BX_FILE_PERMISSIONS")) {
         define("BX_FILE_PERMISSIONS", 0644);
     }
     if (!defined("BX_DIR_PERMISSIONS")) {
         define("BX_DIR_PERMISSIONS", 0755);
     }
 }
コード例 #9
0
ファイル: option.php プロジェクト: ASDAFF/bxApiDocs
 private static function loadTriggers($moduleId)
 {
     static $triggersCache = array();
     if (isset($triggersCache[$moduleId])) {
         return;
     }
     if (preg_match("#[^a-zA-Z0-9._]#", $moduleId)) {
         throw new Main\ArgumentOutOfRangeException("moduleId");
     }
     $triggersCache[$moduleId] = true;
     $path = Main\Loader::getLocal("modules/" . $moduleId . "/option_triggers.php");
     if ($path === false) {
         return;
     }
     include $path;
 }
コード例 #10
0
ファイル: template.php プロジェクト: mrdeadmouse/u136006
 /**
  * @param $templateName
  * @param $html
  * @return bool|int
  */
 public static function update($templateName, $html)
 {
     $result = false;
     $fullPathOfFile = \Bitrix\Main\Loader::getLocal(static::LOCAL_DIR_TMPL . bx_basename($templateName) . '.php');
     if ($fullPathOfFile) {
         $result = File::putFileContents($fullPathOfFile, $html);
     }
     return $result;
 }
コード例 #11
0
ファイル: application.php プロジェクト: rasuldev/torino
 public static function createExceptionHandlerLog()
 {
     $exceptionHandling = Config\Configuration::getValue("exception_handling");
     if ($exceptionHandling === null || !is_array($exceptionHandling) || !isset($exceptionHandling["log"]) || !is_array($exceptionHandling["log"])) {
         return null;
     }
     $options = $exceptionHandling["log"];
     $log = null;
     if (isset($options["class_name"]) && !empty($options["class_name"])) {
         if (isset($options["extension"]) && !empty($options["extension"]) && !extension_loaded($options["extension"])) {
             return null;
         }
         if (isset($options["required_file"]) && !empty($options["required_file"]) && ($requiredFile = Loader::getLocal($options["required_file"])) !== false) {
             require_once $requiredFile;
         }
         $className = $options["class_name"];
         if (!class_exists($className)) {
             return null;
         }
         $log = new $className();
     } elseif (isset($options["settings"]) && is_array($options["settings"])) {
         $log = new Diag\FileExceptionHandlerLog();
     } else {
         return null;
     }
     $log->initialize(isset($options["settings"]) && is_array($options["settings"]) ? $options["settings"] : array());
     return $log;
 }
コード例 #12
0
ファイル: hostrestriction.php プロジェクト: spas-viktor/books
 protected function doActions()
 {
     switch ($this->action) {
         case self::ACTION_STOP:
             /** @noinspection PhpIncludeInspection */
             include Loader::getLocal('/admin/security_403.php');
             die;
             break;
         case self::ACTION_REDIRECT:
             localRedirect($this->actionOptions['host'], true);
             break;
         default:
             trigger_error('Unknown action', E_USER_WARNING);
     }
 }
コード例 #13
0
ファイル: cache.php プロジェクト: k-kalashnikov/geekcon_new
 /**
  * @return Cache
  */
 public static function createInstance()
 {
     $cacheEngine = null;
     // Events can't be used here because events use cache
     $cacheType = "files";
     $v = \Bitrix\Main\Config\Configuration::getValue("cache");
     if ($v != null && isset($v["type"]) && !empty($v["type"])) {
         $cacheType = $v["type"];
     }
     if (is_array($cacheType)) {
         if (isset($cacheType["class_name"])) {
             if (!isset($cacheType["extension"]) || extension_loaded($cacheType["extension"])) {
                 if (isset($cacheType["required_file"]) && ($requiredFile = \Bitrix\Main\Loader::getLocal($cacheType["required_file"]))) {
                     require_once $requiredFile;
                 }
                 $className = $cacheType["class_name"];
                 if (class_exists($className)) {
                     $cacheEngine = new $className();
                 }
             }
         }
     } else {
         switch ($cacheType) {
             case "memcache":
                 if (extension_loaded('memcache')) {
                     $cacheEngine = new CacheEngineMemcache();
                 }
                 break;
             case "eaccelerator":
                 if (extension_loaded('eaccelerator')) {
                     $cacheEngine = new CacheEngineEAccelerator();
                 }
                 break;
             case "apc":
                 if (extension_loaded('apc')) {
                     $cacheEngine = new CacheEngineApc();
                 }
                 break;
             case "files":
                 $cacheEngine = new CacheEngineFiles();
                 break;
             default:
                 break;
         }
     }
     if ($cacheEngine == null) {
         throw new \Bitrix\Main\Config\ConfigurationException("Cache engine is not found");
     }
     if (!$cacheEngine->isAvailable()) {
         throw new \Bitrix\Main\SystemException("Cache engine is not available");
     }
     /*
     $v = \Bitrix\Main\Config\Configuration::getValue("cache");
     if ($v != null && isset($v["type"]))
     {
     	$cacheType = $v["type"];
     	if (is_array($cacheType))
     	{
     		if (isset($cacheType["class_name"]))
     		{
     			if (!isset($cacheType["extension"]) || extension_loaded($cacheType["extension"]))
     			{
     				if (isset($cacheType["required_file"]) && ($requiredFile = \Bitrix\Main\Loader::getLocal($cacheType["required_file"])))
     					require_once($requiredFile);
     
     				$className = $cacheType["class_name"];
     				if (class_exists($className))
     					$cacheEngine = new $className();
     			}
     		}
     	}
     	else
     	{
     		switch ($cacheType)
     		{
     			case "memcache":
     				if (extension_loaded('memcache'))
     					$cacheEngine = new CacheEngineMemcache();
     				break;
     			case "eaccelerator":
     				if (extension_loaded('eaccelerator'))
     					$cacheEngine = new CacheEngineEAccelerator();
     				break;
     			case "apc":
     				if (extension_loaded('apc'))
     					$cacheEngine = new CacheEngineApc();
     				break;
     			default:
     				break;
     		}
     	}
     
     	if (($cacheEngine != null) && !$cacheEngine->isAvailable())
     		$cacheEngine = null;
     }
     
     if ($cacheEngine == null)
     	$cacheEngine = new CacheEngineFiles();
     */
     return new self($cacheEngine);
 }