Exemplo n.º 1
0
    /**
     * Provides functionality for auto-populating $title_for_layout
     * @access protected
     * @param string $fixedTitle
     * @param string $model
     * @param string $modelId
     */
    protected function _autoPageTitle($fixedTitle, $model, $modelId){

        $titleForLayout = null;

        switch($model){
            case 'Person':
                $this->loadModel($model);
                $person = $this->Person->find(
                    'first',
                    array(
                        'conditions'=>array(
                            'Person.id'=>$modelId
                        ),
                        'fields'=>array(
                            'Person.name',
                            'Person.username'
                        )
                    )
                );

                $titleForLayout = ProfileUtility::name($person['Person']) . $fixedTitle;
            break;

            default:

                $parsedModel = $this->_classifyModel($model);

                //If the model belongs to a plugin, checkout the plugin for the autoPageTitle() method
                if($parsedModel['isPlugin']){
                    App::import('Controller', $parsedModel['fullString']);
                    eval('$class = new ' . $parsedModel['pluginClassString'] . 'AppController();');
                    $title = $class->autoPageTitle($fixedTitle, $parsedModel['fullString'], $modelId);
                    $titleForLayout = $title;
                }

            break;
        }

        $this->set('title_for_layout', $titleForLayout);

    }
    /**
     *
     * @access public
     * @param string $model
     * @param string $modelId
     */
    public function index($model, $modelId){

        $classifiedModel = $this->_validAssociation($model, $modelId);

        //If we found the target blog, retrive an paginate its' posts
        $this->paginate = array(
            'conditions' => array(
                'SocialNetwork.model'=>$classifiedModel,
                'SocialNetwork.model_id'=>$modelId
            ),
            'fields'=>array(
                'SocialNetwork.id',
                'SocialNetwork.created',
                'SocialNetwork.modified',
                'SocialNetwork.network',
                'SocialNetwork.profile_url'
            ),
            'limit' => 10,
            'order'=>'SocialNetwork.network ASC'
        );

        $socialNetworks = $this->paginate('SocialNetwork');

        $person = $this->Person->find(
            'first',
            array(
                'conditions'=>array(
                    'Person.id'=>$modelId
                ),
                'fields'=>array(
                    'Person.username',
                    'Person.name'
                )
            )
        );

        $this->set('person', $person);

        $this->set('mine', ($person['Person']['id']==$this->Session->read('Auth.User.id')?true:false));

        $this->set('socialNetworks', $socialNetworks);
        $this->set('title_for_layout', ProfileUtility::name($person['Person']). "'s Social Networks");
    }