Find visible pattern by their pid (elements id)

@param integer $intPid     The content element id
@param array   $arrOptions An optional options array

@return \Model\Collection|\PatternModel|null A collection of models or null if there are no pattern
325494
public static function findVisibleByPid($intPid, array $arrOptions=array())
	{
		$t = static::$strTable;
		
		$arrColumns = array("$t.pid=? AND ($t.ptable='tl_elements' OR $t.ptable='') AND $t.invisible=''");
		
		if (!isset($arrOptions['order']))
		{
			$arrOptions['order'] = "$t.sorting";
		}

		return static::findBy($arrColumns, $intPid, $arrOptions);
	}
1154456
public void fill(IntBiPredicate isInside, IntBinaryOperator pattern)
    {
        fill(0, 0, width, height, isInside, pattern);
    }
595012
public static function countByPidAndType($intPid, $strType, array $arrOptions=array())
	{
		$t = static::$strTable;
		
		$arrColumns = array("$t.pid=? AND ($t.ptable='tl_elements' OR $t.ptable='') AND $t.type=?");
		
		return static::countBy($arrColumns, array($intPid, $strType), $arrOptions);
	}
318183
public static function html2Text($strHtml, $arrOptions = [])
    {
        $strHtml = str_replace("\n", '', $strHtml); // remove white spaces from html
        $strHtml = str_replace('</p>', '<br /></p>', $strHtml); // interpret paragrah as block element
        $strHtml = str_replace('</div>', '<br /></div>', $strHtml); // interpret div as block element
        return Html2Text::convert($strHtml, $arrOptions);
    }
777057
public function findByUid($uid, array $querySettings = ['respectSysLanguage' => false]) {
    if ($uid && $uid > 0) {
      // Create a new query.
      $query = $this->createquery();

      // Apply the passed query settings.
      $query = $this->applyQuerySettings($query, $querySettings);

      // Set the query constraints.
      $query->matching($query->equals('uid', $uid));

      // Execute the query and get the first object.
      $result = $query->execute()->getFirst();

      return $result;
    }

    return null;
  }
1252242
public function trace(/*?\Throwable*/ $throwableOrNull, $options = []) : Inspector
    {
        // Init.----------------------------------------------------------------
        $this->loadDependencies();

        // Business.------------------------------------------------------------

        $options['kind'] = 'trace';
        $class_inspector = static::CLASS_INSPECTOR;
        /** @var Inspector */
        return new $class_inspector(
            $this,
            $throwableOrNull,
            $options
        );
    }
614111
public function relate(array $options) {
        $this->_checkAcl('relate');

        extract($options);
        if (!isset($primaryKey) || !isset($model) || !isset($foreignKeys)) {
            throw new Garp_Content_Exception(
                'Not enough options. "primaryKey", "model" and "foreignKeys" are required.'
            );
        }
        $model         = Garp_Content_Api::modelAliasToClass($model);
        $primaryKey    = (array)$primaryKey;
        $foreignKeys   = (array)$foreignKeys;
        $rule          = isset($rule) ? $rule : null;
        $rule2         = isset($rule2) ? $rule2 : null;
        $bindingModel  = isset($bindingModel) ? 'Model_' . $bindingModel : null;
        $bidirectional = isset($bidirectional) ? $bidirectional : null;

        if (isset($bindingModel)) {
            $bindingModel = new $bindingModel();
            $bindingModel->setCmsContext(true);
        }

        if (array_key_exists('unrelateExisting', $options) && $options['unrelateExisting']) {
            Garp_Content_Relation_Manager::unrelate(
                array(
                    'modelA'        => $this->_model,
                    'modelB'        => $model,
                    'keyA'          => $primaryKey,
                    'rule'          => $rule,
                    'ruleB'         => $rule2,
                    'bindingModel'  => $bindingModel,
                    'bidirectional' => $bidirectional,
                )
            );
        }

        $success = $attempts = 0;

        foreach ($foreignKeys as $i => $relationData) {
            if (!array_key_exists('key', $relationData)) {
                throw new Garp_Content_Exception('Foreign key is a required key.');
            }

            $foreignKey  = $relationData['key'];
            $extraFields = array_key_exists('relationMetadata', $relationData)
                ? $relationData['relationMetadata']
                : array();

            if (Garp_Content_Relation_Manager::relate(
                array(
                'modelA'        => $this->_model,
                'modelB'        => $model,
                'keyA'          => $primaryKey,
                'keyB'          => $foreignKey,
                'extraFields'   => $extraFields,
                'rule'          => $rule,
                'ruleB'         => $rule2,
                'bindingModel'  => $bindingModel,
                'bidirectional' => $bidirectional,
                )
            )
            ) {
                $success++;
            }
            $attempts++;
        }
        return $success == $attempts;
    }
1214178
protected function prepareWidgetOptions($arrIds, $objAttribute)
    {
        $arrOptions = $objAttribute->getFilterOptions(
            ($this->get('onlypossible') ? $arrIds : null),
            (bool) $this->get('onlyused')
        );

        // Remove empty values from list.
        foreach ($arrOptions as $mixKeyOption => $mixOption) {
            // Remove html/php tags.
            $mixOption = \strip_tags($mixOption);
            $mixOption = \trim($mixOption);

            if ($mixOption === '' || $mixOption === null) {
                unset($arrOptions[$mixKeyOption]);
            }
        }

        return $arrOptions;
    }
680718
public function findFirstPublishedElementByPid($intPid, array $arrOptions=array())
	{
		$t = static::$strTable;

		$arrColumns = array("$t.pid=? AND $t.invisible='' AND $t.type='element'");
	
		if (!isset($arrOptions['order']))
		{
			$arrOptions['order'] = "$t.sorting";
		}
	
		return static::findOneBy($arrColumns, $intPid, $arrOptions);
	}
1356516
public static function getDataForPattern($id, $resolveAlias = false)
    {
        $data = array();

        $id = Primer::cleanId($id);

        // Load the Patterns default data
        $defaultData = @file_get_contents(Primer::$PATTERN_PATH . '/' . $id . '/data.json');

        if ($defaultData) {
            $json = json_decode($defaultData);

            if ($json) {
                // Merge in the data
                $data += (array)$json;
            }
        }

        if ($resolveAlias) {
            // Parent data - e.g. elements/button is the parent of elements/button~primary
            $parentData = array();

            // Load parent data if this is inherit
            if (preg_match('/(.*?)~.*?/', $id, $matches)) {
                $parentData = FileSystem::getDataForPattern($matches[1]);
            }

            // Merge the parent and pattern data together, giving preference to the pattern data
            $data = array_replace_recursive((array)$parentData, (array)$data);
        }

        // Create the data structure
        $viewData = new ViewData($data);

        // Give the system a chance to mutate the data
        ViewData::fire($id, $viewData);

        // Return the data structure
        return $viewData;
    }
109113
public function findPalette(ModelInterface $model = null, PropertyValueBag $input = null)
    {
        $matches = [];

        // Determinate the matching count for each palette.
        foreach ($this->palettes as $palette) {
            $condition = $palette->getCondition();

            if ($condition) {
                $count = $condition->getMatchCount($model, $input);

                if (false !== $count) {
                    $matches[$count][] = $palette;
                }
            }
        }

        // Sort by count.
        \ksort($matches);

        // Get palettes with highest matching count.
        $palettes = \array_pop($matches);

        if (1 !== \count($palettes)) {
            throw new DcGeneralInvalidArgumentException(\sprintf('%d matching palettes found.', \count($palettes)));
        }

        return $palettes[0];
    }
883596
public function actionAll( $pid ) {

		$modelClass = $this->modelService->getModelClass();

		$parent = $this->parentService->getById( $pid );

		if( isset( $parent ) ) {

			$dataProvider = $this->modelService->getPageByTypeUserId( CoreGlobal::TYPE_DEFAULT, $parent->id );

			return $this->render( 'all', [
				'dataProvider' => $dataProvider,
				'parent' => $parent,
				'visibilityMap' => $modelClass::$visibilityMap,
				'statusMap' => $modelClass::$statusMap
			]);
		}

		// Model not found
		throw new NotFoundHttpException( Yii::$app->coreMessage->getMessage( CoreGlobal::ERROR_NOT_FOUND ) );
	}
1205957
public static function findPublishedByPid($intPid, array $arrOptions = array())
    {
        $t = static::$strTable;
        $arrColumns = array("$t.pid=?");
        $arrValues = array($intPid);

        if (!C4GUtils::checkBackendUserLogin()) {
            $time = time();
            $arrColumns[] = "$t.published=1";
        }

        if (!isset($arrOptions['order'])) {
            $arrOptions['order'] = "$t.sorting";
        }

        return static::findBy($arrColumns, $arrValues, $arrOptions);
    }
88947
public function getPid():?int
    {
        if(isset($this->swooleProcess->pid)){
            return $this->swooleProcess->pid;
        }else{
            return null;
        }
    }
562766
final public function find(int $id = null)
    {
        $result = $this->first($id);

        if (!$result) {
            return null;
        }

        $this->setProperties($result);

        return $this;
    }
1347785
public function actionReport($cid = null, $fid = null, $tid = null, $pid = null)
    {
        $post = Post::verify($cid, $fid, $tid, $pid);
        if (empty($post)) {
            $this->error(Yii::t('podium/flash', 'Sorry! We can not find the post you are looking for.'));
            return $this->redirect(['forum/index']);
        }

        if (User::can(Rbac::PERM_UPDATE_POST, ['item' => $post])) {
            $this->info(Yii::t('podium/flash', "You don't have to report this post since you are allowed to modify it."));
            return $this->redirect([
                'forum/edit',
                'cid' => $post->forum->category->id,
                'fid' => $post->forum->id,
                'tid' => $post->thread->id,
                'pid' => $post->id
            ]);
        }

        if ($post->author_id == User::loggedId()) {
            $this->info(Yii::t('podium/flash', 'You can not report your own post. Please contact the administrator or moderators if you have got any concerns regarding your post.'));
            return $this->redirect([
                'forum/thread',
                'cid' => $post->forum->category->id,
                'fid' => $post->forum->id,
                'id' => $post->thread->id,
                'slug' => $post->thread->slug
            ]);
        }

        $model = new Message();
        $model->scenario = 'report';
        if ($model->load(Yii::$app->request->post()) && $model->validate()) {
            if ($model->podiumReport($post)) {
                $this->success(Yii::t('podium/flash', 'Thank you for your report. The moderation team will take a look at this post.'));
                return $this->redirect([
                    'forum/thread',
                    'cid' => $post->forum->category->id,
                    'fid' => $post->forum->id,
                    'id' => $post->thread->id,
                    'slug' => $post->thread->slug
                ]);
            }
            $this->error(Yii::t('podium/flash', 'Sorry! There was an error while notifying the moderation team. Contact administrator about this problem.'));
        }
        return $this->render('report', ['model' => $model, 'post' => $post]);
    }
987182
public static function findByPid($varPid, array $arrOptions=array())
	{
		$t = static::$strTable;
		
		$arrOptions = array_merge
		(		
			array
			(
				'column'	=>	array("$t.pid=?","$t.parent=0"),
				'value'		=>	array($varPid)
			),
			$arrOptions
		);

		return static::find($arrOptions);
	}