Ejemplo n.º 1
0
Archivo: Js.php Proyecto: arhe/pwak
 /**
  * Converti un tableau php en tableau js.
  *
  * @static
  * @param array $items
  * @return string
  */
 static function JSArray($items)
 {
     $return = array();
     if (is_array($items)) {
         foreach ($items as $key => $value) {
             switch (gettype($value)) {
                 case 'integer':
                     $return[$key] = $value;
                     break;
                 case 'string':
                     $return[$key] = JsTools::JSQuoteString($value);
                     break;
                 default:
                     // @todo Implement other data type
                     $return[$key] = JsTools::JSQuoteString($value);
             }
             // switch
         }
     }
     return '[' . implode(', ', $return) . ']';
 }
Ejemplo n.º 2
0
 /**
  * AbstractGridAction::__construct()
  *
  * @param array $params
  * @return void
  */
 public function __construct($params = array())
 {
     if (isset($params['Caption'])) {
         $this->caption = $params['Caption'];
     }
     // Contenu d'une infobulle
     $this->title = isset($params['Title']) ? $params['Title'] : $this->caption;
     if (isset($params['Enabled'])) {
         $this->enabled = $params['Enabled'];
     }
     if (isset($params['Profiles'])) {
         $this->profiles = $params['Profiles'];
     }
     $this->enabled = $this->enabled && $this->hasProfilesToExecute();
     if (isset($params['Renderer'])) {
         $this->renderer = $params['Renderer'];
     }
     if (isset($params['GlyphDisabled'])) {
         $this->glyphDisabled = $params['GlyphDisabled'];
     }
     if (isset($params['GlyphEnabled'])) {
         $this->glyphEnabled = $params['GlyphEnabled'];
     }
     $glyph = $this->enabled ? $this->glyphEnabled : $this->glyphDisabled;
     // Si pas de fichier image trouve, 'button' par defaut
     if ($this->renderer == 'image') {
         if (empty($glyph) || !file_exists($glyph)) {
             $this->renderer = 'button';
         } else {
             $this->glyph = $glyph;
             $this->status = ' onmouseover="window.status=' . JsTools::JSQuoteString($this->title) . '; return true;"' . ' onmouseout="window.status=\'\';return true;"';
         }
     }
     // pour definir si l'action declenche l'ouverture d'un popup
     if (isset($params['TargetPopup'])) {
         $this->targetPopup = $params['TargetPopup'];
     }
     // pour definir si le grid est ds un popup ou non
     if (isset($params['GridInPopup'])) {
         $this->gridInPopup = $params['GridInPopup'];
     }
     // pour definir si une url de retour est donnee ou non
     if (isset($params['ReturnURL'])) {
         $this->returnURL = $params['ReturnURL'];
     }
     if (isset($params['AllowEmptySelection'])) {
         $this->allowEmptySelection = $params['AllowEmptySelection'];
     }
     if (isset($params['WithJSConfirm'])) {
         $this->withJSConfirm = $params['WithJSConfirm'];
     }
     if (isset($params['ConfirmMessage'])) {
         $this->confirmMessage = $params['ConfirmMessage'];
     }
     if (isset($params['JsOwnerForm'])) {
         $this->jsOwnerForm = $params['JsOwnerForm'];
     }
     if (isset($params['allowEmptySelection'])) {
         $this->allowEmptySelection = $params['allowEmptySelection'];
     }
 }
Ejemplo n.º 3
0
 /**
  * GridActionToggleProperty::render()
  * Retourne le code html des 2 actions.
  *
  * @return string
  */
 public function render()
 {
     if (!$this->enabled) {
         return;
     }
     $actionOnOnClick = ' onclick="' . $this->jsOwnerForm . '.elements[\'Grid_ToggleAction\'].value=1;' . 'return fw.grid.triggerAction(' . $this->jsOwnerForm . ', ' . $this->index . ');"';
     $actionOffOnClick = ' onclick="' . $this->jsOwnerForm . '.elements[\'Grid_ToggleAction\'].value=0;' . 'return fw.grid.triggerAction(' . $this->jsOwnerForm . ', ' . $this->index . ');"';
     /*
      * XXX le hidden Grid_ToogleAcion à été déplacé dans le template 
      * Grid.html, lorsque le grid à plus de 20 enregistrement et que les 
      * actions sont en haut et en bas du grid, cela évite d'avoir 2 fois le
      * champ
      */
     //$result = '<input type="hidden" value="0" name="Grid_ToggleAction" id="Grid_ToggleActionId"/>';
     $result = '';
     if ($this->useButton) {
         // action on
         $result .= '<input type="button" value="' . $this->toggleOnLabel . '"' . $actionOnOnClick . ' class="button" name="button_' . $this->index . '_0" />&nbsp;';
         $result .= "\n";
         // action off
         $result .= '<input type="button" value="' . $this->toggleOffLabel . '"' . $actionOffOnClick . ' class="button" name="button_' . $this->index . '_1" />&nbsp;';
     } else {
         // action on
         $result .= '<a href="javascript:void(0);" ' . $actionOnOnClick . ' onmouseover="window.status=' . JsTools::JSQuoteString($this->toggleOnLabel) . '; return true;" onmouseout="window.status=\'\';return true;" ' . 'title="' . $this->toggleOnLabel . '">' . '<img src="' . $this->toggleOnGlyph . '" alt="' . $this->toggleOnLabel . '" /></a>&nbsp;';
         $result .= "\n";
         // action off
         $result .= '<a href="javascript:void(0);" ' . $actionOffOnClick . ' onmouseover="window.status=' . JsTools::JSQuoteString($this->toggleOffLabel) . '; return true;" onmouseout="window.status=\'\';return true;" ' . 'title="' . $this->toggleOffLabel . '">' . '<img src="' . $this->toggleOffGlyph . '" alt="' . $this->toggleOffLabel . '" /></a>&nbsp;';
     }
     return $result;
 }