Example #1
0
function constraint_mustBeTheme($themeName)
{
    // step 1: load the theme if it is not already loaded
    constraint_mustBeString($themeName);
    $theme = new $themeName();
    // step 2: check to see if it has registered itself as a theme
    if (!App::$themes->isRegisteredTheme($themeName)) {
        throw new PHP_E_ConstraintFailed(__FUNCTION__);
    }
}
Example #2
0
 public function withClass($extensionClass)
 {
     // var_dump('Extending ' . $this->name . ' with ' . $extensionClass);
     // var_dump('We have ' . count($this->mixins) . ' mixins before this one');
     constraint_mustBeString($extensionClass);
     constraint_mustBeMixinClass($extensionClass);
     $this->mixins[$extensionClass] = $extensionClass;
     $this->updateMethodsAndProperties();
     MF_Events_Manager::triggerEvent('classExtended', null, array('class' => $this->name, 'extension' => $extensionClass));
     // var_dump('We now have ' . count($this->mixins) . ' mixins after this one');
 }
Example #3
0
 public function routeToUrl($url)
 {
     constraint_mustBeString($url);
     $this->rawUrl = $url;
     $this->isInternal = false;
     $this->routeToModule = null;
     $this->routeToPage = null;
     return $this;
 }
 public function __construct($cacheName)
 {
     constraint_mustBeString($cacheName);
     $this->filename = APP_TOPDIR . '/cache/' . $cacheName . '.cache.php';
 }
Example #5
0
 public function usingSnippet($snippet)
 {
     constraint_mustBeString($snippet);
     $this->snippet = $snippet;
     // fluid interface
     return $this;
 }
Example #6
0
 public function orderBy($orderBy)
 {
     constraint_mustBeString($orderBy);
     $this->orderBy = $orderBy;
     return $this;
 }
Example #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;
}
Example #8
0
 public function withUrl($url)
 {
     constraint_mustBeString($url);
     $this->url = $url;
     return $this;
 }
Example #9
0
 public function requireJs($renderer, $name)
 {
     constraint_mustBeString($renderer);
     constraint_mustBeString($name);
     if (!isset($this->javascript[$name]) || !$this->javascript[$name]) {
         $func = 'includeJs_' . $name;
         $this->{$func}($renderer);
     }
 }
Example #10
0
 /**
  *
  * @param string $module name of the module we wanat to load translations for
  */
 protected function requireValidPathForModule($module)
 {
     if (!isset($this->translationFiles[$module])) {
         throw new MF_Language_E_UnknownModule($module);
     }
     constraint_mustBeString($this->translationFiles[$module]);
     if (!file_exists($this->translationFiles[$module])) {
         throw new MF_Language_E_NoSuchTranslation($module, $this->translationFiles[$module]);
     }
 }
Example #11
0
 public function __construct($wizardName)
 {
     constraint_mustBeString($wizardName);
     $this->wizardName = $wizardName;
 }
Example #12
0
 function __construct(DataModel_Definition $oDef, $viewName)
 {
     constraint_mustBeString($viewName);
     $this->oDef = $oDef;
     $this->name = $viewName;
 }
 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']);
 }