Yii::t('blog', 'Draft'), Post::STATUS_ACTIVE => Yii::t('blog', 'Active'), ]; } public static function statusName($status): string { return ArrayHelper::getValue(self::statusList(), $status); } public static function statusLabel($status): string { switch ($status) { case Post::STATUS_DRAFT: $class = 'label label-default'; break; case Post::STATUS_ACTIVE: $class = 'label label-success'; break; default: $class = 'label label-default'; } return Html::tag('span', ArrayHelper::getValue(self::statusList(), $status), [ 'class' => $class, ]); } public static function parseYoutubeUrl($url) { $urls = parse_url($url); //url is http://youtu.be/xxxx if($urls['host'] == 'youtu.be'){ $id = ltrim($urls['path'],'/'); } //url is http://www.youtube.com/embed/xxxx else if(strpos($urls['path'],'embed') == 1){ $id = end(explode('/',$urls['path'])); } //url is xxxx only else if(strpos($url,'/')===false){ $id = $url; } //http://www.youtube.com/watch?feature=player_embedded&v=m-t4pcO99gI //url is http://www.youtube.com/watch?v=xxxx else{ parse_str($urls['query']); /* @var $v */ $id = $v; if(!empty($feature)){ $id = end(explode('v=',$urls['query'])); } } return $id; } }