예제 #1
0
 public static function errorMessagesList(Messages $messages, $fields)
 {
     constraint_mustBeArray($fields);
     // just in case ... if there are no errors, we have nothing
     // to do here
     if ($messages->errorCount == 0) {
         return '';
     }
     // okay, we know for sure that there are errors ... but
     // the question is how many?
     $return = '<ul class="mfErrors2">';
     foreach ($fields as $field) {
         $errors = $messages->getErrorsForField($field);
         if (count($errors) == 0) {
             // no errors for this field
             // move on to the next one
             continue;
         }
         foreach ($errors as $error) {
             $return .= '<li>' . XHTML::translation($error['module'], $error['message'], $error['params']) . '</li>';
         }
     }
     $return .= '</ul>';
     return $return;
 }
예제 #2
0
 public function __construct(&$__data = null)
 {
     if ($__data != null) {
         constraint_mustBeArray($__data);
         $this->__data =& $__data;
         $this->rewind();
     }
 }
예제 #3
0
 /**
  *
  * @param string $module name of the module these translations are for
  * @param array $translations set of translations to load
  */
 public function addTranslations($module, $translations)
 {
     constraint_mustBeString($module);
     constraint_mustBeArray($translations);
     if (!is_array($this->translations[$module])) {
         $this->translations[$module] = array();
     }
     $this->translations[$module] = array_merge($translations, $this->translations[$module]);
 }
예제 #4
0
 /**
  * set the conditions that must match for this route
  */
 public function withConditions($conditions)
 {
     constraint_mustBeArray($conditions);
     $this->conditions = $conditions;
     return $this;
 }
예제 #5
0
 public function withForeignKeys($keys)
 {
     constraint_mustBeArray($keys);
     $oMap = $this->oDB->getStorageForModel($this->currentView->oDef->getModelName());
     foreach ($keys as $field => $value) {
         $this->searchTerms[] = array('type' => Datastore_Query::TYPE_FIELD, 'table' => $oMap->getTable(), 'field' => $field, 'value' => $value);
     }
     return $this;
 }
예제 #6
0
 public function setValidSections($sections)
 {
     constraint_mustBeArray($sections);
     $this->validSections = $sections;
 }
예제 #7
0
function add_to_query_string($query, $additions)
{
    constraint_mustBeString($query);
    constraint_mustBeArray($additions);
    $append = false;
    if (strlen($query) > 0) {
        $append = true;
    }
    $return = '';
    foreach ($additions as $key => $value) {
        if ($append) {
            $return .= '&';
        }
        $append = true;
        $return .= urlencode($key) . '=' . urlencode($value);
    }
    return $query . $return;
}
예제 #8
0
파일: Array.php 프로젝트: stuartherbert/mf
 public function append($secondArray)
 {
     constraint_mustBeArray($secondArray);
     foreach ($secondArray as $secondArrayData) {
         $this->__data[] = $secondArrayData;
     }
 }
예제 #9
0
 public function ourFieldsAre($fieldNames)
 {
     constraint_mustBeArray($fieldNames);
     $this->ourFields = $fieldNames;
     return $this;
 }
예제 #10
0
 public function buildRawQuery()
 {
     // we have to take all the information that we have
     // been given, and turn it into a single SQL statement
     $queryBuilder = array('tokens' => array());
     foreach ($this->searchTerms as $searchTerm) {
         switch ($searchTerm['type']) {
             case Datastore_Query::TYPE_VIEW:
                 $this->buildRawQuery_view($searchTerm, $queryBuilder);
                 break;
             case Datastore_Query::TYPE_FIELD:
                 $this->buildRawQuery_field($searchTerm, $queryBuilder);
                 break;
             case Datastore_Query::TYPE_JOIN:
                 $this->buildRawQuery_join($searchTerm, $queryBuilder);
                 break;
             case Datastore_Query::TYPE_EXPRESSION:
                 $this->buildRawQuery_expression($searchTerm, $queryBuilder);
                 break;
             default:
                 throw new Exception();
         }
     }
     // at this point, we have discovered the pieces
     // now we need to turn them into a single statement
     $sql = 'select ' . join(', ', $queryBuilder['fieldsToSelect']) . ' from ' . $queryBuilder['tablesFrom'][0];
     if (isset($queryBuilder['joins'])) {
         $sql .= ' INNER JOIN ' . join(' INNER JOIN ', $queryBuilder['joins']);
     }
     if (isset($queryBuilder['where'])) {
         $sql .= ' where ' . join(' and ', $queryBuilder['where']);
     }
     if (isset($queryBuilder['orderBy'])) {
         $sql .= ' order by ' . $queryBuilder['orderBy'];
     } else {
         // primary key may be complex
         $primaryKeys = $this->currentView->oDef->getPrimaryKey();
         if (count($primaryKeys) == 1) {
             $sql .= ' order by ' . current($primaryKeys) . ' asc';
         } else {
             $sql .= ' order by ' . implode(' asc,', $primaryKeys) . ' asc';
         }
     }
     constraint_mustBeString($sql);
     constraint_mustBeArray($queryBuilder['tokens']);
     return array($sql, $queryBuilder['tokens']);
 }