function init($args = array())
 {
     parent::init();
     $valid = true;
     if (empty($this->params['default']) || check_against_array($this->params['default'], array('show_content', 'hide_content')) == false) {
         trigger_error('Blurb conditional module called with invalid default setting - content will be displayed as if the regular content module was used');
         $this->params['default'] = 'show_content';
         $valid = false;
     }
     if (empty($this->params['parameter'])) {
         trigger_error('Blurb conditional module called without "parameter" defined - the default setting ' . $this->params['default'] . ' will be used and the parameter ignored');
         $valid = false;
     }
     if (empty($this->params['conditional']) || check_against_array($this->params['conditional'], array('<', '<=', '>', '>=', '==', '!=')) == false) {
         trigger_error('Blurb conditional module called with invalid conditional - the default setting ' . $this->params['default'] . ' will be used and the parameter ignored');
         $valid = false;
     }
     if (empty($this->params['cleanup_function'])) {
         trigger_error('Blurb conditional module was not passed a cleanup_function - the default setting ' . $this->params['default'] . ' will be used and the parameter ignored');
         $valid = false;
     }
     if ($valid && isset($this->request[$this->params['parameter']])) {
         $this->param = $this->request[$this->params['parameter']];
     }
 }
Example #2
0
 /**
  * initialize request
  *
  * @param int $site_id id of the site from where the request originates
  * @param int $al_relationship_id the id of the allowable relationship
  * @param int $left_entity_id the id of the entity on the a site of the relationship
  * @param int $entity_id the id of the entity that is moving up or down
  * @param int $row_id the row number of the entity that is moving up or down
  * @param string $direction which direction the entity is moving
  * @param string $user_netID the netid of the user initiating the request
  * @param string $background set to 'yes' if the request comes via xmlhttp, 'no' if not
  */
 function init($site_id, $al_relationship_id, $left_entity_id, $entity_id, $row_id, $direction, $user_netID, $background)
 {
     $this->user_netID = check_against_regexp($user_netID, array('alphanumeric'));
     $this->direction = check_against_array($direction, array('moveup', 'movedown'));
     $this->left_entity_id = turn_into_int($left_entity_id);
     $this->entity_id = turn_into_int($entity_id);
     $this->row_id = turn_into_int($row_id);
     $this->al_relationship_id = turn_into_int($al_relationship_id);
     $this->site_id = turn_into_int($site_id);
     //$this->type_id = turn_into_int($type_id);
     $this->background = check_against_array($background, array('yes', 'no'));
     // consider passing this in earlier, or just use
 }
	/**     
	 *	Updates a relationship with a given id
	 *
	 *	@param	int $id	ID of existant relationship
	 *	@param	array $values key=>value pairs of columns to update
	 *	@return	void
	 *  @author nwhite
	 */
	function update_relationship( $id, $values)
	{
		$q = $q2 = '';
		$id = turn_into_int($id);
		foreach ($values as $k=>$v)
		{
			$col_name = check_against_array($k, array('id', 'entity_a', 'entity_b', 'type', 'site', 'rel_sort_order'));
			$value = turn_into_int($v);
			if (!empty($col_name) && !empty($value))
			{
				$q2 .= $col_name . ' = ' . $value . ', ';
			}
		}
		if (!empty($q2))
		{
			$q2 = substr($q2, 0, -2);
			$q .= 'UPDATE relationship SET ' .$q2 . ' WHERE id = ' . $id;
			db_query( $q, 'Unable to update relationship with id ' . $id );
		}
	} // }}}
Example #4
0
$es->add_type(id_of('minisite_page'));
$es->limit_tables(array('page_node', 'url'));
$es->limit_fields('entity.name, page_node.custom_page, page_node.url_fragment, url.url');
$es->add_right_relationship_field('owns', 'entity', 'id', 'owner_id');
$es->add_right_relationship_field('owns', 'entity', 'name', 'site_name');
$es->add_left_relationship_field('minisite_page_parent', 'entity', 'id', 'parent_id');
// we add some relations so that we grab only valid pages with names that are not custom url pages
$es->add_relation('(entity.name != "") AND ((url.url = "") OR (url.url IS NULL))');
$result = $es->run_one();
$builder = new reasonPageURL();
$builder->provide_page_entities($result);
$request = carl_get_request();
$detail_mode = isset($request['detail']) ? $request['detail'] == 'true' : false;
$module_limiter = isset($request['limit']) ? conditional_stripslashes(turn_into_string($request['limit'])) : '';
$detail_limiter = isset($request['detail_limit']) ? conditional_stripslashes(turn_into_string($request['detail_limit'])) : '';
$core_local_limiter = isset($request['core_local_limit']) ? check_against_array($request['core_local_limit'], array('core', 'local')) : '';
$num = isset($request['num']) ? turn_into_int($request['num']) : 'All';
if (isset($request['reset'])) {
    header("Location: " . carl_make_redirect(array('limit' => '', 'core_local_limit' => '')));
    exit;
}
// Make an array with first dimension of page type name, second dimension of every page
// ID using the pt, third dimension 'true' for every page type returned by the query.
foreach ($result as $k => $mypage) {
    $page_type_value = $mypage->get_value('custom_page');
    if (empty($page_type_value)) {
        $page_type_value = 'default';
    }
    $reason_page_types[$page_type_value][$k] = 'true';
}
$rpts =& get_reason_page_types();
    } else {
        $data_pages[$page_type]['count']++;
    }
}
// lets add page_types that do not exist
$page_types_no_pages = array_diff(array_values($rpt->get_page_type_names()), array_keys($data_pages));
foreach ($page_types_no_pages as $page_type_no_page) {
    $data_pages[$page_type_no_page]['page_type'] = $page_type_no_page;
    $pt = @$rpt->get_page_type($page_type_no_page);
    $data_pages[$page_type_no_page]['location'] = is_object($pt) ? $pt->get_location() : "";
    $data_pages[$page_type_no_page]['url'] = '';
    $data_pages[$page_type_no_page]['count'] = 0;
}
// let's sort our data set
$sort_field = isset($_GET['table_sort_field']) && check_against_array($_GET['table_sort_field'], array('page_type', 'count', 'url', 'location')) ? $_GET['table_sort_field'] : 'count';
$sort_order = isset($_GET['table_sort_order']) && check_against_array($_GET['table_sort_order'], array('desc', 'asc')) ? $_GET['table_sort_order'] : 'desc';
// do our manual sorting
$sort_func = "_sort_" . $sort_field . "_" . $sort_order;
uasort($data_pages, $sort_func);
$table_admin = new TableAdmin();
$table_admin->set_show_actions_first_cell(false);
$table_admin->set_fields_to_entity_convert(array('count', 'page_type', 'location'));
$table_admin->init_from_array($data_pages, true);
$table_admin->run();
echo '</body>';
echo '</html>';
function _sort_count_desc($a, $b)
{
    if ($a['count'] == $b['count']) {
        return 0;
    }