Ejemplo n.º 1
0
 /**
  * Get an instance of One_Controller_Flow for the proper scheme
  *
  * @param One_Scheme $scheme
  * @param array $redirects
  * @return One_Controller_Flow
  */
 public static function getInstance(One_Scheme $scheme, array $redirects = array())
 {
     if (!array_key_exists(One_Config::get('app.name'), self::$_flowCache) || !array_key_exists($scheme->getName(), self::$_flowCache[One_Config::get('app.name')])) {
         self::$_flowCache[One_Config::get('app.name')][$scheme->getName()] = new One_Controller_Flow($scheme, $redirects);
     }
     return self::$_flowCache[One_Config::get('app.name')][$scheme->getName()];
 }
Ejemplo n.º 2
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);
         }
     }
 }
Ejemplo n.º 3
0
 public function onAfterInitialise()
 {
     // read folder locations from plugin settings
     $oneLibFolder = JPATH_SITE . '/libraries/one/lib/';
     $oneCustomFolder = JPATH_SITE . '/libraries/one/custom/';
     // bootstrap one|content
     require_once $oneLibFolder . 'core/bootstrap.php';
     One_Bootstrap::bootstrap($oneLibFolder, $oneCustomFolder);
     // one|content for Joomla uses different views for front/backend and per language
     // which requires a particular setup of the locator pattern used for these
     $application = 'site';
     $app = JFactory::getApplication();
     if (strpos($app->getName(), 'admin') !== false) {
         $application = 'admin';
     }
     One_Config::set('app.name', $application);
     // pickup language setting
     $language = JFactory::getLanguage()->getTag();
     One_Config::set('app.language', $language);
     // setup locator tokens
     $locatorTokens = array('%APP%' => One_Config::get('app.name'), '%LANG%' => One_Config::get('app.language'));
     One_Config::set('locator.tokens', $locatorTokens);
     One_Config::set('view.locator', 'One_View_Locator_Joomla');
     // set the templater. You have the choice between One_View_Templater_Script and One_View_Templater_Php,
     // the latter being a standard PHP template hndler
     // *** TODO: needs to load this from plugin parameters
     One_Config::set('view.templater', 'One_View_Templater_Script');
     // debug behaviour
     One_Config::set('debug.exitOnError', $this->params->get('exitOnError'));
     One_Config::set('debug.query', $this->params->get('enableDebug', 0));
     // special form subfolder to use
     One_Config::set('form.chrome', $this->params->get('formChrome', ''));
 }
Ejemplo n.º 4
0
 public static function set($key, $value)
 {
     if (empty(self::$registry)) {
         self::$registry = new One_Registry();
     }
     return self::$registry->set($key, $value);
 }
Ejemplo n.º 5
0
 /**
  * This method renders the "save" button
  *
  * @return string
  */
 public function render()
 {
     $output = '<td><a href="#" onclick="document.getElementById( \'task\' ).value = \'save\'; document.getElementById( \'' . One_Button::getFormId() . '\' ).submit(); "><img src="' . One_Config::getInstance()->getUrl() . '/vendor/images/toolset/' . self::getToolset() . '/save.png" title="Save">';
     if (self::showText()) {
         $output .= '<br />Save';
     }
     $output .= '</a></td>';
     return $output;
 }
Ejemplo n.º 6
0
 public static function onAfterInitialise($arguments = array())
 {
     parent::onAfterInitialise($arguments);
     // set default toolset used in backend
     // *** TODO: should be in the support pack for the admin component, to be added to the locator pattern
     // by the admin component (or enabled in the plugin to support the one admin component
     //      One_Button::setToolset('joomla');
     // set DOM type. Not sure yet whether this is really a cool thing to do. This could override the standard
     // dom setting, and should be oved to the plugin initialiser
     One_Config::set('dom.type', 'joomla');
 }
Ejemplo n.º 7
0
 /**
  * Specialize the pattern by replacing certain tokens in the provided pattern. These tokens are set in the
  * One_Config object when one|content is bootstrapped. The tokens aer provided as an array, to make the use
  * of the token functionality flexible.
  *
  * REPLACE      BY
  * -------      --------
  * %ROOT%       the root pattern
  * %APP%        the application currently used
  * %LANG%       the current language (is applicable)
  *
  * @param $pattern
  */
 public static function localize($pattern)
 {
     $localized = str_replace('%ROOT%', One_Config::get('locator.root'), $pattern);
     $tokens = One_Config::get('locator.tokens');
     if (count($tokens)) {
         foreach ($tokens as $token => $value) {
             $localized = str_replace($token, $value, $localized);
         }
     }
     return $localized;
 }
Ejemplo n.º 8
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);
    }
Ejemplo n.º 9
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)
 {
     JHTML::_('behavior.modal');
     JHTML::_('behavior.modal', 'a.modal-button');
     $this->setCfg('class', 'OneFieldTextfield ' . $this->getCfg('class'));
     $path = preg_replace('{/|\\\\}', DIRECTORY_SEPARATOR, trim($this->getCfg('path')));
     if (substr($path, -1, 1) != DIRECTORY_SEPARATOR) {
         $path .= DIRECTORY_SEPARATOR;
     }
     $data = array('id' => $this->getID(), 'name' => $this->getFormName(), 'events' => $this->getEventsAsString(), 'params' => $this->getParametersAsString(), 'required' => $this->isRequired() ? ' *' : '', 'value' => is_null($this->getValue($model)) ? $this->getDefault() : $this->getValue($model), 'path' => $path, 'info' => $this->getCfg('info'), 'error' => $this->getCfg('error'), 'class' => $this->getCfg('class'), 'label' => $this->getLabel(), 'lblLast' => $this->getCfg('lblLast'), 'oneUrl' => One_Config::getInstance()->getUrl());
     $dom = $this->parse($model, $data);
     $d->addDom($dom);
 }
Ejemplo n.º 10
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;
 }
Ejemplo n.º 11
0
 public static function bootstrap($oneLibFolder, $oneCustomFolder)
 {
     // Step 1: setup the basic configuration
     require_once $oneLibFolder . 'core/config.php';
     One_Config::set('locator.root', '{' . $oneCustomFolder . '*,' . $oneLibFolder . '*}/');
     // Step 2: register the autoloader
     require_once $oneLibFolder . 'core/loader.php';
     One_Loader::register($oneLibFolder, $oneCustomFolder);
     // Step 3: load extensions
     One_Config::loadExtensions();
     One_Config::callExtensions('afterInitialise');
     // Step 4: load the main One class
     require_once $oneLibFolder . 'core/one_tbd.php';
 }
Ejemplo n.º 12
0
 public static function initiate($siteRoot, $path, $customPath)
 {
     throw new One_Exception_Deprecated('do your own bootstrapping, dude');
     // Register the autoloader
     One_Loader::register();
     One_Config::getInstance()->setUrl($siteRoot)->setCustomPath($customPath)->setUserStore('mysql')->setTemplater(new One_Template_Adapter_NanoPretend());
     //		define( 'ONETEMPLATER', 'nano');
     //		$tmp = $path . DIRECTORY_SEPARATOR . 'nano' . DIRECTORY_SEPARATOR;
     //		define( 'ONE_SCRIPT_PATH', $tmp );
     //		define( 'ONE_SCRIPT_CUSTOM_PATH', $customPath . DIRECTORY_SEPARATOR . 'nano' );
     //
     //		require_once( $tmp . 'tools' . DIRECTORY_SEPARATOR . 'autoload.php' );
     require_once ONE_LIB_PATH . '/tools.php';
 }
Ejemplo n.º 13
0
 public function execute()
 {
     try {
         $app = JFactory::getApplication();
         $menu = $app->getMenu();
         $menuItem = $menu->getActive();
         $alias = $menuItem->route;
         $controller = new One_Controller_Rest(JFactory::getApplication()->input->getArray());
         $controller->run($alias);
     } catch (Exception $e) {
         if (One_Config::get('debug.exitOnError') === false) {
             echo $e->getMessage();
         } else {
             throw new Exception($e);
         }
     }
 }
Ejemplo n.º 14
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 $dom)
 {
     $src = $this->getCfg('src');
     if (trim($src) == '') {
         throw new One_Exception("A field of type 'nscript' should have a 'src'-attribute defining the nanoScript file to parse.");
     }
     One_Script_Factory::saveSearchPath();
     One_Script_Factory::clearSearchPath();
     $useLang = $this->getCfg('language');
     if ('' == trim($useLang)) {
         $useLang = strtolower(One_Config::get('app.language'));
     }
     die('deprecated stuff found in ' . __FILE__ . ':' . __LINE);
     $cps = One_Config::getInstance()->getCustomPaths();
     foreach ($cps as $cp) {
         One_Script_Factory::addSearchPath($cp . '/views/' . One_Config::get('app.name') . '/' . $model->getScheme()->getName() . '/language/' . $useLang . '/');
     }
     foreach ($cps as $cp) {
         One_Script_Factory::addSearchPath($cp . '/views/' . One_Config::get('app.name') . '/' . $model->getScheme()->getName() . '/');
     }
     $ns = new One_Script();
     $ns->load($src);
     if (!$ns->isError()) {
         if ($this->getID()) {
             $ns->set('id', $this->getID());
         }
         if ($this->getName()) {
             $ns->set('name', $this->getName());
         }
         if ($this->getLabel()) {
             $ns->set('label', $this->getLabel());
         }
         if ($this->getValue($model)) {
             $ns->set('value', $this->getValue($model));
         }
         $ns->set('model', $model);
         $dom->add($ns->execute());
     } else {
         throw new One_Exception($ns->error);
     }
     $dom->add($this->value);
     One_Script_Factory::restoreSearchPath();
 }
Ejemplo n.º 15
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 $dom)
    {
        // collect required data
        $id = $this->getID();
        $name = $this->getName();
        $childScheme = $this->getCfg('scheme');
        $dom->add('<script src="' . One_Config::getInstance()->getUrl() . 'lib/libraries/js/jquery.js" type="text/javascript"></script>', '_head');
        $dom->add('<script type="text/javascript">jQuery.noConflict();</script>', 'head');
        $dom->add('<script src="' . One_Config::getInstance()->getUrl() . 'lib/libraries/js/jquery/jquery.color.js" type="text/javascript"></script>', '_head');
        $dom->add('<script src="' . One_Config::getInstance()->getUrl() . 'lib/libraries/js/jquery.simplemodal-1.3.3.js" type="text/javascript"></script>', '_head');
        $dom->add('<script src="' . One_Config::getInstance()->getUrl() . 'lib/libraries/js/managerToolbar.js" type="text/javascript"></script>', '_head');
        $dom->add('<link rel="stylesheet" href="' . One_Config::getInstance()->getUrl() . 'lib/libraries/js/toolbar.css" type="text/css" />', '_head');
        $dom->add('<link rel="stylesheet" href="' . One_Config::getInstance()->getUrl() . 'lib/libraries/js/toolbar.ie6.css" type="text/css" />', '_head');
        $content = '<div class="childPopupPanel">
			<a href="#" onclick="jModal( \'' . $id . 'NsBox\', \'' . $childScheme . '\' ); return false;">Lookup</a>
			<div id="' . $id . 'NsBox"></div>
		</div>';
        $dom->add($content);
    }
Ejemplo n.º 16
0
 public function dispatch()
 {
     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())) {
             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);
         }
     }
 }
Ejemplo n.º 17
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'));
     $value = is_null($this->getValue($model)) ? $this->getDefault() : $this->getValue($model);
     $data = array('id' => $this->getID(), 'name' => $this->getFormName(), 'value' => $value, 'info' => $this->getCfg('info'), 'error' => $this->getCfg('error'), 'class' => $this->getCfg('class'), 'required' => $this->isRequired() ? ' *' : '', 'label' => $this->getLabel(), 'lblLast' => $this->getCfg('lblLast'), 'oneUrl' => One_Config::getInstance()->getUrl(), 'vendorUrl' => One_Vendor::getInstance()->getSitePath(), 'path' => !is_null($this->getCfg('path')) ? $this->getCfg('path') : One_Config::getInstance()->getSiterootUrl(), 'isSimple' => !is_null($this->getCfg('simple')) ? 'yes' : 'no');
     if ('' != trim($value)) {
         $salt = 'DR$8efatrA4reb66fr+ch5$Ucujach3phe9U@AqutR8hajuq47a6&5tucHu58aSt';
         $encPath = base64_encode($this->getCfg('path') . '/' . $value);
         $forCheck = strlen($encPath);
         $check = md5($forCheck . $encPath . $salt);
         $encLabel = base64_encode($this->getLabel());
         preg_match('/\\.([a-z0-9]+)$/i', $value, $matches);
         $extension = $matches[1];
         $data['encPath'] = $encPath;
         $data['encLabel'] = $encLabel;
         $data['check'] = $check;
         $data['extension'] = $extension;
     }
     $dom = $this->parse($model, $data);
     $d->addDom($dom);
 }
Ejemplo n.º 18
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 main table to fetch data from
     $this->mainTable = $resources['table'];
     $this->defineRole('$self$');
     // 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);
                 }
             }
         }
     }
     // TR20100531 No longer needs to be run after the rest since joins are now checked while adding
     // sselects, order, ...
     $joins = NULL;
     $qJoins = $query->getJoins();
     if (count($qJoins) > 0) {
         foreach ($qJoins as $join => $type) {
             $this->defineRole($join);
             $query->setRoleAlias($join, $this->aliases[$join]);
             $joins .= $this->createJoin($query->getRole($join), $type);
         }
     }
     $selects = $this->aliases['$self$'] . '.*';
     if (count($query->getSelect()) > 0) {
         $selects = $this->createSelects($query->getSelect());
     }
     // get where clauses
     $whereClauses = $query->getWhereClauses();
     $where = NULL;
     if (!is_null($whereClauses)) {
         $where = $this->whereClauses($whereClauses);
     }
     // get having clauses
     $havingClauses = $query->getHavingClauses();
     $having = NULL;
     if (!is_null($havingClauses)) {
         $having = $this->whereClauses($havingClauses);
     }
     // get order
     $order = $this->createOrder();
     //get grouping
     $group = $this->createGroup();
     // get limit
     $limit = $this->createLimit();
     $sql = 'SELECT ' . $selects . ' FROM ' . $this->mainTable . ' ' . $this->aliases['$self$'];
     if (!is_null($joins)) {
         $sql .= $joins;
     }
     if (!is_null($where)) {
         $sql .= ' WHERE ' . $where;
     }
     if (!is_null($group)) {
         $sql .= ' GROUP BY ' . $group;
     }
     if (!is_null($having)) {
         $sql .= ' HAVING ' . $having;
     }
     if (!is_null($order)) {
         $sql .= ' ORDER BY ' . $order;
     }
     if (!is_null($limit)) {
         /* Use the following format to replace MySQL LIMIT for PL/SQL :
         
         				SELECT * FROM (
         						SELECT rownum rnum, a.*
         						FROM(
         								SELECT fieldA,fieldB
         								FROM table
         								ORDER BY fieldA
         						) a
         						WHERE rownum <= START + LIMIT
         				)
         				WHERE rnum >= START
         
         				** or **
         
         				SELECT rownum rnum, a.*
         				FROM(
         						SELECT fieldA,fieldB
         						FROM table
         						ORDER BY fieldA
         				) a
         				WHERE rownum <= LIMIT
         
         
         			*/
         $qLimit = $this->query->getLimit();
         if (isset($qLimit['start']) && intval($qLimit['start']) > -1) {
             $start = intval($qLimit['start']);
         } else {
             $start = 0;
         }
         if (isset($qLimit['limit']) && intval($qLimit['limit']) > 0) {
             $limit = intval($qLimit['limit']);
         } else {
             $limit = 50;
         }
         // @TODO: clean this up
         // create alias for rownum field
         $rnfield = $this->createAlias();
         $subsel = $this->createAlias();
         $sql = "SELECT rownum {$rnfield}, {$subsel}.* FROM ( {$sql} ) {$subsel} WHERE rownum <= {$limit}";
         if ($start) {
             $sql = "SELECT * FROM ( {$sql} )  WHERE {$rnfield} > {$start}";
         }
     }
     if (One_Config::get('debug.query')) {
         echo '<pre>';
         var_dump($sql);
         echo '</pre>';
     }
     return $sql;
 }
Ejemplo n.º 19
0
 /**
  * Parse an include file that contains conditions
  *
  * @param string $include filename of the include
  */
 protected static function parseInclude($include)
 {
     $filename = One_Config::getInstance()->getCustomPath() . '/conditions/' . strtolower($include) . '.xml';
     $incDom = new DOMDocument('1.0', 'utf-8');
     if (file_exists($filename) && $incDom->load($filename)) {
         $xpath = new DOMXPath($incDom);
         $conditions = $xpath->query('/conditions');
         if ($conditions->length > 0) {
             $conditions = $conditions->item(0);
         } else {
             return;
         }
         foreach ($conditions->childNodes as $condition) {
             if ($condition instanceof DOMElement) {
                 switch (strtolower($condition->localName)) {
                     case 'cinclude':
                         self::parseInclude($condition->getAttribute('file'));
                         break;
                     case 'condition':
                         self::parseCondition($condition, $condition->getAttribute('name'));
                         break;
                 }
             }
         }
     }
 }
Ejemplo n.º 20
0
 public function getOneInstance()
 {
     return One_Config::getInstance();
 }
Ejemplo n.º 21
0
 static function addObligatedWidgets(One_Form_Container_Form $form, One_Scheme $scheme)
 {
     // the form should always have a (hidden) widget with the value of the identityAttribute unless there is no identityAttribute
     if (!is_null($scheme->getIdentityAttribute()) && !$form->hasWidget($scheme->getIdentityAttribute()->getName())) {
         $form->addWidget(new One_Form_Widget_Scalar_Hidden($scheme->getIdentityAttribute()->getName(), $scheme->getIdentityAttribute()->getName(), NULL, array('one' => 'one', 'language' => strtolower(One_Config::get('app.language')))));
     }
     if (!$form->hasWidget('task')) {
         $form->addWidget(new One_Form_Widget_Scalar_Hidden('task', 'task', NULL, array('default' => 'edit', 'one' => 'one', 'language' => strtolower(One_Config::get('app.language')))));
     }
     if (!$form->hasWidget('scheme')) {
         $form->addWidget(new One_Form_Widget_Scalar_Hidden('scheme', 'scheme', NULL, array('default' => $scheme->getName(), 'one' => 'one', 'language' => strtolower(One_Config::get('app.language')))));
     }
 }
Ejemplo n.º 22
0
 /**
  * @return One_Templater
  */
 public static function getTemplater($templaterClass = NULL)
 {
     if (is_null($templaterClass)) {
         $templaterClass = One_Config::get('view.templater', 'One_View_Templater_Script');
     }
     return new $templaterClass('');
 }
Ejemplo n.º 23
0
 /**
  * Parse the output of the widget with nanoscript
  *
  * @param One_Model $model
  * @param array $data
  */
 protected function parse($model, $data = array())
 {
     // general Dataset
     $data['excludeError'] = in_array($this->getCfg('excludeError'), array('true', 'yes', '1', 'exclude', 'excludeError')) ? 1 : 0;
     // determine if we need to look for the template-file in a subfolder of widget
     $widgetClass = preg_match('/One_Form_Widget_Default_/', get_class($this)) ? get_parent_class($this) : get_class($this);
     $current = str_replace('One_Form_Widget_', '', $widgetClass);
     $parts = preg_split('/_/', strtolower($current));
     //		array_pop($parts);
     $wtype = implode(DIRECTORY_SEPARATOR, $parts);
     $formChrome = One_Config::get('form.chrome', '');
     $pattern = "%ROOT%/views/" . "{%APP%,default}/" . "oneform/" . ($formChrome ? "{" . $formChrome . '/,}' : '') . "widget/" . ($wtype ? "{" . $wtype . "/,}" : '') . "{%LANG%/,}";
     One_Script_Factory::pushSearchPath($pattern);
     $script = new One_Script();
     //    $script->load($this->_type . '.html');
     $script->load($wtype . '.html');
     if ($script->error) {
         One_Script_Factory::popSearchPath();
         throw new One_Exception('Error loading template for widget ' . $this->_type . ' : ' . $script->error);
     }
     $dom = One_Repository::createDom();
     $dom->add($script->execute($data));
     return $dom;
 }
Ejemplo n.º 24
0
}
$path = implode(DIRECTORY_SEPARATOR, $parts);
define('JPATH_BASE', $path);
// $ONE_SCRIPT_PATH = $libpath . DIRECTORY_SEPARATOR . 'nano' . DIRECTORY_SEPARATOR;
// define( 'ONE_SCRIPT_PATH', $ONE_SCRIPT_PATH );
// define( 'ONE_SCRIPT_CUSTOM_PATH', JPATH_BASE . DIRECTORY_SEPARATOR . 'media' . DIRECTORY_SEPARATOR . 'nano' );
/* Required Files */
require_once JPATH_BASE . DIRECTORY_SEPARATOR . 'includes' . DIRECTORY_SEPARATOR . 'defines.php';
require_once JPATH_BASE . DIRECTORY_SEPARATOR . 'includes' . DIRECTORY_SEPARATOR . 'framework.php';
if ($withDB) {
    /* To use Joomla's Database Class */
    require_once JPATH_BASE . DIRECTORY_SEPARATOR . 'libraries' . DIRECTORY_SEPARATOR . 'joomla' . DIRECTORY_SEPARATOR . 'factory.php';
}
$mainframe = JFactory::getApplication('site');
require_once JPATH_BASE . '/plugins/system/one/lib/one.php';
One_Config::getInstance()->setCustomPath(JPATH_BASE . '/media/one');
// require_once( ONE_SCRIPT_PATH . 'tools' . DIRECTORY_SEPARATOR . 'autoload.php' );
require_once ONE_LIB_PATH . '/tools.php';
$scheme = $_POST['searchscheme'];
$tparts = explode(':', $_POST['target']);
$phrase = strip_tags($_POST['phrase']);
$selfId = isset($_POST['selfId']) ? $_POST['selfId'] : NULL;
$query = One_Repository::selectQuery($scheme);
$scheme = $query->getScheme();
$idAttr = $scheme->getIdentityAttribute()->getName();
if (!is_null($selfId)) {
    $query->where($idAttr, 'neq', $selfId);
}
// possibility to implement if the 2 schemes are the same in the manytomany relationship to exclude the current ID
$or = $query->addOr();
foreach ($tparts as $tpart) {
Ejemplo n.º 25
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)
    {
        One_Vendor::requireVendor('jquery/one_loader');
        One_Vendor::getInstance()->loadScript('jquery/js/jquery.tagify.js', 'head', 10);
        if (is_null($this->getCfg('role')) || is_null($this->getCfg('targetAttribute'))) {
            throw new One_Exception('The Multi-tag widget is only allowed for Many-to-many relations');
        }
        $parts = explode(':', $this->getCfg('role'), 2);
        $targetAttr = $this->getCfg('targetAttribute');
        $link = $model->getScheme()->getLink($parts[1]);
        if (is_null($link) || !$link->getAdapterType() instanceof One_Relation_Adapter_Manytomany) {
            throw new One_Exception('The Multi-tag widget is only allowed for Many-to-many relations');
        }
        $tScheme = One_Repository::getScheme($model->getScheme()->getLink($parts[1])->getTarget());
        $tIdAttr = $tScheme->getIdentityAttribute()->getName();
        // set initial values
        $value = array();
        $values = is_null($this->getValue($model)) ? $this->getDefault() : $this->getValue($model);
        foreach ($values as $tId) {
            $tModel = One_Repository::selectOne($tScheme->getName(), $tId);
            if (null !== $tModel) {
                $value[$tModel->{$tIdAttr}] = $tModel->{$targetAttr};
            }
        }
        $data = array('id' => $this->getID(), 'name' => $this->getFormName(), 'events' => $this->getEventsAsString(), 'params' => $this->getParametersAsString(), 'required' => $this->isRequired() ? ' *' : '', 'options' => $this->getOptions(), 'info' => $this->getCfg('info'), 'error' => $this->getCfg('error'), 'class' => $this->getCfg('class'), 'label' => $this->getLabel(), 'lblLast' => $this->getCfg('lblLast'));
        $dom = $this->parse($model, $data);
        //		$dom->add('<script type="text/javascript" href="'.One_Vendor::getInstance()->getSitePath().'/jquery/js/jquery.tagify.js" />'."\n", '_head');
        //		$dom->add('<link rel="stylesheet" type="text/css" href="'.One_Vendor::getInstance()->getSitePath().'/jquery/css/tagify-style.css" />'."\n", '_head');
        //One_Vendor::getInstance()->loadScript('jquery/js/jquery.tagify.js', 'head', 20);
        One_Vendor::getInstance()->loadStyle('jquery/css/tagify-style.css', 'head', 20);
        // Prepare autocomplete tagfield
        $script = '
		var oneTags' . $this->getID() . ' = jQuery("#' . $this->getID() . '").tagify();
		oneTags' . $this->getID() . '.tagify("inputField").autocomplete({
	        source: function(req, add) {
				req.field = "' . $targetAttr . '";
				req.query = "formtags";

				//pass request to server
                jQuery.getJSON("' . One_Config::getInstance()->getSiterootUrl() . One_Config::getInstance()->getAddressOne() . '&scheme=' . $tScheme->getName() . '&task=json", req, function(data) {

              	 	//create array for response objects
                    var suggestions = [];

              		//process response
                    jQuery.each(data, function(i, val) {
						var keyval = { "label": val.' . $targetAttr . ', "value": val.' . $tIdAttr . ' };
		                suggestions.push(keyval);
	    			});

	            	//pass array to callback
                    add(suggestions);

                });
			},
	        position: { of: oneTags' . $this->getID() . '.tagify("containerDiv") },
			select: function(e, ui) {
				oneTags' . $this->getID() . '.tagify("inputField").val(ui.item.label);
        		oneTags' . $this->getID() . '.tagify("add", ui.item.value, ui.item.label);
				oneTags' . $this->getID() . '.tagify("inputField").val("");
        		return false;
			},
			focus: function(e, ui) {
				oneTags' . $this->getID() . '.tagify("inputField").val(ui.item.label);
				return false;
			},
			change: function(e, ui) {
				oneTags' . $this->getID() . '.tagify("inputField").val("");
				return false;
			}
    	});
		';
        foreach ($value as $tId => $tVal) {
            $script .= '
		oneTags' . $this->getID() . '.tagify("add", "' . $tId . '", "' . $tVal . '");';
        }
        //		$dom->add($script, '_onload');
        One_Vendor::getInstance()->loadScriptDeclaration($script, 'onload', 20);
        $d->addDom($dom);
    }
Ejemplo n.º 26
0
    /**
     * Renders the Joomla-Media widget.
     * This widget is too specific to render with One_Script and should not be rendered otherwise,
     * hence this does not use the One_Form_Container_Abstract::parse() function
     *
     * @param One_Model $model
     * @param One_Dom $d
     * @access protected
     */
    protected function _render($model, One_Dom $d)
    {
        JHTML::_('behavior.modal');
        JHTML::_('behavior.modal', 'a.modal-button');
        $formName = $this->getFormName();
        $name = $this->getName();
        $id = $this->getID();
        $link = 'index.php?option=com_media&amp;view=images&amp;tmpl=component&amp;oneWidget=true&amp;e_name=' . $name;
        $button = new JObject();
        $button->set('modal', true);
        $button->set('link', $link);
        $button->set('text', JText::_('Image'));
        $button->set('name', 'image');
        $button->set('options', "{handler: 'iframe', size: {x: 570, y: 400}}");
        $modal = $button->get('modal') ? 'class="modal-button"' : null;
        $href = $button->get('link') ? 'href="' . JURI::base() . $button->get('link') . '"' : null;
        $onclick = $button->get('onclick') ? 'onclick="' . $button->get('onclick') . '"' : null;
        $dom = One_Repository::createDom();
        // should we show a label?
        if (!is_null($this->getLabel())) {
            $label = '<label class="OneFieldLabel" for="' . $id . '">' . $this->getLabel() . ($this->isRequired() ? ' *' : '') . '</label>' . "\n";
        }
        $dom->add("<span class='OneWidget'>");
        // start with label?
        if ($label && !$this->getCfg('lblLast')) {
            $dom->add($label);
        }
        $app = JFactory::getApplication();
        $jDoc = JFactory::getDocument();
        $path = '';
        if ($app->getName() != 'site') {
            $path = '../';
        }
        $mediaParams = JComponentHelper::getParams('com_media');
        $imageExtensions = $mediaParams->get('image_extensions');
        $imageExtensions = explode(',', $imageExtensions);
        preg_match('/\\.([a-z0-3]{1,4})$/i', $model->{$name}, $match);
        $currExt = $match[1];
        $isImage = in_array($currExt, $imageExtensions);
        $currImgSrc = $path . ($isImage ? $model->{$name} : 'images/spacer.gif');
        $thWidth = !is_null($this->getCfg('thWidth')) ? $this->getCfg('thWidth') : 50;
        $setMedia = 'function changeMedia( item, path )
		{
			document.getElementById( item ).value = path;

			var setImg = "' . $path . 'images/spacer.gif";
			if( path.match( /\\.(' . implode('|', $imageExtensions) . ')$/ ) )
				setImg = "' . $path . '" + ' . 'path;

			document.getElementById( "thImg" + item ).src = setImg;
			document.getElementById( "thImg" + item ).style.width = "' . $thWidth . 'px";
			document.getElementById( "thImgLink" + item ).href = setImg;
			document.getElementById("OneThumb"+item).style.display = "block";

		}

		function clearOneJMediaImg( item )
		{
			document.getElementById( item ).value = "";

			var setImg = "' . $path . 'images/spacer.gif";
			document.getElementById( "thImg" + item ).src = setImg;
			document.getElementById( "thImgLink" + item ).href = setImg;

			document.getElementById("OneThumb"+item).style.display = "none";
		}';
        // slimbox must be loaded AFTER mootools (current slimbox is meant for mootools 1.11)
        $jDoc->addScript(One_Config::getInstance()->getUrl() . '/vendor/slimbox/js/slimbox.js', 'text/javascript');
        $jDoc->addStyleSheet(One_Config::getInstance()->getUrl() . '/vendor/slimbox/css/slimbox.css', 'text/css', 'screen');
        $jDoc->addScriptDeclaration($setMedia);
        // show the input
        $dom->add('<div style="float: left;">');
        $dom->add('<input class="OneFieldInput" type="text" name="' . $formName . '" id="' . $id . '" size="50" readonly="readonly" value="' . $model->{$name} . '" />' . "\n");
        $dom->add('</div>');
        $dom->add('<div class="button2-left">');
        $dom->add('<div class="' . $button->get('name') . '">');
        $dom->add('<a ' . $modal . ' title="' . $button->get('text') . '" ' . $href . ' ' . $onclick . ' rel="' . $button->get('options') . '">' . $button->get('text') . '</a>');
        $dom->add('</div></div>');
        $dom->add('<div class="button2-left">');
        $dom->add('<div class="' . $button->get('name') . '">');
        $dom->add('<a href="#" onclick="clearOneJMediaImg( \'' . $id . '\' ); return false;">Clear image</a>');
        //TODO: clear thumb image
        $dom->add('</div>');
        $dom->add('</div>');
        $dom->add('<div class="OneThumb" id="OneThumb' . $id . '"' . ('' == trim($currImgSrc) || $path . 'images/spacer.gif' == trim($currImgSrc) ? ' style="display: none;"' : '') . '>');
        $dom->add('<a href="' . $currImgSrc . '" id="thImgLink' . $id . '" rel="lightbox"><img id="thImg' . $id . '" src="' . $currImgSrc . '" width="' . $thWidth . '" /></a>');
        $dom->add('</div>');
        // end with label?
        if ($label && $this->getCfg('lblLast')) {
            $dom->add($label);
        }
        $dom->add("</span>");
        $d->addDom($dom);
    }
Ejemplo n.º 27
0
    /**
     * Render the widget as a JS datepicker
     *
     * @param One_Model $model
     * @param One_Dom $d
     */
    private function renderJSCalendar($model, One_Dom $d)
    {
        if (!is_null($this->getCfg('jquery'))) {
            return $this->renderJQueryDatepicker($model, $d);
        }
        $id = $this->getID();
        $name = $this->getName();
        $value = $this->getValue($model);
        $dom = One_Repository::createDom();
        preg_match('/^(\\d{4})-(\\d{2})-(\\d{2})( (\\d{2}):(\\d{2}):(\\d{2}))?$/', $value, $matches);
        One_Vendor::getInstance()->loadStyle('js/jscalendar/calendar-win2k-1.css', 'head');
        One_Vendor::getInstance()->loadScript('js/jscalendar/calendar.js', 'head', 10);
        //		One_Vendor::getInstance()->loadScript('js/jscalendar/lang/calendar-'.strtolower(substr(One::getInstance()->getLanguage(), 0, 2)).'.js', 'head', 11); // problems with language packs so stick to EN
        One_Vendor::getInstance()->loadScript('js/jscalendar/lang/calendar-en.js', 'head', 11);
        One_Vendor::getInstance()->loadScript('js/jscalendar/calendar-setup.js', 'head', 12);
        if ($this->getCfg('jsFlat')) {
            $container = new One_Form_Container_Div($id . 'container');
            $extraParams = array('default' => $this->getDefault());
            if (in_array($this->getCfg('one'), array('one', 'yes', 'true', '1'))) {
                $extraParams['one'] = 'one';
            }
            $hidden = new One_Form_Widget_Scalar_Hidden($id, $name, null, $extraParams);
            $container->render($model, $dom);
            $hidden->render($model, $dom);
            $defaultDate = date('Y-m-d');
            if ('' != $value && '0000-00-00' != $value && '0000-00-00 00:00:00' != $value) {
                $defaultDate = $value;
            }
            $onloadscript = '
			Calendar.setup(
			{
				flat         : "' . $id . 'container",
				flatCallback : dateChanged,
				ifFormat     : "%Y-%m-%d' . (trim($this->getCfg('time')) != '' ? ' %H:%M' : '') . '"' . (trim($this->getCfg('time')) != '' ? ',
				showsTime    : true' : '') . ',
				date         : "' . $value . '"
			}
			);
			';
            $headscript = 'function dateChanged(calendar)
			{
				if(calendar.dateClicked)
				{
					var hidden = document.getElementById("' . $id . '");
					var year = calendar.date.getFullYear();
					var month = ((calendar.date.getMonth() + 1) < 10) ? "0" + (calendar.date.getMonth() + 1) : (calendar.date.getMonth() + 1);
					var day = (calendar.date.getDate() < 10) ? "0" + calendar.date.getDate() : calendar.date.getDate();

					hidden.value = year + "-" + month + "-" + day;
				}
			}';
            One_Vendor::getInstance()->loadScriptDeclaration($headscript, 'head', 10);
            One_Vendor::getInstance()->loadScriptDeclaration($onloadscript, 'onload');
        } else {
            $extraParams = array('readonly' => 'readonly', 'default' => $this->getDefault());
            if (in_array($this->getCfg('one'), array('one', 'yes', 'true', '1'))) {
                $extraParams['one'] = 'one';
            }
            $tf = new One_Form_Widget_Scalar_Textfield($id, $name, NULL, $extraParams);
            $trigger = new One_Form_Widget_Image($id . 'trigger', $name . 'trigger', NULL, array('src' => One_Config::getInstance()->getUrl() . '/vendor/images/calendar.png', 'alt' => 'Show calendar', 'title' => 'Show calendar'));
            $tf->render($model, $dom);
            $trigger->render($model, $dom);
            $script = 'Calendar.setup(
			{
				inputField : "' . $name . '",
				ifFormat   : "%Y-%m-%d' . (trim($this->getCfg('time')) != '' ? ' %H:%M' : '') . '",
				button     : "' . $name . 'trigger"' . (trim($this->getCfg('time')) != '' ? ',
				showsTime    : true' : '') . '
			}
			);';
            One_Vendor::getInstance()->loadScriptDeclaration($script, 'onload');
        }
        //return $output;
        $d->addDom($dom);
    }
Ejemplo n.º 28
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 main table to fetch data from
     $this->mainTable = $resources['table'];
     $this->defineRole('$self$');
     // 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);
                 }
             }
         }
     }
     // TR20100531 No longer needs to be run after the rest since joins are now checked while adding
     // sselects, order, ...
     $joins = NULL;
     $qJoins = $query->getJoins();
     if (count($qJoins) > 0) {
         foreach ($qJoins as $join => $type) {
             $this->defineRole($join);
             $query->setRoleAlias($join, $this->aliases[$join]);
             $joins .= $this->createJoin($query->getRole($join), $type);
         }
     }
     // *** TODO: change the '*' to only the relavant fields defined in the scheme
     $selects = $this->aliases['$self$'] . '.*';
     if (count($query->getSelect()) > 0) {
         $selects = $this->createSelects($query->getSelect());
     }
     // get where clauses
     $whereClauses = $query->getWhereClauses();
     $where = NULL;
     if (!is_null($whereClauses)) {
         $where = $this->whereClauses($whereClauses);
     }
     // get having clauses
     $havingClauses = $query->getHavingClauses();
     $having = NULL;
     if (!is_null($havingClauses)) {
         $having = $this->whereClauses($havingClauses);
     }
     // get order
     $order = $this->createOrder();
     //get grouping
     $group = $this->createGroup();
     // get limit
     $limit = $this->createLimit();
     $sql = 'SELECT ' . $selects . ' FROM `' . $this->mainTable . '` ' . $this->aliases['$self$'];
     if (!is_null($joins)) {
         $sql .= $joins;
     }
     if (!is_null($where)) {
         $sql .= ' WHERE ' . $where;
     }
     if (!is_null($group)) {
         $sql .= ' GROUP BY ' . $group;
     }
     if (!is_null($having)) {
         $sql .= ' HAVING ' . $having;
     }
     if (!is_null($order)) {
         $sql .= ' ORDER BY ' . $order;
     }
     if (!is_null($limit)) {
         $sql .= ' LIMIT ' . $limit;
     }
     if (One_Config::get('debug.query')) {
         echo '<pre>';
         var_dump($sql);
         echo '</pre>';
     }
     return $sql;
 }
Ejemplo n.º 29
0
 /**
  * Set the One_Script search path according to scheme
  *
  * The order to look is
  * 1) SPACE/views/APP/SCHEME/LANG
  * 2) SPACE/views/APP/SCHEME/
  * 3) SPACE/views/APP/LANG
  * 4) SPACE/views/APP/
  * 3) SPACE/views/default/LANG
  * 4) SPACE/views/default/
  *
  * @param string $schemeName
  */
 public function setDefaultViewSearchPath()
 {
     $locator = One_Config::get('view.locator', 'One_View_Locator');
     $viewPattern = $locator::getPatternForScheme($this->schemeName);
     $this->templater->setSearchPath($viewPattern);
 }
Ejemplo n.º 30
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', 'OneFieldDropdown ' . $this->getCfg('class'));
        // fetch all data to do with the relationship
        $parts = explode(':', $this->getCfg('role'));
        $related = $model->getRelated($parts[1]);
        $targetAttr = $this->getCfg('targetAttribute');
        $triggerOn = intval($this->getCfg('triggerOn')) > 0 ? intval($this->getCfg('triggerOn')) : 2;
        $scheme = $model->getScheme();
        $idAttr = $scheme->getIdentityAttribute()->getName();
        $link = $scheme->getLink($parts[1]);
        $relatedIDs = '';
        $options = array();
        if (is_array($related) && count($related) > 0) {
            $relatedIDArray = array();
            $idAttr = One_Repository::getScheme($link->getTarget())->getIdentityAttribute()->getName();
            $tparts = explode(':', $targetAttr);
            foreach ($related as $relate) {
                if (is_null($idAttr)) {
                    $scheme = $model->getScheme();
                    $idAttr = $scheme->getIdentityAttribute()->getName();
                }
                $value = $relate->{$idAttr};
                $shown = '';
                foreach ($tparts as $tpart) {
                    $shown .= $relate->{$tpart} . ' ';
                }
                $options[$value] = $shown;
                $relatedIDArray[] = $relate->{$idAttr};
            }
            $relatedIDs = implode('^,^', $relatedIDArray);
        }
        $data = array('id' => $this->getID(), 'name' => $this->getFormName(), 'events' => $this->getEventsAsString(), 'params' => $this->getParametersAsString(), 'required' => $this->isRequired() ? ' *' : '', 'value' => is_null($this->getValue($model)) ? $this->getDefault() : $this->getValue($model), 'options' => $options, 'onEmpty' => strtolower($this->getCfg('onEmpty')), 'triggerOn' => $triggerOn, 'scheme' => $scheme, 'link' => $link, 'targetAttr' => $targetAttr, 'modelID' => $model->{$idAttr}, 'relatedIDs' => $relatedIDs, 'info' => $this->getCfg('info'), 'error' => $this->getCfg('error'), 'class' => $this->getCfg('class'), 'label' => $this->getLabel(), 'lblLast' => $this->getCfg('lblLast'));
        //		$dom = new One_Dom(); // dom for head section
        //
        //		$head = '<script type="text/javascript" src="' . One::getInstance()->getUrl() . 'lib/libraries/js/featherajax.js"></script>';
        //		$dom->add( $head, '_head' );
        $head = '
			function setRelatedOptions( selfscheme, scheme, selfId, id, targetAttribute, phrase )
			{
				var self = "";
				if( selfscheme == scheme )
					self = "&selfId=" + selfId;
				var aj = new AjaxObject101();
				aj.sndReq( "post", "' . One_Config::getInstance()->getUrl() . '/lib/form/ajax/relational.php", "searchscheme=" + scheme + "&dd=f" + id + "&target=" + targetAttribute + "&phrase=" + phrase + self );
			}

			function addChosenOptions( id )
			{
				var dropdown = document.getElementById( "f" + id );
				var to       = document.getElementById( "t" + id );
				for( var i = 0; i < dropdown.length; i++ )
				{
					if( dropdown.options[i].selected == true )
					{
						var option = document.createElement("option");
						option.value = dropdown.options[i].value;
						option.innerHTML = dropdown.options[i].text;

						var found = false
						for( var j = 0; j < to.length; j++ )
						{
							if( option.value == to.options[j].value )
							{
								found = true;
								break;
							}
						}

						if( !found )
						{
							var hidden = document.getElementById( id );
							to.appendChild( option );

							if( hidden.value != "" )
								hidden.value = hidden.value + "^,^" + option.value;
							else
								hidden.value = option.value;
						}
					}
				}

			}

			function removeChosenOptions( id )
			{
				var to     = document.getElementById( "t" + id );
				var hidden = document.getElementById( id );

				for( var i = ( to.length - 1 ); i >= 0; i-- )
				{
					if( to.options[i].selected == true )
					{
						var pattern  = \'((\\^,\\^)?\' + to.options[i].value + \'(\\^,\\^)?)\';
						var test     = new RegExp( pattern, "gi" );
						/* @TODO There is probably an easier way to do this  */
						hidden.value = hidden.value.replace( test, "" );
						hidden.value = hidden.value.replace( /\\^,\\^\\^,\\^/gi, "^,^" );
						hidden.value = hidden.value.replace( /^\\^,\\^/gi, "" );
						hidden.value = hidden.value.replace( /\\^,\\^$/gi, "" );
						to.remove( i );
					}
				}
			}';
        //		$dom->add( $head, '_head' );
        One_Vendor::getInstance()->loadScript('js/featherajax.js', 200);
        One_Vendor::getInstance()->loadScriptDeclaration($head, 'head', 200);
        $content = $this->parse($model, $data);
        //		$d->addDom($dom);
        $d->addDom($content);
    }