本文整理汇总了PHP中MUtil_Model_ModelAbstract::is方法的典型用法代码示例。如果您正苦于以下问题:PHP MUtil_Model_ModelAbstract::is方法的具体用法?PHP MUtil_Model_ModelAbstract::is怎么用?PHP MUtil_Model_ModelAbstract::is使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MUtil_Model_ModelAbstract
的用法示例。
在下文中一共展示了MUtil_Model_ModelAbstract::is方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: replaceCreateView
/**
* Handles creating or replacing the view for this survey
*
* @param \Gems_Tracker_Survey $viewName
* @param \MUtil_Model_ModelAbstract $answerModel
*/
protected function replaceCreateView(\Gems_Tracker_Survey $survey, \MUtil_Model_ModelAbstract $answerModel)
{
$viewName = $this->getViewName($survey);
$responseDb = $this->project->getResponseDatabase();
$fieldSql = '';
foreach ($answerModel->getItemsOrdered() as $name) {
if (true === $answerModel->get($name, 'survey_question') && !in_array($name, array('submitdate', 'startdate', 'datestamp')) && !$answerModel->is($name, 'type', \MUtil_Model::TYPE_NOVALUE)) {
// Only real answers
$fieldSql .= ',MAX(IF(gdr_answer_id = ' . $responseDb->quote($name) . ', gdr_response, NULL)) AS ' . $responseDb->quoteIdentifier($name);
}
}
if ($fieldSql > '') {
$dbConfig = $this->db->getConfig();
$tokenTable = $this->db->quoteIdentifier($dbConfig['dbname'] . '.gems__tokens');
$createViewSql = 'CREATE OR REPLACE VIEW ' . $responseDb->quoteIdentifier($viewName) . ' AS SELECT gdr_id_token';
$createViewSql .= $fieldSql;
$createViewSql .= "FROM gemsdata__responses join " . $tokenTable . " on (gto_id_token=gdr_id_token and gto_id_survey=" . $survey->getSurveyId() . ") GROUP BY gdr_id_token;";
try {
$responseDb->query($createViewSql)->execute();
} catch (Exception $exc) {
$responseConfig = $responseDb->getConfig();
$dbUser = $this->db->quoteIdentifier($responseConfig['username']) . '@' . $this->db->quoteIdentifier($responseConfig['host']);
$statement = "GRANT SELECT ON " . $tokenTable . " TO " . $dbUser;
$this->getBatch()->addMessage(sprintf($this->_("Creating view failed, try adding rights using the following statement: %s"), $statement));
}
}
}
示例2: applyToModel
/**
* Use this function for a default application of this dependency to the model
*
* @param \MUtil_Model_ModelAbstract $model Try not to store the model as variabe in the dependency (keep it simple)
*/
public function applyToModel(\MUtil_Model_ModelAbstract $model)
{
if ($this->applyOnChange) {
foreach ($this->getDependsOn() as $name) {
if ($model->is($name, 'elementClass', 'Checkbox')) {
if (!$model->has($name, 'onclick')) {
$model->set($name, 'onclick', $this->onChangeJs);
}
} else {
if (!$model->has($name, 'onchange')) {
$model->set($name, 'onchange', $this->onChangeJs);
}
}
}
}
}
示例3: restoreHeaderPositions
/**
* Restores the header position of question before their corresponding question_sub
*
* When sub-questions with the same parent are shown continuous the parent is shown
* once before them. When the sub-questions are displayed in seperate groups the
* parent is shown once at their start.
*
* Stand alone headers without any corresponding value are removed. When they do have
* a value of their own they are still shown, but their position may change according
* to their sub-questions position. (NOTE: As in LimeSurvey their are no question
* headers with values we leave it at this for the moment.)
*
* @param \MUtil_Model_ModelAbstract $model
* @param array $currentNames The current names in use (allows chaining)
* @return array Of the names of labels that should be shown
*/
protected function restoreHeaderPositions(\MUtil_Model_ModelAbstract $model, array $currentNames)
{
$lastParent = null;
$results = array();
foreach ($currentNames as $name) {
if ($model->is($name, 'type', \MUtil_Model::TYPE_NOVALUE)) {
// Skip header types that contain no value
continue;
}
if ($parent = $model->get($name, 'parent_question')) {
// Check for change of parent
if ($lastParent !== $parent) {
if (isset($results[$parent])) {
// Add another copy of the parent to the array
$results[] = $parent;
} else {
// Insert parent header on name if it was not shown before
$results[$parent] = $parent;
}
$lastParent = $parent;
}
} else {
// Make sure a question (without parent) is picked up as parent too
$lastParent = $name;
}
// If already set (as a $parent) this will not
// redisplay the $parent as $result[$name] does
// not change position
$results[$name] = $name;
}
return $results;
}
示例4: filterBasic
/**
* Translate textual null values to actual PHP nulls and trim any whitespace
*
* @param mixed $value
* @param scalar $key The array key, optionally a model key as well
* @return mixed
*/
public function filterBasic(&$value, $key)
{
if (is_string($value) && $this->nullValue === strtoupper($value)) {
$value = null;
return;
}
if ($this->_targetModel instanceof \MUtil_Model_ModelAbstract) {
if ($this->_targetModel->is($key, 'type', \MUtil_Model::TYPE_DATE)) {
$format = $this->dateFormat;
} elseif ($this->_targetModel->is($key, 'type', \MUtil_Model::TYPE_DATETIME)) {
$format = $this->datetimeFormat;
} elseif ($this->_targetModel->is($key, 'type', \MUtil_Model::TYPE_TIME)) {
$format = $this->timeFormat;
} else {
$format = false;
}
if ($this->dateLocale && is_string($this->dateLocale)) {
$this->dateLocale = new \Zend_Locale($this->dateLocale);
}
if ($format && \Zend_Date::isDate($value, $format, $this->dateLocale)) {
$value = new \MUtil_Date($value, $format, $this->dateLocale);
return;
}
$options = $this->_targetModel->get($key, 'multiOptions');
if ($options && !isset($options[$value]) && in_array($value, $options)) {
$value = array_search($value, $options);
}
}
if (is_string($value)) {
$value = trim($value);
return;
}
return;
}