Example #1
0
 protected function initPopover()
 {
     $conf = $this->identifier->getTypeConfig();
     if (!isset($conf['form']['popover'])) {
         return;
     }
     $popoverConf = array();
     foreach ($conf['form']['popover'] as $attrs => $conf) {
         foreach (AESHelper::explode($attrs) as $attr) {
             if (!isset($conf['title'])) {
                 $conf['title'] = 'Document example';
             }
             $popoverConf[] = array_merge(array('attr' => $attr), $conf);
         }
     }
     Yii::app()->clientScript->registerScriptFile(Yii::app()->assetManager->publish(Yii::getPathOfAlias('personIdentifier.assets') . '/popupdetails.js'));
     $module = Yii::app()->getModule('personIdentifier');
     $maxWidth = $module->identifierExampleMaxWidth;
     $maxHeight = $module->identifierExampleMaxHeight;
     foreach ($popoverConf as $index => $conf) {
         if (!isset($conf['img'])) {
             unset($popoverConf[$index]);
             continue;
         }
         $examplesPath = Yii::getPathOfAlias('webroot') . $module->identifierExamplesPath;
         $currentTypeExamplePath = $examplesPath . '/' . $this->identifier->type;
         $sourceImgPath = Yii::getPathOfAlias($module->customIdentifiersPath . '.' . $this->identifier->type) . '/' . $conf['img'];
         $destImgPath = $currentTypeExamplePath . '/' . $conf['img'];
         $published = file_exists($destImgPath);
         if (!$published && !file_exists($sourceImgPath)) {
             unset($popoverConf[$index]);
             continue;
         }
         if (!$published) {
             if (!file_exists(Yii::getPathOfAlias('webroot') . $module->imagesDir)) {
                 mkdir(Yii::getPathOfAlias('webroot') . $module->imagesDir);
             }
             if (!file_exists($examplesPath)) {
                 mkdir($examplesPath);
             }
             if (!file_exists($currentTypeExamplePath)) {
                 mkdir($currentTypeExamplePath);
             }
             $image = Yii::app()->image->load($sourceImgPath);
             list($width, $height) = getimagesize($sourceImgPath);
             if ($width > $maxWidth || $height > $maxHeight) {
                 $image->resize($maxWidth, $maxHeight);
             }
             $image->quality(100)->save($destImgPath);
         }
         list($width, $height) = getimagesize($destImgPath);
         $imgUrl = Yii::app()->getBaseUrl(true) . $module->identifierExamplesPath . '/' . $this->identifier->type . '/' . $conf['img'];
         $popoverConf[$index]['img'] = $imgUrl;
         $popoverConf[$index]['width'] = $width;
         $popoverConf[$index]['height'] = $height;
     }
     Yii::app()->clientScript->registerScript(uniqid(), 'PersonIdentifier.initPopups(' . CJavaScript::encode($popoverConf) . ');');
 }
Example #2
0
 public function testExplode()
 {
     $expArr = array('a', 'b', 'c', 'd');
     $source = 'a,b , c, d';
     $this->assertEquals($expArr, AESHelper::explode($source));
     $expArr = array('a');
     $source = '  a  ';
     $this->assertEquals($expArr, AESHelper::explode($source));
     $expArr = array('a', 'b', 'c', 'd', 'e', 'f');
     $source = ' a b   c  d e f';
     $this->assertEquals($expArr, AESHelper::explode($source, ' '));
 }
Example #3
0
 protected function assertMandatesPresent($aliases)
 {
     $aliases = AESHelper::explode($aliases);
     $mandatesContSel = 'css=#mandates-feed-container items';
     $this->waitForPresent('css=div.mandate');
     $this->waitForNotVisible('css=img.loader');
     usleep(300000);
     $count = count($aliases);
     $this->assertCssCount('css=div.mandate', $count);
     $this->waitForNotVisible('css=#mandates-feed-container .nav img.loader');
     $this->waitForElementContainsText('css=#mandates-feed-container .nav a#items-count', 'Found ' . $count, 4000, 500);
     foreach ($aliases as $alias) {
         $this->assertMandatePresent($alias);
     }
 }
Example #4
0
echo $form->textFieldRow($model, 'remove_vote_time', array('class' => 'span6'));
echo $form->textFieldRow($model, 'revote_time', array('class' => 'span6'));
?>

<?php 
if (!$model->isNewRecord) {
    ?>

<h5 data-toggle="#status"><a name="status"></a>
    <?php 
    echo Yii::t('election', 'Status');
    ?>
</h5><hr>

<?php 
    echo $form->dropDownListRow($model, 'status', AESHelper::arrTranslated($model->getAvailableStatuses()), array('class' => 'span6'));
    ?>

<?php 
}
?>

<div class="form-actions">
    <?php 
$this->widget('bootstrap.widgets.TbButton', array('buttonType' => 'submit', 'type' => 'primary', 'label' => 'Save'));
?>
</div>

<?php 
$this->endWidget();
?>
Example #5
0
 public static function arrTranslatedValue($array, $index, $namespace = 'aes')
 {
     $translated = AESHelper::arrTranslated($array, $namespace);
     return $translated[$index];
 }
Example #6
0
if ($canManage) {
    ?>
            &nbsp;<small><a href="<?php 
    echo Yii::app()->createUrl('/election/management/', array('id' => $this->election->id, '#' => 'electorate-registration-options'));
    ?>
"><?php 
    echo Yii::t('election.provisions', 'Change');
    ?>
</a></small>
            <?php 
}
?>
        </h5>

        <?php 
$this->widget('bootstrap.widgets.TbDetailView', array('htmlOptions' => array('id' => 'electorate-registration-options'), 'type' => 'condensed', 'data' => $model, 'attributes' => array(array('name' => 'voter_group_restriction', 'value' => AESHelper::arrTranslatedValue(Election::$voter_group_restrictions, $model->voter_group_restriction, 'election')), array('name' => 'voter_reg_type', 'value' => AESHelper::arrTranslatedValue(Election::$voter_reg_types, $model->voter_reg_type, 'election')), array('name' => 'voter_reg_confirm', 'value' => AESHelper::arrTranslatedValue(Election::$voter_reg_confirms, $model->voter_reg_confirm, 'election')))));
?>
                

        <h5 data-toggle="#revote-options"><?php 
echo Yii::t('election.provisions', 'Revote options');
?>
            <?php 
if ($canManage) {
    ?>
            &nbsp;<small><a href="<?php 
    echo Yii::app()->createUrl('/election/management/', array('id' => $this->election->id, '#' => 'revote-options'));
    ?>
"><?php 
    echo Yii::t('election.provisions', 'Change');
    ?>
Example #7
0
 public function isElementHasClass($sel, $targetClass)
 {
     $class = $this->getAttribute($sel, 'class');
     if (!$class || $class === '') {
         return false;
     }
     $classes = AESHelper::explode($class, ' ');
     if (is_string($targetClass)) {
         $targetClasses = array($targetClass);
     } elseif (is_array($targetClass)) {
         $targetClasses = $targetClass;
     }
     foreach ($targetClasses as $targetClass) {
         if (!in_array($targetClass, $classes)) {
             return false;
         }
     }
     return true;
 }
Example #8
0
 public function getTypeAttributeNames()
 {
     $attrs = array();
     foreach ($this->getTypeRules() as $rule) {
         $currRuleAttrs = AESHelper::explode($rule[0]);
         foreach ($currRuleAttrs as $attr) {
             if (!in_array($attr, $attrs)) {
                 $attrs[] = $attr;
             }
         }
     }
     return $attrs;
 }
Example #9
0
        <div class="input-prepend">
            <label for="elect_search"><?php 
echo Yii::t('aes', 'Title');
?>
</label>
            <span class="add-on"><i class="icon-search"></i></span>
            <input type="text" id="elect_search" class="span3" maxlength="20" placeholder="<?php 
echo Yii::t('aes', 'Start typing part of the election&apos;s title');
?>
" name="elect_search" value="">
        </div>

        <label for="elect_status"><?php 
echo Yii::t('aes', 'Status');
?>
</label>
        <?php 
echo CHtml::dropDownList('elect_status', '', array_merge(array('' => Yii::t('aes', 'All')), AESHelper::arrTranslated(Election::$statuses)), array('id' => 'elect_status', 'class' => 'span2'));
?>

    </script>

    <script type="text/template" id="more-btn-tpl">
        <div class="row-fluid get-more">
            <div class="span12"><a id="a_more" href="#"><?php 
echo Yii::t('aes', 'More');
?>
</a><span>Loading...</span></div>
        </div>
    </script>
Example #10
0
 public function beforeAction($event)
 {
     $result = parent::beforeAction($event);
     //decode extjs filters format
     if (is_string($this->restFilter) && isset($_GET['extjs'])) {
         $this->restFilter = CJSON::decode($this->restFilter);
         //convert operators to accepted format by ERestHelperScopes
         foreach ($this->restFilter as $index => $filter) {
             if (isset($filter['operator'])) {
                 $this->restFilter[$index]['operator'] = $this->convertFilterOperator($filter['operator']);
             }
         }
     }
     if (ArrayHelper::isAssoc($this->restFilter)) {
         //Conversion needed
         if (!empty($this->acceptFilters['plain'])) {
             $plainKeys = AESHelper::explode($this->acceptFilters['plain']);
             foreach ($plainKeys as $key) {
                 if (isset($this->restFilter[$key])) {
                     $this->plainFilter[$key] = $this->restFilter[$key];
                 }
             }
         } else {
             //copy all to plainFilter
             foreach ($this->restFilter as $key => $value) {
                 $this->plainFilter[$key] = $value;
             }
         }
         if (!empty($this->acceptFilters['model'])) {
             $acceptableKeys = AESHelper::explode($this->acceptFilters['model']);
             foreach ($this->restFilter as $key => $value) {
                 if (!in_array($key, $acceptableKeys)) {
                     unset($this->restFilter[$key]);
                 } elseif ($value == '') {
                     $this->restFilter[$key] = null;
                 }
             }
         }
         if ($this->convertRestFilters) {
             //Convert filters to acceptable format
             $convertedFilter = array();
             foreach ($this->restFilter as $filterName => $value) {
                 if (!is_array($value) || !key_exists('property', $value) && !key_exists('value', $value)) {
                     $convertedFilter[] = array('property' => $filterName, 'value' => $value);
                 } else {
                     $convertedFilter[] = $value;
                 }
             }
             $this->restFilter = $convertedFilter;
         }
     } else {
         //Filters are in acceptable format
         $plainKeys = array();
         $filterableModelKeys = array();
         if (!empty($this->acceptFilters['plain'])) {
             $plainKeys = AESHelper::explode($this->acceptFilters['plain']);
         }
         if (!empty($this->acceptFilters['model'])) {
             $filterableModelKeys = AESHelper::explode($this->acceptFilters['model']);
         }
         $checkPlain = (bool) count($plainKeys);
         $checkModel = (bool) count($filterableModelKeys);
         if ($checkModel || $checkPlain) {
             foreach ($this->restFilter as $index => $filter) {
                 $filterKey = $filter['property'];
                 if ($checkPlain && in_array($filterKey, $plainKeys)) {
                     $this->plainFilter[$filterKey] = $filter['value'];
                 }
                 if ($checkModel && !in_array($filterKey, $filterableModelKeys)) {
                     unset($this->restFilter[$index]);
                 }
             }
         }
     }
     return $result;
 }