Ejemplo n.º 1
0
/**
* @package     jelix
* @subpackage  jtpl_plugin
* @author      Loic Mathaud
* @copyright   2008 Loic Mathaud
* @link        http://www.jelix.org
* @licence     GNU Lesser General Public Licence see LICENCE file or http://www.gnu.org/licenses/lgpl.html
*/
function jtpl_function_html_jmessage($tpl, $type = '')
{
    if ($type == '') {
        $messages = jMessage::getAll();
    } else {
        $messages = jMessage::get($type);
    }
    if (!$messages) {
        return;
    }
    if ($type == '') {
        echo '<ul class="jelix-msg">';
        foreach ($messages as $type_msg => $all_msg) {
            foreach ($all_msg as $msg) {
                echo '<li class="jelix-msg-item-' . $type_msg . '">' . htmlspecialchars($msg) . '</li>';
            }
        }
    } else {
        echo '<ul class="jelix-msg-' . $type . '">';
        foreach ($messages as $msg) {
            echo '<li class="jelix-msg-item-' . $type . '">' . htmlspecialchars($msg) . '</li>';
        }
    }
    echo '</ul>';
    if ($type == '') {
        jMessage::clearAll();
    } else {
        jMessage::clear($type);
    }
}
 function error()
 {
     $messages = jMessage::getAll();
     jMessage::clearAll();
     $rep = $this->getResponse('json');
     $rep->data = $messages;
     return $rep;
 }
 protected function serviceException()
 {
     $messages = jMessage::getAll();
     $mime = 'text/plain';
     $data = implode('\\n', $messages);
     if ($this->tplExceptions !== null) {
         $mime = 'text/xml';
         $tpl = new jTpl();
         $tpl->assign('messages', $messages);
         $data = $tpl->fetch($this->tplExceptions);
     }
     return (object) array('code' => 200, 'mime' => $mime, 'data' => $data, 'cached' => False);
 }
 /**
  * Send an answer
  * @return HTML fragment.
  */
 function serviceAnswer()
 {
     $title = jLocale::get("view~edition.modal.title.default");
     // Get title layer
     if ($this->layerXml and $this->layerXml[0]) {
         $layerXmlZero = $this->layerXml[0];
         $_title = $layerXmlZero->xpath('title');
         if ($_title and $_title[0]) {
             $title = (string) $_title[0];
         }
     }
     $messages = jMessage::getAll();
     $rep = $this->getResponse('htmlfragment');
     $tpl = new jTpl();
     $tpl->assign('title', $title);
     $content = $tpl->fetch('view~jmessage_answer');
     $rep->addContent($content);
     jMessage::clearAll();
     return $rep;
 }
/**
* function plugin :  Display messages from jMessage
*/
function jtpl_function_html_jmessage_bootstrap($tpl, $type = '')
{
    // Get messages
    if ($type == '') {
        $messages = jMessage::getAll();
    } else {
        $messages = jMessage::get($type);
    }
    // Not messages, quit
    if (!$messages) {
        return;
    }
    // Display messages
    if ($type == '') {
        foreach ($messages as $type_msg => $all_msg) {
            if ($type_msg == 'default') {
                $type_msg = 'info';
            } elseif ($type_msg == 'ok') {
                $type_msg = 'success';
            }
            echo '<div class="alert alert-block alert-' . $type_msg . ' fade in" data-alert="alert"><a class="close" data-dismiss="alert" href="#">×</a>';
            foreach ($all_msg as $msg) {
                echo '<p>' . htmlspecialchars($msg) . '</p>';
            }
            echo '</div>';
        }
    } else {
        echo '<div class="alert alert-block ' . $type . ' fade in" data-alert="alert"><a class="close" data-dismiss="alert" href="#">×</a>';
        foreach ($messages as $msg) {
            echo '<p>' . htmlspecialchars($msg) . '</p>';
        }
        echo '</div>';
    }
    if ($type == '') {
        jMessage::clearAll();
    } else {
        jMessage::clear($type);
    }
}
Ejemplo n.º 6
0
 /**
  * Send an OGC service Exception
  * @param $SERVICE the OGC service
  * @return XML OGC Service Exception.
  */
 function serviceException()
 {
     $messages = jMessage::getAll();
     $rep = $this->getResponse('xml');
     $rep->contentTpl = 'lizmap~wms_exception';
     $rep->content->assign('messages', $messages);
     jMessage::clearAll();
     foreach ($messages as $code => $msg) {
         if ($code == 'AuthorizationRequired') {
             $rep->setHttpStatus(401, $code);
         }
     }
     return $rep;
 }
Ejemplo n.º 7
0
 /**
  * Send an OGC service Exception
  * @param $SERVICE the OGC service
  * @return XML OGC Service Exception.
  */
 function serviceException()
 {
     $messages = jMessage::getAll();
     if (!$messages) {
         $messages = array();
     }
     $rep = $this->getResponse('xml');
     $rep->contentTpl = 'lizmap~wms_exception';
     $rep->content->assign('messages', $messages);
     jMessage::clearAll();
     foreach ($messages as $code => $msg) {
         if ($code == 'AuthorizationRequired') {
             $rep->setHttpStatus(401, $code);
         } else {
             if ($code == 'ProjectNotDefined') {
                 $rep->setHttpStatus(404, 'Not Found');
             } else {
                 if ($code == 'RepositoryNotDefined') {
                     $rep->setHttpStatus(404, 'Not Found');
                 }
             }
         }
     }
     return $rep;
 }