12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657 |
- <?php
- class view extends views_db_object {
- var $db_table = 'views_view';
- var $base_table = 'node';
- var $base_field = 'nid';
-
- var $name = "";
-
- var $vid;
-
- var $description;
-
- var $tag;
-
- var $human_name;
-
- var $core;
-
- var $api_version;
-
- var $disabled;
-
- var $built = FALSE;
- var $executed = FALSE;
- var $editing = FALSE;
- var $args = array();
- var $build_info = array();
- var $use_ajax = FALSE;
-
- var $result = array();
-
- var $current_page = NULL;
- var $items_per_page = NULL;
- var $offset = NULL;
- var $total_rows = NULL;
-
- var $attachment_before = '';
- var $attachment_after = '';
-
- var $exposed_data = array();
- var $exposed_input = array();
-
- var $exposed_raw_input = array();
-
- var $old_view = array();
-
- var $parent_views = array();
-
- var $is_attachment = NULL;
-
-
-
-
-
-
- var $current_display;
-
- var $query = NULL;
-
- var $display_handler;
-
- var $display;
-
- var $style_plugin;
-
- var $style_options;
-
- var $row_index;
-
- var $override_url = NULL;
-
- var $override_path = NULL;
-
- var $base_database = NULL;
-
-
- var $field;
-
- var $argument;
-
- var $sort;
-
- var $filter;
-
- var $relationship;
-
- var $header;
-
- var $footer;
-
- var $empty;
-
- function __construct() {
- parent::init();
-
- foreach ($this->db_objects() as $object) {
- $this->$object = array();
- }
- }
-
- function update() {
-
-
- $this->base_table = views_move_table($this->base_table);
- }
-
- function display_objects() {
- return array('argument', 'field', 'sort', 'filter', 'relationship', 'header', 'footer', 'empty');
- }
-
- static function db_objects() {
- return array('display');
- }
-
- function set_arguments($args) {
- $this->args = $args;
- }
-
- function set_current_page($page) {
- $this->current_page = $page;
-
- if (!empty($this->query->pager)) {
- return $this->query->pager->set_current_page($page);
- }
- }
-
- function get_current_page() {
-
- if (!empty($this->query->pager)) {
- return $this->query->pager->get_current_page();
- }
- if (isset($this->current_page)) {
- return $this->current_page;
- }
- }
-
- function get_items_per_page() {
-
- if (!empty($this->query->pager)) {
- return $this->query->pager->get_items_per_page();
- }
- if (isset($this->items_per_page)) {
- return $this->items_per_page;
- }
- }
-
- function set_items_per_page($items_per_page) {
- $this->items_per_page = $items_per_page;
-
- if (!empty($this->query->pager)) {
- $this->query->pager->set_items_per_page($items_per_page);
- }
- }
-
- function get_offset() {
-
- if (!empty($this->query->pager)) {
- return $this->query->pager->get_offset();
- }
- if (isset($this->offset)) {
- return $this->offset;
- }
- }
-
- function set_offset($offset) {
- $this->offset = $offset;
-
- if (!empty($this->query->pager)) {
- $this->query->pager->set_offset($offset);
- }
- }
-
- function use_pager() {
- if (!empty($this->query->pager)) {
- return $this->query->pager->use_pager();
- }
- }
-
- function set_use_ajax($use_ajax) {
- $this->use_ajax = $use_ajax;
- }
-
- function set_exposed_input($filters) {
- $this->exposed_input = $filters;
- }
-
- function get_exposed_input() {
-
-
- if (empty($this->exposed_input)) {
- $this->exposed_input = $_GET;
-
- foreach (array('page', 'q') as $key) {
- if (isset($this->exposed_input[$key])) {
- unset($this->exposed_input[$key]);
- }
- }
-
-
-
-
-
- $display_id = ($this->display_handler->is_defaulted('filters')) ? 'default' : $this->current_display;
- if (empty($this->exposed_input) && !empty($_SESSION['views'][$this->name][$display_id])) {
- $this->exposed_input = $_SESSION['views'][$this->name][$display_id];
- }
- }
- return $this->exposed_input;
- }
-
- function init_display($reset = FALSE) {
-
- if (isset($this->current_display)) {
- return TRUE;
- }
-
- foreach (array_keys($this->display) as $id) {
-
-
-
-
-
-
- if (!empty($this->display[$id]->handler)) {
- $this->display[$id] = clone $this->display[$id];
- unset($this->display[$id]->handler);
- }
- $this->display[$id]->handler = views_get_plugin('display', $this->display[$id]->display_plugin);
- if (!empty($this->display[$id]->handler)) {
- $this->display[$id]->handler->localization_keys = array($id);
-
- $this->display[$id]->handler->init($this, $this->display[$id]);
-
-
-
-
- if ($id != 'default') {
- $this->display[$id]->handler->default_display = &$this->display['default']->handler;
- }
- }
- }
- $this->current_display = 'default';
- $this->display_handler = &$this->display['default']->handler;
- return TRUE;
- }
-
- function choose_display($displays) {
- if (!is_array($displays)) {
- return $displays;
- }
- $this->init_display();
- foreach ($displays as $display_id) {
- if ($this->display[$display_id]->handler->access()) {
- return $display_id;
- }
- }
- return 'default';
- }
-
- function set_display($display_id = NULL) {
-
- if (empty($this->current_display)) {
- $this->init_display();
-
-
- if (empty($display_id)) {
- $display_id = 'default';
- }
- }
- $display_id = $this->choose_display($display_id);
-
- if (empty($display_id)) {
- return FALSE;
- }
-
- if (empty($this->display[$display_id])) {
- $display_id = 'default';
- if (empty($this->display[$display_id])) {
- vpr('set_display() called with invalid display id @display.', array('@display' => $display_id));
- return FALSE;
- }
- }
-
- $this->current_display = $display_id;
-
- if (empty($this->display[$display_id]->handler)) {
- return FALSE;
- }
-
- $this->display_handler = &$this->display[$display_id]->handler;
- return TRUE;
- }
-
- function init_style() {
- if (isset($this->style_plugin)) {
- return is_object($this->style_plugin);
- }
- if (!isset($this->plugin_name)) {
- $this->plugin_name = $this->display_handler->get_option('style_plugin');
- $this->style_options = $this->display_handler->get_option('style_options');
- }
- $this->style_plugin = views_get_plugin('style', $this->plugin_name);
- if (empty($this->style_plugin)) {
- return FALSE;
- }
-
- $this->style_plugin->init($this, $this->display[$this->current_display], $this->style_options);
- return TRUE;
- }
-
- function fix_missing_relationships() {
- if (isset($this->relationships_fixed)) {
- return;
- }
- $this->relationships_fixed = TRUE;
-
-
-
- $base_tables = array(
- $this->base_table => TRUE,
- '#global' => TRUE,
- );
-
-
- foreach ($this->display_handler->get_option('relationships') as $id => $options) {
- $options['table'] = views_move_table($options['table']);
- $data = views_fetch_data($options['table'], FALSE);
- if (isset($data[$options['field']]['relationship']['base'])) {
- $base_tables[$data[$options['field']]['relationship']['base']] = TRUE;
- }
- }
- $base_tables = array_keys($base_tables);
- $missing_base_tables = array();
- $types = views_object_types();
- foreach ($types as $key => $info) {
- foreach ($this->display_handler->get_option($info['plural']) as $id => $options) {
- $options['table'] = views_move_table($options['table']);
- $data = views_fetch_data($options['table'], FALSE);
- $valid_bases = array($options['table']);
- if (isset($data['table']['join'])) {
- $valid_bases = array_merge($valid_bases, array_keys($data['table']['join']));
- }
-
- if (!array_intersect($valid_bases, $base_tables)) {
- $missing_base_tables[$options['table']][] = array('type' => $key, 'id' => $id);
- }
- }
- }
- if (!empty($missing_base_tables)) {
-
-
- $this->display_handler->handlers = array();
- $this->relationships_changed = TRUE;
- $this->changed = TRUE;
-
- foreach ($missing_base_tables as $table => $handlers) {
- $data = views_fetch_data($table);
- $relationship = NULL;
-
-
- if (isset($data['table']['default_relationship'][$this->base_table])) {
-
- $info = $data['table']['default_relationship'][$this->base_table];
- $relationship_options = isset($info['options']) ? $info['options'] : array();
- $relationship = $this->add_item($this->current_display, 'relationship', $info['table'], $info['field'], $relationship_options);
- }
- foreach ($handlers as $handler) {
- $options = $this->display_handler->get_option($types[$handler['type']]['plural']);
- if ($relationship) {
- $options[$handler['id']]['relationship'] = $relationship;
- }
- else {
- unset($options[$handler['id']]);
- }
- $this->display_handler->set_option($types[$handler['type']]['plural'], $options);
- }
- }
- }
- }
-
- function init_handlers() {
- if (empty($this->inited)) {
- $this->fix_missing_relationships();
- foreach (views_object_types() as $key => $info) {
- $this->_init_handler($key, $info);
- }
- $this->inited = TRUE;
- }
- }
-
- function init_pager() {
- if (empty($this->query->pager)) {
- $this->query->pager = $this->display_handler->get_plugin('pager');
- if ($this->query->pager->use_pager()) {
- $this->query->pager->set_current_page($this->current_page);
- }
-
-
- if (isset($this->items_per_page)) {
- $this->query->pager->set_items_per_page($this->items_per_page);
- }
- if (isset($this->offset)) {
- $this->query->pager->set_offset($this->offset);
- }
- }
- }
-
- function get_base_tables() {
- $base_tables = array(
- $this->base_table => TRUE,
- '#global' => TRUE,
- );
- foreach ($this->display_handler->get_handlers('relationship') as $handler) {
- $base_tables[$handler->definition['base']] = TRUE;
- }
- return $base_tables;
- }
-
- function _pre_query() {
- foreach (views_object_types() as $key => $info) {
- $handlers = &$this->$key;
- $position = 0;
- foreach ($handlers as $id => $handler) {
- $handlers[$id]->position = $position;
- $handlers[$id]->pre_query();
- $position++;
- }
- }
- }
-
- function _post_execute() {
- foreach (views_object_types() as $key => $info) {
- $handlers = &$this->$key;
- foreach ($handlers as $id => $handler) {
- $handlers[$id]->post_execute($this->result);
- }
- }
- }
-
- function _init_handler($key, $info) {
-
- $this->$key = $this->display_handler->get_handlers($key);
-
- $handlers = &$this->$key;
-
- foreach ($handlers as $id => $handler) {
- if (!$handler->access()) {
- unset($handlers[$id]);
- }
- }
- }
-
- function _build_arguments() {
-
-
- if (empty($this->argument)) {
- return TRUE;
- }
-
- $position = -1;
-
- $title = $this->display_handler->get_option('title');
- $this->build_info['breadcrumb'] = array();
- $breadcrumb_args = array();
- $substitutions = array();
- $status = TRUE;
-
- foreach ($this->argument as $id => $arg) {
- $position++;
- $argument = &$this->argument[$id];
- if ($argument->broken()) {
- continue;
- }
- $argument->set_relationship();
- $arg = isset($this->args[$position]) ? $this->args[$position] : NULL;
- $argument->position = $position;
- if (isset($arg) || $argument->has_default_argument()) {
- if (!isset($arg)) {
- $arg = $argument->get_default_argument();
-
- if (isset($arg)) {
- $this->args[$position] = $arg;
- }
-
- $argument->is_default = TRUE;
- }
-
- if (!$argument->set_argument($arg)) {
- $status = $argument->validate_fail($arg);
- break;
- }
- if ($argument->is_exception()) {
- $arg_title = $argument->exception_title();
- }
- else {
- $arg_title = $argument->get_title();
- $argument->query($this->display_handler->use_group_by());
- }
-
- $substitutions['%' . ($position + 1)] = $arg_title;
- $substitutions['!' . ($position + 1)] = strip_tags(decode_entities($arg));
-
-
- if ($this->display_handler->uses_breadcrumb() && $argument->uses_breadcrumb()) {
- $path = $this->get_url($breadcrumb_args);
- if (strpos($path, '%') === FALSE) {
- if (!empty($argument->options['breadcrumb_enable']) && !empty($argument->options['breadcrumb'])) {
- $breadcrumb = $argument->options['breadcrumb'];
- }
- else {
- $breadcrumb = $title;
- }
- $this->build_info['breadcrumb'][$path] = str_replace(array_keys($substitutions), $substitutions, $breadcrumb);
- }
- }
-
- $argument->set_breadcrumb($this->build_info['breadcrumb']);
-
- if (!empty($argument->options['title_enable']) && !empty($argument->options['title'])) {
- $title = $argument->options['title'];
- }
- $breadcrumb_args[] = $arg;
- }
- else {
-
- $status = $argument->default_action();
- break;
- }
-
- unset($argument);
- }
-
- if (!empty($title)) {
- $this->build_info['title'] = $title;
- }
-
- $this->build_info['substitutions'] = $substitutions;
- return $status;
- }
-
- function init_query() {
- if (!empty($this->query)) {
- $class = get_class($this->query);
- if ($class && $class != 'stdClass') {
-
- return TRUE;
- }
- }
-
- $views_data = views_fetch_data($this->base_table);
- $this->base_field = !empty($views_data['table']['base']['field']) ? $views_data['table']['base']['field'] : '';
- if (!empty($views_data['table']['base']['database'])) {
- $this->base_database = $views_data['table']['base']['database'];
- }
-
- $query_options = $this->display_handler->get_option('query');
-
- $plugin = !empty($views_data['table']['base']['query class']) ? $views_data['table']['base']['query class'] : 'views_query';
- $this->query = views_get_plugin('query', $plugin);
- if (empty($this->query)) {
- return FALSE;
- }
- $this->query->init($this->base_table, $this->base_field, $query_options['options']);
- return TRUE;
- }
-
- function build($display_id = NULL) {
- if (!empty($this->built)) {
- return;
- }
- if (empty($this->current_display) || $display_id) {
- if (!$this->set_display($display_id)) {
- return FALSE;
- }
- }
-
- foreach (module_implements('views_pre_build') as $module) {
- $function = $module . '_views_pre_build';
- $function($this);
- }
-
-
- $start = microtime(TRUE);
-
- $this->build_info = array(
- 'query' => '',
- 'count_query' => '',
- 'query_args' => array(),
- );
- $this->init_query();
-
-
-
-
-
- $this->init_handlers();
-
- $this->_pre_query();
- if ($this->display_handler->uses_exposed()) {
- $exposed_form = $this->display_handler->get_plugin('exposed_form');
-
- $errors_before = form_set_error();
- $this->exposed_widgets = $exposed_form->render_exposed_form();
-
- $errors_after = form_set_error();
-
-
-
- $exposed_errors = count($errors_after) > count($errors_before);
- if ($exposed_errors || !empty($this->build_info['abort'])) {
- $this->built = TRUE;
-
- $this->executed = TRUE;
- return empty($this->build_info['fail']);
- }
- }
-
- $this->_build('relationship');
-
- if (!empty($this->filter)) {
- $filter_groups = $this->display_handler->get_option('filter_groups');
- if ($filter_groups) {
- $this->query->set_group_operator($filter_groups['operator']);
- foreach($filter_groups['groups'] as $id => $operator) {
- $this->query->set_where_group($operator, $id);
- }
- }
- }
-
- $this->_build('filter');
- $this->build_sort = TRUE;
-
- if (!$this->_build_arguments()) {
- $this->build_time = microtime(TRUE) - $start;
- $this->attach_displays();
- return $this->built;
- }
-
-
-
- if (!$this->init_style()) {
- $this->build_info['fail'] = TRUE;
- return FALSE;
- }
- if ($this->style_plugin->uses_fields()) {
- $this->_build('field');
- }
-
- if (!empty($this->build_sort)) {
-
- if ($this->style_plugin->build_sort()) {
- $this->_build('sort');
- }
-
- $this->style_plugin->build_sort_post();
- }
-
- $this->_build('header');
- $this->_build('footer');
- $this->_build('empty');
-
- $this->display_handler->query($this->display_handler->use_group_by());
-
- $this->style_plugin->query($this->display_handler->use_group_by());
-
- if (isset($exposed_form)) {
- $exposed_form->query();
- }
- if (variable_get('views_sql_signature', FALSE)) {
- $this->query->add_signature($this);
- }
-
- $this->query->alter($this);
-
- if (empty($this->built)) {
-
- $this->query->build($this);
- }
- $this->built = TRUE;
- $this->build_time = microtime(TRUE) - $start;
-
- $this->attach_displays();
-
- foreach (module_implements('views_post_build') as $module) {
- $function = $module . '_views_post_build';
- $function($this);
- }
- return TRUE;
- }
-
- function _build($key) {
- $handlers = &$this->$key;
- foreach ($handlers as $id => $data) {
- if (!empty($handlers[$id]) && is_object($handlers[$id])) {
- $multiple_exposed_input = array(0 => NULL);
- if ($handlers[$id]->multiple_exposed_input()) {
- $multiple_exposed_input = $handlers[$id]->group_multiple_exposed_input($this->exposed_data);
- }
- foreach ($multiple_exposed_input as $group_id) {
-
- if (!empty($this->exposed_data)) {
- $converted = FALSE;
- if ($handlers[$id]->is_a_group()) {
- $converted = $handlers[$id]->convert_exposed_input($this->exposed_data, $group_id);
- $handlers[$id]->store_group_input($this->exposed_data, $converted);
- if (!$converted) {
- continue;
- }
- }
- $rc = $handlers[$id]->accept_exposed_input($this->exposed_data);
- $handlers[$id]->store_exposed_input($this->exposed_data, $rc);
- if (!$rc) {
- continue;
- }
- }
- $handlers[$id]->set_relationship();
- $handlers[$id]->query($this->display_handler->use_group_by());
- }
- }
- }
- }
-
- function execute($display_id = NULL) {
- if (empty($this->built)) {
- if (!$this->build($display_id)) {
- return FALSE;
- }
- }
- if (!empty($this->executed)) {
- return TRUE;
- }
-
- if (!$this->display[$this->current_display]->handler->get_option('enabled') && empty($this->live_preview)) {
- $this->build_info['fail'] = TRUE;
- return FALSE;
- }
-
- foreach (module_implements('views_pre_execute') as $module) {
- $function = $module . '_views_pre_execute';
- $function($this);
- }
-
- if (!empty($this->live_preview)) {
- $cache = FALSE;
- }
- else {
- $cache = $this->display_handler->get_plugin('cache');
- }
- if ($cache && $cache->cache_get('results')) {
- if($this->query->pager->use_pager()) {
- $this->query->pager->total_items = $this->total_rows;
- $this->query->pager->update_page_info();
- }
- vpr('Used cached results');
- }
- else {
- $this->query->execute($this);
-
-
- $this->result = array_values($this->result);
- $this->_post_execute();
- if ($cache) {
- $cache->cache_set('results');
- }
- }
-
- foreach (module_implements('views_post_execute') as $module) {
- $function = $module . '_views_post_execute';
- $function($this);
- }
- $this->executed = TRUE;
- }
-
- function render($display_id = NULL) {
- $this->execute($display_id);
-
- if (!empty($this->build_info['fail'])) {
- return;
- }
- if (!empty($this->view->build_info['denied'])) {
- return;
- }
- drupal_theme_initialize();
- $start = microtime(TRUE);
- if (!empty($this->live_preview) && variable_get('views_show_additional_queries', FALSE)) {
- $this->start_query_capture();
- }
- $exposed_form = $this->display_handler->get_plugin('exposed_form');
- $exposed_form->pre_render($this->result);
-
- if (!empty($this->live_preview)) {
- $cache = FALSE;
- }
- else {
- $cache = $this->display_handler->get_plugin('cache');
- }
- if ($cache && $cache->cache_get('output')) {
- }
- else {
- if ($cache) {
- $cache->cache_start();
- }
-
- if (!empty($this->query->pager)) {
- $this->query->pager->pre_render($this->result);
- }
-
- $this->init_style();
-
-
- if ($this->style_plugin->uses_fields()) {
- foreach ($this->field as $id => $handler) {
- if (!empty($this->field[$id])) {
- $this->field[$id]->pre_render($this->result);
- }
- }
- }
- $this->style_plugin->pre_render($this->result);
-
- foreach (module_implements('views_pre_render') as $module) {
- $function = $module . '_views_pre_render';
- $function($this);
- }
-
- foreach ($GLOBALS['base_theme_info'] as $base) {
- $function = $base->name . '_views_pre_render';
- if (function_exists($function)) {
- $function($this);
- }
- }
- $function = $GLOBALS['theme'] . '_views_pre_render';
- if (function_exists($function)) {
- $function($this);
- }
- $this->display_handler->output = $this->display_handler->render();
- if ($cache) {
- $cache->cache_set('output');
- }
- }
- $this->render_time = microtime(TRUE) - $start;
- $exposed_form->post_render($this->display_handler->output);
- if ($cache) {
- $cache->post_render($this->display_handler->output);
- }
-
- foreach (module_implements('views_post_render') as $module) {
- $function = $module . '_views_post_render';
- $function($this, $this->display_handler->output, $cache);
- }
-
- foreach ($GLOBALS['base_theme_info'] as $base) {
- $function = $base->name . '_views_post_render';
- if (function_exists($function)) {
- $function($this);
- }
- }
- $function = $GLOBALS['theme'] . '_views_post_render';
- if (function_exists($function)) {
- $function($this, $this->display_handler->output, $cache);
- }
- if (!empty($this->live_preview) && variable_get('views_show_additional_queries', FALSE)) {
- $this->end_query_capture();
- }
- return $this->display_handler->output;
- }
-
- function render_field($field, $row) {
- if (isset($this->field[$field]) && isset($this->result[$row])) {
- return $this->field[$field]->advanced_render($this->result[$row]);
- }
- }
-
- function execute_display($display_id = NULL, $args = array()) {
- if (empty($this->current_display) || $this->current_display != $this->choose_display($display_id)) {
- if (!$this->set_display($display_id)) {
- return FALSE;
- }
- }
- $this->pre_execute($args);
-
- $output = $this->display_handler->execute();
- $this->post_execute();
- return $output;
- }
-
- function preview($display_id = NULL, $args = array()) {
- if (empty($this->current_display) || ((!empty($display_id)) && $this->current_display != $display_id)) {
- if (!$this->set_display($display_id)) {
- return FALSE;
- }
- }
- $this->preview = TRUE;
- $this->pre_execute($args);
-
- $output = $this->display_handler->preview();
- $this->post_execute();
- return $output;
- }
-
- function pre_execute($args = array()) {
- $this->old_view[] = views_get_current_view();
- views_set_current_view($this);
- $display_id = $this->current_display;
-
-
- if ($args) {
- $this->set_arguments($args);
- }
-
- foreach (module_implements('views_pre_view') as $module) {
- $function = $module . '_views_pre_view';
- $function($this, $display_id, $this->args);
- }
-
- $this->dom_id = !empty($this->dom_id) ? $this->dom_id : md5($this->name . REQUEST_TIME . rand());
-
- $this->display_handler->pre_execute();
- }
-
- function post_execute() {
-
-
- if ($this->old_view) {
- $old_view = array_pop($this->old_view);
- }
- views_set_current_view(isset($old_view) ? $old_view : FALSE);
- }
-
- function attach_displays() {
- if (!empty($this->is_attachment)) {
- return;
- }
- if (!$this->display_handler->accept_attachments()) {
- return;
- }
- $this->is_attachment = TRUE;
-
- foreach ($this->display as $id => $display) {
- if (!empty($this->display[$id]->handler)) {
- $this->display[$id]->handler->attach_to($this->current_display);
- }
- }
- $this->is_attachment = FALSE;
- }
-
- function execute_hook_menu($display_id = NULL, &$callbacks = array()) {
-
-
- if (!$this->set_display($display_id)) {
- return FALSE;
- }
-
- if (isset($this->display_handler)) {
- return $this->display_handler->execute_hook_menu($callbacks);
- }
- }
-
- function execute_hook_block_list($display_id = NULL) {
-
-
- if (!$this->set_display($display_id)) {
- return FALSE;
- }
-
- if (isset($this->display_handler)) {
- return $this->display_handler->execute_hook_block_list();
- }
- }
-
- function access($displays = NULL, $account = NULL) {
-
- if (!empty($this->disabled)) {
- return FALSE;
- }
- if (!isset($this->current_display)) {
- $this->init_display();
- }
- if (!$account) {
- $account = $GLOBALS['user'];
- }
-
-
- $displays = (array)$displays;
- foreach ($displays as $display_id) {
- if (!empty($this->display[$display_id]->handler)) {
- if ($this->display[$display_id]->handler->access($account)) {
- return TRUE;
- }
- }
- }
- return FALSE;
- }
-
- function get_title() {
- if (empty($this->display_handler)) {
- if (!$this->set_display('default')) {
- return FALSE;
- }
- }
-
- if (!empty($this->build_info['title'])) {
- $title = $this->build_info['title'];
- }
- else {
- $title = $this->display_handler->get_option('title');
- }
-
- if ($this->init_style()) {
- $title = $this->style_plugin->tokenize_value($title, 0);
- }
- return $title;
- }
-
- function set_title($title) {
- $this->build_info['title'] = $title;
- return TRUE;
- }
-
- function get_human_name() {
- if (!empty($this->human_name)) {
- $human_name = $this->human_name;
- }
- else {
- $human_name = $this->name;
- }
- return $human_name;
- }
-
- function build_title() {
- $this->init_display();
- if (empty($this->built)) {
- $this->init_query();
- }
- $this->init_handlers();
- $this->_build_arguments();
- }
-
- function get_url($args = NULL, $path = NULL) {
- if (!empty($this->override_url)) {
- return $this->override_url;
- }
- if (!isset($path)) {
- $path = $this->get_path();
- }
- if (!isset($args)) {
- $args = $this->args;
-
- $position = 0;
- if (!empty($this->argument)) {
- foreach ($this->argument as $argument_id => $argument) {
- if (!empty($argument->is_default) && !empty($argument->options['default_argument_skip_url'])) {
- unset($args[$position]);
- }
- $position++;
- }
- }
- }
-
- if (empty($path) || (empty($args) && strpos($path, '%') === FALSE)) {
- return $path;
- }
- $pieces = array();
- $argument_keys = isset($this->argument) ? array_keys($this->argument) : array();
- $id = current($argument_keys);
- foreach (explode('/', $path) as $piece) {
- if ($piece != '%') {
- $pieces[] = $piece;
- }
- else {
- if (empty($args)) {
-
- if ($id && !empty($this->argument[$id]->options['exception']['value'])) {
- $pieces[] = $this->argument[$id]->options['exception']['value'];
- }
- else {
- $pieces[] = '*';
- }
- }
- else {
- $pieces[] = array_shift($args);
- }
- if ($id) {
- $id = next($argument_keys);
- }
- }
- }
- if (!empty($args)) {
- $pieces = array_merge($pieces, $args);
- }
- return implode('/', $pieces);
- }
-
- function get_path() {
- if (!empty($this->override_path)) {
- return $this->override_path;
- }
- if (empty($this->display_handler)) {
- if (!$this->set_display('default')) {
- return FALSE;
- }
- }
- return $this->display_handler->get_path();
- }
-
- function get_breadcrumb($set = FALSE) {
-
- $base = TRUE;
- $breadcrumb = array();
- if (!empty($this->build_info['breadcrumb'])) {
- foreach ($this->build_info['breadcrumb'] as $path => $title) {
-
-
- if ($path == variable_get('site_frontpage', 'node')) {
- $base = FALSE;
- $title = t('Home');
- }
- if ($title) {
- $breadcrumb[] = l($title, $path, array('html' => TRUE));
- }
- }
- if ($set) {
- if ($base) {
- $breadcrumb = array_merge(drupal_get_breadcrumb(), $breadcrumb);
- }
- drupal_set_breadcrumb($breadcrumb);
- }
- }
- return $breadcrumb;
- }
-
- function is_cacheable() {
- return $this->is_cacheable;
- }
-
- function start_query_capture() {
- global $conf, $queries;
- if (empty($conf['dev_query'])) {
- $this->fix_dev_query = TRUE;
- $conf['dev_query'] = TRUE;
- }
-
-
- $this->last_query_key = NULL;
- if (!empty($queries)) {
- $keys = array_keys($queries);
- $this->last_query_key = array_pop($keys);
- }
- }
-
- function end_query_capture() {
- global $conf, $queries;
- if (!empty($this->fix_dev_query)) {
- $conf['dev_query'] = FALSE;
- }
-
- $temp = $queries;
-
-
- if (isset($this->last_query_key)) {
- while (list($id, $query) = each($queries)) {
- if ($id == $this->last_query_key) {
- break;
- }
- unset($temp[$id]);
- }
- }
- $this->additional_queries = $temp;
- }
-
- static function load_views() {
- $result = db_query("SELECT DISTINCT v.* FROM {views_view} v");
- $views = array();
-
- foreach ($result as $data) {
- $view = new view;
- $view->load_row($data);
- $view->loaded = TRUE;
- $view->type = t('Normal');
- $views[$view->name] = $view;
- $names[$view->vid] = $view->name;
- }
-
- if (!$views) {
- return array();
- }
-
- foreach (view::db_objects() as $key) {
- $object_name = "views_$key";
- $result = db_query("SELECT * FROM {{$object_name}} WHERE vid IN (:vids) ORDER BY vid, position",
- array(':vids' => array_keys($names)));
- foreach ($result as $data) {
- $object = new $object_name(FALSE);
- $object->load_row($data);
-
-
- $location = &$views[$names[$object->vid]]->$key;
-
-
- if (!empty($object->id)) {
- $location[$object->id] = $object;
- }
- else {
- $location[] = $object;
- }
- }
- }
- return $views;
- }
-
- function save() {
- if ($this->vid == 'new') {
- $this->vid = NULL;
- }
-
- elseif (empty($this->vid)) {
- $vid = db_query("SELECT vid from {views_view} WHERE name = :name", array(':name' => $this->name))->fetchField();
- $this->vid = $vid ? $vid : NULL;
- }
- $transaction = db_transaction();
- try {
-
- if (!empty($this->vid)) {
-
- foreach ($this->db_objects() as $key) {
- db_delete('views_' . $key)
- ->condition('vid', $this->vid)
- ->execute();
- }
- }
- $this->save_row(!empty($this->vid) ? 'vid' : FALSE);
-
- foreach ($this->db_objects() as $key) {
- $this->_save_rows($key);
- }
- }
- catch (Exception $e) {
- $transaction->rollback();
- watchdog_exception('views', $e);
- throw $e;
- }
- $this->save_locale_strings();
-
- views_invalidate_cache();
- }
-
- function _save_rows($key) {
- $count = 0;
- foreach ($this->$key as $position => $object) {
- $object->position = ++$count;
- $object->vid = $this->vid;
- $object->save_row();
- }
- }
-
- function delete($clear = TRUE) {
- if (empty($this->vid)) {
- return;
- }
- db_delete('views_view')
- ->condition('vid', $this->vid)
- ->execute();
-
- foreach ($this->db_objects() as $key) {
- db_delete('views_'. $key)
- ->condition('vid', $this->vid)
- ->execute();
- }
- cache_clear_all('views_query:' . $this->name, 'cache_views');
- if ($clear) {
-
- views_invalidate_cache();
- }
- }
-
- function export($indent = '') {
- $this->init_display();
- $this->init_query();
- $output = '';
- $output .= $this->export_row('view', $indent);
-
- $output .= $indent . '$view->api_version = \'' . views_api_version() . "';\n";
- $output .= $indent . '$view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */' . "\n";
- foreach ($this->display as $id => $display) {
- $output .= "\n" . $indent . "/* Display: $display->display_title */\n";
- $output .= $indent . '$handler = $view->new_display(' . ctools_var_export($display->display_plugin, $indent) . ', ' . ctools_var_export($display->display_title, $indent) . ', \'' . $id . "');\n";
- if (empty($display->handler)) {
-
-
-
- continue;
- }
- $output .= $display->handler->export_options($indent, '$handler->options');
- }
-
- if ($this->init_localization()) {
- $this->export_locale_strings('export');
- $translatables = $this->localization_plugin->export_render($indent);
- if (!empty($translatables)) {
- $output .= $translatables;
- }
- }
- return $output;
- }
-
- function copy() {
- $code = $this->export();
- eval($code);
- return $view;
- }
-
- function clone_view() {
- $clone = version_compare(phpversion(), '5.0') < 0 ? $this : clone($this);
- $keys = array('current_display', 'display_handler', 'build_info', 'built', 'executed', 'attachment_before', 'attachment_after', 'field', 'argument', 'filter', 'sort', 'relationship', 'header', 'footer', 'empty', 'query', 'inited', 'style_plugin', 'plugin_name', 'exposed_data', 'exposed_input', 'exposed_widgets', 'many_to_one_tables', 'feed_icon');
- foreach ($keys as $key) {
- if (isset($clone->$key)) {
- unset($clone->$key);
- }
- }
- $clone->built = $clone->executed = FALSE;
- $clone->build_info = array();
- $clone->attachment_before = '';
- $clone->attachment_after = '';
- $clone->result = array();
-
-
- $displays = array();
- foreach ($clone->display as $id => $display) {
- $displays[$id] = clone $display;
- if (isset($displays[$id]->handler)) {
- unset($displays[$id]->handler);
- }
- }
- $clone->display = $displays;
- return $clone;
- }
-
- function destroy() {
- foreach (array_keys($this->display) as $display_id) {
- if (isset($this->display[$display_id]->handler)) {
- $this->display[$display_id]->handler->destroy();
- unset($this->display[$display_id]->handler);
- }
- }
- foreach (views_object_types() as $type => $info) {
- if (isset($this->$type)) {
- $handlers = &$this->$type;
- foreach ($handlers as $id => $item) {
- $handlers[$id]->destroy();
- }
- unset($handlers);
- }
- }
- if (isset($this->style_plugin)) {
- $this->style_plugin->destroy();
- unset($this->style_plugin);
- }
-
- if (isset($this->display_handler)) {
- unset($this->display_handler);
- }
- if (isset($this->current_display)) {
- unset($this->current_display);
- }
- if (isset($this->query)) {
- unset($this->query);
- }
- $keys = array('current_display', 'display_handler', 'build_info', 'built', 'executed', 'attachment_before', 'attachment_after', 'field', 'argument', 'filter', 'sort', 'relationship', 'header', 'footer', 'empty', 'query', 'result', 'inited', 'style_plugin', 'plugin_name', 'exposed_data', 'exposed_input', 'many_to_one_tables');
- foreach ($keys as $key) {
- if (isset($this->$key)) {
- unset($this->$key);
- }
- }
-
-
- $keys = array('items_per_page', 'offset', 'current_page');
- foreach ($keys as $key) {
- if (isset($this->$key)) {
- $this->$key = NULL;
- }
- }
- $this->built = $this->executed = FALSE;
- $this->build_info = array();
- $this->attachment_before = '';
- $this->attachment_after = '';
- }
-
- function validate() {
- $this->init_display();
- $errors = array();
- $this->display_errors = NULL;
- $current_display = $this->current_display;
- foreach ($this->display as $id => $display) {
- if ($display->handler) {
- if (!empty($display->deleted)) {
- continue;
- }
- $result = $this->display[$id]->handler->validate();
- if (!empty($result) && is_array($result)) {
- $errors = array_merge($errors, $result);
-
- $this->display_errors[$id] = TRUE;
- }
- }
- }
- $this->set_display($current_display);
- return $errors ? $errors : TRUE;
- }
-
- function init_localization() {
- if (isset($this->localization_plugin) && is_object($this->localization_plugin)) {
- return TRUE;
- }
- $this->localization_plugin = views_get_plugin('localization', views_get_localization_plugin());
- if (empty($this->localization_plugin)) {
- $this->localization_plugin = views_get_plugin('localization', 'none');
- return FALSE;
- }
-
- $this->localization_plugin->init($this);
- return $this->localization_plugin->translate;
- }
-
- function is_translatable() {
-
-
- return (!isset($this->type) || in_array($this->type, array(t('Normal'), t('Overridden')))) ? TRUE : FALSE;
- }
-
- function save_locale_strings() {
- $this->process_locale_strings('save');
- }
-
- function delete_locale_strings() {
- $this->process_locale_strings('delete');
- }
-
- function export_locale_strings() {
- $this->process_locale_strings('export');
- }
-
- function process_locale_strings($op) {
-
-
-
- if (($this->is_translatable() || $op == 'export') && $this->init_display() && $this->init_localization()) {
- $this->localization_plugin->process_locale_strings($op);
- }
- }
- }
- class views_db_object {
- public $db_table;
-
- function init($init = TRUE) {
- if (is_array($init)) {
- return $this->load_row($init);
- }
- if (!$init) {
- return;
- }
- $schema = drupal_get_schema($this->db_table);
- if (!$schema) {
- return;
- }
-
- foreach ($schema['fields'] as $field => $info) {
- if ($info['type'] == 'serial') {
- $this->$field = NULL;
- }
- if (!isset($this->$field)) {
- if (!empty($info['serialize']) && isset($info['serialized default'])) {
- $this->$field = unserialize($info['serialized default']);
- }
- elseif (isset($info['default'])) {
- $this->$field = $info['default'];
- }
- else {
- $this->$field = '';
- }
- }
- }
- }
-
- function save_row($update = NULL) {
- $fields = $defs = $values = $serials = array();
- $schema = drupal_get_schema($this->db_table);
-
- foreach ($schema['fields'] as $field => $info) {
-
- if ($info['type'] == 'serial') {
- $serials[] = $field;
- continue;
- }
- elseif ($info['type'] == 'int') {
- $this->$field = (int) $this->$field;
- }
- $fields[$field] = empty($info['serialize']) ? $this->$field : serialize($this->$field);
- }
- if (!$update) {
- $query = db_insert($this->db_table);
- }
- else {
- $query = db_update($this->db_table)
- ->condition($update, $this->$update);
- }
- $return = $query
- ->fields($fields)
- ->execute();
- if ($serials && !$update) {
-
-
- foreach ($serials as $field) {
- $this->$field = $return;
- }
- }
- }
-
- function load_row($data) {
- $schema = drupal_get_schema($this->db_table);
-
- foreach ($schema['fields'] as $field => $info) {
- $this->$field = empty($info['serialize']) ? $data->$field : unserialize($data->$field);
- }
- }
-
- function export_row($identifier = NULL, $indent = '') {
- ctools_include('export');
- if (!$identifier) {
- $identifier = $this->db_table;
- }
- $schema = drupal_get_schema($this->db_table);
- $output = $indent . '$' . $identifier . ' = new ' . get_class($this) . "();\n";
-
- foreach ($schema['fields'] as $field => $info) {
- if (!empty($info['no export'])) {
- continue;
- }
- if (!isset($this->$field)) {
- if (isset($info['default'])) {
- $this->$field = $info['default'];
- }
- else {
- $this->$field = '';
- }
-
- if (isset($info['serialize'])) {
- $this->$field = unserialize($this->$field);
- }
- }
- $value = $this->$field;
- if ($info['type'] == 'int') {
- if (isset($info['size']) && $info['size'] == 'tiny') {
- $value = (bool) $value;
- }
- else {
- $value = (int) $value;
- }
- }
- $output .= $indent . '$' . $identifier . '->' . $field . ' = ' . ctools_var_export($value, $indent) . ";\n";
- }
- return $output;
- }
-
- function add_display($type = 'page', $title = NULL, $id = NULL) {
- if (empty($type)) {
- return FALSE;
- }
- $plugin = views_fetch_plugin_data('display', $type);
- if (empty($plugin)) {
- $plugin['title'] = t('Broken');
- }
- if (empty($id)) {
- $id = $this->generate_display_id($type);
- if ($id !== 'default') {
- preg_match("/[0-9]+/", $id, $count);
- $count = $count[0];
- }
- else {
- $count = '';
- }
- if (empty($title)) {
- if ($count > 1) {
- $title = $plugin['title'] . ' ' . $count;
- }
- else {
- $title = $plugin['title'];
- }
- }
- }
-
- $display = new views_display;
- $display->options($type, $id, $title);
-
- $this->display[$id] = $display;
- return $id;
- }
-
- function generate_display_id($type) {
-
-
- if ($type == 'default') {
- return 'default';
- }
-
- $id = $type . '_1';
- $count = 1;
-
-
- while (!empty($this->display[$id])) {
- $id = $type . '_' . ++$count;
- }
- return $id;
- }
-
- public static function generate_item_id($requested_id, $existing_items) {
- $count = 0;
- $id = $requested_id;
- while (!empty($existing_items[$id])) {
- $id = $requested_id . '_' . ++$count;
- }
- return $id;
- }
-
- function &new_display($type = 'page', $title = NULL, $id = NULL) {
- $id = $this->add_display($type, $title, $id);
-
- $this->display[$id]->handler = views_get_plugin('display', $this->display[$id]->display_plugin);
- if (empty($this->display[$id]->handler)) {
-
-
- $this->display[$id]->handler = views_get_plugin('display', 'default');
- }
- if (!empty($this->display[$id]->handler)) {
-
- $this->display[$id]->handler->init($this, $this->display[$id]);
-
- if ($id != 'default') {
- $this->display[$id]->handler->default_display = &$this->display['default']->handler;
- }
- }
- return $this->display[$id]->handler;
- }
-
- function add_item($display_id, $type, $table, $field, $options = array(), $id = NULL) {
- $types = views_object_types();
- $this->set_display($display_id);
- $fields = $this->display[$display_id]->handler->get_option($types[$type]['plural']);
- if (empty($id)) {
- $id = $this->generate_item_id($field, $fields);
- }
- $new_item = array(
- 'id' => $id,
- 'table' => $table,
- 'field' => $field,
- ) + $options;
- if (!empty($types[$type]['type'])) {
- $handler_type = $types[$type]['type'];
- }
- else {
- $handler_type = $type;
- }
- $handler = views_get_handler($table, $field, $handler_type);
- $fields[$id] = $new_item;
- $this->display[$display_id]->handler->set_option($types[$type]['plural'], $fields);
- return $id;
- }
-
- function get_items($type, $display_id = NULL) {
- $this->set_display($display_id);
- if (!isset($display_id)) {
- $display_id = $this->current_display;
- }
-
- $types = views_object_types();
- return $this->display[$display_id]->handler->get_option($types[$type]['plural']);
- }
-
- function get_item($display_id, $type, $id) {
-
- $types = views_object_types();
-
- $this->set_display($display_id);
-
- $fields = $this->display[$display_id]->handler->get_option($types[$type]['plural']);
- return isset($fields[$id]) ? $fields[$id] : NULL;
- }
-
- function set_item($display_id, $type, $id, $item) {
-
- $types = views_object_types();
-
- $this->set_display($display_id);
-
- $fields = $this->display[$display_id]->handler->get_option($types[$type]['plural']);
- if (isset($item)) {
- $fields[$id] = $item;
- }
- else {
- unset($fields[$id]);
- }
-
- $this->display[$display_id]->handler->set_option($types[$type]['plural'], $fields);
- }
-
- function set_item_option($display_id, $type, $id, $option, $value) {
- $item = $this->get_item($display_id, $type, $id);
- $item[$option] = $value;
- $this->set_item($display_id, $type, $id, $item);
- }
- }
- class views_display extends views_db_object {
-
- var $handler;
-
- var $display_options;
- var $db_table = 'views_display';
- function views_display($init = TRUE) {
- parent::init($init);
- }
- function options($type, $id, $title) {
- $this->display_plugin = $type;
- $this->id = $id;
- $this->display_title = $title;
- }
- }
- function views_object_types() {
- static $retval = NULL;
-
- if (!isset($retval)) {
- $retval = array(
- 'field' => array(
- 'title' => t('Fields'),
- 'ltitle' => t('fields'),
- 'stitle' => t('Field'),
- 'lstitle' => t('field'),
- 'plural' => 'fields',
- ),
- 'argument' => array(
- 'title' => t('Contextual filters'),
- 'ltitle' => t('contextual filters'),
- 'stitle' => t('Contextual filter'),
- 'lstitle' => t('contextual filter'),
- 'plural' => 'arguments',
- ),
- 'sort' => array(
- 'title' => t('Sort criteria'),
- 'ltitle' => t('sort criteria'),
- 'stitle' => t('Sort criterion'),
- 'lstitle' => t('sort criterion'),
- 'plural' => 'sorts',
- ),
- 'filter' => array(
- 'title' => t('Filter criteria'),
- 'ltitle' => t('filter criteria'),
- 'stitle' => t('Filter criterion'),
- 'lstitle' => t('filter criterion'),
- 'plural' => 'filters',
- ),
- 'relationship' => array(
- 'title' => t('Relationships'),
- 'ltitle' => t('relationships'),
- 'stitle' => t('Relationship'),
- 'lstitle' => t('Relationship'),
- 'plural' => 'relationships',
- ),
- 'header' => array(
- 'title' => t('Header'),
- 'ltitle' => t('header'),
- 'stitle' => t('Header'),
- 'lstitle' => t('Header'),
- 'plural' => 'header',
- 'type' => 'area',
- ),
- 'footer' => array(
- 'title' => t('Footer'),
- 'ltitle' => t('footer'),
- 'stitle' => t('Footer'),
- 'lstitle' => t('Footer'),
- 'plural' => 'footer',
- 'type' => 'area',
- ),
- 'empty' => array(
- 'title' => t('No results behavior'),
- 'ltitle' => t('no results behavior'),
- 'stitle' => t('No results behavior'),
- 'lstitle' => t('No results behavior'),
- 'plural' => 'empty',
- 'type' => 'area',
- ),
- );
- }
- return $retval;
- }
|