/** * Render submit button * * @param array $params * @param string $content * @param Smarty $smarty * @param boolean $repeat * @return string */ function smarty_block_submit($params, $content, &$smarty, &$repeat) { $params['type'] = 'submit'; $accesskey = array_var($params, 'accesskey', 's'); if ($accesskey) { $params['accesskey'] = 's'; } // if $caption = clean(isset($params['not_lang']) ? $content : lang($content)); if ($accesskey) { $first = null; $first_pos = null; $to_highlight = array(strtolower($accesskey), strtoupper($accesskey)); foreach ($to_highlight as $accesskey_to_highlight) { if (($pos = strpos($caption, $accesskey_to_highlight)) === false) { continue; } // if if ($first_pos === null || $pos < $first_pos) { $first = $accesskey_to_highlight; $first_pos = $pos; } // if } // foreach if ($first !== null) { $caption = str_replace_first($first, "<u>{$first}</u>", $caption); } // if } // if // And done... return open_html_tag('button', $params) . '<span><span>' . $caption . '</span></span></button>'; }
/** * Render star for a given user page * * @param array $params * @param Smarty $smarty * @return string */ function smarty_function_object_user_star($params, &$smarty) { static $ids = array(); $starred_user_id = array_var($params, 'starred_user_id'); $starred_page_type = array_var($params, 'starred_page_type'); $starred_by_user_id = array_var($params, 'starred_by_user_id'); $project_id = array_var($params, 'project_id'); $id = array_var($params, 'id'); if (empty($id)) { do { $id = 'object_star_' . make_string(40); } while (in_array($id, $ids)); } // if $ids[] = $id; $link = mysql_connect(DB_HOST, DB_USER, DB_PASS); mysql_select_db(DB_NAME, $link); $query = "select * from healingcrystals_starred_user_pages where starred_by_user_id='" . $starred_by_user_id . "' and starred_user_id='" . $starred_user_id . "' and starred_page_type='" . $starred_page_type . "'"; $result = mysql_query($query); $is_starred = false; if (mysql_num_rows($result)) { $is_starred = true; } mysql_close($link); if ($is_starred) { $params = array('id' => $id, 'href' => assemble_url('unstar_user_' . $starred_page_type . '_page', array('project_id' => $project_id, 'user_id' => $starred_by_user_id)) . '&starred_user_id=' . $starred_user_id, 'title' => lang('Unstar this object'), 'class' => 'object_star'); $result = open_html_tag('a', $params) . '<img src="' . get_image_url('icons/star-small.gif') . '" alt="" /></a>'; } else { $params = array('id' => $id, 'href' => assemble_url('star_user_' . $starred_page_type . '_page', array('project_id' => $project_id, 'user_id' => $starred_by_user_id)) . '&starred_user_id=' . $starred_user_id, 'title' => lang('Star this object'), 'class' => 'object_star'); $result = open_html_tag('a', $params) . '<img src="' . get_image_url('icons/unstar-small.gif') . '" alt="" /></a>'; } // if return $result . "\n<script type=\"text/javascript\">App.layout.init_star_unstar_link('" . $id . "')</script>"; }
/** * Render checkbox field * * Parameters: * * - name - Field name * - value - Initial value. Value of this field is ignored if checked attribute * is present * - array of additional attributes * * @param array $params * @param Smarty $smarty * @return string */ function smarty_function_checkbox_field($params, &$smarty) { $params['type'] = 'checkbox'; if (array_key_exists('checked', $params)) { if ($params['checked']) { $params['checked'] = 'checked'; } else { unset($params['checked']); } // if } // if $class = array_var($params, 'class'); if ($class == '') { $classes[] = 'inline'; $classes[] = 'input_checkbox'; } else { $classes = explode(' ', $class); if (!in_array('inline', $classes)) { $classes[] = 'inline'; } // if $classes[] = 'input_checkbox'; } // if $params['class'] = implode(' ', $classes); if (!isset($params['value'])) { $params['value'] = '1'; } // if return open_html_tag('input', $params, true); }
/** * Show object visibility if it's private * * @param array $params * @param Smarty $smarty * @return string */ function smarty_function_object_visibility($params, &$smarty) { static $ids = array(); $object = array_var($params, 'object'); if (!instance_of($object, 'ProjectObject')) { return new InvalidParamError('object', $object, '$object is not valid instance of ProjectObject class', true); } // if if ($object->getVisibility() > VISIBILITY_PRIVATE) { return ''; } // if $user = array_var($params, 'user'); if (!instance_of($user, 'User')) { return new InvalidParamError('user', $user, '$user is expected to be an instance of User class', true); } // if if (!$user->canSeePrivate()) { return ''; } // if $id = array_var($params, 'id'); if (empty($id)) { do { $id = 'object_visibility_' . make_string(40); } while (in_array($id, $ids)); } // if $ids[] = $id; return open_html_tag('a', array('href' => assemble_url('project_object_visibility', array('project_id' => $object->getProjectId(), 'object_id' => $object->getId())), 'title' => lang('Private :type', array('type' => Inflector::humanize($object->getType()))), 'class' => 'object_visibility', 'id' => $id)) . '<img src="' . get_image_url('private.gif') . '" alt="" /></a><script type="text/javascript">App.widgets.ObjectVisibility.init("' . $id . '");</script>'; }
/** * with_successive_milestones helper * * @param array $params * @param Smarty $smarty * @return string */ function smarty_function_with_successive_milestones($params, &$smarty) { static $counter = 1; $name = array_var($params, 'name'); if (empty($name)) { return new InvalidParamError('name', $name, '$name value is required', true); } // if $milestone = array_var($params, 'milestone'); if (!instance_of($milestone, 'Milestone')) { return new InvalidParamError('milestone', $milestone, '$milestone value is expected to be an instance of Milestone class', true); } // if $id = array_var($params, 'id'); if (empty($id)) { $id = 'with_successive_milestones_' . $counter; $counter++; } // if $value = array_var($params, 'value'); $action = array_var($value, 'action', 'dont_move'); $milestones = array_var($value, 'milestones'); if (!is_array($milestones)) { $milestones = array(); } // if $logged_user = $smarty->get_template_vars('logged_user'); $successive_milestones = Milestones::findSuccessiveByMilestone($milestone, STATE_VISIBLE, $logged_user->getVisibility()); if (!is_foreachable($successive_milestones)) { return '<p class="details">' . lang('This milestone does not have any successive milestones') . '</p>'; } // if $result = "<div class=\"with_successive_milestones\">\n<div class=\"options\">\n"; $options = array('dont_move' => lang("Don't change anything"), 'move_all' => lang('Adjust all successive milestone by the same number of days'), 'move_selected' => lang('Adjust only selected successive milestones by the same number of days')); foreach ($options as $k => $v) { $radio = radio_field($name . '[action]', $k == $action, array('value' => $k, 'id' => $id . '_' . $k)); $label = label_tag($v, $id . '_' . $k, false, array('class' => 'inline'), ''); $result .= '<span class="block">' . $radio . ' ' . $label . "</span>\n"; } // if $result .= "</div>\n<div class=\"successive_milestones\">"; foreach ($successive_milestones as $successive_milestone) { $input_attributes = array('name' => $name . '[milestones][]', 'id' => $id . '_milestones_' . $successive_milestone->getId(), 'type' => 'checkbox', 'value' => $successive_milestone->getId(), 'class' => 'auto'); if (in_array($successive_milestone->getId(), $milestones)) { $input_attributes['checked'] = true; } // if $input = open_html_tag('input', $input_attributes, true); $label = label_tag($successive_milestone->getName(), $id . '_milestones_' . $successive_milestone->getId(), false, array('class' => 'inline'), ''); $result .= '<span class="block">' . $input . ' ' . $label . "</span>\n"; } // foreach $result .= "</div>\n</div>\n"; return $result; }
/** * Render button * * Parameters: * * - common anchor parameter * * - method - if POST that this button will be send POST request. Method works * only if href parameter is present * - confirm - enforces confirmation dialog * codes * * @param array $params * @param string $content * @param Smarty $smarty * @param boolean $repeat * @return string */ function smarty_block_link($params, $content, &$smarty, &$repeat) { $href = ''; if (isset($params['href'])) { $href = $params['href']; if (str_starts_with($href, '?')) { $href = assemble_from_string($params['href']); } // if } // if $params['href'] = $href; $confirm = ''; if (array_key_exists('confirm', $params)) { $confirm = lang(trim($params['confirm'])); unset($params['confirm']); } // if $post = false; if (array_key_exists('method', $params)) { if (strtolower($params['method']) == 'post') { $post = true; } // if unset($params['method']); } // if if ($post || $confirm) { $execution = $post ? 'App.postLink(' . var_export($href, true) . ')' : 'location.href = ' . var_export($href, true); if ($confirm) { $params['onclick'] = "if(confirm(" . var_export($confirm, true) . ")) { {$execution}; } return false;"; } else { $params['onclick'] = "{$execution}; return false;"; } // if } // if $not_lang = false; if (isset($params['not_lang'])) { $not_lang = (bool) $params['not_lang']; unset($params['not_lang']); } // if if (array_key_exists('id', $params) && strlen($params['id']) == 0) { unset($params['id']); } // if if (array_key_exists('title', $params)) { $params['title'] = lang($params['title']); } // if $text = $not_lang ? $content : lang($content); return open_html_tag('a', $params) . $text . '</a>'; }
/** * Render input text * * Parameters: * * - name - field name * - value - initial value * - array of additional attributes * * @param array $params * @param Smarty $smarty * @return string */ function smarty_function_text_field($params, &$smarty) { $type = 'text'; if (!empty($params['type'])) { $type = array_var($params, 'type'); unset($params['type']); } // if $params['type'] = $type; return open_html_tag('input', $params, true); }
/** * Render select tags control * * @param array $params * @param Smarty $smarty * @return string */ function smarty_function_select_tags($params, &$smarty) { $value = array_var($params, 'value', null, true); if (is_array($value)) { $value = implode(', ', $value); } // if $params['type'] = 'text'; $params['value'] = $value; return open_html_tag('input', $params, true); }
/** * Render project group link * * Parameters: * * - group - ProjectGroup * * @param array $params * @param Smarty $smarty * @return string */ function smarty_function_project_group_link($params, &$smarty) { $group = array_var($params, 'group'); if (!instance_of($group, 'ProjectGroup')) { return new InvalidParamError('group', $group, '$group is expected to be an instance of ProjectGroup class', true); } // if unset($params['group']); $params['href'] = $group->getViewUrl(); return open_html_tag('a', $params) . clean($group->getName()) . '</a>'; }
/** * Render icon IMG tag * * @access public * @param string $filename Icon filename * @param string $alt Value of alt attrbute for IMG * @param array $attributes Array of additional attributes * @return string */ function render_icon($filename, $alt = '', $attributes = null) { if(is_array($attributes)) { $attributes['src'] = icon_url($filename); $attributes['alt'] = $alt; } else { $attributes = array( 'src' => icon_url($filename), 'alt' => $alt ); // array } // if return open_html_tag('img', $attributes, true); } // render_icon
/** * Render textarea * * @param array $params * @param string $content * @param Smarty $smarty * @param boolean $repeat * @return string */ function smarty_block_textarea_field($params, $content, &$smarty, &$repeat) { if (!isset($params['rows'])) { $params['rows'] = 10; } // if if (!isset($params['cols'])) { $params['cols'] = 48; } // if return open_html_tag('textarea', $params) . clean($content) . '</textarea>'; }
/** * Generate image tag based on properties (same as for image_url) * * @param array $params * @param Smarty $smarty * @return string */ function smarty_function_image($params, &$smarty) { require_once SMARTY_PATH . '/plugins/function.image_url.php'; $name = array_var($params, 'name', null, true); $module = array_var($params, 'module', null, true); $params['src'] = smarty_function_image_url(array('name' => $name, 'module' => $module), $smarty); if (!isset($params['alt'])) { $params['alt'] = ''; } // if return open_html_tag('img', $params, true); }
/** * Render button * * Parameters: * * - common button parameter * - href - when button is clicked this link is opened * - method - if POST that this button will be send POST request. Method works * only if href parameter is present * - confirm - enforces confirmation dialog * - not_lang - if true content will not be matched agains registered language * codes * * @param array $params * @param string $content * @param Smarty $smarty * @param boolean $repeat * @return string */ function smarty_block_button($params, $content, &$smarty, &$repeat) { if (!isset($params['type'])) { $params['type'] = 'button'; } // if $href = ''; if (isset($params['href'])) { $href = $params['href']; if (str_starts_with($href, '?')) { $href = assemble_from_string($params['href']); } // if unset($params['href']); } // if $confirm = ''; if (isset($params['confirm'])) { $confirm = trim($params['confirm']); unset($params['confirm']); } // if $post = false; if (isset($params['method'])) { $post = strtolower($params['method']) == 'post'; unset($params['method']); } // if if ($href) { $execution = $post ? 'App.postLink(' . var_export($href, true) . ')' : 'location.href = ' . var_export($href, true); if ($confirm) { $params['onclick'] = "if(confirm(" . var_export($confirm, true) . ")) { {$execution}; } return false;"; } else { $params['onclick'] = "{$execution}; return false;"; } // if } else { if ($confirm) { $params['onclick'] = "return confirm(" . var_export($confirm, true) . ")"; } // if } // if $not_lang = false; if (isset($params['not_lang'])) { $not_lang = (bool) $params['not_lang']; unset($params['not_lang']); } // if $text = $not_lang ? $content : lang($content); return open_html_tag('button', $params) . '<span><span>' . clean($text) . '</span></span></button>'; }
/** * Wrap form field into a DIV * * Properties: * * - field - field name * - errors - errors container (ValidationErrors instance) * - show_errors - show errors list inside of field wrapper * * @param array $params * @param string $content * @param Smarty $smarty * @param boolean $repeat * @return null */ function smarty_block_wrap($params, $content, &$smarty, &$repeat) { $field = array_var($params, 'field'); if (empty($field)) { return new InvalidParamError('field', $field, "'field' property is required for 'wrap_field' helper", true); } // if $classes = array(); if (isset($params['class'])) { $classes = explode(' ', $params['class']); unset($params['class']); } // if if (!in_array('ctrlHolder', $classes)) { $classes[] = 'ctrlHolder'; } // if $error_messages = null; if (isset($params['errors'])) { $errors = $params['errors']; } else { $errors = $smarty->get_template_vars('errors'); } // if if (instance_of($errors, 'ValidationErrors')) { if ($errors->hasError($field)) { $classes[] = 'error'; $error_messages = $errors->getFieldErrors($field); } // if } // if $show_errors = array_var($params, 'show_errors', true); $listed_errors = ''; if (is_foreachable($error_messages) && $show_errors) { require_once $smarty->_get_plugin_filepath('function', 'field_errors'); $listed_errors = smarty_function_field_errors(array('field' => $field, 'errors' => $errors), $smarty); } // if $aid = array_var($params, 'aid'); if ($aid) { $aid = '<p class="aid">' . clean(lang($aid)) . '</p>'; } // if // Unset helper properties, we need this for attributes unset($params['field']); unset($params['errors']); unset($params['show_errors']); unset($params['aid']); $params['class'] = implode(' ', $classes); return open_html_tag('div', $params) . "\n{$listed_errors}\n" . $content . $aid . "\n</div>"; }
/** * Display invoice link * * Params: * * - invoice * * @param array $params * @param Smarty $smarty * @return string */ function smarty_function_invoice_link($params, &$smarty) { $invoice = array_var($params, 'invoice', null, true); if (!instance_of($invoice, 'Invoice')) { return new InvalidParamError('invoice', $invoice, '$invoice is expected to be an instance of Invoice class', true); } // if if (array_var($params, 'company')) { $params['href'] = $invoice->getCompanyViewUrl(); } else { $params['href'] = $invoice->getViewUrl(); } // if return open_html_tag('a', $params) . clean($invoice->getName()) . '</a>'; }
/** * Render widgert * * @param array $params * @param Smarty $smarty * @return string */ function smarty_function_select_project_permissions($params, &$smarty) { static $counter = 1; $id = array_var($params, 'id'); if (empty($id)) { $id = 'select_project_permissions_' . $counter; $counter++; } // if $name = array_var($params, 'name'); $value = array_var($params, 'value', array()); $permissions = Permissions::findProject(); if (is_foreachable($permissions)) { $levels = array(PROJECT_PERMISSION_NONE => lang('No Access'), PROJECT_PERMISSION_ACCESS => lang('Has Access'), PROJECT_PERMISSION_CREATE => lang('and Can Create'), PROJECT_PERMISSION_MANAGE => lang('and Can Manage')); $result = '<table class="select_project_permissions" id="' . clean($id) . '"> <tr> <th>' . lang('Object') . '</th> <th colspan="4">' . lang('Permissions Level') . '</th> </tr>'; $counter = 1; foreach ($permissions as $permission => $permission_name) { $permission_value = array_var($value, $permission); if ($permission_value === null) { $permission_value = PROJECT_PERMISSION_NONE; } // if $result .= '<tr class="' . ($counter % 2 ? 'odd' : 'even') . ' hoverable"><td class="permission_name"><span>' . $permission_name . '</span></td>'; foreach ($levels as $level_value => $level_label) { $input_id = 'select_permission_' . $permission . '_' . $level_value; $input_attributes = array('name' => $name . '[' . $permission . ']', 'value' => $level_value, 'type' => 'radio', 'class' => 'inline', 'id' => $input_id); if ($level_value == $permission_value) { $input_attributes['checked'] = 'checked'; } // if $label_attributes = array('for' => $input_id, 'class' => 'inline'); $cell_class = $level_value == PROJECT_PERMISSION_NONE ? 'no_access' : 'has_access'; $result .= '<td class="permission_value ' . $cell_class . '">' . open_html_tag('input', $input_attributes, true) . ' ' . open_html_tag('label', $label_attributes) . clean($level_label) . '</label></td>'; } // if $result .= '</tr>'; $counter++; } // foreach return $result . '</table><script type="text/javascript">App.widgets.SelectProjectPermissions.init("' . clean($id) . '")</script>'; } // if }
/** * Render yes - no widget * * Parameters: * * - name - name used for radio group * - value - if TRUE Yes will be selected, No will be selected otherwise * - yes - yes lang, default is 'Yes' * - no - no lang, default is 'No' * - id - ID base, if not present script will generate one * * @param array $params * @param Smarty $smarty * @return string */ function smarty_function_yes_no($params, &$smarty) { static $ids; $name = array_var($params, 'name'); if (empty($name)) { return new InvalidParamError('name', $name, "'name' paremeter is required for 'yes_no' helper", true); } // if $id = array_var($params, 'id'); if (empty($id)) { if (!is_array($ids)) { $ids = array(); } // if do { $id = 'yesNo' . rand(); } while (in_array($id, $ids)); $ids[] = $id; } // if $value = (bool) array_var($params, 'value'); $yes_input_attributes = $no_input_attributes = array('name' => $name, 'type' => 'radio', 'class' => 'inline', 'disabled' => (bool) array_var($params, 'disabled')); // array $yes_input_attributes['id'] = $id . 'YesInput'; $yes_input_attributes['value'] = '1'; $no_input_attributes['id'] = $id . 'NoInput'; $no_input_attributes['value'] = '0'; $no_input_attributes['class'] = 'inline'; if ($value) { $yes_input_attributes['checked'] = 'checked'; } else { $no_input_attributes['checked'] = 'checked'; } // if $onOff = (bool) array_var($params, 'on_off'); if ($onOff) { $yesDisplay = lang("On"); $noDisplay = lang("Off"); } else { $yesDisplay = lang("Yes"); $noDisplay = lang("No"); } $yes = open_html_tag('label', array('for' => $yes_input_attributes['id'], 'class' => 'inline')) . open_html_tag('input', $yes_input_attributes, true) . array_var($params, 'yes', $yesDisplay) . '</label>'; $no = open_html_tag('label', array('for' => $no_input_attributes['id'], 'class' => 'inline')) . open_html_tag('input', $no_input_attributes, true) . array_var($params, 'no', $noDisplay) . '</label>'; return "<span class=\"yes_no\">{$yes} {$no}</span>"; }
/** * Render role_permission_value widget * * Params: * * - permission - String - Permission name * - role - Role - System role * * @param array $params * @param Smarty $smarty * @return string */ function smarty_function_role_permission_value($params, &$smarty) { $permission = array_var($params, 'permission'); if (empty($permission)) { return new InvalidParamError('permission', $permission, '$permission value is exepected to be valid system permission name', true); } // if $role = array_var($params, 'role'); if (!instance_of($role, 'Role')) { return new InvalidParamError('role', $role, '$role is exepected to be valid Role instance', true); } // if $yes_for_admins = array_var($params, 'yes_for_admins', true, true); $id = 'role_permission_value_' . $permission . '_' . $role->getId(); $result = open_html_tag('input', array('type' => 'checkbox', 'class' => 'auto', 'checked' => $yes_for_admins ? $role->getPermissionValue('admin_access') || $role->getPermissionValue($permission) : $role->getPermissionValue($permission), 'id' => $id, 'set_permission_value_url' => $role->getSetPermissionValueUrl($permission), 'disabled' => $yes_for_admins && $role->getPermissionValue('admin_access'))); return $result . '<script type="text/javascript">App.system.RolePermissionValue.init("' . $id . '")</script>'; }
/** * Render label * * Paramteres: * * - after_text - text that will be put after label text. Default is '' * - required - puts a star after label text if this field is required * * @param array $params * @param string $connect * @param Smarty $smarty * @param boolean $repeat * @return string */ function smarty_block_label($params, $content, &$smarty, &$repeat) { $after_text = ''; if (isset($params['after_text'])) { $after_text = $params['after_text']; unset($params['after_text']); } // if $is_required = false; if (isset($params['required'])) { $is_required = (bool) $params['required']; unset($params['required']); } // if $not_lang = (bool) array_var($params, 'not_lang'); $text = $not_lang ? $content : lang($content); $render_text = trim($text) . $after_text; if ($is_required) { $render_text = $render_text . '<em>*</em>'; } // if return open_html_tag('label', $params) . $render_text . '</label>'; }
/** * Render star for a given object * * @param array $params * @param Smarty $smarty * @return string */ function smarty_function_object_star($params, &$smarty) { static $ids = array(); $object = array_var($params, 'object'); if (!instance_of($object, 'ProjectObject')) { return new InvalidParamError('object', $object, '$object is not valid instance of ProjectObject class', true); } // if $user = array_var($params, 'user'); if (!instance_of($user, 'User')) { return new InvalidParamError('user', $user, '$user is expected to be an instance of User class', true); } // if $id = array_var($params, 'id'); if (empty($id)) { do { $id = 'object_star_' . make_string(40); } while (in_array($id, $ids)); } // if $ids[] = $id; if ($object->can_be_starred) { if ($object->isStarred($user)) { $params = array('id' => $id, 'href' => $object->getUnstarUrl(), 'title' => lang('Unstar this object'), 'class' => 'object_star'); $result = open_html_tag('a', $params) . '<img src="' . get_image_url('icons/star-small.gif') . '" alt="" /></a>'; } else { $params = array('id' => $id, 'href' => $object->getStarUrl(), 'title' => lang('Star this object'), 'class' => 'object_star'); $result = open_html_tag('a', $params) . '<img src="' . get_image_url('icons/unstar-small.gif') . '" alt="" /></a>'; } // if return $result . "\n<script type=\"text/javascript\">App.layout.init_star_unstar_link('" . $id . "')</script>"; } else { return ''; } // if }
/** * Render input file * * Parameters: * * - name - field name * - value - initial value * - array of additional attributes * * @param array $params * @param Smarty $smarty * @return string */ function smarty_function_file_field($params, &$smarty) { $params['type'] = 'file'; return open_html_tag('input', $params, true); }
/** * Show single milestone * * @param void * @return null */ function view() { $show_archived_pages = '0'; $show_completed_tkts = '0'; if ($this->active_milestone->isNew()) { $this->httpError(HTTP_ERR_NOT_FOUND); } // if if (!$this->active_milestone->canView($this->logged_user)) { $this->httpError(HTTP_ERR_FORBIDDEN); } // if ProjectObjectViews::log($this->active_milestone, $this->logged_user); if ($this->request->isApiCall()) { $this->serveData($this->active_milestone, 'milestone', array('describe_assignees' => true)); } else { $page = (int) $this->request->get('page'); if ($page < 1) { $page = 1; } // if $show_all = $this->request->get('show_all'); if (!empty($show_all) && $show_all == '1' && !isset($_GET['comment_id'])) { $comments = null; $pagination = null; } else { $show_all = ''; list($comments, $pagination) = $this->active_milestone->paginateComments($page, $this->active_milestone->comments_per_page, $this->logged_user->getVisibility()); } $comments_only_mode = $this->request->get('comments_only_mode'); if ($comments_only_mode) { $this->smarty->assign(array('_object_comments_comments' => $comments, 'pagination' => $pagination, '_counter' => ($page - 1) * $this->active_milestone->comments_per_page)); echo $this->smarty->fetch(get_template_path('_object_comments_ajax', 'comments', RESOURCES_MODULE)); exit; } $scroll_to_comment = $this->request->get('comment_id'); /*if (!empty($scroll_to_comment)){ for($i=0; $i<count($comments); $i++){ if ($comments[$i]->getId()==$scroll_to_comment){ $scroll_to_comment = ''; break; } } }*/ if (isset($_GET['archived_pages'])) { $show_archived_pages = $_GET['archived_pages']; } if (isset($_GET['completed_tkts'])) { $show_completed_tkts = $_GET['completed_tkts']; } $total_objects = 0; $objects = $this->active_milestone->getObjects($this->logged_user); if (is_foreachable($objects)) { foreach ($objects as $objects_by_module) { $total_objects += count($objects_by_module); } // foreach } // if // --------------------------------------------------- // Prepare add suboject links // --------------------------------------------------- $links_code = ''; $links = array(); event_trigger('on_milestone_add_links', array($this->active_milestone, $this->logged_user, &$links)); if (is_foreachable($links)) { $total_links = count($links); $counter = 1; foreach ($links as $k => $v) { $links_code .= open_html_tag('a', array('href' => $v)) . $k . '</a>'; if ($counter < $total_links - 1) { $links_code .= ', '; } elseif ($counter == $total_links - 1) { $links_code .= ' ' . lang('or') . ' '; } // if $counter++; } // foreach } // if $dID = $_GET['dID']; if (!empty($dID)) { $this->active_milestone->changeDepartmentTo($dID, array('Page')); } $this->smarty->assign(array('total_objects' => $total_objects, 'milestone_objects' => $objects, 'milestone_add_links_code' => $links_code, 'subscribers' => $this->active_milestone->getSubscribers(), 'current_user_id' => $this->logged_user->getId(), 'show_archived_pages' => $show_archived_pages, 'show_completed_tkts' => $show_completed_tkts, 'object_id' => $this->active_milestone->getId(), 'comments' => $comments, 'pagination' => $pagination, 'counter' => ($page - 1) * $this->active_milestone->comments_per_page, 'scroll_to_comment' => $scroll_to_comment, 'show_all' => $show_all)); } // if }
<?php if ($project->isNew()) { set_page_title(lang('add project')); dashboard_tabbed_navigation(); project_crumbs(lang('add project')); } else { set_page_title(lang('edit project')); project_crumbs(lang('edit project')); $this->includeTemplate(get_template_path('project/pageactions')); } // if echo open_html_tag('a', array('href' => 'javascript:void(0)', 'onclick' => 'javascript:recoverFormInputs();')) . lang('recover last input') . close_html_tag('a'); if ($project->isNew()) { ?> <form action="<?php echo get_url('project', 'add'); ?> " method="post"> <?php } else { ?> <form action="<?php echo $project->getEditUrl($redirect_to); ?> " method="post"> <?php } // if ?>
/** * Render style tag inside optional conditional comment * * @access public * @param string $content * @param string $condition Condition for conditional comment (IE, lte IE6...). If null * conditional comment will not be added * @return string */ function style_tag($content, $condition = null) { // Open and close for conditional comment $open = ''; $close = ''; if ($condition) { $open = "<!--[if $condition]>\n"; $close = '<![endif]-->'; } // if // And return... return $open . open_html_tag('style', array('type' => 'text/css')) . "\n" . $content . "\n" . close_html_tag('style') . "\n" . $close; } // style_tag
/** * Render HTML editor * * @param array $params * @param string $content * @param Smarty $smarty * @param boolean $repeat * @return string */ function smarty_block_editor_field($params, $content, &$smarty, &$repeat) { static $ids = array(), $files_included = false; // if browser is ipad, we need to turn visual editor off if (USER_AGENT == USER_AGENT_IPAD) { $visual = false; } else { if (isset($params['visual'])) { $visual = array_var($params, 'visual', true, true); } else { $logged_user = $smarty->get_template_vars('logged_user'); if (instance_of($logged_user, 'User')) { $visual = UserConfigOptions::getValue('visual_editor', $logged_user); // if user is loaded $visual is set dependable of user config option } else { $visual = true; } // if } } // if $id = array_var($params, 'id'); if (empty($id)) { $counter = 1; do { $id = "visual_editor_{$counter}"; $counter++; } while (in_array($id, $ids)); } // if $ids[] = $id; $params['id'] = $id; //$hide_editor = array_var($params, 'hide_editor'); //if (empty($hide_editor)){ $params['mce_editable'] = true; //} if (!isset($params['auto_expand'])) { $params['auto_expand'] = 'yes'; } // if if ($visual && !$files_included) { $page =& PageConstruction::instance(); $disable_image_upload = array_var($params, 'disable_image_upload', false); $page->addScript(get_asset_url('javascript/tinymce/tiny_mce.js'), false); $page->addScript(get_asset_url('javascript/tinymce/tiny_mce_init.js'), false); echo "<script type='text/javascript'>"; if ($disable_image_upload) { echo "App.widgets.EditorImagePicker.disable_image_upload = true;"; } // if echo "</script>"; $files_included = true; } // if if (isset($params['class'])) { $classes = explode(' ', $params['class']); $classes[] = 'editor'; if (in_array('tiny_value_present', $classes) && !$visual) { $classes[] = 'required'; } // if $params['class'] = implode(' ', $classes); } else { $params['class'] = 'editor'; } // if $return_string = ''; if (!($variable_name = array_var($params, 'variable_name'))) { $name_parameter = array_var($params, 'name'); $variable_name = substr($name_parameter, 0, strrpos($name_parameter, '[')); } // if $variable_name .= '[inline_attachments][]'; $inline_attachments = array_var($params, 'inline_attachments'); if (is_foreachable($inline_attachments)) { foreach ($inline_attachments as $inline_attachment) { $return_string .= '<input type=hidden name="' . $variable_name . '" value="' . $inline_attachment . '" />' . "\n"; } // foreach } // if unset($params['inline_attachments']); unset($params['variable_name']); $params['inline_attachments_name'] = $variable_name; $return_string .= open_html_tag('textarea', $params) . clean($content) . '</textarea>'; return $return_string; }
/** * Render password field * * Parameters: * * - name - field name * - value - initial value * - array of additional attributes * * @param array $params * @param Smarty $smarty * @return string */ function smarty_function_password_field($params, &$smarty) { $params['type'] = 'password'; return open_html_tag('input', $params, true); }
/** * Render option group * * @param string $label Group label * @param array $options * @param array $attributes * @return string */ function option_group_tag($label, $options, $attributes = null) { if (is_array($attributes)) { $attributes['label'] = $label; } else { $attributes = array('label' => $label); } // if $output = open_html_tag('optgroup', $attributes) . "\n"; if (is_array($options)) { foreach ($options as $option) { $output .= $option . "\n"; } // foreach } // if return $output . '</optgroup>' . "\n"; }
/** * Return textarea tag * * @access public * @param string $name * @param string $value * @param array $attributes Array of additional attributes * @return string */ function textarea_field($name, $value, $attributes = null) { if (!is_array($attributes)) { $attributes = array(); } // if $attributes['name'] = $name; if (!isset($attributes['rows']) || trim($attributes['rows'] == '')) { $attributes['rows'] = '10'; // required attribute } // if if (!isset($attributes['cols']) || trim($attributes['cols'] == '')) { $attributes['cols'] = '40'; // required attribute } // if return open_html_tag('textarea', $attributes) . clean($value) . close_html_tag('textarea'); }
/** * Render milestone subobjects add links * * @param Portal $portal * @return string */ function renderSubobjectsAddLinks($portal) { $links = $this->getPortalAddLinks($portal); $rendered = ''; if (is_foreachable($links)) { $total_links = count($links); $counter = 1; foreach ($links as $k => $v) { $rendered .= open_html_tag('a', array('href' => $v)) . $k . '</a>'; if ($counter < $total_links - 1) { $rendered .= ', '; } elseif ($counter == $total_links - 1) { $rendered .= ' ' . lang('or') . ' '; } // if $counter++; } // foreach } // if return $rendered; }
/** * Update time record billed state * * @param void * @return null */ function update_billed_state() { if ($this->active_time->isNew()) { $this->httpError(HTTP_ERR_NOT_FOUND); } // if if (!$this->active_time->canChangeBillableStatus($this->logged_user)) { $this->httpError(HTTP_ERR_FORBIDDEN); } // if if ($this->request->isSubmitted()) { $to = $this->request->get('to') ? BILLABLE_STATUS_BILLED : BILLABLE_STATUS_BILLABLE; $this->active_time->setBillableStatus($to); $this->active_time->save(); if ($this->active_time->isBilled()) { print open_html_tag('a', array('href' => $this->active_time->getUpdateBilledStateUrl(false), 'class' => 'mark_time_record_as_billed', 'title' => lang('Billed ...'))) . '<img src="' . get_image_url('dollar-small.gif') . '" alt="" /></a>'; } else { print open_html_tag('a', array('href' => $this->active_time->getUpdateBilledStateUrl(true), 'class' => 'mark_time_record_as_billed', 'title' => lang('Not billed ...'))) . '<img src="' . get_image_url('gray-dollar-small.gif') . '" alt="" /></a>'; } // if die; } else { $this->httpError(HTTP_ERR_BAD_REQUEST); } // if sleep(3); print 'tup'; die; }