[createCategory 创建分类归档页面]
@DateTime 2018-10-08
@param    string     $value [description]
@return   [type]            [description]
424936
private function createCategory($value='')
    {
        $files = $this->files;

        // 构建文件分类
        $archives = [];
        foreach ($files as $key => $file) {
            // 单页文件不解析
            if (in_array($file['page_uuid'], $this->single_pages)) {
                unset($files[$key]);
                continue;
            }
            // 文件类型处理
            $len = count($file['type']);
            $str = '';
            for ($i=0; $i < $len; $i++) {
                $str.= '__' . $file['type'][$i];
                $str = trim($str, '__');
                $str_py = getpy($str);
                $archives[ $str_py ][] = $file;
            }
        }
        $archives['all'] = $files;

        // 构建分页 分类导航索引
        $limit = $this->page_limit;
        foreach ($archives as $k => $v) {
            // $k = getpy($k); // 中文转拼音
            $pages = ceil(count($v) / $limit);
            for ($i=1; $i <= $pages; $i++) {
                $repo = [];
                $path_key = '';
                if ($i == 1) {
                    $repo = array_slice($v, 0, $limit);
                    $path_key = $k;
                }else{
                    $start = $limit * ($i-1);
                    $repo = array_slice($v, $start, $limit);
                    $path_key = $k.'__'.'page'.'__'.$i;
                }
                $html = $this->renderCategory($repo, $pages, $i, $k);

                // 处理路由
                $path_key = array_filter(explode('__', $path_key), function($s){
                    return $s !== 'all';
                });
                $path = empty($path_key)? '' : implode('/', $path_key) . '/';
                $file_path = $this->public_dir .'/category/'. $path .'index.html';

                $this->fileSys->create($file_path, $html);
            }
        }
    }
1283951
protected function Add( $value )
	{
		switch ( $value->GetValueCode() )
	    {
	        case DayTimeDurationProxyFactory::Code:
	        	/**
	        	 * @var DayTimeDurationProxy $value
	        	 */
	        	$clone = new DayTimeDurationValue( $this->_value->Value );
	        	$clone->Add( /* DayTimeDurationValue */ $value->getValue() );
	        	return new DayTimeDurationProxy( $clone );

	        case DateTimeProxyFactory::Code:
	        	/**
	        	 * @var DateTimeProxy $value
	        	 */
	            return new DateTimeProxy( DateTimeValue::AddDayTimeDuration( $value->getValue(), $this->_value ) );

	        case DateProxyFactory::Code:
	        	/**
	        	 * @var DateProxy $value
	        	 */
	        	return new DateProxy( DateValue::AddDayTimeDuration( $value->getValue(), $this->_value ) );
	        	// return new DateProxy(DateValue::Add( /* DateValue */ $value->getValue(),  $this->_value) );

	        case TimeProxyFactory::Code:
	            return new TimeProxy( TimeValue::AddDayTimeDuration( /* TimeValue */ $value->getValue(),  $this->_value) );

	        default:
	            throw XPath2Exception::withErrorCodeAndParams( "XPTY0004", Resources::BinaryOperatorNotDefined,
					array(
						"op:add",
						SequenceType::WithTypeCodeAndCardinality(SequenceType::GetXmlTypeCodeFromObject( $this->_value ), XmlTypeCardinality::One ),
						SequenceType::WithTypeCodeAndCardinality(SequenceType::GetXmlTypeCodeFromObject( $value->getValue() ), XmlTypeCardinality::One )
					)
				);
	    }
	}
1135715
public function gt($value) {
        $this->rule = $value;
        $this->check_role = 'gt';
        $result = !is_null($this->value) && $this->value > $value;
        $this->checkResult($result);
        return $this;
    }
603405
protected function createItem($value){
		$count=$this->count();
		$title=$value;
		$content=NULL;
		if(\is_array($value)){
			$title=@$value[0];$content=@$value[1];
		}
		$menuItem=$this->content["menu"]->addItem($title);
		$menuItem->addToProperty("data-tab", $menuItem->getIdentifier());
		$menuItem->removeProperty("href");
		$result=$this->createSegment($count, $content, $menuItem->getIdentifier());
		$result->menuTab=$menuItem;
		return $result;
	}
108556
private function toDateTimeObject($value)
    {
        $datetime = null;
        
        switch (true) {
            case $value instanceof \DateTime:
                $datetime = new DateTime($value->format(\DateTime::RFC3339));
                break;
            case is_numeric($value):
                $datetime = new DateTime(sprintf('@%d', $value));
                break;
            case is_string($value):
                $datetime = new DateTime($value);
                break;
        }
        
        return $datetime;
    }
895563
private function objectToDocument($value)
    {
        $metaInformation = $this->metaInformationFactory->loadInformation($value);

        $field = [];
        $document = $this->createDocument($metaInformation);
        foreach ($document as $fieldName => $value) {
            $field[$fieldName] = $value;
        }

        return $field;
    }
428473
public function recursiveCreateDir($value = null)
    {
        return ($value === null) ? $this->recursiveDirectories : $this->recursiveDirectories = $value;
    }
754043
protected function createItem($value){
		if(\is_object($value)===false){
			$value=new HtmlSemDoubleElement("","div","content",$value);
		}
		return new HtmlShapeItem("side-".$this->identifier."-".$this->count(), $value);
	}
804464
protected function buildValue($value)
    {
        if ($value instanceof Model || is_null($value)) {
            return $value;
        }

        $model = $this->attribute->getAttribute('type');
        $instance = new $model();

        $instance->setAttribute('entity_id', $this->entity->getKey());
        $instance->setAttribute('entity_type', get_class($this->entity));
        $instance->setAttribute($this->attribute->getForeignKey(), $this->attribute->getKey());
        $instance->setAttribute('content', $value);

        return $instance;
    }
762491
public function fromDateTime($value)
    {
        $format = $this->getDateFormat();

        // If the value is already a DateTime instance, we will just skip the rest of
        // these checks since they will be a waste of time, and hinder performance
        // when checking the field. We will just return the DateTime right away.
        if ($value instanceof DateTime)
        {
            //
        }

        // If the value is totally numeric, we will assume it is a UNIX timestamp and
        // format the date as such. Once we have the date in DateTime form we will
        // format it according to the proper format for the database connection.
        elseif (is_numeric($value))
        {
            $value = Carbon::createFromTimestamp($value);
        }

        // If the value is in simple year, month, day format, we will format it using
        // that setup. This is for simple "date" fields which do not have hours on
        // the field. This conveniently picks up those dates and format correct.
        elseif (preg_match('/^(\d{4})-(\d{2})-(\d{2})$/', $value))
        {
            $value = Carbon::createFromFormat('Y-m-d', $value)->startOfDay();
        }

        // If this value is some other type of string, we'll create the DateTime with
        // the format used by the database connection. Once we get the instance we
        // can return back the finally formatted DateTime instances to the devs.
        elseif ( ! $value instanceof DateTime)
        {
            $value = Carbon::createFromFormat($format, $value);
        }

        return $value->format($format);
    }
193113
public static function create($value) {
        Str::assert($value, 'value');

        if($value === 'true')  return true;
        if($value === 'false') return false;
        if($value === 'null')  return null;

        $unquoted = preg_replace('/^(?|\"(.*)\"|\\\'(.*)\\\'|\`(.*)\`)$/', '$1', $value);
        if (!is_numeric($unquoted))                   return $unquoted;
        if ((string) intval($unquoted) === $unquoted) return intval($unquoted);

        return floatval($unquoted);
    }
782655
public static function create($value)
    {
        try {
            $expr = new RegexExpression($value);
            return $expr;
        } catch(\Exception $E) {
            $expr = new GlobExpression($value);
            return $expr;
        }
    }
449176
protected function Add( $value )
	{
		switch ( $value->GetValueCode() )
		{
			case YearMonthDurationProxyFactory::Code:
				/**
				 * @var YearMonthDurationProxy $value
				 */
				// return new YearMonthDurationProxy( new YearMonthDurationValue( $this->_value->HighPartValue + (/* YearMonthDurationValue */ $value->getValue() )->HighPartValue));
				$clone = new YearMonthDurationValue( $this->_value->Value );
				$clone->Add( /* YearMonthDurationValue */ $value->getValue() );
				return new YearMonthDurationProxy( $clone );

			case DateTimeProxyFactory::Code:
				/**
				 * @var DateTimeProxy $value
				 */
				return new DateTimeProxy( DateTimeValue::AddYearMonthDuration( $value->getValue(), $this->_value ) );
				// return new DateTimeProxy( DateTimeValue::Add( /* DateTimeValue */ $value->getValue(), $this->_value ) );

			case DateProxyFactory::Code:
				/**
				 * @var DateProxy $value
				 */
				return new DateProxy( DateValue::AddYearMonthDuration( $value->getValue(), $this->_value ) );
				// return new DateProxy( DateValue::Add( /*DateValue */ $value->getValue(), $this->_value ) );

			default:
				throw XPath2Exception::withErrorCodeAndParams( "XPTY0004", Resources::BinaryOperatorNotDefined,
					array(
						"op:add",
						SequenceType::WithTypeCodeAndCardinality(SequenceType::GetXmlTypeCodeFromObject( $this->_value ), XmlTypeCardinality::One ),
						SequenceType::WithTypeCodeAndCardinality(SequenceType::GetXmlTypeCodeFromObject( $value->getValue() ), XmlTypeCardinality::One )
					)
				);
		}
	}
945929
private function createDateTime($value)
    {
        if ($value instanceof DateTime) {
            return $value;
        }
        if ($value instanceof \MongoDate) {
            $dateStr = date('Y-m-d H:i:s.'.$value->usec, $value->sec);
            return new DateTime($dateStr);
        }
        if (is_numeric($value)) {
            // Supports microseconds
            $value = (Float) $value;
            $usec = round(($value - (Integer) $value) * 1000000, 0);
            $dateStr = date('Y-m-d H:i:s.'.$usec, (Integer) $value);
            return new DateTime($dateStr);
        }
        return new DateTime((String) $value);
    }
1109770
protected function createItem($value) {
		$count=\sizeof($this->content);
		$value=new HtmlIcon("icon-".$count, $value);
		$itemO=new HtmlLink("item-".$count,"",$value);
		return $itemO->setClass("item");
	}
1167910
protected function createTag(string $value): Tag
    {
        /** @var TagModel $model */
        $model = $this->framework->createInstance(TagModel::class);
        $model->tstamp = \time();
        $model->name = $value;
        $model->source = $this->alias;
        $model->save();

        return ModelCollection::createTagFromModel($model);
    }
629261
public function filter($value)
    {
	    if (is_string($value))
	        return new DateTime('@'.strtotime($value));
	    if ($value instanceof DateTime)
		    return $value;
	    if (is_int($value))
		    return new DateTime('@'.$value);
	    return null;
    }