Yii Framework Forum: 灰显整个网站--------For雅安四川地震 - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

灰显整个网站--------For雅安四川地震 大规模不幸事件中致哀死者的一种方法---灰显整个网站 Rate Topic: -----

#1 User is offline   yiqing95 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 585
  • Joined: 27-December 10
  • Location:china

Posted 21 April 2013 - 01:44 PM

不幸又发生在四川了 没办法 只能祈求这种天灾人祸少发生些!又有一些人为了出名捐钱捐物了 如果是出自真心最好 不然就老实呆着 不要帮倒忙 比如开着跑车到那里去送水 以为旅游呢 反而阻碍交通 :angry:

yii开发的网站 如果用了布局继承 那么要灰显整个网站 只需要把主布局 改动下就好:
 html {
            filter: progid:DXImageTransform.Microsoft.BasicImage(grayscale=1);
            -webkit-filter: grayscale(100%);
            filter: url("data:image/svg+xml;utf8,<svg xmlns=\'http://www.w3.org/2000/svg\'><filter id=\'grayscale\'><feColorMatrix type=\'matrix\' values=\'0.3333 0.3333 0.3333 0 0 0.3333 0.3333 0.3333 0 0 0.3333 0.3333 0.3333 0 0 0 0 0 1 0\'/></filter></svg>#grayscale"); /* Firefox 10+, Firefox on Android */
        }

        img {
            _filter: progid:DXImageTransform.Microsoft.BasicImage(grayscale=0);
            -webkit-filter: grayscale(100%);
            filter: url("data:image/svg+xml;utf8,<svg xmlns=\'http://www.w3.org/2000/svg\'><filter id=\'grayscale\'><feColorMatrix type=\'matrix\' values=\'0.3333 0.3333 0.3333 0 0 0.3333 0.3333 0.3333 0 0 0.3333 0.3333 0.3333 0 0 0 0 0 1 0\'/></filter></svg>#grayscale"); /* Firefox 10+, Firefox on Android */
        }

上面这段代码拷贝到<head>.. </head> 之间 ;

另一种方法, 扩展一个CWebApplication:
class MyWebApplication extends CWebApplication
{

    /**
     * The post-filter for controller actions.
     * This method is invoked after the currently requested controller action and all its filters
     * are executed. You may override this method with logic that needs to be done
     * after all controller actions.
     * @param CController $controller the controller
     * @param CAction $action the action
     */
    public function afterControllerAction($controller, $action)
    {

    }

    /**
     * The pre-filter for controller actions.
     * This method is invoked before the currently requested controller action and all its filters
     * are executed. You may override this method with logic that needs to be done
     * before all controller actions.
     * @param CController $controller the controller
     * @param CAction $action the action
     * @return boolean whether the action should be executed.
     */
    public function beforeControllerAction($controller,$action)
    {
        $forYaAn = <<<GRAY_PAGE
 html {
            filter: progid:DXImageTransform.Microsoft.BasicImage(grayscale=1);
            -webkit-filter: grayscale(100%);
            filter: url("data:image/svg+xml;utf8,<svg xmlns=\'http://www.w3.org/2000/svg\'><filter id=\'grayscale\'><feColorMatrix type=\'matrix\' values=\'0.3333 0.3333 0.3333 0 0 0.3333 0.3333 0.3333 0 0 0.3333 0.3333 0.3333 0 0 0 0 0 1 0\'/></filter></svg>#grayscale"); /* Firefox 10+, Firefox on Android */
        }

        img {
            _filter: progid:DXImageTransform.Microsoft.BasicImage(grayscale=0);
            -webkit-filter: grayscale(100%);
            filter: url("data:image/svg+xml;utf8,<svg xmlns=\'http://www.w3.org/2000/svg\'><filter id=\'grayscale\'><feColorMatrix type=\'matrix\' values=\'0.3333 0.3333 0.3333 0 0 0.3333 0.3333 0.3333 0 0 0.3333 0.3333 0.3333 0 0 0 0 0 1 0\'/></filter></svg>#grayscale"); /* Firefox 10+, Firefox on Android */
        }
GRAY_PAGE;

        $this->clientScript->registerCss('for_yaAn',$forYaAn);

        if (!empty($this->user->loginRequiredAjaxResponse)){
            Yii::app()->clientScript->registerScript('ajaxLoginRequired', '
            //jQuery("body").ajaxComplete(
            jQuery("body").ajaxSuccess(
                function(event, request, options) {
                    if (request.responseText == "'.Yii::app()->components['user']->loginRequiredAjaxResponse.'") {
                        window.location.href = "'. $this->createUrl(UserHelper::getLoginUrl()) .'";
                    }
                }
            );
        ');
        }
       return parent::beforeControllerAction($controller,$action);
    }



   
}




然后再主入口文件index.php 修改创建应用程序的地方:
$app = Yii::createApplication('MyWebApplication', $config);


css 样式来自:to gray, for Ya'An, Si Chuan earthquake
0

#2 User is offline   mars3228 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 6
  • Joined: 19-April 13

Posted 22 April 2013 - 06:02 AM

感謝分享,長知識,祈求國泰民安
0

#3 User is offline   yiqing95 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 585
  • Joined: 27-December 10
  • Location:china

Posted 22 April 2013 - 10:05 AM

 window.location.href = "'. $this->createUrl(UserHelper::getLoginUrl()) .'";

其中的登陆url换为正确的url:

Yii::app()->user->loginUrl ;
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users