Sections

@return string $this->__cached
323572
private function msection()
	{
		if ($this->__engine == 'blade') {
			$pattern = '/\@section\((.*?)\)(.*?)\@endsection/s';
		}
		else {
			$pattern = '/\{\% section\((.*?)\) \%\}(.*?)\{\% endsection \%\}/s';
		}

		$this->__cached = preg_replace_callback($pattern, function($match) {
			$name = str_replace("'", "", $match[1]);
			$name = str_replace('"', '', $name);

			$code = $match[2];

			$section = array('name' => $name, 'code' => $code);
			array_push(static::$sections, $section);
		}, $this->__cached);

		$this->__cached = preg_replace_callback($this->usingDirective('yield', true, true), function($match) {
			$name = str_replace("'", "", $match[1]);
			$name = str_replace('"', '', $name);

			foreach (static::$sections as $value) {
				if ($value['name'] == $name) {
					return $value['code'];
				}
			}

			return '';
		}, $this->__cached);

		static::$sections = [];
	}
698283
public function getCacheDir(): string
    {
        if ($this->_cache_dir === null)
            $this->_cache_dir = realpath(__DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'cache');

        return $this->_cache_dir;
    }
352401
protected function getLastSection()
    {
        if (0 === count($this->sections)) {
            throw new RenderException('Cannot end a section. You must start a section first.');
        }

        $keys = array_keys($this->sections);
        $key = array_pop($keys);

        return $this->sections[$key];
    }
1152962
public function getMultilingualSection()
    {
        $result = null;
        $msID = $this->getMultilingualSectionID();
        if ($msID !== 0) {
            $s = Section::getByID($msID);
            if ($s) {
                $result = $s;
            }
        }

        return $result;
    }
614202
private function get_target_section() {

        if (!$this->fixeddataset) {
            $key = rand(1, self::$paramsections[$this->size]);
        } else {
            // Using section 1.
            $key = 1;
        }

        return $key;
    }
433599
protected function _get_index()
	{
		// get the section name and identifier
		$sections = explode('.', $this->identifier);
		if (count($sections) > 1)
		{
			$identifier = array_pop($sections);
			$sections = '.'.implode('.', $sections);
		}
		else
		{
			$identifier = $this->identifier;
			$sections = '';
		}

		// get the cache index and return it
		return array($identifier, $sections, xcache_get($this->config['cache_id'].$sections));
	}
953094
protected function getSection($section)
    {
        return isset($this->sections[$section])
            ? $this->sections[$section]
            : null;
    }
150251
public function getCacheDir()
	{
		if ($this->cacheDir === null) {
			$this->setCacheDir(dirname(__FILE__).DIRECTORY_SEPARATOR.'cache'.DIRECTORY_SEPARATOR);
		}

		return $this->cacheDir;
	}
870701
public function handleSection() {

        if ($ClassName = $this->owner->getRequest()->param('SECTIONNAME')) {
            $sections = $this->owner->data()->Sections();
            if ($section = $sections->filter(array('ClassName' => $ClassName))->first()) {
                if ($action = $this->owner->getRequest()->param('ACTION')) {
                    return $section->getController()->$action();
                }
            }
        }
        // return $section->getController();
    }
602696
private function getCached() {
        if (isset($_GET['noCache'])) return null;
        $cacheDir = DATA . 'select' . DIRECTORY_SEPARATOR;
        if (!is_dir($cacheDir)) mkdir($cacheDir, 0777, true);

        $cache = $cacheDir . base64_encode($this->getName()) . '.php';
        if (!is_readable($cache)) return null;
        $cached = include $cache;
        return $this->decode($cached[$this->encode($this->query . serialize($this->values))]);
    }
284609
public function getCaches()
    {
        if (!$this->caches) {
            foreach (Cache::getBins() as $name => $bin) {
                $this->caches[$name] = $bin;
            }
        }

        return $this->caches;
    }
112851
public function sectionStdList()
	{
		$table = array(
			'name' => 'templates',
			'key'=> 'filename',
			'sortMode' => 'filename',
			'sortDesc' => false,
			'columns' => array(
				array('name' => 'description', 'caption' => 'Описание'),
				#array('name' => 'filename', 'caption' => 'Имя файла'),
			),
			'controls' => array (
				'delete' => '',
				'edit' => '',
			),
			'tabs' => array(
				'width'=>'120px',
				'items'=>array(
					array('caption'=>ADM_ADD, 'name'=>'action', 'value'=>'add'),
				)
			),
		);
		$templates = Templates::getInstance();
		$list = $templates->enum('std');
		$items = array();
		foreach ($list as $key=>$value)
		{
			$items[] = array('filename' => $key, 'description' => $value);
		}
		/** @var TAdminUI $page */
		$page = Eresus_Kernel::app()->getPage();
		$result = $page->renderTable($table, $items);
		return $result;
	}
578997
public function getMultilingualSections()
    {
        if ($this->multilingualSections === null) {
            $site = $this->getSite();
            if ($site === null) {
                $this->multilingualSections = [];
            } else {
                $list = [];
                foreach (MultilingualSection::getList($site) as $section) {
                    $list[$section->getCollectionID()] = $section;
                }
                $this->multilingualSections = $list;
            }
        }

        return $this->multilingualSections;
    }
285662
private function find_sections() {
    $sections = array();
    $level_memory = array(0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
    $last_section = FALSE;

    // Match multiline comments
    preg_match_all('#\/\*((?:(?!\*\/).)*)\*\/#s', $this->code, $matches);

    foreach ($matches[1] as $match) {
      $section = array();
      $elements = $this->parse_match($match);

      if (isset($elements['title']) && isset($elements['level'])) {
        // Default htag to the lowest level htag
        $elements['htag'] = 'h6';

        // Find the depth of the level value
        $level_depth_arr = array_filter(explode('.', $elements['level']));
        $level_depth = count($level_depth_arr);
        if (isset($this->section_htags[$level_depth])) {
          $elements['htag'] = $this->section_htags[$level_depth];
        }

        // Reset the level memory to the depth of sub levels
        $level_memory = array_slice($level_memory, 0, $level_depth);
        $level_memory = array_pad($level_memory, 10, 0);

        // Set / unset and count up the levels
        foreach ($level_depth_arr as $key => $level) {
          if (is_numeric($level)) {
            $level_memory[$key] = $level;
          }
          else {
            // Only count up the last level
            if ($key > 0 && $key + 1 == $level_depth) {
              $level_memory[$key]++;
            }
            // Set the level depth
            $level_depth_arr[$key] = $level_memory[$key];
          }
        }
        $elements['level'] = implode('.', $level_depth_arr) . '.';

        $sections[$elements['level']] = $elements;
        $last_section = $elements['level'];
      }
      // If no title or level is provided scan for other styleguide elements
      // and append them to the previous section
      else if (!empty($elements)) {
        foreach ($elements as $element_label => $element_value) {
          $sections[$last_section][$element_label] = isset($sections[$last_section][$element_label])
            ? $sections[$last_section][$element_label] . "\n" . $element_value
            : $element_value;
        }
      }
    }

    ksort($sections);
    $this->build_section_tree($sections);
  }
1331283
protected function sectionRbac()
	{
		if (Yii::$app->authManager === null) return ['Status'=>'not configured'];
		$am = Yii::$app->authManager;

		//get roles and permission
		$roles = [];
		$perms = [];
		foreach ($am->roles as $role) $roles[] = $this->valueCode($role->name);
		foreach ($am->permissions as $perm) $perms[] = $this->valueCode($perm->name);

		//rbac cache config
		if ($am->cache === null) {
			$cacheConfig = Yii::$app->formatter->nullDisplay;
		} else {
			$cacheConfig = $this->valueModal('RBAC cache config', $this->valueVarDump($am->cache), 'Show');
		}

		return [
			'Auth manager'=>$this->valueCode($am->className()) . $this->valueModal($am->className(), $this->valueVarDump($am), 'Show config'),
			'Roles'=>implode(', ', $roles),
			'Permissions'=>implode(', ', $perms),
			'RBAC cache enabled'=>$this->valueBool($am->cache !== null),
			'RBAC cache config'=>$cacheConfig,
		];
	}
369393
public function loadAllSectionData()
    {
        $query = $this->dbHandler->createSelectQuery();
        $query->select(
            $this->dbHandler->quoteColumn('id'),
            $this->dbHandler->quoteColumn('identifier'),
            $this->dbHandler->quoteColumn('name')
        )->from(
            $this->dbHandler->quoteTable('ezsection')
        );

        $statement = $query->prepare();
        $statement->execute();

        return $statement->fetchAll(\PDO::FETCH_ASSOC);
    }
333163
public function getSectionHistoryQuery(Section $section)
    {
        $queryBuilder = $this->createQueryBuilder('contribution')
            ->orderBy('contribution.creationDate', 'DESC')
            ->andWhere('contribution.section = :section')
            ->setParameter('section', $section);

        return $queryBuilder->getQuery();
    }