Beispiel #1
0
 /**
  * @param	string	$source			Name of foreign source (ex., "people")
  * @param	array	$constraints	Array of key/value constraints (ex., "id" => 1)
  * @return	array
  */
 protected function getForeignRecord($source, array $constraints = [])
 {
     // @todo	Cache foreign records instead of reading off disk every time
     $sourceForeign = $this->source->parent()->child("{$source}.json");
     $dataForeign = new Data($sourceForeign);
     return $dataForeign->getRecords($constraints);
 }
 public function indexAction()
 {
     // Get, check and setup the parameters
     if (!($widget_id = $this->getRequest()->getParam("id"))) {
         throw new Stuffpress_Exception("No widget id provided to the widget controller");
     }
     // Verify if the requested widget exist and get its data
     $widgets = new Widgets();
     if (!($widget = $widgets->getWidget($widget_id))) {
         throw new Stuffpress_Exception("Invalid widget id");
     }
     // Get the last comments
     $comments = new Comments(array(Stuffpress_Db_Table::USER => $widget['user_id']));
     $mycomments = $comments->getLastComments();
     $data = new Data();
     // Prepare the comments for output
     foreach ($mycomments as &$comment) {
         $time = strtotime($comment['timestamp']);
         $item = $data->getItem($comment['source_id'], $comment['item_id']);
         $comment['item'] = $item;
         $comment['when'] = Stuffpress_Date::ago($time, "j M y");
         $comment['comment'] = str_replace("\n", " ", $comment['comment']);
         if (strlen($comment['comment']) > 50) {
             $comment['comment'] = mb_substr($comment['comment'], 0, 47) . "...";
         }
     }
     // Get the widget properties
     $properties = new WidgetsProperties(array(Properties::KEY => $widget_id));
     $title = $properties->getProperty('title');
     $this->view->title = $title ? $title : "Latest comments";
     // Prepare the view for rendering
     $this->view->comments = $mycomments;
 }
Beispiel #3
0
 /**
  * 
  * @param \petry\database\Data $data
  * @param type $operator
  * @return \petry\database\Update
  */
 protected function setWhere(Data $data, $operator = 'AND')
 {
     $op = is_null($this->where) ? ' WHERE' : ' ' . $operator . ' ';
     $this->where .= $op . ' ' . $data->getVariable() . $data->getOperator() . ' :' . $data->getVariable();
     $this->whereBindValue[] = $data;
     return $this;
 }
Beispiel #4
0
 /**
  * @param $parts
  * @param $value
  * @return Data
  */
 public static function build($parts, $value)
 {
     $data = new Data();
     $data->setPath($parts);
     $data->setValue($value);
     return $data;
 }
Beispiel #5
0
 /**
  * test for getActualHandles function
  */
 public function testGetActualHandles()
 {
     $this->prepareMocks();
     $layoutHandles = ['handle1', 'config_layout_handle1', 'handle2'];
     $this->updateLayoutMock->expects($this->once())->method('getHandles')->will($this->returnValue($layoutHandles));
     $this->assertEquals($layoutHandles, $this->helper->getActualHandles());
 }
Beispiel #6
0
    function watch()
    {
        $returnStr = $this->showHeader(Language::messageSMSTitle());
        $returnStr .= $this->displayComboBox();
        $returnStr .= "<form method='post'>";
        $params = getSessionParams();
        //$params['reportpage'] = 'reportRes';
        $returnStr .= setSessionParamsPost($params);
        $returnStr .= '<div id="wrap">';
        $returnStr .= '<div class="container"><p>';
        $returnStr .= '<div class="panel panel-default">
                <div class="panel-heading">';
        $returnStr .= '<h4>' . Language::linkWatch() . '</h4>';
        $returnStr .= '                </div>
                <div class="panel-body">';
        require_once 'data.php';
        require_once 'display.php';
        $data = new Data();
        $values = $data->getRespondentData(getFromSessionParams('watchsuid'), getFromSessionParams('watchprimkey'));
        $returnStr .= '</div>
    <div role="panel" class="panel">';
        if (sizeof($values) == 0) {
            $returnStr .= "<br/>" . '<div class="alert alert-warning">' . Language::labelWatchNoData() . '</div>';
        } else {
            $returnStr .= $this->displayDataTablesScripts(array("colvis", "rowreorder"));
            $returnStr .= "<script type='text/javascript'>\n                        \$(document).ready(function(){\n                            \$('#issuetable').dataTable(\n                                {\n                                    \"iDisplayLength\": 5,\n                                    dom: 'C<\"clear\">lfrtip',\n                                    searching: false,\n                                    paging: true\n                                    }    \n                                );\n                                         \n                       });</script>\n\n                        ";
            //
            $returnStr .= "<br/><table id='issuetable' class='table table-bordered table-striped'><thead>";
            $returnStr .= "<th>" . Language::labelWatchVariable() . "</th><th>" . Language::labelWatchValue() . "</th><th>" . Language::labelWatchClean() . "</th><th>" . Language::labelWatchMode() . "</th><th>" . Language::labelWatchLanguage() . "</th><th>" . Language::labelWatchTime() . "</th></tr>";
            $returnStr .= "</thead><tbody>";
            $modes = Common::surveyModes();
            $languages = Language::getLanguagesArray();
            $sesid = session_id();
            require_once 'object.php';
            require_once 'component.php';
            require_once 'setting.php';
            require_once 'type.php';
            require_once 'variabledescriptive.php';
            $survey = new Survey(getFromSessionParams('watchsuid'));
            foreach ($values as $is) {
                $returnStr .= "<tr>";
                $returnStr .= "<td>" . $is["variablename"] . "</td>";
                $returnStr .= "<td>" . $this->getDisplayValue($survey->getVariableDescriptiveByName($is["variablename"]), $is["answer_dec"]) . "</td>";
                $returnStr .= "<td>" . $this->displayDirty([$is["dirty"]]) . "</td>";
                $returnStr .= "<td>" . $modes[$is["mode"]] . "</td>";
                $returnStr .= "<td>" . $languages[str_replace("_", "", getSurveyLanguagePostFix($is["language"]))]['name'] . "</td>";
                $returnStr .= "<td>" . $is["ts"] . "</td>";
                $returnStr .= "</tr>";
            }
            $returnStr .= "</tbody></table>";
        }
        $returnStr .= '</div>
  </div>
</div>';
        $returnStr .= '                </div></div>';
        $returnStr .= '</p></div>    </div>';
        //container and wrap
        $returnStr .= $this->showFooter(false);
        echo $returnStr;
    }
 public function formatData()
 {
     // The file "pb_proto_person.php" was created with the following code:
     // require_once(dirname(__FILE__) . '/../libs/protocolbuf/parser/pb_parser.php');
     // $filename = dirname(__FILE__) . '/person.proto';
     // $parser = new PBParser();
     // $parser->parse($filename);
     $array = new Data();
     $data = $this->getData();
     while ($entry = $data->next()) {
         $person = $array->add_person();
         $person->set_entryId(intval($entry['id']));
         $person->set_firstName($entry['first_name']);
         $person->set_lastName($entry['last_name']);
         $person->set_phone($entry['phone']);
         $person->set_email($entry['email']);
         $person->set_address($entry['address']);
         $person->set_city($entry['city']);
         $person->set_zip($entry['zip']);
         $person->set_state($entry['state']);
         $person->set_country($entry['country']);
         $person->set_description($entry['description']);
         $person->set_password($entry['password']);
         $person->set_createdOn($entry['created_on']);
         $person->set_modifiedOn($entry['modified_on']);
     }
     return $array->SerializeToString();
 }
Beispiel #8
0
 public static function table($name)
 {
     $file = new Data();
     $file->name = $name;
     $file->setType('data');
     return $file;
 }
 /**
  * @return void
  */
 public function testPerform()
 {
     $data = new Data($this->progress, $this->source, $this->destination, $this->recordFactory, $this->helper);
     $this->assertTrue($data->perform());
     foreach ($this->destinationDocuments as $documentName => $recordsCount) {
         $this->assertEquals($recordsCount, count($this->destination->getRecords($documentName, 0)));
     }
 }
Beispiel #10
0
 public function testGetProductPrice()
 {
     $productId = 1;
     $productPrice = ['pricing' => 'test'];
     $priceData = new Data();
     $priceData->setProductPrice($productId, $productPrice);
     $this->assertEquals($productPrice, $priceData->getProductPrice($productId));
 }
Beispiel #11
0
 public function waw2Data()
 {
     $Data = new Data();
     $w2 = $this->dateFormat($Data->getWaw2());
     $day = substr($w2, 0, 2);
     $day2 = (int) $day + 1;
     $w2 = $day . "-" . $day2 . substr($w2, 2);
     return $w2;
 }
 public static function linkEdit(Data $data, $textLink)
 {
     $baseUrl = LinkController::getBaseURL();
     $idData = $data->getId();
     $link = "<a href='{$baseUrl}/admin/datacenter/dado/edit/{$idData}'>";
     $link .= $textLink;
     $link .= "</a>";
     echo $link;
 }
Beispiel #13
0
 public function checkNumData($agency_code, $data_id)
 {
     $data_obj = new Data();
     $arr_data[] = $data_id;
     $data_info = $data_obj->getDataInfo($arr_data);
     $table_name = $data_info[0]->table_name;
     list($table, $field, $datefield) = explode("-", $table_name);
     $rs = DB::connection('nhc_data')->table($table)->where('agency_id', '=', $agency_code)->count();
     return $rs;
 }
Beispiel #14
0
function rearr($array)
{
    arrayRecursive($array, 'urlencode', true);
    $data = new Data();
    $data->setData($array);
    $data->setMd5(md5(urldecode(json_encode($array))));
    $_SESSION['token'] = md5(time());
    $data->setToken($_SESSION['token']);
    echo urldecode(json_encode($data));
}
 public function dashboard()
 {
     if (Auth::is_valid()) {
         $data = new Data();
         $carpeta = new Carpeta();
         $this->data = $data->find();
         $this->carpetas = $carpeta->get_nombre_carpetas_by_user_id(Auth::get("id"));
         $this->obj_carpeta_data = new CarpetaData();
     }
 }
 public function table1Action()
 {
     $this->view->disable();
     if ($this->request->isAjax() == true) {
         $response = new \Phalcon\Http\Response();
         $response->setContentType('application/json', 'UTF-8');
         $db_data = new Data();
         $response->setContent($db_data->get_table_data_json($this->request->getPost(), $this->config->table_1->toArray()));
         return $response;
     }
 }
 /**
  * @test
  */
 public function turnDataToJson()
 {
     $subgroup = new Subgroup("subgrupo");
     $font = new Font("fonte");
     $type = new CoffeType("type");
     $variety = new Variety("variety", 1);
     $origin = new Country("origin");
     $destiny = new Country("destiny");
     $data = new Data(1990, $subgroup, $font, $type, $variety, $origin, $destiny);
     $this->assertEquals($this->jsonExpected(), $data->toJson());
 }
Beispiel #18
0
function editpost_post()
{
    $Data = new Data();
    if (trim(post('body')) == "") {
        print "You must enter a post body.";
    } else {
        if (!$Data->thread_post_update($_POST, id())) {
            print "Your thread was not submitted.";
        }
    }
    exit_clean();
}
Beispiel #19
0
function reply_post()
{
    $Data = new Data();
    if (trim(post('body')) == "") {
        print "You must enter a post body.";
    } else {
        if (!$Data->thread_post_insert($_POST)) {
            print "Your post was not submitted.";
        }
    }
    exit_clean();
}
Beispiel #20
0
 public function deleteComment($id)
 {
     if (!($comment = $this->getComment($id))) {
         return;
     }
     // Decrease the counter
     $data = new Data();
     $data->decreaseComments($comment->source_id, $comment->item_id);
     // Delete the comment
     $where = $this->getAdapter()->quoteInto('id = ?', $id);
     $this->delete($where);
 }
Beispiel #21
0
 /**
  * 自动给给定集合创建索引
  *
  * @param string $collection_id            
  *
  */
 public function autoCreateIndexes($collection_id)
 {
     $cursor = $this->find(array('collection_id' => $collection_id));
     $dataCollection = new Data($this->config);
     $dataCollection->setCollection(iCollectionName($collection_id));
     while ($cursor->hasNext()) {
         $index = $cursor->getNext();
         $keys = Json::decode($index['keys'], Json::TYPE_ARRAY);
         $dataCollection->ensureIndex($keys, array('background' => true));
     }
     return true;
 }
Beispiel #22
0
 /**
  * @param $type
  * @param $amount
  * @param $exception
  * @param $additionalMessage
  * @param $expected
  * @dataProvider getMessagesParamDataProvider
  */
 public function testGetTransactionMessage($type, $amount, $exception, $additionalMessage, $expected)
 {
     $currency = $this->getMock('Magento\\Directory\\Model\\Currency', ['formatTxt', '__wakeup'], [], '', false);
     $currency->expects($this->any())->method('formatTxt')->will($this->returnValue($amount));
     $order = $this->getMock('Magento\\Sales\\Model\\Order', ['getBaseCurrency', '__wakeup'], [], '', false);
     $order->expects($this->any())->method('getBaseCurrency')->will($this->returnValue($currency));
     $payment = $this->getMock('Magento\\Payment\\Model\\Info', ['getOrder', '__wakeup'], [], '', false);
     $payment->expects($this->any())->method('getOrder')->will($this->returnValue($order));
     $card = new \Magento\Framework\Object(['cc_last4' => self::LAST4]);
     $message = $this->_model->getTransactionMessage($payment, $type, self::TRID, $card, $amount, $exception, $additionalMessage);
     $this->assertEquals($expected, $message);
 }
Beispiel #23
0
 public function afterSave()
 {
     parent::afterSave();
     if (count($this->data) == 0) {
         foreach (Sector::model()->findAll() as $sector) {
             $data = new Data();
             $data->metric_id = $this->id;
             $data->sector_id = $sector->id;
             $data->save();
         }
     }
 }
 protected function setProperties(ArrayObject $group, Data $data, array $years)
 {
     $this->json .= '{';
     $this->json .= '"variety":"' . $data->getVarietyName() . '",';
     $this->json .= '"type":"' . $data->getTypeName() . '",';
     $this->json .= '"origin":"' . utf8_decode($data->getOriginName()) . '",';
     $this->json .= '"destiny":"' . utf8_decode($data->getDestinyName()) . '",';
     $this->json .= '"font":"' . utf8_decode($data->getFontName()) . '",';
     $this->json .= '"values":';
     $this->listValues($group, $years);
     $this->json .= '},';
 }
Beispiel #25
0
 public function get($cols = null)
 {
     if (empty($this->table)) {
         $this->table = static::$db_tablename;
     }
     $res = parent::get($cols);
     $out = new Data();
     foreach ($res as $row) {
         $out->append(static::find($row->{static::$db_idcolumn}));
     }
     return $out;
 }
 /**
  * @return void
  */
 public function testPerform()
 {
     $this->data = new Data($this->destination, $this->progress);
     $this->progress->expects($this->once())->method('start')->with(1);
     $this->progress->expects($this->once())->method('advance');
     $this->progress->expects($this->once())->method('finish');
     $this->destination->expects($this->once())->method('getAdapter')->willReturn($this->adapter);
     $this->adapter->expects($this->once())->method('getSelect')->willReturn($this->select);
     $this->select->expects($this->once())->method('from')->with('rating_store', ['rating_id'])->will($this->returnSelf());
     $this->select->expects($this->once())->method('where')->with('store_id > 0')->will($this->returnSelf());
     $this->adapter->expects($this->once())->method('loadDataFromSelect')->with($this->select)->willReturn([['rating_id' => 1]]);
     $this->adapter->expects($this->once())->method('updateDocument')->with('rating', ['is_active' => 1], 'rating_id IN (1)');
     $this->data->perform();
 }
 public function createHTMLToVote()
 {
     $_oData = new Data();
     $_aAllPosts = $_oData->getAllPosts();
     $_sHTML = "<div class='main'>\n                        <ul id='og-grid' class='og-grid'>";
     foreach ($_aAllPosts as $_oPost) {
         if ($_oPost) {
             $_aImg = wp_get_attachment_image_src(get_post_thumbnail_id($_oPost->ID));
             $_sHTML .= "<li>\n                                <a href='" . get_permalink($_oPost->ID) . "' id='" . $_oPost->ID . "' data-largesrc='" . $_aImg[0] . "' data-title='" . get_the_title($_oPost->ID) . "' data-description='" . get_post_field('post_content', $_oPost->ID) . "'>\n                                    " . get_the_post_thumbnail($_oPost->ID, 'thumbnail') . "\n                                </a>\n                            </li>";
         }
     }
     $_sHTML .= "    </ul>\n                    </div>";
     return $_sHTML;
 }
Beispiel #28
0
function alter_data()
{
    $data = new Data($_POST["email"]);
    $data->setIdentifiant($_POST["identifiant"]);
    $data->setNomFils($_POST["nom_fils"]);
    $data->setPrenomFils($_POST["prenom_fils"]);
    $data->setDdnFils($_POST["ddn_fils"]);
    $data->setTelMobile($_POST["tel_mobile"]);
    $data->setDate($_POST["date"]);
    $data->setIp($_POST["ip"]);
    $data->write();
}
Beispiel #29
0
 /**
  * [agencyDataFormAdd description]
  * @return [type] [description]
  */
 public function agencyDataFormAdd()
 {
     $data = Data::All();
     $agency = new Agency();
     $rs_agency = $agency->getAllAgency();
     return View::make('agency.add_agency_data')->with('data', $data)->with('agency', $rs_agency);
 }
 /**
  * @param array $retorno - XML de resposta convertido em array
  */
 function __construct($retorno)
 {
     if (isset($retorno['root'])) {
         $root = $retorno['root'];
         $this->codigo = $root['codret'];
         $this->mensagem = $root['msgret'];
         if ($this->getCodigo() != 0) {
             throw new Exception($this->getMensagem());
         }
         $this->row_count = $root['resumoVendas']['@attributes']['row_count'];
         $resumo = $root['resumoVendas']['rv'];
         $atributos = $resumo['@attributes'];
         $this->dataResumo = $atributos['dt_rv'];
         $this->qtdVendas = $atributos['qtd_cv'];
         $this->valorTotal = $atributos['val_totl_pago'];
         $this->valorLiquido = $atributos['val_totl_lqdo'];
         //$this->nu_rv        = $atributos['nu_rv'];
         //$this->text         = $atributos['text'];
     }
     if (isset($retorno['HEADER'])) {
         $header = $retorno['HEADER'];
         $this->dataRequisicao = Data::stringParaData($header['DATA_REQUISICAO']);
         $this->horaRequisicao = Data::stringParaHora($header['HORA_REQUISICAO']);
         $this->filiacao = $header['FILIACAO'];
     }
 }