Beispiel #1
0
 /**
  * Create a new OneFormContainerForm
  *
  * @param One_Scheme $scheme
  * @param string $formName
  * @param string $action
  * @param string $formFile location of the file, admin/form.xml by default
  * @return OneFormContainerForm
  */
 public static function createForm(One_Scheme $scheme, $formFile = NULL, $language = NULL, $formName = 'oneForm', $action = '', $method = 'post')
 {
     if (is_null($language)) {
         $language = One_Config::get('app.language');
     }
     // search for appropriate form.xml
     $pattern = "%ROOT%/views/" . "{" . ($scheme->getName() != '' ? "%APP%/{$scheme->getName()}," : "") . "%APP%,default}" . DIRECTORY_SEPARATOR . "{%LANG%" . DIRECTORY_SEPARATOR . ",}";
     $filepath = One_Locator::locateUsing($formFile . '.xml', $pattern);
     try {
         if ($filepath !== null) {
             $form = One_Form_Reader_Xml::load($filepath, $scheme, $language, $formName, $action, $method);
             //          echo '<pre>';
             //          print_r($form);
             //          echo '</pre>';
             //          echo '<hr>';
             //          print_r(self::createDefaultForm($scheme, $formFile, $language, $formName, $action, $method));
         } else {
             $form = self::createDefaultForm($scheme, $formFile, $language, $formName, $action, $method);
         }
     } catch (Exception $e) {
         $form = self::createDefaultForm($scheme, $formFile, $language, $formName, $action, $method);
     }
     self::addObligatedWidgets($form, $scheme);
     return $form;
 }
Beispiel #2
0
 public function getFlowFile($fileName)
 {
     // search for appropriate flow definition xml file
     $pattern = "%ROOT%/meta/flows/";
     $filepath = One_Locator::locateUsing($fileName . '.xml', $pattern);
     return $filepath;
     //
     //
     //    $paths = array();
     //		$paths[] = One::getInstance()->getCustomPath().'/meta/flows/'.One::getInstance()->getApplication().'/';
     //		$paths[] = One::getInstance()->getCustomPath().'/meta/flows/';
     //		$paths[] = One::getInstance()->getPath().'/meta/flows/';
     //
     //		$validFile = false;
     //		foreach($paths as $path)
     //		{
     //			$filePath = $path.$fileName.'.xml';
     //			if(file_exists($filePath)) {
     //				$validFile = true;
     //				break;
     //			}
     //		}
     //
     //		return ((!$validFile) ? false : $filePath);
 }
Beispiel #3
0
 public static function searchFile($filename, $path, $mode = 'nano')
 {
     // try the file as specified
     $path = $path . $filename;
     //        print "<br>(trying specified $path)";
     if ($hash = One_Script_Cache::get($path)) {
         return array(true, $hash, $path);
     }
     if (file_exists($path)) {
         return self::loadFileContents($path, $mode);
     }
     // not found, walk the search sequence -- DEPRECATED
     /*
         $sequence = self::$nsLoadPath;
     
         if ($sequence) foreach ($sequence as $pathTemplate)  {
       $place = One_Locator::locateUsing($path,$pathTemplate);
       if ($hash = One_Script_Cache::inCache( $place )) return array( true, $hash, $place );
       return self::loadFileContents( $place, $mode );
     }
     */
     $place = One_Locator::locateUsing($path, self::currentSearchPattern());
     if ($place !== null) {
         if ($hash = One_Script_Cache::inCache($place)) {
             return array(true, $hash, $place);
         }
         return self::loadFileContents($place, $mode);
     }
     self::$error = "One_Script_Factory error : could not locate '{$filename}' in '{$path}'";
     return false;
 }
Beispiel #4
0
 /**
  * Gets all the columns that should be shown in the list
  *
  * @return array Array of all columns in the form of object with extra data
  */
 private function getColumns()
 {
     $session = One_Repository::getSession();
     $exists = true;
     $filename = One_Locator::locateUsing('list.xml', ONE_LOCATOR_ROOTPATTERN . 'views/' . One_Config::get('app.name') . '/' . $this->scheme->getName() . '/');
     if ($filename === null) {
         $exists = false;
     }
     if ($exists) {
         $xml = @simplexml_load_file($filename);
     }
     if ($exists && $xml) {
         // JL06JAN2009 - if no sorting was clicked, check if the default sort column was set
         // in the xml file
         $xmlarray_defs = xmlpm($xml, "/view/columns");
         $sort = (string) $xmlarray_defs[0]->attributes()->sort;
         $limit = (string) $xmlarray_defs[0]->attributes()->limit;
         if ('' != trim($sort)) {
             preg_match('/^([^\\+\\-]+)(\\+|\\-)?$/i', $sort, $sortMatch);
             $this->_sortOrder = 'asc';
             $this->_sort = $sortMatch[1];
             if (isset($sortMatch[2]) && $sortMatch[2] == '-') {
                 $this->_sortOrder = 'desc';
             }
         }
         if (0 < abs(intval($limit))) {
             $this->_limit = abs(intval($limit));
         }
         $xmlarray = $xmlarray_defs[0]->column;
         $this->_columns = array();
         foreach ($xmlarray as $xmlpart) {
             $tmp = new stdClass();
             $name = '';
             $setFilter = false;
             $filterType = 'text';
             $filterOptions = array();
             $operator = 'contains';
             foreach ($xmlpart->attributes() as $key => $val) {
                 switch (strtolower($key)) {
                     case 'name':
                         $tmp->name = (string) $val;
                         break;
                     case 'label':
                         $tmp->label = (string) $val;
                         break;
                     case 'filter':
                         if ($val == 1) {
                             $setFilter = true;
                         }
                         break;
                     case 'filtertype':
                         if (in_array(strtolower($val), array('dropdown', 'text', 'daterange'))) {
                             $filterType = strtolower($val);
                         }
                         break;
                     case 'filteroptions':
                         $options = explode(';', $val);
                         foreach ($options as $option) {
                             $parts = explode('=', $option, 2);
                             $filterOptions[$parts[0]] = $parts[1];
                         }
                     case 'operator':
                         if (in_array((string) $val, $this->_operators)) {
                             $operator = (string) $val;
                         }
                     default:
                         $tmp->{$key} = (string) $val;
                 }
             }
             if ($filterType == 'dropdown' && count($filterOptions) == 0 && trim($tmp->name) != '') {
                 preg_match('/([^:]+)((:)(.+))?/', $tmp->name, $matches);
                 if (!is_null($matches[4])) {
                     $link = $this->scheme->getLink($matches[1]);
                     $target = One_Repository::getScheme($link->getTarget());
                     $tAtt = $matches[4];
                     $tFac = One_Repository::getFactory($target->getName());
                     $tQ = $tFac->selectQuery();
                     $tQ->setSelect(array($tAtt));
                     $tQ->setOrder(array($matches[4] . '+'));
                     $options = $tQ->execute(false);
                     foreach ($options as $option) {
                         $filterOptions[$option->{$tAtt}] = $option->{$tAtt};
                     }
                 }
             }
             //PD16SEP09: if no name is given, interpret the body of the tag as CDATA containing nanoScript
             // TR20100408: change this to only set the name as the label if no name is given.
             if (!isset($tmp->name)) {
                 $tmp->name = $tmp->label;
             }
             //filter operator defaults to contains
             if (!isset($tmp->name)) {
                 $tmp->operator = 'contains';
             }
             // TR20100408: change this to interpret as nanoscript if a value is passed to the tag
             if (trim((string) $xmlpart) != '') {
                 $tmp->nScript = (string) $xmlpart;
             }
             $this->_columns[$tmp->name] = $tmp;
             if ($setFilter) {
                 if ($filterType != 'daterange') {
                     $value = JRequest::getVar('s' . $tmp->name, NULL);
                 } else {
                     $value = array(JRequest::getVar('s' . $tmp->name . 'Start', NULL), JRequest::getVar('s' . $tmp->name . 'End', NULL));
                 }
                 if (is_null($value)) {
                     $value = $session->get($tmp->name, $this->scheme->getName() . '--list');
                 }
                 $session->set($tmp->name, $value, $this->scheme->getName() . '--list');
                 $this->_filters[$tmp->name] = array('label' => $tmp->label, 'value' => $value, 'type' => $filterType, 'options' => $filterOptions, 'operator' => $operator);
             }
         }
     }
     if (is_null($this->_columns)) {
         $columns = $this->scheme->get('attributes');
         $this->_columns = array();
         foreach ($columns as $name => $column) {
             $tmp = new stdClass();
             $tmp->label = $column->getName();
             $tmp->name = $column->getName();
             // TR20100317 used to be $column->column() but should not be used anymore
             $this->_columns[$tmp->name] = $tmp;
         }
     }
     return $this->_columns;
 }