function _add_field_lock_elements(&$disco, &$entity)
 {
     $cm = $this->_load_content_manager();
     $locks = $entity->get_locks();
     $shown_fields = array();
     $hidden_fields = array();
     $values = array();
     foreach ($locks->get_lockable_fields() as $field) {
         $label = prettify_string($field);
         if ($cm->is_element($field)) {
             $el = $cm->get_element($field);
             if (!empty($el->display_name) && $el->display_name != ' ' && $el->display_name != ' ') {
                 $label = $el->display_name;
             }
         }
         if (!$cm->is_element($field) || $cm->element_is_hidden($field)) {
             $hidden_fields[$field] = '<span class="hiddenInContentManager">' . $label . '</span>';
         } else {
             $shown_fields[$field] = $label;
         }
         if ($entity->field_has_lock($field)) {
             $values[] = $field;
         }
     }
     $fields = $shown_fields + $hidden_fields;
     if (!empty($fields)) {
         $disco->add_element('lock_all_fields', 'checkbox');
         if ($entity->has_all_fields_lock()) {
             $disco->set_value('lock_all_fields', true);
         }
     }
     $disco->add_element('lock_specific_fields', 'checkboxgroup_no_sort', array('options' => $fields));
     $disco->set_value('lock_specific_fields', $values);
 }
	function thor_build_display_values()
	{
		$form = new entity($this->form_id);
		$form->get_values();
		if ($form->get_value('type') != id_of('form'))
		{
			trigger_error('the thor viewer was passed an invalid id ('.$form_id.') - it must be passed the ID of a reason form entity');
		}
		else
		{
			$form_xml_obj = new XMLParser($form->get_value('thor_content'));
			$form_xml_obj->Parse();
			$display_values = array();
			foreach ($form_xml_obj->document->tagChildren as $k=>$v)
			{
				$tagname = is_object($v) ? $v->tagName : '';
				if (method_exists($this, '_build_display_'.$tagname))
				{
					$build_function = '_build_display_'.$tagname;
					$display_values = array_merge($display_values, $this->$build_function($v));
				}
			}
		}
		foreach ($this->extra_fields as $field_name)
		{
			$display_values[$field_name]['label'] = prettify_string($field_name);
			$display_values[$field_name]['type'] = 'text';
		}
		$this->_display_values = (isset($display_values)) ? $display_values : array();
	}
Exemple #3
0
 /**
  * Grabs Any Search fields from the Viewer and sets up display names properly
  * @param Viewer $viewer The viewer that we are a part of
  * @return void
  */
 function grab_fields($viewer)
 {
     $this->set_form_method('get');
     if (!$this->has_filters()) {
         unset($this->actions['clear']);
     }
     // remove filter if we have no search fields
     $this->add_element('search_exact_id', 'hidden');
     $this->set_value('search_exact_id', true);
     $this->add_element('refresh_lister_state', 'hidden');
     $this->set_value('refresh_lister_state', true);
     if ($viewer) {
         $this->get_db_fields($viewer);
         reset($viewer);
         while (list($field, ) = each($viewer)) {
             $key = 'search_' . $field;
             //add fields in different ways
             if (!empty($this->fields[$field]) && preg_match("/^enum\\((.*)\\)\$/", $this->fields[$field]['db_type'])) {
                 $this->add_enum_element($field);
             } else {
                 $this->add_element($key, 'text', array('size' => 20));
             }
             if (isset($this->page->request[$key]) and $this->page->request[$key]) {
                 $this->set_value($key, $this->page->request[$key]);
             }
             $this->set_display_name($key, prettify_string($field));
         }
     }
     foreach ($this->page->module->viewer->request as $key => $value) {
         if (!$this->is_element($key)) {
             $this->add_element($key, 'hidden');
             $this->set_value($key, $value);
         }
     }
 }
 /**
  * Assemble the markup for a particular filter selector
  * @return string
  * @access private
  */
 function _build_filter_set($key)
 {
     $ret = '';
     $other_filter_links = $this->default_links;
     unset($other_filter_links[$key]);
     $combined_other_filter_links = implode('&amp;', $other_filter_links);
     $ret .= '<div class="filters">';
     foreach ($this->filter_types as $filter_name => $filter_type) {
         if (!empty($this->filter_entities[$filter_name])) {
             if ($type_id = id_of($filter_type['type'])) {
                 $type = new entity($type_id);
                 $name = $type->get_value('plural_name');
             } else {
                 $name = prettify_string($filter_name);
             }
             $ret .= '<h4>' . $name . '</h4>' . "\n";
             $ret .= '<ul>';
             if (!empty($this->filters[$key])) {
                 $link = '?';
                 if (!empty($this->search_value)) {
                     $link .= 'search=' . urlencode($this->search_value) . '&amp;';
                 }
                 if (!empty($other_filter_links)) {
                     $link .= $combined_other_filter_links;
                 }
                 $ret .= '<li><a href="' . $link . '">All</a></li>' . "\n";
             }
             foreach ($this->filter_entities[$filter_name] as $entity) {
                 $ret .= '<li>';
                 if (!empty($this->filters[$key]) && $this->filters[$key]['type'] == $filter_name && $this->filters[$key]['id'] == $entity->id()) {
                     $ret .= '<strong>' . $entity->get_value('name') . '</strong>' . "\n";
                 } else {
                     $link = '?';
                     if (!empty($other_filter_links)) {
                         $link .= $combined_other_filter_links . '&amp;';
                     }
                     if (!empty($this->search_value)) {
                         $link .= 'search=' . urlencode($this->search_value) . '&amp;';
                     }
                     $link .= 'filter' . $key . '=' . $filter_name . '-' . $entity->id();
                     if (!empty($this->textonly)) {
                         $link .= '&amp;textonly=1';
                     }
                     $ret .= '<a href="' . $link . '">' . $entity->get_value('name') . '</a>' . "\n";
                 }
                 $ret .= '</li>';
             }
             $ret .= '</ul>';
         }
     }
     $ret .= '</div>' . "\n";
     return $ret;
 }
Exemple #5
0
 function show_item_thor_content($field, $value)
 {
     echo '<tr>';
     $this->_row = $this->_row % 2;
     $this->_row++;
     echo '<td class="listRow' . $this->_row . ' col1" >' . prettify_string($field);
     if ($field != '&nbsp;') {
         echo ':';
     }
     echo '</td>';
     $value = htmlspecialchars($value);
     echo '<td class="listRow' . $this->_row . ' col2">' . (($value or strlen($value) > 0) ? $value : '<em>(No value)</em>') . '</td>';
     echo '</tr>';
 }
 function run_error_checks()
 {
     $name = trim($this->display_name);
     if (empty($name)) {
         $name = $this->name;
     }
     $name = prettify_string($name);
     $username = reason_require_authentication();
     $password = $this->grab_value();
     $dir = new directory_service();
     if (!$dir->authenticate($username, $password)) {
         $this->set_error($name . ':  Please check your password.');
     }
 }
    function run()
    {
        $type = new entity($this->admin_page->type_id);
        $entity = new entity($this->admin_page->id);
        $user = new entity($this->admin_page->user_id);
        $text = array('root_node' => 'This is a root ' . $type->get_value('name') . ', so you may not delete it.  If you wish to delete this item, please contact the <a href="' . $this->admin_page->make_link(array("cur_module" => "about_reason")) . '">web team</a>.', 'default' => 'You cannot currently delete this item because following items, which 
										are associated with it, must be associated with a ' . $type->get_value('name') . '. If 
										you wish to delete this item, you must first select a different ' . $type->get_value('name') . ' for each of the following items.<br /><br />', id_of('minisite_page') => 'This page has children.  In order to delete it, you must first either:
										<ul>
										<li>delete its children</li>
										<li>Select a different parent page for its children</li>
										</ul>If you wish to delete this item, please select a different parent for the pages listed below.<br /><br />', 'borrowed' => '<p>This item is currently borrowed by one or more sites.  Deleting it might break their sites.  If you still want to delete it, contact the sites\' maintainers to ask if they can stop borrowing the item.</p>', 'locks' => 'This ' . $type->get_value('name') . ' has had a lock applied to it that keeps it from being deleted. A reason administrator may have applied this lock in order to ensure that a site was not inadventently broken. Please contact a Reason administrator if you have any questions about the rationale for placing this lock on this ' . $type->get_value('name') . '.');
        if (!empty($this->borrowed_by)) {
            echo $text['borrowed'];
            echo '<h4>Sites borrowing this item</h4>' . "\n";
            echo '<ul>' . "\n";
            foreach ($this->borrowed_by as $site) {
                echo '<li><a href="' . $site->get_value('base_url') . '">' . $site->get_value('name') . '</a>' . "\n";
                echo '<div>Primary maintainer: ' . $site->get_value('name_cache') . ', <a href="mailto:' . $site->get_value('email_cache') . '" title="send email">' . $site->get_value('email_cache') . '</a></div></li>' . "\n";
            }
            echo '</ul>' . "\n";
        } elseif ($this->is_root_node()) {
            echo $text['root_node'];
        } elseif (!$entity->user_can_edit_field('state', $user)) {
            echo $text['locks'];
        } else {
            if (!empty($text[$this->admin_page->type_id])) {
                echo $text[$this->admin_page->type_id];
            } else {
                echo $text['default'];
            }
            foreach ($this->values as $v) {
                $link = $this->admin_page->make_link(array('cur_module' => 'Preview', 'id' => $v['e_id'], 'type_id' => $v['relationship_a']));
                echo '<a href="' . $link . '" target="' . $v['e_id'] . '">' . $v['e_name'] . '</a><span class="smallText"> (' . prettify_string($v['name']) . ')</span><br />';
            }
        }
    }
Exemple #8
0
 function load_options($args = array())
 {
     $files = array();
     if (isset($this->directory)) {
         if ($handle = opendir($this->directory)) {
             while ($entry = readdir($handle)) {
                 if (is_file($this->directory . $entry) && (!$this->hide_files_with_initial_period || 0 !== strpos($entry, '.'))) {
                     $show_entry = true;
                     $entry_display = $entry_value = $entry;
                     if (!empty($this->strip_extension)) {
                         $entry_display = $entry_value = substr($entry, 0, strrpos($entry, '.'));
                     }
                     if (!empty($this->prettify_file_name)) {
                         $entry_display = prettify_string(substr($entry, 0, strrpos($entry, '.')));
                     }
                     if (!empty($this->extension)) {
                         if (!preg_match('/' . $this->extension . '$/', $entry)) {
                             $show_entry = false;
                         }
                     }
                     if ($show_entry) {
                         $files[$entry_value] = $entry_display;
                     }
                 }
             }
             ksort($files);
         } else {
             trigger_error('Directory does not appear to be readable (' . $this->directory . ').');
         }
     }
     $this->options += $files;
 }
 /**
  * Displays an embed field.
  */
 private function _show_embed_item($field, $value)
 {
     echo '<tr id="' . str_replace(' ', '_', $field) . '_Row">';
     $this->previewer->_row = $this->previewer->_row % 2;
     $this->previewer->_row++;
     echo '<td class="listRow' . $this->previewer->_row . ' col1">';
     if ($lock_str = $this->previewer->_get_lock_indication_string($field)) {
         echo $lock_str . '&nbsp;';
     }
     echo prettify_string($field);
     if ($field != '&nbsp;') {
         echo ':';
     }
     echo '</td>';
     echo '<td class="listRow' . $this->previewer->_row . ' col2"><input id="' . $field . 'Element" type="text" readonly="readonly" size="50" value="' . htmlspecialchars($value) . '"></td>';
     echo '</tr>';
 }
Exemple #10
0
 /**
  * Get the display name for a given element or element group
  * @param string $element_name
  * @param boolean $empty_ok
  * @return string
  */
 public function get_display_name($element_name, $empty_ok = true)
 {
     $display_name = prettify_string($element_name);
     //find the real display name, if one exists.
     if ($this->_is_element($element_name)) {
         $element_object = $this->get_element($element_name);
         $element_display_name = trim($element_object->display_name);
         if ($empty_ok || !empty($element_display_name)) {
             $display_name = prettify_string($element_display_name);
         }
     } elseif ($this->_is_element_group($element_name)) {
         $element_group_object = $this->get_element_group($element_name);
         $group_display_name = trim($element_group_object->display_name);
         if ($empty_ok || !empty($group_display_name)) {
             $display_name = prettify_string($group_display_name);
         }
     }
     return $display_name;
 }
     $chr1 = strtolower($page_type_name[0]);
     echo '<h2><a name = "' . $chr1 . '">' . strtoupper($chr1) . '</a></h2>';
 }
 echo '<h3><a name="' . $page_type_name . '">' . prettify_string($page_type_name) . '</a></h3>';
 echo '<ul>';
 foreach ($page_type->get_region_names() as $region) {
     $region_info = $page_type->get_region($region);
     $default_region_info = $default_pt->get_region($region);
     // (If the page is not default, then (if a region def differs from the default, then show it))
     // If the page is default, show all region defs.
     if ($page_type_name != 'default' && ($region_info['module_name'] != $default_region_info['module_name'] || $region_info['module_params'] != $default_region_info['module_params']) || $page_type_name == 'default') {
         $xtra = '';
         if (isset($GLOBALS['_reason_deprecated_modules']) && @in_array($region_info['module_name'], $GLOBALS['_reason_deprecated_modules'])) {
             $xtra = ' (deprecated)';
         }
         echo '<li>' . prettify_string($region) . ': ' . (!empty($region_info['module_name']) ? str_replace('_', ' ', "<strong>" . $region_info['module_name']) . "</strong>" . $xtra . "</li>" : "[empty]</li>");
     }
     if (!empty($region_info['module_params'])) {
         echo "Parameters: <ul>";
         foreach ($region_info['module_params'] as $param => $value) {
             if (!empty($value)) {
                 echo "<li>" . $param . ": ";
                 if (is_array($value)) {
                     pray($value);
                 } else {
                     echo $value;
                 }
                 echo "</li>";
             }
         }
         echo "</ul>";
Exemple #12
0
 function grab()
 {
     parent::grab();
     $length = strlen($this->value);
     $length_limits = array('tinytext' => 255, 'text' => 65535, 'mediumtext' => 16777215);
     if (!empty($this->db_type) && array_key_exists($this->db_type, $length_limits)) {
         if ($length > $length_limits[$this->db_type]) {
             $name_to_display = trim($this->display_name);
             if (empty($name_to_display)) {
                 $name_to_display = prettify_string($this->name);
             }
             $this->set_error('There is more text in ' . $name_to_display . ' than can be stored; this field can hold no more than ' . $length_limits[$this->db_type] . ' characters.');
         }
     }
 }
Exemple #13
0
    mysql_free_result($r);
    echo $info['name'] . ': ' . $row[$info['var']] . '<br /><br />';
}
$multiple_result_queries = array(array('q' => 'SELECT user.name AS username, COUNT(*) AS number_of_entities_last_edited FROM entity AS user, entity AS e WHERE e.last_edited_by = user.id AND e.state = "Live" GROUP BY e.last_edited_by ORDER BY number_of_entities_last_edited DESC LIMIT ' . $num, 'name' => 'Active Users (Top ' . $num . ')'), array('q' => 'SELECT type.name AS type, COUNT(e.name) AS number_of_entities FROM entity AS type LEFT JOIN entity AS e ON e.type = type.id WHERE type.type = 1 AND e.state = "Live" GROUP BY type.id ORDER BY number_of_entities DESC LIMIT ' . $num, 'name' => 'Number of Entities by Type (Top ' . $num . ')'), array('q' => 'SELECT type.name AS type, COUNT(e.name) AS number_of_entities FROM entity AS type LEFT JOIN entity AS e ON e.type = type.id WHERE type.type = 1 AND e.state = "Live" GROUP BY type.id ORDER BY number_of_entities ASC LIMIT ' . $num, 'name' => 'Number of Entities by Type (Bottom ' . $num . ')'), array('q' => 'SELECT e.id,e.name,type.name as type,user.name as last_edited_by,DATE_FORMAT(e.creation_date,"%M %e, %Y %r") as creation_date FROM entity as e, entity as type, entity as user WHERE e.type = type.id AND e.last_edited_by = user.id AND e.state = "Live" ORDER BY e.creation_date DESC LIMIT ' . $num, 'name' => 'Recently Created'), array('q' => 'SELECT e.id,e.name,type.name as type,user.name as last_edited_by,DATE_FORMAT(e.last_modified,"%M %e, %Y %r") as last_modified FROM entity as e, entity as type, entity as user WHERE e.type = type.id AND e.last_edited_by = user.id AND e.state = "Live" ORDER BY e.last_modified DESC LIMIT ' . $num, 'name' => 'Recently Edited'), array('q' => 'SELECT e.id,e.name,type.name as type,user.name as last_edited_by,DATE_FORMAT(e.last_modified,"%M %e, %Y %r") as last_modified FROM entity as e, entity as type, entity as user WHERE e.type = type.id AND e.last_edited_by = user.id AND e.state = "Live" ORDER BY e.last_modified ASC LIMIT ' . $num, 'name' => 'Not Recently Edited'), array('q' => 'SELECT ar.name, e1.name AS type_a, e2.name as type_b, count(*) AS number_of_relationships FROM allowable_relationship AS ar, relationship AS r, entity AS e1, entity AS e2 WHERE r.type = ar.id AND ar.relationship_a = e1.id AND ar.relationship_b = e2.id GROUP BY r.type ORDER BY number_of_relationships DESC LIMIT ' . $num, 'name' => 'Number of Relationships by Type (with ownership)'), array('q' => 'SELECT ar.name, e1.name AS type_a, e2.name as type_b, count(*) AS number_of_relationships FROM allowable_relationship AS ar, relationship AS r, entity AS e1, entity AS e2 WHERE r.type = ar.id AND ar.relationship_a = e1.id AND ar.relationship_b = e2.id AND ar.name != "owns" GROUP BY r.type ORDER BY number_of_relationships DESC LIMIT ' . $num, 'name' => 'Number of Relationships by Type (without ownership)'), array('q' => 'SELECT state, count(*) AS Count FROM entity GROUP BY state ORDER BY Count DESC', 'name' => 'Entities by State'));
reset($multiple_result_queries);
while (list(, $mrq) = each($multiple_result_queries)) {
    $first_row = true;
    echo '<strong>' . $mrq['name'] . '</strong><br /><br />';
    echo '<table border="1" cellpadding="5">';
    $r = db_query($mrq['q'], 'Unable to ' . $mrq['name']);
    while ($row = mysql_fetch_array($r, MYSQL_ASSOC)) {
        if ($first_row) {
            echo '<tr>';
            reset($row);
            while (list($key, ) = each($row)) {
                echo '<th>' . prettify_string($key) . '</th>';
            }
            echo '</tr>';
            $first_row = false;
        }
        echo '<tr>';
        reset($row);
        while (list($key, $val) = each($row)) {
            echo '<td>' . $val . '</td>';
        }
        echo '</tr>';
    }
    echo '</table>';
    echo '<br />';
}
//	echo '<strong>Session Variables</strong>';
Exemple #14
0
 /**
  * Recursively prettify all values of an array using prettify_string
  * @author Matt Ryan
  * @date 2006-05-18
  * @param array $array
  * @return array $prettified_array
  */
 function prettify_array($array)
 {
     foreach ($array as $k => $v) {
         if (is_array($v)) {
             $array[$k] = prettify_array($v);
         } else {
             $array[$k] = prettify_string($v);
         }
     }
     return $array;
 }
Exemple #15
0
 /**
  * Sets the unique identifier ( {@link name}) for an instance of this element type.
  * Note that {@link name} needs to be set using this method; it cannot be set using {@link set_class_var()} or {@link init()}.
  * @param string $name The name of this instance of this element type.
  */
 function set_name($name)
 {
     $this->name = $name;
     if (!$this->display_name) {
         $this->display_name = prettify_string($name);
     }
 }
	function run_error_checks()
	{
		foreach($this->forbidden as $field)
		{
			if($this->get_value($field))
			{
				$this->set_error($field,'This field must be left empty for your comment to work');
			}
		}
		$content = $this->get_value('comment_content');
		$content = str_replace('&nbsp;', ' ', $content);
		if (carl_empty_html(trim(tidy($content))))
		{
			$this->set_error('comment_content', 'You must write a comment in order to post a comment!');
		}
				
		$fields_to_tidy = array('comment_content');
		foreach($fields_to_tidy as $field)
		{
			if($this->get_value($field))
			{
				$tidied = trim(tidy($this->get_value($field)));
				if(empty($tidied) && in_array($field,$this->required))
				{
					if(!empty($this->elements[$field]['display_name']))
					{
						$display_name = $this->elements[$field]['display_name'];
					}
					else
					{
						$display_name = prettify_string($field);
					}
					$this->set_error($field,'Please fill in the '.$display_name.' field');
				}
				else 	
				{
					$tidy_errors = tidy_err($this->get_value($field));
					if(!empty($tidy_errors))
					{
						$msg = 'The html in the '.$field.' field is misformed.  Here is what the html checker has to say:<ul>';
						foreach($tidy_errors as $tidy_error)
						{
							$msg .= '<li>'.$tidy_error.'</li>';
						}
						$msg .= '</ul>';
						$this->set_error($field,$msg);
					}
				}
			}
		}
		if (!reason_check_authentication())
		{
			if ($this->is_comment_spam())
			{
				$this->set_error('comment_content', 'Your comment was rejected because it appears to be spam.');
			}
		}
	}
Exemple #17
0
		function show_root_option_menu() // {{{
		{
			$e = new entity($this->page_id);
			$title = $e->get_value('name');
			
			echo '<form name="policy_form" method="get" class="policyForm">' .
					'<select name="policy_id" class="rootMenu">'.
					'<option value="">' . $title . "</option>\n";
			foreach( $this->get_root_nodes() AS $root )
			{
				echo '<option value="'.$root->id().'"';
				if ( $root->id() == $this->request[ 'policy_id' ] ) echo " selected='selected' ";
				echo '>'.prettify_string( $root->get_value( 'name' ) ).'</option>'."\n";
			}
			echo '';
			if ($this->textonly)
				echo '<input type="hidden" name="textonly" value="1"/>';
			if(!empty($this->request['a']))
				echo '<input type="hidden" name="a" value="'.htmlspecialchars($this->request['a']).'" />';
			if(!empty($this->request['audience_id']))
				echo '<input type="hidden" name="audience_id" value="'.htmlspecialchars($this->request['audience_id']).'" />';
			echo '</select><input type="submit" class="rootMenuSubmit" value="Go"></form>';

		}
Exemple #18
0
    function diff_entities($a_id, $b_id, $use_ignore_fields = true)
    {
        $a =& $this->history[$a_id];
        if (!empty($b_id)) {
            $b =& $this->history[$b_id];
        }
        if ($use_ignore_fields) {
            $keys = array_diff(array_keys($a->get_values()), $this->ignore_fields);
        } else {
            $keys = array_keys($a->get_values());
        }
        if (empty($b_id)) {
            $compare_or_comparing = 'Compare';
        } else {
            $compare_or_comparing = 'Comparing';
        }
        $select_form_a = '<form action="?" class="jumpNavigation" name="archive_a_switch" method="get">' . $compare_or_comparing . '
				<select name="archive_a" class="jumpDestination siteMenu" id="archive_a_switch_select">
					';
        $select_form_b = '<form action="?" class="jumpNavigation" name="archive_b_switch" method="get">with
				<select name="archive_b" class="jumpDestination siteMenu" id="archive_b_switch_select">
					<option value="--"' . (empty($b_id) ? ' selected="selected"' : '') . '>--</option>';
        foreach ($this->history as $h) {
            $select_form_a .= '<option value="' . $h->id();
            if ($a->id() == $h->id()) {
                $select_form_a .= '" selected="selected';
            }
            $select_form_a .= '">' . $this->get_archive_name($h->id());
            if (!empty($this->_locks[$h->id()])) {
                $select_form_a .= ' (locked)';
            }
            $select_form_a .= "</option>\n";
            $select_form_b .= '<option value="' . $h->id();
            if (!empty($b_id) and $b->id() == $h->id()) {
                $select_form_b .= '" selected="selected';
            }
            $select_form_b .= '">' . $this->get_archive_name($h->id());
            if (!empty($this->_locks[$h->id()])) {
                $select_form_b .= ' (locked)';
            }
            $select_form_a .= "</option>\n";
        }
        ob_start();
        $this->admin_page->echo_hidden_fields('archive_a');
        $archive_a_fields = ob_get_contents();
        ob_end_clean();
        ob_start();
        $this->admin_page->echo_hidden_fields('archive_b');
        $archive_b_fields = ob_get_contents();
        ob_end_clean();
        $select_form_a .= '</select>' . $archive_a_fields . '<input type="submit" class="jumpNavigationGo" value="go"></form>';
        $select_form_b .= '</select>' . $archive_b_fields . '<input type="submit" class="jumpNavigationGo" value="go"></form>';
        echo '<table border="0" cellspacing="0" cellpadding="4">';
        echo '<tr>';
        echo '<th class="listHead" align="left">Field</th>';
        echo '<th class="listHead">' . $select_form_a . '</th>';
        echo '<th class="listHead">' . $select_form_b . '</th>';
        echo '</tr>';
        $type = new entity($this->admin_page->type_id);
        if (!empty($this->content_transform[$type->get_value('unique_name')])) {
            $transformers = $this->content_transform[$type->get_value('unique_name')];
        }
        foreach ($keys as $key) {
            $diff = false;
            if (!empty($b_id)) {
                if ($a->get_value($key) != $b->get_value($key)) {
                    $diff = true;
                }
            }
            if ($diff) {
                $class = 'highlightRow';
            } else {
                $class = 'listRow1';
            }
            if (!empty($a) && in_array($key, $this->_locks[$a->id()]) || !empty($b) && in_array($key, $this->_locks[$b->id()])) {
                $class .= ' lockedRow';
                $lock_img = '<img class="lockIndicator" src="' . REASON_HTTP_BASE_PATH . 'ui_images/lock_12px.png" alt="locked" width="12" height="12" />';
            } else {
                $lock_img = '';
            }
            echo '<tr>';
            echo '<td class="' . $class . '" valign="top"><strong>' . $lock_img . prettify_string($key) . ':</strong></td>';
            if (!empty($transformers[$key])) {
                $method = $transformers[$key];
                $a_val = $this->{$method}($a->get_value($key));
                if (!empty($b_id)) {
                    $b_val = $this->{$method}($b->get_value($key));
                }
            } else {
                $a_val = $a->get_value($key);
                if (!empty($b_id)) {
                    $b_val = $b->get_value($key);
                }
            }
            echo '<td class="' . $class . '" valign="top"' . (empty($b_id) ? ' colspan="2"' : '') . '>' . $a_val . '</td>';
            if (!empty($b_id)) {
                echo '<td class="' . $class . '" valign="top">' . $b_val . '</td>';
            }
            echo '</tr>';
        }
        // only show the make current link if one of the edits is not the current edit
        if ($a_id != $this->admin_page->id or !empty($b_id) and $b_id != $this->admin_page->id) {
            echo '<tr>';
            echo '<td class="listRow1">&nbsp</td>';
            if ($a_id != $this->admin_page->id) {
                echo '<td class="listRow1"' . (empty($b_id) ? ' colspan="2"' : '') . '>';
                if (empty($this->_locks[$a->id()])) {
                    echo '<a href="' . $this->admin_page->make_link(array('archive_page' => 'confirm_reinstate', 'archive_id' => $a_id)) . '">Make this version current</a>';
                } else {
                    echo '<div class="lockNotice">This version cannot be made current because it would change a value that has been locked.</div>' . "\n";
                }
                echo '</td>';
            } else {
                echo '<td class="listRow1">&nbsp;</td>';
            }
            if (!empty($b_id)) {
                if ($b_id != $this->admin_page->id) {
                    echo '<td class="listRow1">';
                    if (empty($this->_locks[$b->id()])) {
                        echo '<a href="' . $this->admin_page->make_link(array('archive_page' => 'confirm_reinstate', 'archive_id' => $b_id)) . '">Make this version current</a>';
                    } else {
                        echo '<div class="lockNotice">This version cannot be made current because it would change a value that has been locked.</div>' . "\n";
                    }
                    echo '</td>';
                } else {
                    echo '<td class="listRow1">&nbsp;</td>';
                }
            }
            echo '</tr>';
        }
        echo '</table>';
    }
Exemple #19
0
	function add_complete($unique_name,$name,$css = array(),$template_name,$user_id)
	{
		if($this->get_id())
		{
			trigger_error('add_complete method may only be called on a reasonTheme that does not yet have an ID assigned.');
			return false;
		}
		$all_ok = true;
		$output =  '<h4>Adding theme: '.$unique_name.'</h4>';
		$output .= '<ol>';
		if(empty($template_name))
		{
			$template_name = 'default';
		}
		if(empty($name))
		{
			$name = prettify_string($unique_name);
		}
		$template = get_template_by_name($template_name);
		if(empty($template))
		{
			$all_ok = false;
			$template_id = reason_add_template($template_name);
			if(!empty($template_id))
			{
				$template = new entity($template_id);
				$output .= '<li>Template created ('.$template_name.', id '.$template->id().')</li>';
			}
			else
			{
				$output .= '<li>Unable to create template '.$template_name.'. The template file may not be placed correctly.';
				if($this->test_mode)
				{
					$output .= ' Would abort theme addition.';
				}
				else
				{
					$output .= ' Aborting theme addition.';
				}
				$output .= '</li></ol>';
				return array('success'=>false,'report'=>$output);
			}
		}
		else
		{
			$output .= '<li>Template found ('.$template_name.', id '.$template->id().')</li>';
		}
		
		$theme_id = id_of($unique_name);
		if(!$theme_id)
		{
			$all_ok = false;
			$output .= '<li>Theme with unique name '.$unique_name.' needs to be created</li>';
			if(!$this->test_mode)
			{
				$theme_id = $this->create($unique_name,$name,$template->id(),$user_id);
				if(!$theme_id)
				{
					$output .= '<li>Theme '.$name.' unable to be created; aborting theme addition</li></ol>';
					return array('success'=>false,'report'=>$output);
				}
				else
				{
					$output .= '<li>Theme with unique name '.$unique_name.' created</li>';
				}
			}
			else
			{
				$output .= '<li>Would have attempted to create theme entity.</li>';
			}
		}
		else
		{
			$this->set_id($theme_id);
		}
		
		if($this->get_template_id() != $template->id())
		{
			$all_ok = false;
			$output .= '<li>Current theme template id ('.$this->get_template_id().') not the same as specified in update ('.$template->id().').</li>';
			if($this->test_mode)
			{
				$output .= '<li>Would have set theme template to be id '.$template->id().'</li>';
			}
			else
			{
				if($this->attach_template($template->id()))
				{
					$output .= '<li>Attached template id '.$template->id().' to '.$unique_name.'.</li>';
				}
				else
				{
					$output .= '<li>Unable to attach template for some reason. Aborting theme addition.</li>';
					return array('success'=>false,'report'=>$output);
				}
			}
				
		}
		
		$retrieved_css_entities = array();
		
		foreach($css as $css_name=>$css_info)
		{
			$output .= '<li>CSS: '.$css_name.'<ol>';
			if(empty($css_info['url']))
			{
				$output .= '<li>'.$css_name.' has no url specified; skipping this css item</li></ol></li>';
				continue;
			}
			else
			{
				$css_url = $css_info['url'];
			}
			if(empty($retrieved_css_entities[$css_url]))
			{
				$es = new entity_selector();
				$es->add_type(id_of('css'));
				$es->add_relation('url = "'.addslashes($css_url).'"');
				$es->set_num(1);
				$css_ents = $es->run_one();
				if(!empty($css_ents))
				{
					$retrieved_css_entities[$css_url] = current($css_ents);
				}
			}
			if(empty($retrieved_css_entities[$css_url]))
			{
				$all_ok = false;
				//create css & get id of css
				if($this->test_mode)
				{
					$output .= '<li>Would have created a css entity for '.$css_url.' and attached it to the theme</li>';
				}
				else
				{
					$css_id = reason_create_entity(id_of('master_admin'), id_of('css'), $user_id, $css_name, $css_info);
					if($css_id)
					{
						$output .= '<li>Created a css entity for '.$css_url.'</li>';
					}
					else
					{
						$output .= '<li>Tried to create a css entity for '.$css_url.' but was unsuccessful. Aborting creation of this css item.</li>';
						continue;
					}
				}
			}
			else
			{
				$css_id = $retrieved_css_entities[$css_url]->id();
				$output .= '<li>A css entity exists for '.$css_url.' at Reason id '.$css_id.'</li>';
			}
			if(!empty($css_id))
			{
				// attach css
				$attached_css = $this->get_css();
				if(empty($attached_css[$css_id]))
				{
					$all_ok = false;
					if($this->test_mode)
					{
						$output .= '<li>Would have attached css at '.$css_url.' to '.$unique_name.'.</li>';
					}
					else
					{
						if($this->attach_css($css_id))
						{
							$output .= '<li>Attached css at '.$css_url.' to '.$unique_name.'.</li>';
						}
						else
						{
							$output .= '<li>Unable to attach css at '.$css_url.' to '.$unique_name.'; perhaps there is an unknown problem.</li>';
						}
					}
				}
				else
				{
					$output .= '<li>Css at '.$css_url.' already attached to '.$unique_name.'</li>';
				}
				$output .= '</ol></li>';
			}
		}
		if($all_ok)
		{
			$output .= '<li><strong>Everything OK.</strong> The theme '.$unique_name.' appears to be set up correctly.  No database changes are needed.</li>';
		}
		$output .= '</ol>';
		return array('success'=>true,'report'=>$output);
	}
 function get_table_headers()
 {
     $markup_string = '';
     $markup_string .= '<thead><tr>';
     if ($this->row_labels_exist()) {
         $markup_string .= '<th></th>';
     }
     foreach ($this->column_order as $position => $column) {
         if (!empty($this->columns[$column])) {
             $name = $this->columns[$column];
         } else {
             $name = prettify_string($column);
         }
         $markup_string .= '<th>' . $name . '</th>';
     }
     $markup_string .= '</tr></thead>' . "\n";
     return $markup_string;
 }
Exemple #21
0
 function init()
 {
     if (!reason_user_has_privs($this->admin_page->user_id, 'edit')) {
         return;
     }
     $this->admin_page->head_items->add_javascript(WEB_JAVASCRIPT_PATH . 'jquery.mobile-tablednd.js');
     $this->admin_page->head_items->add_javascript(WEB_JAVASCRIPT_PATH . 'sorter.js');
     $this->admin_page->head_items->add_stylesheet(REASON_HTTP_BASE_PATH . 'css/reason_admin/sorter.css');
     $type_entity = new entity($this->admin_page->type_id);
     $this->type_entity = $type_entity;
     $this->admin_page->title = 'Sorting ' . prettify_string($type_entity->get_value('plural_name'));
     if ($this->type_entity->get_value('custom_sorter')) {
         reason_include_once('content_sorters/' . $this->type_entity->get_value('custom_sorter'));
         $sorter = $GLOBALS['_content_sorter_class_names'][$this->type_entity->get_value('custom_sorter')];
         $this->sorter = new $sorter($this->admin_page);
     } else {
         $this->sorter = new sorter($this->admin_page);
     }
     $this->sorter->init();
 }
 /**
  * Get the repetition information markup for a given event
  * @param object $event
  * @return string markup
  */
 protected function get_repetition_info_markup($event)
 {
     $ret = '';
     $rpt = $event->get_value('recurrence');
     $freq = '';
     $words = array();
     $dates_text = '';
     $occurence_days = array();
     if (!($rpt == 'none' || empty($rpt))) {
         $words = array('daily' => array('singular' => 'day', 'plural' => 'days'), 'weekly' => array('singular' => 'week', 'plural' => 'weeks'), 'monthly' => array('singular' => 'month', 'plural' => 'months'), 'yearly' => array('singular' => 'year', 'plural' => 'years'));
         if ($event->get_value('frequency') <= 1) {
             $sp = 'singular';
         } else {
             $sp = 'plural';
             $freq = $event->get_value('frequency') . ' ';
         }
         if ($rpt == 'weekly') {
             $days_of_week = array('sunday', 'monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday');
             foreach ($days_of_week as $day) {
                 if ($event->get_value($day)) {
                     $occurence_days[] = $day;
                 }
             }
             $last_day = array_pop($occurence_days);
             $dates_text = ' on ';
             if (!empty($occurence_days)) {
                 $comma = '';
                 if (count($occurence_days) > 2) {
                     $comma = ',';
                 }
                 $dates_text .= ucwords(implode(', ', $occurence_days)) . $comma . ' and ';
             }
             $dates_text .= prettify_string($last_day);
         } elseif ($rpt == 'monthly') {
             $suffix = array(1 => 'st', 2 => 'nd', 3 => 'rd', 4 => 'th', 5 => 'th');
             if ($event->get_value('week_of_month')) {
                 $dates_text = ' on the ' . $event->get_value('week_of_month');
                 $dates_text .= $suffix[$event->get_value('week_of_month')];
                 $dates_text .= ' ' . $event->get_value('month_day_of_week');
             } else {
                 $dates_text = ' on the ' . prettify_mysql_datetime($event->get_value('datetime'), 'jS') . ' day of the month';
             }
         } elseif ($rpt == 'yearly') {
             $dates_text = ' on ' . prettify_mysql_datetime($event->get_value('datetime'), 'F jS');
         }
         $ret .= '<p class="repetition">This event takes place each ';
         $ret .= $freq;
         $ret .= $words[$rpt][$sp];
         $ret .= $dates_text;
         $ret .= ' from ' . prettify_mysql_datetime($event->get_value('datetime'), 'F jS, Y') . ' to ' . prettify_mysql_datetime($event->get_value('last_occurence'), 'F jS, Y') . '.';
         $ret .= '</p>' . "\n";
     }
     return $ret;
 }
Exemple #23
0
	function run_documentation($sec)
	{
		$module =& $this->_get_module( $sec );
		if( $module )
		{
			$doc =  $module->get_documentation();
			if($doc !== false)
			{
				$module_name = $this->section_to_module[$sec];
				echo '<div class="documentation">'."\n";
				echo '<h4>'.prettify_string($module_name).'</h4>'."\n";
				echo $doc;
				echo '</div>'."\n";
			}
		}
	}
Exemple #24
0
 /**
  * Assemble the markup for a particular filter selector
  * @return string
  * @access private
  */
 function _build_filter_set($key)
 {
     $ret = '';
     $other_filter_links = $this->default_links;
     unset($other_filter_links[$key]);
     $combined_other_filter_links = implode('&amp;', $other_filter_links);
     $ret .= '<div class="filterSet">';
     $ret .= '<select class="filterSelect" name="filter' . htmlspecialchars($key, ENT_QUOTES, "UTF-8") . '">' . "\n";
     if (empty($this->filters[$key])) {
         if (empty($this->filters)) {
             if (count($this->filter_types) == 1) {
                 $ret .= '<option value="">Browse by ' . current(array_keys($this->filter_types)) . ':</option>' . "\n";
             } else {
                 $ret .= '<option value="">Focus on...</option>' . "\n";
             }
         } else {
             $ret .= '<option value="">Add focus...</option>' . "\n";
         }
         $ret .= '<option value=""></option>' . "\n";
     }
     foreach ($this->filter_types as $filter_name => $filter_type) {
         if (!empty($this->filter_entities[$filter_name])) {
             if (count($this->filter_types) != 1) {
                 $ret .= '<option value="" class="type">' . prettify_string($filter_name) . '</option>' . "\n";
             }
             foreach ($this->filter_entities[$filter_name] as $entity) {
                 /** To move to hidden variables:					
                 
                 					
                 					if(!empty($other_filter_links))
                 						$link .= $combined_other_filter_links.'&amp;';
                 					if(!empty($this->search_value))
                 						$link .= 'search='.urlencode($this->search_value).'&amp;';
                 					if (!empty($this->textonly))
                 						$link .= '&amp;textonly=1';
                 					**/
                 $link = urlencode($filter_name) . "-" . urlencode($entity->id());
                 if (!empty($this->filters[$key]) && $this->filters[$key]['type'] == $filter_name && $this->filters[$key]['id'] == $entity->id()) {
                     $add = ' selected="selected"';
                 } else {
                     $add = '';
                 }
                 $ret .= '<option value="' . $link . '"' . $add . '> - ' . $entity->get_value('name') . '</option>' . "\n";
             }
             $ret .= '<option value=""></option>' . "\n";
         }
     }
     $ret .= '</select>' . "\n";
     if (!empty($this->filters[$key])) {
         $link = '?';
         if (!empty($this->search_value)) {
             $link .= 'search=' . urlencode($this->search_value) . '&amp;';
         }
         if (!empty($other_filter_links)) {
             $link .= $combined_other_filter_links;
         }
         $ret .= ' <a href="' . $link . '" title="Remove this filter">Remove</a>' . "\n";
     }
     $ret .= '<input type="submit" class="FilterSubmit" value="Go">';
     $ret .= '</div>' . "\n";
     return $ret;
 }
}
if (!reason_user_has_privs($GLOBALS['__cur_user_id_hack__'], 'upgrade')) {
    die('You must have upgrade privileges to run this script');
}
echo '<h2>Reason: Miscellaneous 4.0b3 to 4.0b4 Updates</h2>';
if (!isset($_POST['verify'])) {
    echo '<p>This script does a variety of minor updates to your Reason instance, including:</p>';
    echo '<ul>';
    echo '<li>Setting up a new content manager for themes</li>';
    echo '<li>Adding new themes:';
    echo '<ul>';
    foreach (get_themes_to_add_b3_to_b4() as $theme_uname => $theme_info) {
        if (!empty($theme_info['name'])) {
            $name = $theme_info['name'];
        } else {
            $name = prettify_string($theme_uname);
        }
        echo '<li>' . $name . '</li>';
    }
    echo '</ul>';
    echo '</li>';
    echo '<li>Changes the event.last_occurence field to be a date field rather than a text field</li>';
    echo '<li>Adds indexes to the following fields:';
    echo '<ul>';
    foreach (get_indexes_to_add_b3_to_b4() as $table => $fields) {
        foreach ($fields as $field) {
            echo '<li>' . $table . '.' . $field . '</li>';
        }
    }
    echo '</ul>';
    echo '</li>';
Exemple #26
0
 /**
  * This is the way an item is shown by default if the function show_item_$field is not defined
  * It keeps track of whether the row is odd or even (for alternating stylesheets and puts out 
  * the element's field and value in two tds
  * @param string $field the name of the field, will show up in the left column
  * @param string $value the value that will be displayed in the right column
  */
 function show_item_default($field, $value)
 {
     echo '<tr>';
     $this->_row = $this->_row % 2;
     $this->_row++;
     echo '<td class="listRow' . $this->_row . ' col1">';
     if ($lock_str = $this->_get_lock_indication_string($field)) {
         echo $lock_str . '&nbsp;';
     }
     echo prettify_string($field);
     if ($field != '&nbsp;') {
         echo ':';
     }
     echo '</td>';
     echo '<td class="listRow' . $this->_row . ' col2">' . (($value or strlen($value) > 0) ? $value : '<em>(No value)</em>') . '</td>';
     echo '</tr>';
 }
 function get_classified_display_name($value)
 {
     if (isset($this->classified_form_display_names[$value])) {
         return $this->classified_form_display_names[$value];
     } else {
         return prettify_string($value);
     }
 }
	function run_error_checks()
	{
		if($this->get_value('tarbaby'))
		{
			$this->set_error('tarbaby','The Not Content field must be left empty for your post to work');
		}
		$fields_to_tidy = array('post_content','description');
		foreach($fields_to_tidy as $field)
		{
			if($this->get_value($field))
			{
				$tidied = trim(tidy($this->get_value($field)));
				if(empty($tidied) && in_array($field,$this->required))
				{
					if(!empty($this->elements[$field]['display_name']))
					{
						$display_name = $this->elements[$field]['display_name'];
					}
					else
					{
						$display_name = prettify_string($field);
					}
					$this->set_error($field,'Please fill in the '.$display_name.' field');
				}
				else
				{
					$tidy_errors = tidy_err($this->get_value($field));
					if(!empty($tidy_errors))
					{
						$msg = 'The html in the '.$field.' field is misformed.  Here is what the html checker has to say:<ul>';
						foreach($tidy_errors as $tidy_error)
						{
							$msg .= '<li>'.$tidy_error.'</li>';
						}
						$msg .= '</ul>';
						$this->set_error($field,$msg);
					}
				}
			}
		}
	}
 function sitebar()
 {
     echo '<div class="sites">';
     if (!$this->id) {
         $sites = $this->get_sites();
         echo '<form action="?" name="siteSwitchSelect" class="jumpNavigation" method="get">' . "\n";
         echo 'Site: <select name="site_id" class="jumpDestination siteMenu">' . "\n";
         echo '<option value="">--</option>' . "\n";
         foreach (array_keys($sites) as $site_id) {
             echo '<option value="' . $site_id . '"';
             if ($site_id == $this->site_id) {
                 echo ' selected="selected"';
             }
             echo '>' . strip_tags($sites[$site_id]->get_value('name')) . '</option>' . "\n";
         }
         $this->show['sites'] = false;
         echo '</select>';
         if (isset($_GET['user_id']) && !empty($_GET['user_id'])) {
             $user_id = turn_into_int($_GET['user_id']);
             if (!empty($user_id)) {
                 echo '<input type="hidden" name="user_id" value="' . $user_id . '" />';
             }
         }
         echo '<input type="submit" class="jumpNavigationGo" value="go" />';
         $cur_site = $sites[$this->site_id];
         $cur_site_base_url = $cur_site->get_value('base_url');
         $cur_site_unique_name = $cur_site->get_value('unique_name');
         $user = new entity($this->user_id);
         $target = $user->get_value('site_window_pref') == 'Popup Window' ? 'target="_blank" ' : '';
         if (!empty($cur_site_base_url) && $cur_site_unique_name != 'master_admin') {
             echo '<a href="http://' . REASON_HOST . $cur_site_base_url . '" ' . $target . 'class="publicSiteLink">Go to public site</a>';
         }
         echo '</form>';
     } else {
         $site = new entity($this->site_id);
         if ($site->get_values()) {
             echo 'Site: <strong>' . $site->get_value('name') . '</strong>' . "\n";
             if ($this->type_id) {
                 $e = new entity($this->type_id);
                 echo '<strong> :: </strong>' . prettify_string($e->get_value('name'));
                 if ($this->id) {
                     $e = new entity($this->id);
                     echo '<strong> :: </strong>' . $e->get_value('name');
                 }
             }
         }
     }
     echo '</div>';
 }
Exemple #30
0
	/**
	 * Display the view options portion of the list chrome
	 *
	 * That is, the tabs for daily, weekly, monthly, yearly views
	 *
	 * @return void
	 * @todo move into markup class
	 */
	function get_view_options()
	{
		$ret = '';
		$ret .= "\n".'<div class="views">'."\n";
		$ret .= '<h4>View:</h4>';
		$ret .= '<ul>'."\n";
		$on_defined_view = false;
		foreach($this->calendar->get_views() as $view_name=>$view)
		{
			if($view != $this->calendar->get_view())
			{
				$link_params = array('view'=>$view,'end_date'=>'');
				if(in_array($view,$this->views_no_index))
					$link_params['no_search'] = 1;
				$opener = '<li><a href="'.$this->construct_link($link_params).'">';
				$closer = '</a></li>';
			}
			else
			{
				$opener = '<li class="current"><strong>';
				$closer = '</strong></li>';
				$on_defined_view = true;
			}
			
			$ret .= $opener.prettify_string($view_name).$closer;
		}
		if(!$on_defined_view)
		{
			$ret .= '<li class="current"><strong>'.$this->get_scope('-').'</strong></li>'."\n";
		}
		$ret .= '</ul>'."\n";
		$ret .= '</div>'."\n";
		return $ret;
	}