Esempio n. 1
0
 /**
  * Builds 'input' elements of type checkbox
  *
  * @param string name
  * @param string $default
  * @param array $options
  * @return string
  */
 public function checkbox($name, $default = null, array $options = array())
 {
     $optionCount = count($options);
     $format = '<input type="checkbox" id="%1$s" name="%2$s[]" %3$s value="%4$s"> <label class="horizontal" for="%1$s">%5$s</label>';
     $output = '';
     $i = 1;
     foreach ($options as $key => $val) {
         $checked = in_array($val, (array) $default) ? 'checked="checked"' : '';
         $val == is_bool($val) ? zula_bool2str($val) : zula_htmlspecialchars($val);
         $output .= sprintf($format, uniqid('html_'), $this->makeNameAttr($name), $checked, $val, zula_htmlspecialchars($key));
         if ($i++ != $optionCount) {
             $output .= '<br>';
         }
     }
     return $output;
 }
Esempio n. 2
0
 /**
  * Gets the role data based on a role id, naem or if set
  * it will attempt to get it by the 'parent_id' value
  *
  * @param string|int $role
  * @param bool $byPid
  * @return array	Array containing all of the role details or
  *					false if no role was found
  */
 public function getRole($role, $byPid = false)
 {
     $byPid = (bool) $byPid;
     $roles = array();
     foreach ($this->getAllRoles() as $tmpRole) {
         if ($byPid == false && ($tmpRole['name'] == $role || $tmpRole['id'] == $role) || $byPid && $tmpRole['parent_id'] == $role) {
             if ($byPid === true) {
                 $roles[] = $tmpRole;
             } else {
                 return $tmpRole;
             }
         }
     }
     if ($byPid === false) {
         throw new Acl_RoleNoExist('role "' . $role . '" does not exist. By PID: ' . zula_bool2str($byPid));
     } else {
         if (count($roles) == 1) {
             return $roles[0];
         } else {
             return $roles;
         }
     }
 }
Esempio n. 3
0
 /**
  * Upgrades to 2.4.0-alpha1 (2.3.60)
  *
  * @return bool|string
  */
 protected function upgradeTo_240_alpha1()
 {
     switch ($this->version) {
         case '2.3.1':
         case '2.3.2':
         case '2.3.3':
         case '2.3.50':
             foreach (Layout::getAll() as $layout) {
                 $layoutObj = new Layout($layout['name']);
                 foreach ($layoutObj->getControllers() as $cntrlr) {
                     if (empty($cntrlr['config']['force_title'])) {
                         if (isset($cntrlr['config']['display_title'])) {
                             $displayTitle = (bool) $cntrlr['config']['display_title'];
                         } else {
                             $displayTitle = true;
                         }
                         $cntrlr['config']['displayTitle'] = zula_bool2str($displayTitle);
                     } else {
                         $cntrlr['config']['displayTitle'] = 'custom';
                         $cntrlr['config']['customTitle'] = $cntrlr['config']['force_title'];
                     }
                     unset($cntrlr['config']['display_title'], $cntrlr['config']['force_title']);
                     $layoutObj->editController($cntrlr['id'], $cntrlr);
                 }
                 $layoutObj->save();
             }
         case '2.3.51':
             $this->sqlFile('2.4.0-alpha1/2.3.52.sql');
         case '2.3.52':
             $this->sqlFile('2.4.0-alpha1/2.3.53.sql');
             foreach (Layout::getAll() as $layout) {
                 $layoutObj = new Layout($layout['name']);
                 foreach ($layoutObj->getControllers() as $cntrlr) {
                     if ($cntrlr['mod'] == 'poll') {
                         $cntrlr['con'] = 'view';
                         if (empty($cntrlr['config']['display_poll'])) {
                             $cntrlr['sec'] = 'index';
                         } else {
                             if ($cntrlr['config']['display_poll'] == 'random') {
                                 $cntrlr['sec'] = 'random';
                             } else {
                                 $cntrlr['sec'] = $cntrlr['config']['display_poll'];
                             }
                         }
                         unset($cntrlr['config']['display_poll']);
                         $layoutObj->editController($cntrlr['id'], $cntrlr);
                     }
                 }
                 $layoutObj->save();
             }
         case '2.3.53':
             $this->sqlFile('2.4.0-alpha1/2.3.54.sql');
         case '2.3.54':
             $this->sqlFile('2.4.0-alpha1/2.3.55.sql');
         case '2.3.55':
             $this->sqlFile('2.4.0-alpha1/2.3.56.sql');
         case '2.3.56':
         default:
             return '2.3.60';
     }
 }