2013-03-21 4 views
0

지난 주이 프레임 워크로 개발하기 시작한 Joomla는 아마추어입니다. 지금 당장 공식 Wiki에있는 공식 Joomla 튜토리얼을 살펴 보겠습니다. 그러나 나는 잘못된 것을하고 있거나 잊어 버린 것이 있거나 튜토리얼에 언급되어 있지 않다.Joomla! 2.5 ACL에 옵션이 표시되지 않습니다.

내가 수행 한 마지막 단계는 액세스 제어 목록을 개발하는 것이 었습니다. 그러나 유지 보수 단추가 표시되지 않습니다.

는 여기에 지금까지 그것을 가지고 어떻게 코드입니다 :

관리/뷰/helloworld를/view.html.php

class HelloWorldViewHelloWorld extends JView { 
protected $form; 
protected $item; 
protected $script; 
protected $canDo; 

public function display($tpl = NULL){ 
    $this->form = $this->get('Form'); 
    $this->item = $this->get('Item'); 
    $this->script = $this->get('Script'); 
    $this->canDo = HelloWorldHelper::getActions($this->item->id); 
    if(count($errors = $this->get('Errors'))){ 
     JError::raiseError(500, implode('<br />', $errors)); 
     return false; 
    } 
    $this->addToolBar(); 
    parent::display($tpl); 
    $this->setDocument(); 
} 

protected function addToolBar(){ 
    $input = JFactory::getApplication()->input; 
    $input->set('hidemainmenu', true); 
    $isNew = ($this->item->id == 0); 
    JToolBarHelper::title($isNew ? JText::_('COM_HELLOWORLD_MANAGER_HELLOWORLD_NEW') : JText::_('COM_HELLOWORLD_MANAGER_HELLOWORLD_EDIT'), 'helloworld'); 
    if($isNew){ 
     if($this->canDo->get('core.create')){ 
      JToolBarHelper::apply('helloworld.apply', 'JTOOLBAR_APPLY'); 
      JToolBarHelper::save('helloworld.save', 'JTOOLBAR_SAVE'); 
      JToolBarHelper::custom('helloworld.save2copy', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AS_COPY', false); 
     } 
     JToolBarHelper::cancel('helloworld.cancel', 'JTOOLBAR_CANCEL'); 
    } else { 
     if($this->canDo->get('core.edit')){ 
      JToolBarHelper::apply('helloworld.apply', 'JTOOLBAR_APPLY'); 
      JToolBarHelper::save('helloworld.save', 'JTOOLBAR_SAVE'); 
      if($this->canDo->get('core.create')){ 
       JToolBarHelper::custom('helloworld.save2copy', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AND_NEW', false); 
      } 
     } 
     if($this->canDo->get('core.create')){ 
      JToolBarHelper::custom('helloworld.save2copy', 'save-new.png', 'save-new_f2.png', 'JTOOLBAR_SAVE_AS_COPY', false); 
     } 
     JToolBarHelper::cancel('helloworld.cancel', 'JTOOLBAR_CLOSE'); 
    } 
} 
protected function setDocument(){ 
    $isNew = ($this->item->id < 1); 
    $document = JFactory::getDocument(); 
    $document->setTitle($isNew ? JText::_('COM_HELLOWORLD_HELLOWORLD_CREATING') : JText::_('COM_HELLOWORLD_HELLOWORLD_EDITING')); 
    $document->addScript(JURI::root() . $this->script); 
    $document->addScript(JURI::root() . "/administrator/components/com_helloworld/views/helloworld/submitbutton.js"); 
    JText::script('COM_HELLOWORLD_HELLOWORLD_ERROR_UNACCEPTABLE'); 
} 
} 

관리/도우미/helloworld.php (부품)

abstract class HelloWorldHelper { 
[...] 
public static function getActions($messageId = 0){ 
    jimport('joomla.access.access'); 
    $user = JFactory::getUser(); 
    $result = new JObject; 
    if(empty($messageId)){ 
     $assetName = 'com_helloworld'; 
    } else { 
     $assetName = 'com_helloworld.message.' . (int) $messageId; 
    } 
    $actions = JAccess::getActions('com_helloworld', 'component'); 
    foreach($actions as $action){ 
     $result->set($action->name, $user->authorise($action->name, $assetName)); 
    } 
    return $result; 
} 
} 

var_dump($this->canDo)을 사용하여 디버깅을 시도했지만 응답이 없습니다. 나는 무엇을 놓칠 수 있나?


업데이트 :var_dump이보기에 $this->canDo을 보내고/HelloWorlds가/view.html.php 반환이 :

object(JObject)#43 (1) { ["_errors":protected]=> array(0) { } } 

여기 호출이 상기의 관점에서 기능/HelloWorlds/view.html.php : 당신이 this tutorial에 따라 알고있는 것처럼

function display($tpl = NULL){ 
    $this->items = $this->get('Items'); 
    $this->pagination = $this->get('Pagination'); 
    $this->canDo = HelloWorldHelper::getActions(); 
    if(count($errors = $this->get('Errors'))){ 
     JError::raiseError(500, implode('<br />', $errors)); 
     return false; 
    } 
    $this->addToolBar($this->pagination->total); 
    parent::display($tpl); 
    $this->setDocument(); 
} 

답변

0

. 한 번 더 코드와 파일을 다시 확인해 주시겠습니까? 왜냐하면 나는 100 %이 튜토리얼의 단계가 정확하다는 것을 확신하기 때문에 (나 자신이 여러 번 그렇게했다). 뭔가 빠졌거나 어딘가에 약간의 실수를 저질렀습니다.

+0

다음은 내가 따라야 할 정확한 튜토리얼입니다. 여러 번 코드를 두 번 확인했는데 어떤 이유에서든 제대로 이해할 수없는 것 같습니다. 버튼이 표시되도록 액세스 옵션에 대한 등록/조정이 있습니까? – TheGEffect

+0

수퍼 유저로 로그인하면 조정할 필요가 없습니다. 내가 볼 수있는 한보기가 정확합니다. 당신은'var_dump ($ this-> canDo)'가 아무것도주지 않는다고 썼다. 여기에 내가 버린 것은 :'object (JObject) # 164 (6) {[ "_errors": protected] => array (0) {} [ "core.admin"] => bool (true) [ "core. bool (true) [ "core.edit"] => bool (true)} bool (true) [ "core.create"] => . 헬퍼 파일에 문제가있을 수 있습니까? –

+0

도우미 코드로 메인 포스트를 편집했습니다. – TheGEffect

2

문제가 해결되었고, 나 스스로 부끄럽다는 것을 깨닫지 못했습니다. 단지 admin/access.xmlhelloworld.xml에 설명되어 있지 않습니다.

관련 문제