Example #1
0
 /**
  * @return array
  */
 public function findListTypes()
 {
     $results = array();
     App::import('Core', 'GummFile');
     $CssFile = new GummFile(get_stylesheet_directory() . DS . 'style.css');
     $cssContents = $CssFile->read();
     if (preg_match("'/\\* -{3,} list styles -{3,} \\*/(.*)/\\* -{3,} end list styles -{3,} \\*/'imsU", $cssContents, $listDeclarationMatches)) {
         if (preg_match_all("'ul\\.sc-list\\.([a-zA-Z-_]+)\\s.*\\{.*background-image\\s?\\:\\s?url\\((.*)\\).*\\}'imsU", $listDeclarationMatches[1], $listTypesMatches)) {
             for ($i = 0; $i < count($listTypesMatches[0]); $i++) {
                 $results[] = array('name' => Inflector::humanize($listTypesMatches[1][$i]), 'class' => $listTypesMatches[1][$i], 'icon' => array('url' => GUMM_THEME_URL . '/' . $listTypesMatches[2][$i], 'repeat' => 'no-repeat', 'position' => 'center'), 'types' => false);
             }
         }
     }
     return $results;
 }
 /**
  * @param string $path
  * @param array $elementParams
  * @return void
  */
 public function __construct($path, $params = array())
 {
     parent::__construct($path);
     $data = $this->read();
     if (preg_match("'params = {.*}'ims", $data, $elementParams)) {
         $elementParams = preg_replace("'\\s?\\*\\s?'imsU", ' ', $elementParams[0]);
         $elementParams = str_replace('params = ', '', $elementParams);
         $elementParams = json_decode($elementParams, true);
         if (isset($elementParams['fields'])) {
             $this->fields = $this->_filterParams((array) $elementParams['fields']);
         }
     }
     $params = Set::merge($elementParams, (array) $params);
     $this->_init((array) $params);
 }