Example #1
0
 public function __construct()
 {
     parent::__construct();
     $tpl = new Mtpl(array('M/Office/Templates/', APP_ROOT . 'app/' . APP_NAME . '/templates/', APP_ROOT . 'public/themes/' . Config::getPref('theme') . '/templates/'));
     $this->assign('output', $tpl->fetch('home'));
     $this->assign('__action', 'dyn');
 }
Example #2
0
File: setup.php Project: demental/m
 public function setup()
 {
     M_Office_Util::$mainOptions = PEAR::getStaticProperty('m_office', 'options');
     M::addPaths('module', array(APP_ROOT . 'app/_shared/modules/', APP_ROOT . 'app/' . APP_NAME . '/modules/', 'M/Office/modules/'));
     M::addPaths('template', array(OFFICE_TEMPLATES_FOLDER, APP_ROOT . 'app/_shared/templates/', APP_ROOT . 'app/' . APP_NAME . '/templates/'));
     if (Config::getPref('theme')) {
         M::addPaths('template', array(APP_ROOT . 'public/themes/' . Config::getPref('theme') . '/templates/'));
     }
     $tpl = new Mtpl(M::getPaths('template'));
     $tpl->assign('jsdir', SITE_URL . 'js/');
     Mreg::set('tpl', $tpl);
 }
Example #3
0
 /**
  * Nested blocks will be stored inside $_p
  * @param  string               $block
  * @return Mtpl|null
  * @throws \Exception
  */
 public function __get($block)
 {
     if ($this->reassign) {
         $this->startReassign();
     }
     $this->touchBlock($block);
     if (!array_key_exists($block, $this->_p)) {
         $tpl = new Mtpl();
         $tpl->setTemplate($this->getBlock($block));
         $this->_p[$block] = $tpl;
     }
     return $this->_p[$block];
 }
Example #4
0
<link rel="stylesheet" type="text/css" href="/css/jquery.autocomplete.css" />
<?php 
if ($local) {
} else {
}
foreach ($tags as $tag) {
    $arr[] = $tag->strip;
}
?>

<?php 
$this->startCapture('js');
?>

  data = <?php 
echo json_encode($arr);
?>
;
  $('#<?php 
echo $field;
?>
').autocomplete({source: data});

<?php 
$this->endCapture();
Mtpl::addJSinline($this->getCapture('js'));
Example #5
0
File: Util.php Project: demental/m
 public static function outputform(&$form, $template = 'bordered', $addwait = true)
 {
     if ($addwait) {
         $formId = $form->getAttribute('id');
         Mtpl::addJSinline('
     $("#' . $formId . ' input:submit").click(function() {
         $(\'<span><img src="images/indicator.gif" />' . __('Loading... Please wait') . '</span>\').prependTo($(this).parent());
     });
     ', 'ready');
     }
     $options = PEAR::getStaticProperty('M_Office', 'options');
     $tpl = Mreg::get('tpl')->instance();
     $tpl->assignRef('form', $form);
     return $tpl->fetch('form-' . $template);
 }
Example #6
0
File: login.php Project: demental/m
        echo $inst . "\n";
    }
}
// =====================================================
// = Javascript for dialog window and any ajax request =
// =====================================================
?>
    $(function() {
            $("#loading").ajaxStart(function(){
              $('indicator').show().css(
                  'left:'+mouse.x + 'px',
                  'top:'+mouse.y + 'px')
             });
			$("#closepanel").click(function(){$("#messagePanel").hide("fast")});
<?php 
foreach (Mtpl::getJSinline('ready') as $inst) {
    echo $inst . "\n";
}
?>
    });
		</script>
	</head>
	<body>
		<div id="doc3">
      <div id="hd">
			  <h3><a href="<?php 
echo ROOT_ADMIN_URL . ROOT_ADMIN_SCRIPT;
?>
"><?php 
echo $adminTitle;
?>
Example #7
0
File: Mtpl.php Project: demental/m
 public function getJSinlineblock($event = 'ready')
 {
     $out = '';
     foreach (Mtpl::getJSinline($event) as $line) {
         $out .= $line . "\n";
     }
     $out = trim($out);
     if (!empty($out)) {
         $out = '
 <script type="text/javascript">
 jQuery(function($) {
 ' . $out . '
 });
 </script>';
     }
     return $out;
 }
Example #8
0
 public function execute(&$input)
 {
     $input = str_replace($this->_JSblock, Mtpl::getJSblock(), $input);
     $input = str_replace($this->_CSSblock, Mtpl::getCSSblock(), $input);
     $input = str_replace($this->_JSblockinline, Mtpl::getJSinlineblock(), $input);
 }
Example #9
0
 function &getAddFormObject($record = null)
 {
     if (is_null($record)) {
         $record = $this->getObject();
     }
     if (!$record->isNew()) {
         $formaction = 'updateFromTableRecord';
         $formclass = 'updateFromTableForm';
         $formactionval = $record->pk();
         $formname = 'addFromTable__' . $this->table . $record->pk();
         $update = $this->table . $record->pk();
         $sub = "OK";
     } else {
         $formaction = 'addFromTableRecord';
         $formclass = 'addFromTableForm';
         $formactionval = 1;
         $formname = 'addFromTable__' . $this->table;
         $update = 'endList__' . $this->table;
         $sub = "+";
     }
     $form = new MyQuickForm($formname, 'POST', M_Office_Util::getQueryParams(array('module' => $this->table, 'filterField' => $this->field, 'filterValue' => $this->value, $formaction => $formactionval, 'ajaxfromtable' => 1), array_keys($_REQUEST), false));
     $form->updateAttributes(array('class' => $formclass, 'target' => $update));
     Mtpl::addJS('jquery.form');
     $record->fb_requiredRuleMessage = __('The field "%s" is required');
     $record->fb_ruleViolationMessage = __('The field "%s" is not valid');
     $record->fb_formAddHeader = true;
     $record->fb_createSubmit = false;
     $record->fb_submitText = $sub;
     $this->fb =& MyFB::create($record);
     $this->fb->useForm($form);
     $this->fb->getForm();
     if ($form->elementExists($this->field)) {
         $form->removeElement($this->field);
     }
     $form->addElement('submit', '__submit__', '+');
     $form->addElement('hidden', $this->field, $this->value);
     //        $form->addElement('static','st','','<pre>'.print_r($_REQUEST,true).'</pre>');
     return $form;
 }
Example #10
0
 function toHtml()
 {
     $this->_js = '';
     if (!defined('HTML_QUICKFORM_ADVANDATE_EXISTS')) {
         $this->_js .= "\n\n\t\t\t    var advandate_Update = function(groupName) {\n\t\t\t\t\t  value=\$('select[name=\"'+groupName+'[firstselect]\"]').val();\n\t\t\t\t\t\tfirstD = \$('select[name^=\"'+groupName+'[firstdate]\"]');\n            \$(firstD).hide();\n\t\t\t\t\t\tsecD = \$('select[name^=\"'+groupName+'[seconddate]\"]');\n            \$(secD).hide();\n\t\t\t\t\t\tnbunits=\$('select[name=\"'+groupName+'[nbunits]\"]');\n            \$(nbunits).hide();\n\t\t\t\t\t\tunit=\$('select[name=\"'+groupName+'[unit]\"]');\n            \$(unit).hide();\n\t\t\t\t\t\tseparator=\$('#" . $this->_escapeString($this->getName()) . "_dates_separator');\n\t\t\t\t\t\tseparator.hide();\n\t\t\t\t  if( value=='is' && \$(\"input[name='created_at[firstselect]']\").val() != 'is' )\n\t\t\t\t  {\n            today = new Date();\n            \$(firstD[0]).val(today.getDate());\n            \$(firstD[1]).val(today.getMonth()+1);\n            \$(firstD[2]).val(today.getFullYear());\n\t\t\t\t  }\n\t\t\t\t\tif(value=='before' || value=='after' || value=='is') {\n            \$(firstD).show();\n\t\t\t\t\t} else {\n\t\t\t\t\t\tif (value=='between'){\n              \$(firstD).show();\n              \$(secD).show();\n\t\t\t\t\t\t\tseparator.show();\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tif (value=='inthelast'){\n                \$(nbunits).show();\n                \$(unit).show();\n\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tif (value=='lastmonth'){\n\t\t\t\t\t\t\t\t\t// Nothing to show\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}";
         define('HTML_QUICKFORM_ADVANDATE_EXISTS', TRUE);
     }
     include_once 'HTML/QuickForm/Renderer/Default.php';
     $renderer = new HTML_QuickForm_Renderer_Default();
     $renderer->setElementTemplate('{element}');
     parent::accept($renderer);
     if (class_exists('Mtpl')) {
         $script = (empty($this->_js) ? '' : $this->_js) . "\n\$(function(){advandate_Update('" . $this->_escapeString($this->getName()) . "');\n            \$('select[name=\"" . $this->_escapeString($this->getName()) . "[firstselect]\"]').bind('change',function(){advandate_Update('" . $this->_escapeString($this->getName()) . "')});\n            });";
         Mtpl::addJSinline($script);
         return $renderer->toHtml();
     } else {
         return "<script type=\"text/javascript\">\n//<![CDATA[\n" . (empty($this->_js) ? '' : $this->_js) . "\n\$(function(){advandate_Update('" . $this->_escapeString($this->getName()) . "');\n            \$('select[name=\"" . $this->_escapeString($this->getName()) . "[firstselect]\"]').bind('change',function(){advandate_Update('" . $this->_escapeString($this->getName()) . "')});\n            });//]]>\n</script>" . $renderer->toHtml();
     }
 }