Example #1
0
 protected function renderIndex()
 {
     $data['schema'] = $this->model->schema;
     $data['primary'] = $this->model->primary;
     //$this->
     $where = [];
     $grid['filter'] = isset($this->grid['filter']) ? $this->grid['filter'] : [];
     foreach ($grid['filter'] as $key => $value) {
         if ($this->input->get($key)) {
             $where[$key] = $this->input->get($key);
         }
     }
     $grid['page'] = isset($this->grid['page']) ? $this->grid['page'] : (intval($this->input->get('page')) ? intval($this->input->get('page')) : 1);
     $grid['pageSize'] = isset($this->grid['pageSize']) ? $this->grid['pageSize'] : 12;
     $grid['total'] = isset($this->grid['total']) ? $this->grid['total'] : $this->model->count($where);
     $grid['fields'] = isset($this->grid['fields']) ? $this->grid['fields'] : array_keys($this->model->schema);
     $grid['fieldshow'] = isset($this->grid['fieldshow']) ? $this->grid['fieldshow'] : null;
     $grid['datasource'] = isset($this->grid['page']) ? $this->grid['datasource'] : $this->model->query($where, $grid['fields'], [$this->model->primary => 'desc'], [$grid['pageSize'] * ($grid['page'] - 1), $grid['pageSize']]);
     $grid['pager'] = isset($this->grid['pager']) ? $this->grid['pager'] : $this->helper->backstage->paging($grid['pageSize'], $grid['total'], $grid['page'], $this->helper->backstage->uri(['page' => '']));
     $grid['tools'] = isset($this->grid['tools']) ? $this->grid['tools'] : ['add' => $this->helper->form->button(['properties' => ['id' => 'add', 'onclick' => 'edit()'], 'label' => '增加'])];
     $grid['operations'] = isset($this->grid['operations']) ? $this->grid['operations'] : [['name' => '操作', 'action' => function ($record) {
         return '<a href="javascript:del(' . $record->id . ')">删除</a> | <a href="javascript:update(' . $record->id . ')">修改</a>';
     }]];
     $data['grid'] = $grid;
     $this->output->view('common/index', $data);
 }
Example #2
0
 /**
  * Unset a parent.
  *
  * @param  pbject $parent The parent instance to unset.
  * @return self
  */
 public function removeParent($parent)
 {
     $this->_parents->remove($parent);
     if ($this->_parents->count() === 0) {
         $this->collector()->remove($this->uuid());
     }
     return $this;
 }
Example #3
0
 /**
  * hasTickets - check if there are Tickets related to a project
  *
  * @access public
  * @param $id
  * @return boolean
  */
 public function hasTickets($id)
 {
     $query = "SELECT id FROM zp_tickets WHERE projectId = '" . $id . "' LIMIT 1";
     $this->db->dbQuery($query);
     if ($this->db->count() == 0) {
         return false;
     } else {
         return true;
     }
 }
Example #4
0
 /**
  * hasTickets - check if a project has Tickets
  *
  * @access public
  * @param $id
  * @return boolean
  */
 public function hasTickets($id)
 {
     $query = "SELECT zp_projects.id FROM zp_projects JOIN zp_tickets ON zp_projects.id = zp_tickets.projectId WHERE zp_projects.clientId = '" . $id . "'";
     $this->db->dbQuery($query);
     if ($this->db->count() == 0) {
         return false;
     } else {
         return true;
     }
 }
 /**
  * parseAlbums function.
  *
  * @access private
  * @return void
  */
 private function parseAlbums()
 {
     if (!is_object($this->objAlbums) || $this->objAlbums->count() < 1) {
         $this->setEmptyTemplate($GLOBALS['TL_LANG']['MSC']['albumsNotFound']);
         return;
     }
     // Import
     $this->import('Session');
     // Define vars
     global $objPage;
     $arrItems = array();
     $objAlbums = $this->objAlbums;
     $total = $objAlbums->count();
     $i = 0;
     // Set page session vars to generate backlink in detail page
     $this->Session->set('pa2PageNumber_' . $this->Template->id, \Input::get('page') ? \Input::get('page') : 1);
     $this->Session->set('pa2PageId_' . $this->Template->id, $objPage->id);
     if ($objAlbums !== null) {
         while ($objAlbums->next()) {
             // Generate subtemplate object
             $objSubtemplate = new \FrontendTemplate($this->Template->strSubtemplate);
             $objSubtemplate->setData($this->Template->getData());
             // Set template variables
             $objSubtemplate->title = strip_tags($objAlbums->title);
             $objSubtemplate->alt = strip_tags($objAlbums->title);
             $objSubtemplate->showTitle = $objSubtemplate->title != '' ? $objSubtemplate->showTitle : false;
             $objSubtemplate->event = $objAlbums->event;
             $objSubtemplate->place = $objAlbums->place;
             $objSubtemplate->photographer = $objAlbums->photographer;
             $objSubtemplate->description = $objAlbums->description;
             $objSubtemplate->numberOfAllImages = count($objAlbums->arrSortedImageUuids);
             // Call template methods
             $objSubtemplate = $this->addDateToTemplate($objSubtemplate, $objAlbums->startdate, $objAlbums->enddate);
             $objSubtemplate = $this->addSpecificClassesToTemplate($objSubtemplate, $i);
             $objSubtemplate = $this->addLinkToTemplate($objSubtemplate, $objAlbums->current());
             $objSubtemplate = $this->addMetaFieldsToTemplate($objSubtemplate);
             // Add preview image to template
             $objPa2PreviewImage = new \Pa2PreviewImage($objAlbums->current(), $objSubtemplate->pa2PreviewImage);
             $objPa2Image = new \Pa2Image($objPa2PreviewImage->getPreviewImageUuid());
             $objPa2Image->addPa2ImageToTemplate($objSubtemplate);
             // Add album class to the class string
             $objSubtemplate->class .= $objSubtemplate->class == '' ? $objAlbums->cssClass : ' ' . $objAlbums->cssClass;
             // If album lightbox is activated the images will be added to the album template
             $objSubtemplate = $this->albumLightbox($objSubtemplate, $objAlbums->current());
             // Parse subtemplate
             $arrItems[] = $objSubtemplate->parse();
             $i++;
         }
     }
     $this->Template->items = $arrItems;
 }
 public function get_venues($per_page = 10, $count = FALSE)
 {
     $_orderby = !empty($this->_req_data['orderby']) ? $this->_req_data['orderby'] : '';
     switch ($_orderby) {
         case 'id':
             $orderby = 'VNU_ID';
             break;
         case 'capacity':
             $orderby = 'VNU_capacity';
             break;
         case 'city':
             $orderby = 'VNU_city';
             break;
         default:
             $orderby = 'VNU_name';
     }
     $sort = isset($this->_req_data['order']) && !empty($this->_req_data['order']) ? $this->_req_data['order'] : 'ASC';
     $current_page = isset($this->_req_data['paged']) && !empty($this->_req_data['paged']) ? $this->_req_data['paged'] : 1;
     $per_page = isset($per_page) && !empty($per_page) ? $per_page : 10;
     $per_page = isset($this->_req_data['perpage']) && !empty($this->_req_data['perpage']) ? $this->_req_data['perpage'] : $per_page;
     $offset = ($current_page - 1) * $per_page;
     $limit = array($offset, $per_page);
     $category = isset($this->_req_data['category']) && $this->_req_data['category'] > 0 ? $this->_req_data['category'] : NULL;
     $where = array();
     //only set initial status if it is in the incoming request.  Otherwise the "all" view display's all statuses.
     if (isset($this->_req_data['status']) && $this->_req_data['status'] != 'all') {
         $where['status'] = $this->_req_data['status'];
     }
     if (isset($this->_req_data['venue_status'])) {
         $where['status'] = $this->_req_data['venue_status'];
     }
     if ($category) {
         $where['Term_Taxonomy.taxonomy'] = 'espresso_venue_categories';
         $where['Term_Taxonomy.term_id'] = $category;
     }
     if (!EE_Registry::instance()->CAP->current_user_can('ee_read_others_venues', 'get_venues')) {
         $where['VNU_wp_user'] = get_current_user_id();
     } else {
         if (!EE_Registry::instance()->CAP->current_user_can('ee_read_private_venues', 'get_venues')) {
             $where['OR'] = array('status*restrict_private' => array('!=', 'private'), 'AND' => array('status*inclusive' => array('=', 'private'), 'VNU_wp_user' => get_current_user_id()));
         }
     }
     if (isset($this->_req_data['s'])) {
         $sstr = '%' . $this->_req_data['s'] . '%';
         $where['OR'] = array('VNU_name' => array('LIKE', $sstr), 'VNU_desc' => array('LIKE', $sstr), 'VNU_short_desc' => array('LIKE', $sstr), 'VNU_address' => array('LIKE', $sstr), 'VNU_address2' => array('LIKE', $sstr), 'VNU_city' => array('LIKE', $sstr), 'VNU_zip' => array('LIKE', $sstr), 'VNU_phone' => array('LIKE', $sstr), 'VNU_url' => array('LIKE', $sstr), 'VNU_virtual_phone' => array('LIKE', $sstr), 'VNU_virtual_url' => array('LIKE', $sstr), 'VNU_google_map_link' => array('LIKE', $sstr), 'Event.EVT_name' => array('LIKE', $sstr), 'Event.EVT_desc' => array('LIKE', $sstr), 'Event.EVT_phone' => array('LIKE', $sstr), 'Event.EVT_external_URL' => array('LIKE', $sstr));
     }
     $venues = $count ? $this->_venue_model->count(array($where), 'VNU_ID') : $this->_venue_model->get_all(array($where, 'limit' => $limit, 'order_by' => $orderby, 'order' => $sort));
     return $venues;
 }
 /**
  * Encode the result set into a collection of models
  * @param  object   $resultSet         The result set to hydrate with
  * @param  object   $modelToHydrate    The model to hydrate
  * @return boolean|\Application\Model\BlogPost
  */
 public function encode($resultSet, $modelToHydrate)
 {
     $collection = array();
     if ($resultSet->count() == 0) {
         return false;
     }
     foreach ($resultSet as $row) {
         foreach ($this->fields as $key => $value) {
             if (isset($row[$value])) {
                 $row[$key] = $row[$value];
             }
         }
         array_push($collection, new $modelToHydrate($row));
     }
     return $collection;
 }
Example #8
0
 /**
  * Load Page Version
  *
  * @param   mixed  $vid Version Id
  * @return  object \Components\Groups\Models\Page\Version
  */
 public function version($vid = null)
 {
     // var to hold version
     $version = new Page\Version();
     // make sure we have versions to return
     if ($this->_versions->count() > 0) {
         // return version object
         if ($vid == null || $vid == 0 || $vid == 'current') {
             $version = $this->_versions->first();
         } else {
             if (is_numeric($vid)) {
                 $version = $this->_versions->fetch('version', $vid);
             }
         }
     }
     //return version
     return $version;
 }
 public function get_venues($per_page = 10, $count = FALSE)
 {
     $_orderby = !empty($this->_req_data['orderby']) ? $this->_req_data['orderby'] : '';
     switch ($_orderby) {
         case 'id':
             $orderby = 'VNU_ID';
             break;
         case 'capacity':
             $orderby = 'VNU_capacity';
             break;
         case 'city':
             $orderby = 'VNU_city';
             break;
         default:
             $orderby = 'VNU_name';
     }
     $sort = isset($this->_req_data['order']) && !empty($this->_req_data['order']) ? $this->_req_data['order'] : 'ASC';
     $current_page = isset($this->_req_data['paged']) && !empty($this->_req_data['paged']) ? $this->_req_data['paged'] : 1;
     $per_page = isset($per_page) && !empty($per_page) ? $per_page : 10;
     $per_page = isset($this->_req_data['perpage']) && !empty($this->_req_data['perpage']) ? $this->_req_data['perpage'] : $per_page;
     $offset = ($current_page - 1) * $per_page;
     $limit = array($offset, $per_page);
     $category = isset($this->_req_data['category']) && $this->_req_data['category'] > 0 ? $this->_req_data['category'] : NULL;
     $where = array('status' => isset($this->_req_data['status']) && $this->_req_data['status'] != 'all' ? $this->_req_data['status'] : array('IN', array('publish', 'draft')));
     if ($category) {
         $where['Term_Taxonomy.taxonomy'] = 'espresso_venue_categories';
         $where['Term_Taxonomy.term_id'] = $category;
     }
     //cap checks
     if (EE_Registry::instance()->CAP->current_user_can('ee_edit_private_venues', 'get_venue')) {
         if (!empty($where['status'][0]) && $where['status'][0] == 'IN') {
             $where['status'][1][] = 'private';
         }
     }
     if (!EE_Registry::instance()->CAP->current_user_can('ee_read_others_venues', 'get_venues')) {
         $where['VNU_wp_user'] = get_current_user_id();
     }
     if (isset($this->_req_data['s'])) {
         $sstr = '%' . $this->_req_data['s'] . '%';
         $where['OR'] = array('VNU_name' => array('LIKE', $sstr), 'VNU_desc' => array('LIKE', $sstr), 'VNU_short_desc' => array('LIKE', $sstr), 'VNU_address' => array('LIKE', $sstr), 'VNU_address2' => array('LIKE', $sstr), 'VNU_city' => array('LIKE', $sstr), 'VNU_zip' => array('LIKE', $sstr), 'VNU_phone' => array('LIKE', $sstr), 'VNU_url' => array('LIKE', $sstr), 'VNU_virtual_phone' => array('LIKE', $sstr), 'VNU_virtual_url' => array('LIKE', $sstr), 'VNU_google_map_link' => array('LIKE', $sstr), 'Event.EVT_name' => array('LIKE', $sstr), 'Event.EVT_desc' => array('LIKE', $sstr), 'Event.EVT_phone' => array('LIKE', $sstr), 'Event.EVT_external_URL' => array('LIKE', $sstr));
     }
     $venues = $count ? $this->_venue_model->count(array($where), 'VNU_ID') : $this->_venue_model->get_all(array($where, 'limit' => $limit, 'order_by' => $orderby, 'order' => $sort));
     return $venues;
 }
 /**
  * Generate HTML string of form input controls
  *
  * @param string $details
  * @return void
  * @author Drew McLellan
  */
 public function render_inputs($details = array())
 {
     $s = '';
     $id = $this->Tag->id();
     $attrs = array();
     if ($this->Tag->placeholder()) {
         $attrs[] = 'placeholder="' . PerchUtil::html($this->Tag->placeholder(), true) . '"';
     }
     if ($this->Tag->count()) {
         if ($this->Tag->count() == 'chars') {
             $attrs[] = 'data-count="chars"';
         }
         if ($this->Tag->count() == 'words') {
             $attrs[] = 'data-count="words"';
         }
         $attrs[] = 'data-count-container="' . $this->Tag->input_id() . '__count"';
     }
     $attrs = implode(' ', $attrs);
     $s = $this->Form->text($this->Tag->input_id(), $this->Form->get($details, $id, $this->Tag->default(), $this->Tag->post_prefix()), $this->Tag->size(), $this->Tag->maxlength(), 'text', $attrs . $this->Tag->get_data_attribute_string());
     if ($this->Tag->count()) {
         $s .= '<div class="counter text-counter" id="' . $this->Tag->input_id() . '__count"></div>';
     }
     return $s;
 }
Example #11
0
 /**
  * Countable implementation
  *
  * @return int number of documents
  */
 public function count()
 {
     return $this->result->count();
 }
Example #12
0
 /**
  * Render an object to a string
  * 
  * @param Wire|object $value
  * @return string
  * 
  */
 protected function objectToString($value)
 {
     if ($value instanceof WireArray && !$value->count()) {
         return '';
     }
     if ($value instanceof Page) {
         return $value->get('title|name');
     }
     if ($value instanceof Pagefiles || $value instanceof Pagefile) {
         $out = $this->renderInputfieldValue($value);
     } else {
         $className = get_class($value);
         $out = (string) $value;
         if ($out === $className) {
             // just the class name probably isn't useful here, see if we can do do something else with it
             $this->renderIsUseless = true;
         }
     }
     return $out;
 }
Example #13
0
 /**
  * Searches for current article in article list and sets previous/next product ids
  *
  * @param oxarticle $oArticle       current Article
  * @param object    $oIdList        articles list containing only fake article objects !!!
  * @param oxubase   $oLocatorTarget oxubase object
  *
  * @return integer
  */
 protected function _getProductPos($oArticle, $oIdList, $oLocatorTarget)
 {
     $iCnt = 1;
     $iPos = 0;
     // variant handling
     $sOxid = $oArticle->oxarticles__oxparentid->value ? $oArticle->oxarticles__oxparentid->value : $oArticle->getId();
     if ($oIdList->count() && isset($oIdList[$sOxid])) {
         $aIds = $oIdList->arrayKeys();
         $iPos = oxRegistry::getUtils()->arrayStringSearch($sOxid, $aIds);
         if (array_key_exists($iPos - 1, $aIds)) {
             $oBackProduct = oxNew('oxArticle');
             $oBackProduct->modifyCacheKey('_locator');
             $oBackProduct->setNoVariantLoading(true);
             if ($oBackProduct->load($aIds[$iPos - 1])) {
                 $oBackProduct->setLinkType($oLocatorTarget->getLinkType());
                 $this->_oBackProduct = $oBackProduct;
             }
         }
         if (array_key_exists($iPos + 1, $aIds)) {
             $oNextProduct = oxNew('oxArticle');
             $oNextProduct->modifyCacheKey('_locator');
             $oNextProduct->setNoVariantLoading(true);
             if ($oNextProduct->load($aIds[$iPos + 1])) {
                 $oNextProduct->setLinkType($oLocatorTarget->getLinkType());
                 $this->_oNextProduct = $oNextProduct;
             }
         }
         return $iPos + 1;
     }
     return 0;
 }
Example #14
0
/**
 * parse SimpleXMLElement instance property parameters and return iCalcreator property parameter array
 *
 * @author Kjell-Inge Gustafsson, kigkonsult <*****@*****.**>
 * @since  2.11.2 - 2012-01-15
 * @param  object $parameters SimpleXMLElement
 * @return array  iCalcreator property parameter array
 */
function _getXMLParams(&$parameters)
{
    if (1 > $parameters->count()) {
        return array();
    }
    $params = array();
    foreach ($parameters->children() as $parameter) {
        // single parameter key
        $key = strtoupper($parameter->getName());
        $value = array();
        foreach ($parameter->children() as $paramValue) {
            // skip parameter value type
            $value[] = reset($paramValue);
        }
        if (2 > count($value)) {
            $params[$key] = html_entity_decode(reset($value));
        } else {
            $params[$key] = $value;
        }
    }
    return $params;
}
Example #15
0
 /**
  * Turn a list of rows into a tree
  *
  * @param   object  $rows
  * @return  array
  */
 public function toTree($rows)
 {
     $results = array();
     if ($rows->count() > 0) {
         $children = array(0 => array());
         foreach ($rows as $row) {
             $pt = $row->get('parent');
             $list = @$children[$pt] ? $children[$pt] : array();
             array_push($list, $row);
             $children[$pt] = $list;
         }
         $results = $this->treeRecurse($children[0], $children);
     }
     return $results;
 }
 /**
  * Assigns values of selection list to variants
  *
  * @param array  $aValues        multilang values of selection list
  * @param object $oVariants      variant list
  * @param object $oArticle       parent article
  * @param array  $aConfLanguages array of all active languages
  *
  * @return mixed
  */
 protected function _assignValues($aValues, $oVariants, $oArticle, $aConfLanguages)
 {
     $myConfig = $this->getConfig();
     $myLang = oxRegistry::getLang();
     $iCounter = 0;
     $aVarselect = array();
     //multilanguage names of existing variants
     //iterating through all select list values (eg. $oValue->name = S, M, X, XL)
     for ($i = 0; $i < count($aValues); $i++) {
         $oValue = $aValues[$i][0];
         $dPriceMod = $this->_getValuePrice($oValue, $oArticle->oxarticles__oxprice->value);
         if ($oVariants->count() > 0) {
             //if we have any existing variants then copying each variant with $oValue->name
             foreach ($oVariants as $oSimpleVariant) {
                 if (!$iCounter) {
                     //we just update the first variant
                     $oVariant = oxNew("oxarticle");
                     $oVariant->setEnableMultilang(false);
                     $oVariant->load($oSimpleVariant->oxarticles__oxid->value);
                     $oVariant->oxarticles__oxprice->setValue($oVariant->oxarticles__oxprice->value + $dPriceMod);
                     //assign for all languages
                     foreach ($aConfLanguages as $sKey => $sLang) {
                         $oValue = $aValues[$i][$sKey];
                         $sPrefix = $myLang->getLanguageTag($sKey);
                         $aVarselect[$oSimpleVariant->oxarticles__oxid->value][$sKey] = $oVariant->{"oxarticles__oxvarselect" . $sPrefix}->value;
                         $oVariant->{'oxarticles__oxvarselect' . $sPrefix}->setValue($oVariant->{"oxarticles__oxvarselect" . $sPrefix}->value . $this->_sMdSeparator . $oValue->name);
                     }
                     $oVariant->oxarticles__oxsort->setValue($oVariant->oxarticles__oxsort->value * 10);
                     $oVariant->save();
                     $sVarId = $oSimpleVariant->oxarticles__oxid->value;
                 } else {
                     //we create new variants
                     foreach ($aVarselect[$oSimpleVariant->oxarticles__oxid->value] as $sKey => $sVarselect) {
                         $oValue = $aValues[$i][$sKey];
                         $sPrefix = $myLang->getLanguageTag($sKey);
                         $aParams['oxarticles__oxvarselect' . $sPrefix] = $sVarselect . $this->_sMdSeparator . $oValue->name;
                     }
                     $aParams['oxarticles__oxartnum'] = $oSimpleVariant->oxarticles__oxartnum->value . "-" . $iCounter;
                     $aParams['oxarticles__oxprice'] = $oSimpleVariant->oxarticles__oxprice->value + $dPriceMod;
                     $aParams['oxarticles__oxsort'] = $oSimpleVariant->oxarticles__oxsort->value * 10 + 10 * $iCounter;
                     $aParams['oxarticles__oxstock'] = 0;
                     $aParams['oxarticles__oxstockflag'] = $oSimpleVariant->oxarticles__oxstockflag->value;
                     $aParams['oxarticles__oxisconfigurable'] = $oSimpleVariant->oxarticles__oxisconfigurable->value;
                     $sVarId = $this->_createNewVariant($aParams, $oArticle->oxarticles__oxid->value);
                     if ($myConfig->getConfigParam('blUseMultidimensionVariants')) {
                         $oAttrList = oxNew('oxattribute');
                         $aIds = $oAttrList->getAttributeAssigns($oSimpleVariant->oxarticles__oxid->value);
                         $aMDVariants["mdvar_" . $sVarId] = $aIds;
                     }
                 }
                 if ($myConfig->getConfigParam('blUseMultidimensionVariants')) {
                     $aMDVariants[$sVarId] = $aValues[$i];
                 }
             }
             $iCounter++;
         } else {
             //in case we don't have any variants then we just create variant(s) with $oValue->name
             $iCounter++;
             foreach ($aConfLanguages as $sKey => $sLang) {
                 $oValue = $aValues[$i][$sKey];
                 $sPrefix = $myLang->getLanguageTag($sKey);
                 $aParams['oxarticles__oxvarselect' . $sPrefix] = $oValue->name;
             }
             $aParams['oxarticles__oxartnum'] = $oArticle->oxarticles__oxartnum->value . "-" . $iCounter;
             $aParams['oxarticles__oxprice'] = $oArticle->oxarticles__oxprice->value + $dPriceMod;
             $aParams['oxarticles__oxsort'] = $iCounter * 100;
             // reduction
             $aParams['oxarticles__oxstock'] = 0;
             $aParams['oxarticles__oxstockflag'] = $oArticle->oxarticles__oxstockflag->value;
             $aParams['oxarticles__oxisconfigurable'] = $oArticle->oxarticles__oxisconfigurable->value;
             $sVarId = $this->_createNewVariant($aParams, $oArticle->oxarticles__oxid->value);
             if ($myConfig->getConfigParam('blUseMultidimensionVariants')) {
                 $aMDVariants[$sVarId] = $aValues[$i];
             }
         }
     }
     return $aMDVariants;
 }
Example #17
0
 /**
  * Cleans the forms data, and populates the errors and cleaned_data.
  *
  * @return null
  */
 protected function fullClean()
 {
     /**
      * Set up our empty error dict.
      */
     $this->_errors = new DForms_Errors_ErrorDict();
     /**
      * Only clean bound forms.
      */
     if (!$this->is_bound) {
         return;
     }
     /**
      * Set up the cleaned data array.
      */
     $this->cleaned_data = array();
     /**
      * Bail early if the form hasn't changed and it's ok to be empty.
      */
     if ($this->empty_permitted and !$this->hasChanged()) {
         return;
     }
     /**
      * Clean each field individually.
      */
     foreach ($this->fields as $name => &$field) {
         /**
          * Get the uncleaned, preparsed value from the field widget.
          */
         $value = $field->widget->valueFromData($this->data, $this->files, $this->addPrefix($name));
         /**
          * Catch any validation errors for this field.
          */
         try {
             /**
              * Pass initial data to file fields only
              */
             if ($field instanceof DForms_Fields_FileField) {
                 /**
                  * Initial data on the form takes precedence over the field.
                  */
                 if (array_key_exists($this->initial, $name)) {
                     $initial = $this->initial[$name];
                 } else {
                     $initial = $field->initial;
                 }
                 /**
                  * Get the file field cleaned value.
                  */
                 $value = $field->clean($value, $initial);
             } else {
                 /**
                  * Get the field cleaned value.
                  */
                 $value = $field->clean($value);
             }
             /**
              * Store the cleaned value for this field.
              */
             $this->cleaned_data[$name] = $value;
             /**
              * Look for field specific cleaning method on this form class.
              *
              * .. note:: These special methods are not in camel case... yet.
              */
             if (method_exists($this, 'clean_' . $name)) {
                 /**
                  * Field specific clean functions do not recieve a value.
                  */
                 $value = call_user_func(array($this, 'clean_' . $name));
                 /**
                  * Store the new field value.
                  */
                 $this->cleaned_data[$name] = $value;
             }
         } catch (DForms_Errors_ValidationError $e) {
             /**
              * Create an error object to store the field validation error.
              */
             $error = new $this->error_class(array($e->getMessage()));
             /**
              * Add the error to the form errors keyed off the field name.
              */
             $this->_errors[$name] = $error;
             /**
              * Remove the cleaned data for the errored field.
              */
             if (array_key_exists($name, $this->cleaned_data)) {
                 unset($this->cleaned_data[$name]);
             }
         }
     }
     unset($field);
     /**
      * Run the form's global clean function.
      */
     try {
         /**
          * Store the modified cleaned data.
          */
         $this->cleaned_data = $this->clean();
     } catch (DForms_Errors_ValidationError $e) {
         /**
          * Create an error object to store the global validation error.
          */
         $error = new $this->error_class(array($e->getMessage()));
         /**
          * Add the error to the form errors with the special global key.
          */
         $this->_errors[self::NON_FIELD_ERRORS] = $error;
     }
     /**
      * Remove cleaned_data property if there was an error.
      */
     if ($this->_errors->count()) {
         unset($this->cleaned_data);
     }
 }
 /**
  * Gives the number of items in the iterator
  * 
  * @return integer
  * @access public
  * @since 8/31/05
  */
 function count()
 {
     return $this->_nodeIterator->count();
 }
Example #19
0
/**
 * Converts an DAO object to an array
 *
 * @param  object $dao (reference )object to convert
 * @param null $params
 * @param bool $uniqueFields
 * @param string $entity
 *
 * @param bool $autoFind
 *
 * @return array
 *
 * @params array of arrays (key = id) of array of fields
 *
 * @static void
 * @access public
 */
function _civicrm_api3_dao_to_array($dao, $params = NULL, $uniqueFields = TRUE, $entity = "", $autoFind = TRUE)
{
    $result = array();
    if (isset($params['options']) && !empty($params['options']['is_count'])) {
        return $dao->count();
    }
    if (empty($dao)) {
        return array();
    }
    if ($autoFind && !$dao->find()) {
        return array();
    }
    if (isset($dao->count)) {
        return $dao->count;
    }
    $fields = array_keys(_civicrm_api3_build_fields_array($dao, $uniqueFields));
    while ($dao->fetch()) {
        $tmp = array();
        foreach ($fields as $key) {
            if (array_key_exists($key, $dao)) {
                // not sure on that one
                if ($dao->{$key} !== NULL) {
                    $tmp[$key] = $dao->{$key};
                }
            }
        }
        $result[$dao->id] = $tmp;
        if (_civicrm_api3_custom_fields_are_required($entity, $params)) {
            _civicrm_api3_custom_data_get($result[$dao->id], $entity, $dao->id);
        }
    }
    return $result;
}
Example #20
0
 /**
  * Returns true/false as to whether this node
  * has any child nodes or not.
  *
  * @return bool Any child nodes or not
  */
 public function hasChildren()
 {
     return $this->nodes->count() > 0;
 }
 /**
  * Get count
  * @return integer
  */
 public function getCount()
 {
     return $this->paginator->count();
 }
 /**
  * Reset the records
  */
 public function rewind()
 {
     $this->objCollection->reset();
     $this->blnValid = $this->objCollection->count() > 0;
 }
 /**
  * Reset the records
  */
 public function rewind()
 {
     $this->objResult->reset();
     $this->blnValid = $this->objResult->count() > 0;
 }
Example #24
0
/**
 * Converts an DAO object to an array
 *
 * @param  object $dao           (reference )object to convert
 * @param null $params
 * @param bool $uniqueFields
 * @param string $entity
 *
 * @return array
 *
 * @params array of arrays (key = id) of array of fields
 *
 * @static void
 * @access public
 */
function _civicrm_api3_dao_to_array($dao, $params = NULL, $uniqueFields = TRUE, $entity = "")
{
    $result = array();
    if (isset($params['options']) && !empty($params['options']['is_count'])) {
        return $dao->count();
    }
    if (empty($dao) || !$dao->find()) {
        return array();
    }
    if (isset($dao->count)) {
        return $dao->count;
    }
    //if custom fields are required we will endeavour to set them . NB passing $entity in might be a bit clunky / unrequired
    if (!empty($entity) && !empty($params['return']) && is_array($params['return'])) {
        foreach ($params['return'] as $return) {
            if (substr($return, 0, 6) == 'custom') {
                $custom = TRUE;
            }
        }
    }
    $fields = array_keys(_civicrm_api3_build_fields_array($dao, $uniqueFields));
    while ($dao->fetch()) {
        $tmp = array();
        foreach ($fields as $key) {
            if (array_key_exists($key, $dao)) {
                // not sure on that one
                if ($dao->{$key} !== NULL) {
                    $tmp[$key] = $dao->{$key};
                }
            }
        }
        $result[$dao->id] = $tmp;
        if (!empty($custom)) {
            _civicrm_api3_custom_data_get($result[$dao->id], $entity, $dao->id);
        }
    }
    return $result;
}
Example #25
0
 /**
  * Get the total number of entities
  *
  * @return  int
  */
 public function count()
 {
     //Reset the model
     return $this->__model->count();
 }
 /**
  * Is sorter ordered by desc
  *
  * @param  string $name
  * @param  string $column
  *
  * @return boolan
  */
 public function desc($name, $column)
 {
     $desc = $this->sorter->count(['name' => $name, 'column' => $column, 'desc' => true, 'user_id' => Auth::user()->id]);
     return $desc > 0;
 }