Exemplo n.º 1
0
    /**
     * Render the output of the container and add it to the DOM
     *
     * @param One_Model $model
     * @param One_Dom $d
     */
    protected function _render($model, One_Dom $d)
    {
        $id = $this->getID();
        $dom = One_Repository::createDom();
        $dom->add('<div id="content-sliders-" class="pane-sliders">
			<div style="display:none;">
				<div></div>
			</div>');
        foreach ($this->getContent() as $content) {
            $content->render($model, $dom);
        }
        $dom->add('</div>');
        One_Vendor::getInstance()->loadScript(preg_replace('!administrator(/?)$!', '', JURI::base()) . '/media/system/js/mootools-core.js', 'head', 30);
        One_Vendor::getInstance()->loadScript(preg_replace('!administrator(/?)$!', '', JURI::base()) . '/media/system/js/core.js', 'head', 31);
        One_Vendor::getInstance()->loadScript(preg_replace('!administrator(/?)$!', '', JURI::base()) . '/media/system/js/mootools-more.js', 'head', 32);
        One_Vendor::getInstance()->loadScriptDeclaration('new Fx.Accordion($$("div#content-sliders-.pane-sliders > .panel > h3.pane-toggler"), $$("div#content-sliders-.pane-sliders > .panel > div.pane-slider"), {
				onActive: function(toggler, i) {
					toggler.addClass("pane-toggler-down");toggler.removeClass("pane-toggler");i.addClass("pane-down");i.removeClass("pane-hide");Cookie.write("jpanesliders_content-sliders-",$$("div#content-sliders-.pane-sliders > .panel > h3").indexOf(toggler));
				},onBackground: function(toggler, i) {
					toggler.addClass("pane-toggler");toggler.removeClass("pane-toggler-down");i.addClass("pane-hide");i.removeClass("pane-down");if($$("div#content-sliders-.pane-sliders > .panel > h3").length==$$("div#content-sliders-.pane-sliders > .panel > h3.pane-toggler").length) Cookie.write("jpanesliders_content-sliders-",-1);
				},duration: 300,opacity: false,alwaysHide: true});', 'onload', 10);
        One_Vendor::getInstance()->loadScriptDeclaration('new Fx.Accordion($$("div#content-sliders.pane-sliders .panel h3.pane-toggler"),$$("div#content-sliders.pane-sliders .panel div.pane-slider"), {
				onActive: function(toggler, i) {
					toggler.addClass("pane-toggler-down");toggler.removeClass("pane-toggler");i.addClass("pane-down");i.removeClass("pane-hide");Cookie.write("jpanesliders_content-sliderscom_content",$$("div#content-sliders.pane-sliders .panel h3").indexOf(toggler));
				},onBackground: function(toggler, i) {
					toggler.addClass("pane-toggler");toggler.removeClass("pane-toggler-down");i.addClass("pane-hide");i.removeClass("pane-down");
				}, duration: 300, display: 0, show: 0, alwaysHide:true, opacity: false});', 'onload', 11);
        $d->addDom($dom);
    }
Exemplo n.º 2
0
 protected function _render($model, One_Dom $d)
 {
     $id = $this->getID();
     $name = $this->getFormName();
     $label = $this->getLabel();
     $info = $this->getCfg('info');
     $error = $this->getCfg('error');
     $dom = One_Repository::createDom();
     $this->setCfg('class', 'OneFieldInput' . $this->getCfg('class'));
     $events = $this->getEventsAsString();
     $params = $this->getParametersAsString();
     //$output = '';
     if (!is_null($label)) {
         //$output .= '<label class="OneFieldLabel" for="' . $id . '">' . $label . '</label>'."\n";
         $dom->add('<label class="OneFieldLabel" for="' . $id . '">' . $label . '</label>' . "\n");
     }
     //$output .= '<input type="'.$this->_totf.'" id="' . $id . '" name="' . $name . '"' . $events . $params . ' />'."\n";
     $dom->add('<input type="' . $this->_totf . '" id="' . $id . '" name="' . $name . '"' . $events . $params . ' />' . "\n");
     if (is_null($info)) {
         //$output .= '<span id="' . $id . 'Info" class="OneInfo">' . $info . '</span>';
         $dom->add('<span id="' . $id . 'Info" class="OneInfo">' . $info . '</span>');
     }
     if (is_null($error)) {
         //$output .= '<span id="' . $id . 'Error" class="OneError">' . $error . '</span>';
         $dom->add('<span id="' . $id . 'Error" class="OneError">' . $error . '</span>');
     }
     //return $output;
     $d->addDom($dom);
 }
Exemplo n.º 3
0
 /**
  * This method composes the form and returns the output
  *
  * @return string Output of the form
  */
 public function execute()
 {
     // Fetch the model needed for this form. We will need it because authorization can depend on the model itself
     if ($this->id) {
         $factory = One_Repository::getFactory($this->scheme->getName());
         $model = $factory->selectOne($this->id);
     } else {
         $model = One::make($this->scheme->getName());
     }
     if (is_null($model)) {
         throw new One_Exception('Could not generate a form for scheme "' . $this->scheme->getName() . '" with id ' . $this->id);
     }
     $this->authorize($this->scheme->getName(), $model->id);
     $session = One_Repository::getSession();
     $formFile = $this->getVariable('formFile', 'form');
     $form = One_Form_Factory::createForm($this->scheme, $formFile, $this->getVariable('lang'), 'oneForm', '');
     // Create a DOM and render the form in it
     $dom = One_Repository::createDom();
     $form->render($model, $dom);
     //    print_r($dom);
     $this->view->setModel($model);
     $this->view->set('scheme', $this->scheme);
     $this->view->set('form', $form);
     $this->view->set('dom', $dom);
     $this->view->set('errors', $session->get('errors', 'OneFormErrors'));
     $vForm = $this->view->show();
     $session->remove('errors', 'OneFormErrors');
     $session->remove('posted', 'OneFormErrors');
     return $vForm;
 }
Exemplo n.º 4
0
 /**
  * Class constructor, with different prototypes:
  *   new One_View( One_Scheme, ...)
  *   new One_View( 'schemename', ...)
  *   new One_View( One_Model, ...)
  *   new One_View( [One_Model ...], ...)
  *
  * @param mixed $modelThing
  * @param string $viewName
  */
 public function __construct($modelThing, $viewName = 'default')
 {
     $this->name = $viewName;
     // which scheme are we rendering for ?
     if ($modelThing instanceof One_Scheme) {
         $this->schemeName = $modelThing->getName();
     } elseif ($modelThing instanceof One_Model) {
         $this->schemeName = $modelThing->getSchemeName();
     } elseif (is_array($modelThing) && count($modelThing) > 0) {
         $this->schemeName = $modelThing[0]->getSchemeName();
     } else {
         $this->schemeName = $modelThing;
     }
     // setup templater
     $this->templater = One_Repository::getTemplater();
     $this->setDefaultViewSearchPath();
     //      $this->templater->setFile($viewName . '.' . $type);
     // the templater knows what to use
     // *** does this not restrict us for view filenames ??
     $this->templater->setFile($viewName);
     if ($this->templater->hasError()) {
         throw new One_Exception("Could not load view '" . $viewName . "' for scheme '" . $this->schemeName . "' : " . $this->templater->getError());
     }
     $this->setModel($modelThing);
 }
Exemplo n.º 5
0
 /**
  * Render the output of the container and add it to the DOM
  *
  * @param One_Model $model
  * @param One_Dom $d
  */
 protected function _render($model, One_Dom $d)
 {
     $id = $this->getID();
     $params = $this->getParametersAsString();
     $events = $this->getEventsAsString();
     $title = $this->getCfg('title');
     $dom = One_Repository::createDom();
     $dom->add('<div id="' . $id . '"' . $params . $events . '>' . "\n");
     $dom->add('<h3 id="' . $id . '-title" class="jpane-toggler title"' . $params . $events . '><span>' . $title . '</span></h3>' . "\n");
     $dom->add("<div class='jpane-slider content'>");
     foreach ($this->getContent() as $content) {
         $content->render($model, $dom);
     }
     $dom->add('</div></div>');
     // add js declaration for the panel
     $options = '{';
     $opt['onActive'] = 'function(toggler, i) { toggler.addClass(\'jpane-toggler-down\'); toggler.removeClass(\'jpane-toggler\'); }';
     $opt['onBackground'] = 'function(toggler, i) { toggler.addClass(\'jpane-toggler\'); toggler.removeClass(\'jpane-toggler-down\'); }';
     $opt['duration'] = 200;
     foreach ($opt as $k => $v) {
         if ($v) {
             $options .= $k . ': ' . $v . ',';
         }
     }
     if (substr($options, -1) == ',') {
         $options = substr($options, 0, -1);
     }
     $options .= '}';
     // $dom->add('window.addEvent(\'domready\', function(){ new Accordion($$(\'.panel h3.jpane-toggler\'), $$(\'.panel div.jpane-slider\'), '.$options.'); });', '_onload');
     One_Vendor::getInstance()->loadScriptDeclaration('window.addEvent(\'domready\', function(){ new Accordion($$(\'.panel h3.jpane-toggler\'), $$(\'.panel div.jpane-slider\'), ' . $options . '); });', 'onload', 10);
     $d->addDom($dom);
 }
Exemplo n.º 6
0
 public function countRelated(One_Relation_Adapter $link, One_Model $model, array $options = array())
 {
     $linkName = $link->getName();
     // identify the target scheme
     $source = One_Repository::getScheme($model->getSchemeName());
     $target = One_Repository::getScheme($link->getTarget());
     $backlinks = $target->getLinks();
     $backlink = $backlinks[$link->getLinkId()];
     if (!$backlink) {
         throw new One_Exception('The role "' . $roleName . '" does not exist for this model');
     }
     $at = $source->getIdentityAttribute()->getName();
     $column = $this->remoteFK($link, $source, $backlink);
     // bind the data using the data
     $localValue = $model->{$at};
     // create query and execute
     $q = One_Repository::selectQuery($link->getTarget());
     $q->setOptions($options);
     if (isset($link->meta['hybrid'])) {
         $var = $link->meta['hybrid'] . '_scheme';
         $q->where($var, 'eq', $source->getName());
     }
     $q->where($column, 'eq', $localValue);
     return $q->getCount();
 }
Exemplo n.º 7
0
 /**
  * Renders the One_Query into an xpath that can fetch results from the XML-datastore
  *
  * @param One_Query $query
  */
 public function render(One_Query $query)
 {
     $this->query = $query;
     $this->scheme = $this->query;
     $resources = $this->scheme->getResources();
     if (trim($query->getRaw()) != '') {
         return $query->getRaw();
     }
     $xpath = $resources['item'];
     // add possible filters to the query
     if (isset($resources['filter'])) {
         $filters = explode(';', $resources['filter']);
         if (count($filters) > 0) {
             foreach ($filters as $filterName) {
                 if ($filterName != '') {
                     $filter = One_Repository::getFilter($filterName, $query->name());
                     $filter->affect($query);
                 }
             }
         }
     }
     $whereClauses = $query->getWhereClauses();
     if (!is_null($whereClauses)) {
         $clauses = $this->whereClauses($whereClauses);
         if (!is_null($clauses)) {
             $xpath .= '[' . $clauses . ']';
         }
     }
     return $xpath;
 }
Exemplo n.º 8
0
 /**
  * One_Renderer_Interspire renders an instance of One_Query into an understandable "query" for Interspire
  * @param One_Query $query
  * @return array
  */
 public function render(One_Query $query)
 {
     $this->query = $query;
     $this->scheme = $this->query->getScheme();
     $resources = $this->scheme->getResources();
     // add possible filters to the query
     if (isset($resources['filter'])) {
         $filters = explode(';', $resources['filter']);
         if (count($filters) > 0) {
             foreach ($filters as $filterName) {
                 if ($filterName != '') {
                     $filter = One_Repository::getFilter($filterName, $query->getScheme()->name());
                     $filter->affect($query);
                 }
             }
         }
     }
     $details = array();
     // For interspire, you can basicly only use the where clauses and even still only certain fields
     // The validation of the fields must be done in the functions themselves because they are too random
     // get where clauses
     $whereClauses = $query->getWhereClauses();
     if (!is_null($whereClauses)) {
         $details = $this->whereClauses($whereClauses);
     }
     $order = $query->getOrder();
     if (!is_null($query->getOrder())) {
         $details['SortInfo'] = $this->createOrder();
     }
     return $details;
 }
Exemplo n.º 9
0
 /**
  * Get the list of instances for this action.
  *
  * @return mixed
  */
 protected function getData()
 {
     $schemeName = $this->scheme;
     if ($this->scheme instanceof One_Scheme) {
         $schemeName = $this->scheme->getName();
     }
     // First, create the query
     $factory = One_Repository::getFactory($schemeName);
     $query = $factory->selectQuery($this->scheme);
     // Set the order if needed
     $orderField = $this->getVariable('order', '');
     if (!in_array(substr($orderField, -1, 1), array('-', '+'))) {
         if (in_array($this->getVariable('orderdirection', '+'), array('-', 'desc'))) {
             $orderField .= '-';
         } else {
             $orderField .= '+';
         }
     }
     $query->setOrder($orderField);
     // Set paging variables
     $start = $this->getVariable('start', 0);
     $cnt = $this->getVariable('count', 0);
     $query->setLimit($cnt, $start);
     // Apply the filters
     $this->processQueryConditions($query);
     // Execute the query
     $results = $query->execute();
     return $results;
 }
Exemplo n.º 10
0
 public function execute()
 {
     //$this->id = $this->getVariable('id');
     if ($this->scheme instanceof One_Scheme) {
         $scheme = $this->scheme;
         $idattr = $this->scheme->getIdentityAttribute();
     } else {
         $scheme = One_Repository::getScheme($this->scheme);
         $idattr = $scheme->getIdentityAttribute();
     }
     $idat = $idattr->getName();
     $schemeName = $scheme->getName();
     $this->authorize($schemeName, $this->id);
     $factory = One_Repository::getFactory($schemeName);
     //$model   = $factory->selectOne($this->id);
     $model = $factory->getInstance($schemeName);
     if (is_null($model)) {
         throw new One_Exception('Item could not be found');
     }
     foreach ($scheme->get('attributes') as $attr) {
         $v = $this->getVariable($attr->getName(), null);
         if ($v !== null) {
             $an = $attr->getName();
             $model->{$an} = $v;
         }
     }
     //$model->$idat = $this->id;
     $model->insert();
     exit;
 }
Exemplo n.º 11
0
 public function dispatch()
 {
     //      if ($this->_view == 'rest') {
     //        return $this->dispatchRest();
     //      }
     try {
         $scheme = $this->_scheme;
         $this->controller = One_Repository::getController($scheme, $this->_options);
         $content = $this->controller->execute($this->_task, $this->_options);
         if (is_null($this->controller->getRedirect())) {
             if ($this->parseContentPlugins && $this->task != 'edit') {
                 // @TODO lookup better way to trigger this today
                 $dummy = new stdClass();
                 $dummy->text = $content;
                 JPluginHelper::importPlugin('content');
                 $dispatcher = JDispatcher::getInstance();
                 $params = JFactory::getApplication()->getParams();
                 $dispatcher->trigger('onContentPrepare', array('com_one.default', &$dummy, &$params, 0));
                 $content = $dummy->text;
             }
             echo $content;
         } else {
             $this->setRedirect($this->controller->getRedirect());
             $this->redirect();
         }
     } catch (Exception $e) {
         if (One_Config::get('debug.exitOnError') === false) {
             echo $e->getMessage();
         } else {
             throw new Exception($e);
         }
     }
 }
Exemplo n.º 12
0
 function execute(&$data, &$parent)
 {
     $output = '';
     $selected = NULL;
     $parts = explode(':', trim($this->data), 2);
     if (count($parts) < 2) {
         return '';
     }
     $scheme = One_Repository::getScheme($parts[0]);
     $factory = One_Repository::getFactory($parts[0]);
     $requested = $parts[1];
     $behaviorOptions = $scheme->get('behaviorOptions.linkalias');
     if (is_null($behaviorOptions)) {
         $selected = $factory->selectOne($requested);
         if (is_null($selected)) {
             return '';
         }
         $output = $scheme->title() . ' ( ' . $requested . ' )';
     } else {
         if (isset($behaviorOptions['lookup'])) {
             $query = $factory->selectQuery();
             $query->where($behaviorOptions['lookup'], 'eq', $requested);
             $results = $query->result();
             if (count($results) == 0) {
                 return '';
             } else {
                 $selected = $results[0];
             }
         } else {
             $selected = $factory->selectOne($requested);
             if (is_null($selected)) {
                 return '';
             }
         }
         if (isset($behaviorOptions['show'])) {
             $shown = $behaviorOptions['show'];
             $output = $selected->{$shown};
         } else {
             $output = $scheme->title() . ' ( ' . $requested . ' )';
         }
     }
     if (trim($output) == '' || is_null($selected)) {
         return '';
     } else {
         $idAttr = $scheme->getIdentityAttribute()->getName();
         $task = 'detail';
         $view = 'detail';
         if (isset($behaviorOptions['task'])) {
             $task = $behaviorOptions['task'];
         }
         if (isset($behaviorOptions['view'])) {
             $view = $behaviorOptions['view'];
         }
         $link = JRoute::_('index.php?option=com_one&scheme=' . $scheme->getName() . '&task=' . $task . '&view=' . $view . '&id=' . $selected->{$idAttr});
         return '<a href="' . $link . '">' . $output . '</a>';
     }
 }
Exemplo n.º 13
0
 public function execute()
 {
     $this->id = $this->getVariable('id');
     $fromJQGrid = intval($this->getVariable('fromJqgrid', 0));
     if ($this->scheme instanceof One_Scheme) {
         $scheme = $this->scheme;
         $idattr = $this->scheme->getIdentityAttribute();
     } else {
         $scheme = One_Repository::getScheme($this->scheme);
         $idattr = $scheme->getIdentityAttribute();
     }
     $idat = $idattr->getName();
     $schemeName = $scheme->getName();
     $this->authorize($schemeName, $this->id);
     $factory = One_Repository::getFactory($schemeName);
     $model = $factory->selectOne($this->id);
     if (is_null($model)) {
         throw new One_Exception('Item could not be found');
     }
     foreach ($scheme->get('attributes') as $attr) {
         if ($idat != $attr->getName() && !in_array($attr->getName(), array('id', 'oper'))) {
             $v = $this->getVariable($attr->getName(), null);
             if ($v !== null) {
                 $an = $attr->getName();
                 $model->{$an} = $v;
             }
         }
     }
     $model->{$idat} = $this->id;
     $model->update();
     $context = new One_Context();
     $posted = $context->getPost();
     // Check for posted reltional fields
     foreach ($posted as $field => $val) {
         if (false === strpos($field, ':')) {
             continue;
         }
         // Get the role and targetAttribute to change
         list($role, $rAttr) = explode(':', $field, 2);
         // Surround in try-catch block to avoid errors on non-existing relations
         try {
             // Only save one-to-many relations
             $rel = $model->getRelated($role);
             if (false === is_array($rel) && null !== $rel) {
                 $tIdAttrName = $rel->getScheme()->getIdentityAttribute()->getName();
                 if ($rAttr == $tIdAttrName) {
                     continue;
                 }
                 $rel->{$rAttr} = $val;
                 $rel->update();
             }
         } catch (Exception $e) {
         }
     }
     exit;
 }
Exemplo n.º 14
0
 /**
  * Respond to get('schemes')
  * Respond to get('schemes/SCHEMENAME')
  *
  * @param $route
  * @return mixed
  * @throws Exception
  */
 public static function metaSchemes($route)
 {
     switch ($route) {
         case '':
             return parent::getSchemeNames();
         default:
             return parent::getScheme($route);
     }
     throw new Exception('One cannot get schemes/', $route);
 }
Exemplo n.º 15
0
 /**
  * This method returns the detail view of the currently chosen item
  *
  * @return string The detail view of the currently chosen item
  */
 public function execute()
 {
     $this->authorize($this->scheme->getName(), $this->id);
     $factory = One_Repository::getFactory($this->scheme->getName());
     $model = $factory->selectOne($this->id);
     if (is_null($model)) {
         throw new One_Exception('Item could not be found');
     }
     $this->view->setModel($model);
     return $this->view->show();
 }
Exemplo n.º 16
0
 public function renderPart(One_Form_Container_Form $form, $part, $model = NULL)
 {
     $toRender = self::getPart($form, $part);
     if (is_null($toRender)) {
         return '';
     } else {
         $dom = One_Repository::createDom();
         $toRender->render($model, $dom);
         return $dom->render();
     }
 }
Exemplo n.º 17
0
 /**
  * Class constructor
  *
  * @param string $name
  * @param string $type name of the One_Scheme_Attribute_Type of the attribute
  * @param array additional options that can be passed to the array
  */
 public function __construct($name, $type, array $options = array())
 {
     $this->set('name', $name);
     $this->set('column', $name);
     // by default, keep it the same
     $this->set('alias', $name);
     // by default, keep it the same
     $this->set('type', One_Repository::getType($type));
     foreach ($options as $key => $val) {
         $this->set($key, $val);
     }
 }
Exemplo n.º 18
0
 /**
  * Render the output of the container and add it to the DOM
  *
  * @param One_Model $model
  * @param One_Dom $d
  */
 protected function _render($model, One_Dom $d)
 {
     $id = $this->getID();
     $title = $this->getCfg('title');
     $dom = One_Repository::createDom();
     $dom->add('<div id="' . $id . '" class="tabbertab' . (trim($this->getCfg('default')) == 'default' ? ' tabbertabdefault' : '') . '"' . (trim($title) != '' ? ' title="' . $title . '"' : '') . '>' . "\n");
     foreach ($this->getContent() as $content) {
         $content->render($model, $dom);
     }
     $dom->add('</div>');
     $d->addDom($dom);
 }
Exemplo n.º 19
0
 /**
  * Return the number of One_Models of the specified kind
  *
  * @param string $schemeName
  * @return int
  *
  * //TODO is this useful at all ? total count ?
  */
 public function selectCount()
 {
     $scheme = $this->scheme;
     $query = One_Repository::selectQuery($scheme);
     $behaviors = $scheme->get('behaviors');
     if ($behaviors) {
         foreach ($behaviors as $behavior) {
             $behavior->onSelect($query);
         }
     }
     return $query->getCount();
 }
Exemplo n.º 20
0
 /**
  * Render the output of the container and add it to the DOM
  *
  * @param One_Model $model
  * @param One_Dom $d
  */
 protected function _render($model, One_Dom $d)
 {
     $id = $this->getID();
     $params = $this->getParametersAsString();
     $events = $this->getEventsAsString();
     $dom = One_Repository::createDom();
     $dom->add('<div id="' . $id . '"' . $params . $events . '>' . "\n");
     foreach ($this->getContent() as $content) {
         $content->render($model, $dom);
     }
     $dom->add('</div>');
     $d->addDom($dom);
 }
Exemplo n.º 21
0
 /**
  * Render the output of the container and add it to the DOM
  *
  * @param One_Model $model
  * @param One_Dom $d
  */
 protected function _render($model, One_Dom $d)
 {
     $id = md5($this->getID() . microtime(true));
     $title = '' != trim($this->getCfg('title')) ? trim($this->getCfg('title')) : $this->getID();
     $dom = One_Repository::createDom();
     $dom->add('<div id="' . $id . '"">' . "\n");
     $d->jqtitles[] = array('id' => $id, 'title' => $title);
     foreach ($this->getContent() as $content) {
         $content->render($model, $dom);
     }
     $dom->add('</div>');
     $d->jqtabs[] = $dom;
 }
Exemplo n.º 22
0
    /**
     * Render the output of the widget and add it to the DOM
     *
     * @param One_Model $model
     * @param One_Dom $d
     */
    protected function _render($model, One_Dom $d)
    {
        $this->setCfg('class', 'OneFieldInput ' . $this->getCfg('class'));
        $data = array('id' => $this->getID(), 'name' => $this->getFormName(), 'value' => is_null($this->getValue($model)) ? $this->getDefault() : $this->getValue($model), 'info' => $this->getCfg('info'), 'error' => $this->getCfg('error'), 'class' => $this->getCfg('class'), 'required' => $this->isRequired() ? ' *' : '', 'label' => $this->getLabel(), 'lblLast' => $this->getCfg('lblLast'), 'One::getInstance()->getUrl()' => One_Config::getInstance()->getUrl());
        $dom = One_Repository::createDom();
        $dom->add('<script type="text/javascript" src="' . One_Vendor::getInstance()->getSitePath() . '/js/ColorPicker2.js"></script>', '_head');
        $dom->add('<script type="text/javascript">
	      var cp = new ColorPicker( "window" );
	    </script>', '_head');
        $content = $this->parse($model, $data);
        $d->addDom($dom);
        $d->addDom($content);
    }
Exemplo n.º 23
0
 /**
  * Render the output of the container and add it to the DOM
  *
  * @param One_Model $model
  * @param One_Dom $d
  */
 protected function _render($model, One_Dom $d)
 {
     $id = $this->getID();
     $title = $this->getCfg('title');
     $dom = One_Repository::createDom();
     $dom->add('<div id="' . $id . '" class="mootabs_panel">' . "\n");
     $d->mootitles[] = array('id' => $id, 'title' => $title);
     foreach ($this->getContent() as $content) {
         $content->render($model, $dom);
     }
     $dom->add('</div>');
     $d->mootabs[] = $dom;
 }
Exemplo n.º 24
0
 /**
  * Render the query
  *
  * @param One_Query $query
  * @return string
  */
 public function render(One_Query $query, $overrideFilters = false)
 {
     $this->query = $query;
     $this->scheme = $this->query->getScheme();
     // if the person wants to perform a raw query, return the raw query
     if (!is_null($query->getRaw())) {
         if (One_Config::get('debug.query')) {
             echo '<pre>';
             var_dump($query->getRaw());
             echo '</pre>';
         }
         return $query->getRaw();
     }
     $this->query = $query;
     $this->scheme = $this->query->getScheme();
     $resources = $this->scheme->getResources();
     // fetch collection to fetch data from
     $this->_collection = $resources['collection'];
     // add possible filters to the query
     if (!$overrideFilters && isset($resources['filter'])) {
         $filters = explode(';', $resources['filter']);
         if (count($filters) > 0) {
             foreach ($filters as $filterName) {
                 if ($filterName != '') {
                     $filter = One_Repository::getFilter($filterName, $query->getScheme()->getName());
                     $filter->affect($query);
                 }
             }
         }
     }
     $findQuery = array('fields' => array(), 'query' => array());
     if (count($query->getSelect()) > 0) {
         $findQuery['fields'] = $this->createSelects($query->getSelect());
     }
     // get where clauses
     $whereClauses = $query->getWhereClauses();
     $where = NULL;
     if (!is_null($whereClauses)) {
         $where = $this->whereClauses($whereClauses);
     }
     if (!is_null($where)) {
         $findQuery['query'] = $where;
     }
     if (One_Config::get('debug.query')) {
         echo '<pre>';
         var_dump($findQuery);
         echo '</pre>';
     }
     $findQuery = json_encode($findQuery);
     return $findQuery;
 }
Exemplo n.º 25
0
 /**
  * This method will return a feed for the chosen scheme
  *
  * @return string The feed string
  */
 public function execute()
 {
     $this->authorize();
     $factory = One_Repository::getFactory($this->scheme->getName());
     $q = $factory->selectQuery();
     $q->setOrder($this->getVariable('order', ''));
     $q->setLimit($this->getVariable('count', 0), $this->getVariable('start', 0));
     $this->processQueryConditions($q);
     $results = $q->result(false);
     $this->view->set('scheme', $this->scheme);
     $this->view->setModel($results);
     echo $this->view->show();
     exit;
     // exit here because nothing else should be outputted after the feed
 }
Exemplo n.º 26
0
 protected function getData()
 {
     $schemeName = $this->scheme;
     if ($this->scheme instanceof One_Scheme) {
         $schemeName = $this->scheme->getName();
     }
     $factory = One_Repository::getFactory($schemeName);
     $query = $factory->selectQuery($this->scheme);
     $ids = explode(',', $this->options['listFormData']);
     $idAttr = One_Repository::getScheme($schemeName)->getIdentityAttribute()->getName();
     $query->where($idAttr, 'in', $ids);
     $this->processQueryConditions($query);
     $results = $query->execute();
     return $results;
 }
Exemplo n.º 27
0
 /**
  * Method to get the field input markup.
  *
  * @return  string  The field input markup.
  * @since  1.6
  */
 protected function getInput()
 {
     $doc = JFactory::getDocument();
     // find out which schemes are defined
     $schemeNames = One_Repository::getSchemeNames();
     sort($schemeNames);
     $options = array();
     foreach ($schemeNames as $schemeName) {
         $currScheme = One_Repository::getScheme($schemeName);
         if (!isset($currScheme->information['internal']) || isset($currScheme->information['menuonly'])) {
             $options[] = array("id" => $schemeName, "title" => $currScheme->get('info.title'));
         }
     }
     array_unshift($options, JHTML::_('select.option', '0', '- ' . JText::_('Select scheme') . ' -', 'id', 'title'));
     return JHTML::_('select.genericlist', $options, '' . $this->formControl . '[' . $this->group . '][' . $this->fieldname . ']', 'class="inputbox" ', 'id', 'title', $this->value, $this->formControl . $this->fieldname);
 }
Exemplo n.º 28
0
 /**
  * Render the output of the container and add it to the DOM
  *
  * @param One_Model $model
  * @param One_Dom $d
  */
 protected function _render($model, One_Dom $d)
 {
     $id = $this->getID();
     $params = $this->getParametersAsString();
     $events = $this->getEventsAsString();
     $title = $this->getCfg('title');
     $dom = One_Repository::createDom();
     $dom->add('<div class="panel">' . "\n");
     $dom->add('<h3 id="' . $id . '-title" class="pane-toggler title"' . $params . $events . '><a href="javascript:void(0);"><span>' . $title . '</span></a></h3>' . "\n");
     $dom->add('<div class="pane-slider content">');
     foreach ($this->getContent() as $content) {
         $content->render($model, $dom);
     }
     $dom->add('</div></div>');
     $d->addDom($dom);
 }
Exemplo n.º 29
0
 /**
  * Render the output of the container and add it to the DOM
  *
  * @param One_Model $model
  * @param One_Dom $d
  */
 protected function _render($model, One_Dom $d)
 {
     $id = $this->getID();
     $params = $this->getParametersAsString();
     $events = $this->getEventsAsString();
     $dom = One_Repository::createDom();
     $dom->add('<fieldset id="' . $id . '"' . $params . $events . '>' . "\n");
     if (trim($this->getCfg('legend')) != '') {
         $dom->add('<legend>' . $this->getCfg('legend') . '</legend>');
     }
     foreach ($this->getContent() as $widget) {
         $dom->add($widget->render($model, $dom));
     }
     $dom->add('</fieldset>' . "\n");
     $d->addDom($dom);
 }
Exemplo n.º 30
0
 /**
  * Get the search value from the context
  *
  * @return mixed
  */
 public function getValue()
 {
     $session = One_Repository::getSession();
     if ($session->varExists('usedSearchOptions', 'one_search')) {
         $cx = new One_Context($session->get('usedSearchOptions', 'one_search'));
     } else {
         $cx = new One_Context();
     }
     $name = $this->getName();
     $value = $cx->get($name);
     if (!is_null($value)) {
         return trim($value);
     } else {
         return NULL;
     }
 }