예제 #1
0
파일: Toolbar.php 프로젝트: Joal01/fof
 /**
  * Render a toolbar element.
  *
  * @param   string  $type        The element type.
  * @param   mixed   $value       The element value.
  * @param   array   $attributes  The element attributes.
  *
  * @return  void
  *
  * @codeCoverageIgnore
  * @throws  \InvalidArgumentException
  */
 private function renderToolbarElement($type, $value = null, array $attributes = array())
 {
     switch ($type) {
         case 'title':
             $icon = isset($attributes['icon']) ? $attributes['icon'] : 'generic.png';
             JToolbarHelper::title($value, $icon);
             break;
         case 'divider':
             JToolbarHelper::divider();
             break;
         case 'custom':
             $task = isset($attributes['task']) ? $attributes['task'] : '';
             $icon = isset($attributes['icon']) ? $attributes['icon'] : '';
             $iconOver = isset($attributes['icon_over']) ? $attributes['icon_over'] : '';
             $alt = isset($attributes['alt']) ? $attributes['alt'] : '';
             $listSelect = isset($attributes['list_select']) ? String::toBool($attributes['list_select']) : true;
             JToolbarHelper::custom($task, $icon, $iconOver, $alt, $listSelect);
             break;
         case 'preview':
             $url = isset($attributes['url']) ? $attributes['url'] : '';
             $update_editors = isset($attributes['update_editors']) ? String::toBool($attributes['update_editors']) : false;
             JToolbarHelper::preview($url, $update_editors);
             break;
         case 'help':
             if (!isset($attributes['help'])) {
                 throw new MissingAttribute('help', 'help');
             }
             $ref = $attributes['help'];
             $com = isset($attributes['com']) ? String::toBool($attributes['com']) : false;
             $override = isset($attributes['override']) ? $attributes['override'] : null;
             $component = isset($attributes['component']) ? $attributes['component'] : null;
             JToolbarHelper::help($ref, $com, $override, $component);
             break;
         case 'back':
             $alt = isset($attributes['alt']) ? $attributes['alt'] : 'JTOOLBAR_BACK';
             $href = isset($attributes['href']) ? $attributes['href'] : 'javascript:history.back();';
             JToolbarHelper::back($alt, $href);
             break;
         case 'media_manager':
             $directory = isset($attributes['directory']) ? $attributes['directory'] : '';
             $alt = isset($attributes['alt']) ? $attributes['alt'] : 'JTOOLBAR_UPLOAD';
             JToolbarHelper::media_manager($directory, $alt);
             break;
         case 'assign':
             $task = isset($attributes['task']) ? $attributes['task'] : 'assign';
             $alt = isset($attributes['alt']) ? $attributes['alt'] : 'JTOOLBAR_ASSIGN';
             JToolbarHelper::assign($task, $alt);
             break;
         case 'new':
             $area = isset($attributes['acl']) ? $attributes['acl'] : 'create';
             if ($this->checkACL($area)) {
                 $task = isset($attributes['task']) ? $attributes['task'] : 'add';
                 $alt = isset($attributes['alt']) ? $attributes['alt'] : 'JTOOLBAR_NEW';
                 $check = isset($attributes['check']) ? String::toBool($attributes['check']) : false;
                 JToolbarHelper::addNew($task, $alt, $check);
             }
             break;
         case 'copy':
             $area = isset($attributes['acl']) ? $attributes['acl'] : 'create';
             if ($this->checkACL($area)) {
                 $task = isset($attributes['task']) ? $attributes['task'] : 'copy';
                 $alt = isset($attributes['alt']) ? $attributes['alt'] : 'JLIB_HTML_BATCH_COPY';
                 $icon = isset($attributes['icon']) ? $attributes['icon'] : 'copy.png';
                 $iconOver = isset($attributes['iconOver']) ? $attributes['iconOver'] : 'copy_f2.png';
                 JToolBarHelper::custom($task, $icon, $iconOver, $alt, false);
             }
             break;
         case 'publish':
             $area = isset($attributes['acl']) ? $attributes['acl'] : 'editstate';
             if ($this->checkACL($area)) {
                 $task = isset($attributes['task']) ? $attributes['task'] : 'publish';
                 $alt = isset($attributes['alt']) ? $attributes['alt'] : 'JTOOLBAR_PUBLISH';
                 $check = isset($attributes['check']) ? String::toBool($attributes['check']) : false;
                 JToolbarHelper::publish($task, $alt, $check);
             }
             break;
         case 'publishList':
             $area = isset($attributes['acl']) ? $attributes['acl'] : 'editstate';
             if ($this->checkACL($area)) {
                 $task = isset($attributes['task']) ? $attributes['task'] : 'publish';
                 $alt = isset($attributes['alt']) ? $attributes['alt'] : 'JTOOLBAR_PUBLISH';
                 JToolbarHelper::publishList($task, $alt);
             }
             break;
         case 'unpublish':
             $area = isset($attributes['acl']) ? $attributes['acl'] : 'editstate';
             if ($this->checkACL($area)) {
                 $task = isset($attributes['task']) ? $attributes['task'] : 'unpublish';
                 $alt = isset($attributes['alt']) ? $attributes['alt'] : 'JTOOLBAR_UNPUBLISH';
                 $check = isset($attributes['check']) ? String::toBool($attributes['check']) : false;
                 JToolbarHelper::unpublish($task, $alt, $check);
             }
             break;
         case 'unpublishList':
             $area = isset($attributes['acl']) ? $attributes['acl'] : 'editstate';
             if ($this->checkACL($area)) {
                 $task = isset($attributes['task']) ? $attributes['task'] : 'unpublish';
                 $alt = isset($attributes['alt']) ? $attributes['alt'] : 'JTOOLBAR_UNPUBLISH';
                 JToolbarHelper::unpublishList($task, $alt);
             }
             break;
         case 'archiveList':
             $area = isset($attributes['acl']) ? $attributes['acl'] : 'editstate';
             if ($this->checkACL($area)) {
                 $task = isset($attributes['task']) ? $attributes['task'] : 'archive';
                 $alt = isset($attributes['alt']) ? $attributes['alt'] : 'JTOOLBAR_ARCHIVE';
                 JToolbarHelper::archiveList($task, $alt);
             }
             break;
         case 'unarchiveList':
             $area = isset($attributes['acl']) ? $attributes['acl'] : 'editstate';
             if ($this->checkACL($area)) {
                 $task = isset($attributes['task']) ? $attributes['task'] : 'unarchive';
                 $alt = isset($attributes['alt']) ? $attributes['alt'] : 'JTOOLBAR_UNARCHIVE';
                 JToolbarHelper::unarchiveList($task, $alt);
             }
             break;
         case 'edit':
         case 'editList':
             $area = isset($attributes['acl']) ? $attributes['acl'] : 'edit';
             if ($this->checkACL($area)) {
                 $task = isset($attributes['task']) ? $attributes['task'] : 'edit';
                 $alt = isset($attributes['alt']) ? $attributes['alt'] : 'JTOOLBAR_EDIT';
                 JToolbarHelper::editList($task, $alt);
             }
             break;
         case 'editHtml':
             $task = isset($attributes['task']) ? $attributes['task'] : 'edit_source';
             $alt = isset($attributes['alt']) ? $attributes['alt'] : 'JTOOLBAR_EDIT_HTML';
             JToolbarHelper::editHtml($task, $alt);
             break;
         case 'editCss':
             $task = isset($attributes['task']) ? $attributes['task'] : 'edit_css';
             $alt = isset($attributes['alt']) ? $attributes['alt'] : 'JTOOLBAR_EDIT_CSS';
             JToolbarHelper::editCss($task, $alt);
             break;
         case 'deleteList':
         case 'delete':
             $area = isset($attributes['acl']) ? $attributes['acl'] : 'delete';
             if ($this->checkACL($area)) {
                 $msg = isset($attributes['msg']) ? $attributes['msg'] : '';
                 $task = isset($attributes['task']) ? $attributes['task'] : 'remove';
                 $alt = isset($attributes['alt']) ? $attributes['alt'] : 'JTOOLBAR_DELETE';
                 JToolbarHelper::deleteList($msg, $task, $alt);
             }
             break;
         case 'trash':
             $area = isset($attributes['acl']) ? $attributes['acl'] : 'editstate';
             if ($this->checkACL($area)) {
                 $task = isset($attributes['task']) ? $attributes['task'] : 'remove';
                 $alt = isset($attributes['alt']) ? $attributes['alt'] : 'JTOOLBAR_TRASH';
                 $check = isset($attributes['check']) ? String::toBool($attributes['check']) : true;
                 JToolbarHelper::trash($task, $alt, $check);
             }
             break;
         case 'apply':
             $task = isset($attributes['task']) ? $attributes['task'] : 'apply';
             $alt = isset($attributes['alt']) ? $attributes['alt'] : 'JTOOLBAR_APPLY';
             JToolbarHelper::apply($task, $alt);
             break;
         case 'save':
             $task = isset($attributes['task']) ? $attributes['task'] : 'save';
             $alt = isset($attributes['alt']) ? $attributes['alt'] : 'JTOOLBAR_SAVE';
             JToolbarHelper::save($task, $alt);
             break;
         case 'savenew':
             $task = isset($attributes['task']) ? $attributes['task'] : 'savenew';
             $alt = isset($attributes['alt']) ? $attributes['alt'] : 'JTOOLBAR_SAVE_AND_NEW';
             $icon = isset($attributes['icon']) ? $attributes['icon'] : 'save-new.png';
             $iconOver = isset($attributes['iconOver']) ? $attributes['iconOver'] : 'save-new_f2.png';
             JToolBarHelper::custom($task, $icon, $iconOver, $alt, false);
             break;
         case 'save2new':
             $task = isset($attributes['task']) ? $attributes['task'] : 'save2new';
             $alt = isset($attributes['alt']) ? $attributes['alt'] : 'JTOOLBAR_SAVE_AND_NEW';
             JToolbarHelper::save2new($task, $alt);
             break;
         case 'save2copy':
             $task = isset($attributes['task']) ? $attributes['task'] : 'save2copy';
             $alt = isset($attributes['alt']) ? $attributes['alt'] : 'JTOOLBAR_SAVE_AS_COPY';
             JToolbarHelper::save2copy($task, $alt);
             break;
         case 'checkin':
             $task = isset($attributes['task']) ? $attributes['task'] : 'checkin';
             $alt = isset($attributes['alt']) ? $attributes['alt'] : 'JTOOLBAR_CHECKIN';
             $check = isset($attributes['check']) ? String::toBool($attributes['check']) : true;
             JToolbarHelper::checkin($task, $alt, $check);
             break;
         case 'cancel':
             $task = isset($attributes['task']) ? $attributes['task'] : 'cancel';
             $alt = isset($attributes['alt']) ? $attributes['alt'] : 'JTOOLBAR_CANCEL';
             JToolbarHelper::cancel($task, $alt);
             break;
         case 'preferences':
             if (!isset($attributes['component'])) {
                 throw new MissingAttribute('component', 'preferences');
             }
             $component = $attributes['component'];
             $height = isset($attributes['height']) ? $attributes['height'] : '550';
             $width = isset($attributes['width']) ? $attributes['width'] : '875';
             $alt = isset($attributes['alt']) ? $attributes['alt'] : 'JToolbar_Options';
             $path = isset($attributes['path']) ? $attributes['path'] : '';
             JToolbarHelper::preferences($component, $height, $width, $alt, $path);
             break;
         default:
             throw new UnknownButtonType($type);
     }
 }
예제 #2
0
파일: StringTest.php 프로젝트: Joal01/fof
 /**
  * @covers       FOF30\Utils\String::toBool
  *
  * @dataProvider FOF30\Tests\Utils\StringProvider::getTestToBool
  *
  * @param string $value
  * @param bool   $expected
  * @param string $message
  */
 public function testToBool($value, $expected, $message)
 {
     $actual = String::toBool($value);
     $this->assertEquals($expected, $actual, $message);
 }
예제 #3
0
파일: Actions.php 프로젝트: Joal01/fof
 /**
  * Get the field configuration
  *
  * @return  array
  */
 protected function getConfig()
 {
     // If no custom options were defined let's figure out which ones of the
     // defaults we shall use...
     $config = array('published' => 1, 'unpublished' => 1, 'archived' => 0, 'trash' => 0, 'all' => 0);
     if (isset($this->element['show_published'])) {
         $config['published'] = String::toBool($this->element['show_published']);
     }
     if (isset($this->element['show_unpublished'])) {
         $config['unpublished'] = String::toBool($this->element['show_unpublished']);
     }
     if (isset($this->element['show_archived'])) {
         $config['archived'] = String::toBool($this->element['show_archived']);
     }
     if (isset($this->element['show_trash'])) {
         $config['trash'] = String::toBool($this->element['show_trash']);
     }
     if (isset($this->element['show_all'])) {
         $config['all'] = String::toBool($this->element['show_all']);
     }
     return $config;
 }