pathToString() публичный статический Метод

public static pathToString ( &$path )
Пример #1
0
 public function insertBranch($pathstring, $type)
 {
     $path = Whups_Query::stringToPath($pathstring);
     $qobj =& $this->query;
     $newbranch = array('type' => $type, 'children' => array());
     $count = count($path);
     for ($i = 0; $i < $count; $i++) {
         $qobj =& $qobj['children'][$path[$i]];
     }
     if (!isset($qobj['children']) || !is_array($qobj['children'])) {
         $qobj['children'] = array();
     }
     $qobj['children'][] = $newbranch;
     $path[] = count($qobj['children']) - 1;
     return Whups_Query::pathToString($path);
 }
Пример #2
0
 /**
  * @TODO: This must be public, but method name has underscore.
  */
 public function _renderRow(&$more, &$path, $type, $criterion, $cvalue, $operator, $value)
 {
     global $whups_driver, $registry;
     $this->currentRow++;
     $pathstring = Whups_Query::pathToString($path);
     $depth = count($path);
     $class = "item" . $this->currentRow % 2;
     switch ($type) {
         case Whups_Query::TYPE_AND:
             $text = _("And");
             break;
         case Whups_Query::TYPE_OR:
             $text = _("Or");
             break;
         case Whups_Query::TYPE_NOT:
             $text = _("Not");
             break;
         case Whups_Query::TYPE_CRITERION:
             switch ($criterion) {
                 case Whups_Query::CRITERION_ID:
                     $text = _("Id");
                     break;
                 case Whups_Query::CRITERION_OWNERS:
                     $text = _("Owners");
                     break;
                 case Whups_Query::CRITERION_GROUPS:
                     $text = _("Groups");
                     break;
                 case Whups_Query::CRITERION_REQUESTER:
                     $text = _("Requester");
                     break;
                 case Whups_Query::CRITERION_ADDED_COMMENT:
                     $text = _("Commentor");
                     break;
                 case Whups_Query::CRITERION_COMMENT:
                     $text = _("Comment");
                     break;
                 case Whups_Query::CRITERION_SUMMARY:
                     $text = _("Summary");
                     break;
                 case Whups_Query::CRITERION_QUEUE:
                     $queue = $whups_driver->getQueue($value);
                     if ($queue) {
                         $text = _("Queue");
                         $value = $queue['name'];
                     }
                     break;
                 case Whups_Query::CRITERION_VERSION:
                     $version = $whups_driver->getVersion($value);
                     if ($version) {
                         $text = _("Version");
                         $value = $version['name'];
                     }
                     break;
                 case Whups_Query::CRITERION_TYPE:
                     $text = _("Type");
                     $value = $whups_driver->getTypeName($value);
                     break;
                 case Whups_Query::CRITERION_STATE:
                     // The value of the following depends on the type.
                     $state = $whups_driver->getState($value);
                     if ($state && isset($this->ticketTypes[$state['type']])) {
                         $text = '[' . $this->ticketTypes[$state['type']] . '] ' . _("State");
                         $value = $state['name'];
                     }
                     break;
                 case Whups_Query::CRITERION_PRIORITY:
                     $state = $whups_driver->getPriority($value);
                     $text = '[' . $this->ticketTypes[$state['type']] . '] ' . _("Priority");
                     $value = $state['name'];
                     break;
                 case Whups_Query::CRITERION_ATTRIBUTE:
                     // The value of the following depends on the type.
                     $aname = $whups_driver->getAttributeName($cvalue);
                     foreach ($this->attributes as $attribute) {
                         if ($attribute['attribute_id'] == $cvalue) {
                             $type = $attribute['type_id'];
                             break;
                         }
                     }
                     if (isset($this->ticketTypes[$type])) {
                         $aname .= ' (' . $this->ticketTypes[$type] . ')';
                     }
                     $text = sprintf("Attribute \"%s\"", $aname);
                     break;
                 case Whups_Query::CRITERION_TIMESTAMP:
                     $text = _("Created");
                     $value = strftime($GLOBALS['prefs']->getValue('report_time_format'), $value);
                     break;
                 case Whups_Query::CRITERION_UPDATED:
                     $text = _("Updated");
                     $value = strftime($GLOBALS['prefs']->getValue('report_time_format'), $value);
                     break;
                 case Whups_Query::CRITERION_RESOLVED:
                     $text = _("Resolved");
                     $value = strftime($GLOBALS['prefs']->getValue('report_time_format'), $value);
                     break;
                 case Whups_Query::CRITERION_ASSIGNED:
                     $text = _("Assigned");
                     $value = strftime($GLOBALS['prefs']->getValue('report_time_format'), $value);
                     break;
                 case Whups_Query::CRITERION_DUE:
                     $text = _("Due");
                     $value = strftime($GLOBALS['prefs']->getValue('report_time_format'), $value);
                     break;
             }
             if (!isset($text)) {
                 $text = sprintf(_("Unknown node type %s"), $type);
                 break;
             }
             $text .= ' ';
             switch ($operator) {
                 case Whups_Query::OPERATOR_GREATER:
                     $text .= _("is greater than");
                     break;
                 case Whups_Query::OPERATOR_LESS:
                     $text .= _("is less than");
                     break;
                 case Whups_Query::OPERATOR_EQUAL:
                     $text .= _("is");
                     break;
                 case Whups_Query::OPERATOR_CI_SUBSTRING:
                     $text .= _("contains (case insensitive) substring");
                     break;
                 case Whups_Query::OPERATOR_CS_SUBSTRING:
                     $text .= _("contains (case sensitive) substring");
                     break;
                 case Whups_Query::OPERATOR_WORD:
                     $text .= _("contains the word");
                     break;
                 case Whups_Query::OPERATOR_PATTERN:
                     $text .= _("matches the pattern");
                     break;
             }
             $text .= " {$value}";
             break;
         default:
             $text = sprintf(_("Unknown node type %s"), $type);
             break;
     }
     // Stick vertical-align: middle; on everything to make it look a
     // little nicer.
     $fimgattrs = 'height="20" width="0" style="vertical-align: middle;"';
     $imgattrs = 'height="20" width="20" style="vertical-align: middle;"';
     $space = '';
     $count = count($more);
     if ($count == 0) {
         // Always have at least one image to make sure all rows are the
         // same height.
         $space = Horde::img('tree/blank.png', '', $fimgattrs) . "\n";
     } else {
         for ($i = 0; $i < $count - 1; $i++) {
             if ($more[$i] == 1) {
                 $space .= Horde::img('tree/line.png', '|', $imgattrs) . "\n";
             } else {
                 $space .= Horde::img('tree/blank.png', '', $imgattrs) . "\n";
             }
         }
     }
     if ($count > 0) {
         if ($more[$count - 1] == 1) {
             $space .= Horde::img('tree/join.png', '+', $imgattrs) . "\n";
         } else {
             $space .= Horde::img('tree/joinbottom.png', '-', $imgattrs) . "\n";
         }
     }
     $extra = $this->isActive ? '' : ' disabled="disabled"';
     $extra .= $pathstring == $this->currentPath ? ' checked="checked"' : '';
     include WHUPS_TEMPLATES . '/renderer/query/render.inc';
 }
Пример #3
0
            $session->set('whups', 'query_form', $qf);
            $vars->set('edit', true);
            break;
    }
    $vars->remove('qaction1');
    $vars->remove('qaction2');
} elseif ($vars->get('formname')) {
    // Now check for submitted forms.
    $class = $vars->get('formname');
    $form = new $class($vars);
    if ($form->validate($vars)) {
        if ($vars->get('edit')) {
            $whups_query->deleteNode($vars->get('path'));
            $path = Whups_Query::stringToPath($vars->get('path'));
            array_pop($path);
            $vars->set('path', Whups_Query::pathToString($path));
            $vars->remove('edit');
        }
        $form->execute($vars);
        $vars->remove('action');
    }
} elseif ($vars->get('action') != '') {
    // Last, check for actions from tabs.
    $action = $vars->get('action');
    switch ($action) {
        case 'new':
            $whups_query = $qManager->newQuery();
            break;
        case 'delete':
            $showExtraForm = 'Whups_Form_Query_Delete';
            $showEditQuery = false;