protected function getOptions() { // Initialize variables. $options = array(); // Initialize some field attributes. $first = (int) $this->element['first']; $last = (int) $this->element['last']; $step = (int) $this->element['step']; // Sanity checks. if ($step == 0) { // Step of 0 will create an endless loop. return $options; } elseif ($first < $last && $step < 0) { // A negative step will never reach the last number. return $options; } elseif ($first > $last && $step > 0) { // A position step will never reach the last number. return $options; } // Build the options array. for ($i = $first; $i <= $last; $i += $step) { $options[] = MHtml::_('select.option', $i); } // Merge any additional options in the XML definition. $options = array_merge(parent::getOptions(), $options); return $options; }
protected function getGroups() { // Initialize variables. $groups = array(); // Initialize some field attributes. $menuType = (string) $this->element['menu_type']; $published = $this->element['published'] ? explode(',', (string) $this->element['published']) : array(); $disable = $this->element['disable'] ? explode(',', (string) $this->element['disable']) : array(); $language = $this->element['language'] ? explode(',', (string) $this->element['language']) : array(); // Get the menu items. $items = MenusHelper::getMenuLinks($menuType, 0, 0, $published, $language); // Build group for a specific menu type. if ($menuType) { // Initialize the group. $groups[$menuType] = array(); // Build the options array. foreach ($items as $link) { $groups[$menuType][] = MHtml::_('select.option', $link->value, $link->text, 'value', 'text', in_array($link->type, $disable)); } } else { // Build the groups arrays. foreach ($items as $menu) { // Initialize the group. $groups[$menu->menutype] = array(); // Build the options array. foreach ($menu->links as $link) { $groups[$menu->menutype][] = MHtml::_('select.option', $link->value, $link->text, 'value', 'text', in_array($link->type, $disable)); } } } // Merge any additional groups in the XML definition. $groups = array_merge(parent::getGroups(), $groups); return $groups; }
protected static function _loadBehavior($group, $params = array()) { static $loaded = array(); if (!array_key_exists($group, $loaded)) { $loaded[$group] = true; // Include mootools framework. MHtml::_('behavior.framework', true); $document = MFactory::getDocument(); $display = isset($params['startOffset']) && isset($params['startTransition']) && $params['startTransition'] ? (int) $params['startOffset'] : null; $show = isset($params['startOffset']) && !(isset($params['startTransition']) && $params['startTransition']) ? (int) $params['startOffset'] : null; $options = '{'; $opt['onActive'] = "function(toggler, i) {toggler.addClass('pane-toggler-down');" . "toggler.removeClass('pane-toggler');i.addClass('pane-down');i.removeClass('pane-hide');Cookie.write('jpanesliders_" . $group . "',\$\$('div#" . $group . ".pane-sliders > .panel > h3').indexOf(toggler));}"; $opt['onBackground'] = "function(toggler, i) {toggler.addClass('pane-toggler');" . "toggler.removeClass('pane-toggler-down');i.addClass('pane-hide');i.removeClass('pane-down');if(\$\$('div#" . $group . ".pane-sliders > .panel > h3').length==\$\$('div#" . $group . ".pane-sliders > .panel > h3.pane-toggler').length) Cookie.write('jpanesliders_" . $group . "',-1);}"; $opt['duration'] = isset($params['duration']) ? (int) $params['duration'] : 300; $opt['display'] = isset($params['useCookie']) && $params['useCookie'] ? MRequest::getInt('jpanesliders_' . $group, $display, 'cookie') : $display; $opt['show'] = isset($params['useCookie']) && $params['useCookie'] ? MRequest::getInt('jpanesliders_' . $group, $show, 'cookie') : $show; $opt['opacity'] = isset($params['opacityTransition']) && $params['opacityTransition'] ? 'true' : 'false'; $opt['alwaysHide'] = isset($params['allowAllClose']) && !$params['allowAllClose'] ? 'false' : 'true'; foreach ($opt as $k => $v) { if ($v) { $options .= $k . ': ' . $v . ','; } } if (substr($options, -1) == ',') { $options = substr($options, 0, -1); } $options .= '}'; $js = "jQuery(document).ready(function () { new Fx.Accordion(\$\$('div#" . $group . ".pane-sliders > .panel > h3.pane-toggler'), \$\$('div#" . $group . ".pane-sliders > .panel > div.pane-slider'), " . $options . "); });"; $document->addScriptDeclaration($js); } }
function render() { $links = $this->createPageLinks(); if (!empty($links)) { return MHtml::pagination($links, $this->htmlOptions); } }
protected function getInput() { // Initialize some field attributes. $size = $this->element['size'] ? ' size="' . (int) $this->element['size'] . '"' : ''; $maxLength = $this->element['maxlength'] ? ' maxlength="' . (int) $this->element['maxlength'] . '"' : ''; $class = $this->element['class'] ? ' class="' . (string) $this->element['class'] . '"' : ''; $auto = (string) $this->element['autocomplete'] == 'off' ? ' autocomplete="off"' : ''; $readonly = (string) $this->element['readonly'] == 'true' ? ' readonly="readonly"' : ''; $disabled = (string) $this->element['disabled'] == 'true' ? ' disabled="disabled"' : ''; $meter = (string) $this->element['strengthmeter'] == 'true'; $threshold = $this->element['threshold'] ? (int) $this->element['threshold'] : 66; $script = ''; if ($meter) { MHtml::_('script', 'system/passwordstrength.js', true, true); $script = '<script type="text/javascript">new Form.PasswordStrength("' . $this->id . '", { threshold: ' . $threshold . ', onUpdate: function(element, strength, threshold) { element.set("data-passwordstrength", strength); } } );</script>'; } return '<input type="password" name="' . $this->name . '" id="' . $this->id . '"' . ' value="' . htmlspecialchars($this->value, ENT_COMPAT, 'UTF-8') . '"' . $auto . $class . $readonly . $disabled . $size . $maxLength . '/>' . $script; }
protected function getOptions() { // Initialize variables. $options = array(); // Initialize some field attributes. $key = $this->element['key_field'] ? (string) $this->element['key_field'] : 'value'; $value = $this->element['value_field'] ? (string) $this->element['value_field'] : (string) $this->element['name']; $translate = $this->element['translate'] ? (string) $this->element['translate'] : false; $query = (string) $this->element['query']; // Get the database object. $db = MFactory::getDBO(); // Set the query and get the result list. $db->setQuery($query); $items = $db->loadObjectlist(); // Check for an error. if ($db->getErrorNum()) { MError::raiseWarning(500, $db->getErrorMsg()); return $options; } // Build the field options. if (!empty($items)) { foreach ($items as $item) { if ($translate == true) { $options[] = MHtml::_('select.option', $item->{$key}, MText::_($item->{$value})); } else { $options[] = MHtml::_('select.option', $item->{$key}, $item->{$value}); } } } // Merge any additional options in the XML definition. $options = array_merge(parent::getOptions(), $options); return $options; }
protected static function _loadBehavior($group, $params = array()) { static $loaded = array(); if (!array_key_exists((string) $group, $loaded)) { // Include MooTools framework MHtml::_('behavior.framework', true); $options = '{'; $opt['onActive'] = isset($params['onActive']) ? $params['onActive'] : null; $opt['onBackground'] = isset($params['onBackground']) ? $params['onBackground'] : null; $opt['display'] = isset($params['startOffset']) ? (int) $params['startOffset'] : null; $opt['useStorage'] = isset($params['useCookie']) && $params['useCookie'] ? 'true' : 'false'; $opt['titleSelector'] = "'dt.tabs'"; $opt['descriptionSelector'] = "'dd.tabs'"; foreach ($opt as $k => $v) { if ($v) { $options .= $k . ': ' . $v . ','; } } if (substr($options, -1) == ',') { $options = substr($options, 0, -1); } $options .= '}'; $js = ' jQuery(document).ready(function () { $$(\'dl#' . $group . '.tabs\').each(function(tabs){ new MTabs(tabs, ' . $options . '); }); });'; $document = MFactory::getDocument(); $document->addScriptDeclaration($js); MHtml::_('script', 'system/tabs.js', false, true); $loaded[(string) $group] = true; } }
protected function getInput() { // Initialize variables. $options = array(); $attr = ''; // Initialize some field attributes. $attr .= $this->element['class'] ? ' class="' . (string) $this->element['class'] . '"' : ''; $attr .= (string) $this->element['disabled'] == 'true' ? ' disabled="disabled"' : ''; $attr .= $this->element['size'] ? ' size="' . (int) $this->element['size'] . '"' : ''; $attr .= $this->multiple ? ' multiple="multiple"' : ''; // Initialize JavaScript field attributes. $attr .= $this->element['onchange'] ? ' onchange="' . (string) $this->element['onchange'] . '"' : ''; // Iterate through the children and build an array of options. foreach ($this->element->children() as $option) { // Only add <option /> elements. if ($option->getName() != 'option') { continue; } // Create a new option object based on the <option /> element. $tmp = MHtml::_('select.option', (string) $option['value'], trim((string) $option), 'value', 'text', (string) $option['disabled'] == 'true'); // Set some option attributes. $tmp->class = (string) $option['class']; // Set some JavaScript option attributes. $tmp->onclick = (string) $option['onclick']; // Add the option object to the result set. $options[] = $tmp; } return MHtml::_('access.usergroup', $this->name, $this->value, $attr, $options, $this->id); }
protected function getInput() { // Initialize variables. $html = array(); $attr = ''; // Initialize some field attributes. $attr .= $this->element['class'] ? ' class="combobox ' . (string) $this->element['class'] . '"' : ' class="combobox"'; $attr .= (string) $this->element['readonly'] == 'true' ? ' readonly="readonly"' : ''; $attr .= (string) $this->element['disabled'] == 'true' ? ' disabled="disabled"' : ''; $attr .= $this->element['size'] ? ' size="' . (int) $this->element['size'] . '"' : ''; // Initialize JavaScript field attributes. $attr .= $this->element['onchange'] ? ' onchange="' . (string) $this->element['onchange'] . '"' : ''; // Get the field options. $options = $this->getOptions(); // Load the combobox behavior. MHtml::_('behavior.combobox'); // Build the input for the combo box. $html[] = '<input type="text" name="' . $this->name . '" id="' . $this->id . '"' . ' value="' . htmlspecialchars($this->value, ENT_COMPAT, 'UTF-8') . '"' . $attr . '/>'; // Build the list for the combo box. $html[] = '<ul id="combobox-' . $this->id . '" style="display:none;">'; foreach ($options as $option) { $html[] = '<li>' . $option->text . '</li>'; } $html[] = '</ul>'; return implode($html); }
protected function getInput() { // Initialize some field attributes. $format = $this->element['format'] ? (string) $this->element['format'] : '%Y-%m-%d'; // Build the attributes array. $attributes = array(); if ($this->element['size']) { $attributes['size'] = (int) $this->element['size']; } if ($this->element['maxlength']) { $attributes['maxlength'] = (int) $this->element['maxlength']; } if ($this->element['class']) { $attributes['class'] = (string) $this->element['class']; } if ((string) $this->element['readonly'] == 'true') { $attributes['readonly'] = 'readonly'; } if ((string) $this->element['disabled'] == 'true') { $attributes['disabled'] = 'disabled'; } if ($this->element['onchange']) { $attributes['onchange'] = (string) $this->element['onchange']; } // Handle the special case for "now". if (strtoupper($this->value) == 'NOW') { $this->value = strftime($format); } // Get some system objects. $config = MFactory::getConfig(); $user = MFactory::getUser(); // If a known filter is given use it. switch (strtoupper((string) $this->element['filter'])) { case 'SERVER_UTC': // Convert a date to UTC based on the server timezone. if (intval($this->value)) { // Get a date object based on the correct timezone. $date = MFactory::getDate($this->value, 'UTC'); $date->setTimezone(new DateTimeZone($config->get('offset'))); // Transform the date string. $this->value = $date->format('Y-m-d H:i:s', true, false); } break; case 'USER_UTC': // Convert a date to UTC based on the user timezone. if (intval($this->value)) { // Get a date object based on the correct timezone. $date = MFactory::getDate($this->value, 'UTC'); $date->setTimezone(new DateTimeZone($user->getParam('timezone', $config->get('offset')))); // Transform the date string. $this->value = $date->format('Y-m-d H:i:s', true, false); } break; } return MHtml::_('calendar', $this->value, $this->name, $this->id, $format, $attributes); }
public static function user($noUser = true) { $optionNo = ''; if ($noUser) { $optionNo = '<option value="0">' . MText::_('MLIB_HTML_BATCH_USER_NOUSER') . '</option>'; } // Create the batch selector to select a user on a selection list. $lines = array('<label id="batch-user-lbl" for="batch-user" class="hasTip"' . ' title="' . MText::_('MLIB_HTML_BATCH_USER_LABEL') . '::' . MText::_('MLIB_HTML_BATCH_USER_LABEL_DESC') . '">', MText::_('MLIB_HTML_BATCH_USER_LABEL'), '</label>', '<select name="batch[user_id]" class="inputbox" id="batch-user-id">', '<option value="">' . MText::_('MLIB_HTML_BATCH_USER_NOCHANGE') . '</option>', $optionNo, MHtml::_('select.options', MHtml::_('user.userlist'), 'value', 'text'), '</select>'); return implode("\n", $lines); }
protected function getOptions() { // Initialise variables. $options = array(); $extension = $this->element['extension'] ? (string) $this->element['extension'] : (string) $this->element['scope']; $published = (string) $this->element['published']; $name = (string) $this->element['name']; // Load the category options for a given extension. if (!empty($extension)) { // Filter over published state or not depending upon if it is present. if ($published) { $options = MHtml::_('category.options', $extension, array('filter.published' => explode(',', $published))); } else { $options = MHtml::_('category.options', $extension); } // Verify permissions. If the action attribute is set, then we scan the options. if ((string) $this->element['action']) { // Get the current user object. $user = MFactory::getUser(); // For new items we want a list of categories you are allowed to create in. if (!$this->form->getValue($name)) { foreach ($options as $i => $option) { // To take save or create in a category you need to have create rights for that category // unless the item is already in that category. // Unset the option if the user isn't authorised for it. In this field assets are always categories. if ($user->authorise('core.create', $extension . '.category.' . $option->value) != true) { unset($options[$i]); } } } else { $categoryOld = $this->form->getValue($name); foreach ($options as $i => $option) { // If you are only allowed to edit in this category but not edit.state, you should not get any // option to change the category. if ($user->authorise('core.edit.state', $extension . '.category.' . $categoryOld) != true) { if ($option->value != $categoryOld) { unset($options[$i]); } } elseif ($user->authorise('core.create', $extension . '.category.' . $option->value) != true && $option->value != $categoryOld) { unset($options[$i]); } } } } if (isset($this->element['show_root'])) { array_unshift($options, MHtml::_('select.option', '0', MText::_('MGLOBAL_ROOT'))); } } else { MError::raiseWarning(500, MText::_('MLIB_FORM_ERROR_FIELDS_CATEGORY_ERROR_EXTENSION_EMPTY')); } // Merge any additional options in the XML definition. $options = array_merge(parent::getOptions(), $options); return $options; }
protected function getOptions() { // Initialize variables. $options = array(); // Convert to name => name array. foreach (MCache::getStores() as $store) { $options[] = MHtml::_('select.option', $store, MText::_('MLIB_FORM_VALUE_CACHE_' . $store), 'value', 'text'); } $options = array_merge(parent::getOptions(), $options); return $options; }
protected function getOptions() { // Initialize variables. $options = array(); // Get the options from MSession. foreach (MSession::getStores() as $store) { $options[] = MHtml::_('select.option', $store, MText::_('MLIB_FORM_VALUE_SESSION_' . $store), 'value', 'text'); } // Merge any additional options in the XML definition. $options = array_merge(parent::getOptions(), $options); return $options; }
protected function _getCommand($msg, $name, $task, $list) { MHtml::_('behavior.framework'); $message = MText::_('MLIB_HTML_PLEASE_MAKE_A_SELECTION_FROM_THE_LIST'); $message = addslashes($message); if ($list) { $cmd = "if (document.adminForm.boxchecked.value==0){alert('{$message}');}else{if (confirm('{$msg}')){Miwi.submitbutton('{$task}');}}"; } else { $cmd = "if (confirm('{$msg}')){Miwi.submitbutton('{$task}');}"; } return $cmd; }
public static function groups($includeSuperAdmin = false) { if (!class_exists('WP_Roles')) { require_once ABSPATH . 'wp-includes/capabilities.php'; } $wp_roles = new WP_Roles(); $roles = $wp_roles->role_names; foreach ($roles as $key => $role) { $groups[] = MHtml::_('select.option', $key, $role); } return $groups; }
public function __construct($config = array()) { // Set the view name if (empty($this->_name)) { if (array_key_exists('name', $config)) { $this->_name = $config['name']; } else { $this->_name = $this->getName(); } } // Set the charset (used by the variable escaping functions) if (array_key_exists('charset', $config)) { $this->_charset = $config['charset']; } // User-defined escaping callback if (array_key_exists('escape', $config)) { $this->setEscape($config['escape']); } // Set a base path for use by the view if (array_key_exists('base_path', $config)) { $this->_basePath = $config['base_path']; } else { $this->_basePath = MPATH_COMPONENT; } // Set the default template search path if (array_key_exists('template_path', $config)) { // User-defined dirs $this->_setPath('template', $config['template_path']); } else { $this->_setPath('template', $this->_basePath . '/views/' . $this->getName() . '/tmpl'); } // Set the default helper search path if (array_key_exists('helper_path', $config)) { // User-defined dirs $this->_setPath('helper', $config['helper_path']); } else { $this->_setPath('helper', $this->_basePath . '/helpers'); } // Set the layout if (array_key_exists('layout', $config)) { $this->setLayout($config['layout']); } else { $this->setLayout('default'); } $this->baseurl = MUri::base(true); MHtml::_('behavior.framework'); if (MFactory::getApplication()->isAdmin()) { MHtml::_('behavior.modal'); } }
protected function getInput() { // Initialize variables. $attr = ''; // Initialize some field attributes. $attr .= $this->element['class'] ? ' class="' . (string) $this->element['class'] . '"' : ''; $attr .= (string) $this->element['disabled'] == 'true' ? ' disabled="disabled"' : ''; $attr .= $this->element['size'] ? ' size="' . (int) $this->element['size'] . '"' : ''; $attr .= $this->multiple ? ' multiple="multiple"' : ''; // Initialize JavaScript field attributes. $attr .= $this->element['onchange'] ? ' onchange="' . (string) $this->element['onchange'] . '"' : ''; // Get the field options. $options = $this->getOptions(); return MHtml::_('access.level', $this->name, $this->value, $attr, $options, $this->id); }
protected function getOptions() { // Initialize variables. $options = array(); // Initialize some field attributes. $filter = (string) $this->element['filter']; $exclude = (string) $this->element['exclude']; $stripExt = (string) $this->element['stripext']; $hideNone = (string) $this->element['hide_none']; $hideDefault = (string) $this->element['hide_default']; // Get the path in which to search for file options. $path = (string) $this->element['directory']; if (!is_dir($path)) { $path = MPATH_ROOT . '/' . $path; } // Prepend some default options based on field attributes. if (!$hideNone) { $options[] = MHtml::_('select.option', '-1', MText::alt('MOPTION_DO_NOT_USE', preg_replace('/[^a-zA-Z0-9_\\-]/', '_', $this->fieldname))); } if (!$hideDefault) { $options[] = MHtml::_('select.option', '', MText::alt('MOPTION_USE_DEFAULT', preg_replace('/[^a-zA-Z0-9_\\-]/', '_', $this->fieldname))); } // Get a list of files in the search path with the given filter. $files = MFolder::files($path, $filter); // Build the options list from the list of files. if (is_array($files)) { foreach ($files as $file) { // Check to see if the file is in the exclude mask. if ($exclude) { if (preg_match(chr(1) . $exclude . chr(1), $file)) { continue; } } // If the extension is to be stripped, do it. if ($stripExt) { $file = MFile::stripExt($file); } $options[] = MHtml::_('select.option', $file, $file); } } // Merge any additional options in the XML definition. $options = array_merge(parent::getOptions(), $options); return $options; }
/** * Updates a particular model. * If update is successful, the browser will be redirected to the 'show' page. */ public function actionUpdate() { $model = $this->loadModel(); // explicitly set model scenario to be current action //$model->setScenario($this->action->id); // whether data is passed if (isset($_POST['Location'])) { // collect user input data $model->attributes = $_POST['Location']; // validate with the current action as scenario and save without validation if (($validated = $model->validate()) !== false && ($saved = $model->save(false)) !== false) { // set success message MUserFlash::setTopSuccess(Yii::t('hint', 'The "{title}" location record has been updated.', array('{title}' => MHtml::wrapInTag($model->title, 'strong')))); // go to the 'show' page $this->redirect(array('show', 'id' => $model->id)); } } $this->render($this->action->id, array('model' => $model)); }
protected function getGroups() { // Initialize variables. $groups = array(); $keyField = $this->element['key_field'] ? (string) $this->element['key_field'] : 'id'; $keyValue = $this->form->getValue($keyField); // If the timezone is not set use the server setting. if (strlen($this->value) == 0 && empty($keyValue)) { $this->value = MFactory::getConfig()->get('offset'); } // Get the list of time zones from the server. $zones = DateTimeZone::listIdentifiers(); // Build the group lists. foreach ($zones as $zone) { // Time zones not in a group we will ignore. if (strpos($zone, '/') === false) { continue; } // Get the group/locale from the timezone. list($group, $locale) = explode('/', $zone, 2); // Only use known groups. if (in_array($group, self::$zones)) { // Initialize the group if necessary. if (!isset($groups[$group])) { $groups[$group] = array(); } // Only add options where a locale exists. if (!empty($locale)) { $groups[$group][$zone] = MHtml::_('select.option', $zone, str_replace('_', ' ', $locale), 'value', 'text', false); } } } // Sort the group lists. ksort($groups); foreach ($groups as $zone => &$location) { sort($location); } // Merge any additional groups in the XML definition. $groups = array_merge(parent::getGroups(), $groups); return $groups; }
protected function getOptions() { // Initialize variables. $options = array(); foreach ($this->element->children() as $option) { // Only add <option /> elements. if ($option->getName() != 'option') { continue; } // Create a new option object based on the <option /> element. $tmp = MHtml::_('select.option', (string) $option['value'], trim((string) $option), 'value', 'text', (string) $option['disabled'] == 'true'); // Set some option attributes. $tmp->class = (string) $option['class']; // Set some JavaScript option attributes. $tmp->onclick = (string) $option['onclick']; // Add the option object to the result set. $options[] = $tmp; } reset($options); return $options; }
public static function relative($date, $unit = null, $time = null) { if (is_null($time)) { // Get now $time = MFactory::getDate('now'); } // Get the difference in seconds between now and the time $diff = strtotime($time) - strtotime($date); // Less than a minute if ($diff < 60) { return MText::_('MLIB_HTML_DATE_RELATIVE_LESSTHANAMINUTE'); } // Round to minutes $diff = round($diff / 60); // 1 to 59 minutes if ($diff < 60 || $unit == 'minute') { return MText::plural('MLIB_HTML_DATE_RELATIVE_MINUTES', $diff); } // Round to hours $diff = round($diff / 60); // 1 to 23 hours if ($diff < 24 || $unit == 'hour') { return MText::plural('MLIB_HTML_DATE_RELATIVE_HOURS', $diff); } // Round to days $diff = round($diff / 24); // 1 to 6 days if ($diff < 7 || $unit == 'day') { return MText::plural('MLIB_HTML_DATE_RELATIVE_DAYS', $diff); } // Round to weeks $diff = round($diff / 7); // 1 to 4 weeks if ($diff <= 4 || $unit == 'week') { return MText::plural('MLIB_HTML_DATE_RELATIVE_WEEKS', $diff); } // Over a month, return the absolute time return MHtml::_('date', $date); }
public static function categories($extension, $config = array('filter.published' => array(0, 1))) { $hash = md5($extension . '.' . serialize($config)); if (!isset(self::$items[$hash])) { $config = (array) $config; $db = MFactory::getDbo(); $query = $db->getQuery(true); $query->select('a.id, a.title, a.level, a.parent_id'); $query->from('#__categories AS a'); $query->where('a.parent_id > 0'); // Filter on extension. $query->where('extension = ' . $db->quote($extension)); // Filter on the published state if (isset($config['filter.published'])) { if (is_numeric($config['filter.published'])) { $query->where('a.published = ' . (int) $config['filter.published']); } elseif (is_array($config['filter.published'])) { MArrayHelper::toInteger($config['filter.published']); $query->where('a.published IN (' . implode(',', $config['filter.published']) . ')'); } } $query->order('a.lft'); $db->setQuery($query); $items = $db->loadObjectList(); // Assemble the list options. self::$items[$hash] = array(); foreach ($items as &$item) { $repeat = $item->level - 1 >= 0 ? $item->level - 1 : 0; $item->title = str_repeat('- ', $repeat) . $item->title; self::$items[$hash][] = MHtml::_('select.option', $item->id, $item->title); } // Special "Add to root" option: self::$items[$hash][] = MHtml::_('select.option', '1', MText::_('MLIB_HTML_ADD_TO_ROOT')); } return self::$items[$hash]; }
/** * Updates a particular model. * If update is successful, the browser will be redirected to the 'show' page. */ public function actionUpdate() { if (($model = $this->loadModel()) === null) { // model not found MUserFlash::setTopError(Yii::t('modelNotFound', $this->id)); $this->redirect($this->getGotoUrl()); } // explicitly set model scenario to be current action //$model->setScenario($this->action->id); // whether data is passed if (isset($_POST['CompanyPayment'])) { // collect user input data $model->attributes = $_POST['CompanyPayment']; // validate with the current action as scenario and save without validation if (($validated = $model->validate()) !== false && ($saved = $model->save(false)) !== false) { // set success message MUserFlash::setTopSuccess(Yii::t('hint', 'The company payment record number "{paymentNumber}" has been updated.', array('{paymentNumber}' => MHtml::wrapInTag(empty($model->paymentNumber) ? $model->id : $model->paymentNumber, 'strong')))); // go to the 'show' page $this->redirect(array('show', 'id' => $model->id)); } } $this->render($this->action->id, array('model' => $model)); }
/** * Updates a particular model. * If update is successful, the browser will be redirected to the 'show' page. */ public function actionUpdate() { $model = $this->loadModel(array('with' => array('allCompany2Project', 'allManager2Project'))); if ($model === null) { // model not found MUserFlash::setTopError(Yii::t('modelNotFound', $this->id)); $this->redirect($this->getGotoUrl()); } // explicitly set model scenario to be current action //$model->setScenario($this->action->id); // whether data is passed if (isset($_POST['Project'])) { // collect user input data $model->attributes = $_POST['Project']; // validate with the current action as scenario and save without validation if (($validated = $model->validate()) !== false && ($saved = $model->save(false)) !== false) { if (isset($_POST['Company2Project'])) { // assigned companies $hasCompany = isset($model->allCompany2Project[0]->id); if (!$hasCompany) { $model->allCompany2Project = array(0 => new Company2Project('create')); $model->allCompany2Project[0]->projectId = $model->id; } foreach ($model->allCompany2Project as $company2Project) { // collect user input data $company2Project->attributes = $_POST['Company2Project']; // at the crossroads: which action is expected to be performed if ($hasCompany && empty($company2Project->companyId)) { // un-assigned associated record $company2Project->delete(); } else { // validate and create/update record $company2Project->save(); } } } if (isset($_POST['User2Project'])) { // assigned managers $hasManager = isset($model->allManager2Project[0]->id); if (!$hasManager) { $model->allManager2Project = array(0 => new User2Project('create')); $model->allManager2Project[0]->projectId = $model->id; } foreach ($model->allManager2Project as $manager2Project) { // collect user input data $manager2Project->attributes = $_POST['User2Project']; // at the crossroads: which action is expected to be performed if ($hasManager && empty($manager2Project->userId)) { // un-assigned associated record $manager2Project->delete(); } else { // validate and create/update record $manager2Project->save(); } } } // set success message MUserFlash::setTopSuccess(Yii::t('hint', 'The "{title}" project record has been updated.', array('{title}' => MHtml::wrapInTag($model->title, 'strong')))); // go to the 'show' page $this->redirect(array('show', 'id' => $model->id)); } } if (!isset($model->allCompany2Project[0])) { // new associated company $model->allCompany2Project = array(0 => new Company2Project('create')); $model->allCompany2Project[0]->projectId = $model->id; } if (!isset($model->allManager2Project[0])) { // new associated manager $model->allManager2Project = array(0 => new User2Project('create')); $model->allManager2Project[0]->projectId = $model->id; $model->allManager2Project[0]->role = User2Project::MANAGER; } $this->render($this->action->id, array('model' => $model)); }
public static function assetgrouplist($name, $selected, $attribs = null, $config = array()) { static $count; $options = MHtmlAccess::assetgroups(); if (isset($config['title'])) { array_unshift($options, MHtml::_('select.option', '', $config['title'])); } return MHtml::_('select.genericlist', $options, $name, array('id' => isset($config['id']) ? $config['id'] : 'assetgroups_' . ++$count, 'list.attr' => is_null($attribs) ? 'class="inputbox" size="3"' : $attribs, 'list.select' => (int) $selected)); }
<html> <head> <title>MONC-PHP</title> <meta http-equiv="content-type" content="text/html; charset=UTF-8"/> <?php echo MHtml::css('bower_components/bootstrap/dist/css/bootstrap.min.css'); ?> <?php echo MHtml::css('css/main.css'); ?> <?php echo MHtml::javascript('bower_components/jquery/jquery.min.js'); ?> <?php echo MHtml::javascript('bower_components/bootstrap/dist/js/bootstrap.min.js'); ?> </head> <body> <?php echo $content; ?> <div class="footer"> <div id="footer-copyright"> <div class="container"> <div class="row"> <div class="col-lg-12 clearfix"> <p class="copyright">
for (var key in opts) { this[key] = opts[key] } } var app = { config: { res: '<?php echo param('res'); ?> ' } } </script> <title><?php echo MHtml::encode($this->pageTitle); ?> </title> </head> <body> <script type="text/javascript"> var mainColor = '#428bca'; </script> <div id="top-bar" class="navbar navbar-default "> <?php $this->renderPartial('/admin/_header'); ?> </div>
/** * Updates a particular model. * If update is successful, the browser will be redirected to the 'show' page. */ public function actionUpdate() { $model = $this->loadModel(array('with' => array('allUser2Company', 'allLocation'))); if ($model === null) { // model not found MUserFlash::setTopError(Yii::t('modelNotFound', $this->id)); $this->redirect($this->getGotoUrl()); } // explicitly set model scenario to be current action //$model->setScenario($this->action->id); // whether data is passed if (isset($_POST['Company'])) { // collect user input data $model->attributes = $_POST['Company']; // validate with the current action as scenario and save without validation if (($validated = $model->validate()) !== false && ($saved = $model->save(false)) !== false) { if (isset($_POST['User2Company'])) { // assigned users $hasUser = isset($model->allUser2Company[0]->id); if (!$hasUser) { $model->allUser2Company = array(0 => new User2Company('create')); $model->allUser2Company[0]->companyId = $model->id; } foreach ($model->allUser2Company as $user2Company) { // collect user input data $user2Company->attributes = $_POST['User2Company']; $user2Company->position = 'owner'; // at the crossroads: which action is expected to be performed if ($hasUser && empty($user2Company->userId)) { // un-assigned associated record $user2Company->delete(); } else { // validate and create/update record $user2Company->save(); } } } if (isset($_POST['Location'])) { // assigned locations if (!isset($model->allLocation[0]->id)) { $model->allLocation = array(0 => new Location('create')); } foreach ($model->allLocation as $location) { // collect user input data $location->attributes = $_POST['Location']; // validate and create/update record if ($location->save()) { $location2Record = new Location2Record('create'); $location2Record->locationId = $location->id; $location2Record->record = get_class($model); $location2Record->recordId = $model->id; $location2Record->save(); } } } // set success message MUserFlash::setTopSuccess(Yii::t('hint', 'The "{title}" company record has been updated.', array('{title}' => MHtml::wrapInTag($model->title, 'strong')))); // go to the 'show' page $this->redirect(array('show', 'id' => $model->id)); } } if (!isset($model->allUser2Company[0])) { // new associated user $model->allUser2Company = array(0 => new User2Company('create')); $model->allUser2Company[0]->companyId = $model->id; } if (!isset($model->allLocation[0])) { // new associated location $model->allLocation = array(0 => new Location('create')); } // display the update form $this->render($this->action->id, array('model' => $model)); }